@epic-web/workshop-app 4.22.4 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. package/build/client/assets/_-Cv8HqtE8.js +2 -0
  2. package/build/client/assets/{_-DbrWZazo.js.map → _-Cv8HqtE8.js.map} +1 -1
  3. package/build/client/assets/_exerciseNumber-D2tXimAK.js +2 -0
  4. package/build/client/assets/{_exerciseNumber-CpcJsfoV.js.map → _exerciseNumber-D2tXimAK.js.map} +1 -1
  5. package/build/client/assets/_exerciseNumber_._stepNumber-CquNe5XV.js +2 -0
  6. package/build/client/assets/{_exerciseNumber_._stepNumber-B5pmJ29o.js.map → _exerciseNumber_._stepNumber-CquNe5XV.js.map} +1 -1
  7. package/build/client/assets/_exerciseNumber_.finished-B-sqDk3j.js +2 -0
  8. package/build/client/assets/{_exerciseNumber_.finished-Ddb3J5ls.js.map → _exerciseNumber_.finished-B-sqDk3j.js.map} +1 -1
  9. package/build/client/assets/_layout-C7yUCsjZ.js +2 -0
  10. package/build/client/assets/{_layout-DVR5FOsb.js.map → _layout-C7yUCsjZ.js.map} +1 -1
  11. package/build/client/assets/_layout-C9AozQxr.js +6 -0
  12. package/build/client/assets/_layout-C9AozQxr.js.map +1 -0
  13. package/build/client/assets/{_layout-BUs3av-e.js → _layout-CRkVkufr.js} +2 -2
  14. package/build/client/assets/{_layout-BUs3av-e.js.map → _layout-CRkVkufr.js.map} +1 -1
  15. package/build/client/assets/_layout-Ciyqvptc.js +2 -0
  16. package/build/client/assets/{_layout-CGLKLU3y.js.map → _layout-Ciyqvptc.js.map} +1 -1
  17. package/build/client/assets/accordion-B-gQ5Whz.js +2 -0
  18. package/build/client/assets/{accordion-BroSqIct.js.map → accordion-B-gQ5Whz.js.map} +1 -1
  19. package/build/client/assets/account-B-3k5HDM.js +2 -0
  20. package/build/client/assets/{account-7o6O4ruO.js.map → account-B-3k5HDM.js.map} +1 -1
  21. package/build/client/assets/app-DAWCzuDw.js +2 -0
  22. package/build/client/assets/{app-BhrXo-z3.js.map → app-DAWCzuDw.js.map} +1 -1
  23. package/build/client/assets/{button-BklqyTPS.js → button-DataaIpW.js} +2 -2
  24. package/build/client/assets/{button-BklqyTPS.js.map → button-DataaIpW.js.map} +1 -1
  25. package/build/client/assets/{components-CME-nGId.js → components-BQB6wEvm.js} +18 -18
  26. package/build/client/assets/{components-CME-nGId.js.map → components-BQB6wEvm.js.map} +1 -1
  27. package/build/client/assets/diff-BWSOt7tL.js +2 -0
  28. package/build/client/assets/{diff-Cr4LLBag.js.map → diff-BWSOt7tL.js.map} +1 -1
  29. package/build/client/assets/diff-JWdZCc2F.js +2 -0
  30. package/build/client/assets/{diff-BNr0PhFR.js.map → diff-JWdZCc2F.js.map} +1 -1
  31. package/build/client/assets/{discord-Dq4e30wV.js → discord-BfUTLoVF.js} +2 -2
  32. package/build/client/assets/{discord-Dq4e30wV.js.map → discord-BfUTLoVF.js.map} +1 -1
  33. package/build/client/assets/discord-BqGuuhG3.js +2 -0
  34. package/build/client/assets/discord-BqGuuhG3.js.map +1 -0
  35. package/build/client/assets/{entry.client-3M2p-8I3.js → entry.client-7AjQ7fYK.js} +9 -9
  36. package/build/client/assets/{entry.client-3M2p-8I3.js.map → entry.client-7AjQ7fYK.js.map} +1 -1
  37. package/build/client/assets/{epic-video-CxZy3iqK.js → epic-video-D8tfMIv8.js} +96 -96
  38. package/build/client/assets/{epic-video-CxZy3iqK.js.map → epic-video-D8tfMIv8.js.map} +1 -1
  39. package/build/client/assets/{error-boundary-DDTvdkB4.js → error-boundary-Bx1mDmB-.js} +2 -2
  40. package/build/client/assets/{error-boundary-DDTvdkB4.js.map → error-boundary-Bx1mDmB-.js.map} +1 -1
  41. package/build/client/assets/finished-DvXH6L-Q.js +2 -0
  42. package/build/client/assets/{finished-CU8QBU41.js.map → finished-DvXH6L-Q.js.map} +1 -1
  43. package/build/client/assets/index-2WpY3jqc.js +37 -0
  44. package/build/client/assets/{index-1cKOJFpX.js.map → index-2WpY3jqc.js.map} +1 -1
  45. package/build/client/assets/{index-B-hHvmeV.js → index-Bt0Fs1uZ.js} +2 -2
  46. package/build/client/assets/{index-B-hHvmeV.js.map → index-Bt0Fs1uZ.js.map} +1 -1
  47. package/build/client/assets/{index-Dx5GmdYq.js → index-DGsreVfh.js} +2 -2
  48. package/build/client/assets/{index-Dx5GmdYq.js.map → index-DGsreVfh.js.map} +1 -1
  49. package/build/client/assets/index-DmASob5Y.js +2 -0
  50. package/build/client/assets/{index-BotyhhDm.js.map → index-DmASob5Y.js.map} +1 -1
  51. package/build/client/assets/index-TIHEbU65.js +36 -0
  52. package/build/client/assets/index-TIHEbU65.js.map +1 -0
  53. package/build/client/assets/{index-hogig2HK.js → index-aPMCrDDW.js} +2 -2
  54. package/build/client/assets/{index-hogig2HK.js.map → index-aPMCrDDW.js.map} +1 -1
  55. package/build/client/assets/{index-BXWoOGxB.js → index-bM_TIo_p.js} +2 -2
  56. package/build/client/assets/{index-BXWoOGxB.js.map → index-bM_TIo_p.js.map} +1 -1
  57. package/build/client/assets/index-kXas9qNh.js +2 -0
  58. package/build/client/assets/{index-c5oITeyN.js.map → index-kXas9qNh.js.map} +1 -1
  59. package/build/client/assets/loading-DXKqMYHW.js +2 -0
  60. package/build/client/assets/{loading-C5uX0jJw.js.map → loading-DXKqMYHW.js.map} +1 -1
  61. package/build/client/assets/login-WXKB-OYe.js +2 -0
  62. package/build/client/assets/login-WXKB-OYe.js.map +1 -0
  63. package/build/client/assets/manifest-5edda375.js +1 -0
  64. package/build/client/assets/mdx-D0cZm8uP.js +2 -0
  65. package/build/client/assets/{mdx-D7ttfz2V.js.map → mdx-D0cZm8uP.js.map} +1 -1
  66. package/build/client/assets/misc-LevbAJZ6.js +2 -0
  67. package/build/client/assets/misc-LevbAJZ6.js.map +1 -0
  68. package/build/client/assets/{nav-chevrons-B82nbdyj.js → nav-chevrons-BB1CK34B.js} +2 -2
  69. package/build/client/assets/{nav-chevrons-B82nbdyj.js.map → nav-chevrons-BB1CK34B.js.map} +1 -1
  70. package/build/client/assets/onboarding-CK8-hFDT.js +2 -0
  71. package/build/client/assets/{onboarding-Co4cldZ0.js.map → onboarding-CK8-hFDT.js.map} +1 -1
  72. package/build/client/assets/{pe-CUZaIcdt.js → pe-BmTNRcy_.js} +2 -2
  73. package/build/client/assets/{pe-CUZaIcdt.js.map → pe-BmTNRcy_.js.map} +1 -1
  74. package/build/client/assets/{presence-Cr--lRCr.js → presence-CmTnJPJh.js} +2 -2
  75. package/build/client/assets/{presence-Cr--lRCr.js.map → presence-CmTnJPJh.js.map} +1 -1
  76. package/build/client/assets/preview-BbJZ7UrX.js +2 -0
  77. package/build/client/assets/{preview-CdiZ0d0L.js.map → preview-BbJZ7UrX.js.map} +1 -1
  78. package/build/client/assets/product-Bi2uble-.js +2 -0
  79. package/build/client/assets/product-Bi2uble-.js.map +1 -0
  80. package/build/client/assets/{progress-bar-CSvo1ZXP.js → progress-bar-HYCoNAkN.js} +2 -2
  81. package/build/client/assets/{progress-bar-CSvo1ZXP.js.map → progress-bar-HYCoNAkN.js.map} +1 -1
  82. package/build/client/assets/{progress-Biq-ngNF.js → progress-fFpCuCyE.js} +2 -2
  83. package/build/client/assets/{progress-Biq-ngNF.js.map → progress-fFpCuCyE.js.map} +1 -1
  84. package/build/client/assets/{request-info-CEhUGODY.js → request-info-D6MPpnDd.js} +2 -2
  85. package/build/client/assets/{request-info-CEhUGODY.js.map → request-info-D6MPpnDd.js.map} +1 -1
  86. package/build/client/assets/{root-D_FY953d.js → root-CY8QRU4e.js} +6 -6
  87. package/build/client/assets/{root-D_FY953d.js.map → root-CY8QRU4e.js.map} +1 -1
  88. package/build/client/assets/set-playground-8-BH15HT.js +2 -0
  89. package/build/client/assets/{set-playground-BXHckvUG.js.map → set-playground-8-BH15HT.js.map} +1 -1
  90. package/build/client/assets/{support-hcqGIpir.js → support-l4EbxG8X.js} +2 -2
  91. package/build/client/assets/{support-hcqGIpir.js.map → support-l4EbxG8X.js.map} +1 -1
  92. package/build/client/assets/test--z-MS4Cz.js +2 -0
  93. package/build/client/assets/{test-BRkbo9G9.js.map → test--z-MS4Cz.js.map} +1 -1
  94. package/build/client/assets/{tests-DQuoxpDA.js → tests-CNclXTWp.js} +2 -2
  95. package/build/client/assets/{tests-DQuoxpDA.js.map → tests-CNclXTWp.js.map} +1 -1
  96. package/build/client/assets/{tooltip-BiHTe_7F.js → tooltip-Blm9zu1K.js} +2 -2
  97. package/build/client/assets/{tooltip-BiHTe_7F.js.map → tooltip-Blm9zu1K.js.map} +1 -1
  98. package/build/client/assets/{use-event-source-A_0lEOPX.js → use-event-source-C81lzj_8.js} +2 -2
  99. package/build/client/assets/{use-event-source-A_0lEOPX.js.map → use-event-source-C81lzj_8.js.map} +1 -1
  100. package/build/client/assets/{user-D6tTg1yS.js → user-2ca9K5af.js} +2 -2
  101. package/build/client/assets/{user-D6tTg1yS.js.map → user-2ca9K5af.js.map} +1 -1
  102. package/build/client/assets/workshop-config-COvWTBns.js +2 -0
  103. package/build/client/assets/workshop-config-COvWTBns.js.map +1 -0
  104. package/build/client/icons.svg +541 -526
  105. package/build/client/logo.svg +48 -0
  106. package/build/server/index.js +155 -80
  107. package/build/server/index.js.map +1 -1
  108. package/package.json +3 -3
  109. package/build/client/assets/_-DbrWZazo.js +0 -2
  110. package/build/client/assets/_exerciseNumber-CpcJsfoV.js +0 -2
  111. package/build/client/assets/_exerciseNumber_._stepNumber-B5pmJ29o.js +0 -2
  112. package/build/client/assets/_exerciseNumber_.finished-Ddb3J5ls.js +0 -2
  113. package/build/client/assets/_layout-BLsKV5zF.js +0 -6
  114. package/build/client/assets/_layout-BLsKV5zF.js.map +0 -1
  115. package/build/client/assets/_layout-CGLKLU3y.js +0 -2
  116. package/build/client/assets/_layout-DVR5FOsb.js +0 -2
  117. package/build/client/assets/accordion-BroSqIct.js +0 -2
  118. package/build/client/assets/account-7o6O4ruO.js +0 -2
  119. package/build/client/assets/app-BhrXo-z3.js +0 -2
  120. package/build/client/assets/client-hints-DNUUFGmB.js +0 -36
  121. package/build/client/assets/client-hints-DNUUFGmB.js.map +0 -1
  122. package/build/client/assets/clsx-B-dksMZM.js +0 -2
  123. package/build/client/assets/clsx-B-dksMZM.js.map +0 -1
  124. package/build/client/assets/diff-BNr0PhFR.js +0 -2
  125. package/build/client/assets/diff-Cr4LLBag.js +0 -2
  126. package/build/client/assets/discord-CHP4_JLJ.js +0 -2
  127. package/build/client/assets/discord-CHP4_JLJ.js.map +0 -1
  128. package/build/client/assets/finished-CU8QBU41.js +0 -2
  129. package/build/client/assets/index-1cKOJFpX.js +0 -37
  130. package/build/client/assets/index-6GyYWV9G.js +0 -2
  131. package/build/client/assets/index-6GyYWV9G.js.map +0 -1
  132. package/build/client/assets/index-BotyhhDm.js +0 -2
  133. package/build/client/assets/index-c5oITeyN.js +0 -2
  134. package/build/client/assets/loading-C5uX0jJw.js +0 -2
  135. package/build/client/assets/login-4cvVFzF8.js +0 -2
  136. package/build/client/assets/login-4cvVFzF8.js.map +0 -1
  137. package/build/client/assets/manifest-da85ee1f.js +0 -1
  138. package/build/client/assets/mdx-D7ttfz2V.js +0 -2
  139. package/build/client/assets/misc-ENVX3CWf.js +0 -2
  140. package/build/client/assets/misc-ENVX3CWf.js.map +0 -1
  141. package/build/client/assets/onboarding-Co4cldZ0.js +0 -2
  142. package/build/client/assets/preview-CdiZ0d0L.js +0 -2
  143. package/build/client/assets/set-playground-BXHckvUG.js +0 -2
  144. package/build/client/assets/test-BRkbo9G9.js +0 -2
@@ -1,5 +1,5 @@
1
- import{R as Dd,r as pt,j as W}from"./index-1cKOJFpX.js";import{u as h_}from"./index-6GyYWV9G.js";import{z as Gc}from"./request-info-CEhUGODY.js";import{e as f_,c as m_,I as p_}from"./misc-ENVX3CWf.js";import{a as g_,e as v_,A as E_,L as vo}from"./components-CME-nGId.js";import{L as rm}from"./loading-C5uX0jJw.js";import{b as b_}from"./user-D6tTg1yS.js";var y_=Object.create,av=Object.defineProperty,T_=Object.getOwnPropertyDescriptor,__=Object.getOwnPropertyNames,A_=Object.getPrototypeOf,S_=Object.prototype.hasOwnProperty,ov=function(i,e){return function(){return i&&(e=i(i=0)),e}},vt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},x_=function(i,e,t,s){if(e&&typeof e=="object"||typeof e=="function")for(var r=__(e),n=0,a=r.length,o;n<a;n++)o=r[n],!S_.call(i,o)&&o!==t&&av(i,o,{get:(function(l){return e[l]}).bind(null,o),enumerable:!(s=T_(e,o))||s.enumerable});return i},Dt=function(i,e,t){return t=i!=null?y_(A_(i)):{},x_(!i||!i.__esModule?av(t,"default",{value:i,enumerable:!0}):t,i)},Ui=vt(function(i,e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={},e.exports=t});function yt(i){"@swc/helpers - typeof";return i&&typeof Symbol<"u"&&i.constructor===Symbol?"symbol":typeof i}var Sc=ov(function(){}),k_=vt(function(i,e){Sc(),function(t,s){typeof define=="function"&&define.amd?define(s):typeof e=="object"&&e.exports?e.exports=s():t.log=s()}(i,function(){var t=function(){},s="undefined",r=(typeof window>"u"?"undefined":yt(window))!==s&&yt(window.navigator)!==s&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function a(g,v){var y=g[v];if(typeof y.bind=="function")return y.bind(g);try{return Function.prototype.bind.call(y,g)}catch{return function(){return Function.prototype.apply.apply(y,[g,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(g){return g==="debug"&&(g="log"),(typeof console>"u"?"undefined":yt(console))===s?!1:g==="trace"&&r?o:console[g]!==void 0?a(console,g):console.log!==void 0?a(console,"log"):t}function d(g,v){for(var y=0;y<n.length;y++){var b=n[y];this[b]=y<g?t:this.methodFactory(b,g,v)}this.log=this.debug}function c(g,v,y){return function(){(typeof console>"u"?"undefined":yt(console))!==s&&(d.call(this,v,y),this[g].apply(this,arguments))}}function u(g,v,y){return l(g)||c.apply(this,arguments)}function h(g,v,y){var b=this,x;v=v??"WARN";var _="loglevel";typeof g=="string"?_+=":"+g:(typeof g>"u"?"undefined":yt(g))==="symbol"&&(_=void 0);function S(L){var C=(n[L]||"silent").toUpperCase();if(!((typeof window>"u"?"undefined":yt(window))===s||!_)){try{window.localStorage[_]=C;return}catch{}try{window.document.cookie=encodeURIComponent(_)+"="+C+";"}catch{}}}function A(){var L;if(!((typeof window>"u"?"undefined":yt(window))===s||!_)){try{L=window.localStorage[_]}catch{}if((typeof L>"u"?"undefined":yt(L))===s)try{var C=window.document.cookie,H=C.indexOf(encodeURIComponent(_)+"=");H!==-1&&(L=/^([^;]+)/.exec(C.slice(H))[1])}catch{}return b.levels[L]===void 0&&(L=void 0),L}}function D(){if(!((typeof window>"u"?"undefined":yt(window))===s||!_)){try{window.localStorage.removeItem(_);return}catch{}try{window.document.cookie=encodeURIComponent(_)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}b.name=g,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=y||u,b.getLevel=function(){return x},b.setLevel=function(L,C){if(typeof L=="string"&&b.levels[L.toUpperCase()]!==void 0&&(L=b.levels[L.toUpperCase()]),typeof L=="number"&&L>=0&&L<=b.levels.SILENT){if(x=L,C!==!1&&S(L),d.call(b,L,g),(typeof console>"u"?"undefined":yt(console))===s&&L<b.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+L},b.setDefaultLevel=function(L){v=L,A()||b.setLevel(L,!1)},b.resetLevel=function(){b.setLevel(v,!1),D()},b.enableAll=function(L){b.setLevel(b.levels.TRACE,L)},b.disableAll=function(L){b.setLevel(b.levels.SILENT,L)};var O=A();O==null&&(O=v),b.setLevel(O,!1)}var f=new h,m={};f.getLogger=function(g){if((typeof g>"u"?"undefined":yt(g))!=="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var v=m[g];return v||(v=m[g]=new h(g,f.getLevel(),f.methodFactory)),v};var p=(typeof window>"u"?"undefined":yt(window))!==s?window.log:void 0;return f.noConflict=function(){return(typeof window>"u"?"undefined":yt(window))!==s&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return m},f.default=f,f})});function kr(i,e){return e!=null&&typeof Symbol<"u"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):kr(i,e)}var Lr=ov(function(){Lr()}),L_=vt(function(i){var e=Object.prototype.hasOwnProperty,t;function s(o){try{return decodeURIComponent(o.replace(/\+/g," "))}catch{return null}}function r(o){try{return encodeURIComponent(o)}catch{return null}}function n(o){for(var l=/([^=?#&]+)=?([^&]*)/g,d={},c;c=l.exec(o);){var u=s(c[1]),h=s(c[2]);u===null||h===null||u in d||(d[u]=h)}return d}function a(o,l){l=l||"";var d=[],c,u;typeof l!="string"&&(l="?");for(u in o)if(e.call(o,u)){if(c=o[u],!c&&(c===null||c===t||isNaN(c))&&(c=""),u=r(u),c=r(c),u===null||c===null)continue;d.push(u+"="+c)}return d.length?l+d.join("&"):""}i.stringify=a,i.parse=n}),I_=vt(function(i,e){(function(t){var s=!1;if(typeof define=="function"&&define.amd&&(define(t),s=!0),typeof i=="object"&&(e.exports=t(),s=!0),!s){var r=window.Cookies,n=window.Cookies=t();n.noConflict=function(){return window.Cookies=r,n}}})(function(){var t=function(){for(var r=0,n={};r<arguments.length;r++){var a=arguments[r];for(var o in a)n[o]=a[o]}return n};function s(r){function n(a,o,l){var d;if(typeof document<"u"){if(arguments.length>1){if(l=t({path:"/"},n.defaults,l),typeof l.expires=="number"){var c=new Date;c.setMilliseconds(c.getMilliseconds()+l.expires*864e5),l.expires=c}try{d=JSON.stringify(o),/^[\{\[]/.test(d)&&(o=d)}catch{}return r.write?o=r.write(o,a):o=encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),a=encodeURIComponent(String(a)),a=a.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),a=a.replace(/[\(\)]/g,escape),document.cookie=[a,"=",o,l.expires?"; expires="+l.expires.toUTCString():"",l.path?"; path="+l.path:"",l.domain?"; domain="+l.domain:"",l.secure?"; secure":""].join("")}a||(d={});for(var u=document.cookie?document.cookie.split("; "):[],h=/(%[0-9A-Z]{2})+/g,f=0;f<u.length;f++){var m=u[f].split("="),p=m.slice(1).join("=");p.charAt(0)==='"'&&(p=p.slice(1,-1));try{var g=m[0].replace(h,decodeURIComponent);if(p=r.read?r.read(p,g):r(p,g)||p.replace(h,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch{}if(a===g){d=p;break}a||(d[g]=p)}catch{}}return d}}return n.set=n,n.get=function(a){return n.call(n,a)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(a,o){n(a,"",t(o,{expires:-1}))},n.withConverter=s,n}return s(function(){})})}),lv=vt(function(i,e){var t=Array.prototype.slice;e.exports=s;function s(r,n){for(("length"in r)||(r=[r]),r=t.call(r);r.length;){var a=r.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(r=t.call(a.childNodes).concat(r))}}}),R_=vt(function(i,e){Lr(),e.exports=t;function t(s,r){if(!kr(this,t))return new t(s,r);this.data=s,this.nodeValue=s,this.length=s.length,this.ownerDocument=r||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),w_=vt(function(i,e){Lr(),e.exports=t;function t(s,r){if(!kr(this,t))return new t(s);this.data=s||"",this.length=this.data.length,this.ownerDocument=r||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(s,r,n){var a=this.data,o=a.substring(0,s),l=a.substring(s+r,a.length);this.data=o+n+l,this.length=this.data.length}}),dv=vt(function(i,e){e.exports=t;function t(s){var r=this,n=s.type;s.target||(s.target=r),r.listeners||(r.listeners={});var a=r.listeners[n];if(a)return a.forEach(function(o){s.currentTarget=r,typeof o=="function"?o(s):o.handleEvent(s)});r.parentNode&&r.parentNode.dispatchEvent(s)}}),cv=vt(function(i,e){e.exports=t;function t(s,r){var n=this;n.listeners||(n.listeners={}),n.listeners[s]||(n.listeners[s]=[]),n.listeners[s].indexOf(r)===-1&&n.listeners[s].push(r)}}),uv=vt(function(i,e){e.exports=t;function t(s,r){var n=this;if(n.listeners&&n.listeners[s]){var a=n.listeners[s],o=a.indexOf(r);o!==-1&&a.splice(o,1)}}}),C_=vt(function(i,e){Sc(),e.exports=s;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function s(h){switch(h.nodeType){case 3:return c(h.data);case 8:return"<!--"+h.data+"-->";default:return r(h)}}function r(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(s)):h.textContent||h.innerText?f.push(c(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=yt(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+u(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var v=h._attributes[p][g],y=(v.prefix?v.prefix+":":"")+g;f.push({name:y,value:v.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function c(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function u(h){return c(h).replace(/"/g,"&quot;")}}),hv=vt(function(i,e){Lr();var t=lv(),s=dv(),r=cv(),n=uv(),a=C_(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,c,u){if(!kr(this,l))return new l(d);var h=u===void 0?o:u||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=c||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,c){d.parentNode&&d.parentNode.removeChild(d);var u=this.childNodes.indexOf(c);return c.parentNode=null,this.childNodes[u]=d,d.parentNode=this,c},l.prototype.removeChild=function(d){var c=this.childNodes.indexOf(d);return this.childNodes.splice(c,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,c){d.parentNode&&d.parentNode.removeChild(d);var u=c==null?-1:this.childNodes.indexOf(c);return u>-1?this.childNodes.splice(u,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,c,u){var h=null,f=c,m=c.indexOf(":");if(m>-1&&(h=c.substr(0,m),f=c.substr(m+1)),this.tagName==="INPUT"&&c==="type")this.type=u;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:u,prefix:h}}},l.prototype.getAttributeNS=function(d,c){var u=this._attributes[d],h=u&&u[c]&&u[c].value;return this.tagName==="INPUT"&&c==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,c){var u=this._attributes[d];u&&delete u[c]},l.prototype.hasAttributeNS=function(d,c){var u=this._attributes[d];return!!u&&c in u},l.prototype.setAttribute=function(d,c){return this.setAttributeNS(null,d,c)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=r,l.prototype.dispatchEvent=s,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var c=d.split(" "),u=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");c.every(function(p){return m.indexOf(p)!==-1})&&u.push(h)}}),u},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var c=[];return t(this.childNodes,function(u){u.nodeType===1&&(d==="*"||u.tagName.toLowerCase()===d)&&c.push(u)}),c},l.prototype.contains=function(d){return t(this,function(c){return d===c})||!1}}),D_=vt(function(i,e){Lr();var t=hv();e.exports=s;function s(r){if(!kr(this,s))return new s;this.childNodes=[],this.parentNode=null,this.ownerDocument=r||null}s.prototype.type="DocumentFragment",s.prototype.nodeType=11,s.prototype.nodeName="#document-fragment",s.prototype.appendChild=t.prototype.appendChild,s.prototype.replaceChild=t.prototype.replaceChild,s.prototype.removeChild=t.prototype.removeChild,s.prototype.toString=function(){return this.childNodes.map(function(r){return String(r)}).join("")}}),M_=vt(function(i,e){e.exports=t;function t(s){}t.prototype.initEvent=function(s,r,n){this.type=s,this.bubbles=r,this.cancelable=n},t.prototype.preventDefault=function(){}}),O_=vt(function(i,e){Lr();var t=lv(),s=R_(),r=w_(),n=hv(),a=D_(),o=M_(),l=dv(),d=cv(),c=uv();e.exports=u;function u(){if(!kr(this,u))return new u;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=u.prototype;h.createTextNode=function(f){return new r(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new s(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=c,h.addEventListener=d,h.dispatchEvent=l}),P_=vt(function(i,e){var t=O_();e.exports=new t}),N_=vt(function(i,e){var t=typeof global<"u"?global:typeof window<"u"?window:{},s=P_(),r;typeof document<"u"?r=document:(r=t["__GLOBAL_DOCUMENT_CACHE@4"],r||(r=t["__GLOBAL_DOCUMENT_CACHE@4"]=s)),e.exports=r});function U_(i){if(Array.isArray(i))return i}function F_(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var s=[],r=!0,n=!1,a,o;try{for(t=t.call(i);!(r=(a=t.next()).done)&&(s.push(a.value),!(e&&s.length===e));r=!0);}catch(l){n=!0,o=l}finally{try{!r&&t.return!=null&&t.return()}finally{if(n)throw o}}return s}}function $_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mp(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=i[t];return s}function B_(i,e){if(i){if(typeof i=="string")return Mp(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Mp(i,e)}}function Tr(i,e){return U_(i)||F_(i,e)||B_(i,e)||$_()}var Da=Dt(Ui()),Ka=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i==="x"?e:e&3|8;return t.toString(16)})},fv=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},Ms=function(i){if(i&&typeof i.nodeName<"u")return i.muxId||(i.muxId=fv()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},Wu=function(i){var e;i&&typeof i.nodeName<"u"?(e=i,i=Ms(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]},Va=Dt(k_()),G_=Va.default.methodFactory;Va.default.methodFactory=function(i,e,t){var s=G_(i,e,t);return function(){for(var r=["[mux]"],n=0;n<arguments.length;n++)r.push(arguments[n]);s.apply(void 0,r)}};Va.default.setLevel(Va.default.getLevel());var Pe=Va.default,Hc=Dt(Ui());function Ku(){var i=Hc.default.doNotTrack||Hc.default.navigator&&Hc.default.navigator.doNotTrack;return i==="1"}var H_=Dt(Ui()),W_={now:function(){var i=H_.default.performance,e=i&&i.timing,t=e&&e.navigationStart,s=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(s)}},Qe=W_;function ne(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}Lr();function ct(i,e){if(!kr(i,e))throw new TypeError("Cannot call a class as a function")}function K_(i,e){for(var t=0;t<e.length;t++){var s=e[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(i,s.key,s)}}function Fi(i,e,t){return e&&K_(i.prototype,e),i}function B(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Vu(i,e){return Vu=Object.setPrototypeOf||function(t,s){return t.__proto__=s,t},Vu(i,e)}function V_(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Vu(i,e)}function Md(i){return Md=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Md(i)}function q_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Sc();function Y_(i,e){return e&&(yt(e)==="object"||typeof e=="function")?e:ne(i)}function j_(i){var e=q_();return function(){var t=Md(i),s;if(e){var r=Md(this).constructor;s=Reflect.construct(t,arguments,r)}else s=t.apply(this,arguments);return Y_(this,s)}}var Jt=function(i){return qa(i)[0]},qa=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],s=t[4],r;return s&&(r=(s.match(/[^\.]+\.[^\.]+$/)||[])[0]),[s,r]},Wc=Dt(Ui()),z_={exists:function(){var i=Wc.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=Wc.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=Wc.default.performance,e=i&&i.timing;return e&&e.navigationStart}},Od=z_;function We(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Pd(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},s=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(s=s.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),s.forEach(function(r){B(i,r,t[r])})}return i}function X_(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);t.push.apply(t,s)}return t}function nm(i,e){return e=e??{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):X_(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var Q_=["x-cdn","content-type"],mv=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],Z_=Q_.concat(mv);function am(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(s){if(s){var r=s.split(": "),n=r.shift();n&&(Z_.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=r.join(": "))}}),e}function Nd(i){if(i){var e=mv.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var J_=function(i){var e={};for(var t in i){var s=i[t],r=s["DATA-ID"].search("io.litix.data.");if(r!==-1){var n=s["DATA-ID"].replace("io.litix.data.","");e[n]=s.VALUE}}return e},pv=J_,Eo=function(i){if(!i)return{};var e=Od.navigationStart(),t=i.loading,s=t?t.start:i.trequest,r=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+s),responseStart:Math.round(e+r),responseEnd:Math.round(e+n)}},Wn=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return am(i.getAllResponseHeaders())},e1=function(i,e,t){var s=arguments.length>4?arguments[4]:void 0,r=i.log,n=i.utils.secondsToMs,a=function(g){var v=parseInt(s.version),y;return v===1&&g.programDateTime!==null&&(y=g.programDateTime),v===0&&g.pdt!==null&&(y=g.pdt),y};if(!Od.exists()){r.warn("performance timing not supported. Not tracking HLS.js.");return}var o=function(g,v){return i.emit(e,g,v)},l=function(g,v){var y=v.levels,b=v.audioTracks,x=v.url,_=v.stats,S=v.networkDetails,A=v.sessionData,D={},O={};y.forEach(function(q,Y){D[Y]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),b.forEach(function(q,Y){O[Y]={name:q.name,language:q.lang,bitrate:q.bitrate}});var L=Eo(_),C=L.bytesLoaded,H=L.requestStart,U=L.responseStart,Q=L.responseEnd;o("requestcompleted",nm(Pd({},pv(A)),{request_event_type:g,request_bytes_loaded:C,request_start:H,request_response_start:U,request_response_end:Q,request_type:"manifest",request_hostname:Jt(x),request_response_headers:Wn(S),request_rendition_lists:{media:D,audio:O,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,l);var d=function(g,v){var y=v.details,b=v.level,x=v.networkDetails,_=v.stats,S=Eo(_),A=S.bytesLoaded,D=S.requestStart,O=S.responseStart,L=S.responseEnd,C=y.fragments[y.fragments.length-1],H=a(C)+n(C.duration);o("requestcompleted",{request_event_type:g,request_bytes_loaded:A,request_start:D,request_response_start:O,request_response_end:L,request_current_level:b,request_type:"manifest",request_hostname:Jt(y.url),request_response_headers:Wn(x),video_holdback:y.holdBack&&n(y.holdBack),video_part_holdback:y.partHoldBack&&n(y.partHoldBack),video_part_target_duration:y.partTarget&&n(y.partTarget),video_target_duration:y.targetduration&&n(y.targetduration),video_source_is_live:y.live,player_manifest_newest_program_time:isNaN(H)?void 0:H})};t.on(s.Events.LEVEL_LOADED,d);var c=function(g,v){var y=v.details,b=v.networkDetails,x=v.stats,_=Eo(x),S=_.bytesLoaded,A=_.requestStart,D=_.responseStart,O=_.responseEnd;o("requestcompleted",{request_event_type:g,request_bytes_loaded:S,request_start:A,request_response_start:D,request_response_end:O,request_type:"manifest",request_hostname:Jt(y.url),request_response_headers:Wn(b)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var u=function(g,v){var y=v.stats,b=v.networkDetails,x=v.frag;y=y||x.stats;var _=Eo(y),S=_.bytesLoaded,A=_.requestStart,D=_.responseStart,O=_.responseEnd,L=b?Wn(b):void 0,C={request_event_type:g,request_bytes_loaded:S,request_start:A,request_response_start:D,request_response_end:O,request_hostname:b?Jt(b.responseURL):void 0,request_id:L?Nd(L):void 0,request_response_headers:L,request_media_duration:x.duration,request_url:b==null?void 0:b.responseURL};x.type==="main"?(C.request_type="media",C.request_current_level=x.level,C.request_video_width=(t.levels[x.level]||{}).width,C.request_video_height=(t.levels[x.level]||{}).height,C.request_labeled_bitrate=(t.levels[x.level]||{}).bitrate):C.request_type=x.type,o("requestcompleted",C)};t.on(s.Events.FRAG_LOADED,u);var h=function(g,v){var y=v.frag,b=y.start,x=a(y),_={currentFragmentPDT:x,currentFragmentStart:n(b)};o("fragmentchange",_)};t.on(s.Events.FRAG_CHANGED,h);var f=function(g,v){var y=v.type,b=v.details,x=v.response,_=v.fatal,S=v.frag,A=v.networkDetails,D=(S==null?void 0:S.url)||v.url||"",O=A?Wn(A):void 0;if((b===s.ErrorDetails.MANIFEST_LOAD_ERROR||b===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||b===s.ErrorDetails.FRAG_LOAD_ERROR||b===s.ErrorDetails.FRAG_LOAD_TIMEOUT||b===s.ErrorDetails.LEVEL_LOAD_ERROR||b===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||b===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||b===s.ErrorDetails.SUBTITLE_LOAD_ERROR||b===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||b===s.ErrorDetails.KEY_LOAD_ERROR||b===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&o("requestfailed",{request_error:b,request_url:D,request_hostname:Jt(D),request_id:O?Nd(O):void 0,request_type:b===s.ErrorDetails.FRAG_LOAD_ERROR||b===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":b===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":b===s.ErrorDetails.SUBTITLE_LOAD_ERROR||b===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":b===s.ErrorDetails.KEY_LOAD_ERROR||b===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:x==null?void 0:x.code,request_error_text:x==null?void 0:x.text}),_){var L,C="".concat(D?"url: ".concat(D,`
1
+ import{R as Dd,r as pt,j as W}from"./index-2WpY3jqc.js";import{u as h_}from"./index-TIHEbU65.js";import{z as Gc}from"./request-info-D6MPpnDd.js";import{f as f_,a as m_,I as p_}from"./misc-LevbAJZ6.js";import{a as g_,e as v_,A as E_,L as vo}from"./components-BQB6wEvm.js";import{L as rm}from"./loading-DXKqMYHW.js";import{b as b_}from"./user-2ca9K5af.js";import{u as y_}from"./workshop-config-COvWTBns.js";var T_=Object.create,av=Object.defineProperty,__=Object.getOwnPropertyDescriptor,A_=Object.getOwnPropertyNames,S_=Object.getPrototypeOf,x_=Object.prototype.hasOwnProperty,ov=function(i,e){return function(){return i&&(e=i(i=0)),e}},vt=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}},k_=function(i,e,t,s){if(e&&typeof e=="object"||typeof e=="function")for(var r=A_(e),n=0,a=r.length,o;n<a;n++)o=r[n],!x_.call(i,o)&&o!==t&&av(i,o,{get:(function(l){return e[l]}).bind(null,o),enumerable:!(s=__(e,o))||s.enumerable});return i},Dt=function(i,e,t){return t=i!=null?T_(S_(i)):{},k_(!i||!i.__esModule?av(t,"default",{value:i,enumerable:!0}):t,i)},Ui=vt(function(i,e){var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t={},e.exports=t});function yt(i){"@swc/helpers - typeof";return i&&typeof Symbol<"u"&&i.constructor===Symbol?"symbol":typeof i}var Sc=ov(function(){}),L_=vt(function(i,e){Sc(),function(t,s){typeof define=="function"&&define.amd?define(s):typeof e=="object"&&e.exports?e.exports=s():t.log=s()}(i,function(){var t=function(){},s="undefined",r=(typeof window>"u"?"undefined":yt(window))!==s&&yt(window.navigator)!==s&&/Trident\/|MSIE /.test(window.navigator.userAgent),n=["trace","debug","info","warn","error"];function a(g,v){var y=g[v];if(typeof y.bind=="function")return y.bind(g);try{return Function.prototype.bind.call(y,g)}catch{return function(){return Function.prototype.apply.apply(y,[g,arguments])}}}function o(){console.log&&(console.log.apply?console.log.apply(console,arguments):Function.prototype.apply.apply(console.log,[console,arguments])),console.trace&&console.trace()}function l(g){return g==="debug"&&(g="log"),(typeof console>"u"?"undefined":yt(console))===s?!1:g==="trace"&&r?o:console[g]!==void 0?a(console,g):console.log!==void 0?a(console,"log"):t}function d(g,v){for(var y=0;y<n.length;y++){var b=n[y];this[b]=y<g?t:this.methodFactory(b,g,v)}this.log=this.debug}function c(g,v,y){return function(){(typeof console>"u"?"undefined":yt(console))!==s&&(d.call(this,v,y),this[g].apply(this,arguments))}}function u(g,v,y){return l(g)||c.apply(this,arguments)}function h(g,v,y){var b=this,x;v=v??"WARN";var _="loglevel";typeof g=="string"?_+=":"+g:(typeof g>"u"?"undefined":yt(g))==="symbol"&&(_=void 0);function S(L){var C=(n[L]||"silent").toUpperCase();if(!((typeof window>"u"?"undefined":yt(window))===s||!_)){try{window.localStorage[_]=C;return}catch{}try{window.document.cookie=encodeURIComponent(_)+"="+C+";"}catch{}}}function A(){var L;if(!((typeof window>"u"?"undefined":yt(window))===s||!_)){try{L=window.localStorage[_]}catch{}if((typeof L>"u"?"undefined":yt(L))===s)try{var C=window.document.cookie,H=C.indexOf(encodeURIComponent(_)+"=");H!==-1&&(L=/^([^;]+)/.exec(C.slice(H))[1])}catch{}return b.levels[L]===void 0&&(L=void 0),L}}function D(){if(!((typeof window>"u"?"undefined":yt(window))===s||!_)){try{window.localStorage.removeItem(_);return}catch{}try{window.document.cookie=encodeURIComponent(_)+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC"}catch{}}}b.name=g,b.levels={TRACE:0,DEBUG:1,INFO:2,WARN:3,ERROR:4,SILENT:5},b.methodFactory=y||u,b.getLevel=function(){return x},b.setLevel=function(L,C){if(typeof L=="string"&&b.levels[L.toUpperCase()]!==void 0&&(L=b.levels[L.toUpperCase()]),typeof L=="number"&&L>=0&&L<=b.levels.SILENT){if(x=L,C!==!1&&S(L),d.call(b,L,g),(typeof console>"u"?"undefined":yt(console))===s&&L<b.levels.SILENT)return"No console available for logging"}else throw"log.setLevel() called with invalid level: "+L},b.setDefaultLevel=function(L){v=L,A()||b.setLevel(L,!1)},b.resetLevel=function(){b.setLevel(v,!1),D()},b.enableAll=function(L){b.setLevel(b.levels.TRACE,L)},b.disableAll=function(L){b.setLevel(b.levels.SILENT,L)};var O=A();O==null&&(O=v),b.setLevel(O,!1)}var f=new h,m={};f.getLogger=function(g){if((typeof g>"u"?"undefined":yt(g))!=="symbol"&&typeof g!="string"||g==="")throw new TypeError("You must supply a name when creating a logger.");var v=m[g];return v||(v=m[g]=new h(g,f.getLevel(),f.methodFactory)),v};var p=(typeof window>"u"?"undefined":yt(window))!==s?window.log:void 0;return f.noConflict=function(){return(typeof window>"u"?"undefined":yt(window))!==s&&window.log===f&&(window.log=p),f},f.getLoggers=function(){return m},f.default=f,f})});function kr(i,e){return e!=null&&typeof Symbol<"u"&&e[Symbol.hasInstance]?!!e[Symbol.hasInstance](i):kr(i,e)}var Lr=ov(function(){Lr()}),I_=vt(function(i){var e=Object.prototype.hasOwnProperty,t;function s(o){try{return decodeURIComponent(o.replace(/\+/g," "))}catch{return null}}function r(o){try{return encodeURIComponent(o)}catch{return null}}function n(o){for(var l=/([^=?#&]+)=?([^&]*)/g,d={},c;c=l.exec(o);){var u=s(c[1]),h=s(c[2]);u===null||h===null||u in d||(d[u]=h)}return d}function a(o,l){l=l||"";var d=[],c,u;typeof l!="string"&&(l="?");for(u in o)if(e.call(o,u)){if(c=o[u],!c&&(c===null||c===t||isNaN(c))&&(c=""),u=r(u),c=r(c),u===null||c===null)continue;d.push(u+"="+c)}return d.length?l+d.join("&"):""}i.stringify=a,i.parse=n}),R_=vt(function(i,e){(function(t){var s=!1;if(typeof define=="function"&&define.amd&&(define(t),s=!0),typeof i=="object"&&(e.exports=t(),s=!0),!s){var r=window.Cookies,n=window.Cookies=t();n.noConflict=function(){return window.Cookies=r,n}}})(function(){var t=function(){for(var r=0,n={};r<arguments.length;r++){var a=arguments[r];for(var o in a)n[o]=a[o]}return n};function s(r){function n(a,o,l){var d;if(typeof document<"u"){if(arguments.length>1){if(l=t({path:"/"},n.defaults,l),typeof l.expires=="number"){var c=new Date;c.setMilliseconds(c.getMilliseconds()+l.expires*864e5),l.expires=c}try{d=JSON.stringify(o),/^[\{\[]/.test(d)&&(o=d)}catch{}return r.write?o=r.write(o,a):o=encodeURIComponent(String(o)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),a=encodeURIComponent(String(a)),a=a.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),a=a.replace(/[\(\)]/g,escape),document.cookie=[a,"=",o,l.expires?"; expires="+l.expires.toUTCString():"",l.path?"; path="+l.path:"",l.domain?"; domain="+l.domain:"",l.secure?"; secure":""].join("")}a||(d={});for(var u=document.cookie?document.cookie.split("; "):[],h=/(%[0-9A-Z]{2})+/g,f=0;f<u.length;f++){var m=u[f].split("="),p=m.slice(1).join("=");p.charAt(0)==='"'&&(p=p.slice(1,-1));try{var g=m[0].replace(h,decodeURIComponent);if(p=r.read?r.read(p,g):r(p,g)||p.replace(h,decodeURIComponent),this.json)try{p=JSON.parse(p)}catch{}if(a===g){d=p;break}a||(d[g]=p)}catch{}}return d}}return n.set=n,n.get=function(a){return n.call(n,a)},n.getJSON=function(){return n.apply({json:!0},[].slice.call(arguments))},n.defaults={},n.remove=function(a,o){n(a,"",t(o,{expires:-1}))},n.withConverter=s,n}return s(function(){})})}),lv=vt(function(i,e){var t=Array.prototype.slice;e.exports=s;function s(r,n){for(("length"in r)||(r=[r]),r=t.call(r);r.length;){var a=r.shift(),o=n(a);if(o)return o;a.childNodes&&a.childNodes.length&&(r=t.call(a.childNodes).concat(r))}}}),w_=vt(function(i,e){Lr(),e.exports=t;function t(s,r){if(!kr(this,t))return new t(s,r);this.data=s,this.nodeValue=s,this.length=s.length,this.ownerDocument=r||null}t.prototype.nodeType=8,t.prototype.nodeName="#comment",t.prototype.toString=function(){return"[object Comment]"}}),C_=vt(function(i,e){Lr(),e.exports=t;function t(s,r){if(!kr(this,t))return new t(s);this.data=s||"",this.length=this.data.length,this.ownerDocument=r||null}t.prototype.type="DOMTextNode",t.prototype.nodeType=3,t.prototype.nodeName="#text",t.prototype.toString=function(){return this.data},t.prototype.replaceData=function(s,r,n){var a=this.data,o=a.substring(0,s),l=a.substring(s+r,a.length);this.data=o+n+l,this.length=this.data.length}}),dv=vt(function(i,e){e.exports=t;function t(s){var r=this,n=s.type;s.target||(s.target=r),r.listeners||(r.listeners={});var a=r.listeners[n];if(a)return a.forEach(function(o){s.currentTarget=r,typeof o=="function"?o(s):o.handleEvent(s)});r.parentNode&&r.parentNode.dispatchEvent(s)}}),cv=vt(function(i,e){e.exports=t;function t(s,r){var n=this;n.listeners||(n.listeners={}),n.listeners[s]||(n.listeners[s]=[]),n.listeners[s].indexOf(r)===-1&&n.listeners[s].push(r)}}),uv=vt(function(i,e){e.exports=t;function t(s,r){var n=this;if(n.listeners&&n.listeners[s]){var a=n.listeners[s],o=a.indexOf(r);o!==-1&&a.splice(o,1)}}}),D_=vt(function(i,e){Sc(),e.exports=s;var t=["area","base","br","col","embed","hr","img","input","keygen","link","menuitem","meta","param","source","track","wbr"];function s(h){switch(h.nodeType){case 3:return c(h.data);case 8:return"<!--"+h.data+"-->";default:return r(h)}}function r(h){var f=[],m=h.tagName;return h.namespaceURI==="http://www.w3.org/1999/xhtml"&&(m=m.toLowerCase()),f.push("<"+m+d(h)+o(h)),t.indexOf(m)>-1?f.push(" />"):(f.push(">"),h.childNodes.length?f.push.apply(f,h.childNodes.map(s)):h.textContent||h.innerText?f.push(c(h.textContent||h.innerText)):h.innerHTML&&f.push(h.innerHTML),f.push("</"+m+">")),f.join("")}function n(h,f){var m=yt(h[f]);return f==="style"&&Object.keys(h.style).length>0?!0:h.hasOwnProperty(f)&&(m==="string"||m==="boolean"||m==="number")&&f!=="nodeName"&&f!=="className"&&f!=="tagName"&&f!=="textContent"&&f!=="innerText"&&f!=="namespaceURI"&&f!=="innerHTML"}function a(h){if(typeof h=="string")return h;var f="";return Object.keys(h).forEach(function(m){var p=h[m];m=m.replace(/[A-Z]/g,function(g){return"-"+g.toLowerCase()}),f+=m+":"+p+";"}),f}function o(h){var f=h.dataset,m=[];for(var p in f)m.push({name:"data-"+p,value:f[p]});return m.length?l(m):""}function l(h){var f=[];return h.forEach(function(m){var p=m.name,g=m.value;p==="style"&&(g=a(g)),f.push(p+'="'+u(g)+'"')}),f.length?" "+f.join(" "):""}function d(h){var f=[];for(var m in h)n(h,m)&&f.push({name:m,value:h[m]});for(var p in h._attributes)for(var g in h._attributes[p]){var v=h._attributes[p][g],y=(v.prefix?v.prefix+":":"")+g;f.push({name:y,value:v.value})}return h.className&&f.push({name:"class",value:h.className}),f.length?l(f):""}function c(h){var f="";return typeof h=="string"?f=h:h&&(f=h.toString()),f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function u(h){return c(h).replace(/"/g,"&quot;")}}),hv=vt(function(i,e){Lr();var t=lv(),s=dv(),r=cv(),n=uv(),a=D_(),o="http://www.w3.org/1999/xhtml";e.exports=l;function l(d,c,u){if(!kr(this,l))return new l(d);var h=u===void 0?o:u||null;this.tagName=h===o?String(d).toUpperCase():d,this.nodeName=this.tagName,this.className="",this.dataset={},this.childNodes=[],this.parentNode=null,this.style={},this.ownerDocument=c||null,this.namespaceURI=h,this._attributes={},this.tagName==="INPUT"&&(this.type="text")}l.prototype.type="DOMElement",l.prototype.nodeType=1,l.prototype.appendChild=function(d){return d.parentNode&&d.parentNode.removeChild(d),this.childNodes.push(d),d.parentNode=this,d},l.prototype.replaceChild=function(d,c){d.parentNode&&d.parentNode.removeChild(d);var u=this.childNodes.indexOf(c);return c.parentNode=null,this.childNodes[u]=d,d.parentNode=this,c},l.prototype.removeChild=function(d){var c=this.childNodes.indexOf(d);return this.childNodes.splice(c,1),d.parentNode=null,d},l.prototype.insertBefore=function(d,c){d.parentNode&&d.parentNode.removeChild(d);var u=c==null?-1:this.childNodes.indexOf(c);return u>-1?this.childNodes.splice(u,0,d):this.childNodes.push(d),d.parentNode=this,d},l.prototype.setAttributeNS=function(d,c,u){var h=null,f=c,m=c.indexOf(":");if(m>-1&&(h=c.substr(0,m),f=c.substr(m+1)),this.tagName==="INPUT"&&c==="type")this.type=u;else{var p=this._attributes[d]||(this._attributes[d]={});p[f]={value:u,prefix:h}}},l.prototype.getAttributeNS=function(d,c){var u=this._attributes[d],h=u&&u[c]&&u[c].value;return this.tagName==="INPUT"&&c==="type"?this.type:typeof h!="string"?null:h},l.prototype.removeAttributeNS=function(d,c){var u=this._attributes[d];u&&delete u[c]},l.prototype.hasAttributeNS=function(d,c){var u=this._attributes[d];return!!u&&c in u},l.prototype.setAttribute=function(d,c){return this.setAttributeNS(null,d,c)},l.prototype.getAttribute=function(d){return this.getAttributeNS(null,d)},l.prototype.removeAttribute=function(d){return this.removeAttributeNS(null,d)},l.prototype.hasAttribute=function(d){return this.hasAttributeNS(null,d)},l.prototype.removeEventListener=n,l.prototype.addEventListener=r,l.prototype.dispatchEvent=s,l.prototype.focus=function(){},l.prototype.toString=function(){return a(this)},l.prototype.getElementsByClassName=function(d){var c=d.split(" "),u=[];return t(this,function(h){if(h.nodeType===1){var f=h.className||"",m=f.split(" ");c.every(function(p){return m.indexOf(p)!==-1})&&u.push(h)}}),u},l.prototype.getElementsByTagName=function(d){d=d.toLowerCase();var c=[];return t(this.childNodes,function(u){u.nodeType===1&&(d==="*"||u.tagName.toLowerCase()===d)&&c.push(u)}),c},l.prototype.contains=function(d){return t(this,function(c){return d===c})||!1}}),M_=vt(function(i,e){Lr();var t=hv();e.exports=s;function s(r){if(!kr(this,s))return new s;this.childNodes=[],this.parentNode=null,this.ownerDocument=r||null}s.prototype.type="DocumentFragment",s.prototype.nodeType=11,s.prototype.nodeName="#document-fragment",s.prototype.appendChild=t.prototype.appendChild,s.prototype.replaceChild=t.prototype.replaceChild,s.prototype.removeChild=t.prototype.removeChild,s.prototype.toString=function(){return this.childNodes.map(function(r){return String(r)}).join("")}}),O_=vt(function(i,e){e.exports=t;function t(s){}t.prototype.initEvent=function(s,r,n){this.type=s,this.bubbles=r,this.cancelable=n},t.prototype.preventDefault=function(){}}),P_=vt(function(i,e){Lr();var t=lv(),s=w_(),r=C_(),n=hv(),a=M_(),o=O_(),l=dv(),d=cv(),c=uv();e.exports=u;function u(){if(!kr(this,u))return new u;this.head=this.createElement("head"),this.body=this.createElement("body"),this.documentElement=this.createElement("html"),this.documentElement.appendChild(this.head),this.documentElement.appendChild(this.body),this.childNodes=[this.documentElement],this.nodeType=9}var h=u.prototype;h.createTextNode=function(f){return new r(f,this)},h.createElementNS=function(f,m){var p=f===null?null:String(f);return new n(m,this,p)},h.createElement=function(f){return new n(f,this)},h.createDocumentFragment=function(){return new a(this)},h.createEvent=function(f){return new o(f)},h.createComment=function(f){return new s(f,this)},h.getElementById=function(f){f=String(f);var m=t(this.childNodes,function(p){if(String(p.id)===f)return p});return m||null},h.getElementsByClassName=n.prototype.getElementsByClassName,h.getElementsByTagName=n.prototype.getElementsByTagName,h.contains=n.prototype.contains,h.removeEventListener=c,h.addEventListener=d,h.dispatchEvent=l}),N_=vt(function(i,e){var t=P_();e.exports=new t}),U_=vt(function(i,e){var t=typeof global<"u"?global:typeof window<"u"?window:{},s=N_(),r;typeof document<"u"?r=document:(r=t["__GLOBAL_DOCUMENT_CACHE@4"],r||(r=t["__GLOBAL_DOCUMENT_CACHE@4"]=s)),e.exports=r});function F_(i){if(Array.isArray(i))return i}function $_(i,e){var t=i==null?null:typeof Symbol<"u"&&i[Symbol.iterator]||i["@@iterator"];if(t!=null){var s=[],r=!0,n=!1,a,o;try{for(t=t.call(i);!(r=(a=t.next()).done)&&(s.push(a.value),!(e&&s.length===e));r=!0);}catch(l){n=!0,o=l}finally{try{!r&&t.return!=null&&t.return()}finally{if(n)throw o}}return s}}function B_(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Mp(i,e){(e==null||e>i.length)&&(e=i.length);for(var t=0,s=new Array(e);t<e;t++)s[t]=i[t];return s}function G_(i,e){if(i){if(typeof i=="string")return Mp(i,e);var t=Object.prototype.toString.call(i).slice(8,-1);if(t==="Object"&&i.constructor&&(t=i.constructor.name),t==="Map"||t==="Set")return Array.from(t);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Mp(i,e)}}function Tr(i,e){return F_(i)||$_(i,e)||G_(i,e)||B_()}var Da=Dt(Ui()),Ka=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(i){var e=Math.random()*16|0,t=i==="x"?e:e&3|8;return t.toString(16)})},fv=function(){return("000000"+(Math.random()*Math.pow(36,6)<<0).toString(36)).slice(-6)},Ms=function(i){if(i&&typeof i.nodeName<"u")return i.muxId||(i.muxId=fv()),i.muxId;var e;try{e=document.querySelector(i)}catch{}return e&&!e.muxId&&(e.muxId=i),(e==null?void 0:e.muxId)||i},Wu=function(i){var e;i&&typeof i.nodeName<"u"?(e=i,i=Ms(e)):e=document.querySelector(i);var t=e&&e.nodeName?e.nodeName.toLowerCase():"";return[e,i,t]},Va=Dt(L_()),H_=Va.default.methodFactory;Va.default.methodFactory=function(i,e,t){var s=H_(i,e,t);return function(){for(var r=["[mux]"],n=0;n<arguments.length;n++)r.push(arguments[n]);s.apply(void 0,r)}};Va.default.setLevel(Va.default.getLevel());var Pe=Va.default,Hc=Dt(Ui());function Ku(){var i=Hc.default.doNotTrack||Hc.default.navigator&&Hc.default.navigator.doNotTrack;return i==="1"}var W_=Dt(Ui()),K_={now:function(){var i=W_.default.performance,e=i&&i.timing,t=e&&e.navigationStart,s=typeof t=="number"&&typeof i.now=="function"?t+i.now():Date.now();return Math.round(s)}},Qe=K_;function ne(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}Lr();function ct(i,e){if(!kr(i,e))throw new TypeError("Cannot call a class as a function")}function V_(i,e){for(var t=0;t<e.length;t++){var s=e[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(i,s.key,s)}}function Fi(i,e,t){return e&&V_(i.prototype,e),i}function B(i,e,t){return e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Vu(i,e){return Vu=Object.setPrototypeOf||function(t,s){return t.__proto__=s,t},Vu(i,e)}function q_(i,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");i.prototype=Object.create(e&&e.prototype,{constructor:{value:i,writable:!0,configurable:!0}}),e&&Vu(i,e)}function Md(i){return Md=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},Md(i)}function Y_(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}Sc();function j_(i,e){return e&&(yt(e)==="object"||typeof e=="function")?e:ne(i)}function z_(i){var e=Y_();return function(){var t=Md(i),s;if(e){var r=Md(this).constructor;s=Reflect.construct(t,arguments,r)}else s=t.apply(this,arguments);return j_(this,s)}}var Jt=function(i){return qa(i)[0]},qa=function(i){if(typeof i!="string"||i==="")return["localhost"];var e=/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/,t=i.match(e)||[],s=t[4],r;return s&&(r=(s.match(/[^\.]+\.[^\.]+$/)||[])[0]),[s,r]},Wc=Dt(Ui()),X_={exists:function(){var i=Wc.default.performance,e=i&&i.timing;return e!==void 0},domContentLoadedEventEnd:function(){var i=Wc.default.performance,e=i&&i.timing;return e&&e.domContentLoadedEventEnd},navigationStart:function(){var i=Wc.default.performance,e=i&&i.timing;return e&&e.navigationStart}},Od=X_;function We(i,e,t){t=t===void 0?1:t,i[e]=i[e]||0,i[e]+=t}function Pd(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{},s=Object.keys(t);typeof Object.getOwnPropertySymbols=="function"&&(s=s.concat(Object.getOwnPropertySymbols(t).filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable}))),s.forEach(function(r){B(i,r,t[r])})}return i}function Q_(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);t.push.apply(t,s)}return t}function nm(i,e){return e=e??{},Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(e)):Q_(Object(e)).forEach(function(t){Object.defineProperty(i,t,Object.getOwnPropertyDescriptor(e,t))}),i}var Z_=["x-cdn","content-type"],mv=["x-request-id","cf-ray","x-amz-cf-id","x-akamai-request-id"],J_=Z_.concat(mv);function am(i){i=i||"";var e={},t=i.trim().split(/[\r\n]+/);return t.forEach(function(s){if(s){var r=s.split(": "),n=r.shift();n&&(J_.indexOf(n.toLowerCase())>=0||n.toLowerCase().indexOf("x-litix-")===0)&&(e[n]=r.join(": "))}}),e}function Nd(i){if(i){var e=mv.find(function(t){return i[t]!==void 0});return e?i[e]:void 0}}var e1=function(i){var e={};for(var t in i){var s=i[t],r=s["DATA-ID"].search("io.litix.data.");if(r!==-1){var n=s["DATA-ID"].replace("io.litix.data.","");e[n]=s.VALUE}}return e},pv=e1,Eo=function(i){if(!i)return{};var e=Od.navigationStart(),t=i.loading,s=t?t.start:i.trequest,r=t?t.first:i.tfirst,n=t?t.end:i.tload;return{bytesLoaded:i.total,requestStart:Math.round(e+s),responseStart:Math.round(e+r),responseEnd:Math.round(e+n)}},Wn=function(i){if(!(!i||typeof i.getAllResponseHeaders!="function"))return am(i.getAllResponseHeaders())},t1=function(i,e,t){var s=arguments.length>4?arguments[4]:void 0,r=i.log,n=i.utils.secondsToMs,a=function(g){var v=parseInt(s.version),y;return v===1&&g.programDateTime!==null&&(y=g.programDateTime),v===0&&g.pdt!==null&&(y=g.pdt),y};if(!Od.exists()){r.warn("performance timing not supported. Not tracking HLS.js.");return}var o=function(g,v){return i.emit(e,g,v)},l=function(g,v){var y=v.levels,b=v.audioTracks,x=v.url,_=v.stats,S=v.networkDetails,A=v.sessionData,D={},O={};y.forEach(function(q,Y){D[Y]={width:q.width,height:q.height,bitrate:q.bitrate,attrs:q.attrs}}),b.forEach(function(q,Y){O[Y]={name:q.name,language:q.lang,bitrate:q.bitrate}});var L=Eo(_),C=L.bytesLoaded,H=L.requestStart,U=L.responseStart,Q=L.responseEnd;o("requestcompleted",nm(Pd({},pv(A)),{request_event_type:g,request_bytes_loaded:C,request_start:H,request_response_start:U,request_response_end:Q,request_type:"manifest",request_hostname:Jt(x),request_response_headers:Wn(S),request_rendition_lists:{media:D,audio:O,video:{}}}))};t.on(s.Events.MANIFEST_LOADED,l);var d=function(g,v){var y=v.details,b=v.level,x=v.networkDetails,_=v.stats,S=Eo(_),A=S.bytesLoaded,D=S.requestStart,O=S.responseStart,L=S.responseEnd,C=y.fragments[y.fragments.length-1],H=a(C)+n(C.duration);o("requestcompleted",{request_event_type:g,request_bytes_loaded:A,request_start:D,request_response_start:O,request_response_end:L,request_current_level:b,request_type:"manifest",request_hostname:Jt(y.url),request_response_headers:Wn(x),video_holdback:y.holdBack&&n(y.holdBack),video_part_holdback:y.partHoldBack&&n(y.partHoldBack),video_part_target_duration:y.partTarget&&n(y.partTarget),video_target_duration:y.targetduration&&n(y.targetduration),video_source_is_live:y.live,player_manifest_newest_program_time:isNaN(H)?void 0:H})};t.on(s.Events.LEVEL_LOADED,d);var c=function(g,v){var y=v.details,b=v.networkDetails,x=v.stats,_=Eo(x),S=_.bytesLoaded,A=_.requestStart,D=_.responseStart,O=_.responseEnd;o("requestcompleted",{request_event_type:g,request_bytes_loaded:S,request_start:A,request_response_start:D,request_response_end:O,request_type:"manifest",request_hostname:Jt(y.url),request_response_headers:Wn(b)})};t.on(s.Events.AUDIO_TRACK_LOADED,c);var u=function(g,v){var y=v.stats,b=v.networkDetails,x=v.frag;y=y||x.stats;var _=Eo(y),S=_.bytesLoaded,A=_.requestStart,D=_.responseStart,O=_.responseEnd,L=b?Wn(b):void 0,C={request_event_type:g,request_bytes_loaded:S,request_start:A,request_response_start:D,request_response_end:O,request_hostname:b?Jt(b.responseURL):void 0,request_id:L?Nd(L):void 0,request_response_headers:L,request_media_duration:x.duration,request_url:b==null?void 0:b.responseURL};x.type==="main"?(C.request_type="media",C.request_current_level=x.level,C.request_video_width=(t.levels[x.level]||{}).width,C.request_video_height=(t.levels[x.level]||{}).height,C.request_labeled_bitrate=(t.levels[x.level]||{}).bitrate):C.request_type=x.type,o("requestcompleted",C)};t.on(s.Events.FRAG_LOADED,u);var h=function(g,v){var y=v.frag,b=y.start,x=a(y),_={currentFragmentPDT:x,currentFragmentStart:n(b)};o("fragmentchange",_)};t.on(s.Events.FRAG_CHANGED,h);var f=function(g,v){var y=v.type,b=v.details,x=v.response,_=v.fatal,S=v.frag,A=v.networkDetails,D=(S==null?void 0:S.url)||v.url||"",O=A?Wn(A):void 0;if((b===s.ErrorDetails.MANIFEST_LOAD_ERROR||b===s.ErrorDetails.MANIFEST_LOAD_TIMEOUT||b===s.ErrorDetails.FRAG_LOAD_ERROR||b===s.ErrorDetails.FRAG_LOAD_TIMEOUT||b===s.ErrorDetails.LEVEL_LOAD_ERROR||b===s.ErrorDetails.LEVEL_LOAD_TIMEOUT||b===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT||b===s.ErrorDetails.SUBTITLE_LOAD_ERROR||b===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT||b===s.ErrorDetails.KEY_LOAD_ERROR||b===s.ErrorDetails.KEY_LOAD_TIMEOUT)&&o("requestfailed",{request_error:b,request_url:D,request_hostname:Jt(D),request_id:O?Nd(O):void 0,request_type:b===s.ErrorDetails.FRAG_LOAD_ERROR||b===s.ErrorDetails.FRAG_LOAD_TIMEOUT?"media":b===s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR||b===s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT?"audio":b===s.ErrorDetails.SUBTITLE_LOAD_ERROR||b===s.ErrorDetails.SUBTITLE_LOAD_TIMEOUT?"subtitle":b===s.ErrorDetails.KEY_LOAD_ERROR||b===s.ErrorDetails.KEY_LOAD_TIMEOUT?"encryption":"manifest",request_error_code:x==null?void 0:x.code,request_error_text:x==null?void 0:x.text}),_){var L,C="".concat(D?"url: ".concat(D,`
3
3
  `):"")+"".concat(x&&(x.code||x.text)?"response: ".concat(x.code,", ").concat(x.text,`
4
4
  `):"")+"".concat(v.reason?"failure reason: ".concat(v.reason,`
5
5
  `):"")+"".concat(v.level?"level: ".concat(v.level,`
@@ -8,51 +8,51 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
8
8
  `):"")+"".concat(v.error?"error: ".concat(v.error,`
9
9
  `):"")+"".concat(v.event?"event: ".concat(v.event,`
10
10
  `):"")+"".concat(v.err?"error message: ".concat((L=v.err)===null||L===void 0?void 0:L.message,`
11
- `):"");o("error",{player_error_code:y,player_error_message:b,player_error_context:C})}};t.on(s.Events.ERROR,f);var m=function(g,v){var y=v.frag,b=y&&y._url||"";o("requestcanceled",{request_event_type:g,request_url:b,request_type:"media",request_hostname:Jt(b)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var p=function(g,v){var y=v.level,b=t.levels[y];if(b&&b.attrs&&b.attrs.BANDWIDTH){var x=b.attrs.BANDWIDTH,_,S=parseFloat(b.attrs["FRAME-RATE"]);isNaN(S)||(_=S),x?o("renditionchange",{video_source_fps:_,video_source_bitrate:x,video_source_width:b.width,video_source_height:b.height,video_source_rendition_name:b.name,video_source_codec:b==null?void 0:b.videoCodec}):r.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,p),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,l),t.off(s.Events.LEVEL_LOADED,d),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,u),t.off(s.Events.FRAG_CHANGED,h),t.off(s.Events.ERROR,f),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),t.off(s.Events.LEVEL_SWITCHED,p),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},t1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Op=function(i,e){if(!i||!i.requestEndDate)return{};var t=Jt(i.url),s=i.url,r=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),c;d.length>0&&(c=am(d[d.length-1]._responseHeaders||""));var u=c?Nd(c):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:r,requestResponseHeaders:c,requestMediaDuration:l,requestHostname:t,requestUrl:s,requestId:u}},i1=function(i,e){var t=e.getQualityFor(i),s=e.getCurrentTrackFor(i).bitrateList;return s?{currentLevel:t,renditionWidth:s[t].width||null,renditionHeight:s[t].height||null,renditionBitrate:s[t].bandwidth}:{}},s1=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},r1=function(i){try{var e,t,s=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(r){return parseInt(r)})[0];return s}catch{return!1}},n1=function(i,e,t){var s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var r=r1(t),n=function(y,b){return i.emit(e,y,b)},a=function(y){var b=y.type,x=y.data,_=(x||{}).url;n("requestcompleted",{request_event_type:b,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:Jt(_),request_url:_})};t.on("manifestLoaded",a);var o={},l=function(y){if(typeof y.getRequests!="function")return null;var b=y.getRequests({state:"executed"});return b.length===0?null:b[b.length-1]},d=function(y){var b=y.type,x=y.fragmentModel,_=y.chunk,S=l(x);c({type:b,request:S,chunk:_})},c=function(y){var b=y.type,x=y.chunk,_=y.request,S=(x||{}).mediaInfo,A=S||{},D=A.type,O=A.bitrateList;O=O||[];var L={};O.forEach(function(F,re){L[re]={},L[re].width=F.width,L[re].height=F.height,L[re].bitrate=F.bandwidth,L[re].attrs={}}),D==="video"?o.video=L:D==="audio"?o.audio=L:o.media=L;var C=Op(_,t),H=C.requestStart,U=C.requestResponseStart,Q=C.requestResponseEnd,q=C.requestResponseHeaders,Y=C.requestMediaDuration,oe=C.requestHostname,ae=C.requestUrl,G=C.requestId;n("requestcompleted",{request_event_type:b,request_start:H,request_response_start:U,request_response_end:Q,request_bytes_loaded:-1,request_type:D+"_init",request_response_headers:q,request_hostname:oe,request_id:G,request_url:ae,request_media_duration:Y,request_rendition_lists:o})};r>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",d);var u=function(y){var b=y.type,x=y.fragmentModel,_=y.chunk,S=l(x);h({type:b,request:S,chunk:_})},h=function(y){var b=y.type,x=y.chunk,_=y.request,S=x||{},A=S.mediaInfo,D=S.start,O=A||{},L=O.type,C=Op(_,t),H=C.requestStart,U=C.requestResponseStart,Q=C.requestResponseEnd,q=C.requestBytesLoaded,Y=C.requestResponseHeaders,oe=C.requestMediaDuration,ae=C.requestHostname,G=C.requestUrl,F=C.requestId,re=i1(L,t),J=re.currentLevel,de=re.renditionWidth,Ae=re.renditionHeight,Ce=re.renditionBitrate;n("requestcompleted",{request_event_type:b,request_start:H,request_response_start:U,request_response_end:Q,request_bytes_loaded:q,request_type:L,request_response_headers:Y,request_hostname:ae,request_id:F,request_url:G,request_media_start_time:D,request_media_duration:oe,request_current_level:J,request_labeled_bitrate:Ce,request_video_width:de,request_video_height:Ae})};r>=4?t.on("mediaFragmentLoaded",h):t.on("mediaFragmentLoaded",u);var f={video:void 0,audio:void 0,totalBitrate:void 0},m=function(){if(f.video&&typeof f.video.bitrate=="number"){if(!(f.video.width&&f.video.height)){s.warn("have bitrate info for video but missing width/height");return}var y=f.video.bitrate;if(f.audio&&typeof f.audio.bitrate=="number"&&(y+=f.audio.bitrate),y!==f.totalBitrate)return f.totalBitrate=y,{video_source_bitrate:y,video_source_height:f.video.height,video_source_width:f.video.width,video_source_codec:s1(f.video.codec)}}},p=function(y,b,x){if(typeof y.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",y);return}var _=y.mediaType;if(_==="audio"||_==="video"){var S=t.getBitrateInfoListFor(_).find(function(D){var O=D.qualityIndex;return O===y.newQuality});if(!(S&&typeof S.bitrate=="number")){s.warn("missing bitrate info for ".concat(_));return}f[_]=nm(Pd({},S),{codec:t.getCurrentTrackFor(_).codec});var A=m();A&&n("renditionchange",A)}};t.on("qualityChangeRendered",p);var g=function(y){var b=y.request,x=y.mediaType;b=b||{},n("requestcanceled",{request_event_type:b.type+"_"+b.action,request_url:b.url,request_type:x,request_hostname:Jt(b.url)})};t.on("fragmentLoadingAbandoned",g);var v=function(y){var b=y.error,x,_,S=(b==null||(x=b.data)===null||x===void 0?void 0:x.request)||{},A=(b==null||(_=b.data)===null||_===void 0?void 0:_.response)||{};(b==null?void 0:b.code)===27&&n("requestfailed",{request_error:S.type+"_"+S.action,request_url:S.url,request_hostname:Jt(S.url),request_type:S.mediaType,request_error_code:A.status,request_error_text:A.statusText});var D="".concat(S!=null&&S.url?"url: ".concat(S.url,`
11
+ `):"");o("error",{player_error_code:y,player_error_message:b,player_error_context:C})}};t.on(s.Events.ERROR,f);var m=function(g,v){var y=v.frag,b=y&&y._url||"";o("requestcanceled",{request_event_type:g,request_url:b,request_type:"media",request_hostname:Jt(b)})};t.on(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,m);var p=function(g,v){var y=v.level,b=t.levels[y];if(b&&b.attrs&&b.attrs.BANDWIDTH){var x=b.attrs.BANDWIDTH,_,S=parseFloat(b.attrs["FRAME-RATE"]);isNaN(S)||(_=S),x?o("renditionchange",{video_source_fps:_,video_source_bitrate:x,video_source_width:b.width,video_source_height:b.height,video_source_rendition_name:b.name,video_source_codec:b==null?void 0:b.videoCodec}):r.warn("missing BANDWIDTH from HLS manifest parsed by HLS.js")}};t.on(s.Events.LEVEL_SWITCHED,p),t._stopMuxMonitor=function(){t.off(s.Events.MANIFEST_LOADED,l),t.off(s.Events.LEVEL_LOADED,d),t.off(s.Events.AUDIO_TRACK_LOADED,c),t.off(s.Events.FRAG_LOADED,u),t.off(s.Events.FRAG_CHANGED,h),t.off(s.Events.ERROR,f),t.off(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,m),t.off(s.Events.LEVEL_SWITCHED,p),t.off(s.Events.DESTROYING,t._stopMuxMonitor),delete t._stopMuxMonitor},t.on(s.Events.DESTROYING,t._stopMuxMonitor)},i1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Op=function(i,e){if(!i||!i.requestEndDate)return{};var t=Jt(i.url),s=i.url,r=i.bytesLoaded,n=new Date(i.requestStartDate).getTime(),a=new Date(i.firstByteDate).getTime(),o=new Date(i.requestEndDate).getTime(),l=isNaN(i.duration)?0:i.duration,d=typeof e.getMetricsFor=="function"?e.getMetricsFor(i.mediaType).HttpList:e.getDashMetrics().getHttpRequests(i.mediaType),c;d.length>0&&(c=am(d[d.length-1]._responseHeaders||""));var u=c?Nd(c):void 0;return{requestStart:n,requestResponseStart:a,requestResponseEnd:o,requestBytesLoaded:r,requestResponseHeaders:c,requestMediaDuration:l,requestHostname:t,requestUrl:s,requestId:u}},s1=function(i,e){var t=e.getQualityFor(i),s=e.getCurrentTrackFor(i).bitrateList;return s?{currentLevel:t,renditionWidth:s[t].width||null,renditionHeight:s[t].height||null,renditionBitrate:s[t].bandwidth}:{}},r1=function(i){var e;return(e=i.match(/.*codecs\*?="(.*)"/))===null||e===void 0?void 0:e[1]},n1=function(i){try{var e,t,s=(t=i.getVersion)===null||t===void 0||(e=t.call(i))===null||e===void 0?void 0:e.split(".").map(function(r){return parseInt(r)})[0];return s}catch{return!1}},a1=function(i,e,t){var s=i.log;if(!t||!t.on){s.warn("Invalid dash.js player reference. Monitoring blocked.");return}var r=n1(t),n=function(y,b){return i.emit(e,y,b)},a=function(y){var b=y.type,x=y.data,_=(x||{}).url;n("requestcompleted",{request_event_type:b,request_start:0,request_response_start:0,request_response_end:0,request_bytes_loaded:-1,request_type:"manifest",request_hostname:Jt(_),request_url:_})};t.on("manifestLoaded",a);var o={},l=function(y){if(typeof y.getRequests!="function")return null;var b=y.getRequests({state:"executed"});return b.length===0?null:b[b.length-1]},d=function(y){var b=y.type,x=y.fragmentModel,_=y.chunk,S=l(x);c({type:b,request:S,chunk:_})},c=function(y){var b=y.type,x=y.chunk,_=y.request,S=(x||{}).mediaInfo,A=S||{},D=A.type,O=A.bitrateList;O=O||[];var L={};O.forEach(function(F,re){L[re]={},L[re].width=F.width,L[re].height=F.height,L[re].bitrate=F.bandwidth,L[re].attrs={}}),D==="video"?o.video=L:D==="audio"?o.audio=L:o.media=L;var C=Op(_,t),H=C.requestStart,U=C.requestResponseStart,Q=C.requestResponseEnd,q=C.requestResponseHeaders,Y=C.requestMediaDuration,oe=C.requestHostname,ae=C.requestUrl,G=C.requestId;n("requestcompleted",{request_event_type:b,request_start:H,request_response_start:U,request_response_end:Q,request_bytes_loaded:-1,request_type:D+"_init",request_response_headers:q,request_hostname:oe,request_id:G,request_url:ae,request_media_duration:Y,request_rendition_lists:o})};r>=4?t.on("initFragmentLoaded",c):t.on("initFragmentLoaded",d);var u=function(y){var b=y.type,x=y.fragmentModel,_=y.chunk,S=l(x);h({type:b,request:S,chunk:_})},h=function(y){var b=y.type,x=y.chunk,_=y.request,S=x||{},A=S.mediaInfo,D=S.start,O=A||{},L=O.type,C=Op(_,t),H=C.requestStart,U=C.requestResponseStart,Q=C.requestResponseEnd,q=C.requestBytesLoaded,Y=C.requestResponseHeaders,oe=C.requestMediaDuration,ae=C.requestHostname,G=C.requestUrl,F=C.requestId,re=s1(L,t),J=re.currentLevel,de=re.renditionWidth,Ae=re.renditionHeight,Ce=re.renditionBitrate;n("requestcompleted",{request_event_type:b,request_start:H,request_response_start:U,request_response_end:Q,request_bytes_loaded:q,request_type:L,request_response_headers:Y,request_hostname:ae,request_id:F,request_url:G,request_media_start_time:D,request_media_duration:oe,request_current_level:J,request_labeled_bitrate:Ce,request_video_width:de,request_video_height:Ae})};r>=4?t.on("mediaFragmentLoaded",h):t.on("mediaFragmentLoaded",u);var f={video:void 0,audio:void 0,totalBitrate:void 0},m=function(){if(f.video&&typeof f.video.bitrate=="number"){if(!(f.video.width&&f.video.height)){s.warn("have bitrate info for video but missing width/height");return}var y=f.video.bitrate;if(f.audio&&typeof f.audio.bitrate=="number"&&(y+=f.audio.bitrate),y!==f.totalBitrate)return f.totalBitrate=y,{video_source_bitrate:y,video_source_height:f.video.height,video_source_width:f.video.width,video_source_codec:r1(f.video.codec)}}},p=function(y,b,x){if(typeof y.newQuality!="number"){s.warn("missing evt.newQuality in qualityChangeRendered event",y);return}var _=y.mediaType;if(_==="audio"||_==="video"){var S=t.getBitrateInfoListFor(_).find(function(D){var O=D.qualityIndex;return O===y.newQuality});if(!(S&&typeof S.bitrate=="number")){s.warn("missing bitrate info for ".concat(_));return}f[_]=nm(Pd({},S),{codec:t.getCurrentTrackFor(_).codec});var A=m();A&&n("renditionchange",A)}};t.on("qualityChangeRendered",p);var g=function(y){var b=y.request,x=y.mediaType;b=b||{},n("requestcanceled",{request_event_type:b.type+"_"+b.action,request_url:b.url,request_type:x,request_hostname:Jt(b.url)})};t.on("fragmentLoadingAbandoned",g);var v=function(y){var b=y.error,x,_,S=(b==null||(x=b.data)===null||x===void 0?void 0:x.request)||{},A=(b==null||(_=b.data)===null||_===void 0?void 0:_.response)||{};(b==null?void 0:b.code)===27&&n("requestfailed",{request_error:S.type+"_"+S.action,request_url:S.url,request_hostname:Jt(S.url),request_type:S.mediaType,request_error_code:A.status,request_error_text:A.statusText});var D="".concat(S!=null&&S.url?"url: ".concat(S.url,`
12
12
  `):"")+"".concat(A!=null&&A.status||A!=null&&A.statusText?"response: ".concat(A==null?void 0:A.status,", ").concat(A==null?void 0:A.statusText,`
13
- `):"");n("error",{player_error_code:b==null?void 0:b.code,player_error_message:b==null?void 0:b.message,player_error_context:D})};t.on("error",v),t._stopMuxMonitor=function(){t.off("manifestLoaded",a),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",h),t.off("qualityChangeRendered",p),t.off("error",v),t.off("fragmentLoadingAbandoned",g),delete t._stopMuxMonitor}},a1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Pp=0,o1=function(){function i(){ct(this,i),B(this,"_listeners",void 0)}return Fi(i,[{key:"on",value:function(e,t,s){return t._eventEmitterGuid=t._eventEmitterGuid||++Pp,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],s&&(t=t.bind(s)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var s=this._listeners&&this._listeners[e];s&&s.forEach(function(r,n){r._eventEmitterGuid===t._eventEmitterGuid&&s.splice(n,1)})}},{key:"one",value:function(e,t,s){var r=this;t._eventEmitterGuid=t._eventEmitterGuid||++Pp;var n=function(){r.off(e,n),t.apply(s||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var s=this;if(this._listeners){t=t||{};var r=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(c){c.call(s,{type:e},d)})};o(r,t),o(n,t),o(a,t)}}}]),i}(),l1=o1,Kc=Dt(Ui()),d1=function(){function i(e){var t=this;ct(this,i),B(this,"_playbackHeartbeatInterval",void 0),B(this,"_playheadShouldBeProgressing",void 0),B(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(s,r){t._playbackHeartbeatInterval!==null&&(Kc.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:r.viewer_time}),t._playbackHeartbeatInterval=null)})}return Fi(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=Kc.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(Kc.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),c1=d1,u1=function i(e){var t=this;ct(this,i),B(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(s,r){try{var n=e.errorTranslator({player_error_code:r.player_error_code,player_error_message:r.player_error_message,player_error_context:r.player_error_context,player_error_severity:r.player_error_severity,player_error_business_exception:r.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||r.player_error_code,e.data.player_error_message=n.player_error_message||r.player_error_message,e.data.player_error_context=n.player_error_context||r.player_error_context,e.data.player_error_severity=n.player_error_severity||r.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||r.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var s,r,n,a,o;(s=e.data)===null||s===void 0||delete s.player_error_code,(r=e.data)===null||r===void 0||delete r.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},h1=u1,f1=function(){function i(e){ct(this,i),B(this,"_watchTimeTrackerLastCheckedTime",void 0),B(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Fi(i,[{key:"_updateWatchTime",value:function(e,t){var s=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=s),We(this.pm.data,"view_watch_time",s-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=s}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),m1=f1,p1=function(){function i(e){var t=this;ct(this,i),B(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),B(this,"_lastTime",void 0),B(this,"_isAdPlaying",void 0),B(this,"_callbackUpdatePlaybackTime",void 0),B(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=Qe.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var s=this._startPlaybackTimeTracking.bind(this);e.on("playing",s),e.on("adplaying",s),e.on("seeked",s);var r=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",r),e.on("seeking",r),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=Qe.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Fi(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=Qe.now(),s=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?s=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(s=t-this._lastTime),s>0&&s<=1e3&&We(this.pm.data,"view_content_playback_time",s),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),g1=p1,v1=function(){function i(e){ct(this,i),B(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Fi(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position>"u"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var s=this,r=function(){s.pm.currentFragmentPDT&&s.pm.currentFragmentStart&&(s.pm.data.player_program_time=s.pm.currentFragmentPDT+s.pm.data.player_playhead_time-s.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,r(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n<"u"&&(this.pm.data.player_playhead_time=n,r(),this._updateMaxPlayheadPosition())}}}]),i}(),E1=v1,Np=5*60*1e3,b1=function i(e){if(ct(this,i),!e.disableRebufferTracking){var t,s=function(n,a){r(a),t=void 0},r=function(n){if(t){var a=n.viewer_time-t;We(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>Np&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(Np,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return r(a)}),e.on("rebufferstart",function(n,a){t||(We(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",s))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",s)})}},y1=b1,T1=function(){function i(e){var t=this;ct(this,i),B(this,"_lastCheckedTime",void 0),B(this,"_lastPlayheadTime",void 0),B(this,"_lastPlayheadTimeUpdatedTime",void 0),B(this,"_rebuffering",void 0),B(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:Qe.now()})}))}return Fi(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var s=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&s>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var r=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&r>0&&n-r>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-r}))}s?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),_1=T1,A1=function(){function i(e){var t=this;ct(this,i),B(this,"NAVIGATION_START",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var s=e.data,r=s.view_id;if(!s.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame>"u"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame>"u"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||Qe.now(),r)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Fi(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),S1=A1,x1=function i(e){var t=this;ct(this,i),B(this,"_lastPlayerHeight",void 0),B(this,"_lastPlayerWidth",void 0),B(this,"_lastPlayheadPosition",void 0),B(this,"_lastSourceHeight",void 0),B(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var s=["pause","rebufferstart","seeking","error","adbreakstart","hb"],r=["playing","hb"];s.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),We(e.data,"view_total_content_playback_time",a),We(e.data,"view_total_upscaling",l*a),We(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),r.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},k1=x1,L1=2e3,I1=function i(e){var t=this;ct(this,i),B(this,"isSeeking",void 0),this.isSeeking=!1;var s=-1,r=function(){var n=Qe.now(),a=(e.data.viewer_time||n)-(s||n);We(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,s=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-s<=L1){s=a.viewer_time;return}t.isSeeking&&r(),t.isSeeking=!0,s=a.viewer_time,We(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){r()}),e.on("viewend",function(){t.isSeeking&&(r(),e.send("seeked")),t.isSeeking=!1,s=-1})},R1=I1,Up=function(i,e){i.push(e),i.sort(function(t,s){return t.viewer_time-s.viewer_time})},w1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],C1=function(){function i(e){var t=this;ct(this,i),B(this,"_adHasPlayed",void 0),B(this,"_adRequests",void 0),B(this,"_adResponses",void 0),B(this,"_currentAdRequestNumber",void 0),B(this,"_currentAdResponseNumber",void 0),B(this,"_prerollPlayTime",void 0),B(this,"_wouldBeNewAdPlay",void 0),B(this,"isAdBreak",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),w1.forEach(function(r){return e.on(r,t._updateAdData.bind(t))});var s=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",s),e.on("playing",s),e.on("viewend",s),e.on("adrequest",function(r,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),Up(t._adRequests,n),We(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||We(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(r,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),Up(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&We(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(r,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,We(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(r,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time>"u"&&typeof t._prerollPlayTime<"u"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(r,n){t._wouldBeNewAdPlay||We(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(r,n){t._wouldBeNewAdPlay||We(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Fi(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var s=Tr(qa(t.ad_tag_url),2),r=s[0],n=s[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=r}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=Tr(qa(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),D1=C1,Fp=Dt(Ui()),M1=function i(e){ct(this,i);var t,s,r=function(){e.disableRebufferTracking||(We(e.data,"view_waiting_rebuffer_count",1),t=Qe.now(),s=Fp.default.setInterval(function(){if(t){var d=Qe.now();We(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(We(e.data,"view_waiting_rebuffer_duration",Qe.now()-t),t=!1,Fp.default.clearInterval(s))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&r()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},O1=M1,P1=function i(e){var t=this;ct(this,i),B(this,"lastWallClockTime",void 0);var s=function(){t.lastWallClockTime=Qe.now(),e.on("before*",r)},r=function(n){var a=Qe.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",s),e.on("playbackheartbeatend",function(){e.off("before*",r),e.one("playbackheartbeat",s)})},N1=P1,Vc=Dt(Ui()),gv=Dt(L_()),vv=Dt(I_()),Ev="muxData",bv=function(){var i;try{i=gv.default.parse(vv.default.get(Ev)||"")}catch{i={}}return i},yv=function(i){try{vv.default.set(Ev,gv.default.stringify(i),{expires:365})}catch{}},U1=function(){var i=bv();return i.mux_viewer_id=i.mux_viewer_id||Ka(),i.msn=i.msn||Math.random(),yv(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},F1=function(){var i=bv(),e=Qe.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=Ka(),i.sst=e),i.sex=e+25*60*1e3,yv(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function $1(i,e){var t=e.beaconCollectionDomain,s=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var r=s||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+r:"https://img.litix.io/a.gif"}var B1=Dt(Ui()),Tv=function(){var i;switch(_v()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},_v=function(){var i=B1.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};Tv.getConnectionFromAPI=_v;var G1=Tv,H1={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},W1=Av(H1),K1={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},$p=Av(K1);function Av(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function qu(i){var e={},t={};return Object.keys(i).forEach(function(s){var r=!1;if(i.hasOwnProperty(s)&&i[s]!==void 0){var n=s.split("_"),a=n[0],o=W1[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+s),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(r=!0),$p[l]?o+=$p[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+s),o+="_"+l+"_")}),r?t[o]=i[s]:e[o]=i[s]}}),Object.assign(e,t)}var ir=Dt(Ui()),V1={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},q1=56*1024,Y1=["hb","requestcompleted","requestfailed","requestcanceled"],j1="https://img.litix.io",Ji=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||j1,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},V1,e)};Ji.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};Ji.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};Ji.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),ir.default.clearTimeout(this._sendTimeout)};Ji.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],qu({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);Sv(this._beaconUrl,t,!0,function(){})};Ji.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),s=Qe.now();Sv(this._beaconUrl,t,!1,function(r,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=Qe.now()-s,i._postInFlight=!1})}};Ji.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};Ji.prototype._startBeaconSending=function(){var i=this;ir.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=ir.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};Ji.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(Qe.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var s,r,n,a=function(){s=JSON.stringify({metadata:t,events:r||i}),n=s.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),r=i.filter(function(l){return Y1.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),r.forEach(function(l){for(var d in l){var c=l[d],u=50*1024;typeof c=="string"&&c.length>u&&(l[d]=c.substring(0,u))}}),a()),s};var z1=function(i){return i.length<=q1},Sv=function(i,e,t,s){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){s();return}if(ir.default.fetch){ir.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:z1(e)}).then(function(n){return s(null,n.ok?null:"Error")}).catch(function(n){return s(null,n)});return}if(ir.default.XMLHttpRequest){var r=new ir.default.XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===4)return s(null,r.status!==200?"error":void 0)},r.open("POST",i),r.setRequestHeader("Content-Type","text/plain"),r.send(e);return}s()},X1=Ji,Q1=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],Z1=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],J1=["ad_id","ad_creative_id","ad_universal_id"],eA=["viewstart","error","ended","viewend"],tA=10*60*1e3,iA=function(){function i(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ct(this,i);var r,n,a,o,l,d,c,u,h,f,m,p;B(this,"mux",void 0),B(this,"envKey",void 0),B(this,"options",void 0),B(this,"eventQueue",void 0),B(this,"sampleRate",void 0),B(this,"disableCookies",void 0),B(this,"respectDoNotTrack",void 0),B(this,"previousBeaconData",void 0),B(this,"lastEventTime",void 0),B(this,"rateLimited",void 0),B(this,"pageLevelData",void 0),B(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=s,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new X1($1(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var v;this.disableCookies=(v=this.options.disableCookies)!==null&&v!==void 0?v:!1;var y;this.respectDoNotTrack=(y=this.options.respectDoNotTrack)!==null&&y!==void 0?y:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(r=this.options.platform)===null||r===void 0?void 0:r.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(c=this.options.platform)===null||c===void 0||(d=c.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(u=h.os)===null||u===void 0?void 0:u.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:G1(),page_url:Vc.default===null||Vc.default===void 0||(p=Vc.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:U1()}return Fi(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Ku())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var s=this.disableCookies?{}:F1(),r=nm(Pd({},this.pageLevelData,t,s,this.viewerData),{event:e,env_key:this.envKey});r.user_id&&(r.viewer_user_id=r.user_id,delete r.user_id);var n,a=((n=r.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,r),l=qu(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,r,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,r,l),!this.rateLimited){if(Pe.info("Sending event",e,r,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):eA.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return r.event="eventrateexceeded",l=qu(r),this.eventQueue.queueEvent(r.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var s=this,r={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=tA)r=Pd({},t),n&&(this.previousBeaconData=r),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=Tr(o,2),d=l[0],c=l[1];s.previousBeaconData&&(c!==s.previousBeaconData[d]||Q1.indexOf(d)>-1||s.objectHasChanged(a,d,c,s.previousBeaconData[d])||s.eventRequiresKey(e,d))&&(r[d]=c,s.previousBeaconData[d]=c)})}return r}},{key:"objectHasChanged",value:function(e,t,s,r){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof s!="object"||typeof r!="object"?!0:Object.keys(s||{}).length!==Object.keys(r||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||J1.includes(t)&&Z1.includes(e))}}]),i}(),sA=function i(e){ct(this,i);var t=0,s=0,r=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,v=f.request_bytes_loaded;n++;var y,b;if(p?(y=p-(m??0),b=(g??0)-p):b=(g??0)-(m??0),b>0&&v&&v>0){var x=v/b*8e3;a++,s+=v,r+=b,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,x),e.data.view_average_request_throughput=s/r*8e3,e.data.view_request_count=n,y>0&&(t+=y,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,y),e.data.view_average_request_latency=t/a)}},c=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},u=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",c),e.on("requestcanceled",u)},rA=sA,nA=60*60*1e3,aA=function i(e){var t=this;ct(this,i),B(this,"_lastEventTime",void 0),e.on("before*",function(s,r){var n=r.viewer_time,a=Qe.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>nA){var l=Object.keys(e.data).reduce(function(d,c){return c.indexOf("video_")===0?Object.assign(d,B({},c,e.data[c])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view"),e.emit("viewinit",Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing&&s.type!=="play"&&s.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),s.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},oA=aA,lA=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],dA=function(i){V_(t,i);var e=j_(t);function t(s,r,n){ct(this,t);var a;a=e.call(this),B(ne(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),B(ne(a),"NAVIGATION_START",void 0),B(ne(a),"_destroyed",void 0),B(ne(a),"_heartBeatTimeout",void 0),B(ne(a),"adTracker",void 0),B(ne(a),"dashjs",void 0),B(ne(a),"data",void 0),B(ne(a),"disablePlayheadRebufferTracking",void 0),B(ne(a),"disableRebufferTracking",void 0),B(ne(a),"errorTracker",void 0),B(ne(a),"errorTranslator",void 0),B(ne(a),"getAdData",void 0),B(ne(a),"getPlayheadTime",void 0),B(ne(a),"getStateData",void 0),B(ne(a),"hlsjs",void 0),B(ne(a),"id",void 0),B(ne(a),"longResumeTracker",void 0),B(ne(a),"minimumRebufferDuration",void 0),B(ne(a),"mux",void 0),B(ne(a),"oldEmit",void 0),B(ne(a),"playbackEventDispatcher",void 0),B(ne(a),"playbackHeartbeat",void 0),B(ne(a),"playbackHeartbeatTime",void 0),B(ne(a),"playheadTime",void 0),B(ne(a),"seekingTracker",void 0),B(ne(a),"sustainedRebufferThreshold",void 0),B(ne(a),"watchTimeTracker",void 0),B(ne(a),"currentFragmentPDT",void 0),B(ne(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=Od.domContentLoadedEventEnd(),a.NAVIGATION_START=Od.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(f){return f}};a.mux=s,a.id=r,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.setLevel(n.debug?"debug":"warn"),a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.playbackEventDispatcher=new iA(s,n.data.env_key,n),a.data={player_instance_id:Ka(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1,a.oldEmit=a.emit,a.emit=function(f,m){m=Object.assign({viewer_time:this.mux.utils.now()},m),this.oldEmit(f,m)};var l=(function(){typeof this.data.view_start>"u"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}).bind(ne(a));a.on("viewinit",function(f,m){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,m),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)});var d=(function(f){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",f)}).bind(ne(a));if(a.on("videochange",function(f,m){d(m)}),a.on("programchange",function(f,m){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),d(Object.assign(m,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(f,m){this.currentFragmentPDT=m.currentFragmentPDT,this.currentFragmentStart=m.currentFragmentStart}),a.on("destroy",a.destroy),typeof window<"u"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var c=function(){var f=typeof a.data.view_start<"u";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",f&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",c,!1);var u=function(f){f.persisted||a.destroy()};window.addEventListener("pagehide",u,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",c),window.removeEventListener("pagehide",u)})}a.on("playerready",function(f,m){Object.assign(this.data,m)}),lA.forEach(function(f){a.on(f,function(m,p){f.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,p),this._sanitizeData()}),a.on("after"+f,function(){(f!=="error"||this.errorTracker.viewErrored)&&this.send(f)})}),a.on("viewend",function(f,m){Object.assign(a.data,m)});var h=function(f){var m=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=m-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",h),a.longResumeTracker=new oA(ne(a)),a.errorTracker=new h1(ne(a)),new N1(ne(a)),a.seekingTracker=new R1(ne(a)),a.playheadTime=new E1(ne(a)),a.playbackHeartbeat=new c1(ne(a)),new k1(ne(a)),a.watchTimeTracker=new m1(ne(a)),new g1(ne(a)),a.adTracker=new D1(ne(a)),new _1(ne(a)),new y1(ne(a)),new S1(ne(a)),new O1(ne(a)),new rA(ne(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Fi(t,[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start<"u"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(s){if(this.data.view_id){var r=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(r.video_source_is_live===void 0&&(r.player_source_duration===1/0||r.video_source_duration===1/0?r.video_source_is_live=!0:(r.player_source_duration>0||r.video_source_duration>0)&&(r.video_source_is_live=!1)),r.video_source_is_live||n.forEach(function(d){r[d]=void 0}),r.video_source_url=r.video_source_url||r.player_source_url,r.video_source_url){var a=Tr(qa(r.video_source_url),2),o=a[0],l=a[1];r.video_source_domain=l,r.video_source_hostname=o}delete r.ad_request_id,this.playbackEventDispatcher.send(s,r),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),s==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var s=this,r=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];r.forEach(function(a){var o=parseInt(s.data[a],10);s.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(s.data[a]){var o=s.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(s.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var s=this;Object.keys(this.data).forEach(function(r){r.indexOf("video_")===0&&delete s.data[r]})}},{key:"_resetViewData",value:function(){var s=this;Object.keys(this.data).forEach(function(r){r.indexOf("view_")===0&&delete s.data[r]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var s=this,r=this.data.view_id=Ka(),n=function(){r===s.data.view_id&&We(s.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var s=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){s.data.player_is_paused||s.emit("hb")},1e4)}},{key:"addHLSJS",value:function(s){if(!s.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=s.hlsjs,e1(this.mux,this.id,s.hlsjs,{},s.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(t1(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(s){if(!s.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=s.dashjs,n1(this.mux,this.id,s.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(a1(this.dashjs),this.dashjs=void 0)}}]),t}(l1),cA=dA;Sc();var Kn=Dt(N_());function uA(){return Kn.default&&!!(Kn.default.fullscreenElement||Kn.default.webkitFullscreenElement||Kn.default.mozFullScreenElement||Kn.default.msFullscreenElement)}var hA=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],fA={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function mA(i,e,t){var s=Tr(Wu(e),3),r=s[0],n=s[1],a=s[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,c={automaticErrorTracking:!0};if(r){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");r.mux&&(r.mux.destroy(),delete r.mux,o.warn("Already monitoring this video element, replacing existing event listeners")),t=Object.assign(c,t),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),t.getPlayheadTime=function(){return d(r.currentTime)},t.getStateData=function(){var h,f=this.hlsjs&&this.hlsjs.url,m=this.dashjs&&yt(this.dashjs.getSource==="function")&&this.dashjs.getSource(),p={player_is_paused:r.paused,player_playhead_time:d(r.currentTime),player_width:parseInt(l(r,"width")),player_height:parseInt(l(r,"height")),player_autoplay_on:r.autoplay,player_preload_on:r.preload,player_language_code:r.lang,player_is_fullscreen:uA(),video_poster_url:r.poster,video_source_url:f||m||r.currentSrc,video_source_duration:d(r.duration),video_source_height:r.videoHeight,video_source_width:r.videoWidth,view_dropped_frame_count:r==null||(h=r.getVideoPlaybackQuality)===null||h===void 0?void 0:h.call(r).droppedVideoFrames},g=t.getPlayheadTime();if(r.getStartDate&&g>0){var v=r.getStartDate();if(v&&typeof v.getTime=="function"&&v.getTime()){var y=v.getTime();if(p.player_program_time=y+g,r.seekable.length>0){var b=y+r.seekable.end(r.seekable.length-1);p.player_live_edge_program_time=b}}}return p},r.mux=r.mux||{},r.mux.deleted=!1,r.mux.emit=function(h,f){i.emit(n,h,f)};var u=function(){o.error("The monitor for this video element has already been destroyed.")};r.mux.destroy=function(){Object.keys(r.mux.listeners).forEach(function(h){r.removeEventListener(h,r.mux.listeners[h],!1)}),delete r.mux.listeners,r.mux.destroy=u,r.mux.swapElement=u,r.mux.emit=u,r.mux.addHLSJS=u,r.mux.addDashJS=u,r.mux.removeHLSJS=u,r.mux.removeDashJS=u,r.mux.deleted=!0,i.emit(n,"destroy")},r.mux.swapElement=function(h){var f=Tr(Wu(h),3),m=f[0],p=f[1],g=f[2];if(m){if(g!=="video"&&g!=="audio")return i.log.error("The element of `"+p+"` was not a media element.")}else return i.log.error("No element was found with the `"+p+"` query selector.");m.muxId=r.muxId,delete r.muxId,m.mux=m.mux||{},m.mux.listeners=Object.assign({},r.mux.listeners),delete r.mux.listeners,Object.keys(m.mux.listeners).forEach(function(v){r.removeEventListener(v,m.mux.listeners[v],!1),m.addEventListener(v,m.mux.listeners[v],!1)}),m.mux.swapElement=r.mux.swapElement,m.mux.destroy=r.mux.destroy,delete r.mux,r=m},r.mux.addHLSJS=function(h){i.addHLSJS(n,h)},r.mux.addDashJS=function(h){i.addDashJS(n,h)},r.mux.removeHLSJS=function(){i.removeHLSJS(n)},r.mux.removeDashJS=function(){i.removeDashJS(n)},i.init(n,t),i.emit(n,"playerready"),r.paused||(i.emit(n,"play"),r.readyState>2&&i.emit(n,"playing")),r.mux.listeners={},hA.forEach(function(h){h==="error"&&!t.automaticErrorTracking||(r.mux.listeners[h]=function(){var f={};if(h==="error"){if(!r.error||r.error.code===1)return;f.player_error_code=r.error.code,f.player_error_message=fA[r.error.code]||r.error.message}i.emit(n,h,f)},r.addEventListener(h,r.mux.listeners[h],!1))})}function pA(i,e,t,s){var r=s;if(i&&typeof i[e]=="function")try{r=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return r}var Ma=Dt(Ui()),$r;Ma.default&&Ma.default.WeakMap&&($r=new WeakMap);function gA(i,e){if(!i||!e||!Ma.default||typeof Ma.default.getComputedStyle!="function")return"";var t;return $r&&$r.has(i)&&(t=$r.get(i)),t||(t=Ma.default.getComputedStyle(i,null),$r&&$r.set(i,t)),t.getPropertyValue(e)}function vA(i){return Math.floor(i*1e3)}var Ls={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},xc=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};xc.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
13
+ `):"");n("error",{player_error_code:b==null?void 0:b.code,player_error_message:b==null?void 0:b.message,player_error_context:D})};t.on("error",v),t._stopMuxMonitor=function(){t.off("manifestLoaded",a),t.off("initFragmentLoaded",c),t.off("mediaFragmentLoaded",h),t.off("qualityChangeRendered",p),t.off("error",v),t.off("fragmentLoadingAbandoned",g),delete t._stopMuxMonitor}},o1=function(i){i&&typeof i._stopMuxMonitor=="function"&&i._stopMuxMonitor()},Pp=0,l1=function(){function i(){ct(this,i),B(this,"_listeners",void 0)}return Fi(i,[{key:"on",value:function(e,t,s){return t._eventEmitterGuid=t._eventEmitterGuid||++Pp,this._listeners=this._listeners||{},this._listeners[e]=this._listeners[e]||[],s&&(t=t.bind(s)),this._listeners[e].push(t),t}},{key:"off",value:function(e,t){var s=this._listeners&&this._listeners[e];s&&s.forEach(function(r,n){r._eventEmitterGuid===t._eventEmitterGuid&&s.splice(n,1)})}},{key:"one",value:function(e,t,s){var r=this;t._eventEmitterGuid=t._eventEmitterGuid||++Pp;var n=function(){r.off(e,n),t.apply(s||this,arguments)};n._eventEmitterGuid=t._eventEmitterGuid,this.on(e,n)}},{key:"emit",value:function(e,t){var s=this;if(this._listeners){t=t||{};var r=this._listeners["before*"]||[],n=this._listeners[e]||[],a=this._listeners["after"+e]||[],o=function(l,d){l=l.slice(),l.forEach(function(c){c.call(s,{type:e},d)})};o(r,t),o(n,t),o(a,t)}}}]),i}(),d1=l1,Kc=Dt(Ui()),c1=function(){function i(e){var t=this;ct(this,i),B(this,"_playbackHeartbeatInterval",void 0),B(this,"_playheadShouldBeProgressing",void 0),B(this,"pm",void 0),this.pm=e,this._playbackHeartbeatInterval=null,this._playheadShouldBeProgressing=!1,e.on("playing",function(){t._playheadShouldBeProgressing=!0}),e.on("play",this._startPlaybackHeartbeatInterval.bind(this)),e.on("playing",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adbreakstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplay",this._startPlaybackHeartbeatInterval.bind(this)),e.on("adplaying",this._startPlaybackHeartbeatInterval.bind(this)),e.on("devicewake",this._startPlaybackHeartbeatInterval.bind(this)),e.on("viewstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("rebufferstart",this._startPlaybackHeartbeatInterval.bind(this)),e.on("pause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("ended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("viewend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("error",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("aderror",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adpause",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adended",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("adbreakend",this._stopPlaybackHeartbeatInterval.bind(this)),e.on("seeked",function(){e.data.player_is_paused?t._stopPlaybackHeartbeatInterval():t._startPlaybackHeartbeatInterval()}),e.on("timeupdate",function(){t._playbackHeartbeatInterval!==null&&e.emit("playbackheartbeat")}),e.on("devicesleep",function(s,r){t._playbackHeartbeatInterval!==null&&(Kc.default.clearInterval(t._playbackHeartbeatInterval),e.emit("playbackheartbeatend",{viewer_time:r.viewer_time}),t._playbackHeartbeatInterval=null)})}return Fi(i,[{key:"_startPlaybackHeartbeatInterval",value:function(){var e=this;this._playbackHeartbeatInterval===null&&(this.pm.emit("playbackheartbeat"),this._playbackHeartbeatInterval=Kc.default.setInterval(function(){e.pm.emit("playbackheartbeat")},this.pm.playbackHeartbeatTime))}},{key:"_stopPlaybackHeartbeatInterval",value:function(){this._playheadShouldBeProgressing=!1,this._playbackHeartbeatInterval!==null&&(Kc.default.clearInterval(this._playbackHeartbeatInterval),this.pm.emit("playbackheartbeatend"),this._playbackHeartbeatInterval=null)}}]),i}(),u1=c1,h1=function i(e){var t=this;ct(this,i),B(this,"viewErrored",void 0),e.on("viewinit",function(){t.viewErrored=!1}),e.on("error",function(s,r){try{var n=e.errorTranslator({player_error_code:r.player_error_code,player_error_message:r.player_error_message,player_error_context:r.player_error_context,player_error_severity:r.player_error_severity,player_error_business_exception:r.player_error_business_exception});n&&(e.data.player_error_code=n.player_error_code||r.player_error_code,e.data.player_error_message=n.player_error_message||r.player_error_message,e.data.player_error_context=n.player_error_context||r.player_error_context,e.data.player_error_severity=n.player_error_severity||r.player_error_severity,e.data.player_error_business_exception=n.player_error_business_exception||r.player_error_business_exception,t.viewErrored=!0)}catch(a){e.mux.log.warn("Exception in error translator callback.",a),t.viewErrored=!0}}),e.on("aftererror",function(){var s,r,n,a,o;(s=e.data)===null||s===void 0||delete s.player_error_code,(r=e.data)===null||r===void 0||delete r.player_error_message,(n=e.data)===null||n===void 0||delete n.player_error_context,(a=e.data)===null||a===void 0||delete a.player_error_severity,(o=e.data)===null||o===void 0||delete o.player_error_business_exception})},f1=h1,m1=function(){function i(e){ct(this,i),B(this,"_watchTimeTrackerLastCheckedTime",void 0),B(this,"pm",void 0),this.pm=e,this._watchTimeTrackerLastCheckedTime=null,e.on("playbackheartbeat",this._updateWatchTime.bind(this)),e.on("playbackheartbeatend",this._clearWatchTimeState.bind(this))}return Fi(i,[{key:"_updateWatchTime",value:function(e,t){var s=t.viewer_time;this._watchTimeTrackerLastCheckedTime===null&&(this._watchTimeTrackerLastCheckedTime=s),We(this.pm.data,"view_watch_time",s-this._watchTimeTrackerLastCheckedTime),this._watchTimeTrackerLastCheckedTime=s}},{key:"_clearWatchTimeState",value:function(e,t){this._updateWatchTime(e,t),this._watchTimeTrackerLastCheckedTime=null}}]),i}(),p1=m1,g1=function(){function i(e){var t=this;ct(this,i),B(this,"_playbackTimeTrackerLastPlayheadPosition",void 0),B(this,"_lastTime",void 0),B(this,"_isAdPlaying",void 0),B(this,"_callbackUpdatePlaybackTime",void 0),B(this,"pm",void 0),this.pm=e,this._playbackTimeTrackerLastPlayheadPosition=-1,this._lastTime=Qe.now(),this._isAdPlaying=!1,this._callbackUpdatePlaybackTime=null;var s=this._startPlaybackTimeTracking.bind(this);e.on("playing",s),e.on("adplaying",s),e.on("seeked",s);var r=this._stopPlaybackTimeTracking.bind(this);e.on("playbackheartbeatend",r),e.on("seeking",r),e.on("adplaying",function(){t._isAdPlaying=!0}),e.on("adended",function(){t._isAdPlaying=!1}),e.on("adpause",function(){t._isAdPlaying=!1}),e.on("adbreakstart",function(){t._isAdPlaying=!1}),e.on("adbreakend",function(){t._isAdPlaying=!1}),e.on("adplay",function(){t._isAdPlaying=!1}),e.on("viewinit",function(){t._playbackTimeTrackerLastPlayheadPosition=-1,t._lastTime=Qe.now(),t._isAdPlaying=!1,t._callbackUpdatePlaybackTime=null})}return Fi(i,[{key:"_startPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime===null&&(this._callbackUpdatePlaybackTime=this._updatePlaybackTime.bind(this),this._playbackTimeTrackerLastPlayheadPosition=this.pm.data.player_playhead_time,this.pm.on("playbackheartbeat",this._callbackUpdatePlaybackTime))}},{key:"_stopPlaybackTimeTracking",value:function(){this._callbackUpdatePlaybackTime&&(this._updatePlaybackTime(),this.pm.off("playbackheartbeat",this._callbackUpdatePlaybackTime),this._callbackUpdatePlaybackTime=null,this._playbackTimeTrackerLastPlayheadPosition=-1)}},{key:"_updatePlaybackTime",value:function(){var e=this.pm.data.player_playhead_time,t=Qe.now(),s=-1;this._playbackTimeTrackerLastPlayheadPosition>=0&&e>this._playbackTimeTrackerLastPlayheadPosition?s=e-this._playbackTimeTrackerLastPlayheadPosition:this._isAdPlaying&&(s=t-this._lastTime),s>0&&s<=1e3&&We(this.pm.data,"view_content_playback_time",s),this._playbackTimeTrackerLastPlayheadPosition=e,this._lastTime=t}}]),i}(),v1=g1,E1=function(){function i(e){ct(this,i),B(this,"pm",void 0),this.pm=e;var t=this._updatePlayheadTime.bind(this);e.on("playbackheartbeat",t),e.on("playbackheartbeatend",t),e.on("timeupdate",t),e.on("destroy",function(){e.off("timeupdate",t)})}return Fi(i,[{key:"_updateMaxPlayheadPosition",value:function(){this.pm.data.view_max_playhead_position=typeof this.pm.data.view_max_playhead_position>"u"?this.pm.data.player_playhead_time:Math.max(this.pm.data.view_max_playhead_position,this.pm.data.player_playhead_time)}},{key:"_updatePlayheadTime",value:function(e,t){var s=this,r=function(){s.pm.currentFragmentPDT&&s.pm.currentFragmentStart&&(s.pm.data.player_program_time=s.pm.currentFragmentPDT+s.pm.data.player_playhead_time-s.pm.currentFragmentStart)};if(t&&t.player_playhead_time)this.pm.data.player_playhead_time=t.player_playhead_time,r(),this._updateMaxPlayheadPosition();else if(this.pm.getPlayheadTime){var n=this.pm.getPlayheadTime();typeof n<"u"&&(this.pm.data.player_playhead_time=n,r(),this._updateMaxPlayheadPosition())}}}]),i}(),b1=E1,Np=5*60*1e3,y1=function i(e){if(ct(this,i),!e.disableRebufferTracking){var t,s=function(n,a){r(a),t=void 0},r=function(n){if(t){var a=n.viewer_time-t;We(e.data,"view_rebuffer_duration",a),t=n.viewer_time,e.data.view_rebuffer_duration>Np&&(e.emit("viewend"),e.send("viewend"),e.mux.log.warn("Ending view after rebuffering for longer than ".concat(Np,"ms, future events will be ignored unless a programchange or videochange occurs.")))}e.data.view_watch_time>=0&&e.data.view_rebuffer_count>0&&(e.data.view_rebuffer_frequency=e.data.view_rebuffer_count/e.data.view_watch_time,e.data.view_rebuffer_percentage=e.data.view_rebuffer_duration/e.data.view_watch_time)};e.on("playbackheartbeat",function(n,a){return r(a)}),e.on("rebufferstart",function(n,a){t||(We(e.data,"view_rebuffer_count",1),t=a.viewer_time,e.one("rebufferend",s))}),e.on("viewinit",function(){t=void 0,e.off("rebufferend",s)})}},T1=y1,_1=function(){function i(e){var t=this;ct(this,i),B(this,"_lastCheckedTime",void 0),B(this,"_lastPlayheadTime",void 0),B(this,"_lastPlayheadTimeUpdatedTime",void 0),B(this,"_rebuffering",void 0),B(this,"pm",void 0),this.pm=e,!(e.disableRebufferTracking||e.disablePlayheadRebufferTracking)&&(this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null,e.on("playbackheartbeat",this._checkIfRebuffering.bind(this)),e.on("playbackheartbeatend",this._cleanupRebufferTracker.bind(this)),e.on("seeking",function(){t._cleanupRebufferTracker(null,{viewer_time:Qe.now()})}))}return Fi(i,[{key:"_checkIfRebuffering",value:function(e,t){if(this.pm.seekingTracker.isSeeking||this.pm.adTracker.isAdBreak||!this.pm.playbackHeartbeat._playheadShouldBeProgressing){this._cleanupRebufferTracker(e,t);return}if(this._lastCheckedTime===null){this._prepareRebufferTrackerState(t.viewer_time);return}if(this._lastPlayheadTime!==this.pm.data.player_playhead_time){this._cleanupRebufferTracker(e,t,!0);return}var s=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.sustainedRebufferThreshold=="number"&&s>=this.pm.sustainedRebufferThreshold&&(this._rebuffering||(this._rebuffering=!0,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}))),this._lastCheckedTime=t.viewer_time}},{key:"_clearRebufferTrackerState",value:function(){this._lastCheckedTime=null,this._lastPlayheadTime=null,this._lastPlayheadTimeUpdatedTime=null}},{key:"_prepareRebufferTrackerState",value:function(e){this._lastCheckedTime=e,this._lastPlayheadTime=this.pm.data.player_playhead_time,this._lastPlayheadTimeUpdatedTime=e}},{key:"_cleanupRebufferTracker",value:function(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(this._rebuffering)this._rebuffering=!1,this.pm.emit("rebufferend",{viewer_time:t.viewer_time});else{if(this._lastCheckedTime===null)return;var r=this.pm.data.player_playhead_time-this._lastPlayheadTime,n=t.viewer_time-this._lastPlayheadTimeUpdatedTime;typeof this.pm.minimumRebufferDuration=="number"&&r>0&&n-r>this.pm.minimumRebufferDuration&&(this._lastCheckedTime=null,this.pm.emit("rebufferstart",{viewer_time:this._lastPlayheadTimeUpdatedTime}),this.pm.emit("rebufferend",{viewer_time:this._lastPlayheadTimeUpdatedTime+n-r}))}s?this._prepareRebufferTrackerState(t.viewer_time):this._clearRebufferTrackerState()}}]),i}(),A1=_1,S1=function(){function i(e){var t=this;ct(this,i),B(this,"NAVIGATION_START",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){var s=e.data,r=s.view_id;if(!s.view_program_changed){var n=function(a,o){var l=o.viewer_time;(a.type==="playing"&&typeof e.data.view_time_to_first_frame>"u"||a.type==="adplaying"&&(typeof e.data.view_time_to_first_frame>"u"||t._inPrerollPosition()))&&t.calculateTimeToFirstFrame(l||Qe.now(),r)};e.one("playing",n),e.one("adplaying",n),e.one("viewend",function(){e.off("playing",n),e.off("adplaying",n)})}})}return Fi(i,[{key:"_inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"calculateTimeToFirstFrame",value:function(e,t){t===this.pm.data.view_id&&(this.pm.watchTimeTracker._updateWatchTime(null,{viewer_time:e}),this.pm.data.view_time_to_first_frame=this.pm.data.view_watch_time,(this.pm.data.player_autoplay_on||this.pm.data.video_is_autoplay)&&this.NAVIGATION_START&&(this.pm.data.view_aggregate_startup_time=this.pm.data.view_start+this.pm.data.view_watch_time-this.NAVIGATION_START))}}]),i}(),x1=S1,k1=function i(e){var t=this;ct(this,i),B(this,"_lastPlayerHeight",void 0),B(this,"_lastPlayerWidth",void 0),B(this,"_lastPlayheadPosition",void 0),B(this,"_lastSourceHeight",void 0),B(this,"_lastSourceWidth",void 0),e.on("viewinit",function(){t._lastPlayheadPosition=-1});var s=["pause","rebufferstart","seeking","error","adbreakstart","hb"],r=["playing","hb"];s.forEach(function(n){e.on(n,function(){if(t._lastPlayheadPosition>=0&&e.data.player_playhead_time>=0&&t._lastPlayerWidth>=0&&t._lastSourceWidth>0&&t._lastPlayerHeight>=0&&t._lastSourceHeight>0){var a=e.data.player_playhead_time-t._lastPlayheadPosition;if(a<0){t._lastPlayheadPosition=-1;return}var o=Math.min(t._lastPlayerWidth/t._lastSourceWidth,t._lastPlayerHeight/t._lastSourceHeight),l=Math.max(0,o-1),d=Math.max(0,1-o);e.data.view_max_upscale_percentage=Math.max(e.data.view_max_upscale_percentage||0,l),e.data.view_max_downscale_percentage=Math.max(e.data.view_max_downscale_percentage||0,d),We(e.data,"view_total_content_playback_time",a),We(e.data,"view_total_upscaling",l*a),We(e.data,"view_total_downscaling",d*a)}t._lastPlayheadPosition=-1})}),r.forEach(function(n){e.on(n,function(){t._lastPlayheadPosition=e.data.player_playhead_time,t._lastPlayerWidth=e.data.player_width,t._lastPlayerHeight=e.data.player_height,t._lastSourceWidth=e.data.video_source_width,t._lastSourceHeight=e.data.video_source_height})})},L1=k1,I1=2e3,R1=function i(e){var t=this;ct(this,i),B(this,"isSeeking",void 0),this.isSeeking=!1;var s=-1,r=function(){var n=Qe.now(),a=(e.data.viewer_time||n)-(s||n);We(e.data,"view_seek_duration",a),e.data.view_max_seek_time=Math.max(e.data.view_max_seek_time||0,a),t.isSeeking=!1,s=-1};e.on("seeking",function(n,a){if(Object.assign(e.data,a),t.isSeeking&&a.viewer_time-s<=I1){s=a.viewer_time;return}t.isSeeking&&r(),t.isSeeking=!0,s=a.viewer_time,We(e.data,"view_seek_count",1),e.send("seeking")}),e.on("seeked",function(){r()}),e.on("viewend",function(){t.isSeeking&&(r(),e.send("seeked")),t.isSeeking=!1,s=-1})},w1=R1,Up=function(i,e){i.push(e),i.sort(function(t,s){return t.viewer_time-s.viewer_time})},C1=["adbreakstart","adrequest","adresponse","adplay","adplaying","adpause","adended","adbreakend","aderror","adclicked","adskipped"],D1=function(){function i(e){var t=this;ct(this,i),B(this,"_adHasPlayed",void 0),B(this,"_adRequests",void 0),B(this,"_adResponses",void 0),B(this,"_currentAdRequestNumber",void 0),B(this,"_currentAdResponseNumber",void 0),B(this,"_prerollPlayTime",void 0),B(this,"_wouldBeNewAdPlay",void 0),B(this,"isAdBreak",void 0),B(this,"pm",void 0),this.pm=e,e.on("viewinit",function(){t.isAdBreak=!1,t._currentAdRequestNumber=0,t._currentAdResponseNumber=0,t._adRequests=[],t._adResponses=[],t._adHasPlayed=!1,t._wouldBeNewAdPlay=!0,t._prerollPlayTime=void 0}),C1.forEach(function(r){return e.on(r,t._updateAdData.bind(t))});var s=function(){t.isAdBreak=!1};e.on("adbreakstart",function(){t.isAdBreak=!0}),e.on("play",s),e.on("playing",s),e.on("viewend",s),e.on("adrequest",function(r,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdRequestNumber++},n),Up(t._adRequests,n),We(e.data,"view_ad_request_count"),t.inPrerollPosition()&&(e.data.view_preroll_requested=!0,t._adHasPlayed||We(e.data,"view_preroll_request_count"))}),e.on("adresponse",function(r,n){n=Object.assign({ad_request_id:"generatedAdRequestId"+t._currentAdResponseNumber++},n),Up(t._adResponses,n);var a=t.findAdRequest(n.ad_request_id);a&&We(e.data,"view_ad_request_time",Math.max(0,n.viewer_time-a.viewer_time))}),e.on("adplay",function(r,n){t._adHasPlayed=!0,t._wouldBeNewAdPlay&&(t._wouldBeNewAdPlay=!1,We(e.data,"view_ad_played_count")),t.inPrerollPosition()&&!e.data.view_preroll_played&&(e.data.view_preroll_played=!0,t._adRequests.length>0&&(e.data.view_preroll_request_time=Math.max(0,n.viewer_time-t._adRequests[0].viewer_time)),e.data.view_start&&(e.data.view_startup_preroll_request_time=Math.max(0,n.viewer_time-e.data.view_start)),t._prerollPlayTime=n.viewer_time)}),e.on("adplaying",function(r,n){t.inPrerollPosition()&&typeof e.data.view_preroll_load_time>"u"&&typeof t._prerollPlayTime<"u"&&(e.data.view_preroll_load_time=n.viewer_time-t._prerollPlayTime,e.data.view_startup_preroll_load_time=n.viewer_time-t._prerollPlayTime)}),e.on("adclicked",function(r,n){t._wouldBeNewAdPlay||We(e.data,"view_ad_clicked_count")}),e.on("adskipped",function(r,n){t._wouldBeNewAdPlay||We(e.data,"view_ad_skipped_count")}),e.on("adended",function(){t._wouldBeNewAdPlay=!0}),e.on("aderror",function(){t._wouldBeNewAdPlay=!0})}return Fi(i,[{key:"inPrerollPosition",value:function(){return typeof this.pm.data.view_content_playback_time>"u"||this.pm.data.view_content_playback_time<=1e3}},{key:"findAdRequest",value:function(e){for(var t=0;t<this._adRequests.length;t++)if(this._adRequests[t].ad_request_id===e)return this._adRequests[t]}},{key:"_updateAdData",value:function(e,t){if(this.inPrerollPosition()){if(!this.pm.data.view_preroll_ad_tag_hostname&&t.ad_tag_url){var s=Tr(qa(t.ad_tag_url),2),r=s[0],n=s[1];this.pm.data.view_preroll_ad_tag_domain=n,this.pm.data.view_preroll_ad_tag_hostname=r}if(!this.pm.data.view_preroll_ad_asset_hostname&&t.ad_asset_url){var a=Tr(qa(t.ad_asset_url),2),o=a[0],l=a[1];this.pm.data.view_preroll_ad_asset_domain=l,this.pm.data.view_preroll_ad_asset_hostname=o}}this.pm.data.ad_asset_url=t==null?void 0:t.ad_asset_url,this.pm.data.ad_tag_url=t==null?void 0:t.ad_tag_url,this.pm.data.ad_creative_id=t==null?void 0:t.ad_creative_id,this.pm.data.ad_id=t==null?void 0:t.ad_id,this.pm.data.ad_universal_id=t==null?void 0:t.ad_universal_id}}]),i}(),M1=D1,Fp=Dt(Ui()),O1=function i(e){ct(this,i);var t,s,r=function(){e.disableRebufferTracking||(We(e.data,"view_waiting_rebuffer_count",1),t=Qe.now(),s=Fp.default.setInterval(function(){if(t){var d=Qe.now();We(e.data,"view_waiting_rebuffer_duration",d-t),t=d}},250))},n=function(){e.disableRebufferTracking||t&&(We(e.data,"view_waiting_rebuffer_duration",Qe.now()-t),t=!1,Fp.default.clearInterval(s))},a=!1,o=function(){a=!0},l=function(){a=!1,n()};e.on("waiting",function(){a&&r()}),e.on("playing",function(){n(),o()}),e.on("pause",l),e.on("seeking",l)},P1=O1,N1=function i(e){var t=this;ct(this,i),B(this,"lastWallClockTime",void 0);var s=function(){t.lastWallClockTime=Qe.now(),e.on("before*",r)},r=function(n){var a=Qe.now(),o=t.lastWallClockTime;t.lastWallClockTime=a,a-o>3e4&&(e.emit("devicesleep",{viewer_time:o}),Object.assign(e.data,{viewer_time:o}),e.send("devicesleep"),e.emit("devicewake",{viewer_time:a}),Object.assign(e.data,{viewer_time:a}),e.send("devicewake"))};e.one("playbackheartbeat",s),e.on("playbackheartbeatend",function(){e.off("before*",r),e.one("playbackheartbeat",s)})},U1=N1,Vc=Dt(Ui()),gv=Dt(I_()),vv=Dt(R_()),Ev="muxData",bv=function(){var i;try{i=gv.default.parse(vv.default.get(Ev)||"")}catch{i={}}return i},yv=function(i){try{vv.default.set(Ev,gv.default.stringify(i),{expires:365})}catch{}},F1=function(){var i=bv();return i.mux_viewer_id=i.mux_viewer_id||Ka(),i.msn=i.msn||Math.random(),yv(i),{mux_viewer_id:i.mux_viewer_id,mux_sample_number:i.msn}},$1=function(){var i=bv(),e=Qe.now();return i.session_start&&(i.sst=i.session_start,delete i.session_start),i.session_id&&(i.sid=i.session_id,delete i.session_id),i.session_expires&&(i.sex=i.session_expires,delete i.session_expires),(!i.sex||i.sex<e)&&(i.sid=Ka(),i.sst=e),i.sex=e+25*60*1e3,yv(i),{session_id:i.sid,session_start:i.sst,session_expires:i.sex}};function B1(i,e){var t=e.beaconCollectionDomain,s=e.beaconDomain;if(t)return"https://"+t;i=i||"inferred";var r=s||"litix.io";return i.match(/^[a-z0-9]+$/)?"https://"+i+"."+r:"https://img.litix.io/a.gif"}var G1=Dt(Ui()),Tv=function(){var i;switch(_v()){case"cellular":i="cellular";break;case"ethernet":i="wired";break;case"wifi":i="wifi";break;case void 0:break;default:i="other"}return i},_v=function(){var i=G1.default.navigator,e=i&&(i.connection||i.mozConnection||i.webkitConnection);return e&&e.type};Tv.getConnectionFromAPI=_v;var H1=Tv,W1={a:"env",b:"beacon",c:"custom",d:"ad",e:"event",f:"experiment",i:"internal",m:"mux",n:"response",p:"player",q:"request",r:"retry",s:"session",t:"timestamp",u:"viewer",v:"video",w:"page",x:"view",y:"sub"},K1=Av(W1),V1={ad:"ad",ag:"aggregate",ap:"api",al:"application",ar:"architecture",as:"asset",au:"autoplay",av:"average",bi:"bitrate",br:"break",bw:"browser",by:"bytes",bz:"business",ca:"cached",cb:"cancel",cc:"codec",cd:"code",cg:"category",ch:"changed",ck:"clicked",cl:"canceled",cn:"config",co:"count",ce:"counter",cp:"complete",cr:"creative",ct:"content",cu:"current",cx:"connection",cz:"context",dg:"downscaling",dm:"domain",dn:"cdn",do:"downscale",dr:"drm",dp:"dropped",du:"duration",dv:"device",ec:"encoding",ed:"edge",en:"end",eg:"engine",em:"embed",er:"error",ep:"experiments",es:"errorcode",et:"errortext",ee:"event",ev:"events",ex:"expires",ez:"exception",fa:"failed",fi:"first",fm:"family",ft:"format",fp:"fps",fq:"frequency",fr:"frame",fs:"fullscreen",ha:"has",hb:"holdback",he:"headers",ho:"host",hn:"hostname",ht:"height",id:"id",ii:"init",in:"instance",ip:"ip",is:"is",ke:"key",la:"language",lb:"labeled",le:"level",li:"live",ld:"loaded",lo:"load",ls:"lists",lt:"latency",ma:"max",md:"media",me:"message",mf:"manifest",mi:"mime",ml:"midroll",mm:"min",mn:"manufacturer",mo:"model",mx:"mux",ne:"newest",nm:"name",no:"number",on:"on",os:"os",pa:"paused",pb:"playback",pd:"producer",pe:"percentage",pf:"played",pg:"program",ph:"playhead",pi:"plugin",pl:"preroll",pn:"playing",po:"poster",pr:"preload",ps:"position",pt:"part",py:"property",ra:"rate",rd:"requested",re:"rebuffer",rf:"rendition",rm:"remote",ro:"ratio",rp:"response",rq:"request",rs:"requests",sa:"sample",sd:"skipped",se:"session",sk:"seek",sm:"stream",so:"source",sq:"sequence",sr:"series",st:"start",su:"startup",sv:"server",sw:"software",sy:"severity",ta:"tag",tc:"tech",te:"text",tg:"target",th:"throughput",ti:"time",tl:"total",to:"to",tt:"title",ty:"type",ug:"upscaling",un:"universal",up:"upscale",ur:"url",us:"user",va:"variant",vd:"viewed",vi:"video",ve:"version",vw:"view",vr:"viewer",wd:"width",wa:"watch",wt:"waiting"},$p=Av(V1);function Av(i){var e={};for(var t in i)i.hasOwnProperty(t)&&(e[i[t]]=t);return e}function qu(i){var e={},t={};return Object.keys(i).forEach(function(s){var r=!1;if(i.hasOwnProperty(s)&&i[s]!==void 0){var n=s.split("_"),a=n[0],o=K1[a];o||(Pe.info("Data key word `"+n[0]+"` not expected in "+s),o=a+"_"),n.splice(1).forEach(function(l){l==="url"&&(r=!0),$p[l]?o+=$p[l]:Number(l)&&Math.floor(Number(l))===Number(l)?o+=l:(Pe.info("Data key word `"+l+"` not expected in "+s),o+="_"+l+"_")}),r?t[o]=i[s]:e[o]=i[s]}}),Object.assign(e,t)}var ir=Dt(Ui()),q1={maxBeaconSize:300,maxQueueLength:3600,baseTimeBetweenBeacons:1e4,maxPayloadKBSize:500},Y1=56*1024,j1=["hb","requestcompleted","requestfailed","requestcanceled"],z1="https://img.litix.io",Ji=function(i){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this._beaconUrl=i||z1,this._eventQueue=[],this._postInFlight=!1,this._failureCount=0,this._sendTimeout=!1,this._options=Object.assign({},q1,e)};Ji.prototype.queueEvent=function(i,e){var t=Object.assign({},e);return this._eventQueue.length<=this._options.maxQueueLength||i==="eventrateexceeded"?(this._eventQueue.push(t),this._sendTimeout||this._startBeaconSending(),this._eventQueue.length<=this._options.maxQueueLength):!1};Ji.prototype.flushEvents=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;if(i&&this._eventQueue.length===1){this._eventQueue.pop();return}this._eventQueue.length&&this._sendBeaconQueue(),this._startBeaconSending()};Ji.prototype.destroy=function(){var i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.destroyed=!0,i?this._clearBeaconQueue():this.flushEvents(),ir.default.clearTimeout(this._sendTimeout)};Ji.prototype._clearBeaconQueue=function(){var i=this._eventQueue.length>this._options.maxBeaconSize?this._eventQueue.length-this._options.maxBeaconSize:0,e=this._eventQueue.slice(i);i>0&&Object.assign(e[e.length-1],qu({mux_view_message:"event queue truncated"}));var t=this._createPayload(e);Sv(this._beaconUrl,t,!0,function(){})};Ji.prototype._sendBeaconQueue=function(){var i=this;if(!this._postInFlight){var e=this._eventQueue.slice(0,this._options.maxBeaconSize);this._eventQueue=this._eventQueue.slice(this._options.maxBeaconSize),this._postInFlight=!0;var t=this._createPayload(e),s=Qe.now();Sv(this._beaconUrl,t,!1,function(r,n){n?(i._eventQueue=e.concat(i._eventQueue),i._failureCount+=1,Pe.info("Error sending beacon: "+n)):i._failureCount=0,i._roundTripTime=Qe.now()-s,i._postInFlight=!1})}};Ji.prototype._getNextBeaconTime=function(){if(!this._failureCount)return this._options.baseTimeBetweenBeacons;var i=Math.pow(2,this._failureCount-1);return i=i*Math.random(),(1+i)*this._options.baseTimeBetweenBeacons};Ji.prototype._startBeaconSending=function(){var i=this;ir.default.clearTimeout(this._sendTimeout),!this.destroyed&&(this._sendTimeout=ir.default.setTimeout(function(){i._eventQueue.length&&i._sendBeaconQueue(),i._startBeaconSending()},this._getNextBeaconTime()))};Ji.prototype._createPayload=function(i){var e=this,t={transmission_timestamp:Math.round(Qe.now())};this._roundTripTime&&(t.rtt_ms=Math.round(this._roundTripTime));var s,r,n,a=function(){s=JSON.stringify({metadata:t,events:r||i}),n=s.length/1024},o=function(){return n<=e._options.maxPayloadKBSize};return a(),o()||(Pe.info("Payload size is too big ("+n+" kb). Removing unnecessary events."),r=i.filter(function(l){return j1.indexOf(l.e)===-1}),a()),o()||(Pe.info("Payload size still too big ("+n+" kb). Cropping fields.."),r.forEach(function(l){for(var d in l){var c=l[d],u=50*1024;typeof c=="string"&&c.length>u&&(l[d]=c.substring(0,u))}}),a()),s};var X1=function(i){return i.length<=Y1},Sv=function(i,e,t,s){if(t&&navigator&&navigator.sendBeacon&&navigator.sendBeacon(i,e)){s();return}if(ir.default.fetch){ir.default.fetch(i,{method:"POST",body:e,headers:{"Content-Type":"text/plain"},keepalive:X1(e)}).then(function(n){return s(null,n.ok?null:"Error")}).catch(function(n){return s(null,n)});return}if(ir.default.XMLHttpRequest){var r=new ir.default.XMLHttpRequest;r.onreadystatechange=function(){if(r.readyState===4)return s(null,r.status!==200?"error":void 0)},r.open("POST",i),r.setRequestHeader("Content-Type","text/plain"),r.send(e);return}s()},Q1=Ji,Z1=["env_key","view_id","view_sequence_number","player_sequence_number","beacon_domain","player_playhead_time","viewer_time","mux_api_version","event","video_id","player_instance_id","player_error_code","player_error_message","player_error_context","player_error_severity","player_error_business_exception"],J1=["adplay","adplaying","adpause","adfirstquartile","admidpoint","adthirdquartile","adended","adresponse","adrequest"],eA=["ad_id","ad_creative_id","ad_universal_id"],tA=["viewstart","error","ended","viewend"],iA=10*60*1e3,sA=function(){function i(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};ct(this,i);var r,n,a,o,l,d,c,u,h,f,m,p;B(this,"mux",void 0),B(this,"envKey",void 0),B(this,"options",void 0),B(this,"eventQueue",void 0),B(this,"sampleRate",void 0),B(this,"disableCookies",void 0),B(this,"respectDoNotTrack",void 0),B(this,"previousBeaconData",void 0),B(this,"lastEventTime",void 0),B(this,"rateLimited",void 0),B(this,"pageLevelData",void 0),B(this,"viewerData",void 0),this.mux=e,this.envKey=t,this.options=s,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.eventQueue=new Q1(B1(this.envKey,this.options));var g;this.sampleRate=(g=this.options.sampleRate)!==null&&g!==void 0?g:1;var v;this.disableCookies=(v=this.options.disableCookies)!==null&&v!==void 0?v:!1;var y;this.respectDoNotTrack=(y=this.options.respectDoNotTrack)!==null&&y!==void 0?y:!1,this.previousBeaconData=null,this.lastEventTime=0,this.rateLimited=!1,this.pageLevelData={mux_api_version:this.mux.API_VERSION,mux_embed:this.mux.NAME,mux_embed_version:this.mux.VERSION,viewer_application_name:(r=this.options.platform)===null||r===void 0?void 0:r.name,viewer_application_version:(n=this.options.platform)===null||n===void 0?void 0:n.version,viewer_application_engine:(a=this.options.platform)===null||a===void 0?void 0:a.layout,viewer_device_name:(o=this.options.platform)===null||o===void 0?void 0:o.product,viewer_device_category:"",viewer_device_manufacturer:(l=this.options.platform)===null||l===void 0?void 0:l.manufacturer,viewer_os_family:(c=this.options.platform)===null||c===void 0||(d=c.os)===null||d===void 0?void 0:d.family,viewer_os_architecture:(h=this.options.platform)===null||h===void 0||(u=h.os)===null||u===void 0?void 0:u.architecture,viewer_os_version:(m=this.options.platform)===null||m===void 0||(f=m.os)===null||f===void 0?void 0:f.version,viewer_connection_type:H1(),page_url:Vc.default===null||Vc.default===void 0||(p=Vc.default.location)===null||p===void 0?void 0:p.href},this.viewerData=this.disableCookies?{}:F1()}return Fi(i,[{key:"send",value:function(e,t){if(!(!e||!(t!=null&&t.view_id))){if(this.respectDoNotTrack&&Ku())return Pe.info("Not sending `"+e+"` because Do Not Track is enabled");if(!t||typeof t!="object")return Pe.error("A data object was expected in send() but was not provided");var s=this.disableCookies?{}:$1(),r=nm(Pd({},this.pageLevelData,t,s,this.viewerData),{event:e,env_key:this.envKey});r.user_id&&(r.viewer_user_id=r.user_id,delete r.user_id);var n,a=((n=r.mux_sample_number)!==null&&n!==void 0?n:0)>=this.sampleRate,o=this._deduplicateBeaconData(e,r),l=qu(o);if(this.lastEventTime=this.mux.utils.now(),a)return Pe.info("Not sending event due to sample rate restriction",e,r,l);if(this.envKey||Pe.info("Missing environment key (envKey) - beacons will be dropped if the video source is not a valid mux video URL",e,r,l),!this.rateLimited){if(Pe.info("Sending event",e,r,l),this.rateLimited=!this.eventQueue.queueEvent(e,l),this.mux.WINDOW_UNLOADING&&e==="viewend")this.eventQueue.destroy(!0);else if(this.mux.WINDOW_HIDDEN&&e==="hb"?this.eventQueue.flushEvents(!0):tA.indexOf(e)>=0&&this.eventQueue.flushEvents(),this.rateLimited)return r.event="eventrateexceeded",l=qu(r),this.eventQueue.queueEvent(r.event,l),Pe.error("Beaconing disabled due to rate limit.")}}}},{key:"destroy",value:function(){this.eventQueue.destroy(!1)}},{key:"_deduplicateBeaconData",value:function(e,t){var s=this,r={},n=t.view_id;if(n==="-1"||e==="viewstart"||e==="viewend"||!this.previousBeaconData||this.mux.utils.now()-this.lastEventTime>=iA)r=Pd({},t),n&&(this.previousBeaconData=r),n&&e==="viewend"&&(this.previousBeaconData=null);else{var a=e.indexOf("request")===0;Object.entries(t).forEach(function(o){var l=Tr(o,2),d=l[0],c=l[1];s.previousBeaconData&&(c!==s.previousBeaconData[d]||Z1.indexOf(d)>-1||s.objectHasChanged(a,d,c,s.previousBeaconData[d])||s.eventRequiresKey(e,d))&&(r[d]=c,s.previousBeaconData[d]=c)})}return r}},{key:"objectHasChanged",value:function(e,t,s,r){return!e||t.indexOf("request_")!==0?!1:t==="request_response_headers"||typeof s!="object"||typeof r!="object"?!0:Object.keys(s||{}).length!==Object.keys(r||{}).length}},{key:"eventRequiresKey",value:function(e,t){return!!(e==="renditionchange"&&t.indexOf("video_source_")===0||eA.includes(t)&&J1.includes(e))}}]),i}(),rA=function i(e){ct(this,i);var t=0,s=0,r=0,n=0,a=0,o=0,l=0,d=function(h,f){var m=f.request_start,p=f.request_response_start,g=f.request_response_end,v=f.request_bytes_loaded;n++;var y,b;if(p?(y=p-(m??0),b=(g??0)-p):b=(g??0)-(m??0),b>0&&v&&v>0){var x=v/b*8e3;a++,s+=v,r+=b,e.data.view_min_request_throughput=Math.min(e.data.view_min_request_throughput||1/0,x),e.data.view_average_request_throughput=s/r*8e3,e.data.view_request_count=n,y>0&&(t+=y,e.data.view_max_request_latency=Math.max(e.data.view_max_request_latency||0,y),e.data.view_average_request_latency=t/a)}},c=function(h,f){n++,o++,e.data.view_request_count=n,e.data.view_request_failed_count=o},u=function(h,f){n++,l++,e.data.view_request_count=n,e.data.view_request_canceled_count=l};e.on("requestcompleted",d),e.on("requestfailed",c),e.on("requestcanceled",u)},nA=rA,aA=60*60*1e3,oA=function i(e){var t=this;ct(this,i),B(this,"_lastEventTime",void 0),e.on("before*",function(s,r){var n=r.viewer_time,a=Qe.now(),o=t._lastEventTime;if(t._lastEventTime=a,o&&a-o>aA){var l=Object.keys(e.data).reduce(function(d,c){return c.indexOf("video_")===0?Object.assign(d,B({},c,e.data[c])):d},{});e.mux.log.info("Received event after at least an hour inactivity, creating a new view"),e.emit("viewinit",Object.assign({viewer_time:n},l)),e.playbackHeartbeat._playheadShouldBeProgressing&&s.type!=="play"&&s.type!=="adbreakstart"&&(e.emit("play",{viewer_time:n}),s.type!=="playing"&&e.emit("playing",{viewer_time:n}))}})},lA=oA,dA=["viewstart","ended","loadstart","pause","play","playing","ratechange","waiting","adplay","adpause","adended","aderror","adplaying","adrequest","adresponse","adbreakstart","adbreakend","adfirstquartile","admidpoint","adthirdquartile","rebufferstart","rebufferend","seeked","error","hb","requestcompleted","requestfailed","requestcanceled","renditionchange"],cA=function(i){q_(t,i);var e=z_(t);function t(s,r,n){ct(this,t);var a;a=e.call(this),B(ne(a),"DOM_CONTENT_LOADED_EVENT_END",void 0),B(ne(a),"NAVIGATION_START",void 0),B(ne(a),"_destroyed",void 0),B(ne(a),"_heartBeatTimeout",void 0),B(ne(a),"adTracker",void 0),B(ne(a),"dashjs",void 0),B(ne(a),"data",void 0),B(ne(a),"disablePlayheadRebufferTracking",void 0),B(ne(a),"disableRebufferTracking",void 0),B(ne(a),"errorTracker",void 0),B(ne(a),"errorTranslator",void 0),B(ne(a),"getAdData",void 0),B(ne(a),"getPlayheadTime",void 0),B(ne(a),"getStateData",void 0),B(ne(a),"hlsjs",void 0),B(ne(a),"id",void 0),B(ne(a),"longResumeTracker",void 0),B(ne(a),"minimumRebufferDuration",void 0),B(ne(a),"mux",void 0),B(ne(a),"oldEmit",void 0),B(ne(a),"playbackEventDispatcher",void 0),B(ne(a),"playbackHeartbeat",void 0),B(ne(a),"playbackHeartbeatTime",void 0),B(ne(a),"playheadTime",void 0),B(ne(a),"seekingTracker",void 0),B(ne(a),"sustainedRebufferThreshold",void 0),B(ne(a),"watchTimeTracker",void 0),B(ne(a),"currentFragmentPDT",void 0),B(ne(a),"currentFragmentStart",void 0),a.DOM_CONTENT_LOADED_EVENT_END=Od.domContentLoadedEventEnd(),a.NAVIGATION_START=Od.navigationStart();var o={debug:!1,minimumRebufferDuration:250,sustainedRebufferThreshold:1e3,playbackHeartbeatTime:25,beaconDomain:"litix.io",sampleRate:1,disableCookies:!1,respectDoNotTrack:!1,disableRebufferTracking:!1,disablePlayheadRebufferTracking:!1,errorTranslator:function(f){return f}};a.mux=s,a.id=r,n!=null&&n.beaconDomain&&a.mux.log.warn("The `beaconDomain` setting has been deprecated in favor of `beaconCollectionDomain`. Please change your integration to use `beaconCollectionDomain` instead of `beaconDomain`."),n=Object.assign(o,n),n.data=n.data||{},n.data.property_key&&(n.data.env_key=n.data.property_key,delete n.data.property_key),Pe.setLevel(n.debug?"debug":"warn"),a.getPlayheadTime=n.getPlayheadTime,a.getStateData=n.getStateData||function(){return{}},a.getAdData=n.getAdData||function(){},a.minimumRebufferDuration=n.minimumRebufferDuration,a.sustainedRebufferThreshold=n.sustainedRebufferThreshold,a.playbackHeartbeatTime=n.playbackHeartbeatTime,a.disableRebufferTracking=n.disableRebufferTracking,a.disableRebufferTracking&&a.mux.log.warn("Disabling rebuffer tracking. This should only be used in specific circumstances as a last resort when your player is known to unreliably track rebuffering."),a.disablePlayheadRebufferTracking=n.disablePlayheadRebufferTracking,a.errorTranslator=n.errorTranslator,a.playbackEventDispatcher=new sA(s,n.data.env_key,n),a.data={player_instance_id:Ka(),mux_sample_rate:n.sampleRate,beacon_domain:n.beaconCollectionDomain||n.beaconDomain},a.data.view_sequence_number=1,a.data.player_sequence_number=1,a.oldEmit=a.emit,a.emit=function(f,m){m=Object.assign({viewer_time:this.mux.utils.now()},m),this.oldEmit(f,m)};var l=(function(){typeof this.data.view_start>"u"&&(this.data.view_start=this.mux.utils.now(),this.emit("viewstart"))}).bind(ne(a));a.on("viewinit",function(f,m){this._resetVideoData(),this._resetViewData(),this._resetErrorData(),this._updateStateData(),Object.assign(this.data,m),this._initializeViewData(),this.one("play",l),this.one("adbreakstart",l)});var d=(function(f){this.emit("viewend"),this.send("viewend"),this.emit("viewinit",f)}).bind(ne(a));if(a.on("videochange",function(f,m){d(m)}),a.on("programchange",function(f,m){this.data.player_is_paused&&this.mux.log.warn("The `programchange` event is intended to be used when the content changes mid playback without the video source changing, however the video is not currently playing. If the video source is changing please use the videochange event otherwise you will lose startup time information."),d(Object.assign(m,{view_program_changed:!0})),l(),this.emit("play"),this.emit("playing")}),a.on("fragmentchange",function(f,m){this.currentFragmentPDT=m.currentFragmentPDT,this.currentFragmentStart=m.currentFragmentStart}),a.on("destroy",a.destroy),typeof window<"u"&&typeof window.addEventListener=="function"&&typeof window.removeEventListener=="function"){var c=function(){var f=typeof a.data.view_start<"u";a.mux.WINDOW_HIDDEN=document.visibilityState==="hidden",f&&a.mux.WINDOW_HIDDEN&&(a.data.player_is_paused||a.emit("hb"))};window.addEventListener("visibilitychange",c,!1);var u=function(f){f.persisted||a.destroy()};window.addEventListener("pagehide",u,!1),a.on("destroy",function(){window.removeEventListener("visibilitychange",c),window.removeEventListener("pagehide",u)})}a.on("playerready",function(f,m){Object.assign(this.data,m)}),dA.forEach(function(f){a.on(f,function(m,p){f.indexOf("ad")!==0&&this._updateStateData(),Object.assign(this.data,p),this._sanitizeData()}),a.on("after"+f,function(){(f!=="error"||this.errorTracker.viewErrored)&&this.send(f)})}),a.on("viewend",function(f,m){Object.assign(a.data,m)});var h=function(f){var m=this.mux.utils.now();this.data.player_init_time&&(this.data.player_startup_time=m-this.data.player_init_time),!this.mux.PLAYER_TRACKED&&this.NAVIGATION_START&&(this.mux.PLAYER_TRACKED=!0,(this.data.player_init_time||this.DOM_CONTENT_LOADED_EVENT_END)&&(this.data.page_load_time=Math.min(this.data.player_init_time||1/0,this.DOM_CONTENT_LOADED_EVENT_END||1/0)-this.NAVIGATION_START)),this.send("playerready"),delete this.data.player_startup_time,delete this.data.page_load_time};return a.one("playerready",h),a.longResumeTracker=new lA(ne(a)),a.errorTracker=new f1(ne(a)),new U1(ne(a)),a.seekingTracker=new w1(ne(a)),a.playheadTime=new b1(ne(a)),a.playbackHeartbeat=new u1(ne(a)),new L1(ne(a)),a.watchTimeTracker=new p1(ne(a)),new v1(ne(a)),a.adTracker=new M1(ne(a)),new A1(ne(a)),new T1(ne(a)),new x1(ne(a)),new P1(ne(a)),new nA(ne(a)),n.hlsjs&&a.addHLSJS(n),n.dashjs&&a.addDashJS(n),a.emit("viewinit",n.data),a}return Fi(t,[{key:"destroy",value:function(){this._destroyed||(this._destroyed=!0,typeof this.data.view_start<"u"&&(this.emit("viewend"),this.send("viewend")),this.playbackEventDispatcher.destroy(),this.removeHLSJS(),this.removeDashJS(),window.clearTimeout(this._heartBeatTimeout))}},{key:"send",value:function(s){if(this.data.view_id){var r=Object.assign({},this.data),n=["player_program_time","player_manifest_newest_program_time","player_live_edge_program_time","player_program_time","video_holdback","video_part_holdback","video_target_duration","video_part_target_duration"];if(r.video_source_is_live===void 0&&(r.player_source_duration===1/0||r.video_source_duration===1/0?r.video_source_is_live=!0:(r.player_source_duration>0||r.video_source_duration>0)&&(r.video_source_is_live=!1)),r.video_source_is_live||n.forEach(function(d){r[d]=void 0}),r.video_source_url=r.video_source_url||r.player_source_url,r.video_source_url){var a=Tr(qa(r.video_source_url),2),o=a[0],l=a[1];r.video_source_domain=l,r.video_source_hostname=o}delete r.ad_request_id,this.playbackEventDispatcher.send(s,r),this.data.view_sequence_number++,this.data.player_sequence_number++,this._restartHeartBeat(),s==="viewend"&&delete this.data.view_id}}},{key:"_updateStateData",value:function(){Object.assign(this.data,this.getStateData()),this.playheadTime._updatePlayheadTime(),this._sanitizeData()}},{key:"_sanitizeData",value:function(){var s=this,r=["player_width","player_height","video_source_width","video_source_height","player_playhead_time","video_source_bitrate"];r.forEach(function(a){var o=parseInt(s.data[a],10);s.data[a]=isNaN(o)?void 0:o});var n=["player_source_url","video_source_url"];n.forEach(function(a){if(s.data[a]){var o=s.data[a].toLowerCase();(o.indexOf("data:")===0||o.indexOf("blob:")===0)&&(s.data[a]="MSE style URL")}})}},{key:"_resetVideoData",value:function(){var s=this;Object.keys(this.data).forEach(function(r){r.indexOf("video_")===0&&delete s.data[r]})}},{key:"_resetViewData",value:function(){var s=this;Object.keys(this.data).forEach(function(r){r.indexOf("view_")===0&&delete s.data[r]}),this.data.view_sequence_number=1}},{key:"_resetErrorData",value:function(){delete this.data.player_error_code,delete this.data.player_error_message,delete this.data.player_error_context,delete this.data.player_error_severity,delete this.data.player_error_business_exception}},{key:"_initializeViewData",value:function(){var s=this,r=this.data.view_id=Ka(),n=function(){r===s.data.view_id&&We(s.data,"player_view_count",1)};this.data.player_is_paused?this.one("play",n):n()}},{key:"_restartHeartBeat",value:function(){var s=this;window.clearTimeout(this._heartBeatTimeout),this._heartBeatTimeout=window.setTimeout(function(){s.data.player_is_paused||s.emit("hb")},1e4)}},{key:"addHLSJS",value:function(s){if(!s.hlsjs){this.mux.log.warn("You must pass a valid hlsjs instance in order to track it.");return}if(this.hlsjs){this.mux.log.warn("An instance of HLS.js is already being monitored for this player.");return}this.hlsjs=s.hlsjs,t1(this.mux,this.id,s.hlsjs,{},s.Hls||window.Hls)}},{key:"removeHLSJS",value:function(){this.hlsjs&&(i1(this.hlsjs),this.hlsjs=void 0)}},{key:"addDashJS",value:function(s){if(!s.dashjs){this.mux.log.warn("You must pass a valid dashjs instance in order to track it.");return}if(this.dashjs){this.mux.log.warn("An instance of Dash.js is already being monitored for this player.");return}this.dashjs=s.dashjs,a1(this.mux,this.id,s.dashjs)}},{key:"removeDashJS",value:function(){this.dashjs&&(o1(this.dashjs),this.dashjs=void 0)}}]),t}(d1),uA=cA;Sc();var Kn=Dt(U_());function hA(){return Kn.default&&!!(Kn.default.fullscreenElement||Kn.default.webkitFullscreenElement||Kn.default.mozFullScreenElement||Kn.default.msFullscreenElement)}var fA=["loadstart","pause","play","playing","seeking","seeked","timeupdate","ratechange","stalled","waiting","error","ended"],mA={1:"MEDIA_ERR_ABORTED",2:"MEDIA_ERR_NETWORK",3:"MEDIA_ERR_DECODE",4:"MEDIA_ERR_SRC_NOT_SUPPORTED"};function pA(i,e,t){var s=Tr(Wu(e),3),r=s[0],n=s[1],a=s[2],o=i.log,l=i.utils.getComputedStyle,d=i.utils.secondsToMs,c={automaticErrorTracking:!0};if(r){if(a!=="video"&&a!=="audio")return o.error("The element of `"+n+"` was not a media element.")}else return o.error("No element was found with the `"+n+"` query selector.");r.mux&&(r.mux.destroy(),delete r.mux,o.warn("Already monitoring this video element, replacing existing event listeners")),t=Object.assign(c,t),t.data=Object.assign({player_software:"HTML5 Video Element",player_mux_plugin_name:"VideoElementMonitor",player_mux_plugin_version:i.VERSION},t.data),t.getPlayheadTime=function(){return d(r.currentTime)},t.getStateData=function(){var h,f=this.hlsjs&&this.hlsjs.url,m=this.dashjs&&yt(this.dashjs.getSource==="function")&&this.dashjs.getSource(),p={player_is_paused:r.paused,player_playhead_time:d(r.currentTime),player_width:parseInt(l(r,"width")),player_height:parseInt(l(r,"height")),player_autoplay_on:r.autoplay,player_preload_on:r.preload,player_language_code:r.lang,player_is_fullscreen:hA(),video_poster_url:r.poster,video_source_url:f||m||r.currentSrc,video_source_duration:d(r.duration),video_source_height:r.videoHeight,video_source_width:r.videoWidth,view_dropped_frame_count:r==null||(h=r.getVideoPlaybackQuality)===null||h===void 0?void 0:h.call(r).droppedVideoFrames},g=t.getPlayheadTime();if(r.getStartDate&&g>0){var v=r.getStartDate();if(v&&typeof v.getTime=="function"&&v.getTime()){var y=v.getTime();if(p.player_program_time=y+g,r.seekable.length>0){var b=y+r.seekable.end(r.seekable.length-1);p.player_live_edge_program_time=b}}}return p},r.mux=r.mux||{},r.mux.deleted=!1,r.mux.emit=function(h,f){i.emit(n,h,f)};var u=function(){o.error("The monitor for this video element has already been destroyed.")};r.mux.destroy=function(){Object.keys(r.mux.listeners).forEach(function(h){r.removeEventListener(h,r.mux.listeners[h],!1)}),delete r.mux.listeners,r.mux.destroy=u,r.mux.swapElement=u,r.mux.emit=u,r.mux.addHLSJS=u,r.mux.addDashJS=u,r.mux.removeHLSJS=u,r.mux.removeDashJS=u,r.mux.deleted=!0,i.emit(n,"destroy")},r.mux.swapElement=function(h){var f=Tr(Wu(h),3),m=f[0],p=f[1],g=f[2];if(m){if(g!=="video"&&g!=="audio")return i.log.error("The element of `"+p+"` was not a media element.")}else return i.log.error("No element was found with the `"+p+"` query selector.");m.muxId=r.muxId,delete r.muxId,m.mux=m.mux||{},m.mux.listeners=Object.assign({},r.mux.listeners),delete r.mux.listeners,Object.keys(m.mux.listeners).forEach(function(v){r.removeEventListener(v,m.mux.listeners[v],!1),m.addEventListener(v,m.mux.listeners[v],!1)}),m.mux.swapElement=r.mux.swapElement,m.mux.destroy=r.mux.destroy,delete r.mux,r=m},r.mux.addHLSJS=function(h){i.addHLSJS(n,h)},r.mux.addDashJS=function(h){i.addDashJS(n,h)},r.mux.removeHLSJS=function(){i.removeHLSJS(n)},r.mux.removeDashJS=function(){i.removeDashJS(n)},i.init(n,t),i.emit(n,"playerready"),r.paused||(i.emit(n,"play"),r.readyState>2&&i.emit(n,"playing")),r.mux.listeners={},fA.forEach(function(h){h==="error"&&!t.automaticErrorTracking||(r.mux.listeners[h]=function(){var f={};if(h==="error"){if(!r.error||r.error.code===1)return;f.player_error_code=r.error.code,f.player_error_message=mA[r.error.code]||r.error.message}i.emit(n,h,f)},r.addEventListener(h,r.mux.listeners[h],!1))})}function gA(i,e,t,s){var r=s;if(i&&typeof i[e]=="function")try{r=i[e].apply(i,t)}catch(n){Pe.info("safeCall error",n)}return r}var Ma=Dt(Ui()),$r;Ma.default&&Ma.default.WeakMap&&($r=new WeakMap);function vA(i,e){if(!i||!e||!Ma.default||typeof Ma.default.getComputedStyle!="function")return"";var t;return $r&&$r.has(i)&&(t=$r.get(i)),t||(t=Ma.default.getComputedStyle(i,null),$r&&$r.set(i,t)),t.getPropertyValue(e)}function EA(i){return Math.floor(i*1e3)}var Ls={TARGET_DURATION:"#EXT-X-TARGETDURATION",PART_INF:"#EXT-X-PART-INF",SERVER_CONTROL:"#EXT-X-SERVER-CONTROL",INF:"#EXTINF",PROGRAM_DATE_TIME:"#EXT-X-PROGRAM-DATE-TIME",VERSION:"#EXT-X-VERSION",SESSION_DATA:"#EXT-X-SESSION-DATA"},xc=function(i){return this.buffer="",this.manifest={segments:[],serverControl:{},sessionData:{}},this.currentUri={},this.process(i),this.manifest};xc.prototype.process=function(i){var e;for(this.buffer+=i,e=this.buffer.indexOf(`
14
14
  `);e>-1;e=this.buffer.indexOf(`
15
- `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};xc.prototype.processLine=function(i){var e=i.indexOf(":"),t=TA(i,e),s=t[0],r=t.length===2?om(t[1]):void 0;if(s[0]!=="#")this.currentUri.uri=s,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(s){case Ls.TARGET_DURATION:{if(!isFinite(r)||r<0)return;this.manifest.targetDuration=r,this.setHoldBack();break}case Ls.PART_INF:{qc(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case Ls.SERVER_CONTROL:{qc(this.manifest,t),this.setHoldBack();break}case Ls.INF:{r===0?this.currentUri.duration=.01:r>0&&(this.currentUri.duration=r);break}case Ls.PROGRAM_DATE_TIME:{var n=r,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case Ls.VERSION:{qc(this.manifest,t);break}case Ls.SESSION_DATA:{var o=_A(t[1]),l=pv(o);Object.assign(this.manifest.sessionData,l)}}};xc.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,s=i.partTargetDuration;if(e){var r="holdBack",n="partHoldBack",a=t&&t*3,o=s&&s*2;t&&!e.hasOwnProperty(r)&&(e[r]=a),a&&e[r]<a&&(e[r]=a),s&&!e.hasOwnProperty(n)&&(e[n]=s*3),s&&e[n]<o&&(e[n]=o)}};var qc=function(i,e){var t=xv(e[0].replace("#EXT-X-","")),s;yA(e[1])?(s={},s=Object.assign(bA(e[1]),s)):s=om(e[1]),i[t]=s},xv=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},om=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},EA=function(i){var e={},t=i.split("=");if(t.length>1){var s=xv(t[0]);e[s]=om(t[1])}return e},bA=function(i){for(var e=i.split(","),t={},s=0;e.length>s;s++){var r=e[s],n=EA(r);t=Object.assign(n,t)}return t},yA=function(i){return i.indexOf("=")>-1},TA=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},_A=function(i){var e={};if(i){var t=i.search(","),s=i.slice(0,t),r=i.slice(t+1),n=[s,r];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},AA=xc,SA={safeCall:pA,safeIncrement:We,getComputedStyle:gA,secondsToMs:vA,assign:Object.assign,headersStringToObject:am,cdnHeadersToRequestId:Nd,extractHostnameAndDomain:qa,extractHostname:Jt,manifestParser:AA,generateShortID:fv,generateUUID:Ka,now:Qe.now},xA=SA,kA={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"},LA=kA,IA="mux-embed",RA="5.2.1",wA="2.1",Ft={},Ts=function(i){var e=arguments;typeof i=="string"?Ts.hasOwnProperty(i)?Da.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),Ts[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Da.default.setTimeout(function(){i(Ts)},0):Pe.warn("`"+i+"` is invalid.")},CA={loaded:Qe.now(),NAME:IA,VERSION:RA,API_VERSION:wA,PLAYER_TRACKED:!1,monitor:function(i,e){return mA(Ts,i,e)},destroyMonitor:function(i){var e=Tr(Wu(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=Ms(i);Ft[t]?Ft[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=Ms(i);Ft[t]?Ft[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=Ms(i);Ft[e]?Ft[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=Ms(i);Ft[e]?Ft[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){Ku()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=Ms(i);Ft[t]=new cA(Ts,t,e)},emit:function(i,e,t){var s=Ms(i);Ft[s]?(Ft[s].emit(e,t),e==="destroy"&&delete Ft[s]):Pe.error("A monitor for `"+s+"` has not been initialized.")},checkDoNotTrack:Ku,log:Pe,utils:xA,events:LA,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ts,CA);typeof Da.default<"u"&&typeof Da.default.addEventListener=="function"&&Da.default.addEventListener("pagehide",function(i){i.persisted||(Ts.WINDOW_UNLOADING=!0)},!1);var lm=Ts;/*!
15
+ `))this.processLine(this.buffer.substring(0,e)),this.buffer=this.buffer.substring(e+1)};xc.prototype.processLine=function(i){var e=i.indexOf(":"),t=_A(i,e),s=t[0],r=t.length===2?om(t[1]):void 0;if(s[0]!=="#")this.currentUri.uri=s,this.manifest.segments.push(this.currentUri),this.manifest.targetDuration&&!("duration"in this.currentUri)&&(this.currentUri.duration=this.manifest.targetDuration),this.currentUri={};else switch(s){case Ls.TARGET_DURATION:{if(!isFinite(r)||r<0)return;this.manifest.targetDuration=r,this.setHoldBack();break}case Ls.PART_INF:{qc(this.manifest,t),this.manifest.partInf.partTarget&&(this.manifest.partTargetDuration=this.manifest.partInf.partTarget),this.setHoldBack();break}case Ls.SERVER_CONTROL:{qc(this.manifest,t),this.setHoldBack();break}case Ls.INF:{r===0?this.currentUri.duration=.01:r>0&&(this.currentUri.duration=r);break}case Ls.PROGRAM_DATE_TIME:{var n=r,a=new Date(n);this.manifest.dateTimeString||(this.manifest.dateTimeString=n,this.manifest.dateTimeObject=a),this.currentUri.dateTimeString=n,this.currentUri.dateTimeObject=a;break}case Ls.VERSION:{qc(this.manifest,t);break}case Ls.SESSION_DATA:{var o=AA(t[1]),l=pv(o);Object.assign(this.manifest.sessionData,l)}}};xc.prototype.setHoldBack=function(){var i=this.manifest,e=i.serverControl,t=i.targetDuration,s=i.partTargetDuration;if(e){var r="holdBack",n="partHoldBack",a=t&&t*3,o=s&&s*2;t&&!e.hasOwnProperty(r)&&(e[r]=a),a&&e[r]<a&&(e[r]=a),s&&!e.hasOwnProperty(n)&&(e[n]=s*3),s&&e[n]<o&&(e[n]=o)}};var qc=function(i,e){var t=xv(e[0].replace("#EXT-X-","")),s;TA(e[1])?(s={},s=Object.assign(yA(e[1]),s)):s=om(e[1]),i[t]=s},xv=function(i){return i.toLowerCase().replace(/-(\w)/g,function(e){return e[1].toUpperCase()})},om=function(i){if(i.toLowerCase()==="yes"||i.toLowerCase()==="no")return i.toLowerCase()==="yes";var e=i.indexOf(":")!==-1?i:parseFloat(i);return isNaN(e)?i:e},bA=function(i){var e={},t=i.split("=");if(t.length>1){var s=xv(t[0]);e[s]=om(t[1])}return e},yA=function(i){for(var e=i.split(","),t={},s=0;e.length>s;s++){var r=e[s],n=bA(r);t=Object.assign(n,t)}return t},TA=function(i){return i.indexOf("=")>-1},_A=function(i,e){return e===-1?[i]:[i.substring(0,e),i.substring(e+1)]},AA=function(i){var e={};if(i){var t=i.search(","),s=i.slice(0,t),r=i.slice(t+1),n=[s,r];return n.forEach(function(a,o){for(var l=a.replace(/['"]+/g,"").split("="),d=0;d<l.length;d++)l[d]==="DATA-ID"&&(e["DATA-ID"]=l[1-d]),l[d]==="VALUE"&&(e.VALUE=l[1-d])}),{data:e}}},SA=xc,xA={safeCall:gA,safeIncrement:We,getComputedStyle:vA,secondsToMs:EA,assign:Object.assign,headersStringToObject:am,cdnHeadersToRequestId:Nd,extractHostnameAndDomain:qa,extractHostname:Jt,manifestParser:SA,generateShortID:fv,generateUUID:Ka,now:Qe.now},kA=xA,LA={PLAYER_READY:"playerready",VIEW_INIT:"viewinit",VIDEO_CHANGE:"videochange",PLAY:"play",PAUSE:"pause",PLAYING:"playing",TIME_UPDATE:"timeupdate",SEEKING:"seeking",SEEKED:"seeked",REBUFFER_START:"rebufferstart",REBUFFER_END:"rebufferend",ERROR:"error",ENDED:"ended",RENDITION_CHANGE:"renditionchange",ORIENTATION_CHANGE:"orientationchange",AD_REQUEST:"adrequest",AD_RESPONSE:"adresponse",AD_BREAK_START:"adbreakstart",AD_PLAY:"adplay",AD_PLAYING:"adplaying",AD_PAUSE:"adpause",AD_FIRST_QUARTILE:"adfirstquartile",AD_MID_POINT:"admidpoint",AD_THIRD_QUARTILE:"adthirdquartile",AD_ENDED:"adended",AD_BREAK_END:"adbreakend",AD_ERROR:"aderror",REQUEST_COMPLETED:"requestcompleted",REQUEST_FAILED:"requestfailed",REQUEST_CANCELLED:"requestcanceled"},IA=LA,RA="mux-embed",wA="5.2.1",CA="2.1",Ft={},Ts=function(i){var e=arguments;typeof i=="string"?Ts.hasOwnProperty(i)?Da.default.setTimeout(function(){e=Array.prototype.splice.call(e,1),Ts[i].apply(null,e)},0):Pe.warn("`"+i+"` is an unknown task"):typeof i=="function"?Da.default.setTimeout(function(){i(Ts)},0):Pe.warn("`"+i+"` is invalid.")},DA={loaded:Qe.now(),NAME:RA,VERSION:wA,API_VERSION:CA,PLAYER_TRACKED:!1,monitor:function(i,e){return pA(Ts,i,e)},destroyMonitor:function(i){var e=Tr(Wu(i),1),t=e[0];t&&t.mux&&typeof t.mux.destroy=="function"?t.mux.destroy():Pe.error("A video element monitor for `"+i+"` has not been initialized via `mux.monitor`.")},addHLSJS:function(i,e){var t=Ms(i);Ft[t]?Ft[t].addHLSJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},addDashJS:function(i,e){var t=Ms(i);Ft[t]?Ft[t].addDashJS(e):Pe.error("A monitor for `"+t+"` has not been initialized.")},removeHLSJS:function(i){var e=Ms(i);Ft[e]?Ft[e].removeHLSJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},removeDashJS:function(i){var e=Ms(i);Ft[e]?Ft[e].removeDashJS():Pe.error("A monitor for `"+e+"` has not been initialized.")},init:function(i,e){Ku()&&e&&e.respectDoNotTrack&&Pe.info("The browser's Do Not Track flag is enabled - Mux beaconing is disabled.");var t=Ms(i);Ft[t]=new uA(Ts,t,e)},emit:function(i,e,t){var s=Ms(i);Ft[s]?(Ft[s].emit(e,t),e==="destroy"&&delete Ft[s]):Pe.error("A monitor for `"+s+"` has not been initialized.")},checkDoNotTrack:Ku,log:Pe,utils:kA,events:IA,WINDOW_HIDDEN:!1,WINDOW_UNLOADING:!1};Object.assign(Ts,DA);typeof Da.default<"u"&&typeof Da.default.addEventListener=="function"&&Da.default.addEventListener("pagehide",function(i){i.persisted||(Ts.WINDOW_UNLOADING=!0)},!1);var lm=Ts;/*!
16
16
  * JavaScript Cookie v2.1.3
17
17
  * https://github.com/js-cookie/js-cookie
18
18
  *
19
19
  * Copyright 2006, 2015 Klaus Hartl & Fagner Brack
20
20
  * Released under the MIT license
21
- */function DA(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var kv={exports:{}};(function(i,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);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(d);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)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=r.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,v=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(v)}return p.path===null&&(p.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=s.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(kv);var dm=kv.exports;function Bp(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,s)}return t}function dt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Bp(Object(t),!0).forEach(function(s){PA(i,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Bp(Object(t)).forEach(function(s){Object.defineProperty(i,s,Object.getOwnPropertyDescriptor(t,s))})}return i}function MA(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var s=t.call(i,e||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function OA(i){var e=MA(i,"string");return typeof e=="symbol"?e:String(e)}function PA(i,e,t){return e=OA(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ke(){return Ke=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},Ke.apply(this,arguments)}const j=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},NA=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=UA},UA=Number.MAX_SAFE_INTEGER||9007199254740991;let E=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),se=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),M=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const Os=function(){},Yu={trace:Os,debug:Os,log:Os,warn:Os,info:Os,error:Os};let Oa=Yu;function FA(i){const e=self.console[i];return e?e.bind(self.console,`[${i}] >`):Os}function $A(i,...e){e.forEach(function(t){Oa[t]=i[t]?i[t].bind(i):FA(t)})}function BA(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){$A(i,"debug","log","info","warn","error");try{Oa.log(`Debug logs enabled for "${e}" in hls.js version 1.5.11`)}catch{Oa=Yu}}else Oa=Yu}const R=Oa,GA=/^(\d+)x(\d+)$/,Gp=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Oe{constructor(e){typeof e=="string"&&(e=Oe.parseAttrList(e)),Ke(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 r=0;r<t.length/2;r++)s[r]=parseInt(t.slice(r*2,r*2+2),16);return s}else 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]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=GA.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const s={},r='"';for(Gp.lastIndex=0;(t=Gp.exec(e))!==null;){let n=t[2];n.indexOf(r)===0&&n.lastIndexOf(r)===n.length-1&&(n=n.slice(1,-1));const a=t[1].trim();s[a]=n}return s}}function HA(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function WA(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class Lv{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const s=t.attr;for(const r in s)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==s[r]){R.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=Ke(new Oe({}),s,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const s=new Date(this.attr["END-DATE"]);j(s.getTime())&&(this._endDate=s)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(j(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 isValid(){return!!this.id&&!this._badValueForSameId&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class kc{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 be={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Iv{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[be.AUDIO]:null,[be.VIDEO]:null,[be.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const s=e.split("@",2);let r;s.length===1?r=(t==null?void 0:t.byteRangeEndOffset)||0:r=parseInt(s[1]),this._byteRange=[r,parseInt(s[0])+r]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=dm.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Yc extends Iv{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=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.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new kc,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 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)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!j(this.programDateTime))return null;const e=j(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){const t=Object.keys(this.levelkeys),s=t.length;if(s>1||s===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}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,r,n,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:s,startDTS:r,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,s),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[be.AUDIO]=null,e[be.VIDEO]=null,e[be.AUDIOVIDEO]=null}}let KA=class extends Iv{constructor(e,t,s,r,n){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.stats=new kc,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=r;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.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)}};const VA=10;class qA{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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 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.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,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||VA}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(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end: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 lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function cm(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function YA(i){const e=ju(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function jA(i){const e=function(s,r,n){const a=s[r];s[r]=s[n],s[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function zA(i){const e=i.split(":");let t=null;if(e[0]==="data"&&e.length===2){const s=e[1].split(";"),r=s[s.length-1].split(",");if(r.length===2){const n=r[0]==="base64",a=r[1];n?(s.splice(-1,1),t=cm(a)):t=YA(a)}}return t}function ju(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}const Rn=typeof self<"u"?self:void 0;var we={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},wt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Hp(i){switch(i){case wt.FAIRPLAY:return we.FAIRPLAY;case wt.PLAYREADY:return we.PLAYREADY;case wt.WIDEVINE:return we.WIDEVINE;case wt.CLEARKEY:return we.CLEARKEY}}var Rv={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function XA(i){if(i===Rv.WIDEVINE)return we.WIDEVINE}function Wp(i){switch(i){case we.FAIRPLAY:return wt.FAIRPLAY;case we.PLAYREADY:return wt.PLAYREADY;case we.WIDEVINE:return wt.WIDEVINE;case we.CLEARKEY:return wt.CLEARKEY}}function jc(i){const{drmSystems:e,widevineLicenseUrl:t}=i,s=e?[we.FAIRPLAY,we.WIDEVINE,we.PLAYREADY,we.CLEARKEY].filter(r=>!!e[r]):[];return!s[we.WIDEVINE]&&t&&s.push(we.WIDEVINE),s}const wv=function(i){return Rn!=null&&(i=Rn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function QA(i,e,t,s){let r;switch(i){case we.FAIRPLAY:r=["cenc","sinf"];break;case we.WIDEVINE:case we.PLAYREADY:r=["cenc"];break;case we.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return ZA(r,e,t,s)}function ZA(i,e,t,s){return[{initDataTypes:i,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function ur(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}const um=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Cv=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ya=(i,e)=>{const t=e;let s=0;for(;um(i,e);){s+=10;const r=Lc(i,e+6);s+=r,Cv(i,e+10)&&(s+=10),e+=s}if(s>0)return i.subarray(t,t+s)},Lc=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},JA=(i,e)=>um(i,e)&&Lc(i,e+6)+10<=i.length-e,hm=i=>{const e=Mv(i);for(let t=0;t<e.length;t++){const s=e[t];if(Dv(s))return nS(s)}},Dv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",eS=i=>{const e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Lc(i,4),s=10;return{type:e,size:t,data:i.subarray(s,s+t)}},Mv=i=>{let e=0;const t=[];for(;um(i,e);){const s=Lc(i,e+6);e+=10;const r=e+s;for(;e+8<r;){const n=eS(i.subarray(e)),a=tS(n);a&&t.push(a),e+=n.size+10}Cv(i,e)&&(e+=10)}return t},tS=i=>i.type==="PRIV"?iS(i):i.type[0]==="W"?rS(i):sS(i),iS=i=>{if(i.size<2)return;const e=Oi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},sS=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1;const s=Oi(i.data.subarray(t),!0);t+=s.length+1;const r=Oi(i.data.subarray(t));return{key:i.type,info:s,data:r}}const e=Oi(i.data.subarray(1));return{key:i.type,data:e}},rS=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1;const s=Oi(i.data.subarray(t),!0);t+=s.length+1;const r=Oi(i.data.subarray(t));return{key:i.type,info:s,data:r}}const e=Oi(i.data);return{key:i.type,data:e}},nS=i=>{if(i.data.byteLength===8){const e=new Uint8Array(i.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)}},Oi=(i,e=!1)=>{const t=aS();if(t){const d=t.decode(i);if(e){const c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}const s=i.length;let r,n,a,o="",l=0;for(;l<s;){if(r=i[l++],r===0&&e)return o;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((r&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((r&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o};let zc;function aS(){if(!navigator.userAgent.includes("PlayStation 4"))return!zc&&typeof self.TextDecoder<"u"&&(zc=new self.TextDecoder("utf-8")),zc}const Si={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let s=i[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}},Ud=Math.pow(2,32)-1,oS=[].push,Ov={video:1,audio:2,id3:3,text:4};function je(i){return String.fromCharCode.apply(null,i)}function Pv(i,e){const t=i[e]<<8|i[e+1];return t<0?65536+t:t}function ee(i,e){const t=Nv(i,e);return t<0?4294967296+t:t}function Kp(i,e){let t=ee(i,e);return t*=Math.pow(2,32),t+=ee(i,e+4),t}function Nv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function Xc(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function lS(i){const e=i.byteLength;for(let t=0;t<e;){const s=ee(i,t);if(s>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=s>1?t+s:e}return!1}function le(i,e){const t=[];if(!e.length)return t;const s=i.byteLength;for(let r=0;r<s;){const n=ee(i,r),a=je(i.subarray(r+4,r+8)),o=n>1?r+n:s;if(a===e[0])if(e.length===1)t.push(i.subarray(r+8,o));else{const l=le(i.subarray(r+8,o),e.slice(1));l.length&&oS.apply(t,l)}r=o}return t}function dS(i){const e=[],t=i[0];let s=8;const r=ee(i,s);s+=4;let n=0,a=0;t===0?(n=ee(i,s),a=ee(i,s+4),s+=8):(n=Kp(i,s),a=Kp(i,s+8),s+=16),s+=2;let o=i.length+a;const l=Pv(i,s);s+=2;for(let d=0;d<l;d++){let c=s;const u=ee(i,c);c+=4;const h=u&2147483647;if((u&2147483648)>>>31===1)return R.warn("SIDX has hierarchical references (not supported)"),null;const m=ee(i,c);c+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/r,start:o,end:o+h-1}}),o+=h,c+=4,s=c}return{earliestPresentationTime:n,timescale:r,version:t,referencesCount:l,references:e}}function Uv(i){const e=[],t=le(i,["moov","trak"]);for(let r=0;r<t.length;r++){const n=t[r],a=le(n,["tkhd"])[0];if(a){let o=a[0];const l=ee(a,o===0?12:20),d=le(n,["mdia","mdhd"])[0];if(d){o=d[0];const c=ee(d,o===0?12:20),u=le(n,["mdia","hdlr"])[0];if(u){const h=je(u.subarray(8,12)),f={soun:be.AUDIO,vide:be.VIDEO}[h];if(f){const m=le(n,["mdia","minf","stbl","stsd"])[0],p=cS(m);e[l]={timescale:c,type:f},e[f]=dt({timescale:c,id:l},p)}}}}}return le(i,["moov","mvex","trex"]).forEach(r=>{const n=ee(r,4),a=e[n];a&&(a.default={duration:ee(r,12),flags:ee(r,20)})}),e}function cS(i){const e=i.subarray(8),t=e.subarray(86),s=je(e.subarray(4,8));let r=s;const n=s==="enca"||s==="encv";if(n){const o=le(e,[s])[0].subarray(s==="enca"?28:78);le(o,["sinf"]).forEach(d=>{const c=le(d,["schm"])[0];if(c){const u=je(c.subarray(4,8));if(u==="cbcs"||u==="cenc"){const h=le(d,["frma"])[0];h&&(r=je(h))}}})}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const a=le(t,["avcC"])[0];r+="."+bo(a[1])+bo(a[2])+bo(a[3]);break}case"mp4a":{const a=le(e,[s])[0],o=le(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=Qc(o,l),l+=2;const d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=Qc(o,l);const c=o[l++];if(c===64)r+="."+bo(c);else break;if(l+=12,o[l++]!==5)break;l=Qc(o,l);const u=o[l++];let h=(u&248)>>3;h===31&&(h+=1+((u&7)<<3)+((o[l]&224)>>5)),r+="."+h}break}case"hvc1":case"hev1":{const a=le(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,c=ee(a,2),u=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);r+="."+l+d,r+="."+c.toString(16).toUpperCase(),r+="."+u+h;let m="";for(let p=f.length;p--;){const g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}r+=m;break}case"dvh1":case"dvhe":{const a=le(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;r+="."+li(o)+"."+li(l);break}case"vp09":{const a=le(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;r+="."+li(o)+"."+li(l)+"."+li(d);break}case"av01":{const a=le(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",c=(a[2]&64)>>6,u=(a[2]&32)>>5,h=o===2&&c?u?12:10:c?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;r+="."+o+"."+li(l)+d+"."+li(h)+"."+f+"."+m+p+g+"."+li(1)+"."+li(1)+"."+li(1)+"."+0;break}}return{codec:r,encrypted:n}}function Qc(i,e){const t=e+5;for(;i[e++]&128&&e<t;);return e}function bo(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function li(i){return(i<10?"0":"")+i}function uS(i,e){if(!i||!e)return i;const t=e.keyId;return t&&e.isCommonEncryption&&le(i,["moov","trak"]).forEach(r=>{const a=le(r,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=le(a,["enca"]);const l=o.length>0;l||(o=le(a,["encv"])),o.forEach(d=>{const c=l?d.subarray(28):d.subarray(78);le(c,["sinf"]).forEach(h=>{const f=Fv(h);if(f){const m=f.subarray(8,24);m.some(p=>p!==0)||(R.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Si.hexDump(m)} -> ${Si.hexDump(t)}`),f.set(t,8))}})})}),i}function Fv(i){const e=le(i,["schm"])[0];if(e){const t=je(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return le(i,["schi","tenc"])[0]}return R.error("[eme] missing 'schm' box"),null}function hS(i,e){return le(e,["moof","traf"]).reduce((t,s)=>{const r=le(s,["tfdt"])[0],n=r[0],a=le(s,["tfhd"]).reduce((o,l)=>{const d=ee(l,4),c=i[d];if(c){let u=ee(r,4);if(n===1){if(u===Ud)return R.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=Ud+1,u+=ee(r,8)}const h=c.timescale||9e4,f=u/h;if(j(f)&&(o===null||f<o))return f}return o},null);return a!==null&&j(a)&&(t===null||a<t)?a:t},null)}function fS(i,e){let t=0,s=0,r=0;const n=le(i,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=le(o,["tfhd"])[0],d=ee(l,4),c=e[d];if(!c)continue;const u=c.default,h=ee(l,0)|(u==null?void 0:u.flags);let f=u==null?void 0:u.duration;h&8&&(h&2?f=ee(l,12):f=ee(l,8));const m=c.timescale||9e4,p=le(o,["trun"]);for(let g=0;g<p.length;g++){if(t=mS(p[g]),!t&&f){const v=ee(p[g],4);t=f*v}c.type===be.VIDEO?s+=t/m:c.type===be.AUDIO&&(r+=t/m)}}if(s===0&&r===0){let a=1/0,o=0,l=0;const d=le(i,["sidx"]);for(let c=0;c<d.length;c++){const u=dS(d[c]);if(u!=null&&u.references){a=Math.min(a,u.earliestPresentationTime/u.timescale);const h=u.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+u.earliestPresentationTime/u.timescale),l=o-a}}if(l&&j(l))return l}return s||r}function mS(i){const e=ee(i,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let s=0;const r=ee(i,4);for(let n=0;n<r;n++){if(e&256){const a=ee(i,t);s+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return s}function pS(i,e,t){le(e,["moof","traf"]).forEach(s=>{le(s,["tfhd"]).forEach(r=>{const n=ee(r,4),a=i[n];if(!a)return;const o=a.timescale||9e4;le(s,["tfdt"]).forEach(l=>{const d=l[0],c=t*o;if(c){let u=ee(l,4);if(d===0)u-=c,u=Math.max(u,0),Xc(l,4,u);else{u*=Math.pow(2,32),u+=ee(l,8),u-=c,u=Math.max(u,0);const h=Math.floor(u/(Ud+1)),f=Math.floor(u%(Ud+1));Xc(l,4,h),Xc(l,8,f)}}})})})}function gS(i){const e={valid:null,remainder:null},t=le(i,["moof"]);if(t.length<2)return e.remainder=i,e;const s=t[t.length-1];return e.valid=ur(i,0,s.byteOffset-8),e.remainder=ur(i,s.byteOffset-8),e}function Vt(i,e){const t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Vp(i,e){const t=[],s=e.samples,r=e.timescale,n=e.id;let a=!1;return le(s,["moof"]).map(l=>{const d=l.byteOffset-8;le(l,["traf"]).map(u=>{const h=le(u,["tfdt"]).map(f=>{const m=f[0];let p=ee(f,4);return m===1&&(p*=Math.pow(2,32),p+=ee(f,8)),p/r})[0];return h!==void 0&&(i=h),le(u,["tfhd"]).map(f=>{const m=ee(f,4),p=ee(f,0)&16777215,g=(p&1)!==0,v=(p&2)!==0,y=(p&8)!==0;let b=0;const x=(p&16)!==0;let _=0;const S=(p&32)!==0;let A=8;m===n&&(g&&(A+=8),v&&(A+=4),y&&(b=ee(f,A),A+=4),x&&(_=ee(f,A),A+=4),S&&(A+=4),e.type==="video"&&(a=vS(e.codec)),le(u,["trun"]).map(D=>{const O=D[0],L=ee(D,0)&16777215,C=(L&1)!==0;let H=0;const U=(L&4)!==0,Q=(L&256)!==0;let q=0;const Y=(L&512)!==0;let oe=0;const ae=(L&1024)!==0,G=(L&2048)!==0;let F=0;const re=ee(D,4);let J=8;C&&(H=ee(D,J),J+=4),U&&(J+=4);let de=H+d;for(let Ae=0;Ae<re;Ae++){if(Q?(q=ee(D,J),J+=4):q=b,Y?(oe=ee(D,J),J+=4):oe=_,ae&&(J+=4),G&&(O===0?F=ee(D,J):F=Nv(D,J),J+=4),e.type===be.VIDEO){let Ce=0;for(;Ce<oe;){const He=ee(s,de);if(de+=4,ES(a,s[de])){const St=s.subarray(de,de+He);$v(St,a?2:1,i+F/r,t)}de+=He,Ce+=He+4}}i+=q/r}}))})})}),t}function vS(i){if(!i)return!1;const e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function ES(i,e){if(i){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function $v(i,e,t,s){const r=Bv(i);let n=0;n+=e;let a=0,o=0,l=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;l=r[n++],a+=l}while(l===255);o=0;do{if(n>=r.length)break;l=r[n++],o+=l}while(l===255);const d=r.length-n;let c=n;if(o<d)n+=o;else if(o>d){R.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(r[c++]===181){const h=Pv(r,c);if(c+=2,h===49){const f=ee(r,c);if(c+=4,f===1195456820){const m=r[c++];if(m===3){const p=r[c++],g=31&p,v=64&p,y=v?2+g*3:0,b=new Uint8Array(y);if(v){b[0]=p;for(let x=1;x<y;x++)b[x]=r[c++]}s.push({type:m,payloadType:a,pts:t,bytes:b})}}}}}else if(a===5&&o>16){const u=[];for(let m=0;m<16;m++){const p=r[c++].toString(16);u.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&u.push("-")}const h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=r[c++];s.push({payloadType:a,pts:t,uuid:u.join(""),userData:Oi(f),userDataBytes:f})}}}function Bv(i){const e=i.byteLength,t=[];let s=1;for(;s<e-2;)i[s]===0&&i[s+1]===0&&i[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return i;const r=e-t.length,n=new Uint8Array(r);let a=0;for(s=0;s<r;a++,s++)a===t[0]&&(a++,t.shift()),n[s]=i[a];return n}function bS(i){const e=i[0];let t="",s="",r=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;je(i.subarray(d,d+1))!=="\0";)t+=je(i.subarray(d,d+1)),d+=1;for(t+=je(i.subarray(d,d+1)),d+=1;je(i.subarray(d,d+1))!=="\0";)s+=je(i.subarray(d,d+1)),d+=1;s+=je(i.subarray(d,d+1)),d+=1,r=ee(i,12),n=ee(i,16),o=ee(i,20),l=ee(i,24),d=28}else if(e===1){d+=4,r=ee(i,d),d+=4;const u=ee(i,d);d+=4;const h=ee(i,d);for(d+=4,a=2**32*u+h,NA(a)||(a=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ee(i,d),d+=4,l=ee(i,d),d+=4;je(i.subarray(d,d+1))!=="\0";)t+=je(i.subarray(d,d+1)),d+=1;for(t+=je(i.subarray(d,d+1)),d+=1;je(i.subarray(d,d+1))!=="\0";)s+=je(i.subarray(d,d+1)),d+=1;s+=je(i.subarray(d,d+1)),d+=1}const c=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:s,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function yS(i,...e){const t=e.length;let s=8,r=t;for(;r--;)s+=e[r].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(i,4),r=0,s=8;r<t;r++)n.set(e[r],s),s+=e[r].byteLength;return n}function TS(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let s,r;s=0,r=new Uint8Array;let n;s>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),yS([112,115,115,104],new Uint8Array([s,0,0,0]),i,n,r,a,t||new Uint8Array)}function _S(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),s=t.getUint32(0);if(i.byteLength!==s&&s>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Si.hexDump(new Uint8Array(i,12,16));const n=t.getUint32(28);if(e.version===0){if(s-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}let yo={};class ja{static clearKeyUriToKeyIdMap(){yo={}}constructor(e,t,s,r=[1],n=null){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=r,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case wt.FAIRPLAY:case wt.WIDEVINE:case wt.PLAYREADY:case wt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&R.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const s=AS(e);return new ja(this.method,this.uri,"identity",this.keyFormatVersions,s)}const t=zA(this.uri);if(t)switch(this.keyFormat){case wt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case wt.PLAYREADY:{const s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=TS(s,null,t);const r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(r)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){const c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){const u=cm(c).subarray(0,16);jA(u),this.keyId=u}}break}default:{let s=t.subarray(0,16);if(s.length!==16){const r=new Uint8Array(16);r.set(s,16-s.length),s=r}this.keyId=s;break}}if(!this.keyId||this.keyId.byteLength!==16){let s=yo[this.uri];if(!s){const r=Object.keys(yo).length%Number.MAX_SAFE_INTEGER;s=new Uint8Array(16),new DataView(s.buffer,12,4).setUint32(0,r),yo[this.uri]=s}this.keyId=s}return this}}function AS(i){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}const Gv=/\{\$([a-zA-Z0-9-_]+)\}/g;function qp(i){return Gv.test(i)}function Lt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let s=t.length;s--;){const r=t[s],n=e[r];n&&(e[r]=zu(i,n))}}function zu(i,e){if(i.variableList!==null||i.hasVariableRefs){const t=i.variableList;return e.replace(Gv,s=>{const r=s.substring(2,s.length-1),n=t==null?void 0:t[r];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),s):n})}return e}function Yp(i,e,t){let s=i.variableList;s||(i.variableList=s={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=e.NAME,n=e.VALUE;r in s?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):s[r]=n||""}function SS(i,e,t){const s=e.IMPORT;if(t&&s in t){let r=i.variableList;r||(i.variableList=r={}),r[s]=t[s]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}function _r(i=!0){return typeof self>"u"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function xS(i){return typeof self<"u"&&i===self.ManagedMediaSource}const Fd={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,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 kS(i,e){const t=Fd[e];return!!t&&!!t[i.slice(0,4)]}function Zc(i,e,t=!0){return!i.split(",").some(s=>!Hv(s,e,t))}function Hv(i,e,t=!0){var s;const r=_r(t);return(s=r==null?void 0:r.isTypeSupported(za(i,e)))!=null?s:!1}function za(i,e){return`${e}/mp4;codecs="${i}"`}function jp(i){if(i){const e=i.substring(0,4);return Fd.video[e]}return 2}function $d(i){return i.split(",").reduce((e,t)=>{const s=Fd.video[t];return s?(s*2+e)/(e?3:2):(Fd.audio[t]+e)/(e?2:1)},0)}const Jc={};function LS(i,e=!0){if(Jc[i])return Jc[i];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let s=0;s<t.length;s++)if(Hv(t[s],"audio",e))return Jc[i]=t[s],t[s];return i}const IS=/flac|opus/i;function Bd(i,e=!0){return i.replace(IS,t=>LS(t.toLowerCase(),e))}function zp(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function RS(i){const e=i.split(".");if(e.length>2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return i}const Xp=/#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,Qp=/#EXT-X-MEDIA:(.*)/g,wS=/^#EXT(?:INF|-X-TARGETDURATION):/m,Zp=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),CS=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(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 Ri{static findGroup(e,t){for(let s=0;s<e.length;s++){const r=e[s];if(r.id===t)return r}}static resolve(e,t){return dm.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return wS.test(e)}static parseMasterPlaylist(e,t){const s=qp(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},n=[];Xp.lastIndex=0;let a;for(;(a=Xp.exec(e))!=null;)if(a[1]){var o;const d=new Oe(a[1]);Lt(r,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const c=zu(r,a[2]),u={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:Ri.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),DS(d.CODECS,u),(o=u.unknownCodecs)!=null&&o.length||n.push(u),r.levels.push(u)}else if(a[3]){const d=a[3],c=a[4];switch(d){case"SESSION-DATA":{const u=new Oe(c);Lt(r,u,["DATA-ID","LANGUAGE","VALUE","URI"]);const h=u["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=u);break}case"SESSION-KEY":{const u=Jp(c,t,r);u.encrypted&&u.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(u)):R.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{const u=new Oe(c);Lt(r,u,["NAME","VALUE","QUERYPARAM"]),Yp(r,u,t)}break}case"CONTENT-STEERING":{const u=new Oe(c);Lt(r,u,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:Ri.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=e0(c);break}}}const l=n.length>0&&n.length<r.levels.length;return r.levels=l?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,s){let r;const n={},a=s.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(Qp.lastIndex=0;(r=Qp.exec(e))!==null;){const d=new Oe(r[1]),c=d.TYPE;if(c){const u=o[c],h=n[c]||[];n[c]=h,Lt(s,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,v=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?Ri.resolve(d.URI,t):""};if(m&&(y.assocLang=m),p&&(y.channels=p),g&&(y.characteristics=g),v&&(y.instreamId=v),u!=null&&u.length){const b=Ri.findGroup(u,y.groupId)||u[0];t0(y,b,"audioCodec"),t0(y,b,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,s,r,n,a){const o=new qA(t),l=o.fragments;let d=null,c=0,u=0,h=0,f=0,m=null,p=new Yc(r,t),g,v,y,b=-1,x=!1,_=null;for(Zp.lastIndex=0,o.m3u8=e,o.hasVariableRefs=qp(e);(g=Zp.exec(e))!==null;){x&&(x=!1,p=new Yc(r,t),p.start=h,p.sn=c,p.cc=f,p.level=s,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(p.setByteRange(_),_=null)));const O=g[1];if(O){p.duration=parseFloat(O);const L=(" "+g[2]).slice(1);p.title=L||null,p.tagList.push(L?["INF",O,L]:["INF",O])}else if(g[3]){if(j(p.duration)){p.start=h,y&&r0(p,y,o),p.sn=c,p.level=s,p.cc=f,l.push(p);const L=(" "+g[3]).slice(1);p.relurl=zu(o,L),i0(p,m),m=p,h+=p.duration,c++,u=0,x=!0}}else if(g[4]){const L=(" "+g[4]).slice(1);m?p.setByteRange(L,m):p.setByteRange(L)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),b===-1&&(b=l.length);else{if(g=g[0].match(CS),!g){R.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<g.length&&!(typeof g[v]<"u");v++);const L=(" "+g[v]).slice(1),C=(" "+g[v+1]).slice(1),H=g[v+2]?(" "+g[v+2]).slice(1):"";switch(L){case"PLAYLIST-TYPE":o.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(C);break;case"SKIP":{const U=new Oe(C);Lt(o,U,["RECENTLY-REMOVED-DATERANGES"]);const Q=U.decimalInteger("SKIPPED-SEGMENTS");if(j(Q)){o.skippedSegments=Q;for(let Y=Q;Y--;)l.unshift(null);c+=Q}const q=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(o.recentlyRemovedDateranges=q.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(C),1);break;case"VERSION":o.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(C||H)&&p.tagList.push(H?[C,H]:[C]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([L]);break;case"BITRATE":p.tagList.push([L,C]);break;case"DATERANGE":{const U=new Oe(C);Lt(o,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Lt(o,U,U.clientAttrs);const Q=new Lv(U,o.dateRanges[U.ID]);Q.isValid||o.skippedSegments?o.dateRanges[Q.id]=Q:R.warn(`Ignoring invalid DATERANGE tag: "${C}"`),p.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":{{const U=new Oe(C);Lt(o,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?SS(o,U,a):Yp(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{const U=Jp(C,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=Ke({},y)),y[U.keyFormat]=U}else R.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":o.startTimeOffset=e0(C);break;case"MAP":{const U=new Oe(C);if(Lt(o,U,["BYTERANGE","URI"]),p.duration){const Q=new Yc(r,t);s0(Q,U,s,y),d=Q,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{const Q=p.byteRangeEndOffset;if(Q){const q=p.byteRangeStartOffset;_=`${Q-q}@${q}`}else _=null;s0(p,U,s,y),d=p,x=!0}break}case"SERVER-CONTROL":{const U=new Oe(C);o.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),o.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const U=new Oe(C);o.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=o.partList;U||(U=o.partList=[]);const Q=u>0?U[U.length-1]:void 0,q=u++,Y=new Oe(C);Lt(o,Y,["BYTERANGE","URI"]);const oe=new KA(Y,p,t,q,Q);U.push(oe),p.duration+=oe.duration;break}case"PRELOAD-HINT":{const U=new Oe(C);Lt(o,U,["URI"]),o.preloadHint=U;break}case"RENDITION-REPORT":{const U=new Oe(C);Lt(o,U,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(U);break}default:R.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(i0(p,m),p.cc=f,o.fragmentHint=p,y&&r0(p,y,o));const S=l.length,A=l[0],D=l[S-1];if(h+=o.skippedSegments*o.targetduration,h>0&&S&&D){o.averagetargetduration=h/S;const O=D.sn;o.endSN=O!=="initSegment"?O:0,o.live||(D.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,b>0&&MS(l,b),o}}function Jp(i,e,t){var s,r;const n=new Oe(i);Lt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(s=n.METHOD)!=null?s:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!l&&R.error(`Invalid IV: ${n.IV}`);const u=o?Ri.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new ja(a,u,c,h,l)}function e0(i){const t=new Oe(i).decimalFloatingPoint("TIME-OFFSET");return j(t)?t:null}function DS(i,e){let t=(i||"").split(/[ ,]+/).filter(s=>s);["video","audio","text"].forEach(s=>{const r=t.filter(n=>kS(n,s));r.length&&(e[`${s}Codec`]=r.join(","),t=t.filter(n=>r.indexOf(n)===-1))}),e.unknownCodecs=t}function t0(i,e,t){const s=e[t];s&&(i[t]=s)}function MS(i,e){let t=i[e];for(let s=e;s--;){const r=i[s];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function i0(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),j(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function s0(i,e,t,s){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",s&&(i.levelkeys=s),i.initSegment=null}function r0(i,e,t){i.levelkeys=e;const{encryptedFragments:s}=t;(!s.length||s[s.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&s.push(i)}var pe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},te={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function n0(i){const{type:e}=i;switch(e){case pe.AUDIO_TRACK:return te.AUDIO;case pe.SUBTITLE_TRACK:return te.SUBTITLE;default:return te.MAIN}}function eu(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class OS{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,s=t.pLoader,r=t.loader,n=s||r,a=new n(t);return this.loaders[e.type]=a,a}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:pe.MANIFEST,url:s,deliveryDirectives:null})}onLevelLoading(e,t){const{id:s,level:r,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:s,level:r,pathwayId:n,responseType:"text",type:pe.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:s,groupId:r,url:n,deliveryDirectives:a}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:pe.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:s,groupId:r,url:n,deliveryDirectives:a}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:pe.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;const s=this.hls.config;let r=this.getInternalLoader(e);if(r){const d=r.context;if(d&&d.url===e.url&&d.level===e.level){R.trace("[playlist-loader]: playlist request ongoing");return}R.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let n;if(e.type===pe.MANIFEST?n=s.manifestLoadPolicy.default:n=Ke({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===pe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===pe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===pe.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const c=d.partTarget,u=d.targetduration;if(c&&u){const h=Math.max(c*3,u*.8)*1e3;n=Ke({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{const f=this.getInternalLoader(u);this.resetInternalLoader(u.type);const m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),Ri.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};r.load(e,o,l)}handleMasterPlaylist(e,t,s,r){const n=this.hls,a=e.data,o=eu(e,s),l=Ri.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,s,l.playlistParsingError,r,t);return}const{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=Ri.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(b=>!b.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(R.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Oe({}),bitrate:0,url:""})),n.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:g,captions:v,contentSteering:d,url:o,stats:t,networkDetails:r,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,s,r,n){const a=this.hls,{id:o,level:l,type:d}=s,c=eu(e,s),u=0,h=j(l)?l:j(o)?o:0,f=n0(s),m=Ri.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===pe.MANIFEST){const p={attrs:new Oe({}),bitrate:0,details:m,name:"",url:c};a.trigger(E.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),s.levelDetails=m,this.handlePlaylistLoaded(m,e,t,s,r,n)}handleManifestParsingError(e,t,s,r,n){this.hls.trigger(E.ERROR,{type:se.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:t.type===pe.MANIFEST,url:e.url,err:s,error:s,reason:s.message,response:e,context:t,networkDetails:r,stats:n})}handleNetworkError(e,t,s=!1,r,n){let a=`A network ${s?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===pe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===pe.AUDIO_TRACK||e.type===pe.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);R.warn(`[playlist-loader]: ${a}`);let l=M.UNKNOWN,d=!1;const c=this.getInternalLoader(e);switch(e.type){case pe.MANIFEST:l=s?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,d=!0;break;case pe.LEVEL:l=s?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,d=!1;break;case pe.AUDIO_TRACK:l=s?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case pe.SUBTITLE_TRACK:l=s?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);const u={type:se.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){const h=(t==null?void 0:t.url)||e.url;u.response=dt({url:h,data:void 0},r)}this.hls.trigger(E.ERROR,u)}handlePlaylistLoaded(e,t,s,r,n,a){const o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=r,f=eu(t,r),m=n0(r),p=typeof r.level=="number"&&m===te.MAIN?d:void 0;if(!e.fragments.length){const v=new Error("No Segments found in Playlist");o.trigger(E.ERROR,{type:se.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:v,reason:v.message,response:t,context:r,level:p,parent:m,networkDetails:n,stats:s});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g){o.trigger(E.ERROR,{type:se.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:r,level:p,parent:m,networkDetails:n,stats:s});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case pe.MANIFEST:case pe.LEVEL:o.trigger(E.LEVEL_LOADED,{details:e,level:p||0,id:c||0,stats:s,networkDetails:n,deliveryDirectives:h});break;case pe.AUDIO_TRACK:o.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:s,networkDetails:n,deliveryDirectives:h});break;case pe.SUBTITLE_TRACK:o.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:s,networkDetails:n,deliveryDirectives:h});break}}}function Wv(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Kv(i,e){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(s){R.debug(`[texttrack-utils]: ${s}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,i.addCue(r)}catch(r){R.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(i.mode=t)}function fn(i){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Xu(i,e,t,s){const r=i.mode;if(r==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const n=NS(i.cues,e,t);for(let a=0;a<n.length;a++)(!s||s(n[a]))&&i.removeCue(n[a])}r==="disabled"&&(i.mode=r)}function PS(i,e){if(e<i[0].startTime)return 0;const t=i.length-1;if(e>i[t].endTime)return-1;let s=0,r=t;for(;s<=r;){const n=Math.floor((r+s)/2);if(e<i[n].startTime)r=n-1;else if(e>i[n].startTime&&s<t)s=n+1;else return n}return i[s].startTime-e<e-i[r].startTime?s:r}function NS(i,e,t){const s=[],r=PS(i,e);if(r>-1)for(let n=r,a=i.length;n<a;n++){const o=i[n];if(o.startTime>=e&&o.endTime<=t)s.push(o);else if(o.startTime>t)return s}return s}function tl(i){const e=[];for(let t=0;t<i.length;t++){const s=i[t];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&e.push(i[t])}return e}var ei={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const US=.25;function Qu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function a0(i,e,t,s,r){let n=new i(e,t,"");try{n.value=s,r&&(n.type=r)}catch{n=new i(e,t,JSON.stringify(r?dt({type:r},s):s))}return n}const To=(()=>{const i=Qu();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function tu(i,e){return i.getTime()/1e3-e}function FS(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class $S{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(fn(this.id3Track),this.id3Track=null,this.media=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 Wv(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:s,enableID3MetadataCues:r}}}=this;if(!s&&!r)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Qu();if(a)for(let o=0;o<n.length;o++){const l=n[o].type;if(l===ei.emsg&&!s||!r)continue;const d=Mv(n[o].data);if(d){const c=n[o].pts;let u=c+n[o].duration;u>To&&(u=To),u-c<=0&&(u=c+US);for(let f=0;f<d.length;f++){const m=d[f];if(!Dv(m)){this.updateId3CueEnds(c,l);const p=a0(a,c,u,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var s;const r=(s=this.id3Track)==null?void 0:s.cues;if(r)for(let n=r.length;n--;){const a=r[n];a.type===t&&a.startTime<e&&a.endTime===To&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:s,type:r}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;r==="audio"?d=c=>c.type===ei.audioId3&&l:r==="video"?d=c=>c.type===ei.emsg&&o:d=c=>c.type===ei.audioId3&&l||c.type===ei.emsg&&o,Xu(n,t,s,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:s,id3Track:r}=this,{dateRanges:n}=t,a=Object.keys(n);if(r){const c=Object.keys(s).filter(u=>!a.includes(u));for(let u=c.length;u--;){const h=c[u];Object.keys(s[h].cues).forEach(f=>{r.removeCue(s[h].cues[f])}),delete s[h]}}const o=t.fragments[t.fragments.length-1];if(a.length===0||!j(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,d=Qu();for(let c=0;c<a.length;c++){const u=a[c],h=n[u],f=tu(h.startDate,l),m=s[u],p=(m==null?void 0:m.cues)||{};let g=(m==null?void 0:m.durationKnown)||!1,v=To;const y=h.endDate;if(y)v=tu(y,l),g=!0;else if(h.endOnNext&&!g){const x=a.reduce((_,S)=>{if(S!==h.id){const A=n[S];if(A.class===h.class&&A.startDate>h.startDate&&(!_||h.startDate<_.startDate))return A}return _},null);x&&(v=tu(x.startDate,l),g=!0)}const b=Object.keys(h.attr);for(let x=0;x<b.length;x++){const _=b[x];if(!HA(_))continue;const S=p[_];if(S)g&&!m.durationKnown&&(S.endTime=v);else if(d){let A=h.attr[_];WA(_)&&(A=FS(A));const D=a0(d,f,v,{key:_,data:A},ei.dateRange);D&&(D.id=u,this.id3Track.addCue(D),p[_]=D)}}s[u]={cues:p,dateRange:h,durationKnown:g}}}}class BS{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:s,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let d=o&&s||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*r);const c=r;return d+Math.min(this.stallCount*1,c)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,s=this.levelDetails;if(e===null||t===null||s===null)return null;const r=s.edge,n=e-t-this.edgeStalled,a=r-s.totalduration,o=r-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;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,levelDetails:t}=this;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.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var s;t.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,(s=this.levelDetails)!=null&&s.live&&R.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1||!t.live)return;const a=this.targetLatency;if(a===null)return;const o=s-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){const c=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const Zu=["NONE","TYPE-0","TYPE-1",null];function GS(i){return Zu.indexOf(i)>-1}const Gd=["SDR","PQ","HLG"];function HS(i){return!!i&&Gd.indexOf(i)>-1}var il={No:"",Yes:"YES",v2:"v2"};function o0(i){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=i,r=s<e/2;return e&&r?t?il.v2:il.Yes:il.No}class l0{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 wn{constructor(e){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.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(t=>!!t).map(t=>t.substring(0,4)).join(","),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 d0(this._audioGroups,e)}hasSubtitleGroup(e){return d0(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 d0(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function iu(i,e){const t=e.startPTS;if(j(t)){let s=0,r;e.sn>i.sn?(s=t-i.start,r=i):(s=i.start-t,r=e),r.duration!==s&&(r.duration=s)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Vv(i,e,t,s,r,n){s-t<=0&&(R.warn("Fragment should have a positive duration",e),s=t+e.duration,n=r+e.duration);let o=t,l=s;const d=e.startPTS,c=e.endPTS;if(j(d)){const g=Math.abs(d-t);j(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),r=Math.min(r,e.startDTS),l=Math.min(s,c),s=Math.max(s,c),n=Math.max(n,e.endDTS)}const u=t-e.start;e.start!==0&&(e.start=t),e.duration=s-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=r,e.endPTS=s,e.minEndPTS=l,e.endDTS=n;const h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f;const m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)iu(p[f],p[f-1]);for(f=m;f<p.length-1;f++)iu(p[f],p[f+1]);return i.fragmentHint&&iu(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,u}function WS(i,e){let t=null;const s=i.fragments;for(let l=s.length-1;l>=0;l--){const d=s[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let r=0,n;if(qS(i,e,(l,d)=>{l.relurl&&(r=l.cc-d.cc),j(l.startPTS)&&j(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;d&&(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){R.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=KS(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const a=e.fragments;if(r){R.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=r}e.skippedSegments&&(e.startCC=e.fragments[0].cc),VS(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Vv(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):qv(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function KS(i,e,t){const s=Ke({},i);return t&&t.forEach(r=>{delete s[r]}),Object.keys(e).forEach(r=>{const n=new Lv(e[r].attr,s[r]);n.isValid?s[r]=n:R.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[r].attr)}"`)}),s}function VS(i,e,t){if(i&&e){let s=0;for(let r=0,n=i.length;r<=n;r++){const a=i[r],o=e[r+s];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):s--}}}function qS(i,e,t){const s=e.skippedSegments,r=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(s?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=r;d<=n;d++){const c=l[a+d];let u=o[d];s&&!u&&d<s&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function qv(i,e){const t=e.startSN+e.skippedSegments-i.startSN,s=i.fragments;t<0||t>=s.length||Ju(e,s[t].start)}function Ju(i,e){if(e){const t=i.fragments;for(let s=i.skippedSegments;s<t.length;s++)t[s].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function YS(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){const s=i.fragments;if(s.length&&t*4>e){const n=s[s.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function jS(i,e,t){if(!(i!=null&&i.details))return null;const s=i.details;let r=s.fragments[e-s.startSN];return r||(r=s.fragmentHint,r&&r.sn===e)?r:e<s.startSN&&t&&t.sn===e?t:null}function c0(i,e,t){var s;return i!=null&&i.details?Yv((s=i.details)==null?void 0:s.partList,e,t):null}function Yv(i,e,t){if(i)for(let s=i.length;s--;){const r=i[s];if(r.index===t&&r.fragment.sn===e)return r}return null}function jv(i){i.forEach((e,t)=>{const{details:s}=e;s!=null&&s.fragments&&s.fragments.forEach(r=>{r.level=t})})}function Hd(i){switch(i.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function u0(i,e){const t=Hd(e);return i.default[`${t?"timeout":"error"}Retry`]}function fm(i,e){const t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function h0(i){return dt(dt({},i),{errorRetry:null,timeoutRetry:null})}function Wd(i,e,t,s){if(!i)return!1;const r=s==null?void 0:s.code,n=e<i.maxNumRetry&&(zS(r)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,s,n):n}function zS(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const zv={search:function(i,e){let t=0,s=i.length-1,r=null,n=null;for(;t<=s;){r=(t+s)/2|0,n=i[r];const a=e(n);if(a>0)t=r+1;else if(a<0)s=r-1;else return n}return null}};function XS(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!j(e))return null;const s=i[0].programDateTime;if(e<(s||0))return null;const r=i[i.length-1].endProgramDateTime;if(e>=(r||0))return null;t=t||0;for(let n=0;n<i.length;++n){const a=i[n];if(ZS(e,t,a))return a}return null}function Kd(i,e,t=0,s=0,r=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;const o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&eh(t,s,n)===0||QS(n,i,Math.min(r,s))))return n;const a=zv.search(e,eh.bind(null,t,s));return a&&(a!==i||!n)?a:n}function QS(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){const s=e.tagList.reduce((r,n)=>(n[0]==="INF"&&(r+=parseFloat(n[1])),r),t);return i.start<=s}return!1}function eh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-s<=i?1:t.start-s>i&&t.start?-1:0}function ZS(i,e,t){const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-s>i}function JS(i,e){return zv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var mt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Yt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class ex{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===te.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var s,r;if(t.fatal)return;const n=this.hls,a=t.context;switch(t.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case M.FRAG_PARSING_ERROR:if((s=t.frag)!=null&&s.gap){t.errorAction={action:mt.DoNothing,flags:Yt.None};return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=mt.SendAlternateToPenaltyBox;return}case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:{var o,l;const d=t.parent===te.MAIN?t.level:n.loadLevel;t.details===M.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const d=n.levels[n.loadLevel];if(d&&(a.type===pe.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===pe.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=mt.SendAlternateToPenaltyBox,t.errorAction.flags=Yt.MoveAllAlternatesMatchingHost;return}}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const d=n.levels[n.loadLevel],c=d==null?void 0:d.attrs["HDCP-LEVEL"];c?t.errorAction={action:mt.SendAlternateToPenaltyBox,flags:Yt.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(t)}return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:n.loadLevel);return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:t.errorAction={action:mt.DoNothing,flags:Yt.None};return}t.type===se.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const s=this.hls,r=u0(s.config.playlistLoadPolicy,e),n=this.playlistError++;if(Wd(r,n,Hd(e),e.response))return{action:mt.RetryRequest,flags:Yt.None,retryConfig:r,retryCount:n};const o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,s=this.getVariantLevelIndex(e.frag),r=t.levels[s],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=u0(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(r&&(e.details!==M.FRAG_GAP&&r.fragmentError++,Wd(o,l,Hd(e),e.response)))return{action:mt.RetryRequest,flags:Yt.None,retryConfig:o,retryCount:l};const d=this.getLevelSwitchAction(e,s);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){const s=this.hls;t==null&&(t=s.loadLevel);const r=this.hls.levels[t];if(r){var n,a;const d=e.details;r.loadError++,d===M.BUFFER_APPEND_ERROR&&r.fragmentError++;let c=-1;const{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=s;s.autoLevelEnabled||(s.loadLevel=-1);const p=(n=e.frag)==null?void 0:n.type,v=(p===te.AUDIO&&d===M.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:S})=>r.audioCodec!==S),b=e.sourceBufferName==="video"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR)&&u.some(({codecSet:S,audioCodec:A})=>r.codecSet!==S&&r.audioCodec===A),{type:x,groupId:_}=(a=e.context)!=null?a:{};for(let S=u.length;S--;){const A=(S+h)%u.length;if(A!==h&&A>=f&&A<=m&&u[A].loadError===0){var o,l;const D=u[A];if(d===M.FRAG_GAP&&p===te.MAIN&&e.frag){const O=u[A].details;if(O){const L=Kd(e.frag,O.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(x===pe.AUDIO_TRACK&&D.hasAudioGroup(_)||x===pe.SUBTITLE_TRACK&&D.hasSubtitleGroup(_))continue;if(p===te.AUDIO&&(o=r.audioGroups)!=null&&o.some(O=>D.hasAudioGroup(O))||p===te.SUBTITLE&&(l=r.subtitleGroups)!=null&&l.some(O=>D.hasSubtitleGroup(O))||v&&r.audioCodec===D.audioCodec||!v&&r.audioCodec!==D.audioCodec||b&&r.codecSet===D.codecSet)continue}c=A;break}}if(c>-1&&s.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:mt.SendAlternateToPenaltyBox,flags:Yt.None,nextAutoLevel:c}}return{action:mt.SendAlternateToPenaltyBox,flags:Yt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var s;switch((s=t.errorAction)==null?void 0:s.action){case mt.DoNothing:break;case mt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==M.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${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:r,hdcpLevel:n,nextAutoLevel:a}=s;switch(r){case Yt.None:this.switchLevel(e,a);break;case Yt.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Zu[Zu.indexOf(n)-1],s.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}s.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class mm{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=R.log.bind(R,`${t}:`),this.warn=R.warn.bind(R,`${t}:`),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.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,s){const r=t==null?void 0:t.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){const o=r[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(d){R.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){const a=r[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const c=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&c>t.partTarget&&(l+=1)}const d=s&&o0(s);return new l0(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,s){const{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(r.advancedDateTime=Date.now()-o,r.live||s!=null&&s.live){if(r.reloaded(s),s&&this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),s&&r.fragments.length>0&&WS(s,r),!this.canLoad||!r.live)return;let l,d,c;if(r.canBlockReload&&r.endSN&&r.advanced){const g=this.hls.config.lowLatencyMode,v=r.lastPartSn,y=r.endSN,b=r.lastPartIndex,x=b!==-1,_=v===y,S=g?0:b;x?(d=_?y+1:v,c=_?S:b+1):d=y+1;const A=r.age,D=A+r.ageHeader;let O=Math.min(D-r.partTarget,r.targetduration*1.5);if(O>0){if(s&&O>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${O} with playlist age: ${r.age}`),O=0;else{const L=Math.floor(O/r.targetduration);if(d+=L,c!==void 0){const C=Math.round(O%r.targetduration/r.partTarget);c+=C}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${O} skip sn ${L} to part ${c}`)}r.tuneInGoal=O}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,c),g||!_){this.loadPlaylist(l);return}}else(r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,c));const u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(r.edge-h)*1e3,m=YS(r,f);r.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&r.canBlockReload?this.requestScheduled=n.loading.first+m-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,s,r){let n=o0(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(s=t.msn,r=t.part,n=il.No),new l0(s,r,n)}checkRetry(e){const t=e.details,s=Hd(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(n===mt.RetryRequest||!r.resolved&&n===mt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(s&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const c=fm(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,r.resolved=!0}return l}}class Dr{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 tx{constructor(e,t,s,r=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 Dr(e),this.fast_=new Dr(t),this.defaultTTFB_=r,this.ttfb_=new Dr(e)}update(e,t){const{slow_:s,fast_:r,ttfb_:n}=this;s.halfLife!==e&&(this.slow_=new Dr(e,s.getEstimate(),s.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Dr(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Dr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,r=e/1e3,n=s/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}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_}destroy(){}}const Xv={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},f0={};function ix(i,e,t,s,r,n){const a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2;let c=null;if(a!=null&&a.length)try{a.length===1&&a[0]?c=e.groups[a[0]].channels:c=a.reduce((u,h)=>{if(h){const f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{u[m]=(u[m]||0)+f.channels[m]})}return u},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(s,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(r,8e6))||!!c&&j(d)&&Object.keys(c).some(u=>parseInt(u)>d)}function sx(i,e,t){const s=i.videoCodec,r=i.audioCodec;if(!s||!r||!t)return Promise.resolve(Xv);const n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());const o=s.split(",").map(l=>({type:"media-source",video:dt(dt({},n),{},{contentType:za(l,"video")})}));return r&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(c=>{if(c.groupId===l){const u=c.channels||"",h=parseFloat(u);j(h)&&h>2&&o.push.apply(o,r.split(",").map(f=>({type:"media-source",audio:{contentType:za(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{const d=rx(l);return f0[d]||(f0[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function rx(i){const{audio:e,video:t}=i,s=t||e;if(s){const r=s.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${r}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${r}`}return""}function nx(){if(typeof matchMedia=="function"){const i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function ax(i,e){let t=!1,s=[];return i&&(t=i!=="SDR",s=[i]),e&&(s=e.allowedVideoRanges||Gd.slice(0),t=e.preferHDR!==void 0?e.preferHDR:nx(),t?s=s.filter(r=>r!=="SDR"):s=["SDR"]),{preferHDR:t,allowedVideoRanges:s}}function ox(i,e,t,s,r){const n=Object.keys(i),a=s==null?void 0:s.channels,o=s==null?void 0:s.audioCodec,l=a&&parseInt(a)===2;let d=!0,c=!1,u=1/0,h=1/0,f=1/0,m=0,p=[];const{preferHDR:g,allowedVideoRanges:v}=ax(e,r);for(let _=n.length;_--;){const S=i[n[_]];d=S.channels[2]>0,u=Math.min(u,S.minHeight),h=Math.min(h,S.minFramerate),f=Math.min(f,S.minBitrate);const A=v.filter(D=>S.videoRanges[D]>0);A.length>0&&(c=!0,p=A)}u=j(u)?u:0,h=j(h)?h:0;const y=Math.max(1080,u),b=Math.max(30,h);return f=j(f)?f:t,t=Math.max(f,t),c||(e=void 0,p=[]),{codecSet:n.reduce((_,S)=>{const A=i[S];if(S===_)return _;if(A.minBitrate>t)return $i(S,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),_;if(!A.hasDefaultAudio)return $i(S,"no renditions with default or auto-select sound found"),_;if(o&&S.indexOf(o.substring(0,4))%5!==0)return $i(S,`audio codec preference "${o}" not found`),_;if(a&&!l){if(!A.channels[a])return $i(S,`no renditions with ${a} channel sound found (channels options: ${Object.keys(A.channels)})`),_}else if((!o||l)&&d&&A.channels[2]===0)return $i(S,"no renditions with stereo sound found"),_;return A.minHeight>y?($i(S,`min resolution of ${A.minHeight} > maximum of ${y}`),_):A.minFramerate>b?($i(S,`min framerate of ${A.minFramerate} > maximum of ${b}`),_):p.some(D=>A.videoRanges[D]>0)?A.maxScore<m?($i(S,`max score of ${A.maxScore} < selected max of ${m}`),_):_&&($d(S)>=$d(_)||A.fragmentError>i[_].fragmentError)?_:(m=A.maxScore,S):($i(S,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),_)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function $i(i,e){R.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function lx(i){return i.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 r=t.channels||"2";return s.channels[r]=(s.channels[r]||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 dx(i,e,t,s){return i.slice(t,s+1).reduce((r,n)=>{if(!n.codecSet)return r;const a=n.audioGroups;let o=r[n.codecSet];o||(r[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);const l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;const c=e.groups[d];c&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?c.hasDefault:c.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(c.channels).forEach(u=>{o.channels[u]=(o.channels[u]||0)+c.channels[u]}))}),r},{})}function wi(i,e,t){if("attrs"in i){const s=e.indexOf(i);if(s!==-1)return s}for(let s=0;s<e.length;s++){const r=e[s];if(En(i,r,t))return s}return-1}function En(i,e,t){const{groupId:s,name:r,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(s===void 0||e.groupId===s)&&(r===void 0||e.name===r)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||cx(o,e.characteristics))&&(t===void 0||t(i,e))}function cx(i,e=""){const t=i.split(","),s=e.split(",");return t.length===s.length&&!t.some(r=>s.indexOf(r)===-1)}function Mr(i,e){const{audioCodec:t,channels:s}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function ux(i,e,t,s,r){const n=e[s],o=e.reduce((h,f,m)=>{const p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(s=Math.max.apply(Math,o));const l=n.videoRange,d=n.frameRate,c=n.codecSet.substring(0,4),u=m0(e,s,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==c)return!1;const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return wi(i,m,r)>-1});return u>-1?u:m0(e,s,h=>{const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return wi(i,m,r)>-1})}function m0(i,e,t){for(let s=e;s;s--)if(t(i[s]))return s;for(let s=e+1;s<i.length;s++)if(t(i[s]))return s;return-1}class hx{constructor(e){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.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:s,hls:r}=this,{autoLevelEnabled:n,media:a}=r;if(!t||!a)return;const o=performance.now(),l=s?s.stats:t.stats,d=s?s.duration:t.duration,c=o-l.loading.start,u=r.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=u){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;const h=r.mainForwardBufferInfo;if(h===null)return;const f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(c<=Math.max(f,1e3*(d/(m*2))))return;const p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,v=l.loaded&&g>-1,y=this.getBwEstimate(),b=r.levels,x=b[t.level],_=l.total||Math.max(l.loaded,Math.round(d*x.averageBitrate/8));let S=v?c-g:c;S<1&&v&&(S=Math.min(c,l.loaded*8/y));const A=v?l.loaded*1e3/S:0,D=A?(_-l.loaded)/A:_*8/y+f/1e3;if(D<=p)return;const O=A?A*8:y;let L=Number.POSITIVE_INFINITY,C;for(C=t.level-1;C>u;C--){const U=b[C].maxBitrate;if(L=this.getTimeToLoadFrag(f/1e3,O,d*U,!b[C].details),L<p)break}if(L>=D||L>d*10)return;r.nextLoadLevel=r.nextAutoLevel=C,v?this.bwEstimator.sample(c-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(c);const H=b[C].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>H&&this.resetEstimator(H),this.clearTimer(),R.warn(`[abr] Fragment ${t.sn}${s?" part "+s.index:""} of level ${t.level} is loading too slowly;
21
+ */function MA(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var kv={exports:{}};(function(i,e){(function(t){var s=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,r=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,o={buildAbsoluteURL:function(l,d,c){if(c=c||{},l=l.trim(),d=d.trim(),!d){if(!c.alwaysNormalize)return l;var u=o.parseURL(l);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(d);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)):d;var f=o.parseURL(l);if(!f)throw new Error("Error trying to parse base URL.");if(!f.netLoc&&f.path&&f.path[0]!=="/"){var m=r.exec(f.path);f.netLoc=m[1],f.path=m[2]}f.netLoc&&!f.path&&(f.path="/");var p={scheme:f.scheme,netLoc:h.netLoc,path:null,params:h.params,query:h.query,fragment:h.fragment};if(!h.netLoc&&(p.netLoc=f.netLoc,h.path[0]!=="/"))if(!h.path)p.path=f.path,h.params||(p.params=f.params,h.query||(p.query=f.query));else{var g=f.path,v=g.substring(0,g.lastIndexOf("/")+1)+h.path;p.path=o.normalizePath(v)}return p.path===null&&(p.path=c.alwaysNormalize?o.normalizePath(h.path):h.path),o.buildURLFromParts(p)},parseURL:function(l){var d=s.exec(l);return d?{scheme:d[1]||"",netLoc:d[2]||"",path:d[3]||"",params:d[4]||"",query:d[5]||"",fragment:d[6]||""}:null},normalizePath:function(l){for(l=l.split("").reverse().join("").replace(n,"");l.length!==(l=l.replace(a,"")).length;);return l.split("").reverse().join("")},buildURLFromParts:function(l){return l.scheme+l.netLoc+l.path+l.params+l.query+l.fragment}};i.exports=o})()})(kv);var dm=kv.exports;function Bp(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(i);e&&(s=s.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,s)}return t}function dt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Bp(Object(t),!0).forEach(function(s){NA(i,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Bp(Object(t)).forEach(function(s){Object.defineProperty(i,s,Object.getOwnPropertyDescriptor(t,s))})}return i}function OA(i,e){if(typeof i!="object"||!i)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var s=t.call(i,e||"default");if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function PA(i){var e=OA(i,"string");return typeof e=="symbol"?e:String(e)}function NA(i,e,t){return e=PA(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ke(){return Ke=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&(i[s]=t[s])}return i},Ke.apply(this,arguments)}const j=Number.isFinite||function(i){return typeof i=="number"&&isFinite(i)},UA=Number.isSafeInteger||function(i){return typeof i=="number"&&Math.abs(i)<=FA},FA=Number.MAX_SAFE_INTEGER||9007199254740991;let E=function(i){return i.MEDIA_ATTACHING="hlsMediaAttaching",i.MEDIA_ATTACHED="hlsMediaAttached",i.MEDIA_DETACHING="hlsMediaDetaching",i.MEDIA_DETACHED="hlsMediaDetached",i.BUFFER_RESET="hlsBufferReset",i.BUFFER_CODECS="hlsBufferCodecs",i.BUFFER_CREATED="hlsBufferCreated",i.BUFFER_APPENDING="hlsBufferAppending",i.BUFFER_APPENDED="hlsBufferAppended",i.BUFFER_EOS="hlsBufferEos",i.BUFFER_FLUSHING="hlsBufferFlushing",i.BUFFER_FLUSHED="hlsBufferFlushed",i.MANIFEST_LOADING="hlsManifestLoading",i.MANIFEST_LOADED="hlsManifestLoaded",i.MANIFEST_PARSED="hlsManifestParsed",i.LEVEL_SWITCHING="hlsLevelSwitching",i.LEVEL_SWITCHED="hlsLevelSwitched",i.LEVEL_LOADING="hlsLevelLoading",i.LEVEL_LOADED="hlsLevelLoaded",i.LEVEL_UPDATED="hlsLevelUpdated",i.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",i.LEVELS_UPDATED="hlsLevelsUpdated",i.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",i.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",i.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",i.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",i.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",i.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",i.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",i.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",i.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",i.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",i.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",i.CUES_PARSED="hlsCuesParsed",i.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",i.INIT_PTS_FOUND="hlsInitPtsFound",i.FRAG_LOADING="hlsFragLoading",i.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",i.FRAG_LOADED="hlsFragLoaded",i.FRAG_DECRYPTED="hlsFragDecrypted",i.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",i.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",i.FRAG_PARSING_METADATA="hlsFragParsingMetadata",i.FRAG_PARSED="hlsFragParsed",i.FRAG_BUFFERED="hlsFragBuffered",i.FRAG_CHANGED="hlsFragChanged",i.FPS_DROP="hlsFpsDrop",i.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",i.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",i.ERROR="hlsError",i.DESTROYING="hlsDestroying",i.KEY_LOADING="hlsKeyLoading",i.KEY_LOADED="hlsKeyLoaded",i.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",i.BACK_BUFFER_REACHED="hlsBackBufferReached",i.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",i}({}),se=function(i){return i.NETWORK_ERROR="networkError",i.MEDIA_ERROR="mediaError",i.KEY_SYSTEM_ERROR="keySystemError",i.MUX_ERROR="muxError",i.OTHER_ERROR="otherError",i}({}),M=function(i){return i.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",i.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",i.KEY_SYSTEM_NO_SESSION="keySystemNoSession",i.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",i.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",i.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",i.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",i.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",i.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",i.MANIFEST_LOAD_ERROR="manifestLoadError",i.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",i.MANIFEST_PARSING_ERROR="manifestParsingError",i.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",i.LEVEL_EMPTY_ERROR="levelEmptyError",i.LEVEL_LOAD_ERROR="levelLoadError",i.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",i.LEVEL_PARSING_ERROR="levelParsingError",i.LEVEL_SWITCH_ERROR="levelSwitchError",i.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",i.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",i.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",i.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",i.FRAG_LOAD_ERROR="fragLoadError",i.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",i.FRAG_DECRYPT_ERROR="fragDecryptError",i.FRAG_PARSING_ERROR="fragParsingError",i.FRAG_GAP="fragGap",i.REMUX_ALLOC_ERROR="remuxAllocError",i.KEY_LOAD_ERROR="keyLoadError",i.KEY_LOAD_TIMEOUT="keyLoadTimeOut",i.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",i.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",i.BUFFER_APPEND_ERROR="bufferAppendError",i.BUFFER_APPENDING_ERROR="bufferAppendingError",i.BUFFER_STALLED_ERROR="bufferStalledError",i.BUFFER_FULL_ERROR="bufferFullError",i.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",i.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",i.INTERNAL_EXCEPTION="internalException",i.INTERNAL_ABORTED="aborted",i.UNKNOWN="unknown",i}({});const Os=function(){},Yu={trace:Os,debug:Os,log:Os,warn:Os,info:Os,error:Os};let Oa=Yu;function $A(i){const e=self.console[i];return e?e.bind(self.console,`[${i}] >`):Os}function BA(i,...e){e.forEach(function(t){Oa[t]=i[t]?i[t].bind(i):$A(t)})}function GA(i,e){if(typeof console=="object"&&i===!0||typeof i=="object"){BA(i,"debug","log","info","warn","error");try{Oa.log(`Debug logs enabled for "${e}" in hls.js version 1.5.11`)}catch{Oa=Yu}}else Oa=Yu}const R=Oa,HA=/^(\d+)x(\d+)$/,Gp=/(.+?)=(".*?"|.*?)(?:,|$)/g;class Oe{constructor(e){typeof e=="string"&&(e=Oe.parseAttrList(e)),Ke(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 r=0;r<t.length/2;r++)s[r]=parseInt(t.slice(r*2,r*2+2),16);return s}else 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]}bool(e){return this[e]==="YES"}decimalResolution(e){const t=HA.exec(this[e]);if(t!==null)return{width:parseInt(t[1],10),height:parseInt(t[2],10)}}static parseAttrList(e){let t;const s={},r='"';for(Gp.lastIndex=0;(t=Gp.exec(e))!==null;){let n=t[2];n.indexOf(r)===0&&n.lastIndexOf(r)===n.length-1&&(n=n.slice(1,-1));const a=t[1].trim();s[a]=n}return s}}function WA(i){return i!=="ID"&&i!=="CLASS"&&i!=="START-DATE"&&i!=="DURATION"&&i!=="END-DATE"&&i!=="END-ON-NEXT"}function KA(i){return i==="SCTE35-OUT"||i==="SCTE35-IN"}class Lv{constructor(e,t){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,t){const s=t.attr;for(const r in s)if(Object.prototype.hasOwnProperty.call(e,r)&&e[r]!==s[r]){R.warn(`DATERANGE tag attribute: "${r}" does not match for tags with ID: "${e.ID}"`),this._badValueForSameId=r;break}e=Ke(new Oe({}),s,e)}if(this.attr=e,this._startDate=new Date(e["START-DATE"]),"END-DATE"in this.attr){const s=new Date(this.attr["END-DATE"]);j(s.getTime())&&(this._endDate=s)}}get id(){return this.attr.ID}get class(){return this.attr.CLASS}get startDate(){return this._startDate}get endDate(){if(this._endDate)return this._endDate;const e=this.duration;return e!==null?new Date(this._startDate.getTime()+e*1e3):null}get duration(){if("DURATION"in this.attr){const e=this.attr.decimalFloatingPoint("DURATION");if(j(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 isValid(){return!!this.id&&!this._badValueForSameId&&j(this.startDate.getTime())&&(this.duration===null||this.duration>=0)&&(!this.endOnNext||!!this.class)}}class kc{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 be={AUDIO:"audio",VIDEO:"video",AUDIOVIDEO:"audiovideo"};class Iv{constructor(e){this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams={[be.AUDIO]:null,[be.VIDEO]:null,[be.AUDIOVIDEO]:null},this.baseurl=e}setByteRange(e,t){const s=e.split("@",2);let r;s.length===1?r=(t==null?void 0:t.byteRangeEndOffset)||0:r=parseInt(s[1]),this._byteRange=[r,parseInt(s[0])+r]}get byteRange(){return this._byteRange?this._byteRange:[]}get byteRangeStartOffset(){return this.byteRange[0]}get byteRangeEndOffset(){return this.byteRange[1]}get url(){return!this._url&&this.baseurl&&this.relurl&&(this._url=dm.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""}set url(e){this._url=e}}class Yc extends Iv{constructor(e,t){super(t),this._decryptdata=null,this.rawProgramDateTime=null,this.programDateTime=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.deltaPTS=void 0,this.maxStartPTS=void 0,this.minEndPTS=void 0,this.stats=new kc,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 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)return this._decryptdata=this.levelkeys[s[0]].getDecryptData(this.sn)}}return this._decryptdata}get end(){return this.start+this.duration}get endProgramDateTime(){if(this.programDateTime===null||!j(this.programDateTime))return null;const e=j(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){const t=Object.keys(this.levelkeys),s=t.length;if(s>1||s===1&&this.levelkeys[t[0]].encrypted)return!0}return!1}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,r,n,a=!1){const{elementaryStreams:o}=this,l=o[e];if(!l){o[e]={startPTS:t,endPTS:s,startDTS:r,endDTS:n,partial:a};return}l.startPTS=Math.min(l.startPTS,t),l.endPTS=Math.max(l.endPTS,s),l.startDTS=Math.min(l.startDTS,r),l.endDTS=Math.max(l.endDTS,n)}clearElementaryStreamInfo(){const{elementaryStreams:e}=this;e[be.AUDIO]=null,e[be.VIDEO]=null,e[be.AUDIOVIDEO]=null}}let VA=class extends Iv{constructor(e,t,s,r,n){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.stats=new kc,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=r;const a=e.enumeratedString("BYTERANGE");a&&this.setByteRange(a,n),n&&(this.fragOffset=n.fragOffset+n.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)}};const qA=10;class YA{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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 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.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,this.availabilityDelay=e.availabilityDelay}get hasProgramDateTime(){return this.fragments.length?j(this.fragments[this.fragments.length-1].programDateTime):!1}get levelTargetDuration(){return this.averagetargetduration||this.targetduration||qA}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(){var e;return(e=this.fragments)!=null&&e.length?this.fragments[this.fragments.length-1].end: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 lastPartSn(){var e;return(e=this.partList)!=null&&e.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}function cm(i){return Uint8Array.from(atob(i),e=>e.charCodeAt(0))}function jA(i){const e=ju(i).subarray(0,16),t=new Uint8Array(16);return t.set(e,16-e.length),t}function zA(i){const e=function(s,r,n){const a=s[r];s[r]=s[n],s[n]=a};e(i,0,3),e(i,1,2),e(i,4,5),e(i,6,7)}function XA(i){const e=i.split(":");let t=null;if(e[0]==="data"&&e.length===2){const s=e[1].split(";"),r=s[s.length-1].split(",");if(r.length===2){const n=r[0]==="base64",a=r[1];n?(s.splice(-1,1),t=cm(a)):t=jA(a)}}return t}function ju(i){return Uint8Array.from(unescape(encodeURIComponent(i)),e=>e.charCodeAt(0))}const Rn=typeof self<"u"?self:void 0;var we={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},wt={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.streamingkeydelivery",PLAYREADY:"com.microsoft.playready",WIDEVINE:"urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed"};function Hp(i){switch(i){case wt.FAIRPLAY:return we.FAIRPLAY;case wt.PLAYREADY:return we.PLAYREADY;case wt.WIDEVINE:return we.WIDEVINE;case wt.CLEARKEY:return we.CLEARKEY}}var Rv={WIDEVINE:"edef8ba979d64acea3c827dcd51d21ed"};function QA(i){if(i===Rv.WIDEVINE)return we.WIDEVINE}function Wp(i){switch(i){case we.FAIRPLAY:return wt.FAIRPLAY;case we.PLAYREADY:return wt.PLAYREADY;case we.WIDEVINE:return wt.WIDEVINE;case we.CLEARKEY:return wt.CLEARKEY}}function jc(i){const{drmSystems:e,widevineLicenseUrl:t}=i,s=e?[we.FAIRPLAY,we.WIDEVINE,we.PLAYREADY,we.CLEARKEY].filter(r=>!!e[r]):[];return!s[we.WIDEVINE]&&t&&s.push(we.WIDEVINE),s}const wv=function(i){return Rn!=null&&(i=Rn.navigator)!=null&&i.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null}();function ZA(i,e,t,s){let r;switch(i){case we.FAIRPLAY:r=["cenc","sinf"];break;case we.WIDEVINE:case we.PLAYREADY:r=["cenc"];break;case we.CLEARKEY:r=["cenc","keyids"];break;default:throw new Error(`Unknown key-system: ${i}`)}return JA(r,e,t,s)}function JA(i,e,t,s){return[{initDataTypes:i,persistentState:s.persistentState||"optional",distinctiveIdentifier:s.distinctiveIdentifier||"optional",sessionTypes:s.sessionTypes||[s.sessionType||"temporary"],audioCapabilities:e.map(n=>({contentType:`audio/mp4; codecs="${n}"`,robustness:s.audioRobustness||"",encryptionScheme:s.audioEncryptionScheme||null})),videoCapabilities:t.map(n=>({contentType:`video/mp4; codecs="${n}"`,robustness:s.videoRobustness||"",encryptionScheme:s.videoEncryptionScheme||null}))}]}function ur(i,e,t){return Uint8Array.prototype.slice?i.slice(e,t):new Uint8Array(Array.prototype.slice.call(i,e,t))}const um=(i,e)=>e+10<=i.length&&i[e]===73&&i[e+1]===68&&i[e+2]===51&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Cv=(i,e)=>e+10<=i.length&&i[e]===51&&i[e+1]===68&&i[e+2]===73&&i[e+3]<255&&i[e+4]<255&&i[e+6]<128&&i[e+7]<128&&i[e+8]<128&&i[e+9]<128,Ya=(i,e)=>{const t=e;let s=0;for(;um(i,e);){s+=10;const r=Lc(i,e+6);s+=r,Cv(i,e+10)&&(s+=10),e+=s}if(s>0)return i.subarray(t,t+s)},Lc=(i,e)=>{let t=0;return t=(i[e]&127)<<21,t|=(i[e+1]&127)<<14,t|=(i[e+2]&127)<<7,t|=i[e+3]&127,t},eS=(i,e)=>um(i,e)&&Lc(i,e+6)+10<=i.length-e,hm=i=>{const e=Mv(i);for(let t=0;t<e.length;t++){const s=e[t];if(Dv(s))return aS(s)}},Dv=i=>i&&i.key==="PRIV"&&i.info==="com.apple.streaming.transportStreamTimestamp",tS=i=>{const e=String.fromCharCode(i[0],i[1],i[2],i[3]),t=Lc(i,4),s=10;return{type:e,size:t,data:i.subarray(s,s+t)}},Mv=i=>{let e=0;const t=[];for(;um(i,e);){const s=Lc(i,e+6);e+=10;const r=e+s;for(;e+8<r;){const n=tS(i.subarray(e)),a=iS(n);a&&t.push(a),e+=n.size+10}Cv(i,e)&&(e+=10)}return t},iS=i=>i.type==="PRIV"?sS(i):i.type[0]==="W"?nS(i):rS(i),sS=i=>{if(i.size<2)return;const e=Oi(i.data,!0),t=new Uint8Array(i.data.subarray(e.length+1));return{key:i.type,info:e,data:t.buffer}},rS=i=>{if(i.size<2)return;if(i.type==="TXXX"){let t=1;const s=Oi(i.data.subarray(t),!0);t+=s.length+1;const r=Oi(i.data.subarray(t));return{key:i.type,info:s,data:r}}const e=Oi(i.data.subarray(1));return{key:i.type,data:e}},nS=i=>{if(i.type==="WXXX"){if(i.size<2)return;let t=1;const s=Oi(i.data.subarray(t),!0);t+=s.length+1;const r=Oi(i.data.subarray(t));return{key:i.type,info:s,data:r}}const e=Oi(i.data);return{key:i.type,data:e}},aS=i=>{if(i.data.byteLength===8){const e=new Uint8Array(i.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)}},Oi=(i,e=!1)=>{const t=oS();if(t){const d=t.decode(i);if(e){const c=d.indexOf("\0");return c!==-1?d.substring(0,c):d}return d.replace(/\0/g,"")}const s=i.length;let r,n,a,o="",l=0;for(;l<s;){if(r=i[l++],r===0&&e)return o;if(r===0||r===3)continue;switch(r>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:o+=String.fromCharCode(r);break;case 12:case 13:n=i[l++],o+=String.fromCharCode((r&31)<<6|n&63);break;case 14:n=i[l++],a=i[l++],o+=String.fromCharCode((r&15)<<12|(n&63)<<6|(a&63)<<0);break}}return o};let zc;function oS(){if(!navigator.userAgent.includes("PlayStation 4"))return!zc&&typeof self.TextDecoder<"u"&&(zc=new self.TextDecoder("utf-8")),zc}const Si={hexDump:function(i){let e="";for(let t=0;t<i.length;t++){let s=i[t].toString(16);s.length<2&&(s="0"+s),e+=s}return e}},Ud=Math.pow(2,32)-1,lS=[].push,Ov={video:1,audio:2,id3:3,text:4};function je(i){return String.fromCharCode.apply(null,i)}function Pv(i,e){const t=i[e]<<8|i[e+1];return t<0?65536+t:t}function ee(i,e){const t=Nv(i,e);return t<0?4294967296+t:t}function Kp(i,e){let t=ee(i,e);return t*=Math.pow(2,32),t+=ee(i,e+4),t}function Nv(i,e){return i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}function Xc(i,e,t){i[e]=t>>24,i[e+1]=t>>16&255,i[e+2]=t>>8&255,i[e+3]=t&255}function dS(i){const e=i.byteLength;for(let t=0;t<e;){const s=ee(i,t);if(s>8&&i[t+4]===109&&i[t+5]===111&&i[t+6]===111&&i[t+7]===102)return!0;t=s>1?t+s:e}return!1}function le(i,e){const t=[];if(!e.length)return t;const s=i.byteLength;for(let r=0;r<s;){const n=ee(i,r),a=je(i.subarray(r+4,r+8)),o=n>1?r+n:s;if(a===e[0])if(e.length===1)t.push(i.subarray(r+8,o));else{const l=le(i.subarray(r+8,o),e.slice(1));l.length&&lS.apply(t,l)}r=o}return t}function cS(i){const e=[],t=i[0];let s=8;const r=ee(i,s);s+=4;let n=0,a=0;t===0?(n=ee(i,s),a=ee(i,s+4),s+=8):(n=Kp(i,s),a=Kp(i,s+8),s+=16),s+=2;let o=i.length+a;const l=Pv(i,s);s+=2;for(let d=0;d<l;d++){let c=s;const u=ee(i,c);c+=4;const h=u&2147483647;if((u&2147483648)>>>31===1)return R.warn("SIDX has hierarchical references (not supported)"),null;const m=ee(i,c);c+=4,e.push({referenceSize:h,subsegmentDuration:m,info:{duration:m/r,start:o,end:o+h-1}}),o+=h,c+=4,s=c}return{earliestPresentationTime:n,timescale:r,version:t,referencesCount:l,references:e}}function Uv(i){const e=[],t=le(i,["moov","trak"]);for(let r=0;r<t.length;r++){const n=t[r],a=le(n,["tkhd"])[0];if(a){let o=a[0];const l=ee(a,o===0?12:20),d=le(n,["mdia","mdhd"])[0];if(d){o=d[0];const c=ee(d,o===0?12:20),u=le(n,["mdia","hdlr"])[0];if(u){const h=je(u.subarray(8,12)),f={soun:be.AUDIO,vide:be.VIDEO}[h];if(f){const m=le(n,["mdia","minf","stbl","stsd"])[0],p=uS(m);e[l]={timescale:c,type:f},e[f]=dt({timescale:c,id:l},p)}}}}}return le(i,["moov","mvex","trex"]).forEach(r=>{const n=ee(r,4),a=e[n];a&&(a.default={duration:ee(r,12),flags:ee(r,20)})}),e}function uS(i){const e=i.subarray(8),t=e.subarray(86),s=je(e.subarray(4,8));let r=s;const n=s==="enca"||s==="encv";if(n){const o=le(e,[s])[0].subarray(s==="enca"?28:78);le(o,["sinf"]).forEach(d=>{const c=le(d,["schm"])[0];if(c){const u=je(c.subarray(4,8));if(u==="cbcs"||u==="cenc"){const h=le(d,["frma"])[0];h&&(r=je(h))}}})}switch(r){case"avc1":case"avc2":case"avc3":case"avc4":{const a=le(t,["avcC"])[0];r+="."+bo(a[1])+bo(a[2])+bo(a[3]);break}case"mp4a":{const a=le(e,[s])[0],o=le(a.subarray(28),["esds"])[0];if(o&&o.length>12){let l=4;if(o[l++]!==3)break;l=Qc(o,l),l+=2;const d=o[l++];if(d&128&&(l+=2),d&64&&(l+=o[l++]),o[l++]!==4)break;l=Qc(o,l);const c=o[l++];if(c===64)r+="."+bo(c);else break;if(l+=12,o[l++]!==5)break;l=Qc(o,l);const u=o[l++];let h=(u&248)>>3;h===31&&(h+=1+((u&7)<<3)+((o[l]&224)>>5)),r+="."+h}break}case"hvc1":case"hev1":{const a=le(t,["hvcC"])[0],o=a[1],l=["","A","B","C"][o>>6],d=o&31,c=ee(a,2),u=(o&32)>>5?"H":"L",h=a[12],f=a.subarray(6,12);r+="."+l+d,r+="."+c.toString(16).toUpperCase(),r+="."+u+h;let m="";for(let p=f.length;p--;){const g=f[p];(g||m)&&(m="."+g.toString(16).toUpperCase()+m)}r+=m;break}case"dvh1":case"dvhe":{const a=le(t,["dvcC"])[0],o=a[2]>>1&127,l=a[2]<<5&32|a[3]>>3&31;r+="."+li(o)+"."+li(l);break}case"vp09":{const a=le(t,["vpcC"])[0],o=a[4],l=a[5],d=a[6]>>4&15;r+="."+li(o)+"."+li(l)+"."+li(d);break}case"av01":{const a=le(t,["av1C"])[0],o=a[1]>>>5,l=a[1]&31,d=a[2]>>>7?"H":"M",c=(a[2]&64)>>6,u=(a[2]&32)>>5,h=o===2&&c?u?12:10:c?10:8,f=(a[2]&16)>>4,m=(a[2]&8)>>3,p=(a[2]&4)>>2,g=a[2]&3;r+="."+o+"."+li(l)+d+"."+li(h)+"."+f+"."+m+p+g+"."+li(1)+"."+li(1)+"."+li(1)+"."+0;break}}return{codec:r,encrypted:n}}function Qc(i,e){const t=e+5;for(;i[e++]&128&&e<t;);return e}function bo(i){return("0"+i.toString(16).toUpperCase()).slice(-2)}function li(i){return(i<10?"0":"")+i}function hS(i,e){if(!i||!e)return i;const t=e.keyId;return t&&e.isCommonEncryption&&le(i,["moov","trak"]).forEach(r=>{const a=le(r,["mdia","minf","stbl","stsd"])[0].subarray(8);let o=le(a,["enca"]);const l=o.length>0;l||(o=le(a,["encv"])),o.forEach(d=>{const c=l?d.subarray(28):d.subarray(78);le(c,["sinf"]).forEach(h=>{const f=Fv(h);if(f){const m=f.subarray(8,24);m.some(p=>p!==0)||(R.log(`[eme] Patching keyId in 'enc${l?"a":"v"}>sinf>>tenc' box: ${Si.hexDump(m)} -> ${Si.hexDump(t)}`),f.set(t,8))}})})}),i}function Fv(i){const e=le(i,["schm"])[0];if(e){const t=je(e.subarray(4,8));if(t==="cbcs"||t==="cenc")return le(i,["schi","tenc"])[0]}return R.error("[eme] missing 'schm' box"),null}function fS(i,e){return le(e,["moof","traf"]).reduce((t,s)=>{const r=le(s,["tfdt"])[0],n=r[0],a=le(s,["tfhd"]).reduce((o,l)=>{const d=ee(l,4),c=i[d];if(c){let u=ee(r,4);if(n===1){if(u===Ud)return R.warn("[mp4-demuxer]: Ignoring assumed invalid signed 64-bit track fragment decode time"),o;u*=Ud+1,u+=ee(r,8)}const h=c.timescale||9e4,f=u/h;if(j(f)&&(o===null||f<o))return f}return o},null);return a!==null&&j(a)&&(t===null||a<t)?a:t},null)}function mS(i,e){let t=0,s=0,r=0;const n=le(i,["moof","traf"]);for(let a=0;a<n.length;a++){const o=n[a],l=le(o,["tfhd"])[0],d=ee(l,4),c=e[d];if(!c)continue;const u=c.default,h=ee(l,0)|(u==null?void 0:u.flags);let f=u==null?void 0:u.duration;h&8&&(h&2?f=ee(l,12):f=ee(l,8));const m=c.timescale||9e4,p=le(o,["trun"]);for(let g=0;g<p.length;g++){if(t=pS(p[g]),!t&&f){const v=ee(p[g],4);t=f*v}c.type===be.VIDEO?s+=t/m:c.type===be.AUDIO&&(r+=t/m)}}if(s===0&&r===0){let a=1/0,o=0,l=0;const d=le(i,["sidx"]);for(let c=0;c<d.length;c++){const u=cS(d[c]);if(u!=null&&u.references){a=Math.min(a,u.earliestPresentationTime/u.timescale);const h=u.references.reduce((f,m)=>f+m.info.duration||0,0);o=Math.max(o,h+u.earliestPresentationTime/u.timescale),l=o-a}}if(l&&j(l))return l}return s||r}function pS(i){const e=ee(i,0);let t=8;e&1&&(t+=4),e&4&&(t+=4);let s=0;const r=ee(i,4);for(let n=0;n<r;n++){if(e&256){const a=ee(i,t);s+=a,t+=4}e&512&&(t+=4),e&1024&&(t+=4),e&2048&&(t+=4)}return s}function gS(i,e,t){le(e,["moof","traf"]).forEach(s=>{le(s,["tfhd"]).forEach(r=>{const n=ee(r,4),a=i[n];if(!a)return;const o=a.timescale||9e4;le(s,["tfdt"]).forEach(l=>{const d=l[0],c=t*o;if(c){let u=ee(l,4);if(d===0)u-=c,u=Math.max(u,0),Xc(l,4,u);else{u*=Math.pow(2,32),u+=ee(l,8),u-=c,u=Math.max(u,0);const h=Math.floor(u/(Ud+1)),f=Math.floor(u%(Ud+1));Xc(l,4,h),Xc(l,8,f)}}})})})}function vS(i){const e={valid:null,remainder:null},t=le(i,["moof"]);if(t.length<2)return e.remainder=i,e;const s=t[t.length-1];return e.valid=ur(i,0,s.byteOffset-8),e.remainder=ur(i,s.byteOffset-8),e}function Vt(i,e){const t=new Uint8Array(i.length+e.length);return t.set(i),t.set(e,i.length),t}function Vp(i,e){const t=[],s=e.samples,r=e.timescale,n=e.id;let a=!1;return le(s,["moof"]).map(l=>{const d=l.byteOffset-8;le(l,["traf"]).map(u=>{const h=le(u,["tfdt"]).map(f=>{const m=f[0];let p=ee(f,4);return m===1&&(p*=Math.pow(2,32),p+=ee(f,8)),p/r})[0];return h!==void 0&&(i=h),le(u,["tfhd"]).map(f=>{const m=ee(f,4),p=ee(f,0)&16777215,g=(p&1)!==0,v=(p&2)!==0,y=(p&8)!==0;let b=0;const x=(p&16)!==0;let _=0;const S=(p&32)!==0;let A=8;m===n&&(g&&(A+=8),v&&(A+=4),y&&(b=ee(f,A),A+=4),x&&(_=ee(f,A),A+=4),S&&(A+=4),e.type==="video"&&(a=ES(e.codec)),le(u,["trun"]).map(D=>{const O=D[0],L=ee(D,0)&16777215,C=(L&1)!==0;let H=0;const U=(L&4)!==0,Q=(L&256)!==0;let q=0;const Y=(L&512)!==0;let oe=0;const ae=(L&1024)!==0,G=(L&2048)!==0;let F=0;const re=ee(D,4);let J=8;C&&(H=ee(D,J),J+=4),U&&(J+=4);let de=H+d;for(let Ae=0;Ae<re;Ae++){if(Q?(q=ee(D,J),J+=4):q=b,Y?(oe=ee(D,J),J+=4):oe=_,ae&&(J+=4),G&&(O===0?F=ee(D,J):F=Nv(D,J),J+=4),e.type===be.VIDEO){let Ce=0;for(;Ce<oe;){const He=ee(s,de);if(de+=4,bS(a,s[de])){const St=s.subarray(de,de+He);$v(St,a?2:1,i+F/r,t)}de+=He,Ce+=He+4}}i+=q/r}}))})})}),t}function ES(i){if(!i)return!1;const e=i.indexOf("."),t=e<0?i:i.substring(0,e);return t==="hvc1"||t==="hev1"||t==="dvh1"||t==="dvhe"}function bS(i,e){if(i){const t=e>>1&63;return t===39||t===40}else return(e&31)===6}function $v(i,e,t,s){const r=Bv(i);let n=0;n+=e;let a=0,o=0,l=0;for(;n<r.length;){a=0;do{if(n>=r.length)break;l=r[n++],a+=l}while(l===255);o=0;do{if(n>=r.length)break;l=r[n++],o+=l}while(l===255);const d=r.length-n;let c=n;if(o<d)n+=o;else if(o>d){R.error(`Malformed SEI payload. ${o} is too small, only ${d} bytes left to parse.`);break}if(a===4){if(r[c++]===181){const h=Pv(r,c);if(c+=2,h===49){const f=ee(r,c);if(c+=4,f===1195456820){const m=r[c++];if(m===3){const p=r[c++],g=31&p,v=64&p,y=v?2+g*3:0,b=new Uint8Array(y);if(v){b[0]=p;for(let x=1;x<y;x++)b[x]=r[c++]}s.push({type:m,payloadType:a,pts:t,bytes:b})}}}}}else if(a===5&&o>16){const u=[];for(let m=0;m<16;m++){const p=r[c++].toString(16);u.push(p.length==1?"0"+p:p),(m===3||m===5||m===7||m===9)&&u.push("-")}const h=o-16,f=new Uint8Array(h);for(let m=0;m<h;m++)f[m]=r[c++];s.push({payloadType:a,pts:t,uuid:u.join(""),userData:Oi(f),userDataBytes:f})}}}function Bv(i){const e=i.byteLength,t=[];let s=1;for(;s<e-2;)i[s]===0&&i[s+1]===0&&i[s+2]===3?(t.push(s+2),s+=2):s++;if(t.length===0)return i;const r=e-t.length,n=new Uint8Array(r);let a=0;for(s=0;s<r;a++,s++)a===t[0]&&(a++,t.shift()),n[s]=i[a];return n}function yS(i){const e=i[0];let t="",s="",r=0,n=0,a=0,o=0,l=0,d=0;if(e===0){for(;je(i.subarray(d,d+1))!=="\0";)t+=je(i.subarray(d,d+1)),d+=1;for(t+=je(i.subarray(d,d+1)),d+=1;je(i.subarray(d,d+1))!=="\0";)s+=je(i.subarray(d,d+1)),d+=1;s+=je(i.subarray(d,d+1)),d+=1,r=ee(i,12),n=ee(i,16),o=ee(i,20),l=ee(i,24),d=28}else if(e===1){d+=4,r=ee(i,d),d+=4;const u=ee(i,d);d+=4;const h=ee(i,d);for(d+=4,a=2**32*u+h,UA(a)||(a=Number.MAX_SAFE_INTEGER,R.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=ee(i,d),d+=4,l=ee(i,d),d+=4;je(i.subarray(d,d+1))!=="\0";)t+=je(i.subarray(d,d+1)),d+=1;for(t+=je(i.subarray(d,d+1)),d+=1;je(i.subarray(d,d+1))!=="\0";)s+=je(i.subarray(d,d+1)),d+=1;s+=je(i.subarray(d,d+1)),d+=1}const c=i.subarray(d,i.byteLength);return{schemeIdUri:t,value:s,timeScale:r,presentationTime:a,presentationTimeDelta:n,eventDuration:o,id:l,payload:c}}function TS(i,...e){const t=e.length;let s=8,r=t;for(;r--;)s+=e[r].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(i,4),r=0,s=8;r<t;r++)n.set(e[r],s),s+=e[r].byteLength;return n}function _S(i,e,t){if(i.byteLength!==16)throw new RangeError("Invalid system id");let s,r;s=0,r=new Uint8Array;let n;s>0?(n=new Uint8Array(4),e.length>0&&new DataView(n.buffer).setUint32(0,e.length,!1)):n=new Uint8Array;const a=new Uint8Array(4);return t&&t.byteLength>0&&new DataView(a.buffer).setUint32(0,t.byteLength,!1),TS([112,115,115,104],new Uint8Array([s,0,0,0]),i,n,r,a,t||new Uint8Array)}function AS(i){if(!(i instanceof ArrayBuffer)||i.byteLength<32)return null;const e={version:0,systemId:"",kids:null,data:null},t=new DataView(i),s=t.getUint32(0);if(i.byteLength!==s&&s>44||t.getUint32(4)!==1886614376||(e.version=t.getUint32(8)>>>24,e.version>1))return null;e.systemId=Si.hexDump(new Uint8Array(i,12,16));const n=t.getUint32(28);if(e.version===0){if(s-32<n)return null;e.data=new Uint8Array(i,32,n)}else if(e.version===1){e.kids=[];for(let a=0;a<n;a++)e.kids.push(new Uint8Array(i,32+a*16,16))}return e}let yo={};class ja{static clearKeyUriToKeyIdMap(){yo={}}constructor(e,t,s,r=[1],n=null){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=r,this.iv=n,this.encrypted=e?e!=="NONE":!1,this.isCommonEncryption=this.encrypted&&e!=="AES-128"}isSupported(){if(this.method){if(this.method==="AES-128"||this.method==="NONE")return!0;if(this.keyFormat==="identity")return this.method==="SAMPLE-AES";switch(this.keyFormat){case wt.FAIRPLAY:case wt.WIDEVINE:case wt.PLAYREADY:case wt.CLEARKEY:return["ISO-23001-7","SAMPLE-AES","SAMPLE-AES-CENC","SAMPLE-AES-CTR"].indexOf(this.method)!==-1}}return!1}getDecryptData(e){if(!this.encrypted||!this.uri)return null;if(this.method==="AES-128"&&this.uri&&!this.iv){typeof e!="number"&&(this.method==="AES-128"&&!this.iv&&R.warn(`missing IV for initialization segment with method="${this.method}" - compliance issue`),e=0);const s=SS(e);return new ja(this.method,this.uri,"identity",this.keyFormatVersions,s)}const t=XA(this.uri);if(t)switch(this.keyFormat){case wt.WIDEVINE:this.pssh=t,t.length>=22&&(this.keyId=t.subarray(t.length-22,t.length-6));break;case wt.PLAYREADY:{const s=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=_S(s,null,t);const r=new Uint16Array(t.buffer,t.byteOffset,t.byteLength/2),n=String.fromCharCode.apply(null,Array.from(r)),a=n.substring(n.indexOf("<"),n.length),d=new DOMParser().parseFromString(a,"text/xml").getElementsByTagName("KID")[0];if(d){const c=d.childNodes[0]?d.childNodes[0].nodeValue:d.getAttribute("VALUE");if(c){const u=cm(c).subarray(0,16);zA(u),this.keyId=u}}break}default:{let s=t.subarray(0,16);if(s.length!==16){const r=new Uint8Array(16);r.set(s,16-s.length),s=r}this.keyId=s;break}}if(!this.keyId||this.keyId.byteLength!==16){let s=yo[this.uri];if(!s){const r=Object.keys(yo).length%Number.MAX_SAFE_INTEGER;s=new Uint8Array(16),new DataView(s.buffer,12,4).setUint32(0,r),yo[this.uri]=s}this.keyId=s}return this}}function SS(i){const e=new Uint8Array(16);for(let t=12;t<16;t++)e[t]=i>>8*(15-t)&255;return e}const Gv=/\{\$([a-zA-Z0-9-_]+)\}/g;function qp(i){return Gv.test(i)}function Lt(i,e,t){if(i.variableList!==null||i.hasVariableRefs)for(let s=t.length;s--;){const r=t[s],n=e[r];n&&(e[r]=zu(i,n))}}function zu(i,e){if(i.variableList!==null||i.hasVariableRefs){const t=i.variableList;return e.replace(Gv,s=>{const r=s.substring(2,s.length-1),n=t==null?void 0:t[r];return n===void 0?(i.playlistParsingError||(i.playlistParsingError=new Error(`Missing preceding EXT-X-DEFINE tag for Variable Reference: "${r}"`)),s):n})}return e}function Yp(i,e,t){let s=i.variableList;s||(i.variableList=s={});let r,n;if("QUERYPARAM"in e){r=e.QUERYPARAM;try{const a=new self.URL(t).searchParams;if(a.has(r))n=a.get(r);else throw new Error(`"${r}" does not match any query parameter in URI: "${t}"`)}catch(a){i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE QUERYPARAM: ${a.message}`))}}else r=e.NAME,n=e.VALUE;r in s?i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE duplicate Variable Name declarations: "${r}"`)):s[r]=n||""}function xS(i,e,t){const s=e.IMPORT;if(t&&s in t){let r=i.variableList;r||(i.variableList=r={}),r[s]=t[s]}else i.playlistParsingError||(i.playlistParsingError=new Error(`EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "${s}"`))}function _r(i=!0){return typeof self>"u"?void 0:(i||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}function kS(i){return typeof self<"u"&&i===self.ManagedMediaSource}const Fd={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,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 LS(i,e){const t=Fd[e];return!!t&&!!t[i.slice(0,4)]}function Zc(i,e,t=!0){return!i.split(",").some(s=>!Hv(s,e,t))}function Hv(i,e,t=!0){var s;const r=_r(t);return(s=r==null?void 0:r.isTypeSupported(za(i,e)))!=null?s:!1}function za(i,e){return`${e}/mp4;codecs="${i}"`}function jp(i){if(i){const e=i.substring(0,4);return Fd.video[e]}return 2}function $d(i){return i.split(",").reduce((e,t)=>{const s=Fd.video[t];return s?(s*2+e)/(e?3:2):(Fd.audio[t]+e)/(e?2:1)},0)}const Jc={};function IS(i,e=!0){if(Jc[i])return Jc[i];const t={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[i];for(let s=0;s<t.length;s++)if(Hv(t[s],"audio",e))return Jc[i]=t[s],t[s];return i}const RS=/flac|opus/i;function Bd(i,e=!0){return i.replace(RS,t=>IS(t.toLowerCase(),e))}function zp(i,e){return i&&i!=="mp4a"?i:e&&e.split(",")[0]}function wS(i){const e=i.split(".");if(e.length>2){let t=e.shift()+".";return t+=parseInt(e.shift()).toString(16),t+=("000"+parseInt(e.shift()).toString(16)).slice(-4),t}return i}const Xp=/#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,Qp=/#EXT-X-MEDIA:(.*)/g,CS=/^#EXT(?:INF|-X-TARGETDURATION):/m,Zp=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[^\r\n]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),DS=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(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 Ri{static findGroup(e,t){for(let s=0;s<e.length;s++){const r=e[s];if(r.id===t)return r}}static resolve(e,t){return dm.buildAbsoluteURL(t,e,{alwaysNormalize:!0})}static isMediaPlaylist(e){return CS.test(e)}static parseMasterPlaylist(e,t){const s=qp(e),r={contentSteering:null,levels:[],playlistParsingError:null,sessionData:null,sessionKeys:null,startTimeOffset:null,variableList:null,hasVariableRefs:s},n=[];Xp.lastIndex=0;let a;for(;(a=Xp.exec(e))!=null;)if(a[1]){var o;const d=new Oe(a[1]);Lt(r,d,["CODECS","SUPPLEMENTAL-CODECS","ALLOWED-CPC","PATHWAY-ID","STABLE-VARIANT-ID","AUDIO","VIDEO","SUBTITLES","CLOSED-CAPTIONS","NAME"]);const c=zu(r,a[2]),u={attrs:d,bitrate:d.decimalInteger("BANDWIDTH")||d.decimalInteger("AVERAGE-BANDWIDTH"),name:d.NAME,url:Ri.resolve(c,t)},h=d.decimalResolution("RESOLUTION");h&&(u.width=h.width,u.height=h.height),MS(d.CODECS,u),(o=u.unknownCodecs)!=null&&o.length||n.push(u),r.levels.push(u)}else if(a[3]){const d=a[3],c=a[4];switch(d){case"SESSION-DATA":{const u=new Oe(c);Lt(r,u,["DATA-ID","LANGUAGE","VALUE","URI"]);const h=u["DATA-ID"];h&&(r.sessionData===null&&(r.sessionData={}),r.sessionData[h]=u);break}case"SESSION-KEY":{const u=Jp(c,t,r);u.encrypted&&u.isSupported()?(r.sessionKeys===null&&(r.sessionKeys=[]),r.sessionKeys.push(u)):R.warn(`[Keys] Ignoring invalid EXT-X-SESSION-KEY tag: "${c}"`);break}case"DEFINE":{{const u=new Oe(c);Lt(r,u,["NAME","VALUE","QUERYPARAM"]),Yp(r,u,t)}break}case"CONTENT-STEERING":{const u=new Oe(c);Lt(r,u,["SERVER-URI","PATHWAY-ID"]),r.contentSteering={uri:Ri.resolve(u["SERVER-URI"],t),pathwayId:u["PATHWAY-ID"]||"."};break}case"START":{r.startTimeOffset=e0(c);break}}}const l=n.length>0&&n.length<r.levels.length;return r.levels=l?n:r.levels,r.levels.length===0&&(r.playlistParsingError=new Error("no levels found in manifest")),r}static parseMasterPlaylistMedia(e,t,s){let r;const n={},a=s.levels,o={AUDIO:a.map(d=>({id:d.attrs.AUDIO,audioCodec:d.audioCodec})),SUBTITLES:a.map(d=>({id:d.attrs.SUBTITLES,textCodec:d.textCodec})),"CLOSED-CAPTIONS":[]};let l=0;for(Qp.lastIndex=0;(r=Qp.exec(e))!==null;){const d=new Oe(r[1]),c=d.TYPE;if(c){const u=o[c],h=n[c]||[];n[c]=h,Lt(s,d,["URI","GROUP-ID","LANGUAGE","ASSOC-LANGUAGE","STABLE-RENDITION-ID","NAME","INSTREAM-ID","CHARACTERISTICS","CHANNELS"]);const f=d.LANGUAGE,m=d["ASSOC-LANGUAGE"],p=d.CHANNELS,g=d.CHARACTERISTICS,v=d["INSTREAM-ID"],y={attrs:d,bitrate:0,id:l++,groupId:d["GROUP-ID"]||"",name:d.NAME||f||"",type:c,default:d.bool("DEFAULT"),autoselect:d.bool("AUTOSELECT"),forced:d.bool("FORCED"),lang:f,url:d.URI?Ri.resolve(d.URI,t):""};if(m&&(y.assocLang=m),p&&(y.channels=p),g&&(y.characteristics=g),v&&(y.instreamId=v),u!=null&&u.length){const b=Ri.findGroup(u,y.groupId)||u[0];t0(y,b,"audioCodec"),t0(y,b,"textCodec")}h.push(y)}}return n}static parseLevelPlaylist(e,t,s,r,n,a){const o=new YA(t),l=o.fragments;let d=null,c=0,u=0,h=0,f=0,m=null,p=new Yc(r,t),g,v,y,b=-1,x=!1,_=null;for(Zp.lastIndex=0,o.m3u8=e,o.hasVariableRefs=qp(e);(g=Zp.exec(e))!==null;){x&&(x=!1,p=new Yc(r,t),p.start=h,p.sn=c,p.cc=f,p.level=s,d&&(p.initSegment=d,p.rawProgramDateTime=d.rawProgramDateTime,d.rawProgramDateTime=null,_&&(p.setByteRange(_),_=null)));const O=g[1];if(O){p.duration=parseFloat(O);const L=(" "+g[2]).slice(1);p.title=L||null,p.tagList.push(L?["INF",O,L]:["INF",O])}else if(g[3]){if(j(p.duration)){p.start=h,y&&r0(p,y,o),p.sn=c,p.level=s,p.cc=f,l.push(p);const L=(" "+g[3]).slice(1);p.relurl=zu(o,L),i0(p,m),m=p,h+=p.duration,c++,u=0,x=!0}}else if(g[4]){const L=(" "+g[4]).slice(1);m?p.setByteRange(L,m):p.setByteRange(L)}else if(g[5])p.rawProgramDateTime=(" "+g[5]).slice(1),p.tagList.push(["PROGRAM-DATE-TIME",p.rawProgramDateTime]),b===-1&&(b=l.length);else{if(g=g[0].match(DS),!g){R.warn("No matches on slow regex match for level playlist!");continue}for(v=1;v<g.length&&!(typeof g[v]<"u");v++);const L=(" "+g[v]).slice(1),C=(" "+g[v+1]).slice(1),H=g[v+2]?(" "+g[v+2]).slice(1):"";switch(L){case"PLAYLIST-TYPE":o.type=C.toUpperCase();break;case"MEDIA-SEQUENCE":c=o.startSN=parseInt(C);break;case"SKIP":{const U=new Oe(C);Lt(o,U,["RECENTLY-REMOVED-DATERANGES"]);const Q=U.decimalInteger("SKIPPED-SEGMENTS");if(j(Q)){o.skippedSegments=Q;for(let Y=Q;Y--;)l.unshift(null);c+=Q}const q=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");q&&(o.recentlyRemovedDateranges=q.split(" "));break}case"TARGETDURATION":o.targetduration=Math.max(parseInt(C),1);break;case"VERSION":o.version=parseInt(C);break;case"INDEPENDENT-SEGMENTS":case"EXTM3U":break;case"ENDLIST":o.live=!1;break;case"#":(C||H)&&p.tagList.push(H?[C,H]:[C]);break;case"DISCONTINUITY":f++,p.tagList.push(["DIS"]);break;case"GAP":p.gap=!0,p.tagList.push([L]);break;case"BITRATE":p.tagList.push([L,C]);break;case"DATERANGE":{const U=new Oe(C);Lt(o,U,["ID","CLASS","START-DATE","END-DATE","SCTE35-CMD","SCTE35-OUT","SCTE35-IN"]),Lt(o,U,U.clientAttrs);const Q=new Lv(U,o.dateRanges[U.ID]);Q.isValid||o.skippedSegments?o.dateRanges[Q.id]=Q:R.warn(`Ignoring invalid DATERANGE tag: "${C}"`),p.tagList.push(["EXT-X-DATERANGE",C]);break}case"DEFINE":{{const U=new Oe(C);Lt(o,U,["NAME","VALUE","IMPORT","QUERYPARAM"]),"IMPORT"in U?xS(o,U,a):Yp(o,U,t)}break}case"DISCONTINUITY-SEQUENCE":f=parseInt(C);break;case"KEY":{const U=Jp(C,t,o);if(U.isSupported()){if(U.method==="NONE"){y=void 0;break}y||(y={}),y[U.keyFormat]&&(y=Ke({},y)),y[U.keyFormat]=U}else R.warn(`[Keys] Ignoring invalid EXT-X-KEY tag: "${C}"`);break}case"START":o.startTimeOffset=e0(C);break;case"MAP":{const U=new Oe(C);if(Lt(o,U,["BYTERANGE","URI"]),p.duration){const Q=new Yc(r,t);s0(Q,U,s,y),d=Q,p.initSegment=d,d.rawProgramDateTime&&!p.rawProgramDateTime&&(p.rawProgramDateTime=d.rawProgramDateTime)}else{const Q=p.byteRangeEndOffset;if(Q){const q=p.byteRangeStartOffset;_=`${Q-q}@${q}`}else _=null;s0(p,U,s,y),d=p,x=!0}break}case"SERVER-CONTROL":{const U=new Oe(C);o.canBlockReload=U.bool("CAN-BLOCK-RELOAD"),o.canSkipUntil=U.optionalFloat("CAN-SKIP-UNTIL",0),o.canSkipDateRanges=o.canSkipUntil>0&&U.bool("CAN-SKIP-DATERANGES"),o.partHoldBack=U.optionalFloat("PART-HOLD-BACK",0),o.holdBack=U.optionalFloat("HOLD-BACK",0);break}case"PART-INF":{const U=new Oe(C);o.partTarget=U.decimalFloatingPoint("PART-TARGET");break}case"PART":{let U=o.partList;U||(U=o.partList=[]);const Q=u>0?U[U.length-1]:void 0,q=u++,Y=new Oe(C);Lt(o,Y,["BYTERANGE","URI"]);const oe=new VA(Y,p,t,q,Q);U.push(oe),p.duration+=oe.duration;break}case"PRELOAD-HINT":{const U=new Oe(C);Lt(o,U,["URI"]),o.preloadHint=U;break}case"RENDITION-REPORT":{const U=new Oe(C);Lt(o,U,["URI"]),o.renditionReports=o.renditionReports||[],o.renditionReports.push(U);break}default:R.warn(`line parsed but not handled: ${g}`);break}}}m&&!m.relurl?(l.pop(),h-=m.duration,o.partList&&(o.fragmentHint=m)):o.partList&&(i0(p,m),p.cc=f,o.fragmentHint=p,y&&r0(p,y,o));const S=l.length,A=l[0],D=l[S-1];if(h+=o.skippedSegments*o.targetduration,h>0&&S&&D){o.averagetargetduration=h/S;const O=D.sn;o.endSN=O!=="initSegment"?O:0,o.live||(D.endList=!0),A&&(o.startCC=A.cc)}else o.endSN=0,o.startCC=0;return o.fragmentHint&&(h+=o.fragmentHint.duration),o.totalduration=h,o.endCC=f,b>0&&OS(l,b),o}}function Jp(i,e,t){var s,r;const n=new Oe(i);Lt(t,n,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);const a=(s=n.METHOD)!=null?s:"",o=n.URI,l=n.hexadecimalInteger("IV"),d=n.KEYFORMATVERSIONS,c=(r=n.KEYFORMAT)!=null?r:"identity";o&&n.IV&&!l&&R.error(`Invalid IV: ${n.IV}`);const u=o?Ri.resolve(o,e):"",h=(d||"1").split("/").map(Number).filter(Number.isFinite);return new ja(a,u,c,h,l)}function e0(i){const t=new Oe(i).decimalFloatingPoint("TIME-OFFSET");return j(t)?t:null}function MS(i,e){let t=(i||"").split(/[ ,]+/).filter(s=>s);["video","audio","text"].forEach(s=>{const r=t.filter(n=>LS(n,s));r.length&&(e[`${s}Codec`]=r.join(","),t=t.filter(n=>r.indexOf(n)===-1))}),e.unknownCodecs=t}function t0(i,e,t){const s=e[t];s&&(i[t]=s)}function OS(i,e){let t=i[e];for(let s=e;s--;){const r=i[s];if(!r)return;r.programDateTime=t.programDateTime-r.duration*1e3,t=r}}function i0(i,e){i.rawProgramDateTime?i.programDateTime=Date.parse(i.rawProgramDateTime):e!=null&&e.programDateTime&&(i.programDateTime=e.endProgramDateTime),j(i.programDateTime)||(i.programDateTime=null,i.rawProgramDateTime=null)}function s0(i,e,t,s){i.relurl=e.URI,e.BYTERANGE&&i.setByteRange(e.BYTERANGE),i.level=t,i.sn="initSegment",s&&(i.levelkeys=s),i.initSegment=null}function r0(i,e,t){i.levelkeys=e;const{encryptedFragments:s}=t;(!s.length||s[s.length-1].levelkeys!==e)&&Object.keys(e).some(r=>e[r].isCommonEncryption)&&s.push(i)}var pe={MANIFEST:"manifest",LEVEL:"level",AUDIO_TRACK:"audioTrack",SUBTITLE_TRACK:"subtitleTrack"},te={MAIN:"main",AUDIO:"audio",SUBTITLE:"subtitle"};function n0(i){const{type:e}=i;switch(e){case pe.AUDIO_TRACK:return te.AUDIO;case pe.SUBTITLE_TRACK:return te.SUBTITLE;default:return te.MAIN}}function eu(i,e){let t=i.url;return(t===void 0||t.indexOf("data:")===0)&&(t=e.url),t}class PS{constructor(e){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=e,this.registerListeners()}startLoad(e){}stopLoad(){this.destroyInternalLoaders()}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.on(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),e.off(E.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)}createInternalLoader(e){const t=this.hls.config,s=t.pLoader,r=t.loader,n=s||r,a=new n(t);return this.loaders[e.type]=a,a}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:pe.MANIFEST,url:s,deliveryDirectives:null})}onLevelLoading(e,t){const{id:s,level:r,pathwayId:n,url:a,deliveryDirectives:o}=t;this.load({id:s,level:r,pathwayId:n,responseType:"text",type:pe.LEVEL,url:a,deliveryDirectives:o})}onAudioTrackLoading(e,t){const{id:s,groupId:r,url:n,deliveryDirectives:a}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:pe.AUDIO_TRACK,url:n,deliveryDirectives:a})}onSubtitleTrackLoading(e,t){const{id:s,groupId:r,url:n,deliveryDirectives:a}=t;this.load({id:s,groupId:r,level:null,responseType:"text",type:pe.SUBTITLE_TRACK,url:n,deliveryDirectives:a})}load(e){var t;const s=this.hls.config;let r=this.getInternalLoader(e);if(r){const d=r.context;if(d&&d.url===e.url&&d.level===e.level){R.trace("[playlist-loader]: playlist request ongoing");return}R.log(`[playlist-loader]: aborting previous loader for type: ${e.type}`),r.abort()}let n;if(e.type===pe.MANIFEST?n=s.manifestLoadPolicy.default:n=Ke({},s.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),r=this.createInternalLoader(e),j((t=e.deliveryDirectives)==null?void 0:t.part)){let d;if(e.type===pe.LEVEL&&e.level!==null?d=this.hls.levels[e.level].details:e.type===pe.AUDIO_TRACK&&e.id!==null?d=this.hls.audioTracks[e.id].details:e.type===pe.SUBTITLE_TRACK&&e.id!==null&&(d=this.hls.subtitleTracks[e.id].details),d){const c=d.partTarget,u=d.targetduration;if(c&&u){const h=Math.max(c*3,u*.8)*1e3;n=Ke({},n,{maxTimeToFirstByteMs:Math.min(h,n.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(h,n.maxTimeToFirstByteMs)})}}}const a=n.errorRetry||n.timeoutRetry||{},o={loadPolicy:n,timeout:n.maxLoadTimeMs,maxRetry:a.maxNumRetry||0,retryDelay:a.retryDelayMs||0,maxRetryDelay:a.maxRetryDelayMs||0},l={onSuccess:(d,c,u,h)=>{const f=this.getInternalLoader(u);this.resetInternalLoader(u.type);const m=d.data;if(m.indexOf("#EXTM3U")!==0){this.handleManifestParsingError(d,u,new Error("no EXTM3U delimiter"),h||null,c);return}c.parsing.start=performance.now(),Ri.isMediaPlaylist(m)?this.handleTrackOrLevelPlaylist(d,c,u,h||null,f):this.handleMasterPlaylist(d,c,u,h)},onError:(d,c,u,h)=>{this.handleNetworkError(c,u,!1,d,h)},onTimeout:(d,c,u)=>{this.handleNetworkError(c,u,!0,void 0,d)}};r.load(e,o,l)}handleMasterPlaylist(e,t,s,r){const n=this.hls,a=e.data,o=eu(e,s),l=Ri.parseMasterPlaylist(a,o);if(l.playlistParsingError){this.handleManifestParsingError(e,s,l.playlistParsingError,r,t);return}const{contentSteering:d,levels:c,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m}=l;this.variableList=m;const{AUDIO:p=[],SUBTITLES:g,"CLOSED-CAPTIONS":v}=Ri.parseMasterPlaylistMedia(a,o,l);p.length&&!p.some(b=>!b.url)&&c[0].audioCodec&&!c[0].attrs.AUDIO&&(R.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),p.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new Oe({}),bitrate:0,url:""})),n.trigger(E.MANIFEST_LOADED,{levels:c,audioTracks:p,subtitles:g,captions:v,contentSteering:d,url:o,stats:t,networkDetails:r,sessionData:u,sessionKeys:h,startTimeOffset:f,variableList:m})}handleTrackOrLevelPlaylist(e,t,s,r,n){const a=this.hls,{id:o,level:l,type:d}=s,c=eu(e,s),u=0,h=j(l)?l:j(o)?o:0,f=n0(s),m=Ri.parseLevelPlaylist(e.data,c,h,f,u,this.variableList);if(d===pe.MANIFEST){const p={attrs:new Oe({}),bitrate:0,details:m,name:"",url:c};a.trigger(E.MANIFEST_LOADED,{levels:[p],audioTracks:[],url:c,stats:t,networkDetails:r,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}t.parsing.end=performance.now(),s.levelDetails=m,this.handlePlaylistLoaded(m,e,t,s,r,n)}handleManifestParsingError(e,t,s,r,n){this.hls.trigger(E.ERROR,{type:se.NETWORK_ERROR,details:M.MANIFEST_PARSING_ERROR,fatal:t.type===pe.MANIFEST,url:e.url,err:s,error:s,reason:s.message,response:e,context:t,networkDetails:r,stats:n})}handleNetworkError(e,t,s=!1,r,n){let a=`A network ${s?"timeout":"error"+(r?" (status "+r.code+")":"")} occurred while loading ${e.type}`;e.type===pe.LEVEL?a+=`: ${e.level} id: ${e.id}`:(e.type===pe.AUDIO_TRACK||e.type===pe.SUBTITLE_TRACK)&&(a+=` id: ${e.id} group-id: "${e.groupId}"`);const o=new Error(a);R.warn(`[playlist-loader]: ${a}`);let l=M.UNKNOWN,d=!1;const c=this.getInternalLoader(e);switch(e.type){case pe.MANIFEST:l=s?M.MANIFEST_LOAD_TIMEOUT:M.MANIFEST_LOAD_ERROR,d=!0;break;case pe.LEVEL:l=s?M.LEVEL_LOAD_TIMEOUT:M.LEVEL_LOAD_ERROR,d=!1;break;case pe.AUDIO_TRACK:l=s?M.AUDIO_TRACK_LOAD_TIMEOUT:M.AUDIO_TRACK_LOAD_ERROR,d=!1;break;case pe.SUBTITLE_TRACK:l=s?M.SUBTITLE_TRACK_LOAD_TIMEOUT:M.SUBTITLE_LOAD_ERROR,d=!1;break}c&&this.resetInternalLoader(e.type);const u={type:se.NETWORK_ERROR,details:l,fatal:d,url:e.url,loader:c,context:e,error:o,networkDetails:t,stats:n};if(r){const h=(t==null?void 0:t.url)||e.url;u.response=dt({url:h,data:void 0},r)}this.hls.trigger(E.ERROR,u)}handlePlaylistLoaded(e,t,s,r,n,a){const o=this.hls,{type:l,level:d,id:c,groupId:u,deliveryDirectives:h}=r,f=eu(t,r),m=n0(r),p=typeof r.level=="number"&&m===te.MAIN?d:void 0;if(!e.fragments.length){const v=new Error("No Segments found in Playlist");o.trigger(E.ERROR,{type:se.NETWORK_ERROR,details:M.LEVEL_EMPTY_ERROR,fatal:!1,url:f,error:v,reason:v.message,response:t,context:r,level:p,parent:m,networkDetails:n,stats:s});return}e.targetduration||(e.playlistParsingError=new Error("Missing Target Duration"));const g=e.playlistParsingError;if(g){o.trigger(E.ERROR,{type:se.NETWORK_ERROR,details:M.LEVEL_PARSING_ERROR,fatal:!1,url:f,error:g,reason:g.message,response:t,context:r,level:p,parent:m,networkDetails:n,stats:s});return}switch(e.live&&a&&(a.getCacheAge&&(e.ageHeader=a.getCacheAge()||0),(!a.getCacheAge||isNaN(e.ageHeader))&&(e.ageHeader=0)),l){case pe.MANIFEST:case pe.LEVEL:o.trigger(E.LEVEL_LOADED,{details:e,level:p||0,id:c||0,stats:s,networkDetails:n,deliveryDirectives:h});break;case pe.AUDIO_TRACK:o.trigger(E.AUDIO_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:s,networkDetails:n,deliveryDirectives:h});break;case pe.SUBTITLE_TRACK:o.trigger(E.SUBTITLE_TRACK_LOADED,{details:e,id:c||0,groupId:u||"",stats:s,networkDetails:n,deliveryDirectives:h});break}}}function Wv(i,e){let t;try{t=new Event("addtrack")}catch{t=document.createEvent("Event"),t.initEvent("addtrack",!1,!1)}t.track=i,e.dispatchEvent(t)}function Kv(i,e){const t=i.mode;if(t==="disabled"&&(i.mode="hidden"),i.cues&&!i.cues.getCueById(e.id))try{if(i.addCue(e),!i.cues.getCueById(e.id))throw new Error(`addCue is failed for: ${e}`)}catch(s){R.debug(`[texttrack-utils]: ${s}`);try{const r=new self.TextTrackCue(e.startTime,e.endTime,e.text);r.id=e.id,i.addCue(r)}catch(r){R.debug(`[texttrack-utils]: Legacy TextTrackCue fallback failed: ${r}`)}}t==="disabled"&&(i.mode=t)}function fn(i){const e=i.mode;if(e==="disabled"&&(i.mode="hidden"),i.cues)for(let t=i.cues.length;t--;)i.removeCue(i.cues[t]);e==="disabled"&&(i.mode=e)}function Xu(i,e,t,s){const r=i.mode;if(r==="disabled"&&(i.mode="hidden"),i.cues&&i.cues.length>0){const n=US(i.cues,e,t);for(let a=0;a<n.length;a++)(!s||s(n[a]))&&i.removeCue(n[a])}r==="disabled"&&(i.mode=r)}function NS(i,e){if(e<i[0].startTime)return 0;const t=i.length-1;if(e>i[t].endTime)return-1;let s=0,r=t;for(;s<=r;){const n=Math.floor((r+s)/2);if(e<i[n].startTime)r=n-1;else if(e>i[n].startTime&&s<t)s=n+1;else return n}return i[s].startTime-e<e-i[r].startTime?s:r}function US(i,e,t){const s=[],r=NS(i,e);if(r>-1)for(let n=r,a=i.length;n<a;n++){const o=i[n];if(o.startTime>=e&&o.endTime<=t)s.push(o);else if(o.startTime>t)return s}return s}function tl(i){const e=[];for(let t=0;t<i.length;t++){const s=i[t];(s.kind==="subtitles"||s.kind==="captions")&&s.label&&e.push(i[t])}return e}var ei={audioId3:"org.id3",dateRange:"com.apple.quicktime.HLS",emsg:"https://aomedia.org/emsg/ID3"};const FS=.25;function Qu(){if(!(typeof self>"u"))return self.VTTCue||self.TextTrackCue}function a0(i,e,t,s,r){let n=new i(e,t,"");try{n.value=s,r&&(n.type=r)}catch{n=new i(e,t,JSON.stringify(r?dt({type:r},s):s))}return n}const To=(()=>{const i=Qu();try{i&&new i(0,Number.POSITIVE_INFINITY,"")}catch{return Number.MAX_VALUE}return Number.POSITIVE_INFINITY})();function tu(i,e){return i.getTime()/1e3-e}function $S(i){return Uint8Array.from(i.replace(/^0x/,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ")).buffer}class BS{constructor(e){this.hls=void 0,this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=e,this._registerListeners()}destroy(){this._unregisterListeners(),this.id3Track=null,this.media=null,this.dateRangeCuesAppended={},this.hls=null}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this)}onMediaAttached(e,t){this.media=t.media}onMediaDetaching(){this.id3Track&&(fn(this.id3Track),this.id3Track=null,this.media=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 Wv(s,this.media),s}return this.media.addTextTrack("metadata","id3")}}onFragParsingMetadata(e,t){if(!this.media)return;const{hls:{config:{enableEmsgMetadataCues:s,enableID3MetadataCues:r}}}=this;if(!s&&!r)return;const{samples:n}=t;this.id3Track||(this.id3Track=this.createTrack(this.media));const a=Qu();if(a)for(let o=0;o<n.length;o++){const l=n[o].type;if(l===ei.emsg&&!s||!r)continue;const d=Mv(n[o].data);if(d){const c=n[o].pts;let u=c+n[o].duration;u>To&&(u=To),u-c<=0&&(u=c+FS);for(let f=0;f<d.length;f++){const m=d[f];if(!Dv(m)){this.updateId3CueEnds(c,l);const p=a0(a,c,u,m,l);p&&this.id3Track.addCue(p)}}}}}updateId3CueEnds(e,t){var s;const r=(s=this.id3Track)==null?void 0:s.cues;if(r)for(let n=r.length;n--;){const a=r[n];a.type===t&&a.startTime<e&&a.endTime===To&&(a.endTime=e)}}onBufferFlushing(e,{startOffset:t,endOffset:s,type:r}){const{id3Track:n,hls:a}=this;if(!a)return;const{config:{enableEmsgMetadataCues:o,enableID3MetadataCues:l}}=a;if(n&&(o||l)){let d;r==="audio"?d=c=>c.type===ei.audioId3&&l:r==="video"?d=c=>c.type===ei.emsg&&o:d=c=>c.type===ei.audioId3&&l||c.type===ei.emsg&&o,Xu(n,t,s,d)}}onLevelUpdated(e,{details:t}){if(!this.media||!t.hasProgramDateTime||!this.hls.config.enableDateRangeMetadataCues)return;const{dateRangeCuesAppended:s,id3Track:r}=this,{dateRanges:n}=t,a=Object.keys(n);if(r){const c=Object.keys(s).filter(u=>!a.includes(u));for(let u=c.length;u--;){const h=c[u];Object.keys(s[h].cues).forEach(f=>{r.removeCue(s[h].cues[f])}),delete s[h]}}const o=t.fragments[t.fragments.length-1];if(a.length===0||!j(o==null?void 0:o.programDateTime))return;this.id3Track||(this.id3Track=this.createTrack(this.media));const l=o.programDateTime/1e3-o.start,d=Qu();for(let c=0;c<a.length;c++){const u=a[c],h=n[u],f=tu(h.startDate,l),m=s[u],p=(m==null?void 0:m.cues)||{};let g=(m==null?void 0:m.durationKnown)||!1,v=To;const y=h.endDate;if(y)v=tu(y,l),g=!0;else if(h.endOnNext&&!g){const x=a.reduce((_,S)=>{if(S!==h.id){const A=n[S];if(A.class===h.class&&A.startDate>h.startDate&&(!_||h.startDate<_.startDate))return A}return _},null);x&&(v=tu(x.startDate,l),g=!0)}const b=Object.keys(h.attr);for(let x=0;x<b.length;x++){const _=b[x];if(!WA(_))continue;const S=p[_];if(S)g&&!m.durationKnown&&(S.endTime=v);else if(d){let A=h.attr[_];KA(_)&&(A=$S(A));const D=a0(d,f,v,{key:_,data:A},ei.dateRange);D&&(D.id=u,this.id3Track.addCue(D),p[_]=D)}}s[u]={cues:p,dateRange:h,durationKnown:g}}}}class GS{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.levelDetails=null,this.currentTime=0,this.stallCount=0,this._latency=null,this.timeupdateHandler=()=>this.timeupdate(),this.hls=e,this.config=e.config,this.registerListeners()}get latency(){return this._latency||0}get maxLatency(){const{config:e,levelDetails:t}=this;return e.liveMaxLatencyDuration!==void 0?e.liveMaxLatencyDuration:t?e.liveMaxLatencyDurationCount*t.targetduration:0}get targetLatency(){const{levelDetails:e}=this;if(e===null)return null;const{holdBack:t,partHoldBack:s,targetduration:r}=e,{liveSyncDuration:n,liveSyncDurationCount:a,lowLatencyMode:o}=this.config,l=this.hls.userConfig;let d=o&&s||t;(l.liveSyncDuration||l.liveSyncDurationCount||d===0)&&(d=n!==void 0?n:a*r);const c=r;return d+Math.min(this.stallCount*1,c)}get liveSyncPosition(){const e=this.estimateLiveEdge(),t=this.targetLatency,s=this.levelDetails;if(e===null||t===null||s===null)return null;const r=s.edge,n=e-t-this.edgeStalled,a=r-s.totalduration,o=r-(this.config.lowLatencyMode&&s.partTarget||s.targetduration);return Math.min(Math.max(a,n),o)}get drift(){const{levelDetails:e}=this;return e===null?1:e.drift}get edgeStalled(){const{levelDetails:e}=this;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,levelDetails:t}=this;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.levelDetails=null,this.hls=this.timeupdateHandler=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(E.ERROR,this.onError,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.off(E.ERROR,this.onError,this)}onMediaAttached(e,t){this.media=t.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)}onMediaDetaching(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)}onManifestLoading(){this.levelDetails=null,this._latency=null,this.stallCount=0}onLevelUpdated(e,{details:t}){this.levelDetails=t,t.advanced&&this.timeupdate(),!t.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)}onError(e,t){var s;t.details===M.BUFFER_STALLED_ERROR&&(this.stallCount++,(s=this.levelDetails)!=null&&s.live&&R.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))}timeupdate(){const{media:e,levelDetails:t}=this;if(!e||!t)return;this.currentTime=e.currentTime;const s=this.computeLatency();if(s===null)return;this._latency=s;const{lowLatencyMode:r,maxLiveSyncPlaybackRate:n}=this.config;if(!r||n===1||!t.live)return;const a=this.targetLatency;if(a===null)return;const o=s-a,l=Math.min(this.maxLatency,a+t.targetduration);if(o<l&&o>.05&&this.forwardBufferLength>1){const c=Math.min(2,Math.max(1,n)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;e.playbackRate=Math.min(c,Math.max(1,u))}else e.playbackRate!==1&&e.playbackRate!==0&&(e.playbackRate=1)}estimateLiveEdge(){const{levelDetails:e}=this;return e===null?null:e.edge+e.age}computeLatency(){const e=this.estimateLiveEdge();return e===null?null:e-this.currentTime}}const Zu=["NONE","TYPE-0","TYPE-1",null];function HS(i){return Zu.indexOf(i)>-1}const Gd=["SDR","PQ","HLG"];function WS(i){return!!i&&Gd.indexOf(i)>-1}var il={No:"",Yes:"YES",v2:"v2"};function o0(i){const{canSkipUntil:e,canSkipDateRanges:t,age:s}=i,r=s<e/2;return e&&r?t?il.v2:il.Yes:il.No}class l0{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 wn{constructor(e){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.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(t=>!!t).map(t=>t.substring(0,4)).join(","),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 d0(this._audioGroups,e)}hasSubtitleGroup(e){return d0(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 d0(i,e){return!e||!i?!1:i.indexOf(e)!==-1}function iu(i,e){const t=e.startPTS;if(j(t)){let s=0,r;e.sn>i.sn?(s=t-i.start,r=i):(s=i.start-t,r=e),r.duration!==s&&(r.duration=s)}else e.sn>i.sn?i.cc===e.cc&&i.minEndPTS?e.start=i.start+(i.minEndPTS-i.start):e.start=i.start+i.duration:e.start=Math.max(i.start-e.duration,0)}function Vv(i,e,t,s,r,n){s-t<=0&&(R.warn("Fragment should have a positive duration",e),s=t+e.duration,n=r+e.duration);let o=t,l=s;const d=e.startPTS,c=e.endPTS;if(j(d)){const g=Math.abs(d-t);j(e.deltaPTS)?e.deltaPTS=Math.max(g,e.deltaPTS):e.deltaPTS=g,o=Math.max(t,d),t=Math.min(t,d),r=Math.min(r,e.startDTS),l=Math.min(s,c),s=Math.max(s,c),n=Math.max(n,e.endDTS)}const u=t-e.start;e.start!==0&&(e.start=t),e.duration=s-e.start,e.startPTS=t,e.maxStartPTS=o,e.startDTS=r,e.endPTS=s,e.minEndPTS=l,e.endDTS=n;const h=e.sn;if(!i||h<i.startSN||h>i.endSN)return 0;let f;const m=h-i.startSN,p=i.fragments;for(p[m]=e,f=m;f>0;f--)iu(p[f],p[f-1]);for(f=m;f<p.length-1;f++)iu(p[f],p[f+1]);return i.fragmentHint&&iu(p[p.length-1],i.fragmentHint),i.PTSKnown=i.alignedSliding=!0,u}function KS(i,e){let t=null;const s=i.fragments;for(let l=s.length-1;l>=0;l--){const d=s[l].initSegment;if(d){t=d;break}}i.fragmentHint&&delete i.fragmentHint.endPTS;let r=0,n;if(YS(i,e,(l,d)=>{l.relurl&&(r=l.cc-d.cc),j(l.startPTS)&&j(l.endPTS)&&(d.start=d.startPTS=l.startPTS,d.startDTS=l.startDTS,d.maxStartPTS=l.maxStartPTS,d.endPTS=l.endPTS,d.endDTS=l.endDTS,d.minEndPTS=l.minEndPTS,d.duration=l.endPTS-l.startPTS,d.duration&&(n=d),e.PTSKnown=e.alignedSliding=!0),d.elementaryStreams=l.elementaryStreams,d.loader=l.loader,d.stats=l.stats,l.initSegment&&(d.initSegment=l.initSegment,t=l.initSegment)}),t&&(e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments).forEach(d=>{var c;d&&(!d.initSegment||d.initSegment.relurl===((c=t)==null?void 0:c.relurl))&&(d.initSegment=t)}),e.skippedSegments)if(e.deltaUpdateFailed=e.fragments.some(l=>!l),e.deltaUpdateFailed){R.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(let l=e.skippedSegments;l--;)e.fragments.shift();e.startSN=e.fragments[0].sn,e.startCC=e.fragments[0].cc}else e.canSkipDateRanges&&(e.dateRanges=VS(i.dateRanges,e.dateRanges,e.recentlyRemovedDateranges));const a=e.fragments;if(r){R.warn("discontinuity sliding from playlist, take drift into account");for(let l=0;l<a.length;l++)a[l].cc+=r}e.skippedSegments&&(e.startCC=e.fragments[0].cc),qS(i.partList,e.partList,(l,d)=>{d.elementaryStreams=l.elementaryStreams,d.stats=l.stats}),n?Vv(e,n,n.startPTS,n.endPTS,n.startDTS,n.endDTS):qv(i,e),a.length&&(e.totalduration=e.edge-a[0].start),e.driftStartTime=i.driftStartTime,e.driftStart=i.driftStart;const o=e.advancedDateTime;if(e.advanced&&o){const l=e.edge;e.driftStart||(e.driftStartTime=o,e.driftStart=l),e.driftEndTime=o,e.driftEnd=l}else e.driftEndTime=i.driftEndTime,e.driftEnd=i.driftEnd,e.advancedDateTime=i.advancedDateTime}function VS(i,e,t){const s=Ke({},i);return t&&t.forEach(r=>{delete s[r]}),Object.keys(e).forEach(r=>{const n=new Lv(e[r].attr,s[r]);n.isValid?s[r]=n:R.warn(`Ignoring invalid Playlist Delta Update DATERANGE tag: "${JSON.stringify(e[r].attr)}"`)}),s}function qS(i,e,t){if(i&&e){let s=0;for(let r=0,n=i.length;r<=n;r++){const a=i[r],o=e[r+s];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?t(a,o):s--}}}function YS(i,e,t){const s=e.skippedSegments,r=Math.max(i.startSN,e.startSN)-e.startSN,n=(i.fragmentHint?1:0)+(s?e.endSN:Math.min(i.endSN,e.endSN))-e.startSN,a=e.startSN-i.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments;for(let d=r;d<=n;d++){const c=l[a+d];let u=o[d];s&&!u&&d<s&&(u=e.fragments[d]=c),c&&u&&t(c,u)}}function qv(i,e){const t=e.startSN+e.skippedSegments-i.startSN,s=i.fragments;t<0||t>=s.length||Ju(e,s[t].start)}function Ju(i,e){if(e){const t=i.fragments;for(let s=i.skippedSegments;s<t.length;s++)t[s].start+=e;i.fragmentHint&&(i.fragmentHint.start+=e)}}function jS(i,e=1/0){let t=1e3*i.targetduration;if(i.updated){const s=i.fragments;if(s.length&&t*4>e){const n=s[s.length-1].duration*1e3;n<t&&(t=n)}}else t/=2;return Math.round(t)}function zS(i,e,t){if(!(i!=null&&i.details))return null;const s=i.details;let r=s.fragments[e-s.startSN];return r||(r=s.fragmentHint,r&&r.sn===e)?r:e<s.startSN&&t&&t.sn===e?t:null}function c0(i,e,t){var s;return i!=null&&i.details?Yv((s=i.details)==null?void 0:s.partList,e,t):null}function Yv(i,e,t){if(i)for(let s=i.length;s--;){const r=i[s];if(r.index===t&&r.fragment.sn===e)return r}return null}function jv(i){i.forEach((e,t)=>{const{details:s}=e;s!=null&&s.fragments&&s.fragments.forEach(r=>{r.level=t})})}function Hd(i){switch(i.details){case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_TIMEOUT:case M.LEVEL_LOAD_TIMEOUT:case M.MANIFEST_LOAD_TIMEOUT:return!0}return!1}function u0(i,e){const t=Hd(e);return i.default[`${t?"timeout":"error"}Retry`]}function fm(i,e){const t=i.backoff==="linear"?1:Math.pow(2,e);return Math.min(t*i.retryDelayMs,i.maxRetryDelayMs)}function h0(i){return dt(dt({},i),{errorRetry:null,timeoutRetry:null})}function Wd(i,e,t,s){if(!i)return!1;const r=s==null?void 0:s.code,n=e<i.maxNumRetry&&(XS(r)||!!t);return i.shouldRetry?i.shouldRetry(i,e,t,s,n):n}function XS(i){return i===0&&navigator.onLine===!1||!!i&&(i<400||i>499)}const zv={search:function(i,e){let t=0,s=i.length-1,r=null,n=null;for(;t<=s;){r=(t+s)/2|0,n=i[r];const a=e(n);if(a>0)t=r+1;else if(a<0)s=r-1;else return n}return null}};function QS(i,e,t){if(e===null||!Array.isArray(i)||!i.length||!j(e))return null;const s=i[0].programDateTime;if(e<(s||0))return null;const r=i[i.length-1].endProgramDateTime;if(e>=(r||0))return null;t=t||0;for(let n=0;n<i.length;++n){const a=i[n];if(JS(e,t,a))return a}return null}function Kd(i,e,t=0,s=0,r=.005){let n=null;if(i){n=e[i.sn-e[0].sn+1]||null;const o=i.endDTS-t;o>0&&o<15e-7&&(t+=15e-7)}else t===0&&e[0].start===0&&(n=e[0]);if(n&&((!i||i.level===n.level)&&eh(t,s,n)===0||ZS(n,i,Math.min(r,s))))return n;const a=zv.search(e,eh.bind(null,t,s));return a&&(a!==i||!n)?a:n}function ZS(i,e,t){if(e&&e.start===0&&e.level<i.level&&(e.endPTS||0)>0){const s=e.tagList.reduce((r,n)=>(n[0]==="INF"&&(r+=parseFloat(n[1])),r),t);return i.start<=s}return!1}function eh(i=0,e=0,t){if(t.start<=i&&t.start+t.duration>i)return 0;const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0));return t.start+t.duration-s<=i?1:t.start-s>i&&t.start?-1:0}function JS(i,e,t){const s=Math.min(e,t.duration+(t.deltaPTS?t.deltaPTS:0))*1e3;return(t.endProgramDateTime||0)-s>i}function ex(i,e){return zv.search(i,t=>t.cc<e?1:t.cc>e?-1:0)}var mt={DoNothing:0,SendEndCallback:1,SendAlternateToPenaltyBox:2,RemoveAlternatePermanently:3,InsertDiscontinuity:4,RetryRequest:5},Yt={None:0,MoveAllAlternatesMatchingHost:1,MoveAllAlternatesMatchingHDCP:2,SwitchToSDR:4};class tx{constructor(e){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=e,this.log=R.log.bind(R,"[info]:"),this.warn=R.warn.bind(R,"[warning]:"),this.error=R.error.bind(R,"[error]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.ERROR,this.onError,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.ERROR,this.onError,this),e.off(E.ERROR,this.onErrorOut,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this))}destroy(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}}startLoad(e){}stopLoad(){this.playlistError=0}getVariantLevelIndex(e){return(e==null?void 0:e.type)===te.MAIN?e.level:this.hls.loadLevel}onManifestLoading(){this.playlistError=0,this.penalizedRenditions={}}onLevelUpdated(){this.playlistError=0}onError(e,t){var s,r;if(t.fatal)return;const n=this.hls,a=t.context;switch(t.details){case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:t.errorAction=this.getFragRetryOrSwitchAction(t);return;case M.FRAG_PARSING_ERROR:if((s=t.frag)!=null&&s.gap){t.errorAction={action:mt.DoNothing,flags:Yt.None};return}case M.FRAG_GAP:case M.FRAG_DECRYPT_ERROR:{t.errorAction=this.getFragRetryOrSwitchAction(t),t.errorAction.action=mt.SendAlternateToPenaltyBox;return}case M.LEVEL_EMPTY_ERROR:case M.LEVEL_PARSING_ERROR:{var o,l;const d=t.parent===te.MAIN?t.level:n.loadLevel;t.details===M.LEVEL_EMPTY_ERROR&&((o=t.context)!=null&&(l=o.levelDetails)!=null&&l.live)?t.errorAction=this.getPlaylistRetryOrSwitchAction(t,d):(t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,d))}return;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:typeof(a==null?void 0:a.level)=="number"&&(t.errorAction=this.getPlaylistRetryOrSwitchAction(t,a.level));return;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.SUBTITLE_LOAD_ERROR:case M.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){const d=n.levels[n.loadLevel];if(d&&(a.type===pe.AUDIO_TRACK&&d.hasAudioGroup(a.groupId)||a.type===pe.SUBTITLE_TRACK&&d.hasSubtitleGroup(a.groupId))){t.errorAction=this.getPlaylistRetryOrSwitchAction(t,n.loadLevel),t.errorAction.action=mt.SendAlternateToPenaltyBox,t.errorAction.flags=Yt.MoveAllAlternatesMatchingHost;return}}return;case M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:{const d=n.levels[n.loadLevel],c=d==null?void 0:d.attrs["HDCP-LEVEL"];c?t.errorAction={action:mt.SendAlternateToPenaltyBox,flags:Yt.MoveAllAlternatesMatchingHDCP,hdcpLevel:c}:this.keySystemError(t)}return;case M.BUFFER_ADD_CODEC_ERROR:case M.REMUX_ALLOC_ERROR:case M.BUFFER_APPEND_ERROR:t.errorAction=this.getLevelSwitchAction(t,(r=t.level)!=null?r:n.loadLevel);return;case M.INTERNAL_EXCEPTION:case M.BUFFER_APPENDING_ERROR:case M.BUFFER_FULL_ERROR:case M.LEVEL_SWITCH_ERROR:case M.BUFFER_STALLED_ERROR:case M.BUFFER_SEEK_OVER_HOLE:case M.BUFFER_NUDGE_ON_STALL:t.errorAction={action:mt.DoNothing,flags:Yt.None};return}t.type===se.KEY_SYSTEM_ERROR&&this.keySystemError(t)}keySystemError(e){const t=this.getVariantLevelIndex(e.frag);e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,t)}getPlaylistRetryOrSwitchAction(e,t){const s=this.hls,r=u0(s.config.playlistLoadPolicy,e),n=this.playlistError++;if(Wd(r,n,Hd(e),e.response))return{action:mt.RetryRequest,flags:Yt.None,retryConfig:r,retryCount:n};const o=this.getLevelSwitchAction(e,t);return r&&(o.retryConfig=r,o.retryCount=n),o}getFragRetryOrSwitchAction(e){const t=this.hls,s=this.getVariantLevelIndex(e.frag),r=t.levels[s],{fragLoadPolicy:n,keyLoadPolicy:a}=t.config,o=u0(e.details.startsWith("key")?a:n,e),l=t.levels.reduce((c,u)=>c+u.fragmentError,0);if(r&&(e.details!==M.FRAG_GAP&&r.fragmentError++,Wd(o,l,Hd(e),e.response)))return{action:mt.RetryRequest,flags:Yt.None,retryConfig:o,retryCount:l};const d=this.getLevelSwitchAction(e,s);return o&&(d.retryConfig=o,d.retryCount=l),d}getLevelSwitchAction(e,t){const s=this.hls;t==null&&(t=s.loadLevel);const r=this.hls.levels[t];if(r){var n,a;const d=e.details;r.loadError++,d===M.BUFFER_APPEND_ERROR&&r.fragmentError++;let c=-1;const{levels:u,loadLevel:h,minAutoLevel:f,maxAutoLevel:m}=s;s.autoLevelEnabled||(s.loadLevel=-1);const p=(n=e.frag)==null?void 0:n.type,v=(p===te.AUDIO&&d===M.FRAG_PARSING_ERROR||e.sourceBufferName==="audio"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR))&&u.some(({audioCodec:S})=>r.audioCodec!==S),b=e.sourceBufferName==="video"&&(d===M.BUFFER_ADD_CODEC_ERROR||d===M.BUFFER_APPEND_ERROR)&&u.some(({codecSet:S,audioCodec:A})=>r.codecSet!==S&&r.audioCodec===A),{type:x,groupId:_}=(a=e.context)!=null?a:{};for(let S=u.length;S--;){const A=(S+h)%u.length;if(A!==h&&A>=f&&A<=m&&u[A].loadError===0){var o,l;const D=u[A];if(d===M.FRAG_GAP&&p===te.MAIN&&e.frag){const O=u[A].details;if(O){const L=Kd(e.frag,O.fragments,e.frag.start);if(L!=null&&L.gap)continue}}else{if(x===pe.AUDIO_TRACK&&D.hasAudioGroup(_)||x===pe.SUBTITLE_TRACK&&D.hasSubtitleGroup(_))continue;if(p===te.AUDIO&&(o=r.audioGroups)!=null&&o.some(O=>D.hasAudioGroup(O))||p===te.SUBTITLE&&(l=r.subtitleGroups)!=null&&l.some(O=>D.hasSubtitleGroup(O))||v&&r.audioCodec===D.audioCodec||!v&&r.audioCodec!==D.audioCodec||b&&r.codecSet===D.codecSet)continue}c=A;break}}if(c>-1&&s.loadLevel!==c)return e.levelRetry=!0,this.playlistError=0,{action:mt.SendAlternateToPenaltyBox,flags:Yt.None,nextAutoLevel:c}}return{action:mt.SendAlternateToPenaltyBox,flags:Yt.MoveAllAlternatesMatchingHost}}onErrorOut(e,t){var s;switch((s=t.errorAction)==null?void 0:s.action){case mt.DoNothing:break;case mt.SendAlternateToPenaltyBox:this.sendAlternateToPenaltyBox(t),!t.errorAction.resolved&&t.details!==M.FRAG_GAP?t.fatal=!0:/MediaSource readyState: ended/.test(t.error.message)&&(this.warn(`MediaSource ended after "${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:r,hdcpLevel:n,nextAutoLevel:a}=s;switch(r){case Yt.None:this.switchLevel(e,a);break;case Yt.MoveAllAlternatesMatchingHDCP:n&&(t.maxHdcpLevel=Zu[Zu.indexOf(n)-1],s.resolved=!0),this.warn(`Restricting playback to HDCP-LEVEL of "${t.maxHdcpLevel}" or lower`);break}s.resolved||this.switchLevel(e,a)}switchLevel(e,t){t!==void 0&&e.errorAction&&(this.warn(`switching to level ${t} after ${e.details}`),this.hls.nextAutoLevel=t,e.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)}}class mm{constructor(e,t){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=R.log.bind(R,`${t}:`),this.warn=R.warn.bind(R,`${t}:`),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.requestScheduled=-1,this.loadPlaylist()}stopLoad(){this.canLoad=!1,this.clearTimer()}switchParams(e,t,s){const r=t==null?void 0:t.renditionReports;if(r){let n=-1;for(let a=0;a<r.length;a++){const o=r[a];let l;try{l=new self.URL(o.URI,t.url).href}catch(d){R.warn(`Could not construct new URL for Rendition Report: ${d}`),l=o.URI||""}if(l===e){n=a;break}else l===e.substring(0,l.length)&&(n=a)}if(n!==-1){const a=r[n],o=parseInt(a["LAST-MSN"])||(t==null?void 0:t.lastPartSn);let l=parseInt(a["LAST-PART"])||(t==null?void 0:t.lastPartIndex);if(this.hls.config.lowLatencyMode){const c=Math.min(t.age-t.partTarget,t.targetduration);l>=0&&c>t.partTarget&&(l+=1)}const d=s&&o0(s);return new l0(o,l>=0?l:void 0,d)}}}loadPlaylist(e){this.requestScheduled===-1&&(this.requestScheduled=self.performance.now())}shouldLoadPlaylist(e){return this.canLoad&&!!e&&!!e.url&&(!e.details||e.details.live)}shouldReloadPlaylist(e){return this.timer===-1&&this.requestScheduled===-1&&this.shouldLoadPlaylist(e)}playlistLoaded(e,t,s){const{details:r,stats:n}=t,a=self.performance.now(),o=n.loading.first?Math.max(0,a-n.loading.first):0;if(r.advancedDateTime=Date.now()-o,r.live||s!=null&&s.live){if(r.reloaded(s),s&&this.log(`live playlist ${e} ${r.advanced?"REFRESHED "+r.lastPartSn+"-"+r.lastPartIndex:r.updated?"UPDATED":"MISSED"}`),s&&r.fragments.length>0&&KS(s,r),!this.canLoad||!r.live)return;let l,d,c;if(r.canBlockReload&&r.endSN&&r.advanced){const g=this.hls.config.lowLatencyMode,v=r.lastPartSn,y=r.endSN,b=r.lastPartIndex,x=b!==-1,_=v===y,S=g?0:b;x?(d=_?y+1:v,c=_?S:b+1):d=y+1;const A=r.age,D=A+r.ageHeader;let O=Math.min(D-r.partTarget,r.targetduration*1.5);if(O>0){if(s&&O>s.tuneInGoal)this.warn(`CDN Tune-in goal increased from: ${s.tuneInGoal} to: ${O} with playlist age: ${r.age}`),O=0;else{const L=Math.floor(O/r.targetduration);if(d+=L,c!==void 0){const C=Math.round(O%r.targetduration/r.partTarget);c+=C}this.log(`CDN Tune-in age: ${r.ageHeader}s last advanced ${A.toFixed(2)}s goal: ${O} skip sn ${L} to part ${c}`)}r.tuneInGoal=O}if(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,c),g||!_){this.loadPlaylist(l);return}}else(r.canBlockReload||r.canSkipUntil)&&(l=this.getDeliveryDirectives(r,t.deliveryDirectives,d,c));const u=this.hls.mainForwardBufferInfo,h=u?u.end-u.len:0,f=(r.edge-h)*1e3,m=jS(r,f);r.updated&&a>this.requestScheduled+m&&(this.requestScheduled=n.loading.start),d!==void 0&&r.canBlockReload?this.requestScheduled=n.loading.first+m-(r.partTarget*1e3||1e3):this.requestScheduled===-1||this.requestScheduled+m<a?this.requestScheduled=a:this.requestScheduled-a<=0&&(this.requestScheduled+=m);let p=this.requestScheduled-a;p=Math.max(0,p),this.log(`reload live playlist ${e} in ${Math.round(p)} ms`),this.timer=self.setTimeout(()=>this.loadPlaylist(l),p)}else this.clearTimer()}getDeliveryDirectives(e,t,s,r){let n=o0(e);return t!=null&&t.skip&&e.deltaUpdateFailed&&(s=t.msn,r=t.part,n=il.No),new l0(s,r,n)}checkRetry(e){const t=e.details,s=Hd(e),r=e.errorAction,{action:n,retryCount:a=0,retryConfig:o}=r||{},l=!!r&&!!o&&(n===mt.RetryRequest||!r.resolved&&n===mt.SendAlternateToPenaltyBox);if(l){var d;if(this.requestScheduled=-1,a>=o.maxNumRetry)return!1;if(s&&(d=e.context)!=null&&d.deliveryDirectives)this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" without delivery-directives`),this.loadPlaylist();else{const c=fm(o,a);this.timer=self.setTimeout(()=>this.loadPlaylist(),c),this.warn(`Retrying playlist loading ${a+1}/${o.maxNumRetry} after "${t}" in ${c}ms`)}e.levelRetry=!0,r.resolved=!0}return l}}class Dr{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 ix{constructor(e,t,s,r=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 Dr(e),this.fast_=new Dr(t),this.defaultTTFB_=r,this.ttfb_=new Dr(e)}update(e,t){const{slow_:s,fast_:r,ttfb_:n}=this;s.halfLife!==e&&(this.slow_=new Dr(e,s.getEstimate(),s.getTotalWeight())),r.halfLife!==t&&(this.fast_=new Dr(t,r.getEstimate(),r.getTotalWeight())),n.halfLife!==e&&(this.ttfb_=new Dr(e,n.getEstimate(),n.getTotalWeight()))}sample(e,t){e=Math.max(e,this.minDelayMs_);const s=8*t,r=e/1e3,n=s/r;this.fast_.sample(r,n),this.slow_.sample(r,n)}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_}destroy(){}}const Xv={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},f0={};function sx(i,e,t,s,r,n){const a=i.audioCodec?i.audioGroups:null,o=n==null?void 0:n.audioCodec,l=n==null?void 0:n.channels,d=l?parseInt(l):o?1/0:2;let c=null;if(a!=null&&a.length)try{a.length===1&&a[0]?c=e.groups[a[0]].channels:c=a.reduce((u,h)=>{if(h){const f=e.groups[h];if(!f)throw new Error(`Audio track group ${h} not found`);Object.keys(f.channels).forEach(m=>{u[m]=(u[m]||0)+f.channels[m]})}return u},{2:0})}catch{return!0}return i.videoCodec!==void 0&&(i.width>1920&&i.height>1088||i.height>1920&&i.width>1088||i.frameRate>Math.max(s,30)||i.videoRange!=="SDR"&&i.videoRange!==t||i.bitrate>Math.max(r,8e6))||!!c&&j(d)&&Object.keys(c).some(u=>parseInt(u)>d)}function rx(i,e,t){const s=i.videoCodec,r=i.audioCodec;if(!s||!r||!t)return Promise.resolve(Xv);const n={width:i.width,height:i.height,bitrate:Math.ceil(Math.max(i.bitrate*.9,i.averageBitrate)),framerate:i.frameRate||30},a=i.videoRange;a!=="SDR"&&(n.transferFunction=a.toLowerCase());const o=s.split(",").map(l=>({type:"media-source",video:dt(dt({},n),{},{contentType:za(l,"video")})}));return r&&i.audioGroups&&i.audioGroups.forEach(l=>{var d;l&&((d=e.groups[l])==null||d.tracks.forEach(c=>{if(c.groupId===l){const u=c.channels||"",h=parseFloat(u);j(h)&&h>2&&o.push.apply(o,r.split(",").map(f=>({type:"media-source",audio:{contentType:za(f,"audio"),channels:""+h}})))}}))}),Promise.all(o.map(l=>{const d=nx(l);return f0[d]||(f0[d]=t.decodingInfo(l))})).then(l=>({supported:!l.some(d=>!d.supported),configurations:o,decodingInfoResults:l})).catch(l=>({supported:!1,configurations:o,decodingInfoResults:[],error:l}))}function nx(i){const{audio:e,video:t}=i,s=t||e;if(s){const r=s.contentType.split('"')[1];if(t)return`r${t.height}x${t.width}f${Math.ceil(t.framerate)}${t.transferFunction||"sd"}_${r}_${Math.ceil(t.bitrate/1e5)}`;if(e)return`c${e.channels}${e.spatialRendering?"s":"n"}_${r}`}return""}function ax(){if(typeof matchMedia=="function"){const i=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(i.media!==e.media)return i.matches===!0}return!1}function ox(i,e){let t=!1,s=[];return i&&(t=i!=="SDR",s=[i]),e&&(s=e.allowedVideoRanges||Gd.slice(0),t=e.preferHDR!==void 0?e.preferHDR:ax(),t?s=s.filter(r=>r!=="SDR"):s=["SDR"]),{preferHDR:t,allowedVideoRanges:s}}function lx(i,e,t,s,r){const n=Object.keys(i),a=s==null?void 0:s.channels,o=s==null?void 0:s.audioCodec,l=a&&parseInt(a)===2;let d=!0,c=!1,u=1/0,h=1/0,f=1/0,m=0,p=[];const{preferHDR:g,allowedVideoRanges:v}=ox(e,r);for(let _=n.length;_--;){const S=i[n[_]];d=S.channels[2]>0,u=Math.min(u,S.minHeight),h=Math.min(h,S.minFramerate),f=Math.min(f,S.minBitrate);const A=v.filter(D=>S.videoRanges[D]>0);A.length>0&&(c=!0,p=A)}u=j(u)?u:0,h=j(h)?h:0;const y=Math.max(1080,u),b=Math.max(30,h);return f=j(f)?f:t,t=Math.max(f,t),c||(e=void 0,p=[]),{codecSet:n.reduce((_,S)=>{const A=i[S];if(S===_)return _;if(A.minBitrate>t)return $i(S,`min bitrate of ${A.minBitrate} > current estimate of ${t}`),_;if(!A.hasDefaultAudio)return $i(S,"no renditions with default or auto-select sound found"),_;if(o&&S.indexOf(o.substring(0,4))%5!==0)return $i(S,`audio codec preference "${o}" not found`),_;if(a&&!l){if(!A.channels[a])return $i(S,`no renditions with ${a} channel sound found (channels options: ${Object.keys(A.channels)})`),_}else if((!o||l)&&d&&A.channels[2]===0)return $i(S,"no renditions with stereo sound found"),_;return A.minHeight>y?($i(S,`min resolution of ${A.minHeight} > maximum of ${y}`),_):A.minFramerate>b?($i(S,`min framerate of ${A.minFramerate} > maximum of ${b}`),_):p.some(D=>A.videoRanges[D]>0)?A.maxScore<m?($i(S,`max score of ${A.maxScore} < selected max of ${m}`),_):_&&($d(S)>=$d(_)||A.fragmentError>i[_].fragmentError)?_:(m=A.maxScore,S):($i(S,`no variants with VIDEO-RANGE of ${JSON.stringify(p)} found`),_)},void 0),videoRanges:p,preferHDR:g,minFramerate:h,minBitrate:f}}function $i(i,e){R.log(`[abr] start candidates with "${i}" ignored because ${e}`)}function dx(i){return i.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 r=t.channels||"2";return s.channels[r]=(s.channels[r]||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 cx(i,e,t,s){return i.slice(t,s+1).reduce((r,n)=>{if(!n.codecSet)return r;const a=n.audioGroups;let o=r[n.codecSet];o||(r[n.codecSet]=o={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!a,fragmentError:0}),o.minBitrate=Math.min(o.minBitrate,n.bitrate);const l=Math.min(n.height,n.width);return o.minHeight=Math.min(o.minHeight,l),o.minFramerate=Math.min(o.minFramerate,n.frameRate),o.maxScore=Math.max(o.maxScore,n.score),o.fragmentError+=n.fragmentError,o.videoRanges[n.videoRange]=(o.videoRanges[n.videoRange]||0)+1,a&&a.forEach(d=>{if(!d)return;const c=e.groups[d];c&&(o.hasDefaultAudio=o.hasDefaultAudio||e.hasDefaultAudio?c.hasDefault:c.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(c.channels).forEach(u=>{o.channels[u]=(o.channels[u]||0)+c.channels[u]}))}),r},{})}function wi(i,e,t){if("attrs"in i){const s=e.indexOf(i);if(s!==-1)return s}for(let s=0;s<e.length;s++){const r=e[s];if(En(i,r,t))return s}return-1}function En(i,e,t){const{groupId:s,name:r,lang:n,assocLang:a,characteristics:o,default:l}=i,d=i.forced;return(s===void 0||e.groupId===s)&&(r===void 0||e.name===r)&&(n===void 0||e.lang===n)&&(n===void 0||e.assocLang===a)&&(l===void 0||e.default===l)&&(d===void 0||e.forced===d)&&(o===void 0||ux(o,e.characteristics))&&(t===void 0||t(i,e))}function ux(i,e=""){const t=i.split(","),s=e.split(",");return t.length===s.length&&!t.some(r=>s.indexOf(r)===-1)}function Mr(i,e){const{audioCodec:t,channels:s}=i;return(t===void 0||(e.audioCodec||"").substring(0,4)===t.substring(0,4))&&(s===void 0||s===(e.channels||"2"))}function hx(i,e,t,s,r){const n=e[s],o=e.reduce((h,f,m)=>{const p=f.uri;return(h[p]||(h[p]=[])).push(m),h},{})[n.uri];o.length>1&&(s=Math.max.apply(Math,o));const l=n.videoRange,d=n.frameRate,c=n.codecSet.substring(0,4),u=m0(e,s,h=>{if(h.videoRange!==l||h.frameRate!==d||h.codecSet.substring(0,4)!==c)return!1;const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return wi(i,m,r)>-1});return u>-1?u:m0(e,s,h=>{const f=h.audioGroups,m=t.filter(p=>!f||f.indexOf(p.groupId)!==-1);return wi(i,m,r)>-1})}function m0(i,e,t){for(let s=e;s;s--)if(t(i[s]))return s;for(let s=e+1;s<i.length;s++)if(t(i[s]))return s;return-1}class fx{constructor(e){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.bwEstimator=void 0,this._abandonRulesCheck=()=>{const{fragCurrent:t,partCurrent:s,hls:r}=this,{autoLevelEnabled:n,media:a}=r;if(!t||!a)return;const o=performance.now(),l=s?s.stats:t.stats,d=s?s.duration:t.duration,c=o-l.loading.start,u=r.minAutoLevel;if(l.aborted||l.loaded&&l.loaded===l.total||t.level<=u){this.clearTimer(),this._nextAutoLevel=-1;return}if(!n||a.paused||!a.playbackRate||!a.readyState)return;const h=r.mainForwardBufferInfo;if(h===null)return;const f=this.bwEstimator.getEstimateTTFB(),m=Math.abs(a.playbackRate);if(c<=Math.max(f,1e3*(d/(m*2))))return;const p=h.len/m,g=l.loading.first?l.loading.first-l.loading.start:-1,v=l.loaded&&g>-1,y=this.getBwEstimate(),b=r.levels,x=b[t.level],_=l.total||Math.max(l.loaded,Math.round(d*x.averageBitrate/8));let S=v?c-g:c;S<1&&v&&(S=Math.min(c,l.loaded*8/y));const A=v?l.loaded*1e3/S:0,D=A?(_-l.loaded)/A:_*8/y+f/1e3;if(D<=p)return;const O=A?A*8:y;let L=Number.POSITIVE_INFINITY,C;for(C=t.level-1;C>u;C--){const U=b[C].maxBitrate;if(L=this.getTimeToLoadFrag(f/1e3,O,d*U,!b[C].details),L<p)break}if(L>=D||L>d*10)return;r.nextLoadLevel=r.nextAutoLevel=C,v?this.bwEstimator.sample(c-Math.min(f,g),l.loaded):this.bwEstimator.sampleTTFB(c);const H=b[C].maxBitrate;this.getBwEstimate()*this.hls.config.abrBandWidthUpFactor>H&&this.resetEstimator(H),this.clearTimer(),R.warn(`[abr] Fragment ${t.sn}${s?" part "+s.index:""} of level ${t.level} is loading too slowly;
22
22
  Time to underbuffer: ${p.toFixed(3)} s
23
23
  Estimated load time for current fragment: ${D.toFixed(3)} s
24
24
  Estimated load time for down switch fragment: ${L.toFixed(3)} s
25
25
  TTFB estimate: ${g|0} ms
26
26
  Current BW estimate: ${j(y)?y|0:"Unknown"} bps
27
27
  New BW estimate: ${this.getBwEstimate()|0} bps
28
- Switching to level ${C} @ ${H|0} bps`),r.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:s,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(R.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new tx(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,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 r;this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r: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 M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:r,partCurrent:n}=this;if(s&&r&&s.sn===r.sn&&s.level===r.level){const a=performance.now(),o=n?n.stats:s.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){const u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(u,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,s,r){const n=e+s/t,a=r?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const s=this.hls.config,{loading:r}=t.stats,n=r.end-r.start;j(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:s}){const r=s?s.stats:t.stats;if(t.type===te.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const n=s?s.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){const n={stats:r,frag:t,part:s,id:t.type};this.onFragBuffered(E.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:s,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:s.stats;if(n.aborted||this.ignoreFragment(s))return;const a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==te.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(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(s,t,e,0,r,1,1);if(n>-1)return n;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return R.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,s=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!s||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=s&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:s}=this,{maxAutoLevel:r,config:n,minAutoLevel:a}=s,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay();let c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(d){const g=this.findBestLevel(l,a,r,d,0,c,u);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){const g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,R.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1)}const f=this.findBestLevel(l,a,r,d,h,c,u);if(R.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;const m=s.levels[a],p=s.levels[s.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a: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,r=e.mainForwardBufferInfo;return(r?r.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,s,r,n,a,o){var l;const d=r+n,c=this.lastLoadedFragLevel,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:v}=this.hls;if(m.length===1)return 0;const y=m[u],b=!!(y!=null&&(l=y.details)!=null&&l.live),x=g===-1||c===-1;let _,S="SDR",A=(y==null?void 0:y.frameRate)||0;const{audioPreference:D,videoPreference:O}=v,L=this.audioTracksByGroup||(this.audioTracksByGroup=lx(p));if(x){if(this.firstSelection!==-1)return this.firstSelection;const q=this.codecTiers||(this.codecTiers=dx(m,L,t,s)),Y=ox(q,S,e,D,O),{codecSet:oe,videoRanges:ae,minFramerate:G,minBitrate:F,preferHDR:re}=Y;_=oe,S=re?ae[ae.length-1]:ae[0],A=G,e=Math.max(e,F),R.log(`[abr] picked start tier ${JSON.stringify(Y)}`)}else _=y==null?void 0:y.codecSet,S=y==null?void 0:y.videoRange;const C=f?f.duration:h?h.duration:0,H=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let q=s;q>=t;q--){var Q;const Y=m[q],oe=q>u;if(!Y)continue;if(v.useMediaCapabilities&&!Y.supportedResult&&!Y.supportedPromise){const Ae=navigator.mediaCapabilities;typeof(Ae==null?void 0:Ae.decodingInfo)=="function"&&ix(Y,L,S,A,e,D)?(Y.supportedPromise=sx(Y,L,Ae),Y.supportedPromise.then(Ce=>{if(!this.hls)return;Y.supportedResult=Ce;const He=this.hls.levels,St=He.indexOf(Y);Ce.error?R.warn(`[abr] MediaCapabilities decodingInfo error: "${Ce.error}" for level ${St} ${JSON.stringify(Ce)}`):Ce.supported||(R.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${St} ${JSON.stringify(Ce)}`),St>-1&&He.length>1&&(R.log(`[abr] Removing unsupported level ${St}`),this.hls.removeLevel(St)))})):Y.supportedResult=Xv}if(_&&Y.codecSet!==_||S&&Y.videoRange!==S||oe&&A>Y.frameRate||!oe&&A>0&&A<Y.frameRate||Y.supportedResult&&!((Q=Y.supportedResult.decodingInfoResults)!=null&&Q[0].smooth)){U.push(q);continue}const ae=Y.details,G=(f?ae==null?void 0:ae.partTarget:ae==null?void 0:ae.averagetargetduration)||C;let F;oe?F=o*e:F=a*e;const re=C&&r>=C*2&&n===0?m[q].averageBitrate:m[q].maxBitrate,J=this.getTimeToLoadFrag(H,F,re*G,ae===void 0);if(F>=re&&(q===c||Y.loadError===0&&Y.fragmentError===0)&&(J<=H||!j(J)||b&&!this.bitrateTestDelay||J<d)){const Ae=this.forcedAutoLevel;return q!==g&&(Ae===-1||Ae!==g)&&(U.length&&R.trace(`[abr] Skipped level(s) ${U.join(",")} of ${s} max with CODECS and VIDEO-RANGE:"${m[U[0]].codecs}" ${m[U[0]].videoRange}; not compatible with "${y.codecs}" ${S}`),R.info(`[abr] switch candidate:${u}->${q} adjustedbw(${Math.round(F)})-bitrate=${Math.round(F-re)} ttfb:${H.toFixed(1)} avgDuration:${G.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${J.toFixed(1)} firstSelection:${x} codecSet:${_} videoRange:${S} hls.loadLevel:${g}`)),x&&(this.firstSelection=q),q}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:s}=this.hls,r=Math.min(Math.max(e,s),t);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}class fx{constructor(){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(){}}var rt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class mx{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.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const s=this.activePartLists[t];if(s)for(let r=s.length;r--;){const n=s[r];if(!n)break;const a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:s}=this,r=Object.keys(s);for(let n=r.length;n--;){const a=s[r[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){const o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,s,r){this.timeRanges&&(this.timeRanges[e]=t);const n=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===s&&this.removeFragment(o.body);return}const l=o.range[e];l&&l.time.some(d=>{const c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(e){const t=this.timeRanges,{frag:s,part:r}=e;if(!t||s.sn==="initSegment")return;const n=Or(s),a=this.fragments[n];if(!a||a.buffered&&s.gap)return;const o=!s.relurl;Object.keys(t).forEach(l=>{const d=s.elementaryStreams[l];if(!d)return;const c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(s,r,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=s.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),_o(a)||this.removeParts(s.sn-1,s.type)):this.removeFragment(a.body)}removeParts(e,t){const s=this.activePartLists[t];s&&(this.activePartLists[t]=s.filter(r=>r.fragment.sn>=e))}fragBuffered(e,t){const s=Or(e);let r=this.fragments[s];!r&&t&&(r=this.fragments[s]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(e,t,s,r){const n={time:[],partial:s},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<r.length;c++){const u=r.start(c)-this.bufferPadding,h=r.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<h&&o>u){const f=Math.max(a,r.start(c)),m=Math.min(o,r.end(c));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=u)break}return n}getPartialFragment(e){let t=null,s,r,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{const c=l[d];c&&_o(c)&&(r=c.body.start-o,n=c.body.end+o,e>=r&&e<=n&&(s=Math.min(e-r,n-e),a<=s&&(t=c.body,a=s)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||_o(t))}getState(e){const t=Or(e),s=this.fragments[t];return s?s.buffered?_o(s)?rt.PARTIAL:rt.OK:rt.APPENDING:rt.NOT_LOADED}isTimeBuffered(e,t,s){let r,n;for(let a=0;a<s.length;a++){if(r=s.start(a)-this.bufferPadding,n=s.end(a)+this.bufferPadding,e>=r&&t<=n)return!0;if(t<=r)return!1}return!1}onFragLoaded(e,t){const{frag:s,part:r}=t;if(s.sn==="initSegment"||s.bitrateTest)return;const n=r?null:t,a=Or(s);this.fragments[a]={body:s,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:s,part:r,timeRanges:n}=t;if(s.sn==="initSegment")return;const a=s.type;if(r){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(r)}this.timeRanges=n,Object.keys(n).forEach(o=>{const l=n[o];this.detectEvictedFragments(o,l,a,r)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Or(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,s,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==s||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=Or(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const s=this.activePartLists[e.type];if(s){const r=e.sn;this.activePartLists[e.type]=s.filter(n=>n.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function _o(i){var e,t,s;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((s=i.range.audiovideo)==null?void 0:s.partial))}function Or(i){return`${i.type}_${i.level}_${i.sn}`}const px={length:0,start:()=>0,end:()=>0};class Le{static isBuffered(e,t){try{if(e){const s=Le.getBuffered(e);for(let r=0;r<s.length;r++)if(t>=s.start(r)&&t<=s.end(r))return!0}}catch{}return!1}static bufferInfo(e,t,s){try{if(e){const r=Le.getBuffered(e),n=[];let a;for(a=0;a<r.length;a++)n.push({start:r.start(a),end:r.end(a)});return this.bufferedInfo(n,t,s)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,s){t=Math.max(0,t),e.sort(function(d,c){const u=d.start-c.start;return u||c.end-d.end});let r=[];if(s)for(let d=0;d<e.length;d++){const c=r.length;if(c){const u=r[c-1].end;e[d].start-u<s?e[d].end>u&&(r[c-1].end=e[d].end):r.push(e[d])}else r.push(e[d])}else r=e;let n=0,a,o=t,l=t;for(let d=0;d<r.length;d++){const c=r[d].start,u=r[d].end;if(t+s>=c&&t<u)o=c,l=u,n=l-t;else if(t+s<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return R.log("failed to get media.buffered",t),px}}}class pm{constructor(e,t,s,r=0,n=-1,a=!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=Ao(),this.buffering={audio:Ao(),video:Ao(),audiovideo:Ao()},this.level=e,this.sn=t,this.id=s,this.size=r,this.part=n,this.partial=a}}function Ao(){return{start:0,executeStart:0,executeEnd:0,end:0}}function sl(i,e){for(let s=0,r=i.length;s<r;s++){var t;if(((t=i[s])==null?void 0:t.cc)===e)return i[s]}return null}function gx(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function vx(i,e){const t=i.fragments,s=e.fragments;if(!s.length||!t.length){R.log("No fragments to align");return}const r=sl(t,s[0].cc);if(!r||r&&!r.startPTS){R.log("No frag in previous level to align on");return}return r}function p0(i,e){if(i){const t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Qv(i,e){const t=e.fragments;for(let s=0,r=t.length;s<r;s++)p0(t[s],i);e.fragmentHint&&p0(e.fragmentHint,i),e.alignedSliding=!0}function Ex(i,e,t){e&&(bx(i,t,e),!t.alignedSliding&&e&&Vd(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&qv(e,t))}function bx(i,e,t){if(gx(i,t,e)){const s=vx(t,e);s&&j(s.start)&&(R.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Qv(s.start,e))}}function Vd(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;const t=i.fragments,s=e.fragments;if(!t.length||!s.length)return;let r,n;const a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(r=sl(s,a),n=sl(t,a)),(!r||!n)&&(r=s[Math.floor(s.length/2)],n=sl(t,r.cc)||t[Math.floor(t.length/2)]);const o=r.programDateTime,l=n.programDateTime;if(!o||!l)return;const d=(l-o)/1e3-(n.start-r.start);Qv(d,i)}const g0=Math.pow(2,17);class yx{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 ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${s?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(E0(e));return}else e.gap=!1;const d=this.loader=e.loader=n?new n(r):new a(r),c=v0(e),u=h0(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:g0};e.stats=d.stats,d.load(c,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let v=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(v.slice(0,16)),v=v.slice(16)),o({frag:e,part:null,payload:v,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:dt({url:s,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,s){this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(E0(e,t));return}const d=this.loader=e.loader=n?new n(r):new a(r),c=v0(e,t),u=h0(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:g0};t.stats=d.stats,d.load(c,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const v={frag:e,part:t,payload:f.data,networkDetails:g};s(v),o(v)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:dt({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){const s=e.stats,r=t.stats,n=r.total;if(s.loaded+=r.loaded,n){const l=Math.round(e.duration/t.duration),d=Math.min(Math.round(s.loaded/n),l),u=(l-d)*Math.round(s.loaded/d);s.total=s.loaded+u}else s.total=Math.max(s.loaded,s.total);const a=s.loading,o=r.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function v0(i,e=null){const t=e||i,s={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(j(r)&&j(n)){var a;let o=r,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){const d=n-r;d%16&&(l=n+(16-d%16)),r!==0&&(s.resetIV=!0,o=r-16)}s.rangeStart=o,s.rangeEnd=l}return s}function E0(i,e){const t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),s={type:se.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(s.part=e),(e||i).stats.aborted=!0,new ji(s)}class ji extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class Tx{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class _x{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Ax(i){const e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ur(i,0,e-t):i}class Sx{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 r=0;r<4;r++)s[r]=t.getUint32(r*4);return s}initTable(){const e=this.sBox,t=this.invSBox,s=this.subMix,r=s[0],n=s[1],a=s[2],o=s[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256);let m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;const y=f[m],b=f[y],x=f[b];let _=f[v]*257^v*16843008;r[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=x*16843009^b*65537^y*257^m*16843008,d[v]=_<<24|_>>>8,c[v]=_<<16|_>>>16,u[v]=_<<8|_>>>24,h[v]=_,m?(m=y^f[f[f[x^y]]],p^=f[f[p]]):m=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let s=!0,r=0;for(;r<t.length&&s;)s=t[r]===this.key[r],r++;if(s)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],v=f[3];let y,b;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}b=y,o%n===0?(b=b<<8|b>>>24,b=u[b>>>24]<<24|u[b>>>16&255]<<16|u[b>>>8&255]<<8|u[b&255],b^=h[o/n|0]<<24):n>6&&o%n===4&&(b=u[b>>>24]<<24|u[b>>>16&255]<<16|u[b>>>8&255]<<8|u[b&255]),d[o]=y=(d[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?c[l]=b:c[l]=m[u[b>>>24]]^p[u[b>>>16&255]]^g[u[b>>>8&255]]^v[u[b&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,s){const r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(s);let f=h[0],m=h[1],p=h[2],g=h[3];const v=new Int32Array(e),y=new Int32Array(v.length);let b,x,_,S,A,D,O,L,C,H,U,Q,q,Y;const oe=this.networkToHostOrderSwap;for(;t<v.length;){for(C=oe(v[t]),H=oe(v[t+1]),U=oe(v[t+2]),Q=oe(v[t+3]),A=C^n[0],D=Q^n[1],O=U^n[2],L=H^n[3],q=4,Y=1;Y<r;Y++)b=l[A>>>24]^d[D>>16&255]^c[O>>8&255]^u[L&255]^n[q],x=l[D>>>24]^d[O>>16&255]^c[L>>8&255]^u[A&255]^n[q+1],_=l[O>>>24]^d[L>>16&255]^c[A>>8&255]^u[D&255]^n[q+2],S=l[L>>>24]^d[A>>16&255]^c[D>>8&255]^u[O&255]^n[q+3],A=b,D=x,O=_,L=S,q=q+4;b=a[A>>>24]<<24^a[D>>16&255]<<16^a[O>>8&255]<<8^a[L&255]^n[q],x=a[D>>>24]<<24^a[O>>16&255]<<16^a[L>>8&255]<<8^a[A&255]^n[q+1],_=a[O>>>24]<<24^a[L>>16&255]<<16^a[A>>8&255]<<8^a[D&255]^n[q+2],S=a[L>>>24]<<24^a[A>>16&255]<<16^a[D>>8&255]<<8^a[O&255]^n[q+3],y[t]=oe(b^f),y[t+1]=oe(S^m),y[t+2]=oe(_^p),y[t+3]=oe(x^g),f=C,m=H,p=U,g=Q,t=t+4}return y.buffer}}const xx=16;class gm{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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}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?Ax(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,s){return this.useSoftware?new Promise((r,n)=>{this.softwareDecrypt(new Uint8Array(e),t,s);const a=this.flush();a?r(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,s)}softwareDecrypt(e,t,s){const{currentIV:r,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Vt(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;r&&(s=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new Sx),l.expandKey(t);const d=n;return this.currentResult=l.decrypt(o.buffer,0,s),this.currentIV=ur(o,-16).buffer,d||null}webCryptoDecrypt(e,t,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,s));this.key=t,this.fastAesKey=new _x(this.subtle,t)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new Tx(this.subtle,new Uint8Array(s)).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(R.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,s)))}onWebCryptoError(e,t,s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,s);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const s=e.length-e.length%xx;return s!==e.length&&(t=ur(e,0,s),this.remainderData=ur(e,s)),t}logOnce(e){this.logEnabled&&(R.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const kx={toString:function(i){let e="";const t=i.length;for(let s=0;s<t;s++)e+=`[${i.start(s).toFixed(3)}-${i.end(s).toFixed(3)}]`;return e}},N={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 vm extends fx{constructor(e,t,s,r,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.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.loadedmetadata=!1,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.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=r,this.log=R.log.bind(R,`${r}:`),this.warn=R.warn.bind(R,`${r}:`),this.hls=e,this.fragmentLoader=new yx(e.config),this.keyLoader=s,this.fragmentTracker=t,this.config=e.config,this.decrypter=new gm(e.config),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){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=N.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const s=t.partList;if(s!=null&&s.length){const n=s[s.length-1];return Le.isBuffered(this.media,n.start+n.duration/2)}const r=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const s=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:s,mediaBuffer:r,state:n}=this,a=s?s.currentTime:0,o=Le.bufferInfo(r||s,a,e.maxBufferHole);if(this.log(`media seeking to ${j(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){const u=a>c;(a<d||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.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._loadFragForPlayback(e,t,s)}_loadFragForPlayback(e,t,s){const r=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,s,r).then(n=>{if(!n)return;const a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(E.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:s}=this;if(s.getState(e)===rt.APPENDING){const n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o))&&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)===rt.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)}flushMainBuffer(e,t,s=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:s};this.hls.trigger(E.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(s=>{if(!s||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:r}=this,{payload:n}=s,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw r.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const d=self.performance.now();return r.trigger(E.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),s.payload=l,this.completeInitSegmentLoad(s)})}return this.completeInitSegmentLoad(s)}).catch(s=>{this.state===N.STOPPED||this.state===N.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=N.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()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var s,r,n,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===te.MAIN?"level":"track"} ${e.level} (frag:[${((s=e.startPTS)!=null?s:NaN).toFixed(3)}-${((r=e.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${o?kx.toString(Le.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==te.SUBTITLE){const c=e.elementaryStreams;if(!Object.keys(c).some(u=>!!c[u])){this.state=N.IDLE;return}}const d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==te.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:s,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new pm(s.level,s.sn,s.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,s=null,r){var n;const a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(E.KEY_LOADED,c),this.state===N.KEY_LOADING&&(this.state=N.IDLE),c}),this.hls.trigger(E.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),s=Math.max(e.start,s||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const c=a.partList;if(c&&r){s>e.end&&a.fragmentHint&&(e=a.fragmentHint);const u=this.getNextPart(c,e,s);if(u>-1){const h=c[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${u}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,r)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,r).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:h,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,s))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),j(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;const l=this.config.progressive;let d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(e,r)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?r:void 0),o]).then(([c])=>(!l&&c&&r&&r(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,s,r){return new Promise((n,a)=>{var o;const l=[],d=(o=s.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,r).then(h=>{l[u.index]=h;const f=h.part;this.hls.trigger(E.FRAG_LOADED,h);const m=c0(s,e.sn,u.index+1)||Yv(d,e.sn,u.index+1);if(m)c(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:se.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}const{frag:s,part:r,level:n}=t,a=self.performance.now();s.stats.parsing.end=a,r&&(r.stats.parsing.end=a),this.updateLevelTiming(s,r,n,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:s}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${r}. The current chunk will not be buffered.`),null;const o=t[r],l=a>-1?c0(o,n,a):null,d=l?l.fragment:jS(o,n,s);return d?(s&&s!==d&&(d.stats=s.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,s,r,n){var a;if(!e||this.state!==N.PARSING)return;const{data1:o,data2:l}=e;let d=o;if(o&&l&&(d=Vt(o,l)),!((a=d)!=null&&a.length))return;const c={type:e.type,frag:t,part:s,chunkMeta:r,parent:t.type,data:d};if(this.hls.trigger(E.BUFFER_APPENDING,c),e.dropped&&e.independent&&!s){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Le.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const s=t.currentTime,r=Le.bufferInfo(t,s,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),s+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const s=this.getLoadPosition();return j(s)?this.getFwdBufferInfoAtPos(e,s,t):null}getFwdBufferInfoAtPos(e,t,s){const{config:{maxBufferHole:r}}=this,n=Le.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,s);if(a&&n.nextStart<a.end)return Le.bufferInfo(e,t,Math.max(n.nextStart,r))}return n}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){const t=this.config,s=e||t.maxBufferLength,r=t.maxMaxBufferLength/2;return r>=s?(t.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0):!1}getAppendedFrag(e,t=te.MAIN){const s=this.fragmentTracker.getAppendedFrag(e,te.MAIN);return s&&"fragment"in s?s.fragment:s}getNextFragment(e,t){const s=t.fragments,r=s.length;if(!r)return null;const{config:n}=this,a=s[0].start;let o;if(t.live){const l=n.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,s),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=s[0]);if(!o){const l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const s=this.fragmentTracker.getState(e);return(s===rt.OK||s===rt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,s,r,n){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&s.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,r);if(l!==null&&s.len+l.len>=n)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,s){let r=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){const d=e[o];if(a=a&&!d.independent,r>-1&&s<d.start)break;const c=d.loaded;c?r=-1:(n||d.independent||a)&&d.fragment===t&&(r=o),n=c}return r}loadedEndOfParts(e,t){const s=e[e.length-1];return s&&t>s.start&&s.loaded}getInitialLiveFragment(e,t){const s=this.fragPrevious;let r=null;if(s){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`),r=XS(t,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const n=s.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];s.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=JS(t,s.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,s){const{config:r}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=s;const{fragmentHint:l}=s,{maxFragLookUpTolerance:d}=r,c=s.partList,u=!!(r.lowLatencyMode&&c!=null&&c.length&&l);u&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){const f=e>t-d?0:d;h=Kd(n,a,e,f)}else h=a[a.length-1];if(h){const f=h.sn-s.startSN,m=this.fragmentTracker.getState(h);if((m===rt.OK||m===rt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn)&&n&&h.level===n.level){const g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==rt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){const{config:t,media:s}=this;if(!s)return;const r=this.hls.liveSyncPosition,n=s.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&s.duration>r&&(n<r||!l)){const d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&s.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=r),s.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),s.currentTime=r))}}alignPlaylists(e,t,s){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const n=e.fragments[0].start,a=!t,o=e.alignedSliding&&j(n);if(a||!o&&!n){const{fragPrevious:l}=this;Ex(l,s,e);const d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${r}`),d}return n}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;if(s<t&&(s=-1),s===-1||this.lastCurrentTime===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&j(n)?(s=t+n,n<0&&(s+=e.totalduration),s=Math.min(Math.max(t,s),t+e.totalduration),this.log(`Start time offset ${n} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${s}`),this.startPosition=s):e.live?s=this.hls.liveSyncPosition||t:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const c=this.getCurrentContext(t.chunkMeta);c&&(t.frag=c.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var r;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const n=t.details===M.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(s,!0);const a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===mt.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);const c=fm(d,l);this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${c}ms`),a.resolved=!0,this.retryDate=self.performance.now()+c,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==mt.RemoveAlternatePermanently&&(a.resolved=!0);else{R.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===mt.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){const t=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,t),r=s&&s.len>.5;r&&this.reduceMaxBufferLength(s.len);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===te.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,s){if(!e)return;const r=Le.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,s),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,s,r){var n;const a=s.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{const c=e.elementaryStreams[d];if(c){const u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||!1;const h=r?0:Vv(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(E.LEVEL_PTS_UPDATED,{details:a,level:s,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(s.fragmentError===0&&(s.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class Zv{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=Lx(e,t);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function Lx(i,e){const t=new Uint8Array(e);let s=0;for(let r=0;r<i.length;r++){const n=i[r];t.set(n,s),s+=n.length}return t}function Ix(){return typeof __HLS_WORKER_BUNDLE__=="function"}function Rx(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function wx(i){const e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ki(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Em{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,r){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=Vt(this.cachedData,e),this.cachedData=null);let s=Ya(e,0),r=s?s.length:0,n;const a=this._audioTrack,o=this._id3Track,l=s?hm(s):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&j(l))&&(this.basePTS=Cx(l,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:ei.audioId3,duration:Number.POSITIVE_INFINITY});r<d;){if(this.canParse(e,r)){const c=this.appendFrame(a,e,r);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r+=c.length,n=r):r=d}else JA(e,r)?(s=Ya(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ei.audioId3,duration:Number.POSITIVE_INFINITY}),r+=s.length,n=r):r++;if(r===d&&n!==d){const c=ur(e,n);this.cachedData?this.cachedData=Vt(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:ki(),id3Track:o,textTrack:ki()}}demuxSampleAes(e,t,s){return Promise.reject(new Error(`[${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:ki(),id3Track:this._id3Track,textTrack:ki()}}destroy(){}}const Cx=(i,e,t)=>{if(j(i))return i*90;const s=t?t.baseTime*9e4/t.timescale:0;return e*9e4+s};function Dx(i,e,t,s){let r,n,a,o;const l=navigator.userAgent.toLowerCase(),d=s,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((e[t+2]&192)>>>6)+1;const u=(e[t+2]&60)>>>2;if(u>c.length-1){const h=new Error(`invalid ADTS sampling index:${u}`);i.emit(E.ERROR,E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,R.log(`manifest codec:${s}, ADTS type:${r}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(r=5,o=new Array(4),n=u-3):(r=2,o=new Array(2),n=u):l.indexOf("android")!==-1?(r=2,o=new Array(2),n=u):(r=5,o=new Array(4),s&&(s.indexOf("mp4a.40.29")!==-1||s.indexOf("mp4a.40.5")!==-1)||!s&&u>=6?n=u-3:((s&&s.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!s&&a===1)&&(r=2,o=new Array(2)),n=u)),o[0]=r<<3,o[0]|=(u&14)>>1,o[1]|=(u&1)<<7,o[1]|=a<<3,r===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:c[u],channelCount:a,codec:"mp4a.40."+r,manifestCodec:d}}function Jv(i,e){return i[e]===255&&(i[e+1]&246)===240}function eE(i,e){return i[e+1]&1?7:9}function bm(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function Mx(i,e){return e+5<i.length}function qd(i,e){return e+1<i.length&&Jv(i,e)}function Ox(i,e){return Mx(i,e)&&Jv(i,e)&&bm(i,e)<=i.length-e}function Px(i,e){if(qd(i,e)){const t=eE(i,e);if(e+t>=i.length)return!1;const s=bm(i,e);if(s<=t)return!1;const r=e+s;return r===i.length||qd(i,r)}return!1}function tE(i,e,t,s,r){if(!i.samplerate){const n=Dx(e,t,s,r);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,R.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function iE(i){return 1024*9e4/i}function Nx(i,e){const t=eE(i,e);if(e+t<=i.length){const s=bm(i,e)-t;if(s>0)return{headerLength:t,frameLength:s}}}function sE(i,e,t,s,r){const n=iE(i.samplerate),a=s+r*n,o=Nx(e,t);let l;if(o){const{frameLength:u,headerLength:h}=o,f=h+u,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);const p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}const d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}let So=null;const Ux=[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],Fx=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],$x=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Bx=[0,1,1,4];function rE(i,e,t,s,r){if(t+24>e.length)return;const n=nE(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=s+r*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function nE(i,e){const t=i[e+1]>>3&3,s=i[e+1]>>1&3,r=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){const a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-s:s===3?3:4,d=Ux[l*14+r-1]*1e3,u=Fx[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=$x[t][s],m=Bx[s],p=f*8*m,g=Math.floor(f*d/u+a)*m;if(So===null){const b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);So=b?parseInt(b[1]):0}return!!So&&So<=87&&s===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:u,channelCount:h,frameLength:g,samplesPerFrame:p}}}function ym(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function aE(i,e){return e+1<i.length&&ym(i,e)}function Gx(i,e){return ym(i,e)&&4<=i.length-e}function oE(i,e){if(e+1<i.length&&ym(i,e)){const s=nE(i,e);let r=4;s!=null&&s.frameLength&&(r=s.frameLength);const n=e+r;return n===i.length||aE(i,n)}return!1}class Hx extends Em{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Ya(e,0);let s=(t==null?void 0:t.length)||0;if(oE(e,s))return!1;for(let r=e.length;s<r;s++)if(Px(e,s))return R.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Ox(e,t)}appendFrame(e,t,s){tE(e,this.observer,t,s,e.manifestCodec);const r=sE(e,t,s,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const Wx=/\/emsg[-/]ID3/i;class Kx{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,r){const n=this.videoTrack=ki("video",1),a=this.audioTrack=ki("audio",1),o=this.txtTrack=ki("text",1);if(this.id3Track=ki("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=Uv(e);if(l.video){const{id:d,timescale:c,codec:u}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u}if(l.audio){const{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=Ov.text,n.sampleDuration=0,n.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return lS(e)}demux(e,t){this.timeOffset=t;let s=e;const r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=Vt(this.remainderData,e));const o=gS(s);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=s;const a=this.extractID3Track(r,t);return n.samples=Vp(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,s=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(t,this.timeOffset);return s.samples=Vp(e,t),{videoTrack:t,audioTrack:ki(),id3Track:r,textTrack:ki()}}extractID3Track(e,t){const s=this.id3Track;if(e.samples.length){const r=le(e.samples,["emsg"]);r&&r.forEach(n=>{const a=bS(n);if(Wx.test(a.schemeIdUri)){const o=j(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const d=a.payload;s.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:ei.emsg,duration:l})}})}return s}demuxSampleAes(e,t,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const lE=(i,e)=>{let t=0,s=5;e+=s;const r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;s>0;){a[0]=i[e];const o=Math.min(s,8),l=8-o;n[0]=4278190080>>>24+l<<l,r[0]=(a[0]&n[0])>>l,t=t?t<<o|r[0]:r[0],e+=1,s-=o}return t};class Vx extends Em{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,s){const r=dE(e,t,s,this.basePTS,this.frameIndex);if(r!==-1)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;const t=Ya(e,0);if(!t)return!1;const s=t.length;return e[s]===11&&e[s+1]===119&&hm(t)!==void 0&&lE(e,s)<16}}function dE(i,e,t,s,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],l=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][l*3+n]*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,p=[2,1,2,3,3,4,4,5][u]+f,g=e[t+5]>>3,v=e[t+5]&7,y=new Uint8Array([n<<6|g<<1|v>>2,(v&3)<<6|u<<3|f<<2|l>>4,l<<4&224]),b=1536/o*9e4,x=s+r*b,_=e.subarray(t,t+c);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:_,pts:x}),c}class qx{constructor(){this.VideoSample=null}createVideoSample(e,t,s,r){return{key:e,frame:!1,pts:t,dts:s,units:[],debug:r,length:0}}getLastNalUnit(e){var t;let s=this.VideoSample,r;if((!s||s.units.length===0)&&(s=e[e.length-1]),(t=s)!=null&&t.units){const n=s.units;r=n[n.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const s=t.samples,r=s.length;if(r){const n=s[r-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&R.log(e.pts+"/"+e.dts+":"+e.debug)}}class b0{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,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(s,s+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}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&&R.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)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)}skipScalingList(e){let t=8,s=8,r;for(let n=0;n<e;n++)s!==0&&(r=this.readEG(),s=(t+r+256)%256),t=s===0?t:s}readSPS(){let e=0,t=0,s=0,r=0,n,a,o;const l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();const g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){const S=c();if(S===3&&h(1),m(),m(),h(1),u())for(a=S!==3?8:12,o=0;o<a;o++)u()&&(o<6?p(16):p(64))}m();const v=c();if(v===0)c();else if(v===1)for(h(1),f(),f(),n=c(),o=0;o<n;o++)f();m(),h(1);const y=c(),b=c(),x=d(1);x===0&&h(1),h(1),u()&&(e=c(),t=c(),s=c(),r=c());let _=[1,1];if(u()&&u())switch(l()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:{_=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-x)*(b+1)*16-(x?2:4)*(s+r),pixelRatio:_}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class Yx extends qx{parseAVCPES(e,t,s,r,n){const a=this.parseAVCNALu(e,s.data);let o=this.VideoSample,l,d=!1;s.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"")),a.forEach(c=>{var u;switch(c.type){case 1:{let p=!1;l=!0;const g=c.data;if(d&&g.length>4){const v=new b0(g).readSliceType();(v===2||v===4||v===7||v===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(u=o)!=null&&u.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,$v(c.data,1,s.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;const p=c.data,v=new b0(p).readSPS();if(!e.sps||e.width!==v.width||e.height!==v.height||((f=e.pixelRatio)==null?void 0:f[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[p],e.duration=n;const y=p.subarray(1,4);let b="avc1.";for(let x=0;x<3;x++){let _=y[x].toString(16);_.length<2&&(_="0"+_),b+=_}e.codec=b}break}case 8:l=!0,e.pps=[c.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+c.type+" ");break}o&&l&&o.units.push(c)}),r&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const s=t.byteLength;let r=e.naluState||0;const n=r,a=[];let o=0,l,d,c,u=-1,h=0;for(r===-1&&(u=0,h=t[0]&31,r=0,o=1);o<s;){if(l=t[o++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(d=o-r-1,u>=0){const f={data:t.subarray(u,d),type:h};a.push(f)}else{const f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Vt(f.data,t.subarray(0,d)),f.state=0))}o<s?(c=t[o]&31,u=o,h=c,r=0):r=-1}else r=0}if(u>=0&&r>=0){const f={data:t.subarray(u,s),type:h,state:r};a.push(f)}if(a.length===0){const f=this.getLastNalUnit(e.samples);f&&(f.data=Vt(f.data,t))}return e.naluState=r,a}}class jx{constructor(e,t,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new gm(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,s){const r=e[t].unit;if(r.length<=16)return;const n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,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 r=0;for(let n=32;n<e.length-16;n+=160,r+=16)s.set(e.subarray(n,n+16),r);return s}getAvcDecryptedUnit(e,t){const s=new Uint8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(s.subarray(r,r+16),n);return e}decryptAvcSample(e,t,s,r,n){const a=Bv(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,s+1,r)})}decryptAvcSamples(e,t,s,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,s=0){if(t>=e.length){r();return}const n=e[t].units;for(;!(s>=n.length);s++){const a=n[s];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,s,r,a),!this.decrypter.isSync()))return}}}}const Je=188;class ms{constructor(e,t,s){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._duration=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.videoParser=new Yx}static probe(e){const t=ms.syncOffset(e);return t>0&&R.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let s=Math.min(Je*5,t-Je)+1,r=0;for(;r<s;){let n=!1,a=-1,o=0;for(let l=r;l<t;l+=Je)if(e[l]===71&&(t-l===Je||e[l+Je]===71)){if(o++,a===-1&&(a=l,a!==0&&(s=Math.min(a+Je*99,e.length-Je)+1)),n||(n=th(e,l)===0),n&&o>1&&(a===0&&o>2||l+Je>s))return a}else{if(o)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Ov[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,s,r){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=ms.createTrack("video"),this._audioTrack=ms.createTrack("audio",r),this._id3Track=ms.createTrack("id3"),this._txtTrack=ms.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=s,this._duration=r}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,r=!1){s||(this.sampleAes=null);let n;const a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack;let c=a.pid,u=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,v=this.pmtParsed,y=this._pmtId,b=e.length;if(this.remainderData&&(e=Vt(this.remainderData,e),b=e.length,this.remainderData=null),b<Je&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};const x=Math.max(0,ms.syncOffset(e));b-=(b-x)%Je,b<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let _=0;for(let A=x;A<b;A+=Je)if(e[A]===71){const D=!!(e[A+1]&64),O=th(e,A),L=(e[A+3]&48)>>4;let C;if(L>1){if(C=A+5+e[A+4],C===A+Je)continue}else C=A+4;switch(O){case c:D&&(u&&(n=Pr(u))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),u={data:[],size:0}),u&&(u.data.push(e.subarray(C,A+Je)),u.size+=A+Je-C);break;case h:if(D){if(m&&(n=Pr(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,A+Je)),m.size+=A+Je-C);break;case f:D&&(p&&(n=Pr(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,A+Je)),p.size+=A+Je-C);break;case 0:D&&(C+=e[C]+1),y=this._pmtId=zx(e,C);break;case y:{D&&(C+=e[C]+1);const H=Xx(e,C,this.typeSupported,s,this.observer);c=H.videoPid,c>0&&(a.pid=c,a.segmentCodec=H.segmentVideoCodec),h=H.audioPid,h>0&&(o.pid=h,o.segmentCodec=H.segmentAudioCodec),f=H.id3Pid,f>0&&(l.pid=f),g!==null&&!v&&(R.warn(`MPEG-TS PMT found at ${A} after unknown PID '${g}'. Backtracking to sync byte @${x} to parse all TS packets.`),g=null,A=x-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=O;break}}else _++;_>0&&Yd(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`)),a.pesData=u,o.pesData=m,l.pesData=p;const S={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return r&&this.extractRemainingSamples(S),S}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:r,textTrack:n}=e,a=s.pesData,o=t.pesData,l=r.pesData;let d;if(a&&(d=Pr(a))?(this.videoParser.parseAVCPES(s,n,d,!0,this._duration),s.pesData=null):s.pesData=a,o&&(d=Pr(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Pr(l))?(this.parseID3PES(r,d),r.pesData=null):r.pesData=l}demuxSampleAes(e,t,s){const r=this.demux(e,s,!0,!this.config.progressive),n=this.sampleAes=new jx(this.observer,this.config,t);return this.decrypt(r,n)}decrypt(e,t){return new Promise(s=>{const{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{s(e)}):s(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{s(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let s=0;const r=this.aacOverFlow;let n=t.data;if(r){this.aacOverFlow=null;const u=r.missing,h=r.sample.unit.byteLength;if(u===-1)n=Vt(r.sample.unit,n);else{const f=h-u;r.sample.unit.set(n.subarray(0,u),f),e.samples.push(r.sample),s=r.missing}}let a,o;for(a=s,o=n.length;a<o-1&&!qd(n,a);a++);if(a!==s){let u;const h=a<o-1;if(h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES",Yd(this.observer,new Error(u),h),!h)return}tE(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){const u=iE(e.samplerate);l=r.sample.pts+u}else{R.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=sE(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!qd(n,a);a++);}parseMPEGPES(e,t){const s=t.data,r=s.length;let n=0,a=0;const o=t.pts;if(o===void 0){R.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(aE(s,a)){const l=rE(e,s,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{const s=t.data,r=t.pts;if(r===void 0){R.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=s.length;let a=0,o=0,l;for(;o<n&&(l=dE(e,s,o,r,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){R.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=Ke({},t,{type:this._videoTrack?ei.emsg:ei.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(s)}}function th(i,e){return((i[e+1]&31)<<8)+i[e+2]}function zx(i,e){return(i[e+10]&31)<<8|i[e+11]}function Xx(i,e,t,s,r){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){const d=th(i,e),c=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!s){su("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!s){su("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?R.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!s){su("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):R.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&c>0){let u=e+5,h=c;for(;h>2;){switch(i[u]){case 106:t.ac3!==!0?R.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}const m=i[u+1]+2;u+=m,h-=m}}break;case 194:case 135:return Yd(r,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return Yd(r,new Error("Unsupported HEVC in M2TS found")),n}e+=c+5}return n}function Yd(i,e,t){R.warn(`parsing error: ${e.message}`),i.emit(E.ERROR,E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function su(i){R.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function Pr(i){let e=0,t,s,r,n,a;const o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Vt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(s=(t[4]<<8)+t[5],s&&s>i.size-6)return null;const d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(R.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),r=t[8];let c=r+9;if(i.size<=c)return null;i.size-=c;const u=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(c)if(c>m){c-=m;continue}else t=t.subarray(c),m-=c,c=0;u.set(t,e),e+=m}return s&&(s-=r+3),{data:u,pts:n,dts:a,len:s}}return null}class Qx extends Em{resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Ya(e,0);let s=(t==null?void 0:t.length)||0;if(t&&e[s]===11&&e[s+1]===119&&hm(t)!==void 0&&lE(e,s)<=16)return!1;for(let r=e.length;s<r;s++)if(oE(e,s))return R.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Gx(e,t)}appendFrame(e,t,s){if(this.basePTS!==null)return rE(e,t,s,this.basePTS,this.frameIndex)}}class y0{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 is=Math.pow(2,32)-1;class w{static init(){w.types={avc1:[],avcC:[],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 w.types)w.types.hasOwnProperty(e)&&(w.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]);w.HDLR_TYPES={video:t,audio:s};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);w.STTS=w.STSC=w.STCO=n,w.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),w.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),w.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),w.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);w.FTYP=w.box(w.types.ftyp,a,l,a,o),w.DINF=w.box(w.types.dinf,w.box(w.types.dref,r))}static box(e,...t){let s=8,r=t.length;const n=r;for(;r--;)s+=t[r].byteLength;const a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=s&255,a.set(e,4),r=0,s=8;r<n;r++)a.set(t[r],s),s+=t[r].byteLength;return a}static hdlr(e){return w.box(w.types.hdlr,w.HDLR_TYPES[e])}static mdat(e){return w.box(w.types.mdat,e)}static mdhd(e,t){t*=e;const s=Math.floor(t/(is+1)),r=Math.floor(t%(is+1));return w.box(w.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,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return w.box(w.types.mdia,w.mdhd(e.timescale,e.duration),w.hdlr(e.type),w.minf(e))}static mfhd(e){return w.box(w.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"?w.box(w.types.minf,w.box(w.types.smhd,w.SMHD),w.DINF,w.stbl(e)):w.box(w.types.minf,w.box(w.types.vmhd,w.VMHD),w.DINF,w.stbl(e))}static moof(e,t,s){return w.box(w.types.moof,w.mfhd(e),w.traf(s,t))}static moov(e){let t=e.length;const s=[];for(;t--;)s[t]=w.trak(e[t]);return w.box.apply(null,[w.types.moov,w.mvhd(e[0].timescale,e[0].duration)].concat(s).concat(w.mvex(e)))}static mvex(e){let t=e.length;const s=[];for(;t--;)s[t]=w.trex(e[t]);return w.box.apply(null,[w.types.mvex,...s])}static mvhd(e,t){t*=e;const s=Math.floor(t/(is+1)),r=Math.floor(t%(is+1)),n=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,r>>24,r>>16&255,r>>8&255,r&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 w.box(w.types.mvhd,n)}static sdtp(e){const t=e.samples||[],s=new Uint8Array(4+t.length);let r,n;for(r=0;r<t.length;r++)n=t[r].flags,s[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return w.box(w.types.sdtp,s)}static stbl(e){return w.box(w.types.stbl,w.stsd(e),w.box(w.types.stts,w.STTS),w.box(w.types.stsc,w.STSC),w.box(w.types.stsz,w.STSZ),w.box(w.types.stco,w.STCO))}static avc1(e){let t=[],s=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,s.push(a>>>8&255),s.push(a&255),s=s.concat(Array.prototype.slice.call(n));const o=w.box(w.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(s))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return w.box(w.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,l>>8&255,l&255,d>>8&255,d&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,w.box(w.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),w.box(w.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.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return w.box(w.types.mp4a,w.audioStsd(e),w.box(w.types.esds,w.esds(e)))}static mp3(e){return w.box(w.types[".mp3"],w.audioStsd(e))}static ac3(e){return w.box(w.types["ac-3"],w.audioStsd(e),w.box(w.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?w.box(w.types.stsd,w.STSD,w.mp3(e)):e.segmentCodec==="ac3"?w.box(w.types.stsd,w.STSD,w.ac3(e)):w.box(w.types.stsd,w.STSD,w.mp4a(e)):w.box(w.types.stsd,w.STSD,w.avc1(e))}static tkhd(e){const t=e.id,s=e.duration*e.timescale,r=e.width,n=e.height,a=Math.floor(s/(is+1)),o=Math.floor(s%(is+1));return w.box(w.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,a>>24,a>>16&255,a>>8&255,a&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,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const s=w.sdtp(e),r=e.id,n=Math.floor(t/(is+1)),a=Math.floor(t%(is+1));return w.box(w.types.traf,w.box(w.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),w.box(w.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),w.trun(e,s.length+16+20+8+16+8+8),s)}static trak(e){return e.duration=e.duration||4294967295,w.box(w.types.trak,w.tkhd(e),w.mdia(e))}static trex(e){const t=e.id;return w.box(w.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||[],r=s.length,n=12+16*r,a=new Uint8Array(n);let o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=s[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&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 w.box(w.types.trun,a)}static initSegment(e){w.types||w.init();const t=w.moov(e);return Vt(w.FTYP,t)}}w.types=void 0;w.HDLR_TYPES=void 0;w.STTS=void 0;w.STSC=void 0;w.STCO=void 0;w.STSZ=void 0;w.VMHD=void 0;w.SMHD=void 0;w.STSD=void 0;w.FTYP=void 0;w.DINF=void 0;const cE=9e4;function Tm(i,e,t=1,s=!1){const r=i*e*t;return s?Math.round(r):r}function Zx(i,e,t=1,s=!1){return Tm(i,e,1/t,s)}function Vn(i,e=!1){return Tm(i,1e3,1/cE,e)}function Jx(i,e=1){return Tm(i,cE,1/e)}const ek=10*1e3,T0=1024,tk=1152,ik=1536;let Nr=null,ru=null;class rl{constructor(e,t,s,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=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,Nr===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Nr=a?parseInt(a[1]):0}if(ru===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);ru=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const s=e.reduce((r,n)=>{const a=n.pts-r;return a<-4294967296?(t=!0,Kt(r,n.pts)):a>0?r:n.pts},e[0].pts);return t&&R.debug("PTS rollover detected"),s}remux(e,t,s,r,n,a,o,l){let d,c,u,h,f,m,p=n,g=n;const v=e.pid>-1,y=t.pid>-1,b=t.samples.length,x=e.samples.length>0,_=o&&b>0||b>1;if((!v||x)&&(!y||_)||this.ISGenerated||o){if(this.ISGenerated){var A,D,O,L;const Q=this.videoTrackConfig;Q&&(t.width!==Q.width||t.height!==Q.height||((A=t.pixelRatio)==null?void 0:A[0])!==((D=Q.pixelRatio)==null?void 0:D[0])||((O=t.pixelRatio)==null?void 0:O[1])!==((L=Q.pixelRatio)==null?void 0:L[1]))&&this.resetInitSegment()}else u=this.generateIS(e,t,n,a);const C=this.isVideoContiguous;let H=-1,U;if(_&&(H=sk(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,H>0){R.warn(`[mp4-remuxer]: Dropped ${H} out of ${b} video samples due to a missing keyframe`);const Q=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(H),t.dropped+=H,g+=(t.samples[0].pts-Q)/t.inputTimeScale,U=g}else H===-1&&(R.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),m=!1);if(this.ISGenerated){if(x&&_){const Q=this.getVideoStartPts(t.samples),Y=(Kt(e.samples[0].pts,Q)-Q)/t.inputTimeScale;p+=Math.max(0,Y),g+=Math.max(0,-Y)}if(x){if(e.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,p,this.isAudioContiguous,a,y||_||l===te.AUDIO?g:void 0),_){const Q=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,C,Q)}}else _&&(d=this.remuxVideo(t,g,C,0));d&&(d.firstKeyFrame=H,d.independent=H!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(f=uE(s,n,this._initPTS,this._initDTS)),r.samples.length&&(h=hE(r,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:m,text:h,id3:f}}generateIS(e,t,s,r){const n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS;let c=!d||r,u="audio/mp4",h,f,m;if(c&&(h=f=1/0),e.config&&n.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}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):w.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*s):c=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:w.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(m=t.inputTimeScale,!d||m!==d.timescale){const p=this.getVideoStartPts(a),g=Math.round(m*s);f=Math.min(f,Kt(a[0].dts,p)-g),h=Math.min(h,p-g)}else c=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,s,r){const n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS;let c=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!s||c===null){const G=t*n,F=a[0].pts-Kt(a[0].dts,a[0].pts);Nr&&c!==null&&Math.abs(G-F-c)<15e3?s=!0:c=G-F}const y=d.baseTime*n/d.timescale;for(let G=0;G<l;G++){const F=a[G];F.pts=Kt(F.pts-y,c),F.dts=Kt(F.dts-y,c),F.dts<a[G>0?G-1:G].dts&&(v=!0)}v&&a.sort(function(G,F){const re=G.dts-F.dts,J=G.pts-F.pts;return re||J}),f=a[0].dts,m=a[a.length-1].dts;const b=m-f,x=b?Math.round(b/(l-1)):h||e.inputTimeScale/30;if(s){const G=f-c,F=G>x,re=G<-1;if((F||re)&&(F?R.warn(`AVC: ${Vn(G,!0)} ms (${G}dts) hole between fragments detected at ${t.toFixed(3)}`):R.warn(`AVC: ${Vn(-G,!0)} ms (${G}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!re||c>=a[0].pts||Nr)){f=c;const J=a[0].pts-G;if(F)a[0].dts=f,a[0].pts=J;else for(let de=0;de<a.length&&!(a[de].dts>J);de++)a[de].dts-=G,a[de].pts-=G;R.log(`Video: Initial PTS/DTS adjusted: ${Vn(J,!0)}/${Vn(f,!0)}, delta: ${Vn(G,!0)} ms`)}}f=Math.max(0,f);let _=0,S=0,A=f;for(let G=0;G<l;G++){const F=a[G],re=F.units,J=re.length;let de=0;for(let Ae=0;Ae<J;Ae++)de+=re[Ae].data.length;S+=de,_+=J,F.length=de,F.dts<A?(F.dts=A,A+=x/4|0||1):A=F.dts,p=Math.min(F.pts,p),g=Math.max(F.pts,g)}m=a[l-1].dts;const D=S+4*_+8;let O;try{O=new Uint8Array(D)}catch(G){this.observer.emit(E.ERROR,E.ERROR,{type:se.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:G,bytes:D,reason:`fail allocating video mdat ${D}`});return}const L=new DataView(O.buffer);L.setUint32(0,D),O.set(w.types.mdat,4);let C=!1,H=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,q=Number.NEGATIVE_INFINITY;for(let G=0;G<l;G++){const F=a[G],re=F.units;let J=0;for(let Ce=0,He=re.length;Ce<He;Ce++){const St=re[Ce],ts=St.data,wr=St.data.byteLength;L.setUint32(u,wr),u+=4,O.set(ts,u),u+=wr,J+=4+wr}let de;if(G<l-1)h=a[G+1].dts-F.dts,de=a[G+1].pts-F.pts;else{const Ce=this.config,He=G>0?F.dts-a[G-1].dts:x;if(de=G>0?F.pts-a[G-1].pts:x,Ce.stretchShortVideoTrack&&this.nextAudioPts!==null){const St=Math.floor(Ce.maxBufferHole*n),ts=(r?p+r*n:this.nextAudioPts)-F.pts;ts>St?(h=ts-He,h<0?h=He:C=!0,R.log(`[mp4-remuxer]: It is approximately ${ts/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=He}else h=He}const Ae=Math.round(F.pts-F.dts);H=Math.min(H,h),Q=Math.max(Q,h),U=Math.min(U,de),q=Math.max(q,de),o.push(new _0(F.key,h,J,Ae))}if(o.length){if(Nr){if(Nr<70){const G=o[0].flags;G.dependsOn=2,G.isNonSync=0}}else if(ru&&q-U<Q-H&&x/Q<.025&&o[0].cts===0){R.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let G=f;for(let F=0,re=o.length;F<re;F++){const J=G+o[F].duration,de=G+o[F].cts;if(F<re-1){const Ae=J+o[F+1].cts;o[F].duration=Ae-de}else o[F].duration=F?o[F-1].duration:x;o[F].cts=0,G=J}}}h=C||!h?x:h,this.nextAvcDts=c=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;const ae={data1:w.moof(e.sequenceNumber++,f,Ke({},e,{samples:o})),data2:O,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:c/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ae}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return tk;case"ac3":return ik;default:return T0}}remuxAudio(e,t,s,r,n){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0;let p=e.samples,g=h?0:8,v=this.nextAudioPts||-1;const y=t*a,b=u.baseTime*a/u.timescale;if(this.isAudioContiguous=s=s||p.length&&v>0&&(r&&Math.abs(y-v)<9e3||Math.abs(Kt(p[0].pts-b,y)-v)<20*c),p.forEach(function(Y){Y.pts=Kt(Y.pts-b,y)}),!s||v<0){if(p=p.filter(Y=>Y.pts>=0),!p.length)return;n===0?v=0:r&&!m?v=Math.max(0,y):v=p[0].pts}if(e.segmentCodec==="aac"){const Y=this.config.maxAudioFramesDrift;for(let oe=0,ae=v;oe<p.length;oe++){const G=p[oe],F=G.pts,re=F-ae,J=Math.abs(1e3*re/a);if(re<=-Y*c&&m)oe===0&&(R.warn(`Audio frame @ ${(F/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*re/a)} ms.`),this.nextAudioPts=v=ae=F);else if(re>=Y*c&&J<ek&&m){let de=Math.round(re/c);ae=F-de*c,ae<0&&(de--,ae+=c),oe===0&&(this.nextAudioPts=v=ae),R.warn(`[mp4-remuxer]: Injecting ${de} audio frame @ ${(ae/a).toFixed(3)}s due to ${Math.round(1e3*re/a)} ms gap.`);for(let Ae=0;Ae<de;Ae++){const Ce=Math.max(ae,0);let He=y0.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);He||(R.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),He=G.unit.subarray()),p.splice(oe,0,{unit:He,pts:Ce}),ae+=c,oe++}}G.pts=ae,ae+=c}}let x=null,_=null,S,A=0,D=p.length;for(;D--;)A+=p[D].unit.byteLength;for(let Y=0,oe=p.length;Y<oe;Y++){const ae=p[Y],G=ae.unit;let F=ae.pts;if(_!==null){const J=f[Y-1];J.duration=Math.round((F-_)/l)}else if(s&&e.segmentCodec==="aac"&&(F=v),x=F,A>0){A+=g;try{S=new Uint8Array(A)}catch(J){this.observer.emit(E.ERROR,E.ERROR,{type:se.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:A,reason:`fail allocating audio mdat ${A}`});return}h||(new DataView(S.buffer).setUint32(0,A),S.set(w.types.mdat,4))}else return;S.set(G,g);const re=G.byteLength;g+=re,f.push(new _0(!0,d,re,0)),_=F}const O=f.length;if(!O)return;const L=f[f.length-1];this.nextAudioPts=v=_+l*L.duration;const C=h?new Uint8Array(0):w.moof(e.sequenceNumber++,x/l,Ke({},e,{samples:f}));e.samples=[];const H=x/a,U=v/a,q={data1:C,data2:S,startPTS:H,endPTS:U,startDTS:H,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,q}remuxEmptyAudio(e,t,s,r){const n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,u=(l!==null?l:r.startDTS*n)+c,h=r.endDTS*n+c,f=o*T0,m=Math.ceil((h-u)/f),p=y0.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),!p){R.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const g=[];for(let v=0;v<m;v++){const y=u+v*f;g.push({unit:p,pts:y,dts:y})}return e.samples=g,this.remuxAudio(e,t,s,!1)}}function Kt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function sk(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function uE(i,e,t,s){const r=i.samples.length;if(!r)return;const n=i.inputTimeScale;for(let o=0;o<r;o++){const l=i.samples[o];l.pts=Kt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Kt(l.dts-s.baseTime*n/s.timescale,e*n)/n}const a=i.samples;return i.samples=[],{samples:a}}function hE(i,e,t){const s=i.samples.length;if(!s)return;const r=i.inputTimeScale;for(let a=0;a<s;a++){const o=i.samples[a];o.pts=Kt(o.pts-t.baseTime*r/t.timescale,e*r)/r}i.samples.sort((a,o)=>a.pts-o.pts);const n=i.samples;return i.samples=[],{samples:n}}class _0{constructor(e,t,s,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=s,this.cts=r,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class rk{constructor(){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}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,s,r){this.audioCodec=t,this.videoCodec=s,this.generateInitSegment(uS(e,r)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const r=this.initData=Uv(e);r.audio&&(t=A0(r.audio,be.AUDIO)),r.video&&(s=A0(r.video,be.VIDEO));const n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+s,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:s,initSegment:e,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,s,r,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:r,id3:s,initSegment:void 0};j(c)||(c=this.lastEndTime=n||0);const h=t.samples;if(!(h!=null&&h.length))return u;const f={initPTS:void 0,timescale:1};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const p=fS(h,m),g=hS(m,h),v=g===null?n:g;(nk(d,v,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=v-n,d&&d.timescale===1&&R.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});const y=e?v-d.baseTime/d.timescale:c,b=y+p;pS(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=b:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!m.audio,_=!!m.video;let S="";x&&(S+="audio"),_&&(S+="video");const A={data1:h,startPTS:y,startDTS:y,endPTS:b,endDTS:b,type:S,hasAudio:x,hasVideo:_,nb:1,dropped:0};return u.audio=A.type==="audio"?A:void 0,u.video=A.type!=="audio"?A:void 0,u.initSegment=f,u.id3=uE(s,n,d,d),r.samples.length&&(u.text=hE(r,n,d)),u}}function nk(i,e,t,s){if(i===null)return!0;const r=Math.max(s,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>r}function A0(i,e){const t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===be.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Bd(t,!1);const s="mp4a.40.5";return R.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${s}"`),s}return R.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}let zi;try{zi=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),zi=Rn==null?void 0:Rn.Date.now}const nl=[{demux:Kx,remux:rk},{demux:ms,remux:rl},{demux:Hx,remux:rl},{demux:Qx,remux:rl}];nl.splice(2,0,{demux:Vx,remux:rl});class S0{constructor(e,t,s,r,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=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.vendor=r,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,r){const n=s.transmuxing;n.executeStart=zi();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);const{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=r||o,{audioCodec:p,videoCodec:g,defaultInitPts:v,duration:y,initSegmentData:b}=l,x=ak(a,t);if(x&&x.method==="AES-128"){const D=this.getDecrypter();if(D.isSync()){let O=D.softwareDecrypt(a,x.key.buffer,x.iv.buffer);if(s.part>-1&&(O=D.flush()),!O)return n.executeEnd=zi(),nu(s);a=new Uint8Array(O)}else return this.decryptionPromise=D.webCryptoDecrypt(a,x.key.buffer,x.iv.buffer).then(O=>{const L=this.push(O,null,s);return this.decryptionPromise=null,L}),this.decryptionPromise}const _=this.needsProbing(c,u);if(_){const D=this.configureTransmuxer(a);if(D)return R.warn(`[transmuxer] ${D.message}`),this.observer.emit(E.ERROR,E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),n.executeEnd=zi(),nu(s)}(c||u||m||_)&&this.resetInitSegment(b,p,g,y,t),(c||m||_)&&this.resetInitialTimestamp(v),d||this.resetContiguity();const S=this.transmux(a,x,f,h,s),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,n.executeEnd=zi(),S}flush(e){const t=e.transmuxing;t.executeStart=zi();const{decrypter:s,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));const a=[],{timeOffset:o}=r;if(s){const u=s.flush();u&&a.push(this.push(u,null,e))}const{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=zi(),[nu(e)];const c=l.flush(o);return al(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,s){const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;R.log(`[transmuxer.ts]: Flushed fragment ${s.sn}${s.part>-1?" p: "+s.part:""} of level ${s.level}`);const c=this.remuxer.remux(r,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:s}),s.transmuxing.executeEnd=zi()}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,r,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,s,r),o.resetInitSegment(e,t,s,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,s,r,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,s,r,n):a=this.transmuxUnencrypted(e,s,r,n),a}transmuxUnencrypted(e,t,s,r){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,s,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,s,r,n){return this.demuxer.demuxSampleAes(e,t,s).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,s,r,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:s,typeSupported:r,vendor:n}=this;let a;for(let h=0,f=nl.length;h<f;h++){var o;if((o=nl[h].demux)!=null&&o.probe(e)){a=nl[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,d=this.remuxer,c=a.remux,u=a.demux;(!d||!(d instanceof c))&&(this.remuxer=new c(s,t,r,n)),(!l||!(l instanceof u))&&(this.demuxer=new u(s,t,r),this.probe=u.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new gm(this.config)),e}}function ak(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const nu=i=>({remuxResult:{},chunkMeta:i});function al(i){return"then"in i&&i.then instanceof Function}class ok{constructor(e,t,s,r,n){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=r,this.defaultInitPts=n||null}}class lk{constructor(e,t,s,r,n,a){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=r,this.timeOffset=n,this.initSegmentChange=a}}var fE={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new s:delete l._events[d]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,m=new Array(f);h<f;h++)m[h]=u[h].fn;return m},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,y,b;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,h),!0;case 5:return g.fn.call(g.context,c,u,h,f),!0;case 6:return g.fn.call(g.context,c,u,h,f,m),!0}for(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var x=g.length,_;for(b=0;b<x;b++)switch(g[b].once&&this.removeListener(d,g[b].fn,void 0,!0),v){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,c);break;case 3:g[b].fn.call(g[b].context,c,u);break;case 4:g[b].fn.call(g[b].context,c,u,h);break;default:if(!y)for(_=1,y=new Array(v-1);_<v;_++)y[_-1]=arguments[_];g[b].fn.apply(g[b].context,y)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!h||m.once)&&(!u||m.context===u)&&a(this,f);else{for(var p=0,g=[],v=m.length;p<v;p++)(m[p].fn!==c||h&&!m[p].once||u&&m[p].context!==u)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(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,i.exports=o})(fE);var dk=fE.exports,_m=DA(dk);class mE{constructor(e,t,s,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=s,this.onFlush=r;const a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===E.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new _m,this.observer.on(E.FRAG_DECRYPTED,a),this.observer.on(E.ERROR,a);const o=_r(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||Ix())){try{n.workerPath?(R.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=wx(n.workerPath)):(R.log(`injecting Web Worker for "${t}"`),this.workerContext=Rx()),this.onwmsg=u=>this.onWorkerMessage(u);const{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{const h=new Error(`${u.message} (${u.filename}:${u.lineno})`);n.enableWorker=!1,R.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(E.ERROR,{type:se.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},c.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(c){R.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new S0(this.observer,l,n,"",t)}return}this.transmuxer=new S0(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,s,r,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();const{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,v=!(g&&n.cc===g.cc),y=!(g&&d.level===g.level),b=g?d.sn-g.sn:-1,x=this.part?d.part-this.part.index:-1,_=b===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),S=!y&&(b===1||b===0&&(x===1||_&&x<=0)),A=self.performance.now();(y||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=A),a&&(x||!S)&&(a.stats.parsing.start=A);const D=!(g&&((u=n.initSegment)==null?void 0:u.url)===((h=g.initSegment)==null?void 0:h.url)),O=new lk(v,S,l,y,m,D);if(!S||v||D){R.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
28
+ Switching to level ${C} @ ${H|0} bps`),r.trigger(E.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:s,stats:l})},this.hls=e,this.bwEstimator=this.initEstimator(),this.registerListeners()}resetEstimator(e){e&&(R.log(`setting initial bwe to ${e}`),this.hls.config.abrEwmaDefaultEstimate=e),this.firstSelection=-1,this.bwEstimator=this.initEstimator()}initEstimator(){const e=this.hls.config;return new ix(e.abrEwmaSlowVoD,e.abrEwmaFastVoD,e.abrEwmaDefaultEstimate)}registerListeners(){const{hls:e}=this;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),e.off(E.ERROR,this.onError,this))}destroy(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null}onManifestLoading(e,t){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,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 r;this.fragCurrent=s,this.partCurrent=(r=t.part)!=null?r: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 M.BUFFER_ADD_CODEC_ERROR:case M.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case M.FRAG_LOAD_TIMEOUT:{const s=t.frag,{fragCurrent:r,partCurrent:n}=this;if(s&&r&&s.sn===r.sn&&s.level===r.level){const a=performance.now(),o=n?n.stats:s.stats,l=a-o.loading.start,d=o.loading.first?o.loading.first-o.loading.start:-1;if(o.loaded&&d>-1){const u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(l-Math.min(u,d),o.loaded)}else this.bwEstimator.sampleTTFB(l)}break}}}getTimeToLoadFrag(e,t,s,r){const n=e+s/t,a=r?this.lastLevelLoadSec:0;return n+a}onLevelLoaded(e,t){const s=this.hls.config,{loading:r}=t.stats,n=r.end-r.start;j(n)&&(this.lastLevelLoadSec=n/1e3),t.details.live?this.bwEstimator.update(s.abrEwmaSlowLive,s.abrEwmaFastLive):this.bwEstimator.update(s.abrEwmaSlowVoD,s.abrEwmaFastVoD)}onFragLoaded(e,{frag:t,part:s}){const r=s?s.stats:t.stats;if(t.type===te.MAIN&&this.bwEstimator.sampleTTFB(r.loading.first-r.loading.start),!this.ignoreFragment(t)){if(this.clearTimer(),t.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){const n=s?s.duration:t.duration,a=this.hls.levels[t.level],o=(a.loaded?a.loaded.bytes:0)+r.loaded,l=(a.loaded?a.loaded.duration:0)+n;a.loaded={bytes:o,duration:l},a.realBitrate=Math.round(8*o/l)}if(t.bitrateTest){const n={stats:r,frag:t,part:s,id:t.type};this.onFragBuffered(E.FRAG_BUFFERED,n),t.bitrateTest=!1}else this.lastLoadedFragLevel=t.level}}onFragBuffered(e,t){const{frag:s,part:r}=t,n=r!=null&&r.stats.loaded?r.stats:s.stats;if(n.aborted||this.ignoreFragment(s))return;const a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),s.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}ignoreFragment(e){return e.type!==te.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(),r=this.hls.config.maxStarvationDelay,n=this.findBestLevel(s,t,e,0,r,1,1);if(n>-1)return n;const a=this.hls.firstLevel,o=Math.min(Math.max(a,t),e);return R.warn(`[abr] Could not find best starting auto level. Defaulting to first in playlist ${a} clamped to ${o}`),o}get forcedAutoLevel(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}get nextAutoLevel(){const e=this.forcedAutoLevel,s=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(e!==-1&&(!s||!r||this.nextAutoLevelKey===this.getAutoLevelKey()))return e;const n=s&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(e!==-1){const a=this.hls.levels;if(a.length>Math.max(e,n)&&a[e].loadError<=a[n].loadError)return e}return this._nextAutoLevel=n,this.nextAutoLevelKey=this.getAutoLevelKey(),n}getAutoLevelKey(){return`${this.getBwEstimate()}_${this.getStarvationDelay().toFixed(2)}`}getNextABRAutoLevel(){const{fragCurrent:e,partCurrent:t,hls:s}=this,{maxAutoLevel:r,config:n,minAutoLevel:a}=s,o=t?t.duration:e?e.duration:0,l=this.getBwEstimate(),d=this.getStarvationDelay();let c=n.abrBandWidthFactor,u=n.abrBandWidthUpFactor;if(d){const g=this.findBestLevel(l,a,r,d,0,c,u);if(g>=0)return g}let h=o?Math.min(o,n.maxStarvationDelay):n.maxStarvationDelay;if(!d){const g=this.bitrateTestDelay;g&&(h=(o?Math.min(o,n.maxLoadingDelay):n.maxLoadingDelay)-g,R.info(`[abr] bitrate test took ${Math.round(1e3*g)}ms, set first fragment max fetchDuration to ${Math.round(1e3*h)} ms`),c=u=1)}const f=this.findBestLevel(l,a,r,d,h,c,u);if(R.info(`[abr] ${d?"rebuffering expected":"buffer is empty"}, optimal quality level ${f}`),f>-1)return f;const m=s.levels[a],p=s.levels[s.loadLevel];return(m==null?void 0:m.bitrate)<(p==null?void 0:p.bitrate)?a: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,r=e.mainForwardBufferInfo;return(r?r.len:0)/s}getBwEstimate(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate}findBestLevel(e,t,s,r,n,a,o){var l;const d=r+n,c=this.lastLoadedFragLevel,u=c===-1?this.hls.firstLevel:c,{fragCurrent:h,partCurrent:f}=this,{levels:m,allAudioTracks:p,loadLevel:g,config:v}=this.hls;if(m.length===1)return 0;const y=m[u],b=!!(y!=null&&(l=y.details)!=null&&l.live),x=g===-1||c===-1;let _,S="SDR",A=(y==null?void 0:y.frameRate)||0;const{audioPreference:D,videoPreference:O}=v,L=this.audioTracksByGroup||(this.audioTracksByGroup=dx(p));if(x){if(this.firstSelection!==-1)return this.firstSelection;const q=this.codecTiers||(this.codecTiers=cx(m,L,t,s)),Y=lx(q,S,e,D,O),{codecSet:oe,videoRanges:ae,minFramerate:G,minBitrate:F,preferHDR:re}=Y;_=oe,S=re?ae[ae.length-1]:ae[0],A=G,e=Math.max(e,F),R.log(`[abr] picked start tier ${JSON.stringify(Y)}`)}else _=y==null?void 0:y.codecSet,S=y==null?void 0:y.videoRange;const C=f?f.duration:h?h.duration:0,H=this.bwEstimator.getEstimateTTFB()/1e3,U=[];for(let q=s;q>=t;q--){var Q;const Y=m[q],oe=q>u;if(!Y)continue;if(v.useMediaCapabilities&&!Y.supportedResult&&!Y.supportedPromise){const Ae=navigator.mediaCapabilities;typeof(Ae==null?void 0:Ae.decodingInfo)=="function"&&sx(Y,L,S,A,e,D)?(Y.supportedPromise=rx(Y,L,Ae),Y.supportedPromise.then(Ce=>{if(!this.hls)return;Y.supportedResult=Ce;const He=this.hls.levels,St=He.indexOf(Y);Ce.error?R.warn(`[abr] MediaCapabilities decodingInfo error: "${Ce.error}" for level ${St} ${JSON.stringify(Ce)}`):Ce.supported||(R.warn(`[abr] Unsupported MediaCapabilities decodingInfo result for level ${St} ${JSON.stringify(Ce)}`),St>-1&&He.length>1&&(R.log(`[abr] Removing unsupported level ${St}`),this.hls.removeLevel(St)))})):Y.supportedResult=Xv}if(_&&Y.codecSet!==_||S&&Y.videoRange!==S||oe&&A>Y.frameRate||!oe&&A>0&&A<Y.frameRate||Y.supportedResult&&!((Q=Y.supportedResult.decodingInfoResults)!=null&&Q[0].smooth)){U.push(q);continue}const ae=Y.details,G=(f?ae==null?void 0:ae.partTarget:ae==null?void 0:ae.averagetargetduration)||C;let F;oe?F=o*e:F=a*e;const re=C&&r>=C*2&&n===0?m[q].averageBitrate:m[q].maxBitrate,J=this.getTimeToLoadFrag(H,F,re*G,ae===void 0);if(F>=re&&(q===c||Y.loadError===0&&Y.fragmentError===0)&&(J<=H||!j(J)||b&&!this.bitrateTestDelay||J<d)){const Ae=this.forcedAutoLevel;return q!==g&&(Ae===-1||Ae!==g)&&(U.length&&R.trace(`[abr] Skipped level(s) ${U.join(",")} of ${s} max with CODECS and VIDEO-RANGE:"${m[U[0]].codecs}" ${m[U[0]].videoRange}; not compatible with "${y.codecs}" ${S}`),R.info(`[abr] switch candidate:${u}->${q} adjustedbw(${Math.round(F)})-bitrate=${Math.round(F-re)} ttfb:${H.toFixed(1)} avgDuration:${G.toFixed(1)} maxFetchDuration:${d.toFixed(1)} fetchDuration:${J.toFixed(1)} firstSelection:${x} codecSet:${_} videoRange:${S} hls.loadLevel:${g}`)),x&&(this.firstSelection=q),q}}return-1}set nextAutoLevel(e){const{maxAutoLevel:t,minAutoLevel:s}=this.hls,r=Math.min(Math.max(e,s),t);this._nextAutoLevel!==r&&(this.nextAutoLevelKey="",this._nextAutoLevel=r)}}class mx{constructor(){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(){}}var rt={NOT_LOADED:"NOT_LOADED",APPENDING:"APPENDING",PARTIAL:"PARTIAL",OK:"OK"};class px{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.on(E.BUFFER_APPENDED,this.onBufferAppended,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.BUFFER_APPENDED,this.onBufferAppended,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this)}destroy(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null}getAppendedFrag(e,t){const s=this.activePartLists[t];if(s)for(let r=s.length;r--;){const n=s[r];if(!n)break;const a=n.end;if(n.start<=e&&a!==null&&e<=a)return n}return this.getBufferedFrag(e,t)}getBufferedFrag(e,t){const{fragments:s}=this,r=Object.keys(s);for(let n=r.length;n--;){const a=s[r[n]];if((a==null?void 0:a.body.type)===t&&a.buffered){const o=a.body;if(o.start<=e&&e<=o.end)return o}}return null}detectEvictedFragments(e,t,s,r){this.timeRanges&&(this.timeRanges[e]=t);const n=(r==null?void 0:r.fragment.sn)||-1;Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o||n>=o.body.sn)return;if(!o.buffered&&!o.loaded){o.body.type===s&&this.removeFragment(o.body);return}const l=o.range[e];l&&l.time.some(d=>{const c=!this.isTimeBuffered(d.startPTS,d.endPTS,t);return c&&this.removeFragment(o.body),c})})}detectPartialFragments(e){const t=this.timeRanges,{frag:s,part:r}=e;if(!t||s.sn==="initSegment")return;const n=Or(s),a=this.fragments[n];if(!a||a.buffered&&s.gap)return;const o=!s.relurl;Object.keys(t).forEach(l=>{const d=s.elementaryStreams[l];if(!d)return;const c=t[l],u=o||d.partial===!0;a.range[l]=this.getBufferedTimes(s,r,u,c)}),a.loaded=null,Object.keys(a.range).length?(a.buffered=!0,(a.body.endList=s.endList||a.body.endList)&&(this.endListFragments[a.body.type]=a),_o(a)||this.removeParts(s.sn-1,s.type)):this.removeFragment(a.body)}removeParts(e,t){const s=this.activePartLists[t];s&&(this.activePartLists[t]=s.filter(r=>r.fragment.sn>=e))}fragBuffered(e,t){const s=Or(e);let r=this.fragments[s];!r&&t&&(r=this.fragments[s]={body:e,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},e.gap&&(this.hasGaps=!0)),r&&(r.loaded=null,r.buffered=!0)}getBufferedTimes(e,t,s,r){const n={time:[],partial:s},a=e.start,o=e.end,l=e.minEndPTS||o,d=e.maxStartPTS||a;for(let c=0;c<r.length;c++){const u=r.start(c)-this.bufferPadding,h=r.end(c)+this.bufferPadding;if(d>=u&&l<=h){n.time.push({startPTS:Math.max(a,r.start(c)),endPTS:Math.min(o,r.end(c))});break}else if(a<h&&o>u){const f=Math.max(a,r.start(c)),m=Math.min(o,r.end(c));m>f&&(n.partial=!0,n.time.push({startPTS:f,endPTS:m}))}else if(o<=u)break}return n}getPartialFragment(e){let t=null,s,r,n,a=0;const{bufferPadding:o,fragments:l}=this;return Object.keys(l).forEach(d=>{const c=l[d];c&&_o(c)&&(r=c.body.start-o,n=c.body.end+o,e>=r&&e<=n&&(s=Math.min(e-r,n-e),a<=s&&(t=c.body,a=s)))}),t}isEndListAppended(e){const t=this.endListFragments[e];return t!==void 0&&(t.buffered||_o(t))}getState(e){const t=Or(e),s=this.fragments[t];return s?s.buffered?_o(s)?rt.PARTIAL:rt.OK:rt.APPENDING:rt.NOT_LOADED}isTimeBuffered(e,t,s){let r,n;for(let a=0;a<s.length;a++){if(r=s.start(a)-this.bufferPadding,n=s.end(a)+this.bufferPadding,e>=r&&t<=n)return!0;if(t<=r)return!1}return!1}onFragLoaded(e,t){const{frag:s,part:r}=t;if(s.sn==="initSegment"||s.bitrateTest)return;const n=r?null:t,a=Or(s);this.fragments[a]={body:s,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}onBufferAppended(e,t){const{frag:s,part:r,timeRanges:n}=t;if(s.sn==="initSegment")return;const a=s.type;if(r){let o=this.activePartLists[a];o||(this.activePartLists[a]=o=[]),o.push(r)}this.timeRanges=n,Object.keys(n).forEach(o=>{const l=n[o];this.detectEvictedFragments(o,l,a,r)})}onFragBuffered(e,t){this.detectPartialFragments(t)}hasFragment(e){const t=Or(e);return!!this.fragments[t]}hasParts(e){var t;return!!((t=this.activePartLists[e])!=null&&t.length)}removeFragmentsInRange(e,t,s,r,n){r&&!this.hasGaps||Object.keys(this.fragments).forEach(a=>{const o=this.fragments[a];if(!o)return;const l=o.body;l.type!==s||r&&!l.gap||l.start<t&&l.end>e&&(o.buffered||n)&&this.removeFragment(l)})}removeFragment(e){const t=Or(e);e.stats.loaded=0,e.clearElementaryStreamInfo();const s=this.activePartLists[e.type];if(s){const r=e.sn;this.activePartLists[e.type]=s.filter(n=>n.fragment.sn!==r)}delete this.fragments[t],e.endList&&delete this.endListFragments[e.type]}removeAllFragments(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1}}function _o(i){var e,t,s;return i.buffered&&(i.body.gap||((e=i.range.video)==null?void 0:e.partial)||((t=i.range.audio)==null?void 0:t.partial)||((s=i.range.audiovideo)==null?void 0:s.partial))}function Or(i){return`${i.type}_${i.level}_${i.sn}`}const gx={length:0,start:()=>0,end:()=>0};class Le{static isBuffered(e,t){try{if(e){const s=Le.getBuffered(e);for(let r=0;r<s.length;r++)if(t>=s.start(r)&&t<=s.end(r))return!0}}catch{}return!1}static bufferInfo(e,t,s){try{if(e){const r=Le.getBuffered(e),n=[];let a;for(a=0;a<r.length;a++)n.push({start:r.start(a),end:r.end(a)});return this.bufferedInfo(n,t,s)}}catch{}return{len:0,start:t,end:t,nextStart:void 0}}static bufferedInfo(e,t,s){t=Math.max(0,t),e.sort(function(d,c){const u=d.start-c.start;return u||c.end-d.end});let r=[];if(s)for(let d=0;d<e.length;d++){const c=r.length;if(c){const u=r[c-1].end;e[d].start-u<s?e[d].end>u&&(r[c-1].end=e[d].end):r.push(e[d])}else r.push(e[d])}else r=e;let n=0,a,o=t,l=t;for(let d=0;d<r.length;d++){const c=r[d].start,u=r[d].end;if(t+s>=c&&t<u)o=c,l=u,n=l-t;else if(t+s<c){a=c;break}}return{len:n,start:o||0,end:l||0,nextStart:a}}static getBuffered(e){try{return e.buffered}catch(t){return R.log("failed to get media.buffered",t),gx}}}class pm{constructor(e,t,s,r=0,n=-1,a=!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=Ao(),this.buffering={audio:Ao(),video:Ao(),audiovideo:Ao()},this.level=e,this.sn=t,this.id=s,this.size=r,this.part=n,this.partial=a}}function Ao(){return{start:0,executeStart:0,executeEnd:0,end:0}}function sl(i,e){for(let s=0,r=i.length;s<r;s++){var t;if(((t=i[s])==null?void 0:t.cc)===e)return i[s]}return null}function vx(i,e,t){return!!(e&&(t.endCC>t.startCC||i&&i.cc<t.startCC))}function Ex(i,e){const t=i.fragments,s=e.fragments;if(!s.length||!t.length){R.log("No fragments to align");return}const r=sl(t,s[0].cc);if(!r||r&&!r.startPTS){R.log("No frag in previous level to align on");return}return r}function p0(i,e){if(i){const t=i.start+e;i.start=i.startPTS=t,i.endPTS=t+i.duration}}function Qv(i,e){const t=e.fragments;for(let s=0,r=t.length;s<r;s++)p0(t[s],i);e.fragmentHint&&p0(e.fragmentHint,i),e.alignedSliding=!0}function bx(i,e,t){e&&(yx(i,t,e),!t.alignedSliding&&e&&Vd(t,e),!t.alignedSliding&&e&&!t.skippedSegments&&qv(e,t))}function yx(i,e,t){if(vx(i,t,e)){const s=Ex(t,e);s&&j(s.start)&&(R.log(`Adjusting PTS using last level due to CC increase within current level ${e.url}`),Qv(s.start,e))}}function Vd(i,e){if(!i.hasProgramDateTime||!e.hasProgramDateTime)return;const t=i.fragments,s=e.fragments;if(!t.length||!s.length)return;let r,n;const a=Math.min(e.endCC,i.endCC);e.startCC<a&&i.startCC<a&&(r=sl(s,a),n=sl(t,a)),(!r||!n)&&(r=s[Math.floor(s.length/2)],n=sl(t,r.cc)||t[Math.floor(t.length/2)]);const o=r.programDateTime,l=n.programDateTime;if(!o||!l)return;const d=(l-o)/1e3-(n.start-r.start);Qv(d,i)}const g0=Math.pow(2,17);class Tx{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 ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,error:new Error(`Fragment does not have a ${s?"part list":"url"}`),networkDetails:null}));this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap)if(e.tagList.some(f=>f[0]==="GAP")){l(E0(e));return}else e.gap=!1;const d=this.loader=e.loader=n?new n(r):new a(r),c=v0(e),u=h0(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:e.sn==="initSegment"?1/0:g0};e.stats=d.stats,d.load(c,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d);let v=f.data;p.resetIV&&e.decryptdata&&(e.decryptdata.iv=new Uint8Array(v.slice(0,16)),v=v.slice(16)),o({frag:e,part:null,payload:v,networkDetails:g})},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,response:dt({url:s,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))},onProgress:(f,m,p,g)=>{t&&t({frag:e,part:null,payload:p,networkDetails:g})}})})}loadPart(e,t,s){this.abort();const r=this.config,n=r.fLoader,a=r.loader;return new Promise((o,l)=>{if(this.loader&&this.loader.destroy(),e.gap||t.gap){l(E0(e,t));return}const d=this.loader=e.loader=n?new n(r):new a(r),c=v0(e,t),u=h0(r.fragLoadPolicy.default),h={loadPolicy:u,timeout:u.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0,highWaterMark:g0};t.stats=d.stats,d.load(c,h,{onSuccess:(f,m,p,g)=>{this.resetLoader(e,d),this.updateStatsFromPart(e,t);const v={frag:e,part:t,payload:f.data,networkDetails:g};s(v),o(v)},onError:(f,m,p,g)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_ERROR,fatal:!1,frag:e,part:t,response:dt({url:c.url,data:void 0},f),error:new Error(`HTTP Error ${f.code} ${f.text}`),networkDetails:p,stats:g}))},onAbort:(f,m,p)=>{e.stats.aborted=t.stats.aborted,this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.INTERNAL_ABORTED,fatal:!1,frag:e,part:t,error:new Error("Aborted"),networkDetails:p,stats:f}))},onTimeout:(f,m,p)=>{this.resetLoader(e,d),l(new ji({type:se.NETWORK_ERROR,details:M.FRAG_LOAD_TIMEOUT,fatal:!1,frag:e,part:t,error:new Error(`Timeout after ${h.timeout}ms`),networkDetails:p,stats:f}))}})})}updateStatsFromPart(e,t){const s=e.stats,r=t.stats,n=r.total;if(s.loaded+=r.loaded,n){const l=Math.round(e.duration/t.duration),d=Math.min(Math.round(s.loaded/n),l),u=(l-d)*Math.round(s.loaded/d);s.total=s.loaded+u}else s.total=Math.max(s.loaded,s.total);const a=s.loading,o=r.loading;a.start?a.first+=o.first-o.start:(a.start=o.start,a.first=o.first),a.end=o.end}resetLoader(e,t){e.loader=null,this.loader===t&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),t.destroy()}}function v0(i,e=null){const t=e||i,s={frag:i,part:e,responseType:"arraybuffer",url:t.url,headers:{},rangeStart:0,rangeEnd:0},r=t.byteRangeStartOffset,n=t.byteRangeEndOffset;if(j(r)&&j(n)){var a;let o=r,l=n;if(i.sn==="initSegment"&&((a=i.decryptdata)==null?void 0:a.method)==="AES-128"){const d=n-r;d%16&&(l=n+(16-d%16)),r!==0&&(s.resetIV=!0,o=r-16)}s.rangeStart=o,s.rangeEnd=l}return s}function E0(i,e){const t=new Error(`GAP ${i.gap?"tag":"attribute"} found`),s={type:se.MEDIA_ERROR,details:M.FRAG_GAP,fatal:!1,frag:i,error:t,networkDetails:null};return e&&(s.part=e),(e||i).stats.aborted=!0,new ji(s)}class ji extends Error{constructor(e){super(e.error.message),this.data=void 0,this.data=e}}class _x{constructor(e,t){this.subtle=void 0,this.aesIV=void 0,this.subtle=e,this.aesIV=t}decrypt(e,t){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},t,e)}}class Ax{constructor(e,t){this.subtle=void 0,this.key=void 0,this.subtle=e,this.key=t}expandKey(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])}}function Sx(i){const e=i.byteLength,t=e&&new DataView(i.buffer).getUint8(e-1);return t?ur(i,0,e-t):i}class xx{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 r=0;r<4;r++)s[r]=t.getUint32(r*4);return s}initTable(){const e=this.sBox,t=this.invSBox,s=this.subMix,r=s[0],n=s[1],a=s[2],o=s[3],l=this.invSubMix,d=l[0],c=l[1],u=l[2],h=l[3],f=new Uint32Array(256);let m=0,p=0,g=0;for(g=0;g<256;g++)g<128?f[g]=g<<1:f[g]=g<<1^283;for(g=0;g<256;g++){let v=p^p<<1^p<<2^p<<3^p<<4;v=v>>>8^v&255^99,e[m]=v,t[v]=m;const y=f[m],b=f[y],x=f[b];let _=f[v]*257^v*16843008;r[m]=_<<24|_>>>8,n[m]=_<<16|_>>>16,a[m]=_<<8|_>>>24,o[m]=_,_=x*16843009^b*65537^y*257^m*16843008,d[v]=_<<24|_>>>8,c[v]=_<<16|_>>>16,u[v]=_<<8|_>>>24,h[v]=_,m?(m=y^f[f[f[x^y]]],p^=f[f[p]]):m=p=1}}expandKey(e){const t=this.uint8ArrayToUint32Array_(e);let s=!0,r=0;for(;r<t.length&&s;)s=t[r]===this.key[r],r++;if(s)return;this.key=t;const n=this.keySize=t.length;if(n!==4&&n!==6&&n!==8)throw new Error("Invalid aes key size="+n);const a=this.ksRows=(n+6+1)*4;let o,l;const d=this.keySchedule=new Uint32Array(a),c=this.invKeySchedule=new Uint32Array(a),u=this.sBox,h=this.rcon,f=this.invSubMix,m=f[0],p=f[1],g=f[2],v=f[3];let y,b;for(o=0;o<a;o++){if(o<n){y=d[o]=t[o];continue}b=y,o%n===0?(b=b<<8|b>>>24,b=u[b>>>24]<<24|u[b>>>16&255]<<16|u[b>>>8&255]<<8|u[b&255],b^=h[o/n|0]<<24):n>6&&o%n===4&&(b=u[b>>>24]<<24|u[b>>>16&255]<<16|u[b>>>8&255]<<8|u[b&255]),d[o]=y=(d[o-n]^b)>>>0}for(l=0;l<a;l++)o=a-l,l&3?b=d[o]:b=d[o-4],l<4||o<=4?c[l]=b:c[l]=m[u[b>>>24]]^p[u[b>>>16&255]]^g[u[b>>>8&255]]^v[u[b&255]],c[l]=c[l]>>>0}networkToHostOrderSwap(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24}decrypt(e,t,s){const r=this.keySize+6,n=this.invKeySchedule,a=this.invSBox,o=this.invSubMix,l=o[0],d=o[1],c=o[2],u=o[3],h=this.uint8ArrayToUint32Array_(s);let f=h[0],m=h[1],p=h[2],g=h[3];const v=new Int32Array(e),y=new Int32Array(v.length);let b,x,_,S,A,D,O,L,C,H,U,Q,q,Y;const oe=this.networkToHostOrderSwap;for(;t<v.length;){for(C=oe(v[t]),H=oe(v[t+1]),U=oe(v[t+2]),Q=oe(v[t+3]),A=C^n[0],D=Q^n[1],O=U^n[2],L=H^n[3],q=4,Y=1;Y<r;Y++)b=l[A>>>24]^d[D>>16&255]^c[O>>8&255]^u[L&255]^n[q],x=l[D>>>24]^d[O>>16&255]^c[L>>8&255]^u[A&255]^n[q+1],_=l[O>>>24]^d[L>>16&255]^c[A>>8&255]^u[D&255]^n[q+2],S=l[L>>>24]^d[A>>16&255]^c[D>>8&255]^u[O&255]^n[q+3],A=b,D=x,O=_,L=S,q=q+4;b=a[A>>>24]<<24^a[D>>16&255]<<16^a[O>>8&255]<<8^a[L&255]^n[q],x=a[D>>>24]<<24^a[O>>16&255]<<16^a[L>>8&255]<<8^a[A&255]^n[q+1],_=a[O>>>24]<<24^a[L>>16&255]<<16^a[A>>8&255]<<8^a[D&255]^n[q+2],S=a[L>>>24]<<24^a[A>>16&255]<<16^a[D>>8&255]<<8^a[O&255]^n[q+3],y[t]=oe(b^f),y[t+1]=oe(S^m),y[t+2]=oe(_^p),y[t+3]=oe(x^g),f=C,m=H,p=U,g=Q,t=t+4}return y.buffer}}const kx=16;class gm{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.useSoftware=e.enableSoftwareAES,this.removePKCS7Padding=t,t)try{const s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch{}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?Sx(s):s}reset(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)}decrypt(e,t,s){return this.useSoftware?new Promise((r,n)=>{this.softwareDecrypt(new Uint8Array(e),t,s);const a=this.flush();a?r(a.buffer):n(new Error("[softwareDecrypt] Failed to decrypt data"))}):this.webCryptoDecrypt(new Uint8Array(e),t,s)}softwareDecrypt(e,t,s){const{currentIV:r,currentResult:n,remainderData:a}=this;this.logOnce("JS AES decrypt"),a&&(e=Vt(a,e),this.remainderData=null);const o=this.getValidChunk(e);if(!o.length)return null;r&&(s=r);let l=this.softwareDecrypter;l||(l=this.softwareDecrypter=new xx),l.expandKey(t);const d=n;return this.currentResult=l.decrypt(o.buffer,0,s),this.currentIV=ur(o,-16).buffer,d||null}webCryptoDecrypt(e,t,s){if(this.key!==t||!this.fastAesKey){if(!this.subtle)return Promise.resolve(this.onWebCryptoError(e,t,s));this.key=t,this.fastAesKey=new Ax(this.subtle,t)}return this.fastAesKey.expandKey().then(r=>this.subtle?(this.logOnce("WebCrypto AES decrypt"),new _x(this.subtle,new Uint8Array(s)).decrypt(e.buffer,r)):Promise.reject(new Error("web crypto not initialized"))).catch(r=>(R.warn(`[decrypter]: WebCrypto Error, disable WebCrypto API, ${r.name}: ${r.message}`),this.onWebCryptoError(e,t,s)))}onWebCryptoError(e,t,s){this.useSoftware=!0,this.logEnabled=!0,this.softwareDecrypt(e,t,s);const r=this.flush();if(r)return r.buffer;throw new Error("WebCrypto and softwareDecrypt: failed to decrypt data")}getValidChunk(e){let t=e;const s=e.length-e.length%kx;return s!==e.length&&(t=ur(e,0,s),this.remainderData=ur(e,s)),t}logOnce(e){this.logEnabled&&(R.log(`[decrypter]: ${e}`),this.logEnabled=!1)}}const Lx={toString:function(i){let e="";const t=i.length;for(let s=0;s<t;s++)e+=`[${i.start(s).toFixed(3)}-${i.end(s).toFixed(3)}]`;return e}},N={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 vm extends mx{constructor(e,t,s,r,n){super(),this.hls=void 0,this.fragPrevious=null,this.fragCurrent=null,this.fragmentTracker=void 0,this.transmuxer=null,this._state=N.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.loadedmetadata=!1,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.onvseeking=null,this.onvended=null,this.logPrefix="",this.log=void 0,this.warn=void 0,this.playlistType=n,this.logPrefix=r,this.log=R.log.bind(R,`${r}:`),this.warn=R.warn.bind(R,`${r}:`),this.hls=e,this.fragmentLoader=new Tx(e.config),this.keyLoader=s,this.fragmentTracker=t,this.config=e.config,this.decrypter=new gm(e.config),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}doTick(){this.onTickEnd()}onTickEnd(){}startLoad(e){}stopLoad(){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=N.STOPPED}_streamEnded(e,t){if(t.live||e.nextStart||!e.end||!this.media)return!1;const s=t.partList;if(s!=null&&s.length){const n=s[s.length-1];return Le.isBuffered(this.media,n.start+n.duration/2)}const r=t.fragments[t.fragments.length-1].type;return this.fragmentTracker.isEndListAppended(r)}getLevelDetails(){if(this.levels&&this.levelLastLoaded!==null){var e;return(e=this.levelLastLoaded)==null?void 0:e.details}}onMediaAttached(e,t){const s=this.media=this.mediaBuffer=t.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),s.addEventListener("seeking",this.onvseeking),s.addEventListener("ended",this.onvended);const r=this.config;this.levels&&r.autoStartLoad&&this.state===N.STOPPED&&this.startLoad(r.startPosition)}onMediaDetaching(){const e=this.media;e!=null&&e.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),e&&this.onvseeking&&this.onvended&&(e.removeEventListener("seeking",this.onvseeking),e.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.keyLoader&&this.keyLoader.detach(),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()}onMediaSeeking(){const{config:e,fragCurrent:t,media:s,mediaBuffer:r,state:n}=this,a=s?s.currentTime:0,o=Le.bufferInfo(r||s,a,e.maxBufferHole);if(this.log(`media seeking to ${j(a)?a.toFixed(3):a}, state: ${n}`),this.state===N.ENDED)this.resetLoadingState();else if(t){const l=e.maxFragLookUpTolerance,d=t.start-l,c=t.start+t.duration+l;if(!o.len||c<o.start||d>o.end){const u=a>c;(a<d||u)&&(u&&t.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),t.abortRequests(),this.resetLoadingState()),this.fragPrevious=null)}}s&&(this.fragmentTracker.removeFragmentsInRange(a,1/0,this.playlistType,!0),this.lastCurrentTime=a),!this.loadedmetadata&&!o.len&&(this.nextLoadPosition=this.startPosition=a),this.tickImmediate()}onMediaEnded(){this.startPosition=this.lastCurrentTime=0}onManifestLoaded(e,t){this.startTimeOffset=t.startTimeOffset,this.initPTS=[]}onHandlerDestroying(){this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),this.stopLoad(),super.onHandlerDestroying(),this.hls=null}onHandlerDestroyed(){this.state=N.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._loadFragForPlayback(e,t,s)}_loadFragForPlayback(e,t,s){const r=n=>{if(this.fragContextChanged(e)){this.warn(`Fragment ${e.sn}${n.part?" p: "+n.part.index:""} of level ${e.level} was dropped during download.`),this.fragmentTracker.removeFragment(e);return}e.stats.chunkCount++,this._handleFragmentLoadProgress(n)};this._doFragLoad(e,t,s,r).then(n=>{if(!n)return;const a=this.state;if(this.fragContextChanged(e)){(a===N.FRAG_LOADING||!this.fragCurrent&&a===N.PARSING)&&(this.fragmentTracker.removeFragment(e),this.state=N.IDLE);return}"payload"in n&&(this.log(`Loaded fragment ${e.sn} of level ${e.level}`),this.hls.trigger(E.FRAG_LOADED,n)),this._handleFragmentLoadComplete(n)}).catch(n=>{this.state===N.STOPPED||this.state===N.ERROR||(this.warn(`Frag error: ${(n==null?void 0:n.message)||n}`),this.resetFragmentLoading(e))})}clearTrackerIfNeeded(e){var t;const{fragmentTracker:s}=this;if(s.getState(e)===rt.APPENDING){const n=e.type,a=this.getFwdBufferInfo(this.mediaBuffer,n),o=Math.max(e.duration,a?a.len:this.config.maxBufferLength),l=this.backtrackFragment;((l?e.sn-l.sn:0)===1||this.reduceMaxBufferLength(o))&&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)===rt.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)}flushMainBuffer(e,t,s=null){if(!(e-t))return;const r={startOffset:e,endOffset:t,type:s};this.hls.trigger(E.BUFFER_FLUSHING,r)}_loadInitSegment(e,t){this._doFragLoad(e,t).then(s=>{if(!s||this.fragContextChanged(e)||!this.levels)throw new Error("init load aborted");return s}).then(s=>{const{hls:r}=this,{payload:n}=s,a=e.decryptdata;if(n&&n.byteLength>0&&a!=null&&a.key&&a.iv&&a.method==="AES-128"){const o=self.performance.now();return this.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch(l=>{throw r.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:l,reason:l.message,frag:e}),l}).then(l=>{const d=self.performance.now();return r.trigger(E.FRAG_DECRYPTED,{frag:e,payload:l,stats:{tstart:o,tdecrypt:d}}),s.payload=l,this.completeInitSegmentLoad(s)})}return this.completeInitSegmentLoad(s)}).catch(s=>{this.state===N.STOPPED||this.state===N.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=N.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()}fragContextChanged(e){const{fragCurrent:t}=this;return!e||!t||e.sn!==t.sn||e.level!==t.level}fragBufferedComplete(e,t){var s,r,n,a;const o=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log(`Buffered ${e.type} sn: ${e.sn}${t?" part: "+t.index:""} of ${this.playlistType===te.MAIN?"level":"track"} ${e.level} (frag:[${((s=e.startPTS)!=null?s:NaN).toFixed(3)}-${((r=e.endPTS)!=null?r:NaN).toFixed(3)}] > buffer:${o?Lx.toString(Le.getBuffered(o)):"(detached)"})`),e.sn!=="initSegment"){var l;if(e.type!==te.SUBTITLE){const c=e.elementaryStreams;if(!Object.keys(c).some(u=>!!c[u])){this.state=N.IDLE;return}}const d=(l=this.levels)==null?void 0:l[e.level];d!=null&&d.fragmentError&&(this.log(`Resetting level fragment error count of ${d.fragmentError} on frag buffered`),d.fragmentError=0)}this.state=N.IDLE,o&&(!this.loadedmetadata&&e.type==te.MAIN&&o.buffered.length&&((n=this.fragCurrent)==null?void 0:n.sn)===((a=this.fragPrevious)==null?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())}seekToStartPos(){}_handleFragmentLoadComplete(e){const{transmuxer:t}=this;if(!t)return;const{frag:s,part:r,partsLoaded:n}=e,a=!n||n.length===0||n.some(l=>!l),o=new pm(s.level,s.sn,s.stats.chunkCount+1,0,r?r.index:-1,!a);t.flush(o)}_handleFragmentLoadProgress(e){}_doFragLoad(e,t,s=null,r){var n;const a=t==null?void 0:t.details;if(!this.levels||!a)throw new Error(`frag load aborted, missing level${a?"":" detail"}s`);let o=null;if(e.encrypted&&!((n=e.decryptdata)!=null&&n.key)?(this.log(`Loading key for ${e.sn} of [${a.startSN}-${a.endSN}], ${this.logPrefix==="[stream-controller]"?"level":"track"} ${e.level}`),this.state=N.KEY_LOADING,this.fragCurrent=e,o=this.keyLoader.load(e).then(c=>{if(!this.fragContextChanged(c.frag))return this.hls.trigger(E.KEY_LOADED,c),this.state===N.KEY_LOADING&&(this.state=N.IDLE),c}),this.hls.trigger(E.KEY_LOADING,{frag:e}),this.fragCurrent===null&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))):!e.encrypted&&a.encryptedFragments.length&&this.keyLoader.loadClear(e,a.encryptedFragments),s=Math.max(e.start,s||0),this.config.lowLatencyMode&&e.sn!=="initSegment"){const c=a.partList;if(c&&r){s>e.end&&a.fragmentHint&&(e=a.fragmentHint);const u=this.getNextPart(c,e,s);if(u>-1){const h=c[u];this.log(`Loading part sn: ${e.sn} p: ${h.index} cc: ${e.cc} of playlist [${a.startSN}-${a.endSN}] parts [0-${u}-${c.length-1}] ${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),this.nextLoadPosition=h.start+h.duration,this.state=N.FRAG_LOADING;let f;return o?f=o.then(m=>!m||this.fragContextChanged(m.frag)?null:this.doFragPartsLoad(e,h,t,r)).catch(m=>this.handleFragLoadError(m)):f=this.doFragPartsLoad(e,h,t,r).catch(m=>this.handleFragLoadError(m)),this.hls.trigger(E.FRAG_LOADING,{frag:e,part:h,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):f}else if(!e.url||this.loadedEndOfParts(c,s))return Promise.resolve(null)}}this.log(`Loading fragment ${e.sn} cc: ${e.cc} ${a?"of ["+a.startSN+"-"+a.endSN+"] ":""}${this.logPrefix==="[stream-controller]"?"level":"track"}: ${e.level}, target: ${parseFloat(s.toFixed(3))}`),j(e.sn)&&!this.bitrateTest&&(this.nextLoadPosition=e.start+e.duration),this.state=N.FRAG_LOADING;const l=this.config.progressive;let d;return l&&o?d=o.then(c=>!c||this.fragContextChanged(c==null?void 0:c.frag)?null:this.fragmentLoader.load(e,r)).catch(c=>this.handleFragLoadError(c)):d=Promise.all([this.fragmentLoader.load(e,l?r:void 0),o]).then(([c])=>(!l&&c&&r&&r(c),c)).catch(c=>this.handleFragLoadError(c)),this.hls.trigger(E.FRAG_LOADING,{frag:e,targetBufferTime:s}),this.fragCurrent===null?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):d}doFragPartsLoad(e,t,s,r){return new Promise((n,a)=>{var o;const l=[],d=(o=s.details)==null?void 0:o.partList,c=u=>{this.fragmentLoader.loadPart(e,u,r).then(h=>{l[u.index]=h;const f=h.part;this.hls.trigger(E.FRAG_LOADED,h);const m=c0(s,e.sn,u.index+1)||Yv(d,e.sn,u.index+1);if(m)c(m);else return n({frag:e,part:f,partsLoaded:l})}).catch(a)};c(t)})}handleFragLoadError(e){if("data"in e){const t=e.data;e.data&&t.details===M.INTERNAL_ABORTED?this.handleFragLoadAborted(t.frag,t.part):this.hls.trigger(E.ERROR,t)}else this.hls.trigger(E.ERROR,{type:se.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,err:e,error:e,fatal:!0});return null}_handleTransmuxerFlush(e){const t=this.getCurrentContext(e);if(!t||this.state!==N.PARSING){!this.fragCurrent&&this.state!==N.STOPPED&&this.state!==N.ERROR&&(this.state=N.IDLE);return}const{frag:s,part:r,level:n}=t,a=self.performance.now();s.stats.parsing.end=a,r&&(r.stats.parsing.end=a),this.updateLevelTiming(s,r,n,e.partial)}getCurrentContext(e){const{levels:t,fragCurrent:s}=this,{level:r,sn:n,part:a}=e;if(!(t!=null&&t[r]))return this.warn(`Levels object was unset while buffering fragment ${n} of level ${r}. The current chunk will not be buffered.`),null;const o=t[r],l=a>-1?c0(o,n,a):null,d=l?l.fragment:zS(o,n,s);return d?(s&&s!==d&&(d.stats=s.stats),{frag:d,part:l,level:o}):null}bufferFragmentData(e,t,s,r,n){var a;if(!e||this.state!==N.PARSING)return;const{data1:o,data2:l}=e;let d=o;if(o&&l&&(d=Vt(o,l)),!((a=d)!=null&&a.length))return;const c={type:e.type,frag:t,part:s,chunkMeta:r,parent:t.type,data:d};if(this.hls.trigger(E.BUFFER_APPENDING,c),e.dropped&&e.independent&&!s){if(n)return;this.flushBufferGap(t)}}flushBufferGap(e){const t=this.media;if(!t)return;if(!Le.isBuffered(t,t.currentTime)){this.flushMainBuffer(0,e.start);return}const s=t.currentTime,r=Le.bufferInfo(t,s,0),n=e.duration,a=Math.min(this.config.maxFragLookUpTolerance*2,n*.25),o=Math.max(Math.min(e.start-a,r.end-a),s+a);e.start-o>a&&this.flushMainBuffer(o,e.start)}getFwdBufferInfo(e,t){const s=this.getLoadPosition();return j(s)?this.getFwdBufferInfoAtPos(e,s,t):null}getFwdBufferInfoAtPos(e,t,s){const{config:{maxBufferHole:r}}=this,n=Le.bufferInfo(e,t,r);if(n.len===0&&n.nextStart!==void 0){const a=this.fragmentTracker.getBufferedFrag(t,s);if(a&&n.nextStart<a.end)return Le.bufferInfo(e,t,Math.max(n.nextStart,r))}return n}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){const t=this.config,s=e||t.maxBufferLength,r=t.maxMaxBufferLength/2;return r>=s?(t.maxMaxBufferLength=r,this.warn(`Reduce max buffer length to ${r}s`),!0):!1}getAppendedFrag(e,t=te.MAIN){const s=this.fragmentTracker.getAppendedFrag(e,te.MAIN);return s&&"fragment"in s?s.fragment:s}getNextFragment(e,t){const s=t.fragments,r=s.length;if(!r)return null;const{config:n}=this,a=s[0].start;let o;if(t.live){const l=n.initialLiveManifestSize;if(r<l)return this.warn(`Not enough fragments to start playback (have: ${r}, need: ${l})`),null;(!t.PTSKnown&&!this.startFragRequested&&this.startPosition===-1||e<a)&&(o=this.getInitialLiveFragment(t,s),this.startPosition=this.nextLoadPosition=o?this.hls.liveSyncPosition||o.start:e)}else e<=a&&(o=s[0]);if(!o){const l=n.lowLatencyMode?t.partEnd:t.fragmentEnd;o=this.getFragmentAtPosition(e,l,t)}return this.mapToInitFragWhenRequired(o)}isLoopLoading(e,t){const s=this.fragmentTracker.getState(e);return(s===rt.OK||s===rt.PARTIAL&&!!e.gap)&&this.nextLoadPosition>t}getNextFragmentLoopLoading(e,t,s,r,n){const a=e.gap,o=this.getNextFragment(this.nextLoadPosition,t);if(o===null)return o;if(e=o,a&&e&&!e.gap&&s.nextStart){const l=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,s.nextStart,r);if(l!==null&&s.len+l.len>=n)return this.log(`buffer full after gaps in "${r}" playlist starting at sn: ${e.sn}`),null}return e}mapToInitFragWhenRequired(e){return e!=null&&e.initSegment&&!(e!=null&&e.initSegment.data)&&!this.bitrateTest?e.initSegment:e}getNextPart(e,t,s){let r=-1,n=!1,a=!0;for(let o=0,l=e.length;o<l;o++){const d=e[o];if(a=a&&!d.independent,r>-1&&s<d.start)break;const c=d.loaded;c?r=-1:(n||d.independent||a)&&d.fragment===t&&(r=o),n=c}return r}loadedEndOfParts(e,t){const s=e[e.length-1];return s&&t>s.start&&s.loaded}getInitialLiveFragment(e,t){const s=this.fragPrevious;let r=null;if(s){if(e.hasProgramDateTime&&(this.log(`Live playlist, switching playlist, load frag with same PDT: ${s.programDateTime}`),r=QS(t,s.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){const n=s.sn+1;if(n>=e.startSN&&n<=e.endSN){const a=t[n-e.startSN];s.cc===a.cc&&(r=a,this.log(`Live playlist, switching playlist, load frag with next SN: ${r.sn}`))}r||(r=ex(t,s.cc),r&&this.log(`Live playlist, switching playlist, load frag with same CC: ${r.sn}`))}}else{const n=this.hls.liveSyncPosition;n!==null&&(r=this.getFragmentAtPosition(n,this.bitrateTest?e.fragmentEnd:e.edge,e))}return r}getFragmentAtPosition(e,t,s){const{config:r}=this;let{fragPrevious:n}=this,{fragments:a,endSN:o}=s;const{fragmentHint:l}=s,{maxFragLookUpTolerance:d}=r,c=s.partList,u=!!(r.lowLatencyMode&&c!=null&&c.length&&l);u&&l&&!this.bitrateTest&&(a=a.concat(l),o=l.sn);let h;if(e<t){const f=e>t-d?0:d;h=Kd(n,a,e,f)}else h=a[a.length-1];if(h){const f=h.sn-s.startSN,m=this.fragmentTracker.getState(h);if((m===rt.OK||m===rt.PARTIAL&&h.gap)&&(n=h),n&&h.sn===n.sn&&(!u||c[0].fragment.sn>h.sn)&&n&&h.level===n.level){const g=a[f+1];h.sn<o&&this.fragmentTracker.getState(g)!==rt.OK?h=g:h=null}}return h}synchronizeToLiveEdge(e){const{config:t,media:s}=this;if(!s)return;const r=this.hls.liveSyncPosition,n=s.currentTime,a=e.fragments[0].start,o=e.edge,l=n>=a-t.maxFragLookUpTolerance&&n<=o;if(r!==null&&s.duration>r&&(n<r||!l)){const d=t.liveMaxLatencyDuration!==void 0?t.liveMaxLatencyDuration:t.liveMaxLatencyDurationCount*e.targetduration;(!l&&s.readyState<4||n<o-d)&&(this.loadedmetadata||(this.nextLoadPosition=r),s.readyState&&(this.warn(`Playback: ${n.toFixed(3)} is located too far from the end of live sliding playlist: ${o}, reset currentTime to : ${r.toFixed(3)}`),s.currentTime=r))}}alignPlaylists(e,t,s){const r=e.fragments.length;if(!r)return this.warn("No fragments in live playlist"),0;const n=e.fragments[0].start,a=!t,o=e.alignedSliding&&j(n);if(a||!o&&!n){const{fragPrevious:l}=this;bx(l,s,e);const d=e.fragments[0].start;return this.log(`Live playlist sliding: ${d.toFixed(2)} start-sn: ${t?t.startSN:"na"}->${e.startSN} prev-sn: ${l?l.sn:"na"} fragments: ${r}`),d}return n}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;if(s<t&&(s=-1),s===-1||this.lastCurrentTime===-1){const r=this.startTimeOffset!==null,n=r?this.startTimeOffset:e.startTimeOffset;n!==null&&j(n)?(s=t+n,n<0&&(s+=e.totalduration),s=Math.min(Math.max(t,s),t+e.totalduration),this.log(`Start time offset ${n} found in ${r?"multivariant":"media"} playlist, adjust startPosition to ${s}`),this.startPosition=s):e.live?s=this.hls.liveSyncPosition||t:this.startPosition=s=0,this.lastCurrentTime=s}this.nextLoadPosition=s}getLoadPosition(){const{media:e}=this;let t=0;return this.loadedmetadata&&e?t=e.currentTime:this.nextLoadPosition&&(t=this.nextLoadPosition),t}handleFragLoadAborted(e,t){this.transmuxer&&e.sn!=="initSegment"&&e.stats.aborted&&(this.warn(`Fragment ${e.sn}${t?" part "+t.index:""} of level ${e.level} was aborted`),this.resetFragmentLoading(e))}resetFragmentLoading(e){(!this.fragCurrent||!this.fragContextChanged(e)&&this.state!==N.FRAG_LOADING_WAITING_RETRY)&&(this.state=N.IDLE)}onFragmentOrKeyLoadError(e,t){if(t.chunkMeta&&!t.frag){const c=this.getCurrentContext(t.chunkMeta);c&&(t.frag=c.frag)}const s=t.frag;if(!s||s.type!==e||!this.levels)return;if(this.fragContextChanged(s)){var r;this.warn(`Frag load error must match current frag to retry ${s.url} > ${(r=this.fragCurrent)==null?void 0:r.url}`);return}const n=t.details===M.FRAG_GAP;n&&this.fragmentTracker.fragBuffered(s,!0);const a=t.errorAction,{action:o,retryCount:l=0,retryConfig:d}=a||{};if(a&&o===mt.RetryRequest&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);const c=fm(d,l);this.warn(`Fragment ${s.sn} of ${e} ${s.level} errored with ${t.details}, retrying loading ${l+1}/${d.maxNumRetry} in ${c}ms`),a.resolved=!0,this.retryDate=self.performance.now()+c,this.state=N.FRAG_LOADING_WAITING_RETRY}else if(d&&a)if(this.resetFragmentErrors(e),l<d.maxNumRetry)!n&&o!==mt.RemoveAlternatePermanently&&(a.resolved=!0);else{R.warn(`${t.details} reached or exceeded max retry (${l})`);return}else(a==null?void 0:a.action)===mt.SendAlternateToPenaltyBox?this.state=N.WAITING_LEVEL:this.state=N.ERROR;this.tickImmediate()}reduceLengthAndFlushBuffer(e){if(this.state===N.PARSING||this.state===N.PARSED){const t=e.parent,s=this.getFwdBufferInfo(this.mediaBuffer,t),r=s&&s.len>.5;r&&this.reduceMaxBufferLength(s.len);const n=!r;return n&&this.warn(`Buffer full error while media.currentTime is not buffered, flush ${t} buffer`),e.frag&&(this.fragmentTracker.removeFragment(e.frag),this.nextLoadPosition=e.frag.start),this.resetLoadingState(),n}return!1}resetFragmentErrors(e){e===te.AUDIO&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==N.STOPPED&&(this.state=N.IDLE)}afterBufferFlushed(e,t,s){if(!e)return;const r=Le.getBuffered(e);this.fragmentTracker.detectEvictedFragments(t,r,s),this.state===N.ENDED&&this.resetLoadingState()}resetLoadingState(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=N.IDLE}resetStartWhenNotLoaded(e){if(!this.loadedmetadata){this.startFragRequested=!1;const t=e?e.details:null;t!=null&&t.live?(this.startPosition=-1,this.setStartPosition(t,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}}resetWhenMissingContext(e){this.warn(`The loading context changed while buffering fragment ${e.sn} of level ${e.level}. This chunk will not be buffered.`),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()}removeUnbufferedFrags(e=0){this.fragmentTracker.removeFragmentsInRange(e,1/0,this.playlistType,!1,!0)}updateLevelTiming(e,t,s,r){var n;const a=s.details;if(!a){this.warn("level.details undefined");return}if(!Object.keys(e.elementaryStreams).reduce((l,d)=>{const c=e.elementaryStreams[d];if(c){const u=c.endPTS-c.startPTS;if(u<=0)return this.warn(`Could not parse fragment ${e.sn} ${d} duration reliably (${u})`),l||!1;const h=r?0:Vv(a,e,c.startPTS,c.endPTS,c.startDTS,c.endDTS);return this.hls.trigger(E.LEVEL_PTS_UPDATED,{details:a,level:s,drift:h,type:d,frag:e,start:c.startPTS,end:c.endPTS}),!0}return l},!1)&&((n=this.transmuxer)==null?void 0:n.error)===null){const l=new Error(`Found no media in fragment ${e.sn} of level ${e.level} resetting transmuxer to fallback to playlist timing`);if(s.fragmentError===0&&(s.fragmentError++,e.gap=!0,this.fragmentTracker.removeFragment(e),this.fragmentTracker.fragBuffered(e,!0)),this.warn(l.message),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:l,frag:e,reason:`Found no media in msn ${e.sn} of level "${s.url}"`}),!this.hls)return;this.resetTransmuxer()}this.state=N.PARSED,this.hls.trigger(E.FRAG_PARSED,{frag:e,part:t})}resetTransmuxer(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)}recoverWorkerError(e){e.event==="demuxerWorker"&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())}set state(e){const t=this._state;t!==e&&(this._state=e,this.log(`${t}->${e}`))}get state(){return this._state}}class Zv{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=Ix(e,t);else return new Uint8Array(0);return this.reset(),s}reset(){this.chunks.length=0,this.dataLength=0}}function Ix(i,e){const t=new Uint8Array(e);let s=0;for(let r=0;r<i.length;r++){const n=i[r];t.set(n,s),s+=n.length}return t}function Rx(){return typeof __HLS_WORKER_BUNDLE__=="function"}function wx(){const i=new self.Blob([`var exports={};var module={exports:exports};function define(f){f()};define.amd=true;(${__HLS_WORKER_BUNDLE__.toString()})(true);`],{type:"text/javascript"}),e=self.URL.createObjectURL(i);return{worker:new self.Worker(e),objectURL:e}}function Cx(i){const e=new self.URL(i,self.location.href).href;return{worker:new self.Worker(e),scriptURL:e}}function ki(i="",e=9e4){return{type:i,id:-1,pid:-1,inputTimeScale:e,sequenceNumber:-1,samples:[],dropped:0}}class Em{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,r){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=Vt(this.cachedData,e),this.cachedData=null);let s=Ya(e,0),r=s?s.length:0,n;const a=this._audioTrack,o=this._id3Track,l=s?hm(s):void 0,d=e.length;for((this.basePTS===null||this.frameIndex===0&&j(l))&&(this.basePTS=Dx(l,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:ei.audioId3,duration:Number.POSITIVE_INFINITY});r<d;){if(this.canParse(e,r)){const c=this.appendFrame(a,e,r);c?(this.frameIndex++,this.lastPTS=c.sample.pts,r+=c.length,n=r):r=d}else eS(e,r)?(s=Ya(e,r),o.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:s,type:ei.audioId3,duration:Number.POSITIVE_INFINITY}),r+=s.length,n=r):r++;if(r===d&&n!==d){const c=ur(e,n);this.cachedData?this.cachedData=Vt(this.cachedData,c):this.cachedData=c}}return{audioTrack:a,videoTrack:ki(),id3Track:o,textTrack:ki()}}demuxSampleAes(e,t,s){return Promise.reject(new Error(`[${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:ki(),id3Track:this._id3Track,textTrack:ki()}}destroy(){}}const Dx=(i,e,t)=>{if(j(i))return i*90;const s=t?t.baseTime*9e4/t.timescale:0;return e*9e4+s};function Mx(i,e,t,s){let r,n,a,o;const l=navigator.userAgent.toLowerCase(),d=s,c=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];r=((e[t+2]&192)>>>6)+1;const u=(e[t+2]&60)>>>2;if(u>c.length-1){const h=new Error(`invalid ADTS sampling index:${u}`);i.emit(E.ERROR,E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!0,error:h,reason:h.message});return}return a=(e[t+2]&1)<<2,a|=(e[t+3]&192)>>>6,R.log(`manifest codec:${s}, ADTS type:${r}, samplingIndex:${u}`),/firefox/i.test(l)?u>=6?(r=5,o=new Array(4),n=u-3):(r=2,o=new Array(2),n=u):l.indexOf("android")!==-1?(r=2,o=new Array(2),n=u):(r=5,o=new Array(4),s&&(s.indexOf("mp4a.40.29")!==-1||s.indexOf("mp4a.40.5")!==-1)||!s&&u>=6?n=u-3:((s&&s.indexOf("mp4a.40.2")!==-1&&(u>=6&&a===1||/vivaldi/i.test(l))||!s&&a===1)&&(r=2,o=new Array(2)),n=u)),o[0]=r<<3,o[0]|=(u&14)>>1,o[1]|=(u&1)<<7,o[1]|=a<<3,r===5&&(o[1]|=(n&14)>>1,o[2]=(n&1)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:c[u],channelCount:a,codec:"mp4a.40."+r,manifestCodec:d}}function Jv(i,e){return i[e]===255&&(i[e+1]&246)===240}function eE(i,e){return i[e+1]&1?7:9}function bm(i,e){return(i[e+3]&3)<<11|i[e+4]<<3|(i[e+5]&224)>>>5}function Ox(i,e){return e+5<i.length}function qd(i,e){return e+1<i.length&&Jv(i,e)}function Px(i,e){return Ox(i,e)&&Jv(i,e)&&bm(i,e)<=i.length-e}function Nx(i,e){if(qd(i,e)){const t=eE(i,e);if(e+t>=i.length)return!1;const s=bm(i,e);if(s<=t)return!1;const r=e+s;return r===i.length||qd(i,r)}return!1}function tE(i,e,t,s,r){if(!i.samplerate){const n=Mx(e,t,s,r);if(!n)return;i.config=n.config,i.samplerate=n.samplerate,i.channelCount=n.channelCount,i.codec=n.codec,i.manifestCodec=n.manifestCodec,R.log(`parsed codec:${i.codec}, rate:${n.samplerate}, channels:${n.channelCount}`)}}function iE(i){return 1024*9e4/i}function Ux(i,e){const t=eE(i,e);if(e+t<=i.length){const s=bm(i,e)-t;if(s>0)return{headerLength:t,frameLength:s}}}function sE(i,e,t,s,r){const n=iE(i.samplerate),a=s+r*n,o=Ux(e,t);let l;if(o){const{frameLength:u,headerLength:h}=o,f=h+u,m=Math.max(0,t+f-e.length);m?(l=new Uint8Array(f-h),l.set(e.subarray(t+h,e.length),0)):l=e.subarray(t+h,t+f);const p={unit:l,pts:a};return m||i.samples.push(p),{sample:p,length:f,missing:m}}const d=e.length-t;return l=new Uint8Array(d),l.set(e.subarray(t,e.length),0),{sample:{unit:l,pts:a},length:d,missing:-1}}let So=null;const Fx=[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],$x=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Bx=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Gx=[0,1,1,4];function rE(i,e,t,s,r){if(t+24>e.length)return;const n=nE(e,t);if(n&&t+n.frameLength<=e.length){const a=n.samplesPerFrame*9e4/n.sampleRate,o=s+r*a,l={unit:e.subarray(t,t+n.frameLength),pts:o,dts:o};return i.config=[],i.channelCount=n.channelCount,i.samplerate=n.sampleRate,i.samples.push(l),{sample:l,length:n.frameLength,missing:0}}}function nE(i,e){const t=i[e+1]>>3&3,s=i[e+1]>>1&3,r=i[e+2]>>4&15,n=i[e+2]>>2&3;if(t!==1&&r!==0&&r!==15&&n!==3){const a=i[e+2]>>1&1,o=i[e+3]>>6,l=t===3?3-s:s===3?3:4,d=Fx[l*14+r-1]*1e3,u=$x[(t===3?0:t===2?1:2)*3+n],h=o===3?1:2,f=Bx[t][s],m=Gx[s],p=f*8*m,g=Math.floor(f*d/u+a)*m;if(So===null){const b=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);So=b?parseInt(b[1]):0}return!!So&&So<=87&&s===2&&d>=224e3&&o===0&&(i[e+3]=i[e+3]|128),{sampleRate:u,channelCount:h,frameLength:g,samplesPerFrame:p}}}function ym(i,e){return i[e]===255&&(i[e+1]&224)===224&&(i[e+1]&6)!==0}function aE(i,e){return e+1<i.length&&ym(i,e)}function Hx(i,e){return ym(i,e)&&4<=i.length-e}function oE(i,e){if(e+1<i.length&&ym(i,e)){const s=nE(i,e);let r=4;s!=null&&s.frameLength&&(r=s.frameLength);const n=e+r;return n===i.length||aE(i,n)}return!1}class Wx extends Em{constructor(e,t){super(),this.observer=void 0,this.config=void 0,this.observer=e,this.config=t}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"aac",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Ya(e,0);let s=(t==null?void 0:t.length)||0;if(oE(e,s))return!1;for(let r=e.length;s<r;s++)if(Nx(e,s))return R.log("ADTS sync word found !"),!0;return!1}canParse(e,t){return Px(e,t)}appendFrame(e,t,s){tE(e,this.observer,t,s,e.manifestCodec);const r=sE(e,t,s,this.basePTS,this.frameIndex);if(r&&r.missing===0)return r}}const Kx=/\/emsg[-/]ID3/i;class Vx{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,r){const n=this.videoTrack=ki("video",1),a=this.audioTrack=ki("audio",1),o=this.txtTrack=ki("text",1);if(this.id3Track=ki("id3",1),this.timeOffset=0,!(e!=null&&e.byteLength))return;const l=Uv(e);if(l.video){const{id:d,timescale:c,codec:u}=l.video;n.id=d,n.timescale=o.timescale=c,n.codec=u}if(l.audio){const{id:d,timescale:c,codec:u}=l.audio;a.id=d,a.timescale=c,a.codec=u}o.id=Ov.text,n.sampleDuration=0,n.duration=a.duration=r}resetContiguity(){this.remainderData=null}static probe(e){return dS(e)}demux(e,t){this.timeOffset=t;let s=e;const r=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(s=Vt(this.remainderData,e));const o=vS(s);this.remainderData=o.remainder,r.samples=o.valid||new Uint8Array}else r.samples=s;const a=this.extractID3Track(r,t);return n.samples=Vp(t,r),{videoTrack:r,audioTrack:this.audioTrack,id3Track:a,textTrack:this.txtTrack}}flush(){const e=this.timeOffset,t=this.videoTrack,s=this.txtTrack;t.samples=this.remainderData||new Uint8Array,this.remainderData=null;const r=this.extractID3Track(t,this.timeOffset);return s.samples=Vp(e,t),{videoTrack:t,audioTrack:ki(),id3Track:r,textTrack:ki()}}extractID3Track(e,t){const s=this.id3Track;if(e.samples.length){const r=le(e.samples,["emsg"]);r&&r.forEach(n=>{const a=yS(n);if(Kx.test(a.schemeIdUri)){const o=j(a.presentationTime)?a.presentationTime/a.timeScale:t+a.presentationTimeDelta/a.timeScale;let l=a.eventDuration===4294967295?Number.POSITIVE_INFINITY:a.eventDuration/a.timeScale;l<=.001&&(l=Number.POSITIVE_INFINITY);const d=a.payload;s.samples.push({data:d,len:d.byteLength,dts:o,pts:o,type:ei.emsg,duration:l})}})}return s}demuxSampleAes(e,t,s){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))}destroy(){}}const lE=(i,e)=>{let t=0,s=5;e+=s;const r=new Uint32Array(1),n=new Uint32Array(1),a=new Uint8Array(1);for(;s>0;){a[0]=i[e];const o=Math.min(s,8),l=8-o;n[0]=4278190080>>>24+l<<l,r[0]=(a[0]&n[0])>>l,t=t?t<<o|r[0]:r[0],e+=1,s-=o}return t};class qx extends Em{constructor(e){super(),this.observer=void 0,this.observer=e}resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/ac-3",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"ac3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}canParse(e,t){return t+64<e.length}appendFrame(e,t,s){const r=dE(e,t,s,this.basePTS,this.frameIndex);if(r!==-1)return{sample:e.samples[e.samples.length-1],length:r,missing:0}}static probe(e){if(!e)return!1;const t=Ya(e,0);if(!t)return!1;const s=t.length;return e[s]===11&&e[s+1]===119&&hm(t)!==void 0&&lE(e,s)<16}}function dE(i,e,t,s,r){if(t+8>e.length||e[t]!==11||e[t+1]!==119)return-1;const n=e[t+4]>>6;if(n>=3)return-1;const o=[48e3,44100,32e3][n],l=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][l*3+n]*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,p=[2,1,2,3,3,4,4,5][u]+f,g=e[t+5]>>3,v=e[t+5]&7,y=new Uint8Array([n<<6|g<<1|v>>2,(v&3)<<6|u<<3|f<<2|l>>4,l<<4&224]),b=1536/o*9e4,x=s+r*b,_=e.subarray(t,t+c);return i.config=y,i.channelCount=p,i.samplerate=o,i.samples.push({unit:_,pts:x}),c}class Yx{constructor(){this.VideoSample=null}createVideoSample(e,t,s,r){return{key:e,frame:!1,pts:t,dts:s,units:[],debug:r,length:0}}getLastNalUnit(e){var t;let s=this.VideoSample,r;if((!s||s.units.length===0)&&(s=e[e.length-1]),(t=s)!=null&&t.units){const n=s.units;r=n[n.length-1]}return r}pushAccessUnit(e,t){if(e.units.length&&e.frame){if(e.pts===void 0){const s=t.samples,r=s.length;if(r){const n=s[r-1];e.pts=n.pts,e.dts=n.dts}else{t.dropped++;return}}t.samples.push(e)}e.debug.length&&R.log(e.pts+"/"+e.dts+":"+e.debug)}}class b0{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,r=new Uint8Array(4),n=Math.min(4,t);if(n===0)throw new Error("no bytes available");r.set(e.subarray(s,s+n)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=n*8,this.bytesAvailable-=n}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&&R.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)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)}skipScalingList(e){let t=8,s=8,r;for(let n=0;n<e;n++)s!==0&&(r=this.readEG(),s=(t+r+256)%256),t=s===0?t:s}readSPS(){let e=0,t=0,s=0,r=0,n,a,o;const l=this.readUByte.bind(this),d=this.readBits.bind(this),c=this.readUEG.bind(this),u=this.readBoolean.bind(this),h=this.skipBits.bind(this),f=this.skipEG.bind(this),m=this.skipUEG.bind(this),p=this.skipScalingList.bind(this);l();const g=l();if(d(5),h(3),l(),m(),g===100||g===110||g===122||g===244||g===44||g===83||g===86||g===118||g===128){const S=c();if(S===3&&h(1),m(),m(),h(1),u())for(a=S!==3?8:12,o=0;o<a;o++)u()&&(o<6?p(16):p(64))}m();const v=c();if(v===0)c();else if(v===1)for(h(1),f(),f(),n=c(),o=0;o<n;o++)f();m(),h(1);const y=c(),b=c(),x=d(1);x===0&&h(1),h(1),u()&&(e=c(),t=c(),s=c(),r=c());let _=[1,1];if(u()&&u())switch(l()){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:{_=[l()<<8|l(),l()<<8|l()];break}}return{width:Math.ceil((y+1)*16-e*2-t*2),height:(2-x)*(b+1)*16-(x?2:4)*(s+r),pixelRatio:_}}readSliceType(){return this.readUByte(),this.readUEG(),this.readUEG()}}class jx extends Yx{parseAVCPES(e,t,s,r,n){const a=this.parseAVCNALu(e,s.data);let o=this.VideoSample,l,d=!1;s.data=null,o&&a.length&&!e.audFound&&(this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"")),a.forEach(c=>{var u;switch(c.type){case 1:{let p=!1;l=!0;const g=c.data;if(d&&g.length>4){const v=new b0(g).readSliceType();(v===2||v===4||v===7||v===9)&&(p=!0)}if(p){var h;(h=o)!=null&&h.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null)}o||(o=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts,"")),o.frame=!0,o.key=p;break}case 5:l=!0,(u=o)!=null&&u.frame&&!o.key&&(this.pushAccessUnit(o,e),o=this.VideoSample=null),o||(o=this.VideoSample=this.createVideoSample(!0,s.pts,s.dts,"")),o.key=!0,o.frame=!0;break;case 6:{l=!0,$v(c.data,1,s.pts,t.samples);break}case 7:{var f,m;l=!0,d=!0;const p=c.data,v=new b0(p).readSPS();if(!e.sps||e.width!==v.width||e.height!==v.height||((f=e.pixelRatio)==null?void 0:f[0])!==v.pixelRatio[0]||((m=e.pixelRatio)==null?void 0:m[1])!==v.pixelRatio[1]){e.width=v.width,e.height=v.height,e.pixelRatio=v.pixelRatio,e.sps=[p],e.duration=n;const y=p.subarray(1,4);let b="avc1.";for(let x=0;x<3;x++){let _=y[x].toString(16);_.length<2&&(_="0"+_),b+=_}e.codec=b}break}case 8:l=!0,e.pps=[c.data];break;case 9:l=!0,e.audFound=!0,o&&this.pushAccessUnit(o,e),o=this.VideoSample=this.createVideoSample(!1,s.pts,s.dts,"");break;case 12:l=!0;break;default:l=!1,o&&(o.debug+="unknown NAL "+c.type+" ");break}o&&l&&o.units.push(c)}),r&&o&&(this.pushAccessUnit(o,e),this.VideoSample=null)}parseAVCNALu(e,t){const s=t.byteLength;let r=e.naluState||0;const n=r,a=[];let o=0,l,d,c,u=-1,h=0;for(r===-1&&(u=0,h=t[0]&31,r=0,o=1);o<s;){if(l=t[o++],!r){r=l?0:1;continue}if(r===1){r=l?0:2;continue}if(!l)r=3;else if(l===1){if(d=o-r-1,u>=0){const f={data:t.subarray(u,d),type:h};a.push(f)}else{const f=this.getLastNalUnit(e.samples);f&&(n&&o<=4-n&&f.state&&(f.data=f.data.subarray(0,f.data.byteLength-n)),d>0&&(f.data=Vt(f.data,t.subarray(0,d)),f.state=0))}o<s?(c=t[o]&31,u=o,h=c,r=0):r=-1}else r=0}if(u>=0&&r>=0){const f={data:t.subarray(u,s),type:h,state:r};a.push(f)}if(a.length===0){const f=this.getLastNalUnit(e.samples);f&&(f.data=Vt(f.data,t))}return e.naluState=r,a}}class zx{constructor(e,t,s){this.keyData=void 0,this.decrypter=void 0,this.keyData=s,this.decrypter=new gm(t,{removePKCS7Padding:!1})}decryptBuffer(e){return this.decrypter.decrypt(e,this.keyData.key.buffer,this.keyData.iv.buffer)}decryptAacSample(e,t,s){const r=e[t].unit;if(r.length<=16)return;const n=r.subarray(16,r.length-r.length%16),a=n.buffer.slice(n.byteOffset,n.byteOffset+n.length);this.decryptBuffer(a).then(o=>{const l=new Uint8Array(o);r.set(l,16),this.decrypter.isSync()||this.decryptAacSamples(e,t+1,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 r=0;for(let n=32;n<e.length-16;n+=160,r+=16)s.set(e.subarray(n,n+16),r);return s}getAvcDecryptedUnit(e,t){const s=new Uint8Array(t);let r=0;for(let n=32;n<e.length-16;n+=160,r+=16)e.set(s.subarray(r,r+16),n);return e}decryptAvcSample(e,t,s,r,n){const a=Bv(n.data),o=this.getAvcEncryptedData(a);this.decryptBuffer(o.buffer).then(l=>{n.data=this.getAvcDecryptedUnit(a,l),this.decrypter.isSync()||this.decryptAvcSamples(e,t,s+1,r)})}decryptAvcSamples(e,t,s,r){if(e instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;t++,s=0){if(t>=e.length){r();return}const n=e[t].units;for(;!(s>=n.length);s++){const a=n[s];if(!(a.data.length<=48||a.type!==1&&a.type!==5)&&(this.decryptAvcSample(e,t,s,r,a),!this.decrypter.isSync()))return}}}}const Je=188;class ms{constructor(e,t,s){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._duration=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.videoParser=new jx}static probe(e){const t=ms.syncOffset(e);return t>0&&R.warn(`MPEG2-TS detected but first sync word found @ offset ${t}`),t!==-1}static syncOffset(e){const t=e.length;let s=Math.min(Je*5,t-Je)+1,r=0;for(;r<s;){let n=!1,a=-1,o=0;for(let l=r;l<t;l+=Je)if(e[l]===71&&(t-l===Je||e[l+Je]===71)){if(o++,a===-1&&(a=l,a!==0&&(s=Math.min(a+Je*99,e.length-Je)+1)),n||(n=th(e,l)===0),n&&o>1&&(a===0&&o>2||l+Je>s))return a}else{if(o)return-1;break}r++}return-1}static createTrack(e,t){return{container:e==="video"||e==="audio"?"video/mp2t":void 0,type:e,id:Ov[e],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:e==="audio"?t:void 0}}resetInitSegment(e,t,s,r){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=ms.createTrack("video"),this._audioTrack=ms.createTrack("audio",r),this._id3Track=ms.createTrack("id3"),this._txtTrack=ms.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=t,this.videoCodec=s,this._duration=r}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,r=!1){s||(this.sampleAes=null);let n;const a=this._videoTrack,o=this._audioTrack,l=this._id3Track,d=this._txtTrack;let c=a.pid,u=a.pesData,h=o.pid,f=l.pid,m=o.pesData,p=l.pesData,g=null,v=this.pmtParsed,y=this._pmtId,b=e.length;if(this.remainderData&&(e=Vt(this.remainderData,e),b=e.length,this.remainderData=null),b<Je&&!r)return this.remainderData=e,{audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};const x=Math.max(0,ms.syncOffset(e));b-=(b-x)%Je,b<e.byteLength&&!r&&(this.remainderData=new Uint8Array(e.buffer,b,e.buffer.byteLength-b));let _=0;for(let A=x;A<b;A+=Je)if(e[A]===71){const D=!!(e[A+1]&64),O=th(e,A),L=(e[A+3]&48)>>4;let C;if(L>1){if(C=A+5+e[A+4],C===A+Je)continue}else C=A+4;switch(O){case c:D&&(u&&(n=Pr(u))&&this.videoParser.parseAVCPES(a,d,n,!1,this._duration),u={data:[],size:0}),u&&(u.data.push(e.subarray(C,A+Je)),u.size+=A+Je-C);break;case h:if(D){if(m&&(n=Pr(m)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,n);break;case"mp3":this.parseMPEGPES(o,n);break;case"ac3":this.parseAC3PES(o,n);break}m={data:[],size:0}}m&&(m.data.push(e.subarray(C,A+Je)),m.size+=A+Je-C);break;case f:D&&(p&&(n=Pr(p))&&this.parseID3PES(l,n),p={data:[],size:0}),p&&(p.data.push(e.subarray(C,A+Je)),p.size+=A+Je-C);break;case 0:D&&(C+=e[C]+1),y=this._pmtId=Xx(e,C);break;case y:{D&&(C+=e[C]+1);const H=Qx(e,C,this.typeSupported,s,this.observer);c=H.videoPid,c>0&&(a.pid=c,a.segmentCodec=H.segmentVideoCodec),h=H.audioPid,h>0&&(o.pid=h,o.segmentCodec=H.segmentAudioCodec),f=H.id3Pid,f>0&&(l.pid=f),g!==null&&!v&&(R.warn(`MPEG-TS PMT found at ${A} after unknown PID '${g}'. Backtracking to sync byte @${x} to parse all TS packets.`),g=null,A=x-188),v=this.pmtParsed=!0;break}case 17:case 8191:break;default:g=O;break}}else _++;_>0&&Yd(this.observer,new Error(`Found ${_} TS packet/s that do not start with 0x47`)),a.pesData=u,o.pesData=m,l.pesData=p;const S={audioTrack:o,videoTrack:a,id3Track:l,textTrack:d};return r&&this.extractRemainingSamples(S),S}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:r,textTrack:n}=e,a=s.pesData,o=t.pesData,l=r.pesData;let d;if(a&&(d=Pr(a))?(this.videoParser.parseAVCPES(s,n,d,!0,this._duration),s.pesData=null):s.pesData=a,o&&(d=Pr(o))){switch(t.segmentCodec){case"aac":this.parseAACPES(t,d);break;case"mp3":this.parseMPEGPES(t,d);break;case"ac3":this.parseAC3PES(t,d);break}t.pesData=null}else o!=null&&o.size&&R.log("last AAC PES packet truncated,might overlap between fragments"),t.pesData=o;l&&(d=Pr(l))?(this.parseID3PES(r,d),r.pesData=null):r.pesData=l}demuxSampleAes(e,t,s){const r=this.demux(e,s,!0,!this.config.progressive),n=this.sampleAes=new zx(this.observer,this.config,t);return this.decrypt(r,n)}decrypt(e,t){return new Promise(s=>{const{audioTrack:r,videoTrack:n}=e;r.samples&&r.segmentCodec==="aac"?t.decryptAacSamples(r.samples,0,()=>{n.samples?t.decryptAvcSamples(n.samples,0,0,()=>{s(e)}):s(e)}):n.samples&&t.decryptAvcSamples(n.samples,0,0,()=>{s(e)})})}destroy(){this._duration=0}parseAACPES(e,t){let s=0;const r=this.aacOverFlow;let n=t.data;if(r){this.aacOverFlow=null;const u=r.missing,h=r.sample.unit.byteLength;if(u===-1)n=Vt(r.sample.unit,n);else{const f=h-u;r.sample.unit.set(n.subarray(0,u),f),e.samples.push(r.sample),s=r.missing}}let a,o;for(a=s,o=n.length;a<o-1&&!qd(n,a);a++);if(a!==s){let u;const h=a<o-1;if(h?u=`AAC PES did not start with ADTS header,offset:${a}`:u="No ADTS header found in AAC PES",Yd(this.observer,new Error(u),h),!h)return}tE(e,this.observer,n,a,this.audioCodec);let l;if(t.pts!==void 0)l=t.pts;else if(r){const u=iE(e.samplerate);l=r.sample.pts+u}else{R.warn("[tsdemuxer]: AAC PES unknown PTS");return}let d=0,c;for(;a<o;)if(c=sE(e,n,a,l,d),a+=c.length,c.missing){this.aacOverFlow=c;break}else for(d++;a<o-1&&!qd(n,a);a++);}parseMPEGPES(e,t){const s=t.data,r=s.length;let n=0,a=0;const o=t.pts;if(o===void 0){R.warn("[tsdemuxer]: MPEG PES unknown PTS");return}for(;a<r;)if(aE(s,a)){const l=rE(e,s,a,o,n);if(l)a+=l.length,n++;else break}else a++}parseAC3PES(e,t){{const s=t.data,r=t.pts;if(r===void 0){R.warn("[tsdemuxer]: AC3 PES unknown PTS");return}const n=s.length;let a=0,o=0,l;for(;o<n&&(l=dE(e,s,o,r,a++))>0;)o+=l}}parseID3PES(e,t){if(t.pts===void 0){R.warn("[tsdemuxer]: ID3 PES unknown PTS");return}const s=Ke({},t,{type:this._videoTrack?ei.emsg:ei.audioId3,duration:Number.POSITIVE_INFINITY});e.samples.push(s)}}function th(i,e){return((i[e+1]&31)<<8)+i[e+2]}function Xx(i,e){return(i[e+10]&31)<<8|i[e+11]}function Qx(i,e,t,s,r){const n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=(i[e+1]&15)<<8|i[e+2],o=e+3+a-4,l=(i[e+10]&15)<<8|i[e+11];for(e+=12+l;e<o;){const d=th(i,e),c=(i[e+3]&15)<<8|i[e+4];switch(i[e]){case 207:if(!s){su("ADTS AAC");break}case 15:n.audioPid===-1&&(n.audioPid=d);break;case 21:n.id3Pid===-1&&(n.id3Pid=d);break;case 219:if(!s){su("H.264");break}case 27:n.videoPid===-1&&(n.videoPid=d,n.segmentVideoCodec="avc");break;case 3:case 4:!t.mpeg&&!t.mp3?R.log("MPEG audio found, not supported in this browser"):n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="mp3");break;case 193:if(!s){su("AC-3");break}case 129:t.ac3?n.audioPid===-1&&(n.audioPid=d,n.segmentAudioCodec="ac3"):R.log("AC-3 audio found, not supported in this browser");break;case 6:if(n.audioPid===-1&&c>0){let u=e+5,h=c;for(;h>2;){switch(i[u]){case 106:t.ac3!==!0?R.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=d,n.segmentAudioCodec="ac3");break}const m=i[u+1]+2;u+=m,h-=m}}break;case 194:case 135:return Yd(r,new Error("Unsupported EC-3 in M2TS found")),n;case 36:return Yd(r,new Error("Unsupported HEVC in M2TS found")),n}e+=c+5}return n}function Yd(i,e,t){R.warn(`parsing error: ${e.message}`),i.emit(E.ERROR,E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,levelRetry:t,error:e,reason:e.message})}function su(i){R.log(`${i} with AES-128-CBC encryption found in unencrypted stream`)}function Pr(i){let e=0,t,s,r,n,a;const o=i.data;if(!i||i.size===0)return null;for(;o[0].length<19&&o.length>1;)o[0]=Vt(o[0],o[1]),o.splice(1,1);if(t=o[0],(t[0]<<16)+(t[1]<<8)+t[2]===1){if(s=(t[4]<<8)+t[5],s&&s>i.size-6)return null;const d=t[7];d&192&&(n=(t[9]&14)*536870912+(t[10]&255)*4194304+(t[11]&254)*16384+(t[12]&255)*128+(t[13]&254)/2,d&64?(a=(t[14]&14)*536870912+(t[15]&255)*4194304+(t[16]&254)*16384+(t[17]&255)*128+(t[18]&254)/2,n-a>60*9e4&&(R.warn(`${Math.round((n-a)/9e4)}s delta between PTS and DTS, align them`),n=a)):a=n),r=t[8];let c=r+9;if(i.size<=c)return null;i.size-=c;const u=new Uint8Array(i.size);for(let h=0,f=o.length;h<f;h++){t=o[h];let m=t.byteLength;if(c)if(c>m){c-=m;continue}else t=t.subarray(c),m-=c,c=0;u.set(t,e),e+=m}return s&&(s-=r+3),{data:u,pts:n,dts:a,len:s}}return null}class Zx extends Em{resetInitSegment(e,t,s,r){super.resetInitSegment(e,t,s,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:t,duration:r,inputTimeScale:9e4,dropped:0}}static probe(e){if(!e)return!1;const t=Ya(e,0);let s=(t==null?void 0:t.length)||0;if(t&&e[s]===11&&e[s+1]===119&&hm(t)!==void 0&&lE(e,s)<=16)return!1;for(let r=e.length;s<r;s++)if(oE(e,s))return R.log("MPEG Audio sync word found !"),!0;return!1}canParse(e,t){return Hx(e,t)}appendFrame(e,t,s){if(this.basePTS!==null)return rE(e,t,s,this.basePTS,this.frameIndex)}}class y0{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 is=Math.pow(2,32)-1;class w{static init(){w.types={avc1:[],avcC:[],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 w.types)w.types.hasOwnProperty(e)&&(w.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]);w.HDLR_TYPES={video:t,audio:s};const r=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),n=new Uint8Array([0,0,0,0,0,0,0,0]);w.STTS=w.STSC=w.STCO=n,w.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),w.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),w.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),w.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);const a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),l=new Uint8Array([0,0,0,1]);w.FTYP=w.box(w.types.ftyp,a,l,a,o),w.DINF=w.box(w.types.dinf,w.box(w.types.dref,r))}static box(e,...t){let s=8,r=t.length;const n=r;for(;r--;)s+=t[r].byteLength;const a=new Uint8Array(s);for(a[0]=s>>24&255,a[1]=s>>16&255,a[2]=s>>8&255,a[3]=s&255,a.set(e,4),r=0,s=8;r<n;r++)a.set(t[r],s),s+=t[r].byteLength;return a}static hdlr(e){return w.box(w.types.hdlr,w.HDLR_TYPES[e])}static mdat(e){return w.box(w.types.mdat,e)}static mdhd(e,t){t*=e;const s=Math.floor(t/(is+1)),r=Math.floor(t%(is+1));return w.box(w.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,r>>24,r>>16&255,r>>8&255,r&255,85,196,0,0]))}static mdia(e){return w.box(w.types.mdia,w.mdhd(e.timescale,e.duration),w.hdlr(e.type),w.minf(e))}static mfhd(e){return w.box(w.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"?w.box(w.types.minf,w.box(w.types.smhd,w.SMHD),w.DINF,w.stbl(e)):w.box(w.types.minf,w.box(w.types.vmhd,w.VMHD),w.DINF,w.stbl(e))}static moof(e,t,s){return w.box(w.types.moof,w.mfhd(e),w.traf(s,t))}static moov(e){let t=e.length;const s=[];for(;t--;)s[t]=w.trak(e[t]);return w.box.apply(null,[w.types.moov,w.mvhd(e[0].timescale,e[0].duration)].concat(s).concat(w.mvex(e)))}static mvex(e){let t=e.length;const s=[];for(;t--;)s[t]=w.trex(e[t]);return w.box.apply(null,[w.types.mvex,...s])}static mvhd(e,t){t*=e;const s=Math.floor(t/(is+1)),r=Math.floor(t%(is+1)),n=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,r>>24,r>>16&255,r>>8&255,r&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 w.box(w.types.mvhd,n)}static sdtp(e){const t=e.samples||[],s=new Uint8Array(4+t.length);let r,n;for(r=0;r<t.length;r++)n=t[r].flags,s[r+4]=n.dependsOn<<4|n.isDependedOn<<2|n.hasRedundancy;return w.box(w.types.sdtp,s)}static stbl(e){return w.box(w.types.stbl,w.stsd(e),w.box(w.types.stts,w.STTS),w.box(w.types.stsc,w.STSC),w.box(w.types.stsz,w.STSZ),w.box(w.types.stco,w.STCO))}static avc1(e){let t=[],s=[],r,n,a;for(r=0;r<e.sps.length;r++)n=e.sps[r],a=n.byteLength,t.push(a>>>8&255),t.push(a&255),t=t.concat(Array.prototype.slice.call(n));for(r=0;r<e.pps.length;r++)n=e.pps[r],a=n.byteLength,s.push(a>>>8&255),s.push(a&255),s=s.concat(Array.prototype.slice.call(n));const o=w.box(w.types.avcC,new Uint8Array([1,t[3],t[4],t[5],255,224|e.sps.length].concat(t).concat([e.pps.length]).concat(s))),l=e.width,d=e.height,c=e.pixelRatio[0],u=e.pixelRatio[1];return w.box(w.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,l>>8&255,l&255,d>>8&255,d&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,w.box(w.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),w.box(w.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.length;return new Uint8Array([0,0,0,0,3,23+t,0,1,0,4,15+t,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([t]).concat(e.config).concat([6,1,2]))}static audioStsd(e){const t=e.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,e.channelCount,0,16,0,0,0,0,t>>8&255,t&255,0,0])}static mp4a(e){return w.box(w.types.mp4a,w.audioStsd(e),w.box(w.types.esds,w.esds(e)))}static mp3(e){return w.box(w.types[".mp3"],w.audioStsd(e))}static ac3(e){return w.box(w.types["ac-3"],w.audioStsd(e),w.box(w.types.dac3,e.config))}static stsd(e){return e.type==="audio"?e.segmentCodec==="mp3"&&e.codec==="mp3"?w.box(w.types.stsd,w.STSD,w.mp3(e)):e.segmentCodec==="ac3"?w.box(w.types.stsd,w.STSD,w.ac3(e)):w.box(w.types.stsd,w.STSD,w.mp4a(e)):w.box(w.types.stsd,w.STSD,w.avc1(e))}static tkhd(e){const t=e.id,s=e.duration*e.timescale,r=e.width,n=e.height,a=Math.floor(s/(is+1)),o=Math.floor(s%(is+1));return w.box(w.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,a>>24,a>>16&255,a>>8&255,a&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,r>>8&255,r&255,0,0,n>>8&255,n&255,0,0]))}static traf(e,t){const s=w.sdtp(e),r=e.id,n=Math.floor(t/(is+1)),a=Math.floor(t%(is+1));return w.box(w.types.traf,w.box(w.types.tfhd,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,r&255])),w.box(w.types.tfdt,new Uint8Array([1,0,0,0,n>>24,n>>16&255,n>>8&255,n&255,a>>24,a>>16&255,a>>8&255,a&255])),w.trun(e,s.length+16+20+8+16+8+8),s)}static trak(e){return e.duration=e.duration||4294967295,w.box(w.types.trak,w.tkhd(e),w.mdia(e))}static trex(e){const t=e.id;return w.box(w.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||[],r=s.length,n=12+16*r,a=new Uint8Array(n);let o,l,d,c,u,h;for(t+=8+n,a.set([e.type==="video"?1:0,0,15,1,r>>>24&255,r>>>16&255,r>>>8&255,r&255,t>>>24&255,t>>>16&255,t>>>8&255,t&255],0),o=0;o<r;o++)l=s[o],d=l.duration,c=l.size,u=l.flags,h=l.cts,a.set([d>>>24&255,d>>>16&255,d>>>8&255,d&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 w.box(w.types.trun,a)}static initSegment(e){w.types||w.init();const t=w.moov(e);return Vt(w.FTYP,t)}}w.types=void 0;w.HDLR_TYPES=void 0;w.STTS=void 0;w.STSC=void 0;w.STCO=void 0;w.STSZ=void 0;w.VMHD=void 0;w.SMHD=void 0;w.STSD=void 0;w.FTYP=void 0;w.DINF=void 0;const cE=9e4;function Tm(i,e,t=1,s=!1){const r=i*e*t;return s?Math.round(r):r}function Jx(i,e,t=1,s=!1){return Tm(i,e,1/t,s)}function Vn(i,e=!1){return Tm(i,1e3,1/cE,e)}function ek(i,e=1){return Tm(i,cE,1/e)}const tk=10*1e3,T0=1024,ik=1152,sk=1536;let Nr=null,ru=null;class rl{constructor(e,t,s,r=""){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=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,Nr===null){const a=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Nr=a?parseInt(a[1]):0}if(ru===null){const n=navigator.userAgent.match(/Safari\/(\d+)/i);ru=n?parseInt(n[1]):0}}destroy(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null}resetTimeStamp(e){R.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=e}resetNextTimestamp(){R.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1}resetInitSegment(){R.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0}getVideoStartPts(e){let t=!1;const s=e.reduce((r,n)=>{const a=n.pts-r;return a<-4294967296?(t=!0,Kt(r,n.pts)):a>0?r:n.pts},e[0].pts);return t&&R.debug("PTS rollover detected"),s}remux(e,t,s,r,n,a,o,l){let d,c,u,h,f,m,p=n,g=n;const v=e.pid>-1,y=t.pid>-1,b=t.samples.length,x=e.samples.length>0,_=o&&b>0||b>1;if((!v||x)&&(!y||_)||this.ISGenerated||o){if(this.ISGenerated){var A,D,O,L;const Q=this.videoTrackConfig;Q&&(t.width!==Q.width||t.height!==Q.height||((A=t.pixelRatio)==null?void 0:A[0])!==((D=Q.pixelRatio)==null?void 0:D[0])||((O=t.pixelRatio)==null?void 0:O[1])!==((L=Q.pixelRatio)==null?void 0:L[1]))&&this.resetInitSegment()}else u=this.generateIS(e,t,n,a);const C=this.isVideoContiguous;let H=-1,U;if(_&&(H=rk(t.samples),!C&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,H>0){R.warn(`[mp4-remuxer]: Dropped ${H} out of ${b} video samples due to a missing keyframe`);const Q=this.getVideoStartPts(t.samples);t.samples=t.samples.slice(H),t.dropped+=H,g+=(t.samples[0].pts-Q)/t.inputTimeScale,U=g}else H===-1&&(R.warn(`[mp4-remuxer]: No keyframe found out of ${b} video samples`),m=!1);if(this.ISGenerated){if(x&&_){const Q=this.getVideoStartPts(t.samples),Y=(Kt(e.samples[0].pts,Q)-Q)/t.inputTimeScale;p+=Math.max(0,Y),g+=Math.max(0,-Y)}if(x){if(e.samplerate||(R.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),u=this.generateIS(e,t,n,a)),c=this.remuxAudio(e,p,this.isAudioContiguous,a,y||_||l===te.AUDIO?g:void 0),_){const Q=c?c.endPTS-c.startPTS:0;t.inputTimeScale||(R.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),u=this.generateIS(e,t,n,a)),d=this.remuxVideo(t,g,C,Q)}}else _&&(d=this.remuxVideo(t,g,C,0));d&&(d.firstKeyFrame=H,d.independent=H!==-1,d.firstKeyFramePTS=U)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(s.samples.length&&(f=uE(s,n,this._initPTS,this._initDTS)),r.samples.length&&(h=hE(r,n,this._initPTS))),{audio:c,video:d,initSegment:u,independent:m,text:h,id3:f}}generateIS(e,t,s,r){const n=e.samples,a=t.samples,o=this.typeSupported,l={},d=this._initPTS;let c=!d||r,u="audio/mp4",h,f,m;if(c&&(h=f=1/0),e.config&&n.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}l.audio={id:"audio",container:u,codec:e.codec,initSegment:e.segmentCodec==="mp3"&&o.mpeg?new Uint8Array(0):w.initSegment([e]),metadata:{channelCount:e.channelCount}},c&&(m=e.inputTimeScale,!d||m!==d.timescale?h=f=n[0].pts-Math.round(m*s):c=!1)}if(t.sps&&t.pps&&a.length){if(t.timescale=t.inputTimeScale,l.video={id:"main",container:"video/mp4",codec:t.codec,initSegment:w.initSegment([t]),metadata:{width:t.width,height:t.height}},c)if(m=t.inputTimeScale,!d||m!==d.timescale){const p=this.getVideoStartPts(a),g=Math.round(m*s);f=Math.min(f,Kt(a[0].dts,p)-g),h=Math.min(h,p-g)}else c=!1;this.videoTrackConfig={width:t.width,height:t.height,pixelRatio:t.pixelRatio}}if(Object.keys(l).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:h,timescale:m},this._initDTS={baseTime:f,timescale:m}):h=m=void 0,{tracks:l,initPTS:h,timescale:m}}remuxVideo(e,t,s,r){const n=e.inputTimeScale,a=e.samples,o=[],l=a.length,d=this._initPTS;let c=this.nextAvcDts,u=8,h=this.videoSampleDuration,f,m,p=Number.POSITIVE_INFINITY,g=Number.NEGATIVE_INFINITY,v=!1;if(!s||c===null){const G=t*n,F=a[0].pts-Kt(a[0].dts,a[0].pts);Nr&&c!==null&&Math.abs(G-F-c)<15e3?s=!0:c=G-F}const y=d.baseTime*n/d.timescale;for(let G=0;G<l;G++){const F=a[G];F.pts=Kt(F.pts-y,c),F.dts=Kt(F.dts-y,c),F.dts<a[G>0?G-1:G].dts&&(v=!0)}v&&a.sort(function(G,F){const re=G.dts-F.dts,J=G.pts-F.pts;return re||J}),f=a[0].dts,m=a[a.length-1].dts;const b=m-f,x=b?Math.round(b/(l-1)):h||e.inputTimeScale/30;if(s){const G=f-c,F=G>x,re=G<-1;if((F||re)&&(F?R.warn(`AVC: ${Vn(G,!0)} ms (${G}dts) hole between fragments detected at ${t.toFixed(3)}`):R.warn(`AVC: ${Vn(-G,!0)} ms (${G}dts) overlapping between fragments detected at ${t.toFixed(3)}`),!re||c>=a[0].pts||Nr)){f=c;const J=a[0].pts-G;if(F)a[0].dts=f,a[0].pts=J;else for(let de=0;de<a.length&&!(a[de].dts>J);de++)a[de].dts-=G,a[de].pts-=G;R.log(`Video: Initial PTS/DTS adjusted: ${Vn(J,!0)}/${Vn(f,!0)}, delta: ${Vn(G,!0)} ms`)}}f=Math.max(0,f);let _=0,S=0,A=f;for(let G=0;G<l;G++){const F=a[G],re=F.units,J=re.length;let de=0;for(let Ae=0;Ae<J;Ae++)de+=re[Ae].data.length;S+=de,_+=J,F.length=de,F.dts<A?(F.dts=A,A+=x/4|0||1):A=F.dts,p=Math.min(F.pts,p),g=Math.max(F.pts,g)}m=a[l-1].dts;const D=S+4*_+8;let O;try{O=new Uint8Array(D)}catch(G){this.observer.emit(E.ERROR,E.ERROR,{type:se.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:G,bytes:D,reason:`fail allocating video mdat ${D}`});return}const L=new DataView(O.buffer);L.setUint32(0,D),O.set(w.types.mdat,4);let C=!1,H=Number.POSITIVE_INFINITY,U=Number.POSITIVE_INFINITY,Q=Number.NEGATIVE_INFINITY,q=Number.NEGATIVE_INFINITY;for(let G=0;G<l;G++){const F=a[G],re=F.units;let J=0;for(let Ce=0,He=re.length;Ce<He;Ce++){const St=re[Ce],ts=St.data,wr=St.data.byteLength;L.setUint32(u,wr),u+=4,O.set(ts,u),u+=wr,J+=4+wr}let de;if(G<l-1)h=a[G+1].dts-F.dts,de=a[G+1].pts-F.pts;else{const Ce=this.config,He=G>0?F.dts-a[G-1].dts:x;if(de=G>0?F.pts-a[G-1].pts:x,Ce.stretchShortVideoTrack&&this.nextAudioPts!==null){const St=Math.floor(Ce.maxBufferHole*n),ts=(r?p+r*n:this.nextAudioPts)-F.pts;ts>St?(h=ts-He,h<0?h=He:C=!0,R.log(`[mp4-remuxer]: It is approximately ${ts/90} ms to the next segment; using duration ${h/90} ms for the last video frame.`)):h=He}else h=He}const Ae=Math.round(F.pts-F.dts);H=Math.min(H,h),Q=Math.max(Q,h),U=Math.min(U,de),q=Math.max(q,de),o.push(new _0(F.key,h,J,Ae))}if(o.length){if(Nr){if(Nr<70){const G=o[0].flags;G.dependsOn=2,G.isNonSync=0}}else if(ru&&q-U<Q-H&&x/Q<.025&&o[0].cts===0){R.warn("Found irregular gaps in sample duration. Using PTS instead of DTS to determine MP4 sample duration.");let G=f;for(let F=0,re=o.length;F<re;F++){const J=G+o[F].duration,de=G+o[F].cts;if(F<re-1){const Ae=J+o[F+1].cts;o[F].duration=Ae-de}else o[F].duration=F?o[F-1].duration:x;o[F].cts=0,G=J}}}h=C||!h?x:h,this.nextAvcDts=c=m+h,this.videoSampleDuration=h,this.isVideoContiguous=!0;const ae={data1:w.moof(e.sequenceNumber++,f,Ke({},e,{samples:o})),data2:O,startPTS:p/n,endPTS:(g+h)/n,startDTS:f/n,endDTS:c/n,type:"video",hasAudio:!1,hasVideo:!0,nb:o.length,dropped:e.dropped};return e.samples=[],e.dropped=0,ae}getSamplesPerFrame(e){switch(e.segmentCodec){case"mp3":return ik;case"ac3":return sk;default:return T0}}remuxAudio(e,t,s,r,n){const a=e.inputTimeScale,o=e.samplerate?e.samplerate:a,l=a/o,d=this.getSamplesPerFrame(e),c=d*l,u=this._initPTS,h=e.segmentCodec==="mp3"&&this.typeSupported.mpeg,f=[],m=n!==void 0;let p=e.samples,g=h?0:8,v=this.nextAudioPts||-1;const y=t*a,b=u.baseTime*a/u.timescale;if(this.isAudioContiguous=s=s||p.length&&v>0&&(r&&Math.abs(y-v)<9e3||Math.abs(Kt(p[0].pts-b,y)-v)<20*c),p.forEach(function(Y){Y.pts=Kt(Y.pts-b,y)}),!s||v<0){if(p=p.filter(Y=>Y.pts>=0),!p.length)return;n===0?v=0:r&&!m?v=Math.max(0,y):v=p[0].pts}if(e.segmentCodec==="aac"){const Y=this.config.maxAudioFramesDrift;for(let oe=0,ae=v;oe<p.length;oe++){const G=p[oe],F=G.pts,re=F-ae,J=Math.abs(1e3*re/a);if(re<=-Y*c&&m)oe===0&&(R.warn(`Audio frame @ ${(F/a).toFixed(3)}s overlaps nextAudioPts by ${Math.round(1e3*re/a)} ms.`),this.nextAudioPts=v=ae=F);else if(re>=Y*c&&J<tk&&m){let de=Math.round(re/c);ae=F-de*c,ae<0&&(de--,ae+=c),oe===0&&(this.nextAudioPts=v=ae),R.warn(`[mp4-remuxer]: Injecting ${de} audio frame @ ${(ae/a).toFixed(3)}s due to ${Math.round(1e3*re/a)} ms gap.`);for(let Ae=0;Ae<de;Ae++){const Ce=Math.max(ae,0);let He=y0.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);He||(R.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),He=G.unit.subarray()),p.splice(oe,0,{unit:He,pts:Ce}),ae+=c,oe++}}G.pts=ae,ae+=c}}let x=null,_=null,S,A=0,D=p.length;for(;D--;)A+=p[D].unit.byteLength;for(let Y=0,oe=p.length;Y<oe;Y++){const ae=p[Y],G=ae.unit;let F=ae.pts;if(_!==null){const J=f[Y-1];J.duration=Math.round((F-_)/l)}else if(s&&e.segmentCodec==="aac"&&(F=v),x=F,A>0){A+=g;try{S=new Uint8Array(A)}catch(J){this.observer.emit(E.ERROR,E.ERROR,{type:se.MUX_ERROR,details:M.REMUX_ALLOC_ERROR,fatal:!1,error:J,bytes:A,reason:`fail allocating audio mdat ${A}`});return}h||(new DataView(S.buffer).setUint32(0,A),S.set(w.types.mdat,4))}else return;S.set(G,g);const re=G.byteLength;g+=re,f.push(new _0(!0,d,re,0)),_=F}const O=f.length;if(!O)return;const L=f[f.length-1];this.nextAudioPts=v=_+l*L.duration;const C=h?new Uint8Array(0):w.moof(e.sequenceNumber++,x/l,Ke({},e,{samples:f}));e.samples=[];const H=x/a,U=v/a,q={data1:C,data2:S,startPTS:H,endPTS:U,startDTS:H,endDTS:U,type:"audio",hasAudio:!0,hasVideo:!1,nb:O};return this.isAudioContiguous=!0,q}remuxEmptyAudio(e,t,s,r){const n=e.inputTimeScale,a=e.samplerate?e.samplerate:n,o=n/a,l=this.nextAudioPts,d=this._initDTS,c=d.baseTime*9e4/d.timescale,u=(l!==null?l:r.startDTS*n)+c,h=r.endDTS*n+c,f=o*T0,m=Math.ceil((h-u)/f),p=y0.getSilentFrame(e.manifestCodec||e.codec,e.channelCount);if(R.warn("[mp4-remuxer]: remux empty Audio"),!p){R.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec");return}const g=[];for(let v=0;v<m;v++){const y=u+v*f;g.push({unit:p,pts:y,dts:y})}return e.samples=g,this.remuxAudio(e,t,s,!1)}}function Kt(i,e){let t;if(e===null)return i;for(e<i?t=-8589934592:t=8589934592;Math.abs(i-e)>4294967296;)i+=t;return i}function rk(i){for(let e=0;e<i.length;e++)if(i[e].key)return e;return-1}function uE(i,e,t,s){const r=i.samples.length;if(!r)return;const n=i.inputTimeScale;for(let o=0;o<r;o++){const l=i.samples[o];l.pts=Kt(l.pts-t.baseTime*n/t.timescale,e*n)/n,l.dts=Kt(l.dts-s.baseTime*n/s.timescale,e*n)/n}const a=i.samples;return i.samples=[],{samples:a}}function hE(i,e,t){const s=i.samples.length;if(!s)return;const r=i.inputTimeScale;for(let a=0;a<s;a++){const o=i.samples[a];o.pts=Kt(o.pts-t.baseTime*r/t.timescale,e*r)/r}i.samples.sort((a,o)=>a.pts-o.pts);const n=i.samples;return i.samples=[],{samples:n}}class _0{constructor(e,t,s,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=t,this.size=s,this.cts=r,this.flags={isLeading:0,isDependedOn:0,hasRedundancy:0,degradPrio:0,dependsOn:e?2:1,isNonSync:e?0:1}}}class nk{constructor(){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}destroy(){}resetTimeStamp(e){this.initPTS=e,this.lastEndTime=null}resetNextTimestamp(){this.lastEndTime=null}resetInitSegment(e,t,s,r){this.audioCodec=t,this.videoCodec=s,this.generateInitSegment(hS(e,r)),this.emitInitSegment=!0}generateInitSegment(e){let{audioCodec:t,videoCodec:s}=this;if(!(e!=null&&e.byteLength)){this.initTracks=void 0,this.initData=void 0;return}const r=this.initData=Uv(e);r.audio&&(t=A0(r.audio,be.AUDIO)),r.video&&(s=A0(r.video,be.VIDEO));const n={};r.audio&&r.video?n.audiovideo={container:"video/mp4",codec:t+","+s,initSegment:e,id:"main"}:r.audio?n.audio={container:"audio/mp4",codec:t,initSegment:e,id:"audio"}:r.video?n.video={container:"video/mp4",codec:s,initSegment:e,id:"main"}:R.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n}remux(e,t,s,r,n,a){var o,l;let{initPTS:d,lastEndTime:c}=this;const u={audio:void 0,video:void 0,text:r,id3:s,initSegment:void 0};j(c)||(c=this.lastEndTime=n||0);const h=t.samples;if(!(h!=null&&h.length))return u;const f={initPTS:void 0,timescale:1};let m=this.initData;if((o=m)!=null&&o.length||(this.generateInitSegment(h),m=this.initData),!((l=m)!=null&&l.length))return R.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),u;this.emitInitSegment&&(f.tracks=this.initTracks,this.emitInitSegment=!1);const p=mS(h,m),g=fS(m,h),v=g===null?n:g;(ak(d,v,n,p)||f.timescale!==d.timescale&&a)&&(f.initPTS=v-n,d&&d.timescale===1&&R.warn(`Adjusting initPTS by ${f.initPTS-d.baseTime}`),this.initPTS=d={baseTime:f.initPTS,timescale:1});const y=e?v-d.baseTime/d.timescale:c,b=y+p;gS(m,h,d.baseTime/d.timescale),p>0?this.lastEndTime=b:(R.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());const x=!!m.audio,_=!!m.video;let S="";x&&(S+="audio"),_&&(S+="video");const A={data1:h,startPTS:y,startDTS:y,endPTS:b,endDTS:b,type:S,hasAudio:x,hasVideo:_,nb:1,dropped:0};return u.audio=A.type==="audio"?A:void 0,u.video=A.type!=="audio"?A:void 0,u.initSegment=f,u.id3=uE(s,n,d,d),r.samples.length&&(u.text=hE(r,n,d)),u}}function ak(i,e,t,s){if(i===null)return!0;const r=Math.max(s,1),n=e-i.baseTime/i.timescale;return Math.abs(n-t)>r}function A0(i,e){const t=i==null?void 0:i.codec;if(t&&t.length>4)return t;if(e===be.AUDIO){if(t==="ec-3"||t==="ac-3"||t==="alac")return t;if(t==="fLaC"||t==="Opus")return Bd(t,!1);const s="mp4a.40.5";return R.info(`Parsed audio codec "${t}" or audio object type not handled. Using "${s}"`),s}return R.warn(`Unhandled video codec "${t}"`),t==="hvc1"||t==="hev1"?"hvc1.1.6.L120.90":t==="av01"?"av01.0.04M.08":"avc1.42e01e"}let zi;try{zi=self.performance.now.bind(self.performance)}catch{R.debug("Unable to use Performance API on this environment"),zi=Rn==null?void 0:Rn.Date.now}const nl=[{demux:Vx,remux:nk},{demux:ms,remux:rl},{demux:Wx,remux:rl},{demux:Zx,remux:rl}];nl.splice(2,0,{demux:qx,remux:rl});class S0{constructor(e,t,s,r,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=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.vendor=r,this.id=n}configure(e){this.transmuxConfig=e,this.decrypter&&this.decrypter.reset()}push(e,t,s,r){const n=s.transmuxing;n.executeStart=zi();let a=new Uint8Array(e);const{currentTransmuxState:o,transmuxConfig:l}=this;r&&(this.currentTransmuxState=r);const{contiguous:d,discontinuity:c,trackSwitch:u,accurateTimeOffset:h,timeOffset:f,initSegmentChange:m}=r||o,{audioCodec:p,videoCodec:g,defaultInitPts:v,duration:y,initSegmentData:b}=l,x=ok(a,t);if(x&&x.method==="AES-128"){const D=this.getDecrypter();if(D.isSync()){let O=D.softwareDecrypt(a,x.key.buffer,x.iv.buffer);if(s.part>-1&&(O=D.flush()),!O)return n.executeEnd=zi(),nu(s);a=new Uint8Array(O)}else return this.decryptionPromise=D.webCryptoDecrypt(a,x.key.buffer,x.iv.buffer).then(O=>{const L=this.push(O,null,s);return this.decryptionPromise=null,L}),this.decryptionPromise}const _=this.needsProbing(c,u);if(_){const D=this.configureTransmuxer(a);if(D)return R.warn(`[transmuxer] ${D.message}`),this.observer.emit(E.ERROR,E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,fatal:!1,error:D,reason:D.message}),n.executeEnd=zi(),nu(s)}(c||u||m||_)&&this.resetInitSegment(b,p,g,y,t),(c||m||_)&&this.resetInitialTimestamp(v),d||this.resetContiguity();const S=this.transmux(a,x,f,h,s),A=this.currentTransmuxState;return A.contiguous=!0,A.discontinuity=!1,A.trackSwitch=!1,n.executeEnd=zi(),S}flush(e){const t=e.transmuxing;t.executeStart=zi();const{decrypter:s,currentTransmuxState:r,decryptionPromise:n}=this;if(n)return n.then(()=>this.flush(e));const a=[],{timeOffset:o}=r;if(s){const u=s.flush();u&&a.push(this.push(u,null,e))}const{demuxer:l,remuxer:d}=this;if(!l||!d)return t.executeEnd=zi(),[nu(e)];const c=l.flush(o);return al(c)?c.then(u=>(this.flushRemux(a,u,e),a)):(this.flushRemux(a,c,e),a)}flushRemux(e,t,s){const{audioTrack:r,videoTrack:n,id3Track:a,textTrack:o}=t,{accurateTimeOffset:l,timeOffset:d}=this.currentTransmuxState;R.log(`[transmuxer.ts]: Flushed fragment ${s.sn}${s.part>-1?" p: "+s.part:""} of level ${s.level}`);const c=this.remuxer.remux(r,n,a,o,d,l,!0,this.id);e.push({remuxResult:c,chunkMeta:s}),s.transmuxing.executeEnd=zi()}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,r,n){const{demuxer:a,remuxer:o}=this;!a||!o||(a.resetInitSegment(e,t,s,r),o.resetInitSegment(e,t,s,n))}destroy(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)}transmux(e,t,s,r,n){let a;return t&&t.method==="SAMPLE-AES"?a=this.transmuxSampleAes(e,t,s,r,n):a=this.transmuxUnencrypted(e,s,r,n),a}transmuxUnencrypted(e,t,s,r){const{audioTrack:n,videoTrack:a,id3Track:o,textTrack:l}=this.demuxer.demux(e,t,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(n,a,o,l,t,s,!1,this.id),chunkMeta:r}}transmuxSampleAes(e,t,s,r,n){return this.demuxer.demuxSampleAes(e,t,s).then(a=>({remuxResult:this.remuxer.remux(a.audioTrack,a.videoTrack,a.id3Track,a.textTrack,s,r,!1,this.id),chunkMeta:n}))}configureTransmuxer(e){const{config:t,observer:s,typeSupported:r,vendor:n}=this;let a;for(let h=0,f=nl.length;h<f;h++){var o;if((o=nl[h].demux)!=null&&o.probe(e)){a=nl[h];break}}if(!a)return new Error("Failed to find demuxer by probing fragment data");const l=this.demuxer,d=this.remuxer,c=a.remux,u=a.demux;(!d||!(d instanceof c))&&(this.remuxer=new c(s,t,r,n)),(!l||!(l instanceof u))&&(this.demuxer=new u(s,t,r),this.probe=u.probe)}needsProbing(e,t){return!this.demuxer||!this.remuxer||e||t}getDecrypter(){let e=this.decrypter;return e||(e=this.decrypter=new gm(this.config)),e}}function ok(i,e){let t=null;return i.byteLength>0&&(e==null?void 0:e.key)!=null&&e.iv!==null&&e.method!=null&&(t=e),t}const nu=i=>({remuxResult:{},chunkMeta:i});function al(i){return"then"in i&&i.then instanceof Function}class lk{constructor(e,t,s,r,n){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=r,this.defaultInitPts=n||null}}class dk{constructor(e,t,s,r,n,a){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=r,this.timeOffset=n,this.initSegmentChange=a}}var fE={exports:{}};(function(i){var e=Object.prototype.hasOwnProperty,t="~";function s(){}Object.create&&(s.prototype=Object.create(null),new s().__proto__||(t=!1));function r(l,d,c){this.fn=l,this.context=d,this.once=c||!1}function n(l,d,c,u,h){if(typeof c!="function")throw new TypeError("The listener must be a function");var f=new r(c,u||l,h),m=t?t+d:d;return l._events[m]?l._events[m].fn?l._events[m]=[l._events[m],f]:l._events[m].push(f):(l._events[m]=f,l._eventsCount++),l}function a(l,d){--l._eventsCount===0?l._events=new s:delete l._events[d]}function o(){this._events=new s,this._eventsCount=0}o.prototype.eventNames=function(){var d=[],c,u;if(this._eventsCount===0)return d;for(u in c=this._events)e.call(c,u)&&d.push(t?u.slice(1):u);return Object.getOwnPropertySymbols?d.concat(Object.getOwnPropertySymbols(c)):d},o.prototype.listeners=function(d){var c=t?t+d:d,u=this._events[c];if(!u)return[];if(u.fn)return[u.fn];for(var h=0,f=u.length,m=new Array(f);h<f;h++)m[h]=u[h].fn;return m},o.prototype.listenerCount=function(d){var c=t?t+d:d,u=this._events[c];return u?u.fn?1:u.length:0},o.prototype.emit=function(d,c,u,h,f,m){var p=t?t+d:d;if(!this._events[p])return!1;var g=this._events[p],v=arguments.length,y,b;if(g.fn){switch(g.once&&this.removeListener(d,g.fn,void 0,!0),v){case 1:return g.fn.call(g.context),!0;case 2:return g.fn.call(g.context,c),!0;case 3:return g.fn.call(g.context,c,u),!0;case 4:return g.fn.call(g.context,c,u,h),!0;case 5:return g.fn.call(g.context,c,u,h,f),!0;case 6:return g.fn.call(g.context,c,u,h,f,m),!0}for(b=1,y=new Array(v-1);b<v;b++)y[b-1]=arguments[b];g.fn.apply(g.context,y)}else{var x=g.length,_;for(b=0;b<x;b++)switch(g[b].once&&this.removeListener(d,g[b].fn,void 0,!0),v){case 1:g[b].fn.call(g[b].context);break;case 2:g[b].fn.call(g[b].context,c);break;case 3:g[b].fn.call(g[b].context,c,u);break;case 4:g[b].fn.call(g[b].context,c,u,h);break;default:if(!y)for(_=1,y=new Array(v-1);_<v;_++)y[_-1]=arguments[_];g[b].fn.apply(g[b].context,y)}}return!0},o.prototype.on=function(d,c,u){return n(this,d,c,u,!1)},o.prototype.once=function(d,c,u){return n(this,d,c,u,!0)},o.prototype.removeListener=function(d,c,u,h){var f=t?t+d:d;if(!this._events[f])return this;if(!c)return a(this,f),this;var m=this._events[f];if(m.fn)m.fn===c&&(!h||m.once)&&(!u||m.context===u)&&a(this,f);else{for(var p=0,g=[],v=m.length;p<v;p++)(m[p].fn!==c||h&&!m[p].once||u&&m[p].context!==u)&&g.push(m[p]);g.length?this._events[f]=g.length===1?g[0]:g:a(this,f)}return this},o.prototype.removeAllListeners=function(d){var c;return d?(c=t?t+d:d,this._events[c]&&a(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,i.exports=o})(fE);var ck=fE.exports,_m=MA(ck);class mE{constructor(e,t,s,r){this.error=null,this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.useWorker=void 0,this.workerContext=null,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0;const n=e.config;this.hls=e,this.id=t,this.useWorker=!!n.enableWorker,this.onTransmuxComplete=s,this.onFlush=r;const a=(d,c)=>{c=c||{},c.frag=this.frag,c.id=this.id,d===E.ERROR&&(this.error=c.error),this.hls.trigger(d,c)};this.observer=new _m,this.observer.on(E.FRAG_DECRYPTED,a),this.observer.on(E.ERROR,a);const o=_r(n.preferManagedMediaSource)||{isTypeSupported:()=>!1},l={mpeg:o.isTypeSupported("audio/mpeg"),mp3:o.isTypeSupported('audio/mp4; codecs="mp3"'),ac3:o.isTypeSupported('audio/mp4; codecs="ac-3"')};if(this.useWorker&&typeof Worker<"u"&&(n.workerPath||Rx())){try{n.workerPath?(R.log(`loading Web Worker ${n.workerPath} for "${t}"`),this.workerContext=Cx(n.workerPath)):(R.log(`injecting Web Worker for "${t}"`),this.workerContext=wx()),this.onwmsg=u=>this.onWorkerMessage(u);const{worker:c}=this.workerContext;c.addEventListener("message",this.onwmsg),c.onerror=u=>{const h=new Error(`${u.message} (${u.filename}:${u.lineno})`);n.enableWorker=!1,R.warn(`Error in "${t}" Web Worker, fallback to inline`),this.hls.trigger(E.ERROR,{type:se.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:!1,event:"demuxerWorker",error:h})},c.postMessage({cmd:"init",typeSupported:l,vendor:"",id:t,config:JSON.stringify(n)})}catch(c){R.warn(`Error setting up "${t}" Web Worker, fallback to inline`,c),this.resetWorker(),this.error=null,this.transmuxer=new S0(this.observer,l,n,"",t)}return}this.transmuxer=new S0(this.observer,l,n,"",t)}resetWorker(){if(this.workerContext){const{worker:e,objectURL:t}=this.workerContext;t&&self.URL.revokeObjectURL(t),e.removeEventListener("message",this.onwmsg),e.onerror=null,e.terminate(),this.workerContext=null}}destroy(){if(this.workerContext)this.resetWorker(),this.onwmsg=void 0;else{const t=this.transmuxer;t&&(t.destroy(),this.transmuxer=null)}const e=this.observer;e&&e.removeAllListeners(),this.frag=null,this.observer=null,this.hls=null}push(e,t,s,r,n,a,o,l,d,c){var u,h;d.transmuxing.start=self.performance.now();const{transmuxer:f}=this,m=a?a.start:n.start,p=n.decryptdata,g=this.frag,v=!(g&&n.cc===g.cc),y=!(g&&d.level===g.level),b=g?d.sn-g.sn:-1,x=this.part?d.part-this.part.index:-1,_=b===0&&d.id>1&&d.id===(g==null?void 0:g.stats.chunkCount),S=!y&&(b===1||b===0&&(x===1||_&&x<=0)),A=self.performance.now();(y||b||n.stats.parsing.start===0)&&(n.stats.parsing.start=A),a&&(x||!S)&&(a.stats.parsing.start=A);const D=!(g&&((u=n.initSegment)==null?void 0:u.url)===((h=g.initSegment)==null?void 0:h.url)),O=new dk(v,S,l,y,m,D);if(!S||v||D){R.log(`[transmuxer-interface, ${n.type}]: Starting new transmux session for sn: ${d.sn} p: ${d.part} level: ${d.level} id: ${d.id}
29
29
  discontinuity: ${v}
30
30
  trackSwitch: ${y}
31
31
  contiguous: ${S}
32
32
  accurateTimeOffset: ${l}
33
33
  timeOffset: ${m}
34
- initSegmentChange: ${D}`);const L=new ok(s,r,t,o,c);this.configureTransmuxer(L)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(f){const L=f.push(e,p,d,O);al(L)?(f.async=!0,L.then(C=>{this.handleTransmuxComplete(C)}).catch(C=>{this.transmuxerError(C,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(L))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let s=t.flush(e);al(s)||t.async?(al(s)||(s=Promise.resolve(s)),s.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}}transmuxerError(e,t,s){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:s}))}handleFlushResult(e,t){e.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data;if(!(t!=null&&t.event)){R.warn(`worker message received with no ${t?"event name":"data"}`);return}const s=this.hls;if(this.hls)switch(t.event){case"init":{var r;const n=(r=this.workerContext)==null?void 0:r.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":R[t.data.logType]&&R[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,s.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function pE(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!Cn(i[t].attrs,e[t].attrs))return!1;return!0}function Cn(i,e,t){const s=i["STABLE-RENDITION-ID"];return s&&!t?s===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>i[r]!==e[r])}function ih(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}const x0=100;class ck extends vm{constructor(e,t,s){super(e,t,s,"[audio-stream-controller]",te.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-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.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:n}){if(s==="main"){const a=t.cc;this.initPTS[t.cc]={baseTime:r,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${r}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(x0),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;const{levels:s,trackId:r}=this,n=s==null||(e=s[r])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;const s=performance.now(),r=this.retryDate;if(!r||s>=r||(t=this.media)!=null&&t.seeking){const{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{const s=this.waitingData;if(s){const{frag:r,part:n,cache:a,complete:o}=s;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;const l=a.flush(),d={frag:r,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),d=Le.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);eh(d.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:s,trackId:r}=this,n=e.config;if(!s&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[r]))return;const a=t[r],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,be.AUDIO,te.AUDIO));const d=this.getFwdBufferInfo(l,te.AUDIO);if(d===null)return;const{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o)){e.trigger(E.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,te.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start;let v=this.flushing?this.getLoadPosition():d.end;if(u&&s){const _=this.getLoadPosition();c&&!Cn(u.attrs,c.attrs)&&(v=_),o.PTSKnown&&_<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=g+.05)}if(f>=m&&!u&&v<p[p.length-1].start)return;let y=this.getNextFragment(v,o),b=!1;if(y&&this.isLoopLoading(y,v)&&(b=!!y.gap,y=this.getNextFragmentLoopLoading(y,o,d,te.MAIN,m)),!y){this.bufferFlushed=!0;return}const x=h&&y.start>h.end+o.targetduration;if(x||!(h!=null&&h.len)&&d.len){const _=this.getAppendedFrag(y.start,te.MAIN);if(_===null||(b||(b=!!_.gap||!!x&&h.len===0),x&&!b||b&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(y,a,v)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(s=>new wn(s))}onAudioTrackSwitching(e,t){const s=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),s?this.setInterval(x0):this.resetTransmuxer(),s?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:r}=this,{details:n,id:a}=t;if(!r){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=r[a];let l=0;if(n.live||(s=o.details)!=null&&s.live){this.checkLiveUpdate(n);const c=this.mainDetails;if(n.deltaUpdateFailed||!c)return;if(!o.details&&n.hasProgramDateTime&&c.hasProgramDateTime)Vd(n,c),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new mE(this.hls,te.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[s.cc],m=(t=s.initSegment)==null?void 0:t.data;if(f!==void 0){const g=r?r.index:-1,v=g!==-1,y=new pm(s.level,s.sn,s.stats.chunkCount,n.byteLength,g,v);h.push(n,m,u,"",s,r,c.totalduration,!1,y,f)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:p}=this.waitingData=this.waitingData||{frag:s,part:r,cache:new Zv,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const s=t.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s.type!==te.AUDIO){if(!this.loadedmetadata&&s.type===te.MAIN){const n=this.videoBuffer||this.media;n&&Le.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(s.sn!=="initSegment"){this.fragPrevious=s;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,dt({},n)))}this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.AUDIO,t);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((s=t.context)==null?void 0:s.type)===pe.AUDIO_TRACK&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==be.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==be.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);const s=this.mediaBuffer||this.media;s&&(this.afterBufferFlushed(s,t,te.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const s="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){const g=l.initSegment||l;this._bufferInitSegment(c,p.tracks,g,a),r.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:s,tracks:p.tracks})}if(h){const{startPTS:g,endPTS:v,startDTS:y,endDTS:b}=h;d&&(d.elementaryStreams[be.AUDIO]={startPTS:g,endPTS:v,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(be.AUDIO,g,v,y,b),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){const g=Ke({id:s,frag:l,details:u},m);r.trigger(E.FRAG_PARSING_METADATA,g)}if(f){const g=Ke({id:s,frag:l,details:u},f);r.trigger(E.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,s,r){if(this.state!==N.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.id="audio";const a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(E.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:s,part:null,chunkMeta:r,parent:s.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||r===rt.NOT_LOADED||r===rt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&Vd(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,s)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:s}=this,r=s==null?void 0:s.attrs,n=e.attrs;t&&r&&(r.CHANNELS!==n.CHANNELS||s.name!==e.name||s.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(E.AUDIO_TRACK_SWITCHED,dt({},e))}}class uk extends mm{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(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.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:r,details:n}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Audio track with id:${s} and group:${r} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.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,r=this.groupIds;let n=this.currentTrack;if(!s||(r==null?void 0:r.length)!==(s==null?void 0:s.length)||s!=null&&s.some(o=>(r==null?void 0:r.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(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const l=this.hls.config.audioPreference;if(!n&&l){const h=wi(l,o,Mr);if(h>-1)n=o[h];else{const f=wi(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));const c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${s==null?void 0:s.join(",")}`),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(d!==-1&&u===-1)this.setAudioTrack(d);else if(o.length&&u===-1){var a;const h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===pe.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-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 r=this.currentTrack;if(r&&En(e,r,Mr))return r;const n=wi(e,this.tracksInGroup,Mr);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=ux(e,t.levels,s,a,Mr);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=wi(e,s);if(a>-1)return s[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===s&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,dt({},r)),n))return;const a=this.switchParams(r.url,s==null?void 0:s.details,r.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(!(this.selectDefaultTrack&&!r.default)&&(!e||En(e,r,Mr)))return s}if(e){const{name:s,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){const c=t[d];if(En({name:s,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l},c,Mr))return d}for(let d=0;d<t.length;d++){const c=t[d];if(Cn(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const c=t[d];if(Cn(e.attrs,c.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const s=t.id,r=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${s} "${t.name}" lang:${t.lang} group:${r}`),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:r,deliveryDirectives:e||null})}}}const k0=500;class hk extends vm{constructor(e,t,s){super(e,t,s,"[subtitle-stream-controller]",te.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(k0),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:s,success:r}=t;if(this.fragPrevious=s,this.state=N.IDLE,!r)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=s.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}const l=s.start+s.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null)}onBufferFlushing(e,t){const{startOffset:s,endOffset:r}=t;if(s===0&&r!==Number.POSITIVE_INFINITY){const n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(s,n,te.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===te.MAIN){var s;(s=this.media)!=null&&s.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const s=t.frag;(s==null?void 0:s.type)===te.SUBTITLE&&(t.details===M.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&pE(this.levels,t)){this.levels=t.map(s=>new wn(s));return}this.tracksBuffered=[],this.levels=t.map(s=>{const r=new wn(s);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,te.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 r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(k0)}onSubtitleTrackLoaded(e,t){var s;const{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(s=l.details)!=null&&s.live){const u=this.mainDetails;if(a.deltaUpdateFailed||!u)return;const h=u.fragments[0];if(!l.details)a.hasProgramDateTime&&u.hasProgramDateTime?(Vd(a,u),d=a.fragments[0].start):h&&(d=h.start,Ju(a,d));else{var c;d=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details),d===0&&h&&(d=h.start,Ju(a,d))}}l.details=a,this.levelLastLoaded=l,o===r&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Kd(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:s}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&s&&s.byteLength>0&&r!=null&&r.key&&r.iv&&r.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer).catch(o=>{throw n.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const l=performance.now();n.trigger(E.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){const{currentTrackId:e,levels:t}=this,s=t==null?void 0:t[e];if(!s||!t.length||!s.details)return;const{config:r}=this,n=this.getLoadPosition(),a=Le.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,te.MAIN),c=s.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;const h=c.fragments,f=h.length,m=c.edge;let p=null;const g=this.fragPrevious;if(o<m){const v=r.maxFragLookUpTolerance,y=o>m-v?0:v;p=Kd(g,h,Math.max(h[0].start,o),y),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){const v=p.sn-c.startSN,y=h[v-1];y&&y.cc===p.cc&&this.fragmentTracker.getState(y)===rt.NOT_LOADED&&(p=y)}this.fragmentTracker.getState(p)===rt.NOT_LOADED&&this.loadFragment(p,s,o)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,s){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,s))}get mediaBufferTimeRanges(){return new fk(this.tracksBuffered[this.currentTrackId]||[])}}class fk{constructor(e){this.buffered=void 0;const t=(s,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${s}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][s]};this.buffered={get length(){return e.length},end(s){return t("end",s,e.length)},start(s){return t("start",s,e.length)}}}}class mk extends mm{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.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const s=tl(this.media.textTracks);for(let n=0;n<s.length;n++)if(s[n].mode==="hidden")t=s[n];else if(s[n].mode==="showing"){t=s[n];break}const r=this.findTrackForTextTrack(t);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},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(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.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(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),tl(this.media.textTracks).forEach(t=>{fn(t)}),this.subtitleTrack=-1,this.media=null}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:r,details:n}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${s} and group:${r} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.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,r=this.groupIds;let n=this.currentTrack;if(!s||(r==null?void 0:r.length)!==(s==null?void 0:s.length)||s!=null&&s.some(a=>(r==null?void 0:r.indexOf(a))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(c=>!s||s.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=!1),a.forEach((c,u)=>{c.id=u});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const c=wi(o,a);if(c>-1)n=a[c];else{const u=wi(o,this.tracks);n=this.tracks[u]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${s==null?void 0:s.join(",")}" group-id`),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,s=this.selectDefaultTrack;for(let r=0;r<t.length;r++){const n=t[r];if(!(s&&!n.default||!s&&!e)&&(!e||En(n,e)))return r}if(e){for(let r=0;r<t.length;r++){const n=t[r];if(Cn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const n=t[r];if(Cn(e.attrs,n.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(ih(r,e))return s}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===pe.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){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const s=this.currentTrack;if(s&&En(e,s))return s;const r=wi(e,this.tracksInGroup);if(r>-1){const n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else{if(s)return null;{const n=wi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const s=t.id,r=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${s}`),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:n,id:s,groupId:r,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=tl(e.textTracks),s=this.currentTrack;let r;if(s&&(r=t.filter(n=>ih(s,n))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==r&&(n.mode="disabled")}),r){const n=this.subtitleDisplay?"showing":"hidden";r.mode!==n&&(r.mode=n)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!j(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:e});return}const n=!!r.details&&!r.details.live;if(e===this.trackId&&r===s&&n)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:o="",name:l,type:d,url:c}=r;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});const u=this.switchParams(r.url,s==null?void 0:s.details,r.details);this.loadPlaylist(u)}}class pk{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,s){const r=this.queues[t];r.push(e),r.length===1&&!s&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const s=new Promise(n=>{t=n}),r={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,e),s}executeNext(e){const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(r){R.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${r}`),s.onError(r);const n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const L0=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class gk{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=s=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=s=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:s,mediaSource:r}=this;this.log("Media source opened"),s&&(s.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(E.MEDIA_ATTACHED,{media:s,mediaSource:r})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:s,_objectUrl:r}=this;s!==r&&R.error(`Media element src was set while attaching MediaSource (${r} > ${s})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=xS(_r(e.config.preferManagedMediaSource)),this.log=R.log.bind(R,t),this.warn=R.warn.bind(R,t),this.error=R.error.bind(R,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new pk(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=s,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const s=this.media=t.media,r=_r(this.appendSource);if(s&&r){var n;const a=this.mediaSource=new r;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{s.removeAttribute("src");const l=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||l&&a instanceof l,I0(s),vk(s,o),s.load()}catch{s.src=o}else s.src=o;s.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:s}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(r){this.warn(`onMediaDetaching: ${r.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(e.removeAttribute("src"),this.appendSource&&I0(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(E.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var s;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(r){this.warn(`onBufferReset ${e}`,r)}}onBufferCodecs(e,t){const s=this.getSourceBufferTypes().length,r=Object.keys(t);if(r.forEach(a=>{if(s){const l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;const{id:d,codec:c,levelCodec:u,container:h,metadata:f}=t[a],m=zp(l.codec,l.levelCodec),p=m==null?void 0:m.replace(L0,"$1");let g=zp(c,u);const v=(o=g)==null?void 0:o.replace(L0,"$1");if(g&&p!==v){a.slice(0,5)==="audio"&&(g=Bd(g,this.appendSource));const y=`${h};codecs=${g}`;this.appendChangeType(a,y),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:c,container:h,levelCodec:u,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),s)return;const n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${r.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:s}=this,r={execute:()=>{const n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),s.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};s.append(r,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:s,operationQueue:r,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,u=c.buffering[o],h=self.performance.now();u.start=h;const f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);const p=n.audio;let g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const v=l.start,y={execute:()=>{if(u.executeStart=self.performance.now(),g){const b=this.sourceBuffer[o];if(b){const x=v-b.timestampOffset;Math.abs(x)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${x}) sn: ${l.sn})`),b.timestampOffset=v)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const b=self.performance.now();u.executeEnd=u.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);const{sourceBuffer:x}=this,_={};for(const S in x)_[S]=Le.getBuffered(x[S]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(E.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:_})},onError:b=>{const x={type:se.MEDIA_ERROR,parent:l.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:c,error:b,err:b,fatal:!1};if(b.code===DOMException.QUOTA_EXCEEDED_ERR)x.details=M.BUFFER_FULL_ERROR;else{const _=++this.appendErrors[o];x.details=M.BUFFER_APPEND_ERROR,this.warn(`Failed ${_}/${s.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),_>=s.config.appendErrorMaxRetry&&(x.fatal=!0)}s.trigger(E.ERROR,x)}};r.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:s}=this,r=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(E.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?s.append(r(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{s.append(r(n),n)})}onFragParsed(e,t){const{frag:s,part:r}=t,n=[],a=r?r.elementaryStreams:s.elementaryStreams;a[be.AUDIOVIDEO]?n.push("audiovideo"):(a[be.AUDIO]&&n.push("audio"),a[be.VIDEO]&&n.push("video"));const o=()=>{const l=self.performance.now();s.stats.buffering.end=l,r&&(r.stats.buffering.end=l);const d=r?r.stats:s.stats;this.hls.trigger(E.FRAG_BUFFERED,{frag:s,part:r,stats:d,id:s.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((r,n)=>{const a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),r&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const a=this.sourceBuffer[n];a&&(a.ending=!1)});const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:s}=this;if(!s||t===null||!this.getSourceBufferTypes().length)return;const n=e.config,a=s.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(j(l)&&l>0){const d=Math.max(l,o),c=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,c)}if(j(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),c=Math.max(d,o),u=Math.floor(a/o)*o+c;this.flushFrontBuffer(a,o,u)}}flushBackBuffer(e,t,s){const{details:r,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{const l=n[o];if(l){const d=Le.getBuffered(l);if(d.length>0&&s>d.start(0)){if(this.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:s}),r!=null&&r.live)this.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:o})}}})}flushFrontBuffer(e,t,s){const{sourceBuffer:r}=this;this.getSourceBufferTypes().forEach(a=>{const o=r[a];if(o){const l=Le.getBuffered(o),d=l.length;if(d<2)return;const c=l.start(d-1),u=l.end(d-1);if(s>c||e>=c&&e<=u)return;if(o.ended&&e-u<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:s,mediaSource:r}=this,n=e.fragments[0].start+e.totalduration,a=s.duration,o=j(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(r.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!j(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),r.duration=n)}updateSeekableRange(e){const t=this.mediaSource,s=e.fragments;if(s.length&&e.live&&t!=null&&t.setLiveSeekableRange){const n=Math.max(0,s[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:s}=this,r=Object.keys(s).length;if(r&&(!e||r===2||"audiovideo"in s)){this.createSourceBuffers(s),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:s}=this;if(!s)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!t[n]){var r;const a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((r=a.levelCodec)==null?void 0:r.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=Bd(o,this.appendSource));const l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{const d=t[n]=s.addSourceBuffer(l),c=n;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(c,"bufferedchange",(u,h)=>{const f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(E.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e;const t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t==null?void 0:t.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:s}=this;s.current(e).onComplete(),s.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var s;const r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(s=this.mediaSource)==null?void 0:s.readyState}`);this.error(`${r}`,t),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(r)}removeExecutor(e,t,s){const{media:r,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!r||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}const d=j(r.duration)?r.duration:1/0,c=j(n.duration)?n.duration:1/0,u=Math.max(0,t),h=Math.min(s,d,c);h>u&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const s=this.sourceBuffer[t];if(!s){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}s.ended=!1,s.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:s}=this,r=t.map(n=>s.appendBlocker(n));Promise.all(r).then(()=>{e(),t.forEach(n=>{const a=this.sourceBuffer[n];a!=null&&a.updating||s.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,s){const r=this.sourceBuffer[e];if(!r)return;const n=s.bind(this,e);this.listeners[e].push({event:t,listener:n}),r.addEventListener(t,n)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(s=>{t.removeEventListener(s.event,s.listener)})}}function I0(i){const e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function vk(i,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}const Ek={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},gE=i=>String.fromCharCode(Ek[i]||i),Xt=15,Bi=100,bk={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},yk={17:2,18:4,21:6,22:8,23:10,19:13,20:15},Tk={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},_k={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Ak=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class Sk{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const s=typeof t=="function"?t():t;R.log(`${this.time} [${e}] ${s}`)}}}const Is=function(e){const t=[];for(let s=0;s<e.length;s++)t.push(e[s].toString(16));return t};class vE{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 r=t[s];e.hasOwnProperty(r)&&(this[r]=e[r])}}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 xk{constructor(){this.uchar=" ",this.penState=new vE}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 kk{constructor(e){this.chars=[],this.pos=0,this.currPenState=new vE,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Bi;t++)this.chars.push(new xk);this.logger=e}equals(e){for(let t=0;t<Bi;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Bi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Bi;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>Bi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Bi)}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=gE(e);if(this.pos>=Bi){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<Bi;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<Bi;s++){const r=this.chars[s].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class au{constructor(e){this.rows=[],this.currRow=Xt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Xt;t++)this.rows.push(new kk(e));this.logger=e}reset(){for(let e=0;e<Xt;e++)this.rows[e].clear();this.currRow=Xt-1}equals(e){let t=!0;for(let s=0;s<Xt;s++)if(!this.rows[s].equals(e.rows[s])){t=!1;break}return t}copy(e){for(let t=0;t<Xt;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Xt;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 = "+JSON.stringify(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<Xt;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;const s=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);s.setCursor(e.indent),e.color=s.chars[a].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(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="",r=-1;for(let n=0;n<Xt;n++){const a=this.rows[n].getTextString();a&&(r=n+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?s="["+t.join(" | ")+"]":s=t.join(`
35
- `)),s}getTextAndFormat(){return this.rows}}class R0{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 au(s),this.nonDisplayedMemory=new au(s),this.lastOutputScreen=new au(s),this.currRollUpRow=this.displayedMemory.rows[Xt-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[Xt-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,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[s]}this.logger.log(2,"MIDROW: "+JSON.stringify(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 w0{constructor(e,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=Ik(),this.logger=void 0;const r=this.logger=new Sk;this.channels=[null,new R0(e,t,r),new R0(e+1,s,r)]}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 r=t[s]&127,n=t[s+1]&127;let a=!1,o=null;if(r===0&&n===0)continue;this.logger.log(3,()=>"["+Is([t[s],t[s+1]])+"] -> ("+Is([r,n])+")");const l=this.cmdHistory;if(r>=16&&r<=31){if(Lk(r,n,l)){xo(null,null,l),this.logger.log(3,()=>"Repeated command ("+Is([r,n])+") is dropped");continue}xo(r,n,this.cmdHistory),a=this.parseCmd(r,n),a||(a=this.parseMidrow(r,n)),a||(a=this.parsePAC(r,n)),a||(a=this.parseBackgroundAttributes(r,n))}else xo(null,null,l);if(!a&&(o=this.parseChars(r,n),o)){const c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Is([r,n])+" orig: "+Is([t[s],t[s+1]]))}}parseCmd(e,t){const s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(s||r))return!1;const n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!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 r=this.channels[s];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Is([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let s;const r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(r||n))return!1;const a=e<=23?1:2;t>=64&&t<=95?s=a===1?bk[e]:Tk[e]:s=a===1?yk[e]:_k[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(s,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let s;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?s=t-96:s=t-64,r.underline=(s&1)===1,s<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((s-16)/2)*4,r}parseChars(e,t){let s,r=null,n=null;if(e>=25?(s=2,n=e-8):(s=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+gE(a)+"' in channel "+s),r=[a]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes = "+Is(r).join(",")),r}parseBackgroundAttributes(e,t){const s=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(s||r))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=Ak[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}xo(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 xo(i,e,t){t.a=i,t.b=e}function Lk(i,e,t){return t.a===i&&t.b===e}function Ik(){return{a:null,b:null}}class ko{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}}var Am=function(){if(Rn!=null&&Rn.VTTCue)return self.VTTCue;const i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const d=l.toLowerCase();return~o.indexOf(d)?d:!1}function s(o){return t(i,o)}function r(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){const c=arguments[d];for(const u in c)o[u]=c[u]}return o}function a(o,l,d){const c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,v=null,y="",b=!0,x="auto",_="start",S=50,A="middle",D=50,O="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(L){h=""+L}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(L){f=!!L}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");m=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return p},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");p=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return g},set:function(L){g=""+L,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return v},set:function(L){v=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return y},set:function(L){const C=s(L);if(C===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=C,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return b},set:function(L){b=!!L,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return x},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");x=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return _},set:function(L){const C=r(L);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");_=C,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return S},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");S=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return A},set:function(L){const C=r(L);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");A=C,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return D},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");D=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return O},set:function(L){const C=r(L);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");O=C,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class Rk{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function EE(i){function e(s,r,n,a){return(s|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}const t=i.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 wk{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 r=0;r<s.length;++r)if(t===s[r]){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 bE(i,e,t,s){const r=s?i.split(s):[i];for(const n in r){if(typeof r[n]!="string")continue;const a=r[n].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const sh=new Am(0,0,""),Lo=sh.align==="middle"?"middle":"center";function Ck(i,e,t){const s=i;function r(){const o=EE(i);if(o===null)throw new Error("Malformed timestamp: "+s);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const d=new wk;bE(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Lo,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Lo,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Lo,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&sh.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Lo);let u=d.get("position","auto");u==="auto"&&sh.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=r(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);i=i.slice(3),a(),e.endTime=r(),a(),n(i,e)}function yE(i){return i.replace(/<br(?: \/)?>/gi,`
36
- `)}class Dk{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new Rk,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 n=t.buffer,a=0;for(n=yE(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
34
+ initSegmentChange: ${D}`);const L=new lk(s,r,t,o,c);this.configureTransmuxer(L)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:e,decryptdata:p,chunkMeta:d,state:O},e instanceof ArrayBuffer?[e]:[]);else if(f){const L=f.push(e,p,d,O);al(L)?(f.async=!0,L.then(C=>{this.handleTransmuxComplete(C)}).catch(C=>{this.transmuxerError(C,d,"transmuxer-interface push error")})):(f.async=!1,this.handleTransmuxComplete(L))}}flush(e){e.transmuxing.start=self.performance.now();const{transmuxer:t}=this;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:e});else if(t){let s=t.flush(e);al(s)||t.async?(al(s)||(s=Promise.resolve(s)),s.then(n=>{this.handleFlushResult(n,e)}).catch(n=>{this.transmuxerError(n,e,"transmuxer-interface flush error")})):this.handleFlushResult(s,e)}}transmuxerError(e,t,s){this.hls&&(this.error=e,this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_PARSING_ERROR,chunkMeta:t,frag:this.frag||void 0,fatal:!1,error:e,err:e,reason:s}))}handleFlushResult(e,t){e.forEach(s=>{this.handleTransmuxComplete(s)}),this.onFlush(t)}onWorkerMessage(e){const t=e.data;if(!(t!=null&&t.event)){R.warn(`worker message received with no ${t?"event name":"data"}`);return}const s=this.hls;if(this.hls)switch(t.event){case"init":{var r;const n=(r=this.workerContext)==null?void 0:r.objectURL;n&&self.URL.revokeObjectURL(n);break}case"transmuxComplete":{this.handleTransmuxComplete(t.data);break}case"flush":{this.onFlush(t.data);break}case"workerLog":R[t.data.logType]&&R[t.data.logType](t.data.message);break;default:{t.data=t.data||{},t.data.frag=this.frag,t.data.id=this.id,s.trigger(t.event,t.data);break}}}configureTransmuxer(e){const{transmuxer:t}=this;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:e}):t&&t.configure(e)}handleTransmuxComplete(e){e.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(e)}}function pE(i,e){if(i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(!Cn(i[t].attrs,e[t].attrs))return!1;return!0}function Cn(i,e,t){const s=i["STABLE-RENDITION-ID"];return s&&!t?s===e["STABLE-RENDITION-ID"]:!(t||["LANGUAGE","NAME","CHARACTERISTICS","AUTOSELECT","DEFAULT","FORCED","ASSOC-LANGUAGE"]).some(r=>i[r]!==e[r])}function ih(i,e){return e.label.toLowerCase()===i.name.toLowerCase()&&(!e.language||e.language.toLowerCase()===(i.lang||"").toLowerCase())}const x0=100;class uk extends vm{constructor(e,t,s){super(e,t,s,"[audio-stream-controller]",te.AUDIO),this.videoBuffer=null,this.videoTrackCC=-1,this.waitingVideoCC=-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.mainDetails=null,this.bufferedTrack=null,this.switchingTrack=null}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:n}){if(s==="main"){const a=t.cc;this.initPTS[t.cc]={baseTime:r,timescale:n},this.log(`InitPTS for cc: ${a} found from main: ${r}`),this.videoTrackCC=a,this.state===N.WAITING_INIT_PTS&&this.tick()}}startLoad(e){if(!this.levels){this.startPosition=e,this.state=N.STOPPED;return}const t=this.lastCurrentTime;this.stopLoad(),this.setInterval(x0),t>0&&e===-1?(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t,this.state=N.IDLE):(this.loadedmetadata=!1,this.state=N.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}doTick(){switch(this.state){case N.IDLE:this.doTickIdle();break;case N.WAITING_TRACK:{var e;const{levels:s,trackId:r}=this,n=s==null||(e=s[r])==null?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=N.WAITING_INIT_PTS}break}case N.FRAG_LOADING_WAITING_RETRY:{var t;const s=performance.now(),r=this.retryDate;if(!r||s>=r||(t=this.media)!=null&&t.seeking){const{levels:n,trackId:a}=this;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((n==null?void 0:n[a])||null),this.state=N.IDLE}break}case N.WAITING_INIT_PTS:{const s=this.waitingData;if(s){const{frag:r,part:n,cache:a,complete:o}=s;if(this.initPTS[r.cc]!==void 0){this.waitingData=null,this.waitingVideoCC=-1,this.state=N.FRAG_LOADING;const l=a.flush(),d={frag:r,part:n,payload:l,networkDetails:null};this._handleFragmentLoadProgress(d),o&&super._handleFragmentLoadComplete(d)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log(`Waiting fragment cc (${r.cc}) cancelled because video is at cc ${this.videoTrackCC}`),this.clearWaitingFragment();else{const l=this.getLoadPosition(),d=Le.bufferInfo(this.mediaBuffer,l,this.config.maxBufferHole);eh(d.end,this.config.maxFragLookUpTolerance,r)<0&&(this.log(`Waiting fragment cc (${r.cc}) @ ${r.start} cancelled because another fragment at ${d.end} is needed`),this.clearWaitingFragment())}}else this.state=N.IDLE}}this.onTickEnd()}clearWaitingFragment(){const e=this.waitingData;e&&(this.fragmentTracker.removeFragment(e.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=N.IDLE)}resetLoadingState(){this.clearWaitingFragment(),super.resetLoadingState()}onTickEnd(){const{media:e}=this;e!=null&&e.readyState&&(this.lastCurrentTime=e.currentTime)}doTickIdle(){const{hls:e,levels:t,media:s,trackId:r}=this,n=e.config;if(!s&&(this.startFragRequested||!n.startFragPrefetch)||!(t!=null&&t[r]))return;const a=t[r],o=a.details;if(!o||o.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(o)){this.state=N.WAITING_TRACK;return}const l=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&l&&(this.bufferFlushed=!1,this.afterBufferFlushed(l,be.AUDIO,te.AUDIO));const d=this.getFwdBufferInfo(l,te.AUDIO);if(d===null)return;const{bufferedTrack:c,switchingTrack:u}=this;if(!u&&this._streamEnded(d,o)){e.trigger(E.BUFFER_EOS,{type:"audio"}),this.state=N.ENDED;return}const h=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,te.MAIN),f=d.len,m=this.getMaxBufferLength(h==null?void 0:h.len),p=o.fragments,g=p[0].start;let v=this.flushing?this.getLoadPosition():d.end;if(u&&s){const _=this.getLoadPosition();c&&!Cn(u.attrs,c.attrs)&&(v=_),o.PTSKnown&&_<g&&(d.end>g||d.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),s.currentTime=g+.05)}if(f>=m&&!u&&v<p[p.length-1].start)return;let y=this.getNextFragment(v,o),b=!1;if(y&&this.isLoopLoading(y,v)&&(b=!!y.gap,y=this.getNextFragmentLoopLoading(y,o,d,te.MAIN,m)),!y){this.bufferFlushed=!0;return}const x=h&&y.start>h.end+o.targetduration;if(x||!(h!=null&&h.len)&&d.len){const _=this.getAppendedFrag(y.start,te.MAIN);if(_===null||(b||(b=!!_.gap||!!x&&h.len===0),x&&!b||b&&d.nextStart&&d.nextStart<_.end))return}this.loadFragment(y,a,v)}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.min(Math.max(t,e),this.config.maxMaxBufferLength):t}onMediaDetaching(){this.videoBuffer=null,this.bufferFlushed=this.flushing=!1,super.onMediaDetaching()}onAudioTracksUpdated(e,{audioTracks:t}){this.resetTransmuxer(),this.levels=t.map(s=>new wn(s))}onAudioTrackSwitching(e,t){const s=!!t.url;this.trackId=t.id;const{fragCurrent:r}=this;r&&(r.abortRequests(),this.removeUnbufferedFrags(r.start)),this.resetLoadingState(),s?this.setInterval(x0):this.resetTransmuxer(),s?(this.switchingTrack=t,this.state=N.IDLE,this.flushAudioIfNeeded(t)):(this.switchingTrack=null,this.bufferedTrack=t,this.state=N.STOPPED),this.tick()}onManifestLoading(){this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=this.flushing=!1,this.levels=this.mainDetails=this.waitingData=this.bufferedTrack=this.cachedTrackLoadedData=this.switchingTrack=null,this.startFragRequested=!1,this.trackId=this.videoTrackCC=this.waitingVideoCC=-1}onLevelLoaded(e,t){this.mainDetails=t.details,this.cachedTrackLoadedData!==null&&(this.hls.trigger(E.AUDIO_TRACK_LOADED,this.cachedTrackLoadedData),this.cachedTrackLoadedData=null)}onAudioTrackLoaded(e,t){var s;if(this.mainDetails==null){this.cachedTrackLoadedData=t;return}const{levels:r}=this,{details:n,id:a}=t;if(!r){this.warn(`Audio tracks were reset while loading level ${a}`);return}this.log(`Audio track ${a} loaded [${n.startSN},${n.endSN}]${n.lastPartSn?`[part-${n.lastPartSn}-${n.lastPartIndex}]`:""},duration:${n.totalduration}`);const o=r[a];let l=0;if(n.live||(s=o.details)!=null&&s.live){this.checkLiveUpdate(n);const c=this.mainDetails;if(n.deltaUpdateFailed||!c)return;if(!o.details&&n.hasProgramDateTime&&c.hasProgramDateTime)Vd(n,c),l=n.fragments[0].start;else{var d;l=this.alignPlaylists(n,o.details,(d=this.levelLastLoaded)==null?void 0:d.details)}}o.details=n,this.levelLastLoaded=o,!this.startFragRequested&&(this.mainDetails||!n.live)&&this.setStartPosition(this.mainDetails||n,l),this.state===N.WAITING_TRACK&&!this.waitForCdnTuneIn(n)&&(this.state=N.IDLE),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:n}=e,{config:a,trackId:o,levels:l}=this;if(!l){this.warn(`Audio tracks were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const d=l[o];if(!d){this.warn("Audio track is undefined on fragment load progress");return}const c=d.details;if(!c){this.warn("Audio track details undefined on fragment load progress"),this.removeUnbufferedFrags(s.start);return}const u=a.defaultAudioCodec||d.audioCodec||"mp4a.40.2";let h=this.transmuxer;h||(h=this.transmuxer=new mE(this.hls,te.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));const f=this.initPTS[s.cc],m=(t=s.initSegment)==null?void 0:t.data;if(f!==void 0){const g=r?r.index:-1,v=g!==-1,y=new pm(s.level,s.sn,s.stats.chunkCount,n.byteLength,g,v);h.push(n,m,u,"",s,r,c.totalduration,!1,y,f)}else{this.log(`Unknown video PTS for cc ${s.cc}, waiting for video PTS before demuxing audio frag ${s.sn} of [${c.startSN} ,${c.endSN}],track ${o}`);const{cache:p}=this.waitingData=this.waitingData||{frag:s,part:r,cache:new Zv,complete:!1};p.push(new Uint8Array(n)),this.waitingVideoCC=this.videoTrackCC,this.state=N.WAITING_INIT_PTS}}_handleFragmentLoadComplete(e){if(this.waitingData){this.waitingData.complete=!0;return}super._handleFragmentLoadComplete(e)}onBufferReset(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1}onBufferCreated(e,t){const s=t.tracks.audio;s&&(this.mediaBuffer=s.buffer||null),t.tracks.video&&(this.videoBuffer=t.tracks.video.buffer||null)}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s.type!==te.AUDIO){if(!this.loadedmetadata&&s.type===te.MAIN){const n=this.videoBuffer||this.media;n&&Le.getBuffered(n).length&&(this.loadedmetadata=!0)}return}if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}, audioSwitch: ${this.switchingTrack?this.switchingTrack.name:"false"}`);return}if(s.sn!=="initSegment"){this.fragPrevious=s;const n=this.switchingTrack;n&&(this.bufferedTrack=n,this.switchingTrack=null,this.hls.trigger(E.AUDIO_TRACK_SWITCHED,dt({},n)))}this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.AUDIO,t);break;case M.AUDIO_TRACK_LOAD_ERROR:case M.AUDIO_TRACK_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_TRACK&&((s=t.context)==null?void 0:s.type)===pe.AUDIO_TRACK&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="audio")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&(this.bufferedTrack=null,super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"));break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}onBufferFlushing(e,{type:t}){t!==be.VIDEO&&(this.flushing=!0)}onBufferFlushed(e,{type:t}){if(t!==be.VIDEO){this.flushing=!1,this.bufferFlushed=!0,this.state===N.ENDED&&(this.state=N.IDLE);const s=this.mediaBuffer||this.media;s&&(this.afterBufferFlushed(s,t,te.AUDIO),this.tick())}}_handleTransmuxComplete(e){var t;const s="audio",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:c}=o,{details:u}=c,{audio:h,text:f,id3:m,initSegment:p}=n;if(this.fragContextChanged(l)||!u){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,this.switchingTrack&&h&&this.completeAudioSwitch(this.switchingTrack),p!=null&&p.tracks){const g=l.initSegment||l;this._bufferInitSegment(c,p.tracks,g,a),r.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:g,id:s,tracks:p.tracks})}if(h){const{startPTS:g,endPTS:v,startDTS:y,endDTS:b}=h;d&&(d.elementaryStreams[be.AUDIO]={startPTS:g,endPTS:v,startDTS:y,endDTS:b}),l.setElementaryStreamInfo(be.AUDIO,g,v,y,b),this.bufferFragmentData(h,l,d,a)}if(m!=null&&(t=m.samples)!=null&&t.length){const g=Ke({id:s,frag:l,details:u},m);r.trigger(E.FRAG_PARSING_METADATA,g)}if(f){const g=Ke({id:s,frag:l,details:u},f);r.trigger(E.FRAG_PARSING_USERDATA,g)}}_bufferInitSegment(e,t,s,r){if(this.state!==N.PARSING)return;t.video&&delete t.video;const n=t.audio;if(!n)return;n.id="audio";const a=e.audioCodec;this.log(`Init audio buffer, container:${n.container}, codecs[level/parsed]=[${a}/${n.codec}]`),a&&a.split(",").length===1&&(n.levelCodec=a),this.hls.trigger(E.BUFFER_CODECS,t);const o=n.initSegment;if(o!=null&&o.byteLength){const l={type:"audio",frag:s,part:null,chunkMeta:r,parent:s.type,data:o};this.hls.trigger(E.BUFFER_APPENDING,l)}this.tickImmediate()}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);if(this.fragCurrent=e,this.switchingTrack||r===rt.NOT_LOADED||r===rt.PARTIAL){var n;if(e.sn==="initSegment")this._loadInitSegment(e,t);else if((n=t.details)!=null&&n.live&&!this.initPTS[e.cc]){this.log(`Waiting for video PTS in continuity counter ${e.cc} of live stream before loading audio fragment ${e.sn} of level ${this.trackId}`),this.state=N.WAITING_INIT_PTS;const a=this.mainDetails;a&&a.fragments[0].start!==t.details.fragments[0].start&&Vd(t.details,a)}else this.startFragRequested=!0,super.loadFragment(e,t,s)}else this.clearTrackerIfNeeded(e)}flushAudioIfNeeded(e){const{media:t,bufferedTrack:s}=this,r=s==null?void 0:s.attrs,n=e.attrs;t&&r&&(r.CHANNELS!==n.CHANNELS||s.name!==e.name||s.lang!==e.lang)&&(this.log("Switching audio track : flushing all audio"),super.flushMainBuffer(0,Number.POSITIVE_INFINITY,"audio"),this.bufferedTrack=null)}completeAudioSwitch(e){const{hls:t}=this;this.flushAudioIfNeeded(e),this.bufferedTrack=e,this.switchingTrack=null,t.trigger(E.AUDIO_TRACK_SWITCHED,dt({},e))}}class hk extends mm{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(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),e.off(E.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:r,details:n}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Audio track with id:${s} and group:${r} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Audio track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.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,r=this.groupIds;let n=this.currentTrack;if(!s||(r==null?void 0:r.length)!==(s==null?void 0:s.length)||s!=null&&s.some(o=>(r==null?void 0:r.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(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=o;const l=this.hls.config.audioPreference;if(!n&&l){const h=wi(l,o,Mr);if(h>-1)n=o[h];else{const f=wi(l,this.tracks);n=this.tracks[f]}}let d=this.findTrackId(n);d===-1&&n&&(d=this.findTrackId(null));const c={audioTracks:o};this.log(`Updating audio tracks, ${o.length} track(s) found in group(s): ${s==null?void 0:s.join(",")}`),this.hls.trigger(E.AUDIO_TRACKS_UPDATED,c);const u=this.trackId;if(d!==-1&&u===-1)this.setAudioTrack(d);else if(o.length&&u===-1){var a;const h=new Error(`No audio track selected for current audio group-ID(s): ${(a=this.groupIds)==null?void 0:a.join(",")} track count: ${o.length}`);this.warn(h.message),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:h})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}onError(e,t){t.fatal||!t.context||t.context.type===pe.AUDIO_TRACK&&t.context.id===this.trackId&&(!this.groupIds||this.groupIds.indexOf(t.context.groupId)!==-1)&&(this.requestScheduled=-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 r=this.currentTrack;if(r&&En(e,r,Mr))return r;const n=wi(e,this.tracksInGroup,Mr);if(n>-1){const a=this.tracksInGroup[n];return this.setAudioTrack(n),a}else if(r){let a=t.loadLevel;a===-1&&(a=t.firstAutoLevel);const o=hx(e,t.levels,s,a,Mr);if(o===-1)return null;t.nextLoadLevel=o}if(e.channels||e.audioCodec){const a=wi(e,s);if(a>-1)return s[a]}}}return null}setAudioTrack(e){const t=this.tracksInGroup;if(e<0||e>=t.length){this.warn(`Invalid audio track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e],n=r.details&&!r.details.live;if(e===this.trackId&&r===s&&n||(this.log(`Switching to audio-track ${e} "${r.name}" lang:${r.lang} group:${r.groupId} channels:${r.channels}`),this.trackId=e,this.currentTrack=r,this.hls.trigger(E.AUDIO_TRACK_SWITCHING,dt({},r)),n))return;const a=this.switchParams(r.url,s==null?void 0:s.details,r.details);this.loadPlaylist(a)}findTrackId(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(!(this.selectDefaultTrack&&!r.default)&&(!e||En(e,r,Mr)))return s}if(e){const{name:s,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l}=e;for(let d=0;d<t.length;d++){const c=t[d];if(En({name:s,lang:r,assocLang:n,characteristics:a,audioCodec:o,channels:l},c,Mr))return d}for(let d=0;d<t.length;d++){const c=t[d];if(Cn(e.attrs,c.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return d}for(let d=0;d<t.length;d++){const c=t[d];if(Cn(e.attrs,c.attrs,["LANGUAGE"]))return d}}return-1}loadPlaylist(e){const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){super.loadPlaylist();const s=t.id,r=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`loading audio-track playlist ${s} "${t.name}" lang:${t.lang} group:${r}`),this.clearTimer(),this.hls.trigger(E.AUDIO_TRACK_LOADING,{url:n,id:s,groupId:r,deliveryDirectives:e||null})}}}const k0=500;class fk extends vm{constructor(e,t,s){super(e,t,s,"[subtitle-stream-controller]",te.SUBTITLE),this.currentTrackId=-1,this.tracksBuffered=[],this.mainDetails=null,this._registerListeners()}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying(),this.mainDetails=null}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.ERROR,this.onError,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.ERROR,this.onError,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}startLoad(e){this.stopLoad(),this.state=N.IDLE,this.setInterval(k0),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}onManifestLoading(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()}onMediaDetaching(){this.tracksBuffered=[],super.onMediaDetaching()}onLevelLoaded(e,t){this.mainDetails=t.details}onSubtitleFragProcessed(e,t){const{frag:s,success:r}=t;if(this.fragPrevious=s,this.state=N.IDLE,!r)return;const n=this.tracksBuffered[this.currentTrackId];if(!n)return;let a;const o=s.start;for(let d=0;d<n.length;d++)if(o>=n[d].start&&o<=n[d].end){a=n[d];break}const l=s.start+s.duration;a?a.end=l:(a={start:o,end:l},n.push(a)),this.fragmentTracker.fragBuffered(s),this.fragBufferedComplete(s,null)}onBufferFlushing(e,t){const{startOffset:s,endOffset:r}=t;if(s===0&&r!==Number.POSITIVE_INFINITY){const n=r-1;if(n<=0)return;t.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach(a=>{for(let o=0;o<a.length;){if(a[o].end<=n){a.shift();continue}else if(a[o].start<n)a[o].start=n;else break;o++}}),this.fragmentTracker.removeFragmentsInRange(s,n,te.SUBTITLE)}}onFragBuffered(e,t){if(!this.loadedmetadata&&t.frag.type===te.MAIN){var s;(s=this.media)!=null&&s.buffered.length&&(this.loadedmetadata=!0)}}onError(e,t){const s=t.frag;(s==null?void 0:s.type)===te.SUBTITLE&&(t.details===M.FRAG_GAP&&this.fragmentTracker.fragBuffered(s,!0),this.fragCurrent&&this.fragCurrent.abortRequests(),this.state!==N.STOPPED&&(this.state=N.IDLE))}onSubtitleTracksUpdated(e,{subtitleTracks:t}){if(this.levels&&pE(this.levels,t)){this.levels=t.map(s=>new wn(s));return}this.tracksBuffered=[],this.levels=t.map(s=>{const r=new wn(s);return this.tracksBuffered[r.id]=[],r}),this.fragmentTracker.removeFragmentsInRange(0,Number.POSITIVE_INFINITY,te.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 r=this.levels[this.currentTrackId];r!=null&&r.details?this.mediaBuffer=this.mediaBufferTimeRanges:this.mediaBuffer=null,r&&this.setInterval(k0)}onSubtitleTrackLoaded(e,t){var s;const{currentTrackId:r,levels:n}=this,{details:a,id:o}=t;if(!n){this.warn(`Subtitle tracks were reset while loading level ${o}`);return}const l=n[o];if(o>=n.length||!l)return;this.log(`Subtitle track ${o} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""},duration:${a.totalduration}`),this.mediaBuffer=this.mediaBufferTimeRanges;let d=0;if(a.live||(s=l.details)!=null&&s.live){const u=this.mainDetails;if(a.deltaUpdateFailed||!u)return;const h=u.fragments[0];if(!l.details)a.hasProgramDateTime&&u.hasProgramDateTime?(Vd(a,u),d=a.fragments[0].start):h&&(d=h.start,Ju(a,d));else{var c;d=this.alignPlaylists(a,l.details,(c=this.levelLastLoaded)==null?void 0:c.details),d===0&&h&&(d=h.start,Ju(a,d))}}l.details=a,this.levelLastLoaded=l,o===r&&(!this.startFragRequested&&(this.mainDetails||!a.live)&&this.setStartPosition(this.mainDetails||a,d),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===N.IDLE&&(Kd(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),l.details=void 0)))}_handleFragmentLoadComplete(e){const{frag:t,payload:s}=e,r=t.decryptdata,n=this.hls;if(!this.fragContextChanged(t)&&s&&s.byteLength>0&&r!=null&&r.key&&r.iv&&r.method==="AES-128"){const a=performance.now();this.decrypter.decrypt(new Uint8Array(s),r.key.buffer,r.iv.buffer).catch(o=>{throw n.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.FRAG_DECRYPT_ERROR,fatal:!1,error:o,reason:o.message,frag:t}),o}).then(o=>{const l=performance.now();n.trigger(E.FRAG_DECRYPTED,{frag:t,payload:o,stats:{tstart:a,tdecrypt:l}})}).catch(o=>{this.warn(`${o.name}: ${o.message}`),this.state=N.IDLE})}}doTick(){if(!this.media){this.state=N.IDLE;return}if(this.state===N.IDLE){const{currentTrackId:e,levels:t}=this,s=t==null?void 0:t[e];if(!s||!t.length||!s.details)return;const{config:r}=this,n=this.getLoadPosition(),a=Le.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,r.maxBufferHole),{end:o,len:l}=a,d=this.getFwdBufferInfo(this.media,te.MAIN),c=s.details,u=this.getMaxBufferLength(d==null?void 0:d.len)+c.levelTargetDuration;if(l>u)return;const h=c.fragments,f=h.length,m=c.edge;let p=null;const g=this.fragPrevious;if(o<m){const v=r.maxFragLookUpTolerance,y=o>m-v?0:v;p=Kd(g,h,Math.max(h[0].start,o),y),!p&&g&&g.start<h[0].start&&(p=h[0])}else p=h[f-1];if(!p)return;if(p=this.mapToInitFragWhenRequired(p),p.sn!=="initSegment"){const v=p.sn-c.startSN,y=h[v-1];y&&y.cc===p.cc&&this.fragmentTracker.getState(y)===rt.NOT_LOADED&&(p=y)}this.fragmentTracker.getState(p)===rt.NOT_LOADED&&this.loadFragment(p,s,o)}}getMaxBufferLength(e){const t=super.getMaxBufferLength();return e?Math.max(t,e):t}loadFragment(e,t,s){this.fragCurrent=e,e.sn==="initSegment"?this._loadInitSegment(e,t):(this.startFragRequested=!0,super.loadFragment(e,t,s))}get mediaBufferTimeRanges(){return new mk(this.tracksBuffered[this.currentTrackId]||[])}}class mk{constructor(e){this.buffered=void 0;const t=(s,r,n)=>{if(r=r>>>0,r>n-1)throw new DOMException(`Failed to execute '${s}' on 'TimeRanges': The index provided (${r}) is greater than the maximum bound (${n})`);return e[r][s]};this.buffered={get length(){return e.length},end(s){return t("end",s,e.length)},start(s){return t("start",s,e.length)}}}}class pk extends mm{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.asyncPollTrackChange=()=>this.pollTrackChange(0),this.useTextTrackPolling=!1,this.subtitlePollingInterval=-1,this._subtitleDisplay=!0,this.onTextTracksChanged=()=>{if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),!this.media||!this.hls.config.renderTextTracksNatively)return;let t=null;const s=tl(this.media.textTracks);for(let n=0;n<s.length;n++)if(s[n].mode==="hidden")t=s[n];else if(s[n].mode==="showing"){t=s[n];break}const r=this.findTrackForTextTrack(t);this.subtitleTrack!==r&&this.setSubtitleTrack(r)},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(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.on(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADING,this.onLevelLoading,this),e.off(E.LEVEL_SWITCHING,this.onLevelSwitching,this),e.off(E.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),e.off(E.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(){if(!this.media)return;self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),tl(this.media.textTracks).forEach(t=>{fn(t)}),this.subtitleTrack=-1,this.media=null}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:r,details:n}=t,a=this.tracksInGroup[s];if(!a||a.groupId!==r){this.warn(`Subtitle track with id:${s} and group:${r} not found in active group ${a==null?void 0:a.groupId}`);return}const o=a.details;a.details=t.details,this.log(`Subtitle track ${s} "${a.name}" lang:${a.lang} group:${r} loaded [${n.startSN}-${n.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,r=this.groupIds;let n=this.currentTrack;if(!s||(r==null?void 0:r.length)!==(s==null?void 0:s.length)||s!=null&&s.some(a=>(r==null?void 0:r.indexOf(a))===-1)){this.groupIds=s,this.trackId=-1,this.currentTrack=null;const a=this.tracks.filter(c=>!s||s.indexOf(c.groupId)!==-1);if(a.length)this.selectDefaultTrack&&!a.some(c=>c.default)&&(this.selectDefaultTrack=!1),a.forEach((c,u)=>{c.id=u});else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;const o=this.hls.config.subtitlePreference;if(!n&&o){this.selectDefaultTrack=!1;const c=wi(o,a);if(c>-1)n=a[c];else{const u=wi(o,this.tracks);n=this.tracks[u]}}let l=this.findTrackId(n);l===-1&&n&&(l=this.findTrackId(null));const d={subtitleTracks:a};this.log(`Updating subtitle tracks, ${a.length} track(s) found in "${s==null?void 0:s.join(",")}" group-id`),this.hls.trigger(E.SUBTITLE_TRACKS_UPDATED,d),l!==-1&&this.trackId===-1&&this.setSubtitleTrack(l)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}findTrackId(e){const t=this.tracksInGroup,s=this.selectDefaultTrack;for(let r=0;r<t.length;r++){const n=t[r];if(!(s&&!n.default||!s&&!e)&&(!e||En(n,e)))return r}if(e){for(let r=0;r<t.length;r++){const n=t[r];if(Cn(e.attrs,n.attrs,["LANGUAGE","ASSOC-LANGUAGE","CHARACTERISTICS"]))return r}for(let r=0;r<t.length;r++){const n=t[r];if(Cn(e.attrs,n.attrs,["LANGUAGE"]))return r}}return-1}findTrackForTextTrack(e){if(e){const t=this.tracksInGroup;for(let s=0;s<t.length;s++){const r=t[s];if(ih(r,e))return s}}return-1}onError(e,t){t.fatal||!t.context||t.context.type===pe.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){const t=this.allSubtitleTracks;if(this.selectDefaultTrack=!1,t.length){const s=this.currentTrack;if(s&&En(e,s))return s;const r=wi(e,this.tracksInGroup);if(r>-1){const n=this.tracksInGroup[r];return this.setSubtitleTrack(r),n}else{if(s)return null;{const n=wi(e,t);if(n>-1)return t[n]}}}}return null}loadPlaylist(e){super.loadPlaylist();const t=this.currentTrack;if(this.shouldLoadPlaylist(t)&&t){const s=t.id,r=t.groupId;let n=t.url;if(e)try{n=e.addDirectives(n)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}this.log(`Loading subtitle playlist for id ${s}`),this.hls.trigger(E.SUBTITLE_TRACK_LOADING,{url:n,id:s,groupId:r,deliveryDirectives:e||null})}}toggleTrackModes(){const{media:e}=this;if(!e)return;const t=tl(e.textTracks),s=this.currentTrack;let r;if(s&&(r=t.filter(n=>ih(s,n))[0],r||this.warn(`Unable to find subtitle TextTrack with name "${s.name}" and language "${s.lang}"`)),[].slice.call(t).forEach(n=>{n.mode!=="disabled"&&n!==r&&(n.mode="disabled")}),r){const n=this.subtitleDisplay?"showing":"hidden";r.mode!==n&&(r.mode=n)}}setSubtitleTrack(e){const t=this.tracksInGroup;if(!this.media){this.queuedDefaultTrack=e;return}if(e<-1||e>=t.length||!j(e)){this.warn(`Invalid subtitle track id: ${e}`);return}this.clearTimer(),this.selectDefaultTrack=!1;const s=this.currentTrack,r=t[e]||null;if(this.trackId=e,this.currentTrack=r,this.toggleTrackModes(),!r){this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:e});return}const n=!!r.details&&!r.details.live;if(e===this.trackId&&r===s&&n)return;this.log(`Switching to subtitle-track ${e}`+(r?` "${r.name}" lang:${r.lang} group:${r.groupId}`:""));const{id:a,groupId:o="",name:l,type:d,url:c}=r;this.hls.trigger(E.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:d,url:c});const u=this.switchParams(r.url,s==null?void 0:s.details,r.details);this.loadPlaylist(u)}}class gk{constructor(e){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=e}append(e,t,s){const r=this.queues[t];r.push(e),r.length===1&&!s&&this.executeNext(t)}insertAbort(e,t){this.queues[t].unshift(e),this.executeNext(t)}appendBlocker(e){let t;const s=new Promise(n=>{t=n}),r={execute:t,onStart:()=>{},onComplete:()=>{},onError:()=>{}};return this.append(r,e),s}executeNext(e){const t=this.queues[e];if(t.length){const s=t[0];try{s.execute()}catch(r){R.warn(`[buffer-operation-queue]: Exception executing "${e}" SourceBuffer operation: ${r}`),s.onError(r);const n=this.buffers[e];n!=null&&n.updating||this.shiftAndExecuteNext(e)}}}shiftAndExecuteNext(e){this.queues[e].shift(),this.executeNext(e)}current(e){return this.queues[e][0]}}const L0=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/;class vk{constructor(e){this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=s=>{this.hls&&this.hls.pauseBuffering()},this._onStartStreaming=s=>{this.hls&&this.hls.resumeBuffering()},this._onMediaSourceOpen=()=>{const{media:s,mediaSource:r}=this;this.log("Media source opened"),s&&(s.removeEventListener("emptied",this._onMediaEmptied),this.updateMediaElementDuration(),this.hls.trigger(E.MEDIA_ATTACHED,{media:s,mediaSource:r})),r&&r.removeEventListener("sourceopen",this._onMediaSourceOpen),this.checkPendingTracks()},this._onMediaSourceClose=()=>{this.log("Media source closed")},this._onMediaSourceEnded=()=>{this.log("Media source ended")},this._onMediaEmptied=()=>{const{mediaSrc:s,_objectUrl:r}=this;s!==r&&R.error(`Media element src was set while attaching MediaSource (${r} > ${s})`)},this.hls=e;const t="[buffer-controller]";this.appendSource=kS(_r(e.config.preferManagedMediaSource)),this.log=R.log.bind(R,t),this.warn=R.warn.bind(R,t),this.error=R.error.bind(R,t),this._initSourceBuffer(),this.registerListeners()}hasSourceTypes(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0}destroy(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null}registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.BUFFER_RESET,this.onBufferReset,this),e.on(E.BUFFER_APPENDING,this.onBufferAppending,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.BUFFER_EOS,this.onBufferEos,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.on(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.on(E.FRAG_PARSED,this.onFragParsed,this),e.on(E.FRAG_CHANGED,this.onFragChanged,this)}unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.BUFFER_RESET,this.onBufferReset,this),e.off(E.BUFFER_APPENDING,this.onBufferAppending,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.BUFFER_EOS,this.onBufferEos,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),e.off(E.LEVEL_UPDATED,this.onLevelUpdated,this),e.off(E.FRAG_PARSED,this.onFragParsed,this),e.off(E.FRAG_CHANGED,this.onFragChanged,this)}_initSourceBuffer(){this.sourceBuffer={},this.operationQueue=new gk(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null}onManifestLoading(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null}onManifestParsed(e,t){let s=2;(t.audio&&!t.video||!t.altAudio)&&(s=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=s,this.log(`${this.bufferCodecEventsExpected} bufferCodec event(s) expected`)}onMediaAttaching(e,t){const s=this.media=t.media,r=_r(this.appendSource);if(s&&r){var n;const a=this.mediaSource=new r;this.log(`created media source: ${(n=a.constructor)==null?void 0:n.name}`),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));const o=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{s.removeAttribute("src");const l=self.ManagedMediaSource;s.disableRemotePlayback=s.disableRemotePlayback||l&&a instanceof l,I0(s),Ek(s,o),s.load()}catch{s.src=o}else s.src=o;s.addEventListener("emptied",this._onMediaEmptied)}}onMediaDetaching(){const{media:e,mediaSource:t,_objectUrl:s}=this;if(t){if(this.log("media source detaching"),t.readyState==="open")try{t.endOfStream()}catch(r){this.warn(`onMediaDetaching: ${r.message} while calling endOfStream`)}this.onBufferReset(),t.removeEventListener("sourceopen",this._onMediaSourceOpen),t.removeEventListener("sourceended",this._onMediaSourceEnded),t.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(t.removeEventListener("startstreaming",this._onStartStreaming),t.removeEventListener("endstreaming",this._onEndStreaming)),e&&(e.removeEventListener("emptied",this._onMediaEmptied),s&&self.URL.revokeObjectURL(s),this.mediaSrc===s?(e.removeAttribute("src"),this.appendSource&&I0(e),e.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(E.MEDIA_DETACHED,void 0)}onBufferReset(){this.getSourceBufferTypes().forEach(e=>{this.resetBuffer(e)}),this._initSourceBuffer()}resetBuffer(e){const t=this.sourceBuffer[e];try{if(t){var s;this.removeBufferListeners(e),this.sourceBuffer[e]=void 0,(s=this.mediaSource)!=null&&s.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(t)}}catch(r){this.warn(`onBufferReset ${e}`,r)}}onBufferCodecs(e,t){const s=this.getSourceBufferTypes().length,r=Object.keys(t);if(r.forEach(a=>{if(s){const l=this.tracks[a];if(l&&typeof l.buffer.changeType=="function"){var o;const{id:d,codec:c,levelCodec:u,container:h,metadata:f}=t[a],m=zp(l.codec,l.levelCodec),p=m==null?void 0:m.replace(L0,"$1");let g=zp(c,u);const v=(o=g)==null?void 0:o.replace(L0,"$1");if(g&&p!==v){a.slice(0,5)==="audio"&&(g=Bd(g,this.appendSource));const y=`${h};codecs=${g}`;this.appendChangeType(a,y),this.log(`switching codec ${m} to ${g}`),this.tracks[a]={buffer:l.buffer,codec:c,container:h,levelCodec:u,metadata:f,id:d}}}}else this.pendingTracks[a]=t[a]}),s)return;const n=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==n&&(this.log(`${n} bufferCodec event(s) expected ${r.join(",")}`),this.bufferCodecEventsExpected=n),this.mediaSource&&this.mediaSource.readyState==="open"&&this.checkPendingTracks()}appendChangeType(e,t){const{operationQueue:s}=this,r={execute:()=>{const n=this.sourceBuffer[e];n&&(this.log(`changing ${e} sourceBuffer type to ${t}`),n.changeType(t)),s.shiftAndExecuteNext(e)},onStart:()=>{},onComplete:()=>{},onError:n=>{this.warn(`Failed to change ${e} SourceBuffer type`,n)}};s.append(r,e,!!this.pendingTracks[e])}onBufferAppending(e,t){const{hls:s,operationQueue:r,tracks:n}=this,{data:a,type:o,frag:l,part:d,chunkMeta:c}=t,u=c.buffering[o],h=self.performance.now();u.start=h;const f=l.stats.buffering,m=d?d.stats.buffering:null;f.start===0&&(f.start=h),m&&m.start===0&&(m.start=h);const p=n.audio;let g=!1;o==="audio"&&(p==null?void 0:p.container)==="audio/mpeg"&&(g=!this.lastMpegAudioChunk||c.id===1||this.lastMpegAudioChunk.sn!==c.sn,this.lastMpegAudioChunk=c);const v=l.start,y={execute:()=>{if(u.executeStart=self.performance.now(),g){const b=this.sourceBuffer[o];if(b){const x=v-b.timestampOffset;Math.abs(x)>=.1&&(this.log(`Updating audio SourceBuffer timestampOffset to ${v} (delta: ${x}) sn: ${l.sn})`),b.timestampOffset=v)}}this.appendExecutor(a,o)},onStart:()=>{},onComplete:()=>{const b=self.performance.now();u.executeEnd=u.end=b,f.first===0&&(f.first=b),m&&m.first===0&&(m.first=b);const{sourceBuffer:x}=this,_={};for(const S in x)_[S]=Le.getBuffered(x[S]);this.appendErrors[o]=0,o==="audio"||o==="video"?this.appendErrors.audiovideo=0:(this.appendErrors.audio=0,this.appendErrors.video=0),this.hls.trigger(E.BUFFER_APPENDED,{type:o,frag:l,part:d,chunkMeta:c,parent:l.type,timeRanges:_})},onError:b=>{const x={type:se.MEDIA_ERROR,parent:l.type,details:M.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:d,chunkMeta:c,error:b,err:b,fatal:!1};if(b.code===DOMException.QUOTA_EXCEEDED_ERR)x.details=M.BUFFER_FULL_ERROR;else{const _=++this.appendErrors[o];x.details=M.BUFFER_APPEND_ERROR,this.warn(`Failed ${_}/${s.config.appendErrorMaxRetry} times to append segment in "${o}" sourceBuffer`),_>=s.config.appendErrorMaxRetry&&(x.fatal=!0)}s.trigger(E.ERROR,x)}};r.append(y,o,!!this.pendingTracks[o])}onBufferFlushing(e,t){const{operationQueue:s}=this,r=n=>({execute:this.removeExecutor.bind(this,n,t.startOffset,t.endOffset),onStart:()=>{},onComplete:()=>{this.hls.trigger(E.BUFFER_FLUSHED,{type:n})},onError:a=>{this.warn(`Failed to remove from ${n} SourceBuffer`,a)}});t.type?s.append(r(t.type),t.type):this.getSourceBufferTypes().forEach(n=>{s.append(r(n),n)})}onFragParsed(e,t){const{frag:s,part:r}=t,n=[],a=r?r.elementaryStreams:s.elementaryStreams;a[be.AUDIOVIDEO]?n.push("audiovideo"):(a[be.AUDIO]&&n.push("audio"),a[be.VIDEO]&&n.push("video"));const o=()=>{const l=self.performance.now();s.stats.buffering.end=l,r&&(r.stats.buffering.end=l);const d=r?r.stats:s.stats;this.hls.trigger(E.FRAG_BUFFERED,{frag:s,part:r,stats:d,id:s.type})};n.length===0&&this.warn(`Fragments must have at least one ElementaryStreamType set. type: ${s.type} level: ${s.level} sn: ${s.sn}`),this.blockBuffers(o,n)}onFragChanged(e,t){this.trimBuffers()}onBufferEos(e,t){this.getSourceBufferTypes().reduce((r,n)=>{const a=this.sourceBuffer[n];return a&&(!t.type||t.type===n)&&(a.ending=!0,a.ended||(a.ended=!0,this.log(`${n} sourceBuffer now EOS`))),r&&!!(!a||a.ended)},!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers(()=>{this.getSourceBufferTypes().forEach(n=>{const a=this.sourceBuffer[n];a&&(a.ending=!1)});const{mediaSource:r}=this;if(!r||r.readyState!=="open"){r&&this.log(`Could not call mediaSource.endOfStream(). mediaSource.readyState: ${r.readyState}`);return}this.log("Calling mediaSource.endOfStream()"),r.endOfStream()}))}onLevelUpdated(e,{details:t}){t.fragments.length&&(this.details=t,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())}trimBuffers(){const{hls:e,details:t,media:s}=this;if(!s||t===null||!this.getSourceBufferTypes().length)return;const n=e.config,a=s.currentTime,o=t.levelTargetDuration,l=t.live&&n.liveBackBufferLength!==null?n.liveBackBufferLength:n.backBufferLength;if(j(l)&&l>0){const d=Math.max(l,o),c=Math.floor(a/o)*o-d;this.flushBackBuffer(a,o,c)}if(j(n.frontBufferFlushThreshold)&&n.frontBufferFlushThreshold>0){const d=Math.max(n.maxBufferLength,n.frontBufferFlushThreshold),c=Math.max(d,o),u=Math.floor(a/o)*o+c;this.flushFrontBuffer(a,o,u)}}flushBackBuffer(e,t,s){const{details:r,sourceBuffer:n}=this;this.getSourceBufferTypes().forEach(o=>{const l=n[o];if(l){const d=Le.getBuffered(l);if(d.length>0&&s>d.start(0)){if(this.hls.trigger(E.BACK_BUFFER_REACHED,{bufferEnd:s}),r!=null&&r.live)this.hls.trigger(E.LIVE_BACK_BUFFER_REACHED,{bufferEnd:s});else if(l.ended&&d.end(d.length-1)-e<t*2){this.log(`Cannot flush ${o} back buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:s,type:o})}}})}flushFrontBuffer(e,t,s){const{sourceBuffer:r}=this;this.getSourceBufferTypes().forEach(a=>{const o=r[a];if(o){const l=Le.getBuffered(o),d=l.length;if(d<2)return;const c=l.start(d-1),u=l.end(d-1);if(s>c||e>=c&&e<=u)return;if(o.ended&&e-u<2*t){this.log(`Cannot flush ${a} front buffer while SourceBuffer is in ended state`);return}this.hls.trigger(E.BUFFER_FLUSHING,{startOffset:c,endOffset:1/0,type:a})}})}updateMediaElementDuration(){if(!this.details||!this.media||!this.mediaSource||this.mediaSource.readyState!=="open")return;const{details:e,hls:t,media:s,mediaSource:r}=this,n=e.fragments[0].start+e.totalduration,a=s.duration,o=j(r.duration)?r.duration:0;e.live&&t.config.liveDurationInfinity?(r.duration=1/0,this.updateSeekableRange(e)):(n>o&&n>a||!j(a))&&(this.log(`Updating Media Source duration to ${n.toFixed(3)}`),r.duration=n)}updateSeekableRange(e){const t=this.mediaSource,s=e.fragments;if(s.length&&e.live&&t!=null&&t.setLiveSeekableRange){const n=Math.max(0,s[0].start),a=Math.max(n,n+e.totalduration);this.log(`Media Source duration is set to ${t.duration}. Setting seekable range to ${n}-${a}.`),t.setLiveSeekableRange(n,a)}}checkPendingTracks(){const{bufferCodecEventsExpected:e,operationQueue:t,pendingTracks:s}=this,r=Object.keys(s).length;if(r&&(!e||r===2||"audiovideo"in s)){this.createSourceBuffers(s),this.pendingTracks={};const n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(E.BUFFER_CREATED,{tracks:this.tracks}),n.forEach(a=>{t.executeNext(a)});else{const a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}}createSourceBuffers(e){const{sourceBuffer:t,mediaSource:s}=this;if(!s)throw Error("createSourceBuffers called when mediaSource was null");for(const n in e)if(!t[n]){var r;const a=e[n];if(!a)throw Error(`source buffer exists for track ${n}, however track does not`);let o=((r=a.levelCodec)==null?void 0:r.indexOf(","))===-1?a.levelCodec:a.codec;o&&n.slice(0,5)==="audio"&&(o=Bd(o,this.appendSource));const l=`${a.container};codecs=${o}`;this.log(`creating sourceBuffer(${l})`);try{const d=t[n]=s.addSourceBuffer(l),c=n;this.addBufferListener(c,"updatestart",this._onSBUpdateStart),this.addBufferListener(c,"updateend",this._onSBUpdateEnd),this.addBufferListener(c,"error",this._onSBUpdateError),this.appendSource&&this.addBufferListener(c,"bufferedchange",(u,h)=>{const f=h.removedRanges;f!=null&&f.length&&this.hls.trigger(E.BUFFER_FLUSHED,{type:n})}),this.tracks[n]={buffer:d,codec:o,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(d){this.error(`error while trying to add sourceBuffer: ${d.message}`),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:d,sourceBufferName:n,mimeType:l})}}}get mediaSrc(){var e;const t=((e=this.media)==null?void 0:e.firstChild)||this.media;return t==null?void 0:t.src}_onSBUpdateStart(e){const{operationQueue:t}=this;t.current(e).onStart()}_onSBUpdateEnd(e){var t;if(((t=this.mediaSource)==null?void 0:t.readyState)==="closed"){this.resetBuffer(e);return}const{operationQueue:s}=this;s.current(e).onComplete(),s.shiftAndExecuteNext(e)}_onSBUpdateError(e,t){var s;const r=new Error(`${e} SourceBuffer error. MediaSource readyState: ${(s=this.mediaSource)==null?void 0:s.readyState}`);this.error(`${r}`,t),this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_APPENDING_ERROR,sourceBufferName:e,error:r,fatal:!1});const n=this.operationQueue.current(e);n&&n.onError(r)}removeExecutor(e,t,s){const{media:r,mediaSource:n,operationQueue:a,sourceBuffer:o}=this,l=o[e];if(!r||!n||!l){this.warn(`Attempting to remove from the ${e} SourceBuffer, but it does not exist`),a.shiftAndExecuteNext(e);return}const d=j(r.duration)?r.duration:1/0,c=j(n.duration)?n.duration:1/0,u=Math.max(0,t),h=Math.min(s,d,c);h>u&&(!l.ending||l.ended)?(l.ended=!1,this.log(`Removing [${u},${h}] from the ${e} SourceBuffer`),l.remove(u,h)):a.shiftAndExecuteNext(e)}appendExecutor(e,t){const s=this.sourceBuffer[t];if(!s){if(!this.pendingTracks[t])throw new Error(`Attempting to append to the ${t} SourceBuffer, but it does not exist`);return}s.ended=!1,s.appendBuffer(e)}blockBuffers(e,t=this.getSourceBufferTypes()){if(!t.length){this.log("Blocking operation requested, but no SourceBuffers exist"),Promise.resolve().then(e);return}const{operationQueue:s}=this,r=t.map(n=>s.appendBlocker(n));Promise.all(r).then(()=>{e(),t.forEach(n=>{const a=this.sourceBuffer[n];a!=null&&a.updating||s.shiftAndExecuteNext(n)})})}getSourceBufferTypes(){return Object.keys(this.sourceBuffer)}addBufferListener(e,t,s){const r=this.sourceBuffer[e];if(!r)return;const n=s.bind(this,e);this.listeners[e].push({event:t,listener:n}),r.addEventListener(t,n)}removeBufferListeners(e){const t=this.sourceBuffer[e];t&&this.listeners[e].forEach(s=>{t.removeEventListener(s.event,s.listener)})}}function I0(i){const e=i.querySelectorAll("source");[].slice.call(e).forEach(t=>{i.removeChild(t)})}function Ek(i,e){const t=self.document.createElement("source");t.type="video/mp4",t.src=e,i.appendChild(t)}const bk={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},gE=i=>String.fromCharCode(bk[i]||i),Xt=15,Bi=100,yk={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},Tk={17:2,18:4,21:6,22:8,23:10,19:13,20:15},_k={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},Ak={25:2,26:4,29:6,30:8,31:10,27:13,28:15},Sk=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];class xk{constructor(){this.time=null,this.verboseLevel=0}log(e,t){if(this.verboseLevel>=e){const s=typeof t=="function"?t():t;R.log(`${this.time} [${e}] ${s}`)}}}const Is=function(e){const t=[];for(let s=0;s<e.length;s++)t.push(e[s].toString(16));return t};class vE{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 r=t[s];e.hasOwnProperty(r)&&(this[r]=e[r])}}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 kk{constructor(){this.uchar=" ",this.penState=new vE}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 Lk{constructor(e){this.chars=[],this.pos=0,this.currPenState=new vE,this.cueStartTime=null,this.logger=void 0;for(let t=0;t<Bi;t++)this.chars.push(new kk);this.logger=e}equals(e){for(let t=0;t<Bi;t++)if(!this.chars[t].equals(e.chars[t]))return!1;return!0}copy(e){for(let t=0;t<Bi;t++)this.chars[t].copy(e.chars[t])}isEmpty(){let e=!0;for(let t=0;t<Bi;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>Bi&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=Bi)}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=gE(e);if(this.pos>=Bi){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<Bi;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<Bi;s++){const r=this.chars[s].uchar;r!==" "&&(t=!1),e.push(r)}return t?"":e.join("")}setPenStyles(e){this.currPenState.setStyles(e),this.chars[this.pos].setPenState(this.currPenState)}}class au{constructor(e){this.rows=[],this.currRow=Xt-1,this.nrRollUpRows=null,this.lastOutputScreen=null,this.logger=void 0;for(let t=0;t<Xt;t++)this.rows.push(new Lk(e));this.logger=e}reset(){for(let e=0;e<Xt;e++)this.rows[e].clear();this.currRow=Xt-1}equals(e){let t=!0;for(let s=0;s<Xt;s++)if(!this.rows[s].equals(e.rows[s])){t=!1;break}return t}copy(e){for(let t=0;t<Xt;t++)this.rows[t].copy(e.rows[t])}isEmpty(){let e=!0;for(let t=0;t<Xt;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 = "+JSON.stringify(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<Xt;o++)this.rows[o].clear();const n=this.currRow+1-this.nrRollUpRows,a=this.lastOutputScreen;if(a){const o=a.rows[n].cueStartTime,l=this.logger.time;if(o!==null&&l!==null&&o<l)for(let d=0;d<this.nrRollUpRows;d++)this.rows[t-this.nrRollUpRows+d+1].copy(a.rows[n+d])}}this.currRow=t;const s=this.rows[this.currRow];if(e.indent!==null){const n=e.indent,a=Math.max(n-1,0);s.setCursor(e.indent),e.color=s.chars[a].penState.foreground}const r={foreground:e.color,underline:e.underline,italics:e.italics,background:"black",flash:!1};this.setPen(r)}setBkgData(e){this.logger.log(2,()=>"bkgData = "+JSON.stringify(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="",r=-1;for(let n=0;n<Xt;n++){const a=this.rows[n].getTextString();a&&(r=n+1,e?t.push("Row "+r+": '"+a+"'"):t.push(a.trim()))}return t.length>0&&(e?s="["+t.join(" | ")+"]":s=t.join(`
35
+ `)),s}getTextAndFormat(){return this.rows}}class R0{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 au(s),this.nonDisplayedMemory=new au(s),this.lastOutputScreen=new au(s),this.currRollUpRow=this.displayedMemory.rows[Xt-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[Xt-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,r=["white","green","blue","cyan","red","yellow","magenta"];t.foreground=r[s]}this.logger.log(2,"MIDROW: "+JSON.stringify(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 w0{constructor(e,t,s){this.channels=void 0,this.currentChannel=0,this.cmdHistory=Rk(),this.logger=void 0;const r=this.logger=new xk;this.channels=[null,new R0(e,t,r),new R0(e+1,s,r)]}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 r=t[s]&127,n=t[s+1]&127;let a=!1,o=null;if(r===0&&n===0)continue;this.logger.log(3,()=>"["+Is([t[s],t[s+1]])+"] -> ("+Is([r,n])+")");const l=this.cmdHistory;if(r>=16&&r<=31){if(Ik(r,n,l)){xo(null,null,l),this.logger.log(3,()=>"Repeated command ("+Is([r,n])+") is dropped");continue}xo(r,n,this.cmdHistory),a=this.parseCmd(r,n),a||(a=this.parseMidrow(r,n)),a||(a=this.parsePAC(r,n)),a||(a=this.parseBackgroundAttributes(r,n))}else xo(null,null,l);if(!a&&(o=this.parseChars(r,n),o)){const c=this.currentChannel;c&&c>0?this.channels[c].insertChars(o):this.logger.log(2,"No channel found yet. TEXT-MODE?")}!a&&!o&&this.logger.log(2,()=>"Couldn't parse cleaned data "+Is([r,n])+" orig: "+Is([t[s],t[s+1]]))}}parseCmd(e,t){const s=(e===20||e===28||e===21||e===29)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=33&&t<=35;if(!(s||r))return!1;const n=e===20||e===21||e===23?1:2,a=this.channels[n];return e===20||e===21||e===28||e===29?t===32?a.ccRCL():t===33?a.ccBS():t===34?a.ccAOF():t===35?a.ccAON():t===36?a.ccDER():t===37?a.ccRU(2):t===38?a.ccRU(3):t===39?a.ccRU(4):t===40?a.ccFON():t===41?a.ccRDC():t===42?a.ccTR():t===43?a.ccRTD():t===44?a.ccEDM():t===45?a.ccCR():t===46?a.ccENM():t===47&&a.ccEOC():a.ccTO(t-32),this.currentChannel=n,!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 r=this.channels[s];return r?(r.ccMIDROW(t),this.logger.log(3,()=>"MIDROW ("+Is([e,t])+")"),!0):!1}return!1}parsePAC(e,t){let s;const r=(e>=17&&e<=23||e>=25&&e<=31)&&t>=64&&t<=127,n=(e===16||e===24)&&t>=64&&t<=95;if(!(r||n))return!1;const a=e<=23?1:2;t>=64&&t<=95?s=a===1?yk[e]:_k[e]:s=a===1?Tk[e]:Ak[e];const o=this.channels[a];return o?(o.setPAC(this.interpretPAC(s,t)),this.currentChannel=a,!0):!1}interpretPAC(e,t){let s;const r={color:null,italics:!1,indent:null,underline:!1,row:e};return t>95?s=t-96:s=t-64,r.underline=(s&1)===1,s<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(s/2)]:s<=15?(r.italics=!0,r.color="white"):r.indent=Math.floor((s-16)/2)*4,r}parseChars(e,t){let s,r=null,n=null;if(e>=25?(s=2,n=e-8):(s=1,n=e),n>=17&&n<=19){let a;n===17?a=t+80:n===18?a=t+112:a=t+144,this.logger.log(2,()=>"Special char '"+gE(a)+"' in channel "+s),r=[a]}else e>=32&&e<=127&&(r=t===0?[e]:[e,t]);return r&&this.logger.log(3,()=>"Char codes = "+Is(r).join(",")),r}parseBackgroundAttributes(e,t){const s=(e===16||e===24)&&t>=32&&t<=47,r=(e===23||e===31)&&t>=45&&t<=47;if(!(s||r))return!1;let n;const a={};e===16||e===24?(n=Math.floor((t-32)/2),a.background=Sk[n],t%2===1&&(a.background=a.background+"_semi")):t===45?a.background="transparent":(a.foreground="black",t===47&&(a.underline=!0));const o=e<=23?1:2;return this.channels[o].setBkgData(a),!0}reset(){for(let e=0;e<Object.keys(this.channels).length;e++){const t=this.channels[e];t&&t.reset()}xo(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 xo(i,e,t){t.a=i,t.b=e}function Ik(i,e,t){return t.a===i&&t.b===e}function Rk(){return{a:null,b:null}}class ko{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}}var Am=function(){if(Rn!=null&&Rn.VTTCue)return self.VTTCue;const i=["","lr","rl"],e=["start","middle","end","left","right"];function t(o,l){if(typeof l!="string"||!Array.isArray(o))return!1;const d=l.toLowerCase();return~o.indexOf(d)?d:!1}function s(o){return t(i,o)}function r(o){return t(e,o)}function n(o,...l){let d=1;for(;d<arguments.length;d++){const c=arguments[d];for(const u in c)o[u]=c[u]}return o}function a(o,l,d){const c=this,u={enumerable:!0};c.hasBeenReset=!1;let h="",f=!1,m=o,p=l,g=d,v=null,y="",b=!0,x="auto",_="start",S=50,A="middle",D=50,O="middle";Object.defineProperty(c,"id",n({},u,{get:function(){return h},set:function(L){h=""+L}})),Object.defineProperty(c,"pauseOnExit",n({},u,{get:function(){return f},set:function(L){f=!!L}})),Object.defineProperty(c,"startTime",n({},u,{get:function(){return m},set:function(L){if(typeof L!="number")throw new TypeError("Start time must be set to a number.");m=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"endTime",n({},u,{get:function(){return p},set:function(L){if(typeof L!="number")throw new TypeError("End time must be set to a number.");p=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"text",n({},u,{get:function(){return g},set:function(L){g=""+L,this.hasBeenReset=!0}})),Object.defineProperty(c,"region",n({},u,{get:function(){return v},set:function(L){v=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"vertical",n({},u,{get:function(){return y},set:function(L){const C=s(L);if(C===!1)throw new SyntaxError("An invalid or illegal string was specified.");y=C,this.hasBeenReset=!0}})),Object.defineProperty(c,"snapToLines",n({},u,{get:function(){return b},set:function(L){b=!!L,this.hasBeenReset=!0}})),Object.defineProperty(c,"line",n({},u,{get:function(){return x},set:function(L){if(typeof L!="number"&&L!=="auto")throw new SyntaxError("An invalid number or illegal string was specified.");x=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"lineAlign",n({},u,{get:function(){return _},set:function(L){const C=r(L);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");_=C,this.hasBeenReset=!0}})),Object.defineProperty(c,"position",n({},u,{get:function(){return S},set:function(L){if(L<0||L>100)throw new Error("Position must be between 0 and 100.");S=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"positionAlign",n({},u,{get:function(){return A},set:function(L){const C=r(L);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");A=C,this.hasBeenReset=!0}})),Object.defineProperty(c,"size",n({},u,{get:function(){return D},set:function(L){if(L<0||L>100)throw new Error("Size must be between 0 and 100.");D=L,this.hasBeenReset=!0}})),Object.defineProperty(c,"align",n({},u,{get:function(){return O},set:function(L){const C=r(L);if(!C)throw new SyntaxError("An invalid or illegal string was specified.");O=C,this.hasBeenReset=!0}})),c.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}();class wk{decode(e,t){if(!e)return"";if(typeof e!="string")throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(e))}}function EE(i){function e(s,r,n,a){return(s|0)*3600+(r|0)*60+(n|0)+parseFloat(a||0)}const t=i.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 Ck{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 r=0;r<s.length;++r)if(t===s[r]){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 bE(i,e,t,s){const r=s?i.split(s):[i];for(const n in r){if(typeof r[n]!="string")continue;const a=r[n].split(t);if(a.length!==2)continue;const o=a[0],l=a[1];e(o,l)}}const sh=new Am(0,0,""),Lo=sh.align==="middle"?"middle":"center";function Dk(i,e,t){const s=i;function r(){const o=EE(i);if(o===null)throw new Error("Malformed timestamp: "+s);return i=i.replace(/^[^\sa-zA-Z-]+/,""),o}function n(o,l){const d=new Ck;bE(o,function(h,f){let m;switch(h){case"region":for(let p=t.length-1;p>=0;p--)if(t[p].id===f){d.set(h,t[p].region);break}break;case"vertical":d.alt(h,f,["rl","lr"]);break;case"line":m=f.split(","),d.integer(h,m[0]),d.percent(h,m[0])&&d.set("snapToLines",!1),d.alt(h,m[0],["auto"]),m.length===2&&d.alt("lineAlign",m[1],["start",Lo,"end"]);break;case"position":m=f.split(","),d.percent(h,m[0]),m.length===2&&d.alt("positionAlign",m[1],["start",Lo,"end","line-left","line-right","auto"]);break;case"size":d.percent(h,f);break;case"align":d.alt(h,f,["start",Lo,"end","left","right"]);break}},/:/,/\s/),l.region=d.get("region",null),l.vertical=d.get("vertical","");let c=d.get("line","auto");c==="auto"&&sh.line===-1&&(c=-1),l.line=c,l.lineAlign=d.get("lineAlign","start"),l.snapToLines=d.get("snapToLines",!0),l.size=d.get("size",100),l.align=d.get("align",Lo);let u=d.get("position","auto");u==="auto"&&sh.position===50&&(u=l.align==="start"||l.align==="left"?0:l.align==="end"||l.align==="right"?100:50),l.position=u}function a(){i=i.replace(/^\s+/,"")}if(a(),e.startTime=r(),a(),i.slice(0,3)!=="-->")throw new Error("Malformed time stamp (time stamps must be separated by '-->'): "+s);i=i.slice(3),a(),e.endTime=r(),a(),n(i,e)}function yE(i){return i.replace(/<br(?: \/)?>/gi,`
36
+ `)}class Mk{constructor(){this.state="INITIAL",this.buffer="",this.decoder=new wk,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 n=t.buffer,a=0;for(n=yE(n);a<n.length&&n[a]!=="\r"&&n[a]!==`
37
37
  `;)++a;const o=n.slice(0,a);return n[a]==="\r"&&++a,n[a]===`
38
- `&&++a,t.buffer=n.slice(a),o}function r(n){bE(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=s();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=s(),t.state){case"HEADER":/:/.test(n)?r(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Am(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Ck(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!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+=`
38
+ `&&++a,t.buffer=n.slice(a),o}function r(n){bE(n,function(a,o){},/:/)}try{let n="";if(t.state==="INITIAL"){if(!/\r\n|\n/.test(t.buffer))return this;n=s();const o=n.match(/^()?WEBVTT([ \t].*)?$/);if(!(o!=null&&o[0]))throw new Error("Malformed WebVTT signature.");t.state="HEADER"}let a=!1;for(;t.buffer;){if(!/\r\n|\n/.test(t.buffer))return this;switch(a?a=!1:n=s(),t.state){case"HEADER":/:/.test(n)?r(n):n||(t.state="ID");continue;case"NOTE":n||(t.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(n)){t.state="NOTE";break}if(!n)continue;if(t.cue=new Am(0,0,""),t.state="CUE",n.indexOf("-->")===-1){t.cue.id=n;continue}case"CUE":if(!t.cue){t.state="BADCUE";continue}try{Dk(n,t.cue,t.regionList)}catch{t.cue=null,t.state="BADCUE";continue}t.state="CUETEXT";continue;case"CUETEXT":{const o=n.indexOf("-->")!==-1;if(!n||o&&(a=!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+=`
39
39
  `),t.cue.text+=n}continue;case"BADCUE":n||(t.state="ID")}}}catch{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+=`
40
40
 
41
- `,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 Mk=/\r\n|\n\r|\n|\r/g,ou=function(e,t,s=0){return e.slice(s,s+t.length)===t},Ok=function(e){let t=parseInt(e.slice(-3));const s=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!j(t)||!j(s)||!j(r)||!j(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*s,t+=60*1e3*r,t+=60*60*1e3*n,t},lu=function(e){let t=5381,s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return(t>>>0).toString()};function Sm(i,e,t){return lu(i.toString())+lu(e.toString())+lu(t)}const Pk=function(e,t,s){let r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=r.start-n.start,r.new=!1,r=n,n=e[r.prevCC]}e.presentationOffset=s};function Nk(i,e,t,s,r,n,a){const o=new Dk,l=Oi(new Uint8Array(i)).trim().replace(Mk,`
41
+ `,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 Ok=/\r\n|\n\r|\n|\r/g,ou=function(e,t,s=0){return e.slice(s,s+t.length)===t},Pk=function(e){let t=parseInt(e.slice(-3));const s=parseInt(e.slice(-6,-4)),r=parseInt(e.slice(-9,-7)),n=e.length>9?parseInt(e.substring(0,e.indexOf(":"))):0;if(!j(t)||!j(s)||!j(r)||!j(n))throw Error(`Malformed X-TIMESTAMP-MAP: Local:${e}`);return t+=1e3*s,t+=60*1e3*r,t+=60*60*1e3*n,t},lu=function(e){let t=5381,s=e.length;for(;s;)t=t*33^e.charCodeAt(--s);return(t>>>0).toString()};function Sm(i,e,t){return lu(i.toString())+lu(e.toString())+lu(t)}const Nk=function(e,t,s){let r=e[t],n=e[r.prevCC];if(!n||!n.new&&r.new){e.ccOffset=e.presentationOffset=r.start,r.new=!1;return}for(;(a=n)!=null&&a.new;){var a;e.ccOffset+=r.start-n.start,r.new=!1,r=n,n=e[r.prevCC]}e.presentationOffset=s};function Uk(i,e,t,s,r,n,a){const o=new Mk,l=Oi(new Uint8Array(i)).trim().replace(Ok,`
42
42
  `).split(`
43
- `),d=[],c=e?Jx(e.baseTime,e.timescale):0;let u="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){const v=t[s];let y=t.ccOffset;const b=(h-c)/9e4;if(v!=null&&v.new&&(f!==void 0?y=t.ccOffset=v.start:Pk(t,s,b)),b){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}y=b-t.presentationOffset}const x=g.endTime-g.startTime,_=Kt((g.startTime+y-f)*9e4,r*9e4)/9e4;g.startTime=Math.max(_,0),g.endTime=Math.max(_+x,0);const S=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(S)),g.id||(g.id=Sm(g.startTime,g.endTime,S)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(ou(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(v=>{ou(v,"LOCAL:")?u=v.slice(6):ou(v,"MPEGTS:")&&(h=parseInt(v.slice(7)))});try{f=Ok(u)/1e3}catch(v){m=v}return}else g===""&&(p=!1);o.parse(g+`
44
- `)}),o.flush()}const du="stpp.ttml.im1t",TE=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,_E=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Uk={left:"start",center:"center",right:"end",start:"start",end:"end"};function C0(i,e,t,s){const r=le(new Uint8Array(i),["mdat"]);if(r.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(o=>Oi(o)),a=Zx(e.baseTime,1,e.timescale);try{n.forEach(o=>t(Fk(o,a)))}catch(o){s(o)}}function Fk(i,e){const r=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=r.getAttribute(`ttp:${h}`)||n[h],u),{}),o=r.getAttribute("xml:space")!=="preserve",l=D0(cu(r,"styling","style")),d=D0(cu(r,"layout","region")),c=cu(r,"body","[begin]");return[].map.call(c,u=>{const h=AE(u,o);if(!h||!u.hasAttribute("begin"))return null;const f=hu(u.getAttribute("begin"),a),m=hu(u.getAttribute("dur"),a);let p=hu(u.getAttribute("end"),a);if(f===null)throw M0(u);if(p===null){if(m===null)throw M0(u);p=f+m}const g=new Am(f-e,p-e,h);g.id=Sm(g.startTime,g.endTime,g.text);const v=d[u.getAttribute("region")],y=l[u.getAttribute("style")],b=$k(v,y,l),{textAlign:x}=b;if(x){const _=Uk[x];_&&(g.lineAlign=_),g.align=x}return Ke(g,b),g}).filter(u=>u!==null)}function cu(i,e,t){const s=i.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function D0(i){return i.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function AE(i,e){return[].slice.call(i.childNodes).reduce((t,s,r)=>{var n;return s.nodeName==="br"&&r?t+`
45
- `:(n=s.childNodes)!=null&&n.length?AE(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function $k(i,e,t){const s="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,l)=>{const d=uu(e,s,l)||uu(i,s,l)||uu(r,s,l);return d&&(o[l]=d),o},{})}function uu(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function M0(i){return new Error(`Could not parse ttml timestamp ${i}`)}function hu(i,e){if(!i)return null;let t=EE(i);return t===null&&(TE.test(i)?t=Bk(i,e):_E.test(i)&&(t=Gk(i,e))),t}function Bk(i,e){const t=TE.exec(i),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 Gk(i,e){const t=_E.exec(i),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 Hk{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=P0(),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(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new ko(this,"textTrack1"),t=new ko(this,"textTrack2"),s=new ko(this,"textTrack3"),r=new ko(this,"textTrack4");this.cea608Parser1=new w0(1,e,t),this.cea608Parser2=new w0(3,s,r)}}addCues(e,t,s,r,n){let a=!1;for(let o=n.length;o--;){const l=n[o],d=Wk(l[0],l[1],t,s);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],s),a=!0,d/(s-t)>.5))return}if(a||n.push([t,s]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,s,r)}else{const o=this.Cues.newCue(null,t,s,r);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:n}){const{unparsedVttFrags:a}=this;s==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(E.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:s}=this;if(s)for(let r=0;r<s.textTracks.length;r++){const n=s.textTracks[r];if(O0(n,{name:e,lang:t,attrs:{}}))return n}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:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)s[e]=o,fn(s[e]),Wv(s[e],r);else{const l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,s[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,r={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,s){const r=this.media;if(r)return r.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{fn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=P0(),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++)fn(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],r=s.some(n=>n.textCodec===du);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(pE(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const a=this.media,o=a?tl(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&O0(o[h],l)){u=o[h],o[h]=null;break}u&&(c=u)}if(c)fn(c);else{const u=SE(l);c=this.createTextTrack(u,l.name,l.lang),c&&(c.mode="disabled")}c&&this.textTracks.push(c)}),o!=null&&o.length){const l=o.filter(d=>d!==null).map(d=>d.label);l.length&&R.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const r=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!r)return;const n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=s.name,s.lang&&(a.languageCode=s.lang),a.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===te.MAIN){var s,r;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,c=(s=(r=t.part)==null?void 0:r.index)!=null?s:-1;n&&a&&(d!==o+1||d===o&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){const{frag:s,payload:r}=t;if(s.type===te.SUBTITLE)if(r.byteLength){const n=s.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[s.level],l=this.vttCCs;l[s.cc]||(l[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),o&&o.textCodec===du?this._parseIMSC1(s,r):this._parseVTTs(t)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;C0(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),s.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{R.log(`Failed to parse IMSC1: ${r}`),s.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:s,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[s.cc]&&o===-1){a.push(e);return}const l=this.hls,d=(t=s.initSegment)!=null&&t.data?Vt(s.initSegment.data,new Uint8Array(r)):r;Nk(d,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,c=>{this._appendCues(c,s.level),l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},c=>{const u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(s,r),R.log(`Failed to parse VTT cue: ${c}`),!(u&&o>s.cc)&&l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:c})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||C0(t,this.initPTS[e.cc],()=>{s.textCodec=du,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>Kv(r,n))}else{const r=this.tracks[t];if(!r)return;const n=r.default?"default":"subtitles"+t;s.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===te.SUBTITLE&&this.onFragLoaded(E.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:s,cea608Parser2:r}=this;if(!this.enabled||!s||!r)return;const{frag:n,samples:a}=t;if(!(n.type===te.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const d=this.extractCea608Data(l);s.addData(a[o].pts,d[0]),r.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:r,type:n}){const{media:a}=this;if(!(!a||a.currentTime<s)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>Xu(o[l],t,s))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>Xu(o[l],t,r))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let r=2;for(let n=0;n<s;n++){const a=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){const c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}}function SE(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function O0(i,e){return!!i&&i.kind===SE(e)&&ih(e,i)}function Wk(i,e,t,s){return Math.min(e,s)-Math.max(i,t)}function P0(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class xm{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(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.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&&j(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}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&&R.log(`Setting autoLevelCapping to ${s}: ${e[s].height}p@${e[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=s,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((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,xm.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{}return e}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 r=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,s);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){n=o;break}}return n}}class Kk{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(E.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,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 r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,s){const r=performance.now();if(t){if(this.lastTime){const n=r-this.lastTime,a=s-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:s}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;R.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=r,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)}}const Io="[eme]";class bn{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=bn.CDMCleanupPromise?[bn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=R.debug.bind(R,Io),this.log=R.log.bind(R,Io),this.warn=R.warn.bind(R,Io),this.error=R.error.bind(R,Io),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===we.WIDEVINE&&s)return s;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t[e];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,s=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(s),n=t.map(a=>a.videoCodec).filter(s);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=d=>{const c=d.shift();this.getMediaKeysPromise(c,r,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof $t?o(u):o(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${s}`;return wv===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return s(e,t)}getMediaKeysPromise(e,t,s){const r=QA(e,t,s,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(e,r);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log(`Creating key-system session "${t}" keyId: ${Si.hexDump(e.keyId||[])}`);const r=s.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(s,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Si.hexDump(e.keyId)}updateKeySession(e,t){var s;const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${Si.hexDump(((s=e.decryptdata)==null?void 0:s.keyId)||[])}
46
- } (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,s)=>{const r=jc(this.config),n=e.map(Hp).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=Wp(a);o?t(o):s(new Error(`Unable to find format for key-system "${a}"`))}).catch(s)})}loadKey(e){const t=e.keyInfo.decryptdata,s=this.getKeyIdString(t),r=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[s];return n||(n=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof $t?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=Hp(e.keyFormat),n=r?[r]:jc(this.config);return this.attemptKeySystemAccess(n)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=jc(this.config)),e.length===0)throw new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:s}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),s===null)return;let r,n;if(t==="sinf"&&this.config.drmSystems[we.FAIRPLAY]){const c=je(new Uint8Array(s));try{const u=cm(JSON.parse(c).sinf),h=Fv(new Uint8Array(u));if(!h)return;r=h.subarray(8,24),n=we.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const c=_S(s);if(c===null)return;c.version===0&&c.systemId===Rv.WIDEVINE&&c.data&&(r=c.data.subarray(8,24)),n=XA(c.systemId)}if(!n||!r)return;const a=Si.hexDump(r),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let d=o[a];for(let c=0;c<l.length;c++){const u=l[c],h=u.decryptdata;if(h.pssh||!h.keyId)continue;const f=Si.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(s),h.keyId=r,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,s,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();const f=new ja("ISO-23001-7",a,(h=Wp(c))!=null?h:"");return f.pssh=new Uint8Array(s),f.keyId=r,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();const m=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(m,t,s,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>s.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const m=o.call(this.hls,t,s,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,s=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${d} (init data type: ${t} length: ${s?s.byteLength:null})`);const c=new _m,u=e._onmessage=m=>{const p=e.mediaKeysSession;if(!p){c.emit("error",new Error("invalid state"));return}const{messageType:g,message:v}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${v.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,v).catch(y=>{this.handleError(y),c.emit("error",y)}):g==="license-release"?e.keySystem===we.FAIRPLAY&&(this.updateKeySession(e,ju("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const g=e.keyStatus;c.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",u),e.mediaKeysSession.addEventListener("keystatuseschange",h);const f=new Promise((m,p)=>{c.on("error",p),c.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,s).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw c.removeAllListeners(),this.removeSession(e),m}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,s)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Si.hexDump("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))} session keyId: ${Si.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:dt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};r.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,n)=>{e.setServerCertificate(s).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${s==null?void 0:s.byteLength}) on "${t}"`),r(e)}).catch(a=>{n(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.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 r=new DOMParser().parseFromString(s,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let u=0,h=n.length;u<h;u++){var a,o;c=n[u];const f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const l=r.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return ju(atob(d))}setupLicenseXHR(e,t,s,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,s,r)}).catch(a=>{if(!s.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,s,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(c){this.error(c)}r(l)}else{const l=s.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(r,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==we.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ja.clearKeyUriToKeyIdMap();const s=t.length;bn.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),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);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}bn.CDMCleanupPromise=void 0;class $t 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}}var Et;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(Et||(Et={}));var rh;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(rh||(rh={}));var sr;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(sr||(sr={}));const Vk={[sr.OBJECT]:["br","d","ot","tb"],[sr.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[sr.SESSION]:["cid","pr","sf","sid","st","v"],[sr.STATUS]:["bs","rtp"]};class Dn{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(s=>s instanceof Dn?s:new Dn(s))),this.value=e,this.params=t}}class xE{constructor(e){this.description=void 0,this.description=e}}const qk="Dict";function Yk(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function jk(i,e,t,s){return new Error(`failed to ${i} "${Yk(e)}" as ${t}`,{cause:s})}const N0="Bare Item",zk="Boolean",Xk="Byte Sequence",Qk="Decimal",Zk="Integer";function Jk(i){return i<-999999999999999||999999999999999<i}const eL=/[\x00-\x1f\x7f]+/,tL="Token",iL="Key";function Pi(i,e,t){return jk("serialize",i,e,t)}function sL(i){if(typeof i!="boolean")throw Pi(i,zk);return i?"?1":"?0"}function rL(i){return btoa(String.fromCharCode(...i))}function nL(i){if(ArrayBuffer.isView(i)===!1)throw Pi(i,Xk);return`:${rL(i)}:`}function kE(i){if(Jk(i))throw Pi(i,Zk);return i.toString()}function aL(i){return`@${kE(i.getTime()/1e3)}`}function LE(i,e){if(i<0)return-LE(-i,e);const t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){const r=Math.floor(i*t);return(r%2===0?r:r+1)/t}else return Math.round(i*t)/t}function oL(i){const e=LE(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Pi(i,Qk);const t=e.toString();return t.includes(".")?t:`${t}.0`}const lL="String";function dL(i){if(eL.test(i))throw Pi(i,lL);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function cL(i){return i.description||i.toString().slice(7,-1)}function U0(i){const e=cL(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Pi(e,tL);return e}function nh(i){switch(typeof i){case"number":if(!j(i))throw Pi(i,N0);return Number.isInteger(i)?kE(i):oL(i);case"string":return dL(i);case"symbol":return U0(i);case"boolean":return sL(i);case"object":if(i instanceof Date)return aL(i);if(i instanceof Uint8Array)return nL(i);if(i instanceof xE)return U0(i);default:throw Pi(i,N0)}}function ah(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Pi(i,iL);return i}function km(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${ah(e)}`:`;${ah(e)}=${nh(t)}`).join("")}function IE(i){return i instanceof Dn?`${nh(i.value)}${km(i.params)}`:nh(i)}function uL(i){return`(${i.value.map(IE).join(" ")})${km(i.params)}`}function hL(i,e={whitespace:!0}){if(typeof i!="object")throw Pi(i,qk);const t=i instanceof Map?i.entries():Object.entries(i),s=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof Dn||(n=new Dn(n));let a=ah(r);return n.value===!0?a+=km(n.params):(a+="=",Array.isArray(n.value)?a+=uL(n):a+=IE(n)),a}).join(`,${s}`)}function fL(i,e){return hL(i,e)}const mL=i=>i==="ot"||i==="sf"||i==="st",pL=i=>typeof i=="number"?j(i):i!=null&&i!==""&&i!==!1;function gL(i,e){const t=new URL(i),s=new URL(e);if(t.origin!==s.origin)return i;const r=t.pathname.split("/").slice(1),n=s.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")}function vL(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}const ol=i=>Math.round(i),EL=(i,e)=>(e!=null&&e.baseUrl&&(i=gL(i,e.baseUrl)),encodeURIComponent(i)),Ro=i=>ol(i/100)*100,bL={br:ol,d:ol,bl:Ro,dl:Ro,mtp:Ro,nor:EL,rtp:Ro,tb:ol};function yL(i,e){const t={};if(i==null||typeof i!="object")return t;const s=Object.keys(i).sort(),r=Ke({},bL,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return s.forEach(a=>{if(n!=null&&n(a))return;let o=i[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||pL(o)&&(mL(a)&&typeof o=="string"&&(o=new xE(o)),t[a]=o))}),t}function RE(i,e={}){return i?fL(yL(i,e),Ke({whitespace:!1},e)):""}function TL(i,e={}){if(!i)return{};const t=Object.entries(i),s=Object.entries(Vk).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((n,a)=>{var o,l;const[d,c]=a,u=((o=s.find(h=>h[1].includes(d)))==null?void 0:o[0])||sr.REQUEST;return(l=n[u])!=null||(n[u]={}),n[u][d]=c,n},{});return Object.entries(r).reduce((n,[a,o])=>(n[a]=RE(o,e),n),{})}function _L(i,e,t){return Ke(i,TL(e,t))}const AL="CMCD";function SL(i,e={}){if(!i)return"";const t=RE(i,e);return`${AL}=${encodeURIComponent(t)}`}const F0=/CMCD=[^&#]+/;function xL(i,e,t){const s=SL(e,t);if(!s)return i;if(F0.test(i))return i.replace(F0,s);const r=i.includes("?")?"&":"?";return`${i}${r}${s}`}class kL{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=r=>{try{this.apply(r,{ot:Et.MANIFEST,su:!this.initialized})}catch(n){R.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const n=r.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Et.VIDEO||o===Et.AUDIO||o==Et.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(n){R.warn("Could not generate segment CMCD data.",n)}},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||vL(),this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=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,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:rh.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ke(t,this.createData());const s=t.ot===Et.INIT||t.ot===Et.VIDEO||t.ot===Et.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((n,a)=>(r.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),_L(e.headers,t)):e.url=xL(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Et.TIMED_TEXT;if(e.sn==="initSegment")return Et.INIT;if(t==="audio")return Et.AUDIO;if(t==="main")return this.hls.audioTracks.length?Et.VIDEO:Et.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===Et.AUDIO)s=r.audioTracks;else{const n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;s=r.levels.slice(0,a)}for(const n of s)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,s=e===Et.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:Le.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(n){this.loader=void 0,this.loader=new s(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new s(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}}const LL=3e5;class IL{constructor(e){this.hls=void 0,this.log=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.log=R.log.bind(R,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))}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)===mt.SendAlternateToPenaltyBox&&s.flags===Yt.MoveAllAlternatesMatchingHost){const r=this.levels;let n=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:d}=t.context;o&&r?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),s.resolved=this.pathwayId!==a),s.resolved||R.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(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 ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(n=>{r-s[n]>LL&&delete s[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in s)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,jv(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,s){const r=this.getLevelsForPathway(s).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===pe.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===pe.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;const d=this.getLevelsForPathway(o).map(c=>{const u=new Oe(c.attrs);u["PATHWAY-ID"]=a;const h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(s[u.AUDIO]=h,u.AUDIO=h),f&&(r[u.SUBTITLES]=f,u.SUBTITLES=f);const m=wE(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new wn({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let g=1;g<c.audioGroups.length;g++)p.addGroupId("audio",`${c.audioGroups[g]}_clone_${a}`);if(c.subtitleGroups)for(let g=1;g<c.subtitleGroups.length;g++)p.addGroupId("text",`${c.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),$0(this.audioTracks,s,l,a),$0(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+c)}const n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);const m=c.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":v}=m;if(p)try{this.uri=new self.URL(p,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);const y={steeringManifest:m,url:r.toString()};this.hls.trigger(E.STEERING_MANIFEST_LOADED,y),v&&this.updatePathwayPriority(v)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){const p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){const g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,m)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const r=(s=this.hls)==null?void 0:s.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function $0(i,e,t,s){i&&Object.keys(e).forEach(r=>{const n=i.filter(a=>a.groupId===r).map(a=>{const o=Ke({},a);return o.details=void 0,o.attrs=new Oe(o.attrs),o.url=o.attrs.URI=wE(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=s,o});i.push(...n)})}function wE(i,e,t,s){const{HOST:r,PARAMS:n,[t]:a}=s;let o;e&&(o=a==null?void 0:a[e],o&&(i=o));const l=new self.URL(i);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}const RL=/^age:\s*[\d.]+\s*$/im;class CE{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 kc,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,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return n(s,t.url)}).catch(a=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),n(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(a=>{this.callbacks.onError({code:s.status,text:a.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[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=n&&j(n)?n:a,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 r=t.readyState,n=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){s.loading.end=Math.max(self.performance.now(),s.loading.first);const l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(s.loaded=s.total=d,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first),!this.callbacks)return;const c=this.callbacks.onProgress;if(c&&c(s,e,l,t),!this.callbacks)return;const u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,s,e,t)}else{const l=n.loadPolicy.errorRetry,d=s.retry,c={url:e.url,data:void 0,code:a};Wd(l,d,!1,c)?this.retry(l):(R.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,s))}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Wd(e,t,!0))this.retry(e);else{var s;R.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=fm(e,s.retry),s.retry++,R.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${s.retry}/${e.maxNumRetry} in ${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&&RL.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function wL(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const CL=/(\d+)-(\d+)\/(\d+)/;class B0{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||PL,this.controller=new self.AbortController,this.stats=new kc}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 r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=DL(e,this.controller.signal),a=s.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&j(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;const h=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},c-(h-r.loading.start)),!u.ok){const{status:f,statusText:m}=u;throw new NL(m||"fetch, bad network response",f,u)}return r.loading.first=h,r.total=OL(u.headers)||r.total,a&&j(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,a):o?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{const h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=u[l];f&&(r.loaded=r.total=f);const m={url:h.url,data:u,code:h.status};a&&!j(t.highWaterMark)&&a(r,e,u,h),s.onSuccess(m,r,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const h=u&&u.code||0,f=u?u.message:null;s.onError({code:h,text:f},e,u?u.details:null,r)})}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,r=0,n){const a=new Zv,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,s,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const c=d.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,s,a.flush(),e)):n(t,s,c,e),l()}).catch(()=>Promise.reject());return l()}}function DL(i,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ke({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function ML(i){const e=CL.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function OL(i){const e=i.get("Content-Range");if(e){const s=ML(e);if(j(s))return s}const t=i.get("Content-Length");if(t)return parseInt(t)}function PL(i,e){return new self.Request(i.url,e)}class NL extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const UL=/\s/,FL={newCue(i,e,t,s){const r=[];let n,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<s.rows.length;h++)if(n=s.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let p=0;p<n.chars.length;p++)UL.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=yE(d.trim()),m=Sm(e,t,f);i!=null&&(u=i.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return i&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Kv(i,h))),r}},$L={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},DE=dt(dt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,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,loader:CE,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:hx,bufferController:gk,capLevelController:xm,errorController:ex,fpsController:Kk,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:wv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:$L},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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},BL()),{},{subtitleStreamController:hk,subtitleTrackController:mk,timelineController:Hk,audioStreamController:ck,audioTrackController:uk,emeController:bn,cmcdController:kL,contentSteeringController:IL});function BL(){return{cueHandler:FL,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 GL(i,e){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 t=oh(i),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(d=>{const c=`${n}Loading${d}`,u=e[c];if(u!==void 0&&o){l.push(c);const h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&R.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),dt(dt({},t),e)}function oh(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(oh):Object.keys(i).reduce((e,t)=>(e[t]=oh(i[t]),e),{}):i}function HL(i){const e=i.loader;e!==B0&&e!==CE?(R.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):wL()&&(i.loader=B0,i.progressive=!0,i.enableSoftwareAES=!0,R.log("[config]: Progressive streaming enabled, using FetchLoader"))}let fu;class WL extends mm{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(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.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,r=[],n={},a={};let o=!1,l=!1,d=!1;t.levels.forEach(c=>{var u,h;const f=c.attrs;let{audioCodec:m,videoCodec:p}=c;((u=m)==null?void 0:u.indexOf("mp4a.40.34"))!==-1&&(fu||(fu=/chrome|firefox/i.test(navigator.userAgent)),fu&&(c.audioCodec=m=void 0)),m&&(c.audioCodec=m=Bd(m,s)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=c.videoCodec=RS(p));const{width:g,height:v,unknownCodecs:y}=c;if(o||(o=!!(g&&v)),l||(l=!!p),d||(d=!!m),y!=null&&y.length||m&&!Zc(m,"audio",s)||p&&!Zc(p,"video",s))return;const{CODECS:b,"FRAME-RATE":x,"HDCP-LEVEL":_,"PATHWAY-ID":S,RESOLUTION:A,"VIDEO-RANGE":D}=f,L=`${`${S||"."}-`}${c.bitrate}-${A}-${x}-${b}-${D}-${_}`;if(n[L])if(n[L].uri!==c.url&&!c.attrs["PATHWAY-ID"]){const C=a[L]+=1;c.attrs["PATHWAY-ID"]=new Array(C+1).join(".");const H=new wn(c);n[L]=H,r.push(H)}else n[L].addGroupId("audio",f.AUDIO),n[L].addGroupId("text",f.SUBTITLES);else{const C=new wn(c);n[L]=C,a[L]=1,r.push(C)}}),this.filterAndSortMediaOptions(r,t,o,l,d)}filterAndSortMediaOptions(e,t,s,r,n){let a=[],o=[],l=e;if((s||r)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:v})=>(!!m||!!(g&&v))&&HS(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||Zc(p.audioCodec,"audio",m)),G0(a)}t.subtitles&&(o=t.subtitles,G0(o));const d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return Gd.indexOf(m.videoRange)-Gd.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){const g=jp(m.videoCodec),v=jp(p.videoCodec);if(g!==v)return v-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){const g=$d(m.codecSet),v=$d(p.codecSet);if(g!==v)return v-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){c=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===c){var u;this._firstLevel=m;const p=c.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((u=this.hls.userConfig)==null?void 0:u.abrEwmaDefaultEstimate)===void 0){const v=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);v>g&&g===DE.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}const h=n&&!r,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(E.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}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(E.ERROR,{type:se.OTHER_ERROR,details:M.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,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,s===e&&a.details&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${s}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,l);const d=a.details;if(!d||d.live){const c=this.switchParams(a.uri,r==null?void 0:r.details,d);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}onError(e,t){t.fatal||!t.context||t.context.type===pe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===te.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(n=>!!s[n]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:n}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(s=t.deliveryDirectives)!=null&&s.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){let r=s.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const n=s.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${r}`),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:r,level:t,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||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;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(a=>a.level=-1)),!1));jv(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(E.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(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function G0(i){const e={};i.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}class KL{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[s].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=M.KEY_LOAD_ERROR,s,r,n){return new ji({type:se.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:s,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:r}=e;for(let n=0;n<t.length;n++){const a=t[n];if(r<=a.cc&&(s==="initSegment"||a.sn==="initSegment"||s<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var s,r;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,d))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((s=o)!=null&&s.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(s);if(r)return(e.keyLoadPromise=r.then(n=>(e.mediaKeySessionContext=n,s))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,n=new r(s);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=s.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{const{frag:g,keyInfo:v,url:y}=m;if(!g.decryptdata||v!==this.keyUriToKeyInfo[y])return o(this.createKeyLoadError(g,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));v.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,v.loader=null,a({frag:g,keyInfo:v})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,dt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,c,u)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,n=s.loader;t.keyLoader===n&&(t.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}function ME(){return self.SourceBuffer||self.WebKitSourceBuffer}function OE(){if(!_r())return!1;const e=ME();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function VL(){if(!OE())return!1;const i=_r();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(za(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(za(e,"audio"))))}function qL(){var i;const e=ME();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}const YL=250,ll=2,jL=.1,zL=.05;class XL{constructor(e,t,s,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=s,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:s,media:r,stalled:n}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){const g=self.performance.now()-n;R.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!Le.getBuffered(r).length){this.nudgeRetry=0;return}const c=Le.bufferInfo(r,a,0),u=c.nextStart||0;if(o){const g=c.len>ll,v=!u||t&&t.start<=a||u-a>ll&&!this.fragmentTracker.getPartialFragment(a);if(g||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(c.len>0)&&!u)return;const v=Math.max(u,c.start||0)-a,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,x=(y==null||(h=y.details)==null?void 0:h.live)?y.details.targetduration*2:ll,_=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=x||_)){r.paused||this._trySkipBufferHole(_);return}}const f=self.performance.now();if(n===null){this.stalled=f;return}const m=f-n;if(!o&&m>=YL&&(this._reportStall(c),!this.media))return;const p=Le.bufferInfo(r,a,s.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){const{config:s,fragmentTracker:r,media:n}=this;if(n===null)return;const a=n.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>s.maxBufferHole||e.nextStart&&e.nextStart-a<s.maxBufferHole)&&t>s.highBufferWatchdogPeriod*1e3&&(R.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:s,stallReported:r}=this;if(!r&&s){this.stallReported=!0;const n=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${JSON.stringify(e)})`);R.warn(n.message),t.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:s,media:r}=this;if(r===null)return 0;const n=r.currentTime,a=Le.bufferInfo(r,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&r.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(n===0){const m=h.getAppendedFrag(0,te.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||h.getAppendedFrag(n,te.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){const v=h.getPartialFragment(g);if(v)g+=v.duration;else{p=!0;break}}if(p)return 0}}}const u=Math.max(o+zL,n+jL);if(R.warn(`skipping hole, adjusting currentTime from ${n} to ${u}`),this.moved=!0,this.stalled=null,r.currentTime=u,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${u}`);s.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:s,nudgeRetry:r}=this;if(s===null)return;const n=s.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=n+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);R.warn(o.message),s.currentTime=a,t.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);R.error(a.message),t.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const QL=100;class ZL extends vm{constructor(e,t,s){super(e,t,s,"[stream-controller]",te.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.ERROR,this.onError,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.ERROR,this.onError,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:s}=this;if(this.stopLoad(),this.setInterval(QL),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{const{levels:t,level:s}=this,r=t==null?void 0:t[s],n=r==null?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),s=this.retryDate;if(!s||t>=s||(e=this.media)!=null&&e.seeking){const{levels:r,level:n}=this,a=r==null?void 0:r[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=e.nextLoadLevel;if(!(s!=null&&s[n]))return;const a=s[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const p={};this.altAudio&&(p.type="video"),this.hls.trigger(E.BUFFER_EOS,p),this.state=N.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}const c=o.len,u=this.getMaxBufferLength(a.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,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==rt.OK){var m;const g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,v=d.fragments[g-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 g=this.audioOnly&&!this.altAudio?be.AUDIO:be.VIDEO,v=(g===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,g,te.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,te.MAIN,u)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===rt.NOT_LOADED||r===rt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,s)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,te.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 r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?s=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:s=0}else s=0;const a=this.getBufferedFrag(t.currentTime+s);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(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 N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new XL(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;j(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn(`Main forward buffer length on "seeked" event ${s?s.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let s=!1,r=!1;t.levels.forEach(n=>{const a=n.audioCodec;a&&(s=s||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&r&&!qL(),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!==N.IDLE)return;const r=s[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r}=this,n=t.level,a=t.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=r[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(s=l.details)!=null&&s.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(E.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const o=a[s.level],l=o.details;if(!l){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=s.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new mE(this.hls,te.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,p=m!==-1,g=new pm(s.level,s.sn,s.stats.chunkCount,n.byteLength,m,p),v=this.initPTS[s.cc];f.push(n,u,h,d,s,r,l.totalduration,c,g,v)}onAudioTrackSwitching(e,t){const s=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;s&&(n.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(E.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=t.id,r=!!this.hls.audioTracks[s].url;if(r){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,n,a=!1;for(const o in s){const l=s[o];if(l.id==="main"){if(n=o,r=l,o==="video"){const d=s[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s&&s.type!==te.MAIN)return;if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}const n=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.MAIN,t);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===pe.LEVEL&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Le.getBuffered(e).length){const s=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,s)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==be.AUDIO||this.audioOnly&&!this.altAudio){const s=(t===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,te.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),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 ${s}, already seeking at ${t}`);return}const r=Le.getBuffered(e),a=(r.length?r.start(0):0)-s;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),s+=a,this.startPosition=s),this.log(`seek to target start position ${s} from current time ${t}`),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:r}=this;if(!s||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(E.FRAG_LOADED,s),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const s="main",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:c}=o,{video:u,text:h,id3:f,initSegment:m}=n,{details:p}=c,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){const b=l.initSegment||l;this._bufferInitSegment(c,m.tracks,b,a),r.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:s,tracks:m.tracks})}const v=m.initPTS,y=m.timescale;j(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:y},r.trigger(E.INIT_PTS_FOUND,{frag:l,id:s,initPTS:v,timescale:y}))}if(u&&p&&l.sn!=="initSegment"){const v=p.fragments[l.sn-1-p.startSN],y=l.sn===p.startSN,b=!v||l.cc>v.cc;if(n.independent!==!1){const{startPTS:x,endPTS:_,startDTS:S,endDTS:A}=u;if(d)d.elementaryStreams[u.type]={startPTS:x,endPTS:_,startDTS:S,endDTS:A};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!b&&(this.couldBacktrack=!0),u.dropped&&u.independent){const D=this.getMainFwdBufferInfo(),O=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,L=u.firstKeyFramePTS?u.firstKeyFramePTS:x;if(!y&&O<L-this.config.maxBufferHole&&!b){this.backtrack(l);return}else b&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,_,l.start,A,!0)}else y&&x>ll&&(l.gap=!0);l.setElementaryStreamInfo(u.type,x,_,S,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a,y||b)}else if(y||b)l.gap=!0;else{this.backtrack(l);return}}if(g){const{startPTS:v,endPTS:y,startDTS:b,endDTS:x}=g;d&&(d.elementaryStreams[be.AUDIO]={startPTS:v,endPTS:y,startDTS:b,endDTS:x}),l.setElementaryStreamInfo(be.AUDIO,v,y,b,x),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){const v={id:s,frag:l,details:p,samples:f.samples};r.trigger(E.FRAG_PARSING_METADATA,v)}if(p&&h){const v={id:s,frag:l,details:p,samples:h.samples};r.trigger(E.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,s,r){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec;const d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const c=n.metadata;c&&"channelCount"in c&&(c.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(E.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(E.BUFFER_APPENDING,{type:l,data:c,frag:s,part:null,chunkMeta:r,parent:s.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,te.MAIN)}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=N.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(Le.isBuffered(e,s)?t=this.getAppendedFrag(s):Le.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(E.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(E.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,s=this.currentFrag;if(s&&j(t)&&j(s.programDateTime)){const r=s.programDateTime+(t-s.start)*1e3;return new Date(r)}}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 rr{static get version(){return"1.5.11"}static isMSESupported(){return OE()}static isSupported(){return VL()}static getMediaSource(){return _r()}static get Events(){return E}static get ErrorTypes(){return se}static get ErrorDetails(){return M}static get DefaultConfig(){return rr.defaultConfig?rr.defaultConfig:DE}static set DefaultConfig(e){rr.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new _m,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,BA(e.debug||!1,"Hls instance");const t=this.config=GL(rr.DefaultConfig,e);this.userConfig=e,t.progressive&&HL(t);const{abrController:s,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new s(this),c=this.bufferController=new r(this),u=this.capLevelController=new n(this),h=new o(this),f=new OS(this),m=new $S(this),p=t.contentSteeringController,g=p?new p(this):null,v=this.levelController=new WL(this,g),y=new mx(this),b=new KL(this.config),x=this.streamController=new ZL(this,y,b);u.setStreamController(x),h.setStreamController(x);const _=[f,v,x];g&&_.splice(1,0,g),this.networkControllers=_;const S=[d,c,u,h,m,y];this.audioTrackController=this.createController(t.audioTrackController,_);const A=t.audioStreamController;A&&_.push(new A(this,y,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,_);const D=t.subtitleStreamController;D&&_.push(new D(this,y,b)),this.createController(t.timelineController,S),b.emeController=this.emeController=this.createController(t.emeController,S),this.cmcdController=this.createController(t.cmcdController,S),this.latencyController=this.createController(BS,S),this.coreComponents=S,_.push(l);const O=l.onErrorOut;typeof O=="function"&&this.on(E.ERROR,O,l)}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,r){this._emitter.off(e,t,s,r)}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(R.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const r=e===E.ERROR;this.trigger(E.ERROR,{type:se.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){R.log("destroy"),this.trigger(E.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){R.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})}detachMedia(){R.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,s=this.url,r=this.url=dm.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,R.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})}startLoad(e=-1){R.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){R.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){R.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){R.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){R.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){R.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){R.log(`set loadLevel:${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){R.log(`set firstLevel:${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){R.log(`set startLevel:${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 ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(R.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){GS(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 r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,s)for(let n=r;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=s)return n}return r}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()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||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}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}rr.defaultConfig=void 0;var Ne=rr,as=class aa extends Error{constructor(e,t=aa.MEDIA_ERR_CUSTOM,s,r){var n;super(e),this.name="MediaError",this.code=t,this.context=r,this.fatal=s??(t>=aa.MEDIA_ERR_NETWORK&&t<=aa.MEDIA_ERR_ENCRYPTED),this.message||(this.message=(n=aa.defaultMessages[this.code])!=null?n:"")}};as.MEDIA_ERR_ABORTED=1,as.MEDIA_ERR_NETWORK=2,as.MEDIA_ERR_DECODE=3,as.MEDIA_ERR_SRC_NOT_SUPPORTED=4,as.MEDIA_ERR_ENCRYPTED=5,as.MEDIA_ERR_CUSTOM=100,as.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Ct=as,JL=i=>i==null,PE=(i,e)=>JL(e)?!1:i in e,lh={ANY:"any",MUTED:"muted"},_e={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Ci={MSE:"mse",NATIVE:"native"},dl={HEADER:"header",QUERY:"query",NONE:"none"},jd=Object.values(dl),Ss={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},H0={HLS:Ss.M3U8};[...Object.values(Ss)];var st=(i,e,t,s,r=i)=>{r.addEventListener(e,t,s),i.addEventListener("teardown",()=>{r.removeEventListener(e,t)},{once:!0})};function eI(i,e,t){e&&t>e&&(t=e);for(let s=0;s<i.length;s++)if(i.start(s)<=t&&i.end(s)>=t)return!0;return!1}var tI=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),s=i.slice(e);return[t,s]},Ic=i=>{let e=i.type;if(e){let s=e.toUpperCase();return PE(s,H0)?H0[s]:e}let{src:t}=i;return t?iI(t):""},NE=i=>i==="VOD"?_e.ON_DEMAND:_e.LIVE,UE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,iI=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let s=e.slice(t+1).toUpperCase();return PE(s,Ss)?Ss[s]:""},sI=Object.values(lh),W0=i=>typeof i=="boolean"||typeof i=="string"&&sI.includes(i),rI=(i,e,t)=>{let{autoplay:s}=i,r=!1,n=!1,a=W0(s)?s:!!s,o=()=>{r||st(e,"playing",()=>{r=!0},{once:!0})};if(o(),st(e,"loadstart",()=>{r=!1,o(),mu(e,a)},{once:!0}),st(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==_e.UNKNOWN?n=i.streamType===_e.LIVE:n=!Number.isFinite(e.duration)),mu(e,a)},{once:!0}),t&&t.once(Ne.Events.LEVEL_LOADED,(l,d)=>{var c;i.streamType&&i.streamType!==_e.UNKNOWN?n=i.streamType===_e.LIVE:n=(c=d.details.live)!=null?c:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&st(e,"play",()=>{e.preload==="metadata"?t.once(Ne.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{r||(a=W0(l)?l:!!l,mu(e,a))}},mu=(i,e)=>{if(!e)return;let t=i.muted,s=()=>i.muted=t;switch(e){case lh.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(s)});break;case lh.MUTED:i.muted=!0,i.play().catch(s);break;default:i.play().catch(()=>{});break}},nI=({preload:i,src:e},t,s)=>{let r=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!s)return r(i),r;let n=!1,a=!1,o=s.config.maxBufferLength,l=s.config.maxBufferSize,d=u=>{r(u);let h=u??t.preload;a||h==="none"||(h==="metadata"?(s.config.maxBufferLength=1,s.config.maxBufferSize=1):(s.config.maxBufferLength=o,s.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,s.loadSource(e))};return st(t,"play",()=>{a=!0,s.config.maxBufferLength=o,s.config.maxBufferSize=l,c()},{once:!0}),d(i),d};function aI(i,e){var t;if(!("videoTracks"in i))return;let s=new WeakMap;e.on(Ne.Events.MANIFEST_PARSED,function(d,c){l();let u=i.addVideoTrack("main");u.selected=!0;for(let[h,f]of c.levels.entries()){let m=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);s.set(f,`${h}`),m.id=`${h}`}}),e.on(Ne.Events.AUDIO_TRACKS_UPDATED,function(d,c){o();for(let u of c.audioTracks){let h=u.default?"main":"alternative",f=i.addAudioTrack(h,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),u=e.audioTracks.map(h=>h.id);c!=e.audioTrack&&u.includes(c)&&(e.audioTrack=c)}),e.on(Ne.Events.LEVELS_UPDATED,function(d,c){var u;let h=i.videoTracks[(u=i.videoTracks.selectedIndex)!=null?u:0];if(!h)return;let f=c.levels.map(m=>s.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let r=d=>{let c=d.target.selectedIndex;c!=e.nextLevel&&n(c)},n=d=>{let c=i.currentTime,u=!1,h=(f,m)=>{u||(u=!Number.isFinite(m.endOffset))};e.on(Ne.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(Ne.Events.BUFFER_FLUSHING,h),u||e.trigger(Ne.Events.BUFFER_FLUSHING,{startOffset:c+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",r);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(Ne.Events.DESTROYING,l)}var pu=i=>"time"in i?i.time:i.startTime;function oI(i,e){e.on(Ne.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:c,name:u,type:h})=>c==(l==null?void 0:l.lang)&&u===a.label&&h.toLowerCase()===a.kind);Lm(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var r;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(r=e.subtitleTracks[e.subtitleTrack])==null?void 0:r.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:c})=>l==n.language&&d===n.label&&c.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(Ne.Events.CUES_PARSED,(r,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var c;(c=o.cues)!=null&&c.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(Ne.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(r=>{r.remove()})});let s=()=>{Array.from(i.textTracks).forEach(r=>{var n,a;if(!["subtitles","caption"].includes(r.kind)&&r.label==="thumbnails"){if(!((n=r.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}r.mode!=="hidden"&&(r.mode="hidden")}})};e.once(Ne.Events.MANIFEST_LOADED,s),e.once(Ne.Events.MEDIA_ATTACHED,s)}function Lm(i,e,t,s,r){let n=document.createElement("track");return n.kind=e,n.label=t,s&&(n.srclang=s),r&&(n.id=r),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function lI(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),s=>s.track===e);t==null||t.remove()}function co(i,e,t){var s;return(s=Array.from(i.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind===t))==null?void 0:s.track}async function FE(i,e,t,s){let r=co(i,t,s);return r||(r=Lm(i,s,t),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort((n,a)=>pu(a)-pu(n)).forEach(n=>{var a,o;let l=n.value,d=pu(n);if("endTime"in n&&n.endTime!=null)r==null||r.addCue(new VTTCue(d,n.endTime,s==="chapters"?l:JSON.stringify(l??null)));else{let c=Array.prototype.findIndex.call(r==null?void 0:r.cues,m=>m.startTime>=d),u=(a=r==null?void 0:r.cues)==null?void 0:a[c],h=u?u.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=r==null?void 0:r.cues)==null?void 0:o[c-1];f&&(f.endTime=d),r==null||r.addCue(new VTTCue(d,h,s==="chapters"?l:JSON.stringify(l??null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),r}var Im="cuepoints",$E=Object.freeze({label:Im});async function BE(i,e,t=$E){return FE(i,e,t.label,"metadata")}var dh=i=>({time:i.startTime,value:JSON.parse(i.text)});function dI(i,e={label:Im}){let t=co(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,s=>dh(s)):[]}function GE(i,e={label:Im}){var t,s;let r=co(i,e.label,"metadata");if(!((t=r==null?void 0:r.activeCues)!=null&&t.length))return;if(r.activeCues.length===1)return dh(r.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:o,endTime:l})=>o<=n&&l>n);return dh(a||r.activeCues[0])}async function cI(i,e=$E){return new Promise(t=>{st(i,"loadstart",async()=>{let s=await BE(i,[],e);st(i,"cuechange",()=>{let r=GE(i);if(r){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});i.dispatchEvent(n)}},{},s),t(s)})})}var Rm="chapters",HE=Object.freeze({label:Rm}),ch=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function WE(i,e,t=HE){return FE(i,e,t.label,"chapters")}function uI(i,e={label:Rm}){var t;let s=co(i,e.label,"chapters");return(t=s==null?void 0:s.cues)!=null&&t.length?Array.from(s.cues,r=>ch(r)):[]}function KE(i,e={label:Rm}){var t,s;let r=co(i,e.label,"chapters");if(!((t=r==null?void 0:r.activeCues)!=null&&t.length))return;if(r.activeCues.length===1)return ch(r.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:o,endTime:l})=>o<=n&&l>n);return ch(a||r.activeCues[0])}async function hI(i,e=HE){return new Promise(t=>{st(i,"loadstart",async()=>{let s=await WE(i,[],e);st(i,"cuechange",()=>{let r=KE(i);if(r){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:r});i.dispatchEvent(n)}},{},s),t(s)})})}function fI(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function mI(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var pI=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
43
+ `),d=[],c=e?ek(e.baseTime,e.timescale):0;let u="00:00.000",h=0,f=0,m,p=!0;o.oncue=function(g){const v=t[s];let y=t.ccOffset;const b=(h-c)/9e4;if(v!=null&&v.new&&(f!==void 0?y=t.ccOffset=v.start:Nk(t,s,b)),b){if(!e){m=new Error("Missing initPTS for VTT MPEGTS");return}y=b-t.presentationOffset}const x=g.endTime-g.startTime,_=Kt((g.startTime+y-f)*9e4,r*9e4)/9e4;g.startTime=Math.max(_,0),g.endTime=Math.max(_+x,0);const S=g.text.trim();g.text=decodeURIComponent(encodeURIComponent(S)),g.id||(g.id=Sm(g.startTime,g.endTime,S)),g.endTime>0&&d.push(g)},o.onparsingerror=function(g){m=g},o.onflush=function(){if(m){a(m);return}n(d)},l.forEach(g=>{if(p)if(ou(g,"X-TIMESTAMP-MAP=")){p=!1,g.slice(16).split(",").forEach(v=>{ou(v,"LOCAL:")?u=v.slice(6):ou(v,"MPEGTS:")&&(h=parseInt(v.slice(7)))});try{f=Pk(u)/1e3}catch(v){m=v}return}else g===""&&(p=!1);o.parse(g+`
44
+ `)}),o.flush()}const du="stpp.ttml.im1t",TE=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,_E=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Fk={left:"start",center:"center",right:"end",start:"start",end:"end"};function C0(i,e,t,s){const r=le(new Uint8Array(i),["mdat"]);if(r.length===0){s(new Error("Could not parse IMSC1 mdat"));return}const n=r.map(o=>Oi(o)),a=Jx(e.baseTime,1,e.timescale);try{n.forEach(o=>t($k(o,a)))}catch(o){s(o)}}function $k(i,e){const r=new DOMParser().parseFromString(i,"text/xml").getElementsByTagName("tt")[0];if(!r)throw new Error("Invalid ttml");const n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((u,h)=>(u[h]=r.getAttribute(`ttp:${h}`)||n[h],u),{}),o=r.getAttribute("xml:space")!=="preserve",l=D0(cu(r,"styling","style")),d=D0(cu(r,"layout","region")),c=cu(r,"body","[begin]");return[].map.call(c,u=>{const h=AE(u,o);if(!h||!u.hasAttribute("begin"))return null;const f=hu(u.getAttribute("begin"),a),m=hu(u.getAttribute("dur"),a);let p=hu(u.getAttribute("end"),a);if(f===null)throw M0(u);if(p===null){if(m===null)throw M0(u);p=f+m}const g=new Am(f-e,p-e,h);g.id=Sm(g.startTime,g.endTime,g.text);const v=d[u.getAttribute("region")],y=l[u.getAttribute("style")],b=Bk(v,y,l),{textAlign:x}=b;if(x){const _=Fk[x];_&&(g.lineAlign=_),g.align=x}return Ke(g,b),g}).filter(u=>u!==null)}function cu(i,e,t){const s=i.getElementsByTagName(e)[0];return s?[].slice.call(s.querySelectorAll(t)):[]}function D0(i){return i.reduce((e,t)=>{const s=t.getAttribute("xml:id");return s&&(e[s]=t),e},{})}function AE(i,e){return[].slice.call(i.childNodes).reduce((t,s,r)=>{var n;return s.nodeName==="br"&&r?t+`
45
+ `:(n=s.childNodes)!=null&&n.length?AE(s,e):e?t+s.textContent.trim().replace(/\s+/g," "):t+s.textContent},"")}function Bk(i,e,t){const s="http://www.w3.org/ns/ttml#styling";let r=null;const n=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],a=i!=null&&i.hasAttribute("style")?i.getAttribute("style"):null;return a&&t.hasOwnProperty(a)&&(r=t[a]),n.reduce((o,l)=>{const d=uu(e,s,l)||uu(i,s,l)||uu(r,s,l);return d&&(o[l]=d),o},{})}function uu(i,e,t){return i&&i.hasAttributeNS(e,t)?i.getAttributeNS(e,t):null}function M0(i){return new Error(`Could not parse ttml timestamp ${i}`)}function hu(i,e){if(!i)return null;let t=EE(i);return t===null&&(TE.test(i)?t=Gk(i,e):_E.test(i)&&(t=Hk(i,e))),t}function Gk(i,e){const t=TE.exec(i),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 Hk(i,e){const t=_E.exec(i),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 Wk{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=P0(),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(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.on(E.FRAG_LOADING,this.onFragLoading,this),e.on(E.FRAG_LOADED,this.onFragLoaded,this),e.on(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.on(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.on(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.on(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.on(E.BUFFER_FLUSHING,this.onBufferFlushing,this)}destroy(){const{hls:e}=this;e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),e.off(E.FRAG_LOADING,this.onFragLoading,this),e.off(E.FRAG_LOADED,this.onFragLoaded,this),e.off(E.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),e.off(E.FRAG_DECRYPTED,this.onFragDecrypted,this),e.off(E.INIT_PTS_FOUND,this.onInitPtsFound,this),e.off(E.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),e.off(E.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0}initCea608Parsers(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){const e=new ko(this,"textTrack1"),t=new ko(this,"textTrack2"),s=new ko(this,"textTrack3"),r=new ko(this,"textTrack4");this.cea608Parser1=new w0(1,e,t),this.cea608Parser2=new w0(3,s,r)}}addCues(e,t,s,r,n){let a=!1;for(let o=n.length;o--;){const l=n[o],d=Kk(l[0],l[1],t,s);if(d>=0&&(l[0]=Math.min(l[0],t),l[1]=Math.max(l[1],s),a=!0,d/(s-t)>.5))return}if(a||n.push([t,s]),this.config.renderTextTracksNatively){const o=this.captionsTracks[e];this.Cues.newCue(o,t,s,r)}else{const o=this.Cues.newCue(null,t,s,r);this.hls.trigger(E.CUES_PARSED,{type:"captions",cues:o,track:e})}}onInitPtsFound(e,{frag:t,id:s,initPTS:r,timescale:n}){const{unparsedVttFrags:a}=this;s==="main"&&(this.initPTS[t.cc]={baseTime:r,timescale:n}),a.length&&(this.unparsedVttFrags=[],a.forEach(o=>{this.onFragLoaded(E.FRAG_LOADED,o)}))}getExistingTrack(e,t){const{media:s}=this;if(s)for(let r=0;r<s.textTracks.length;r++){const n=s.textTracks[r];if(O0(n,{name:e,lang:t,attrs:{}}))return n}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:r}=this,{label:n,languageCode:a}=t[e],o=this.getExistingTrack(n,a);if(o)s[e]=o,fn(s[e]),Wv(s[e],r);else{const l=this.createTextTrack("captions",n,a);l&&(l[e]=!0,s[e]=l)}}createNonNativeTrack(e){if(this.nonNativeCaptionsTracks[e])return;const t=this.captionsProperties[e];if(!t)return;const s=t.label,r={_id:e,label:s,kind:"captions",default:t.media?!!t.media.default:!1,closedCaptions:t.media};this.nonNativeCaptionsTracks[e]=r,this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[r]})}createTextTrack(e,t,s){const r=this.media;if(r)return r.addTextTrack(e,t,s)}onMediaAttaching(e,t){this.media=t.media,this._cleanTracks()}onMediaDetaching(){const{captionsTracks:e}=this;Object.keys(e).forEach(t=>{fn(e[t]),delete e[t]}),this.nonNativeCaptionsTracks={}}onManifestLoading(){this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs=P0(),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++)fn(t[s])}onSubtitleTracksUpdated(e,t){const s=t.subtitleTracks||[],r=s.some(n=>n.textCodec===du);if(this.config.enableWebVTT||r&&this.config.enableIMSC1){if(pE(this.tracks,s)){this.tracks=s;return}if(this.textTracks=[],this.tracks=s,this.config.renderTextTracksNatively){const a=this.media,o=a?tl(a.textTracks):null;if(this.tracks.forEach((l,d)=>{let c;if(o){let u=null;for(let h=0;h<o.length;h++)if(o[h]&&O0(o[h],l)){u=o[h],o[h]=null;break}u&&(c=u)}if(c)fn(c);else{const u=SE(l);c=this.createTextTrack(u,l.name,l.lang),c&&(c.mode="disabled")}c&&this.textTracks.push(c)}),o!=null&&o.length){const l=o.filter(d=>d!==null).map(d=>d.label);l.length&&R.warn(`Media element contains unused subtitle tracks: ${l.join(", ")}. Replace media element for each source to clear TextTracks and captions menu.`)}}else if(this.tracks.length){const a=this.tracks.map(o=>({label:o.name,kind:o.type.toLowerCase(),default:o.default,subtitleTrack:o}));this.hls.trigger(E.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:a})}}}onManifestLoaded(e,t){this.config.enableCEA708Captions&&t.captions&&t.captions.forEach(s=>{const r=/(?:CC|SERVICE)([1-4])/.exec(s.instreamId);if(!r)return;const n=`textTrack${r[1]}`,a=this.captionsProperties[n];a&&(a.label=s.name,s.lang&&(a.languageCode=s.lang),a.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===te.MAIN){var s,r;const{cea608Parser1:n,cea608Parser2:a,lastSn:o}=this,{cc:l,sn:d}=t.frag,c=(s=(r=t.part)==null?void 0:r.index)!=null?s:-1;n&&a&&(d!==o+1||d===o&&c!==this.lastPartIndex+1||l!==this.lastCc)&&(n.reset(),a.reset()),this.lastCc=l,this.lastSn=d,this.lastPartIndex=c}}onFragLoaded(e,t){const{frag:s,payload:r}=t;if(s.type===te.SUBTITLE)if(r.byteLength){const n=s.decryptdata,a="stats"in t;if(n==null||!n.encrypted||a){const o=this.tracks[s.level],l=this.vttCCs;l[s.cc]||(l[s.cc]={start:s.start,prevCC:this.prevCC,new:!0},this.prevCC=s.cc),o&&o.textCodec===du?this._parseIMSC1(s,r):this._parseVTTs(t)}}else this.hls.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:new Error("Empty subtitle payload")})}_parseIMSC1(e,t){const s=this.hls;C0(t,this.initPTS[e.cc],r=>{this._appendCues(r,e.level),s.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:e})},r=>{R.log(`Failed to parse IMSC1: ${r}`),s.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:e,error:r})})}_parseVTTs(e){var t;const{frag:s,payload:r}=e,{initPTS:n,unparsedVttFrags:a}=this,o=n.length-1;if(!n[s.cc]&&o===-1){a.push(e);return}const l=this.hls,d=(t=s.initSegment)!=null&&t.data?Vt(s.initSegment.data,new Uint8Array(r)):r;Uk(d,this.initPTS[s.cc],this.vttCCs,s.cc,s.start,c=>{this._appendCues(c,s.level),l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:s})},c=>{const u=c.message==="Missing initPTS for VTT MPEGTS";u?a.push(e):this._fallbackToIMSC1(s,r),R.log(`Failed to parse VTT cue: ${c}`),!(u&&o>s.cc)&&l.trigger(E.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:s,error:c})})}_fallbackToIMSC1(e,t){const s=this.tracks[e.level];s.textCodec||C0(t,this.initPTS[e.cc],()=>{s.textCodec=du,this._parseIMSC1(e,t)},()=>{s.textCodec="wvtt"})}_appendCues(e,t){const s=this.hls;if(this.config.renderTextTracksNatively){const r=this.textTracks[t];if(!r||r.mode==="disabled")return;e.forEach(n=>Kv(r,n))}else{const r=this.tracks[t];if(!r)return;const n=r.default?"default":"subtitles"+t;s.trigger(E.CUES_PARSED,{type:"subtitles",cues:e,track:n})}}onFragDecrypted(e,t){const{frag:s}=t;s.type===te.SUBTITLE&&this.onFragLoaded(E.FRAG_LOADED,t)}onSubtitleTracksCleared(){this.tracks=[],this.captionsTracks={}}onFragParsingUserdata(e,t){this.initCea608Parsers();const{cea608Parser1:s,cea608Parser2:r}=this;if(!this.enabled||!s||!r)return;const{frag:n,samples:a}=t;if(!(n.type===te.MAIN&&this.closedCaptionsForLevel(n)==="NONE"))for(let o=0;o<a.length;o++){const l=a[o].bytes;if(l){const d=this.extractCea608Data(l);s.addData(a[o].pts,d[0]),r.addData(a[o].pts,d[1])}}}onBufferFlushing(e,{startOffset:t,endOffset:s,endOffsetSubtitles:r,type:n}){const{media:a}=this;if(!(!a||a.currentTime<s)){if(!n||n==="video"){const{captionsTracks:o}=this;Object.keys(o).forEach(l=>Xu(o[l],t,s))}if(this.config.renderTextTracksNatively&&t===0&&r!==void 0){const{textTracks:o}=this;Object.keys(o).forEach(l=>Xu(o[l],t,r))}}}extractCea608Data(e){const t=[[],[]],s=e[0]&31;let r=2;for(let n=0;n<s;n++){const a=e[r++],o=127&e[r++],l=127&e[r++];if(o===0&&l===0)continue;if((4&a)!==0){const c=3&a;(c===0||c===1)&&(t[c].push(o),t[c].push(l))}}return t}}function SE(i){return i.characteristics&&/transcribes-spoken-dialog/gi.test(i.characteristics)&&/describes-music-and-sound/gi.test(i.characteristics)?"captions":"subtitles"}function O0(i,e){return!!i&&i.kind===SE(e)&&ih(e,i)}function Kk(i,e,t,s){return Math.min(e,s)-Math.max(i,t)}function P0(){return{ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}}}class xm{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(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.on(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.BUFFER_CODECS,this.onBufferCodecs,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this)}unregisterListener(){const{hls:e}=this;e.off(E.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),e.off(E.MEDIA_ATTACHING,this.onMediaAttaching,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.BUFFER_CODECS,this.onBufferCodecs,this),e.off(E.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&&j(this.autoLevelCapping)&&this.detectPlayerSize()}onBufferCodecs(e,t){this.hls.config.capLevelToPlayerSize&&t.video&&this.startCapping()}onMediaDetaching(){this.stopCapping()}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&&R.log(`Setting autoLevelCapping to ${s}: ${e[s].height}p@${e[s].bitrate} for media ${this.mediaWidth}x${this.mediaHeight}`),t.autoLevelCapping=s,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((r,n)=>this.isLevelAllowed(r)&&n<=e);return this.clientRect=null,xm.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{}return e}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 r=(o,l)=>l?o.width!==l.width||o.height!==l.height:!0;let n=e.length-1;const a=Math.max(t,s);for(let o=0;o<e.length;o+=1){const l=e[o];if((l.width>=a||l.height>=a)&&r(l,e[o+1])){n=o;break}}return n}}class Vk{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(E.MEDIA_ATTACHING,this.onMediaAttaching,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHING,this.onMediaAttaching,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 r=t.media instanceof self.HTMLVideoElement?t.media:null;this.media=r,r&&typeof r.getVideoPlaybackQuality=="function"&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),s.fpsDroppedMonitoringPeriod)}}checkFPS(e,t,s){const r=performance.now();if(t){if(this.lastTime){const n=r-this.lastTime,a=s-this.lastDroppedFrames,o=t-this.lastDecodedFrames,l=1e3*a/n,d=this.hls;if(d.trigger(E.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:s}),l>0&&a>d.config.fpsDroppedMonitoringThreshold*o){let c=d.currentLevel;R.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(d.autoLevelCapping===-1||d.autoLevelCapping>=c)&&(c=c-1,d.trigger(E.FPS_DROP_LEVEL_CAPPING,{level:c,droppedLevel:d.currentLevel}),d.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=r,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)}}const Io="[eme]";class bn{constructor(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=bn.CDMCleanupPromise?[bn.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=R.debug.bind(R,Io),this.log=R.log.bind(R,Io),this.warn=R.warn.bind(R,Io),this.error=R.error.bind(R,Io),this.hls=e,this.config=e.config,this.registerListeners()}destroy(){this.unregisterListeners(),this.onMediaDetached();const e=this.config;e.requestMediaKeySystemAccessFunc=null,e.licenseXhrSetup=e.licenseResponseCallback=void 0,e.drmSystems=e.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null}registerListeners(){this.hls.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(E.MANIFEST_LOADED,this.onManifestLoaded,this)}unregisterListeners(){this.hls.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(E.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(E.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(E.MANIFEST_LOADED,this.onManifestLoaded,this)}getLicenseServerUrl(e){const{drmSystems:t,widevineLicenseUrl:s}=this.config,r=t[e];if(r)return r.licenseUrl;if(e===we.WIDEVINE&&s)return s;throw new Error(`no license server URL configured for key-system "${e}"`)}getServerCertificateUrl(e){const{drmSystems:t}=this.config,s=t[e];if(s)return s.serverCertificateUrl;this.log(`No Server Certificate in config.drmSystems["${e}"]`)}attemptKeySystemAccess(e){const t=this.hls.levels,s=(a,o,l)=>!!a&&l.indexOf(a)===o,r=t.map(a=>a.audioCodec).filter(s),n=t.map(a=>a.videoCodec).filter(s);return r.length+n.length===0&&n.push("avc1.42e01e"),new Promise((a,o)=>{const l=d=>{const c=d.shift();this.getMediaKeysPromise(c,r,n).then(u=>a({keySystem:c,mediaKeys:u})).catch(u=>{d.length?l(d):u instanceof $t?o(u):o(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_ACCESS,error:u,fatal:!0},u.message))})};l(e)})}requestMediaKeySystemAccess(e,t){const{requestMediaKeySystemAccessFunc:s}=this.config;if(typeof s!="function"){let r=`Configured requestMediaKeySystemAccess is not a function ${s}`;return wv===null&&self.location.protocol==="http:"&&(r=`navigator.requestMediaKeySystemAccess is not available over insecure protocol ${location.protocol}`),Promise.reject(new Error(r))}return s(e,t)}getMediaKeysPromise(e,t,s){const r=ZA(e,t,s,this.config.drmSystemOptions),n=this.keySystemAccessPromises[e];let a=n==null?void 0:n.keySystemAccess;if(!a){this.log(`Requesting encrypted media "${e}" key-system access with config: ${JSON.stringify(r)}`),a=this.requestMediaKeySystemAccess(e,r);const o=this.keySystemAccessPromises[e]={keySystemAccess:a};return a.catch(l=>{this.log(`Failed to obtain access to key-system "${e}": ${l}`)}),a.then(l=>{this.log(`Access for key-system "${l.keySystem}" obtained`);const d=this.fetchServerCertificate(e);return this.log(`Create media-keys for "${e}"`),o.mediaKeys=l.createMediaKeys().then(c=>(this.log(`Media-keys created for "${e}"`),d.then(u=>u?this.setMediaKeysServerCertificate(c,e,u):c))),o.mediaKeys.catch(c=>{this.error(`Failed to create media-keys for "${e}"}: ${c}`)}),o.mediaKeys})}return a.then(()=>n.mediaKeys)}createMediaKeySessionContext({decryptdata:e,keySystem:t,mediaKeys:s}){this.log(`Creating key-system session "${t}" keyId: ${Si.hexDump(e.keyId||[])}`);const r=s.createSession(),n={decryptdata:e,keySystem:t,mediaKeys:s,mediaKeysSession:r,keyStatus:"status-pending"};return this.mediaKeySessions.push(n),n}renewKeySession(e){const t=e.decryptdata;if(t.pssh){const s=this.createMediaKeySessionContext(e),r=this.getKeyIdString(t),n="cenc";this.keyIdToKeySessionPromise[r]=this.generateRequestWithPreferredKeySession(s,n,t.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(e)}getKeyIdString(e){if(!e)throw new Error("Could not read keyId of undefined decryptdata");if(e.keyId===null)throw new Error("keyId is null");return Si.hexDump(e.keyId)}updateKeySession(e,t){var s;const r=e.mediaKeysSession;return this.log(`Updating key-session "${r.sessionId}" for keyID ${Si.hexDump(((s=e.decryptdata)==null?void 0:s.keyId)||[])}
46
+ } (data length: ${t&&t.byteLength})`),r.update(t)}selectKeySystemFormat(e){const t=Object.keys(e.levelkeys||{});return this.keyFormatPromise||(this.log(`Selecting key-system from fragment (sn: ${e.sn} ${e.type}: ${e.level}) key formats ${t.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(t)),this.keyFormatPromise}getKeyFormatPromise(e){return new Promise((t,s)=>{const r=jc(this.config),n=e.map(Hp).filter(a=>!!a&&r.indexOf(a)!==-1);return this.getKeySystemSelectionPromise(n).then(({keySystem:a})=>{const o=Wp(a);o?t(o):s(new Error(`Unable to find format for key-system "${a}"`))}).catch(s)})}loadKey(e){const t=e.keyInfo.decryptdata,s=this.getKeyIdString(t),r=`(keyId: ${s} format: "${t.keyFormat}" method: ${t.method} uri: ${t.uri})`;this.log(`Starting session for key ${r}`);let n=this.keyIdToKeySessionPromise[s];return n||(n=this.keyIdToKeySessionPromise[s]=this.getKeySystemForKeyPromise(t).then(({keySystem:a,mediaKeys:o})=>(this.throwIfDestroyed(),this.log(`Handle encrypted media sn: ${e.frag.sn} ${e.frag.type}: ${e.frag.level} using key ${r}`),this.attemptSetMediaKeys(a,o).then(()=>{this.throwIfDestroyed();const l=this.createMediaKeySessionContext({keySystem:a,mediaKeys:o,decryptdata:t});return this.generateRequestWithPreferredKeySession(l,"cenc",t.pssh,"playlist-key")}))),n.catch(a=>this.handleError(a))),n}throwIfDestroyed(e="Invalid state"){if(!this.hls)throw new Error("invalid state")}handleError(e){this.hls&&(this.error(e.message),e instanceof $t?this.hls.trigger(E.ERROR,e.data):this.hls.trigger(E.ERROR,{type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_KEYS,error:e,fatal:!0}))}getKeySystemForKeyPromise(e){const t=this.getKeyIdString(e),s=this.keyIdToKeySessionPromise[t];if(!s){const r=Hp(e.keyFormat),n=r?[r]:jc(this.config);return this.attemptKeySystemAccess(n)}return s}getKeySystemSelectionPromise(e){if(e.length||(e=jc(this.config)),e.length===0)throw new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},`Missing key-system license configuration options ${JSON.stringify({drmSystems:this.config.drmSystems})}`);return this.attemptKeySystemAccess(e)}_onMediaEncrypted(e){const{initDataType:t,initData:s}=e;if(this.debug(`"${e.type}" event: init data type: "${t}"`),s===null)return;let r,n;if(t==="sinf"&&this.config.drmSystems[we.FAIRPLAY]){const c=je(new Uint8Array(s));try{const u=cm(JSON.parse(c).sinf),h=Fv(new Uint8Array(u));if(!h)return;r=h.subarray(8,24),n=we.FAIRPLAY}catch{this.warn('Failed to parse sinf "encrypted" event message initData');return}}else{const c=AS(s);if(c===null)return;c.version===0&&c.systemId===Rv.WIDEVINE&&c.data&&(r=c.data.subarray(8,24)),n=QA(c.systemId)}if(!n||!r)return;const a=Si.hexDump(r),{keyIdToKeySessionPromise:o,mediaKeySessions:l}=this;let d=o[a];for(let c=0;c<l.length;c++){const u=l[c],h=u.decryptdata;if(h.pssh||!h.keyId)continue;const f=Si.hexDump(h.keyId);if(a===f||h.uri.replace(/-/g,"").indexOf(a)!==-1){d=o[f],delete o[f],h.pssh=new Uint8Array(s),h.keyId=r,d=o[a]=d.then(()=>this.generateRequestWithPreferredKeySession(u,t,s,"encrypted-event-key-match"));break}}d||(d=o[a]=this.getKeySystemSelectionPromise([n]).then(({keySystem:c,mediaKeys:u})=>{var h;this.throwIfDestroyed();const f=new ja("ISO-23001-7",a,(h=Wp(c))!=null?h:"");return f.pssh=new Uint8Array(s),f.keyId=r,this.attemptSetMediaKeys(c,u).then(()=>{this.throwIfDestroyed();const m=this.createMediaKeySessionContext({decryptdata:f,keySystem:c,mediaKeys:u});return this.generateRequestWithPreferredKeySession(m,t,s,"encrypted-event-no-match")})})),d.catch(c=>this.handleError(c))}_onWaitingForKey(e){this.log(`"${e.type}" event`)}attemptSetMediaKeys(e,t){const s=this.setMediaKeysQueue.slice();this.log(`Setting media-keys for "${e}"`);const r=Promise.all(s).then(()=>{if(!this.media)throw new Error("Attempted to set mediaKeys without media element attached");return this.media.setMediaKeys(t)});return this.setMediaKeysQueue.push(r),r.then(()=>{this.log(`Media-keys set for "${e}"`),s.push(r),this.setMediaKeysQueue=this.setMediaKeysQueue.filter(n=>s.indexOf(n)===-1)})}generateRequestWithPreferredKeySession(e,t,s,r){var n,a;const o=(n=this.config.drmSystems)==null||(a=n[e.keySystem])==null?void 0:a.generateRequest;if(o)try{const m=o.call(this.hls,t,s,e);if(!m)throw new Error("Invalid response from configured generateRequest filter");t=m.initDataType,s=e.decryptdata.pssh=m.initData?new Uint8Array(m.initData):null}catch(m){var l;if(this.warn(m.message),(l=this.hls)!=null&&l.config.debug)throw m}if(s===null)return this.log(`Skipping key-session request for "${r}" (no initData)`),Promise.resolve(e);const d=this.getKeyIdString(e.decryptdata);this.log(`Generating key-session request for "${r}": ${d} (init data type: ${t} length: ${s?s.byteLength:null})`);const c=new _m,u=e._onmessage=m=>{const p=e.mediaKeysSession;if(!p){c.emit("error",new Error("invalid state"));return}const{messageType:g,message:v}=m;this.log(`"${g}" message event for session "${p.sessionId}" message size: ${v.byteLength}`),g==="license-request"||g==="license-renewal"?this.renewLicense(e,v).catch(y=>{this.handleError(y),c.emit("error",y)}):g==="license-release"?e.keySystem===we.FAIRPLAY&&(this.updateKeySession(e,ju("acknowledged")),this.removeSession(e)):this.warn(`unhandled media key message type "${g}"`)},h=e._onkeystatuseschange=m=>{if(!e.mediaKeysSession){c.emit("error",new Error("invalid state"));return}this.onKeyStatusChange(e);const g=e.keyStatus;c.emit("keyStatus",g),g==="expired"&&(this.warn(`${e.keySystem} expired for key ${d}`),this.renewKeySession(e))};e.mediaKeysSession.addEventListener("message",u),e.mediaKeysSession.addEventListener("keystatuseschange",h);const f=new Promise((m,p)=>{c.on("error",p),c.on("keyStatus",g=>{g.startsWith("usable")?m():g==="output-restricted"?p(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED,fatal:!1},"HDCP level output restricted")):g==="internal-error"?p(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_STATUS_INTERNAL_ERROR,fatal:!0},`key status changed to "${g}"`)):g==="expired"?p(new Error("key expired while generating request")):this.warn(`unhandled key status change "${g}"`)})});return e.mediaKeysSession.generateRequest(t,s).then(()=>{var m;this.log(`Request generated for key-session "${(m=e.mediaKeysSession)==null?void 0:m.sessionId}" keyId: ${d}`)}).catch(m=>{throw new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_NO_SESSION,error:m,fatal:!1},`Error generating key-session request: ${m}`)}).then(()=>f).catch(m=>{throw c.removeAllListeners(),this.removeSession(e),m}).then(()=>(c.removeAllListeners(),e))}onKeyStatusChange(e){e.mediaKeysSession.keyStatuses.forEach((t,s)=>{this.log(`key status change "${t}" for keyStatuses keyId: ${Si.hexDump("buffer"in s?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):new Uint8Array(s))} session keyId: ${Si.hexDump(new Uint8Array(e.decryptdata.keyId||[]))} uri: ${e.decryptdata.uri}`),e.keyStatus=t})}fetchServerCertificate(e){const t=this.config,s=t.loader,r=new s(t),n=this.getServerCertificateUrl(e);return n?(this.log(`Fetching server certificate for "${e}"`),new Promise((a,o)=>{const l={responseType:"arraybuffer",url:n},d=t.certLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{a(h.data)},onError:(h,f,m,p)=>{o(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:dt({url:l.url,data:void 0},h)},`"${e}" certificate request failed (${n}). Status: ${h.code} (${h.text})`))},onTimeout:(h,f,m)=>{o(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED,fatal:!0,networkDetails:m,response:{url:l.url,data:void 0}},`"${e}" certificate request timed out (${n})`))},onAbort:(h,f,m)=>{o(new Error("aborted"))}};r.load(l,c,u)})):Promise.resolve()}setMediaKeysServerCertificate(e,t,s){return new Promise((r,n)=>{e.setServerCertificate(s).then(a=>{this.log(`setServerCertificate ${a?"success":"not supported by CDM"} (${s==null?void 0:s.byteLength}) on "${t}"`),r(e)}).catch(a=>{n(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED,error:a,fatal:!0},a.message))})})}renewLicense(e,t){return this.requestLicense(e,new Uint8Array(t)).then(s=>this.updateKeySession(e,new Uint8Array(s)).catch(r=>{throw new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_SESSION_UPDATE_FAILED,error:r,fatal:!0},r.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 r=new DOMParser().parseFromString(s,"application/xml"),n=r.querySelectorAll("HttpHeader");if(n.length>0){let c;for(let u=0,h=n.length;u<h;u++){var a,o;c=n[u];const f=(a=c.querySelector("name"))==null?void 0:a.textContent,m=(o=c.querySelector("value"))==null?void 0:o.textContent;f&&m&&e.setRequestHeader(f,m)}}const l=r.querySelector("Challenge"),d=l==null?void 0:l.textContent;if(!d)throw new Error("Cannot find <Challenge> in key message");return ju(atob(d))}setupLicenseXHR(e,t,s,r){const n=this.config.licenseXhrSetup;return n?Promise.resolve().then(()=>{if(!s.decryptdata)throw new Error("Key removed");return n.call(this.hls,e,t,s,r)}).catch(a=>{if(!s.decryptdata)throw a;return e.open("POST",t,!0),n.call(this.hls,e,t,s,r)}).then(a=>(e.readyState||e.open("POST",t,!0),{xhr:e,licenseChallenge:a||r})):(e.open("POST",t,!0),Promise.resolve({xhr:e,licenseChallenge:r}))}requestLicense(e,t){const s=this.config.keyLoadPolicy.default;return new Promise((r,n)=>{const a=this.getLicenseServerUrl(e.keySystem);this.log(`Sending license request to URL: ${a}`);const o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=()=>{if(!this.hls||!e.mediaKeysSession)return n(new Error("invalid state"));if(o.readyState===4)if(o.status===200){this._requestLicenseFailureCount=0;let l=o.response;this.log(`License received ${l instanceof ArrayBuffer?l.byteLength:l}`);const d=this.config.licenseResponseCallback;if(d)try{l=d.call(this.hls,o,a,e)}catch(c){this.error(c)}r(l)}else{const l=s.errorRetry,d=l?l.maxNumRetry:0;if(this._requestLicenseFailureCount++,this._requestLicenseFailureCount>d||o.status>=400&&o.status<500)n(new $t({type:se.KEY_SYSTEM_ERROR,details:M.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:a,data:void 0,code:o.status,text:o.statusText}},`License Request XHR failed (${a}). Status: ${o.status} (${o.statusText})`));else{const c=d-this._requestLicenseFailureCount+1;this.warn(`Retrying license request, ${c} attempts left`),this.requestLicense(e,t).then(r,n)}}},e.licenseXhr&&e.licenseXhr.readyState!==XMLHttpRequest.DONE&&e.licenseXhr.abort(),e.licenseXhr=o,this.setupLicenseXHR(o,a,e,t).then(({xhr:l,licenseChallenge:d})=>{e.keySystem==we.PLAYREADY&&(d=this.unpackPlayReadyKeyMessage(l,d)),l.send(d)})})}onMediaAttached(e,t){if(!this.config.emeEnabled)return;const s=t.media;this.media=s,s.addEventListener("encrypted",this.onMediaEncrypted),s.addEventListener("waitingforkey",this.onWaitingForKey)}onMediaDetached(){const e=this.media,t=this.mediaKeySessions;e&&(e.removeEventListener("encrypted",this.onMediaEncrypted),e.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},ja.clearKeyUriToKeyIdMap();const s=t.length;bn.CDMCleanupPromise=Promise.all(t.map(r=>this.removeSession(r)).concat(e==null?void 0:e.setMediaKeys(null).catch(r=>{this.log(`Could not clear media keys: ${r}`)}))).then(()=>{s&&(this.log("finished closing key sessions and clearing media keys"),t.length=0)}).catch(r=>{this.log(`Could not close sessions and clear media keys: ${r}`)})}onManifestLoading(){this.keyFormatPromise=null}onManifestLoaded(e,{sessionKeys:t}){if(!(!t||!this.config.emeEnabled)&&!this.keyFormatPromise){const s=t.reduce((r,n)=>(r.indexOf(n.keyFormat)===-1&&r.push(n.keyFormat),r),[]);this.log(`Selecting key-system from session-keys ${s.join(", ")}`),this.keyFormatPromise=this.getKeyFormatPromise(s)}}removeSession(e){const{mediaKeysSession:t,licenseXhr:s}=e;if(t){this.log(`Remove licenses and keys and close session ${t.sessionId}`),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);return r>-1&&this.mediaKeySessions.splice(r,1),t.remove().catch(n=>{this.log(`Could not remove session: ${n}`)}).then(()=>t.close()).catch(n=>{this.log(`Could not close session: ${n}`)})}}}bn.CDMCleanupPromise=void 0;class $t 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}}var Et;(function(i){i.MANIFEST="m",i.AUDIO="a",i.VIDEO="v",i.MUXED="av",i.INIT="i",i.CAPTION="c",i.TIMED_TEXT="tt",i.KEY="k",i.OTHER="o"})(Et||(Et={}));var rh;(function(i){i.DASH="d",i.HLS="h",i.SMOOTH="s",i.OTHER="o"})(rh||(rh={}));var sr;(function(i){i.OBJECT="CMCD-Object",i.REQUEST="CMCD-Request",i.SESSION="CMCD-Session",i.STATUS="CMCD-Status"})(sr||(sr={}));const qk={[sr.OBJECT]:["br","d","ot","tb"],[sr.REQUEST]:["bl","dl","mtp","nor","nrr","su"],[sr.SESSION]:["cid","pr","sf","sid","st","v"],[sr.STATUS]:["bs","rtp"]};class Dn{constructor(e,t){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map(s=>s instanceof Dn?s:new Dn(s))),this.value=e,this.params=t}}class xE{constructor(e){this.description=void 0,this.description=e}}const Yk="Dict";function jk(i){return Array.isArray(i)?JSON.stringify(i):i instanceof Map?"Map{}":i instanceof Set?"Set{}":typeof i=="object"?JSON.stringify(i):String(i)}function zk(i,e,t,s){return new Error(`failed to ${i} "${jk(e)}" as ${t}`,{cause:s})}const N0="Bare Item",Xk="Boolean",Qk="Byte Sequence",Zk="Decimal",Jk="Integer";function eL(i){return i<-999999999999999||999999999999999<i}const tL=/[\x00-\x1f\x7f]+/,iL="Token",sL="Key";function Pi(i,e,t){return zk("serialize",i,e,t)}function rL(i){if(typeof i!="boolean")throw Pi(i,Xk);return i?"?1":"?0"}function nL(i){return btoa(String.fromCharCode(...i))}function aL(i){if(ArrayBuffer.isView(i)===!1)throw Pi(i,Qk);return`:${nL(i)}:`}function kE(i){if(eL(i))throw Pi(i,Jk);return i.toString()}function oL(i){return`@${kE(i.getTime()/1e3)}`}function LE(i,e){if(i<0)return-LE(-i,e);const t=Math.pow(10,e);if(Math.abs(i*t%1-.5)<Number.EPSILON){const r=Math.floor(i*t);return(r%2===0?r:r+1)/t}else return Math.round(i*t)/t}function lL(i){const e=LE(i,3);if(Math.floor(Math.abs(e)).toString().length>12)throw Pi(i,Zk);const t=e.toString();return t.includes(".")?t:`${t}.0`}const dL="String";function cL(i){if(tL.test(i))throw Pi(i,dL);return`"${i.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`}function uL(i){return i.description||i.toString().slice(7,-1)}function U0(i){const e=uL(i);if(/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(e)===!1)throw Pi(e,iL);return e}function nh(i){switch(typeof i){case"number":if(!j(i))throw Pi(i,N0);return Number.isInteger(i)?kE(i):lL(i);case"string":return cL(i);case"symbol":return U0(i);case"boolean":return rL(i);case"object":if(i instanceof Date)return oL(i);if(i instanceof Uint8Array)return aL(i);if(i instanceof xE)return U0(i);default:throw Pi(i,N0)}}function ah(i){if(/^[a-z*][a-z0-9\-_.*]*$/.test(i)===!1)throw Pi(i,sL);return i}function km(i){return i==null?"":Object.entries(i).map(([e,t])=>t===!0?`;${ah(e)}`:`;${ah(e)}=${nh(t)}`).join("")}function IE(i){return i instanceof Dn?`${nh(i.value)}${km(i.params)}`:nh(i)}function hL(i){return`(${i.value.map(IE).join(" ")})${km(i.params)}`}function fL(i,e={whitespace:!0}){if(typeof i!="object")throw Pi(i,Yk);const t=i instanceof Map?i.entries():Object.entries(i),s=e!=null&&e.whitespace?" ":"";return Array.from(t).map(([r,n])=>{n instanceof Dn||(n=new Dn(n));let a=ah(r);return n.value===!0?a+=km(n.params):(a+="=",Array.isArray(n.value)?a+=hL(n):a+=IE(n)),a}).join(`,${s}`)}function mL(i,e){return fL(i,e)}const pL=i=>i==="ot"||i==="sf"||i==="st",gL=i=>typeof i=="number"?j(i):i!=null&&i!==""&&i!==!1;function vL(i,e){const t=new URL(i),s=new URL(e);if(t.origin!==s.origin)return i;const r=t.pathname.split("/").slice(1),n=s.pathname.split("/").slice(1,-1);for(;r[0]===n[0];)r.shift(),n.shift();for(;n.length;)n.shift(),r.unshift("..");return r.join("/")}function EL(){try{return crypto.randomUUID()}catch{try{const e=URL.createObjectURL(new Blob),t=e.toString();return URL.revokeObjectURL(e),t.slice(t.lastIndexOf("/")+1)}catch{let t=new Date().getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const n=(t+Math.random()*16)%16|0;return t=Math.floor(t/16),(r=="x"?n:n&3|8).toString(16)})}}}const ol=i=>Math.round(i),bL=(i,e)=>(e!=null&&e.baseUrl&&(i=vL(i,e.baseUrl)),encodeURIComponent(i)),Ro=i=>ol(i/100)*100,yL={br:ol,d:ol,bl:Ro,dl:Ro,mtp:Ro,nor:bL,rtp:Ro,tb:ol};function TL(i,e){const t={};if(i==null||typeof i!="object")return t;const s=Object.keys(i).sort(),r=Ke({},yL,e==null?void 0:e.formatters),n=e==null?void 0:e.filter;return s.forEach(a=>{if(n!=null&&n(a))return;let o=i[a];const l=r[a];l&&(o=l(o,e)),!(a==="v"&&o===1)&&(a=="pr"&&o===1||gL(o)&&(pL(a)&&typeof o=="string"&&(o=new xE(o)),t[a]=o))}),t}function RE(i,e={}){return i?mL(TL(i,e),Ke({whitespace:!1},e)):""}function _L(i,e={}){if(!i)return{};const t=Object.entries(i),s=Object.entries(qk).concat(Object.entries((e==null?void 0:e.customHeaderMap)||{})),r=t.reduce((n,a)=>{var o,l;const[d,c]=a,u=((o=s.find(h=>h[1].includes(d)))==null?void 0:o[0])||sr.REQUEST;return(l=n[u])!=null||(n[u]={}),n[u][d]=c,n},{});return Object.entries(r).reduce((n,[a,o])=>(n[a]=RE(o,e),n),{})}function AL(i,e,t){return Ke(i,_L(e,t))}const SL="CMCD";function xL(i,e={}){if(!i)return"";const t=RE(i,e);return`${SL}=${encodeURIComponent(t)}`}const F0=/CMCD=[^&#]+/;function kL(i,e,t){const s=xL(e,t);if(!s)return i;if(F0.test(i))return i.replace(F0,s);const r=i.includes("?")?"&":"?";return`${i}${r}${s}`}class LL{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=r=>{try{this.apply(r,{ot:Et.MANIFEST,su:!this.initialized})}catch(n){R.warn("Could not generate manifest CMCD data.",n)}},this.applyFragmentData=r=>{try{const n=r.frag,a=this.hls.levels[n.level],o=this.getObjectType(n),l={d:n.duration*1e3,ot:o};(o===Et.VIDEO||o===Et.AUDIO||o==Et.MUXED)&&(l.br=a.bitrate/1e3,l.tb=this.getTopBandwidth(o)/1e3,l.bl=this.getBufferLength(o)),this.apply(r,l)}catch(n){R.warn("Could not generate segment CMCD data.",n)}},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||EL(),this.cid=s.contentId,this.useHeaders=s.useHeaders===!0,this.includeKeys=s.includeKeys,this.registerListeners())}registerListeners(){const e=this.hls;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHED,this.onMediaDetached,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this)}unregisterListeners(){const e=this.hls;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHED,this.onMediaDetached,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this)}destroy(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=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,r;this.audioBuffer=(s=t.tracks.audio)==null?void 0:s.buffer,this.videoBuffer=(r=t.tracks.video)==null?void 0:r.buffer}createData(){var e;return{v:1,sf:rh.HLS,sid:this.sid,cid:this.cid,pr:(e=this.media)==null?void 0:e.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}}apply(e,t={}){Ke(t,this.createData());const s=t.ot===Et.INIT||t.ot===Et.VIDEO||t.ot===Et.MUXED;this.starved&&s&&(t.bs=!0,t.su=!0,this.starved=!1),t.su==null&&(t.su=this.buffering);const{includeKeys:r}=this;r&&(t=Object.keys(t).reduce((n,a)=>(r.includes(a)&&(n[a]=t[a]),n),{})),this.useHeaders?(e.headers||(e.headers={}),AL(e.headers,t)):e.url=kL(e.url,t)}getObjectType(e){const{type:t}=e;if(t==="subtitle")return Et.TIMED_TEXT;if(e.sn==="initSegment")return Et.INIT;if(t==="audio")return Et.AUDIO;if(t==="main")return this.hls.audioTracks.length?Et.VIDEO:Et.MUXED}getTopBandwidth(e){let t=0,s;const r=this.hls;if(e===Et.AUDIO)s=r.audioTracks;else{const n=r.maxAutoLevel,a=n>-1?n+1:r.levels.length;s=r.levels.slice(0,a)}for(const n of s)n.bitrate>t&&(t=n.bitrate);return t>0?t:NaN}getBufferLength(e){const t=this.hls.media,s=e===Et.AUDIO?this.audioBuffer:this.videoBuffer;return!s||!t?NaN:Le.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(n){this.loader=void 0,this.loader=new s(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}createFragmentLoader(){const{fLoader:e}=this.config,t=this.applyFragmentData,s=e||this.config.loader;return class{constructor(n){this.loader=void 0,this.loader=new s(n)}get stats(){return this.loader.stats}get context(){return this.loader.context}destroy(){this.loader.destroy()}abort(){this.loader.abort()}load(n,a,o){t(n),this.loader.load(n,a,o)}}}}const IL=3e5;class RL{constructor(e){this.hls=void 0,this.log=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.log=R.log.bind(R,"[content-steering]:"),this.registerListeners()}registerListeners(){const e=this.hls;e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.ERROR,this.onError,this)}unregisterListeners(){const e=this.hls;e&&(e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.ERROR,this.onError,this))}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)===mt.SendAlternateToPenaltyBox&&s.flags===Yt.MoveAllAlternatesMatchingHost){const r=this.levels;let n=this.pathwayPriority,a=this.pathwayId;if(t.context){const{groupId:o,pathwayId:l,type:d}=t.context;o&&r?a=this.getPathwayForGroupId(o,d,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&r&&(n=r.reduce((o,l)=>(o.indexOf(l.pathwayId)===-1&&o.push(l.pathwayId),o),[])),n&&n.length>1&&(this.updatePathwayPriority(n),s.resolved=this.pathwayId!==a),s.resolved||R.warn(`Could not resolve ${t.details} ("${t.error.message}") with content-steering for Pathway: ${a} levels: ${r&&r.length} priorities: ${JSON.stringify(n)} penalized: ${JSON.stringify(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 ${this.pathwayId}. Setting initial Pathway to "${s}"`),t=this.getLevelsForPathway(s),this.pathwayId=s}return t.length!==e.length?(this.log(`Found ${t.length}/${e.length} levels in Pathway "${this.pathwayId}"`),t):e}getLevelsForPathway(e){return this.levels===null?[]:this.levels.filter(t=>e===t.pathwayId)}updatePathwayPriority(e){this.pathwayPriority=e;let t;const s=this.penalizedPathways,r=performance.now();Object.keys(s).forEach(n=>{r-s[n]>IL&&delete s[n]});for(let n=0;n<e.length;n++){const a=e[n];if(a in s)continue;if(a===this.pathwayId)return;const o=this.hls.nextLoadLevel,l=this.hls.levels[o];if(t=this.getLevelsForPathway(a),t.length>0){this.log(`Setting Pathway to "${a}"`),this.pathwayId=a,jv(t),this.hls.trigger(E.LEVELS_UPDATED,{levels:t});const d=this.hls.levels[o];l&&d&&this.levels&&(d.attrs["STABLE-VARIANT-ID"]!==l.attrs["STABLE-VARIANT-ID"]&&d.bitrate!==l.bitrate&&this.log(`Unstable Pathways change from bitrate ${l.bitrate} to ${d.bitrate}`),this.hls.nextLoadLevel=o);break}}}getPathwayForGroupId(e,t,s){const r=this.getLevelsForPathway(s).concat(this.levels||[]);for(let n=0;n<r.length;n++)if(t===pe.AUDIO_TRACK&&r[n].hasAudioGroup(e)||t===pe.SUBTITLE_TRACK&&r[n].hasSubtitleGroup(e))return r[n].pathwayId;return s}clonePathways(e){const t=this.levels;if(!t)return;const s={},r={};e.forEach(n=>{const{ID:a,"BASE-ID":o,"URI-REPLACEMENT":l}=n;if(t.some(c=>c.pathwayId===a))return;const d=this.getLevelsForPathway(o).map(c=>{const u=new Oe(c.attrs);u["PATHWAY-ID"]=a;const h=u.AUDIO&&`${u.AUDIO}_clone_${a}`,f=u.SUBTITLES&&`${u.SUBTITLES}_clone_${a}`;h&&(s[u.AUDIO]=h,u.AUDIO=h),f&&(r[u.SUBTITLES]=f,u.SUBTITLES=f);const m=wE(c.uri,u["STABLE-VARIANT-ID"],"PER-VARIANT-URIS",l),p=new wn({attrs:u,audioCodec:c.audioCodec,bitrate:c.bitrate,height:c.height,name:c.name,url:m,videoCodec:c.videoCodec,width:c.width});if(c.audioGroups)for(let g=1;g<c.audioGroups.length;g++)p.addGroupId("audio",`${c.audioGroups[g]}_clone_${a}`);if(c.subtitleGroups)for(let g=1;g<c.subtitleGroups.length;g++)p.addGroupId("text",`${c.subtitleGroups[g]}_clone_${a}`);return p});t.push(...d),$0(this.audioTracks,s,l,a),$0(this.subtitleTracks,r,l,a)})}loadSteeringManifest(e){const t=this.hls.config,s=t.loader;this.loader&&this.loader.destroy(),this.loader=new s(t);let r;try{r=new self.URL(e)}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest URI: ${e}`);return}if(r.protocol!=="data:"){const c=(this.hls.bandwidthEstimate||t.abrEwmaDefaultEstimate)|0;r.searchParams.set("_HLS_pathway",this.pathwayId),r.searchParams.set("_HLS_throughput",""+c)}const n={responseType:"json",url:r.href},a=t.steeringManifestLoadPolicy.default,o=a.errorRetry||a.timeoutRetry||{},l={loadPolicy:a,timeout:a.maxLoadTimeMs,maxRetry:o.maxNumRetry||0,retryDelay:o.retryDelayMs||0,maxRetryDelay:o.maxRetryDelayMs||0},d={onSuccess:(c,u,h,f)=>{this.log(`Loaded steering manifest: "${r}"`);const m=c.data;if(m.VERSION!==1){this.log(`Steering VERSION ${m.VERSION} not supported!`);return}this.updated=performance.now(),this.timeToLoad=m.TTL;const{"RELOAD-URI":p,"PATHWAY-CLONES":g,"PATHWAY-PRIORITY":v}=m;if(p)try{this.uri=new self.URL(p,r).href}catch{this.enabled=!1,this.log(`Failed to parse Steering Manifest RELOAD-URI: ${p}`);return}this.scheduleRefresh(this.uri||h.url),g&&this.clonePathways(g);const y={steeringManifest:m,url:r.toString()};this.hls.trigger(E.STEERING_MANIFEST_LOADED,y),v&&this.updatePathwayPriority(v)},onError:(c,u,h,f)=>{if(this.log(`Error loading steering manifest: ${c.code} ${c.text} (${u.url})`),this.stopLoad(),c.code===410){this.enabled=!1,this.log(`Steering manifest ${u.url} no longer available`);return}let m=this.timeToLoad*1e3;if(c.code===429){const p=this.loader;if(typeof(p==null?void 0:p.getResponseHeader)=="function"){const g=p.getResponseHeader("Retry-After");g&&(m=parseFloat(g)*1e3)}this.log(`Steering manifest ${u.url} rate limited`);return}this.scheduleRefresh(this.uri||u.url,m)},onTimeout:(c,u,h)=>{this.log(`Timeout loading steering manifest (${u.url})`),this.scheduleRefresh(this.uri||u.url)}};this.log(`Requesting steering manifest: ${r}`),this.loader.load(n,l,d)}scheduleRefresh(e,t=this.timeToLoad*1e3){this.clearTimeout(),this.reloadTimer=self.setTimeout(()=>{var s;const r=(s=this.hls)==null?void 0:s.media;if(r&&!r.ended){this.loadSteeringManifest(e);return}this.scheduleRefresh(e,this.timeToLoad*1e3)},t)}}function $0(i,e,t,s){i&&Object.keys(e).forEach(r=>{const n=i.filter(a=>a.groupId===r).map(a=>{const o=Ke({},a);return o.details=void 0,o.attrs=new Oe(o.attrs),o.url=o.attrs.URI=wE(a.url,a.attrs["STABLE-RENDITION-ID"],"PER-RENDITION-URIS",t),o.groupId=o.attrs["GROUP-ID"]=e[r],o.attrs["PATHWAY-ID"]=s,o});i.push(...n)})}function wE(i,e,t,s){const{HOST:r,PARAMS:n,[t]:a}=s;let o;e&&(o=a==null?void 0:a[e],o&&(i=o));const l=new self.URL(i);return r&&!o&&(l.host=r),n&&Object.keys(n).sort().forEach(d=>{d&&l.searchParams.set(d,n[d])}),l.href}const wL=/^age:\s*[\d.]+\s*$/im;class CE{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 kc,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,r=this.stats;r.loading.first=0,r.loaded=0,r.aborted=!1;const n=this.xhrSetup;n?Promise.resolve().then(()=>{if(!(this.loader!==s||this.stats.aborted))return n(s,t.url)}).catch(a=>{if(!(this.loader!==s||this.stats.aborted))return s.open("GET",t.url,!0),n(s,t.url)}).then(()=>{this.loader!==s||this.stats.aborted||this.openAndSendXhr(s,t,e)}).catch(a=>{this.callbacks.onError({code:s.status,text:a.message},t,s,r)}):this.openAndSendXhr(s,t,e)}openAndSendXhr(e,t,s){e.readyState||e.open("GET",t.url,!0);const r=t.headers,{maxTimeToFirstByteMs:n,maxLoadTimeMs:a}=s.loadPolicy;if(r)for(const o in r)e.setRequestHeader(o,r[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=n&&j(n)?n:a,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 r=t.readyState,n=this.config;if(!s.aborted&&r>=2&&(s.loading.first===0&&(s.loading.first=Math.max(self.performance.now(),s.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(s.loading.first-s.loading.start)))),r===4)){self.clearTimeout(this.requestTimeout),t.onreadystatechange=null,t.onprogress=null;const a=t.status,o=t.responseType!=="text";if(a>=200&&a<300&&(o&&t.response||t.responseText!==null)){s.loading.end=Math.max(self.performance.now(),s.loading.first);const l=o?t.response:t.responseText,d=t.responseType==="arraybuffer"?l.byteLength:l.length;if(s.loaded=s.total=d,s.bwEstimate=s.total*8e3/(s.loading.end-s.loading.first),!this.callbacks)return;const c=this.callbacks.onProgress;if(c&&c(s,e,l,t),!this.callbacks)return;const u={url:t.responseURL,data:l,code:a};this.callbacks.onSuccess(u,s,e,t)}else{const l=n.loadPolicy.errorRetry,d=s.retry,c={url:e.url,data:void 0,code:a};Wd(l,d,!1,c)?this.retry(l):(R.error(`${a} while loading ${e.url}`),this.callbacks.onError({code:a,text:t.statusText},e,t,s))}}}loadtimeout(){if(!this.config)return;const e=this.config.loadPolicy.timeoutRetry,t=this.stats.retry;if(Wd(e,t,!0))this.retry(e);else{var s;R.warn(`timeout while loading ${(s=this.context)==null?void 0:s.url}`);const r=this.callbacks;r&&(this.abortInternal(),r.onTimeout(this.stats,this.context,this.loader))}}retry(e){const{context:t,stats:s}=this;this.retryDelay=fm(e,s.retry),s.retry++,R.warn(`${status?"HTTP Status "+status:"Timeout"} while loading ${t==null?void 0:t.url}, retrying ${s.retry}/${e.maxNumRetry} in ${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&&wL.test(this.loader.getAllResponseHeaders())){const t=this.loader.getResponseHeader("age");e=t?parseFloat(t):null}return e}getResponseHeader(e){return this.loader&&new RegExp(`^${e}:\\s*[\\d.]+\\s*$`,"im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(e):null}}function CL(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch{}return!1}const DL=/(\d+)-(\d+)\/(\d+)/;class B0{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||NL,this.controller=new self.AbortController,this.stats=new kc}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 r=this.stats;if(r.loading.start)throw new Error("Loader can only be used once.");r.loading.start=self.performance.now();const n=ML(e,this.controller.signal),a=s.onProgress,o=e.responseType==="arraybuffer",l=o?"byteLength":"length",{maxTimeToFirstByteMs:d,maxLoadTimeMs:c}=t.loadPolicy;this.context=e,this.config=t,this.callbacks=s,this.request=this.fetchSetup(e,n),self.clearTimeout(this.requestTimeout),t.timeout=d&&j(d)?d:c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},t.timeout),self.fetch(this.request).then(u=>{this.response=this.loader=u;const h=Math.max(self.performance.now(),r.loading.start);if(self.clearTimeout(this.requestTimeout),t.timeout=c,this.requestTimeout=self.setTimeout(()=>{this.abortInternal(),s.onTimeout(r,e,this.response)},c-(h-r.loading.start)),!u.ok){const{status:f,statusText:m}=u;throw new UL(m||"fetch, bad network response",f,u)}return r.loading.first=h,r.total=PL(u.headers)||r.total,a&&j(t.highWaterMark)?this.loadProgressively(u,r,e,t.highWaterMark,a):o?u.arrayBuffer():e.responseType==="json"?u.json():u.text()}).then(u=>{const h=this.response;if(!h)throw new Error("loader destroyed");self.clearTimeout(this.requestTimeout),r.loading.end=Math.max(self.performance.now(),r.loading.first);const f=u[l];f&&(r.loaded=r.total=f);const m={url:h.url,data:u,code:h.status};a&&!j(t.highWaterMark)&&a(r,e,u,h),s.onSuccess(m,r,e,h)}).catch(u=>{if(self.clearTimeout(this.requestTimeout),r.aborted)return;const h=u&&u.code||0,f=u?u.message:null;s.onError({code:h,text:f},e,u?u.details:null,r)})}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,r=0,n){const a=new Zv,o=e.body.getReader(),l=()=>o.read().then(d=>{if(d.done)return a.dataLength&&n(t,s,a.flush(),e),Promise.resolve(new ArrayBuffer(0));const c=d.value,u=c.length;return t.loaded+=u,u<r||a.dataLength?(a.push(c),a.dataLength>=r&&n(t,s,a.flush(),e)):n(t,s,c,e),l()}).catch(()=>Promise.reject());return l()}}function ML(i,e){const t={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(Ke({},i.headers))};return i.rangeEnd&&t.headers.set("Range","bytes="+i.rangeStart+"-"+String(i.rangeEnd-1)),t}function OL(i){const e=DL.exec(i);if(e)return parseInt(e[2])-parseInt(e[1])+1}function PL(i){const e=i.get("Content-Range");if(e){const s=OL(e);if(j(s))return s}const t=i.get("Content-Length");if(t)return parseInt(t)}function NL(i,e){return new self.Request(i.url,e)}class UL extends Error{constructor(e,t,s){super(e),this.code=void 0,this.details=void 0,this.code=t,this.details=s}}const FL=/\s/,$L={newCue(i,e,t,s){const r=[];let n,a,o,l,d;const c=self.VTTCue||self.TextTrackCue;for(let h=0;h<s.rows.length;h++)if(n=s.rows[h],o=!0,l=0,d="",!n.isEmpty()){var u;for(let p=0;p<n.chars.length;p++)FL.test(n.chars[p].uchar)&&o?l++:(d+=n.chars[p].uchar,o=!1);n.cueStartTime=e,e===t&&(t+=1e-4),l>=16?l--:l++;const f=yE(d.trim()),m=Sm(e,t,f);i!=null&&(u=i.cues)!=null&&u.getCueById(m)||(a=new c(e,t,f),a.id=m,a.line=h+1,a.align="left",a.position=10+Math.min(80,Math.floor(l*8/32)*10),r.push(a))}return i&&r.length&&(r.sort((h,f)=>h.line==="auto"||f.line==="auto"?0:h.line>8&&f.line>8?f.line-h.line:h.line-f.line),r.forEach(h=>Kv(i,h))),r}},BL={maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null},DE=dt(dt({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:60*1e3*1e3,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,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,loader:CE,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:fx,bufferController:vk,capLevelController:xm,errorController:tx,fpsController:Vk,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:wv,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:BL},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}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},GL()),{},{subtitleStreamController:fk,subtitleTrackController:pk,timelineController:Wk,audioStreamController:uk,audioTrackController:hk,emeController:bn,cmcdController:LL,contentSteeringController:RL});function GL(){return{cueHandler:$L,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 HL(i,e){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 t=oh(i),s=["manifest","level","frag"],r=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return s.forEach(n=>{const a=`${n==="level"?"playlist":n}LoadPolicy`,o=e[a]===void 0,l=[];r.forEach(d=>{const c=`${n}Loading${d}`,u=e[c];if(u!==void 0&&o){l.push(c);const h=t[a].default;switch(e[a]={default:h},d){case"TimeOut":h.maxLoadTimeMs=u,h.maxTimeToFirstByteMs=u;break;case"MaxRetry":h.errorRetry.maxNumRetry=u,h.timeoutRetry.maxNumRetry=u;break;case"RetryDelay":h.errorRetry.retryDelayMs=u,h.timeoutRetry.retryDelayMs=u;break;case"MaxRetryTimeout":h.errorRetry.maxRetryDelayMs=u,h.timeoutRetry.maxRetryDelayMs=u;break}}}),l.length&&R.warn(`hls.js config: "${l.join('", "')}" setting(s) are deprecated, use "${a}": ${JSON.stringify(e[a])}`)}),dt(dt({},t),e)}function oh(i){return i&&typeof i=="object"?Array.isArray(i)?i.map(oh):Object.keys(i).reduce((e,t)=>(e[t]=oh(i[t]),e),{}):i}function WL(i){const e=i.loader;e!==B0&&e!==CE?(R.log("[config]: Custom loader detected, cannot enable progressive streaming"),i.progressive=!1):CL()&&(i.loader=B0,i.progressive=!0,i.enableSoftwareAES=!0,R.log("[config]: Progressive streaming enabled, using FetchLoader"))}let fu;class KL extends mm{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(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this),e.on(E.ERROR,this.onError,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_LOADED,this.onManifestLoaded,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this),e.off(E.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,r=[],n={},a={};let o=!1,l=!1,d=!1;t.levels.forEach(c=>{var u,h;const f=c.attrs;let{audioCodec:m,videoCodec:p}=c;((u=m)==null?void 0:u.indexOf("mp4a.40.34"))!==-1&&(fu||(fu=/chrome|firefox/i.test(navigator.userAgent)),fu&&(c.audioCodec=m=void 0)),m&&(c.audioCodec=m=Bd(m,s)),((h=p)==null?void 0:h.indexOf("avc1"))===0&&(p=c.videoCodec=wS(p));const{width:g,height:v,unknownCodecs:y}=c;if(o||(o=!!(g&&v)),l||(l=!!p),d||(d=!!m),y!=null&&y.length||m&&!Zc(m,"audio",s)||p&&!Zc(p,"video",s))return;const{CODECS:b,"FRAME-RATE":x,"HDCP-LEVEL":_,"PATHWAY-ID":S,RESOLUTION:A,"VIDEO-RANGE":D}=f,L=`${`${S||"."}-`}${c.bitrate}-${A}-${x}-${b}-${D}-${_}`;if(n[L])if(n[L].uri!==c.url&&!c.attrs["PATHWAY-ID"]){const C=a[L]+=1;c.attrs["PATHWAY-ID"]=new Array(C+1).join(".");const H=new wn(c);n[L]=H,r.push(H)}else n[L].addGroupId("audio",f.AUDIO),n[L].addGroupId("text",f.SUBTITLES);else{const C=new wn(c);n[L]=C,a[L]=1,r.push(C)}}),this.filterAndSortMediaOptions(r,t,o,l,d)}filterAndSortMediaOptions(e,t,s,r,n){let a=[],o=[],l=e;if((s||r)&&n&&(l=l.filter(({videoCodec:m,videoRange:p,width:g,height:v})=>(!!m||!!(g&&v))&&WS(p))),l.length===0){Promise.resolve().then(()=>{if(this.hls){t.levels.length&&this.warn(`One or more CODECS in variant not supported: ${JSON.stringify(t.levels[0].attrs)}`);const m=new Error("no level with compatible codecs found in manifest");this.hls.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:t.url,error:m,reason:m.message})}});return}if(t.audioTracks){const{preferManagedMediaSource:m}=this.hls.config;a=t.audioTracks.filter(p=>!p.audioCodec||Zc(p.audioCodec,"audio",m)),G0(a)}t.subtitles&&(o=t.subtitles,G0(o));const d=l.slice(0);l.sort((m,p)=>{if(m.attrs["HDCP-LEVEL"]!==p.attrs["HDCP-LEVEL"])return(m.attrs["HDCP-LEVEL"]||"")>(p.attrs["HDCP-LEVEL"]||"")?1:-1;if(s&&m.height!==p.height)return m.height-p.height;if(m.frameRate!==p.frameRate)return m.frameRate-p.frameRate;if(m.videoRange!==p.videoRange)return Gd.indexOf(m.videoRange)-Gd.indexOf(p.videoRange);if(m.videoCodec!==p.videoCodec){const g=jp(m.videoCodec),v=jp(p.videoCodec);if(g!==v)return v-g}if(m.uri===p.uri&&m.codecSet!==p.codecSet){const g=$d(m.codecSet),v=$d(p.codecSet);if(g!==v)return v-g}return m.averageBitrate!==p.averageBitrate?m.averageBitrate-p.averageBitrate:0});let c=d[0];if(this.steering&&(l=this.steering.filterParsedLevels(l),l.length!==d.length)){for(let m=0;m<d.length;m++)if(d[m].pathwayId===l[0].pathwayId){c=d[m];break}}this._levels=l;for(let m=0;m<l.length;m++)if(l[m]===c){var u;this._firstLevel=m;const p=c.bitrate,g=this.hls.bandwidthEstimate;if(this.log(`manifest loaded, ${l.length} level(s) found, first bitrate: ${p}`),((u=this.hls.userConfig)==null?void 0:u.abrEwmaDefaultEstimate)===void 0){const v=Math.min(p,this.hls.config.abrEwmaDefaultEstimateMax);v>g&&g===DE.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=v)}break}const h=n&&!r,f={levels:l,audioTracks:a,subtitleTracks:o,sessionData:t.sessionData,sessionKeys:t.sessionKeys,firstLevel:this._firstLevel,stats:t.stats,audio:n,video:r,altAudio:!h&&a.some(m=>!!m.url)};this.hls.trigger(E.MANIFEST_PARSED,f),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}get levels(){return this._levels.length===0?null:this._levels}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(E.ERROR,{type:se.OTHER_ERROR,details:M.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,r=this.currentLevel,n=r?r.attrs["PATHWAY-ID"]:void 0,a=t[e],o=a.attrs["PATHWAY-ID"];if(this.currentLevelIndex=e,this.currentLevel=a,s===e&&a.details&&r&&n===o)return;this.log(`Switching to level ${e} (${a.height?a.height+"p ":""}${a.videoRange?a.videoRange+" ":""}${a.codecSet?a.codecSet+" ":""}@${a.bitrate})${o?" with Pathway "+o:""} from level ${s}${n?" with Pathway "+n:""}`);const l={level:e,attrs:a.attrs,details:a.details,bitrate:a.bitrate,averageBitrate:a.averageBitrate,maxBitrate:a.maxBitrate,realBitrate:a.realBitrate,width:a.width,height:a.height,codecSet:a.codecSet,audioCodec:a.audioCodec,videoCodec:a.videoCodec,audioGroups:a.audioGroups,subtitleGroups:a.subtitleGroups,loaded:a.loaded,loadError:a.loadError,fragmentError:a.fragmentError,name:a.name,id:a.id,uri:a.uri,url:a.url,urlId:0,audioGroupIds:a.audioGroupIds,textGroupIds:a.textGroupIds};this.hls.trigger(E.LEVEL_SWITCHING,l);const d=a.details;if(!d||d.live){const c=this.switchParams(a.uri,r==null?void 0:r.details,d);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}onError(e,t){t.fatal||!t.context||t.context.type===pe.LEVEL&&t.context.level===this.level&&this.checkRetry(t)}onFragBuffered(e,{frag:t}){if(t!==void 0&&t.type===te.MAIN){const s=t.elementaryStreams;if(!Object.keys(s).some(n=>!!s[n]))return;const r=this._levels[t.level];r!=null&&r.loadError&&(this.log(`Resetting level error count of ${r.loadError} on frag buffered`),r.loadError=0)}}onLevelLoaded(e,t){var s;const{level:r,details:n}=t,a=this._levels[r];if(!a){var o;this.warn(`Invalid level index ${r}`),(o=t.deliveryDirectives)!=null&&o.skip&&(n.deltaUpdateFailed=!0);return}r===this.currentLevelIndex?(a.fragmentError===0&&(a.loadError=0),this.playlistLoaded(r,t,a.details)):(s=t.deliveryDirectives)!=null&&s.skip&&(n.deltaUpdateFailed=!0)}loadPlaylist(e){super.loadPlaylist();const t=this.currentLevelIndex,s=this.currentLevel;if(s&&this.shouldLoadPlaylist(s)){let r=s.uri;if(e)try{r=e.addDirectives(r)}catch(a){this.warn(`Could not construct new URL with HLS Delivery Directives: ${a}`)}const n=s.attrs["PATHWAY-ID"];this.log(`Loading level index ${t}${(e==null?void 0:e.msn)!==void 0?" at sn "+e.msn+" part "+e.part:""} with${n?" Pathway "+n:""} ${r}`),this.clearTimer(),this.hls.trigger(E.LEVEL_LOADING,{url:r,level:t,pathwayId:s.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||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;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(a=>a.level=-1)),!1));jv(s),this._levels=s,this.currentLevelIndex>-1&&(t=this.currentLevel)!=null&&t.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(E.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(E.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:t,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:s}))}}function G0(i){const e={};i.forEach(t=>{const s=t.groupId||"";t.id=e[s]=e[s]||0,e[s]++})}class VL{constructor(e){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=e}abort(e){for(const s in this.keyUriToKeyInfo){const r=this.keyUriToKeyInfo[s].loader;if(r){var t;if(e&&e!==((t=r.context)==null?void 0:t.frag.type))return;r.abort()}}}detach(){for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e];(t.mediaKeySessionContext||t.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[e]}}destroy(){this.detach();for(const e in this.keyUriToKeyInfo){const t=this.keyUriToKeyInfo[e].loader;t&&t.destroy()}this.keyUriToKeyInfo={}}createKeyLoadError(e,t=M.KEY_LOAD_ERROR,s,r,n){return new ji({type:se.NETWORK_ERROR,details:t,fatal:!1,frag:e,response:n,error:s,networkDetails:r})}loadClear(e,t){if(this.emeController&&this.config.emeEnabled){const{sn:s,cc:r}=e;for(let n=0;n<t.length;n++){const a=t[n];if(r<=a.cc&&(s==="initSegment"||a.sn==="initSegment"||s<a.sn)){this.emeController.selectKeySystemFormat(a).then(o=>{a.setKeyFormat(o)});break}}}}load(e){return!e.decryptdata&&e.encrypted&&this.emeController?this.emeController.selectKeySystemFormat(e).then(t=>this.loadInternal(e,t)):this.loadInternal(e)}loadInternal(e,t){var s,r;t&&e.setKeyFormat(t);const n=e.decryptdata;if(!n){const d=new Error(t?`Expected frag.decryptdata to be defined after setting format ${t}`:"Missing decryption data on fragment in onKeyLoading");return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,d))}const a=n.uri;if(!a)return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Invalid key URI: "${a}"`)));let o=this.keyUriToKeyInfo[a];if((s=o)!=null&&s.decryptdata.key)return n.key=o.decryptdata.key,Promise.resolve({frag:e,keyInfo:o});if((r=o)!=null&&r.keyLoadPromise){var l;switch((l=o.mediaKeySessionContext)==null?void 0:l.keyStatus){case void 0:case"status-pending":case"usable":case"usable-in-future":return o.keyLoadPromise.then(d=>(n.key=d.keyInfo.decryptdata.key,{frag:e,keyInfo:o}))}}switch(o=this.keyUriToKeyInfo[a]={decryptdata:n,keyLoadPromise:null,loader:null,mediaKeySessionContext:null},n.method){case"ISO-23001-7":case"SAMPLE-AES":case"SAMPLE-AES-CENC":case"SAMPLE-AES-CTR":return n.keyFormat==="identity"?this.loadKeyHTTP(o,e):this.loadKeyEME(o,e);case"AES-128":return this.loadKeyHTTP(o,e);default:return Promise.reject(this.createKeyLoadError(e,M.KEY_LOAD_ERROR,new Error(`Key supplied with unsupported METHOD: "${n.method}"`)))}}loadKeyEME(e,t){const s={frag:t,keyInfo:e};if(this.emeController&&this.config.emeEnabled){const r=this.emeController.loadKey(s);if(r)return(e.keyLoadPromise=r.then(n=>(e.mediaKeySessionContext=n,s))).catch(n=>{throw e.keyLoadPromise=null,n})}return Promise.resolve(s)}loadKeyHTTP(e,t){const s=this.config,r=s.loader,n=new r(s);return t.keyLoader=e.loader=n,e.keyLoadPromise=new Promise((a,o)=>{const l={keyInfo:e,frag:t,responseType:"arraybuffer",url:e.decryptdata.uri},d=s.keyLoadPolicy.default,c={loadPolicy:d,timeout:d.maxLoadTimeMs,maxRetry:0,retryDelay:0,maxRetryDelay:0},u={onSuccess:(h,f,m,p)=>{const{frag:g,keyInfo:v,url:y}=m;if(!g.decryptdata||v!==this.keyUriToKeyInfo[y])return o(this.createKeyLoadError(g,M.KEY_LOAD_ERROR,new Error("after key load, decryptdata unset or changed"),p));v.decryptdata.key=g.decryptdata.key=new Uint8Array(h.data),g.keyLoader=null,v.loader=null,a({frag:g,keyInfo:v})},onError:(h,f,m,p)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_ERROR,new Error(`HTTP Error ${h.code} loading key ${h.text}`),m,dt({url:l.url,data:void 0},h)))},onTimeout:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.KEY_LOAD_TIMEOUT,new Error("key loading timed out"),m))},onAbort:(h,f,m)=>{this.resetLoader(f),o(this.createKeyLoadError(t,M.INTERNAL_ABORTED,new Error("key loading aborted"),m))}};n.load(l,c,u)})}resetLoader(e){const{frag:t,keyInfo:s,url:r}=e,n=s.loader;t.keyLoader===n&&(t.keyLoader=null,s.loader=null),delete this.keyUriToKeyInfo[r],n&&n.destroy()}}function ME(){return self.SourceBuffer||self.WebKitSourceBuffer}function OE(){if(!_r())return!1;const e=ME();return!e||e.prototype&&typeof e.prototype.appendBuffer=="function"&&typeof e.prototype.remove=="function"}function qL(){if(!OE())return!1;const i=_r();return typeof(i==null?void 0:i.isTypeSupported)=="function"&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some(e=>i.isTypeSupported(za(e,"video")))||["mp4a.40.2","fLaC"].some(e=>i.isTypeSupported(za(e,"audio"))))}function YL(){var i;const e=ME();return typeof(e==null||(i=e.prototype)==null?void 0:i.changeType)=="function"}const jL=250,ll=2,zL=.1,XL=.05;class QL{constructor(e,t,s,r){this.config=void 0,this.media=null,this.fragmentTracker=void 0,this.hls=void 0,this.nudgeRetry=0,this.stallReported=!1,this.stalled=null,this.moved=!1,this.seeking=!1,this.config=e,this.media=t,this.fragmentTracker=s,this.hls=r}destroy(){this.media=null,this.hls=this.fragmentTracker=null}poll(e,t){const{config:s,media:r,stalled:n}=this;if(r===null)return;const{currentTime:a,seeking:o}=r,l=this.seeking&&!o,d=!this.seeking&&o;if(this.seeking=o,a!==e){if(this.moved=!0,o||(this.nudgeRetry=0),n!==null){if(this.stallReported){const g=self.performance.now()-n;R.warn(`playback not stuck anymore @${a}, after ${Math.round(g)}ms`),this.stallReported=!1}this.stalled=null}return}if(d||l){this.stalled=null;return}if(r.paused&&!o||r.ended||r.playbackRate===0||!Le.getBuffered(r).length){this.nudgeRetry=0;return}const c=Le.bufferInfo(r,a,0),u=c.nextStart||0;if(o){const g=c.len>ll,v=!u||t&&t.start<=a||u-a>ll&&!this.fragmentTracker.getPartialFragment(a);if(g||v)return;this.moved=!1}if(!this.moved&&this.stalled!==null){var h;if(!(c.len>0)&&!u)return;const v=Math.max(u,c.start||0)-a,y=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,x=(y==null||(h=y.details)==null?void 0:h.live)?y.details.targetduration*2:ll,_=this.fragmentTracker.getPartialFragment(a);if(v>0&&(v<=x||_)){r.paused||this._trySkipBufferHole(_);return}}const f=self.performance.now();if(n===null){this.stalled=f;return}const m=f-n;if(!o&&m>=jL&&(this._reportStall(c),!this.media))return;const p=Le.bufferInfo(r,a,s.maxBufferHole);this._tryFixBufferStall(p,m)}_tryFixBufferStall(e,t){const{config:s,fragmentTracker:r,media:n}=this;if(n===null)return;const a=n.currentTime,o=r.getPartialFragment(a);o&&(this._trySkipBufferHole(o)||!this.media)||(e.len>s.maxBufferHole||e.nextStart&&e.nextStart-a<s.maxBufferHole)&&t>s.highBufferWatchdogPeriod*1e3&&(R.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}_reportStall(e){const{hls:t,media:s,stallReported:r}=this;if(!r&&s){this.stallReported=!0;const n=new Error(`Playback stalling at @${s.currentTime} due to low buffer (${JSON.stringify(e)})`);R.warn(n.message),t.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,fatal:!1,error:n,buffer:e.len})}}_trySkipBufferHole(e){const{config:t,hls:s,media:r}=this;if(r===null)return 0;const n=r.currentTime,a=Le.bufferInfo(r,n,0),o=n<a.start?a.start:a.nextStart;if(o){const l=a.len<=t.maxBufferHole,d=a.len>0&&a.len<1&&r.readyState<3,c=o-n;if(c>0&&(l||d)){if(c>t.maxBufferHole){const{fragmentTracker:h}=this;let f=!1;if(n===0){const m=h.getAppendedFrag(0,te.MAIN);m&&o<m.end&&(f=!0)}if(!f){const m=e||h.getAppendedFrag(n,te.MAIN);if(m){let p=!1,g=m.end;for(;g<o;){const v=h.getPartialFragment(g);if(v)g+=v.duration;else{p=!0;break}}if(p)return 0}}}const u=Math.max(o+XL,n+zL);if(R.warn(`skipping hole, adjusting currentTime from ${n} to ${u}`),this.moved=!0,this.stalled=null,r.currentTime=u,e&&!e.gap){const h=new Error(`fragment loaded with buffer holes, seeking from ${n} to ${u}`);s.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_SEEK_OVER_HOLE,fatal:!1,error:h,reason:h.message,frag:e})}return u}}return 0}_tryNudgeBuffer(){const{config:e,hls:t,media:s,nudgeRetry:r}=this;if(s===null)return;const n=s.currentTime;if(this.nudgeRetry++,r<e.nudgeMaxRetry){const a=n+(r+1)*e.nudgeOffset,o=new Error(`Nudging 'currentTime' from ${n} to ${a}`);R.warn(o.message),s.currentTime=a,t.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_NUDGE_ON_STALL,error:o,fatal:!1})}else{const a=new Error(`Playhead still not moving while enough data buffered @${n} after ${e.nudgeMaxRetry} nudges`);R.error(a.message),t.trigger(E.ERROR,{type:se.MEDIA_ERROR,details:M.BUFFER_STALLED_ERROR,error:a,fatal:!0})}}}const ZL=100;class JL extends vm{constructor(e,t,s){super(e,t,s,"[stream-controller]",te.MAIN),this.audioCodecSwap=!1,this.gapController=null,this.level=-1,this._forceStartLoad=!1,this.altAudio=!1,this.audioOnly=!1,this.fragPlaying=null,this.onvplaying=null,this.onvseeked=null,this.fragLastKbps=0,this.couldBacktrack=!1,this.backtrackFragment=null,this.audioCodecSwitch=!1,this.videoBuffer=null,this._registerListeners()}_registerListeners(){const{hls:e}=this;e.on(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.on(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.on(E.MANIFEST_LOADING,this.onManifestLoading,this),e.on(E.MANIFEST_PARSED,this.onManifestParsed,this),e.on(E.LEVEL_LOADING,this.onLevelLoading,this),e.on(E.LEVEL_LOADED,this.onLevelLoaded,this),e.on(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.on(E.ERROR,this.onError,this),e.on(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.on(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.on(E.BUFFER_CREATED,this.onBufferCreated,this),e.on(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.on(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.on(E.FRAG_BUFFERED,this.onFragBuffered,this)}_unregisterListeners(){const{hls:e}=this;e.off(E.MEDIA_ATTACHED,this.onMediaAttached,this),e.off(E.MEDIA_DETACHING,this.onMediaDetaching,this),e.off(E.MANIFEST_LOADING,this.onManifestLoading,this),e.off(E.MANIFEST_PARSED,this.onManifestParsed,this),e.off(E.LEVEL_LOADED,this.onLevelLoaded,this),e.off(E.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),e.off(E.ERROR,this.onError,this),e.off(E.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),e.off(E.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),e.off(E.BUFFER_CREATED,this.onBufferCreated,this),e.off(E.BUFFER_FLUSHED,this.onBufferFlushed,this),e.off(E.LEVELS_UPDATED,this.onLevelsUpdated,this),e.off(E.FRAG_BUFFERED,this.onFragBuffered,this)}onHandlerDestroying(){this._unregisterListeners(),super.onHandlerDestroying()}startLoad(e){if(this.levels){const{lastCurrentTime:t,hls:s}=this;if(this.stopLoad(),this.setInterval(ZL),this.level=-1,!this.startFragRequested){let r=s.startLevel;r===-1&&(s.config.testBandwidth&&this.levels.length>1?(r=0,this.bitrateTest=!0):r=s.firstAutoLevel),s.nextLoadLevel=r,this.level=s.loadLevel,this.loadedmetadata=!1}t>0&&e===-1&&(this.log(`Override startPosition with lastCurrentTime @${t.toFixed(3)}`),e=t),this.state=N.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=e,this.tick()}else this._forceStartLoad=!0,this.state=N.STOPPED}stopLoad(){this._forceStartLoad=!1,super.stopLoad()}doTick(){switch(this.state){case N.WAITING_LEVEL:{const{levels:t,level:s}=this,r=t==null?void 0:t[s],n=r==null?void 0:r.details;if(n&&(!n.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(n))break;this.state=N.IDLE;break}else if(this.hls.nextLoadLevel!==this.level){this.state=N.IDLE;break}break}case N.FRAG_LOADING_WAITING_RETRY:{var e;const t=self.performance.now(),s=this.retryDate;if(!s||t>=s||(e=this.media)!=null&&e.seeking){const{levels:r,level:n}=this,a=r==null?void 0:r[n];this.resetStartWhenNotLoaded(a||null),this.state=N.IDLE}}break}this.state===N.IDLE&&this.doTickIdle(),this.onTickEnd()}onTickEnd(){super.onTickEnd(),this.checkBuffer(),this.checkFragmentChanged()}doTickIdle(){const{hls:e,levelLastLoaded:t,levels:s,media:r}=this;if(t===null||!r&&(this.startFragRequested||!e.config.startFragPrefetch)||this.altAudio&&this.audioOnly)return;const n=e.nextLoadLevel;if(!(s!=null&&s[n]))return;const a=s[n],o=this.getMainFwdBufferInfo();if(o===null)return;const l=this.getLevelDetails();if(l&&this._streamEnded(o,l)){const p={};this.altAudio&&(p.type="video"),this.hls.trigger(E.BUFFER_EOS,p),this.state=N.ENDED;return}e.loadLevel!==n&&e.manualLevel===-1&&this.log(`Adapting to level ${n} from level ${this.level}`),this.level=e.nextLoadLevel=n;const d=a.details;if(!d||this.state===N.WAITING_LEVEL||d.live&&this.levelLastLoaded!==a){this.level=n,this.state=N.WAITING_LEVEL;return}const c=o.len,u=this.getMaxBufferLength(a.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,d);if(this.couldBacktrack&&!this.fragPrevious&&f&&f.sn!=="initSegment"&&this.fragmentTracker.getState(f)!==rt.OK){var m;const g=((m=this.backtrackFragment)!=null?m:f).sn-d.startSN,v=d.fragments[g-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 g=this.audioOnly&&!this.altAudio?be.AUDIO:be.VIDEO,v=(g===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;v&&this.afterBufferFlushed(v,g,te.MAIN)}f=this.getNextFragmentLoopLoading(f,d,o,te.MAIN,u)}f&&(f.initSegment&&!f.initSegment.data&&!this.bitrateTest&&(f=f.initSegment),this.loadFragment(f,a,h))}loadFragment(e,t,s){const r=this.fragmentTracker.getState(e);this.fragCurrent=e,r===rt.NOT_LOADED||r===rt.PARTIAL?e.sn==="initSegment"?this._loadInitSegment(e,t):this.bitrateTest?(this.log(`Fragment ${e.sn} of level ${e.level} is being downloaded to test bitrate and will not be buffered`),this._loadBitrateTestFrag(e,t)):(this.startFragRequested=!0,super.loadFragment(e,t,s)):this.clearTrackerIfNeeded(e)}getBufferedFrag(e){return this.fragmentTracker.getBufferedFrag(e,te.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 r=this.getAppendedFrag(t.currentTime);r&&r.start>1&&this.flushMainBuffer(0,r.start-1);const n=this.getLevelDetails();if(n!=null&&n.live){const o=this.getMainFwdBufferInfo();if(!o||o.len<n.targetduration*2)return}if(!t.paused&&e){const o=this.hls.nextLoadLevel,l=e[o],d=this.fragLastKbps;d&&this.fragCurrent?s=this.fragCurrent.duration*l.maxBitrate/(1e3*d)+1:s=0}else s=0;const a=this.getBufferedFrag(t.currentTime+s);if(a){const o=this.followingBufferedFrag(a);if(o){this.abortCurrentFrag();const l=o.maxStartPTS?o.maxStartPTS:o.start,d=o.duration,c=Math.max(a.end,l+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(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 N.KEY_LOADING:case N.FRAG_LOADING:case N.FRAG_LOADING_WAITING_RETRY:case N.PARSING:case N.PARSED:this.state=N.IDLE;break}this.nextLoadPosition=this.getLoadPosition()}flushMainBuffer(e,t){super.flushMainBuffer(e,t,this.altAudio?"video":null)}onMediaAttached(e,t){super.onMediaAttached(e,t);const s=t.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),s.addEventListener("playing",this.onvplaying),s.addEventListener("seeked",this.onvseeked),this.gapController=new QL(this.config,s,this.fragmentTracker,this.hls)}onMediaDetaching(){const{media:e}=this;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),super.onMediaDetaching()}onMediaPlaying(){this.tick()}onMediaSeeked(){const e=this.media,t=e?e.currentTime:null;j(t)&&this.log(`Media seeked to ${t.toFixed(3)}`);const s=this.getMainFwdBufferInfo();if(s===null||s.len===0){this.warn(`Main forward buffer length on "seeked" event ${s?s.len:"empty"})`);return}this.tick()}onManifestLoading(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(E.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1}onManifestParsed(e,t){let s=!1,r=!1;t.levels.forEach(n=>{const a=n.audioCodec;a&&(s=s||a.indexOf("mp4a.40.2")!==-1,r=r||a.indexOf("mp4a.40.5")!==-1)}),this.audioCodecSwitch=s&&r&&!YL(),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!==N.IDLE)return;const r=s[t.level];(!r.details||r.details.live&&this.levelLastLoaded!==r||this.waitForCdnTuneIn(r.details))&&(this.state=N.WAITING_LEVEL)}onLevelLoaded(e,t){var s;const{levels:r}=this,n=t.level,a=t.details,o=a.totalduration;if(!r){this.warn(`Levels were reset while loading level ${n}`);return}this.log(`Level ${n} loaded [${a.startSN},${a.endSN}]${a.lastPartSn?`[part-${a.lastPartSn}-${a.lastPartIndex}]`:""}, cc [${a.startCC}, ${a.endCC}] duration:${o}`);const l=r[n],d=this.fragCurrent;d&&(this.state===N.FRAG_LOADING||this.state===N.FRAG_LOADING_WAITING_RETRY)&&d.level!==t.level&&d.loader&&this.abortCurrentFrag();let c=0;if(a.live||(s=l.details)!=null&&s.live){var u;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;c=this.alignPlaylists(a,l.details,(u=this.levelLastLoaded)==null?void 0:u.details)}if(l.details=a,this.levelLastLoaded=l,this.hls.trigger(E.LEVEL_UPDATED,{details:a,level:n}),this.state===N.WAITING_LEVEL){if(this.waitForCdnTuneIn(a))return;this.state=N.IDLE}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,c),this.tick()}_handleFragmentLoadProgress(e){var t;const{frag:s,part:r,payload:n}=e,{levels:a}=this;if(!a){this.warn(`Levels were reset while fragment load was in progress. Fragment ${s.sn} of level ${s.level} will not be buffered`);return}const o=a[s.level],l=o.details;if(!l){this.warn(`Dropping fragment ${s.sn} of level ${s.level} after level details were reset`),this.fragmentTracker.removeFragment(s);return}const d=o.videoCodec,c=l.PTSKnown||!l.live,u=(t=s.initSegment)==null?void 0:t.data,h=this._getAudioCodec(o),f=this.transmuxer=this.transmuxer||new mE(this.hls,te.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),m=r?r.index:-1,p=m!==-1,g=new pm(s.level,s.sn,s.stats.chunkCount,n.byteLength,m,p),v=this.initPTS[s.cc];f.push(n,u,h,d,s,r,l.totalduration,c,g,v)}onAudioTrackSwitching(e,t){const s=this.altAudio;if(!!!t.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;const a=this.fragCurrent;a&&(this.log("Switching to main audio track, cancel main fragment load"),a.abortRequests(),this.fragmentTracker.removeFragment(a)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();const n=this.hls;s&&(n.trigger(E.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(E.AUDIO_TRACK_SWITCHED,t)}}onAudioTrackSwitched(e,t){const s=t.id,r=!!this.hls.audioTracks[s].url;if(r){const n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=r,this.tick()}onBufferCreated(e,t){const s=t.tracks;let r,n,a=!1;for(const o in s){const l=s[o];if(l.id==="main"){if(n=o,r=l,o==="video"){const d=s[o];d&&(this.videoBuffer=d.buffer)}}else a=!0}a&&r?(this.log(`Alternate track found, use ${n}.buffered to schedule main fragment loading`),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media}onFragBuffered(e,t){const{frag:s,part:r}=t;if(s&&s.type!==te.MAIN)return;if(this.fragContextChanged(s)){this.warn(`Fragment ${s.sn}${r?" p: "+r.index:""} of level ${s.level} finished buffering, but was aborted. state: ${this.state}`),this.state===N.PARSED&&(this.state=N.IDLE);return}const n=r?r.stats:s.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),s.sn!=="initSegment"&&(this.fragPrevious=s),this.fragBufferedComplete(s,r)}onError(e,t){var s;if(t.fatal){this.state=N.ERROR;return}switch(t.details){case M.FRAG_GAP:case M.FRAG_PARSING_ERROR:case M.FRAG_DECRYPT_ERROR:case M.FRAG_LOAD_ERROR:case M.FRAG_LOAD_TIMEOUT:case M.KEY_LOAD_ERROR:case M.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(te.MAIN,t);break;case M.LEVEL_LOAD_ERROR:case M.LEVEL_LOAD_TIMEOUT:case M.LEVEL_PARSING_ERROR:!t.levelRetry&&this.state===N.WAITING_LEVEL&&((s=t.context)==null?void 0:s.type)===pe.LEVEL&&(this.state=N.IDLE);break;case M.BUFFER_APPEND_ERROR:case M.BUFFER_FULL_ERROR:if(!t.parent||t.parent!=="main")return;if(t.details===M.BUFFER_APPEND_ERROR){this.resetLoadingState();return}this.reduceLengthAndFlushBuffer(t)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case M.INTERNAL_EXCEPTION:this.recoverWorkerError(t);break}}checkBuffer(){const{media:e,gapController:t}=this;if(!(!e||!t||!e.readyState)){if(this.loadedmetadata||!Le.getBuffered(e).length){const s=this.state!==N.IDLE?this.fragCurrent:null;t.poll(this.lastCurrentTime,s)}this.lastCurrentTime=e.currentTime}}onFragLoadEmergencyAborted(){this.state=N.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()}onBufferFlushed(e,{type:t}){if(t!==be.AUDIO||this.audioOnly&&!this.altAudio){const s=(t===be.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(s,t,te.MAIN),this.tick()}}onLevelsUpdated(e,t){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),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 ${s}, already seeking at ${t}`);return}const r=Le.getBuffered(e),a=(r.length?r.start(0):0)-s;a>0&&(a<this.config.maxBufferHole||a<this.config.maxFragLookUpTolerance)&&(this.log(`adjusting start position by ${a} to match buffer start`),s+=a,this.startPosition=s),this.log(`seek to target start position ${s} from current time ${t}`),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:r}=this;if(!s||this.fragContextChanged(e))return;t.fragmentError=0,this.state=N.IDLE,this.startFragRequested=!1,this.bitrateTest=!1;const n=e.stats;n.parsing.start=n.parsing.end=n.buffering.start=n.buffering.end=self.performance.now(),r.trigger(E.FRAG_LOADED,s),e.bitrateTest=!1})}_handleTransmuxComplete(e){var t;const s="main",{hls:r}=this,{remuxResult:n,chunkMeta:a}=e,o=this.getCurrentContext(a);if(!o){this.resetWhenMissingContext(a);return}const{frag:l,part:d,level:c}=o,{video:u,text:h,id3:f,initSegment:m}=n,{details:p}=c,g=this.altAudio?void 0:n.audio;if(this.fragContextChanged(l)){this.fragmentTracker.removeFragment(l);return}if(this.state=N.PARSING,m){if(m!=null&&m.tracks){const b=l.initSegment||l;this._bufferInitSegment(c,m.tracks,b,a),r.trigger(E.FRAG_PARSING_INIT_SEGMENT,{frag:b,id:s,tracks:m.tracks})}const v=m.initPTS,y=m.timescale;j(v)&&(this.initPTS[l.cc]={baseTime:v,timescale:y},r.trigger(E.INIT_PTS_FOUND,{frag:l,id:s,initPTS:v,timescale:y}))}if(u&&p&&l.sn!=="initSegment"){const v=p.fragments[l.sn-1-p.startSN],y=l.sn===p.startSN,b=!v||l.cc>v.cc;if(n.independent!==!1){const{startPTS:x,endPTS:_,startDTS:S,endDTS:A}=u;if(d)d.elementaryStreams[u.type]={startPTS:x,endPTS:_,startDTS:S,endDTS:A};else if(u.firstKeyFrame&&u.independent&&a.id===1&&!b&&(this.couldBacktrack=!0),u.dropped&&u.independent){const D=this.getMainFwdBufferInfo(),O=(D?D.end:this.getLoadPosition())+this.config.maxBufferHole,L=u.firstKeyFramePTS?u.firstKeyFramePTS:x;if(!y&&O<L-this.config.maxBufferHole&&!b){this.backtrack(l);return}else b&&(l.gap=!0);l.setElementaryStreamInfo(u.type,l.start,_,l.start,A,!0)}else y&&x>ll&&(l.gap=!0);l.setElementaryStreamInfo(u.type,x,_,S,A),this.backtrackFragment&&(this.backtrackFragment=l),this.bufferFragmentData(u,l,d,a,y||b)}else if(y||b)l.gap=!0;else{this.backtrack(l);return}}if(g){const{startPTS:v,endPTS:y,startDTS:b,endDTS:x}=g;d&&(d.elementaryStreams[be.AUDIO]={startPTS:v,endPTS:y,startDTS:b,endDTS:x}),l.setElementaryStreamInfo(be.AUDIO,v,y,b,x),this.bufferFragmentData(g,l,d,a)}if(p&&f!=null&&(t=f.samples)!=null&&t.length){const v={id:s,frag:l,details:p,samples:f.samples};r.trigger(E.FRAG_PARSING_METADATA,v)}if(p&&h){const v={id:s,frag:l,details:p,samples:h.samples};r.trigger(E.FRAG_PARSING_USERDATA,v)}}_bufferInitSegment(e,t,s,r){if(this.state!==N.PARSING)return;this.audioOnly=!!t.audio&&!t.video,this.altAudio&&!this.audioOnly&&delete t.audio;const{audio:n,video:a,audiovideo:o}=t;if(n){let l=e.audioCodec;const d=navigator.userAgent.toLowerCase();if(this.audioCodecSwitch){l&&(l.indexOf("mp4a.40.5")!==-1?l="mp4a.40.2":l="mp4a.40.5");const c=n.metadata;c&&"channelCount"in c&&(c.channelCount||1)!==1&&d.indexOf("firefox")===-1&&(l="mp4a.40.5")}l&&l.indexOf("mp4a.40.5")!==-1&&d.indexOf("android")!==-1&&n.container!=="audio/mpeg"&&(l="mp4a.40.2",this.log(`Android: force audio codec to ${l}`)),e.audioCodec&&e.audioCodec!==l&&this.log(`Swapping manifest audio codec "${e.audioCodec}" for "${l}"`),n.levelCodec=l,n.id="main",this.log(`Init audio buffer, container:${n.container}, codecs[selected/level/parsed]=[${l||""}/${e.audioCodec||""}/${n.codec}]`)}a&&(a.levelCodec=e.videoCodec,a.id="main",this.log(`Init video buffer, container:${a.container}, codecs[level/parsed]=[${e.videoCodec||""}/${a.codec}]`)),o&&this.log(`Init audiovideo buffer, container:${o.container}, codecs[level/parsed]=[${e.codecs}/${o.codec}]`),this.hls.trigger(E.BUFFER_CODECS,t),Object.keys(t).forEach(l=>{const c=t[l].initSegment;c!=null&&c.byteLength&&this.hls.trigger(E.BUFFER_APPENDING,{type:l,data:c,frag:s,part:null,chunkMeta:r,parent:s.type})}),this.tickImmediate()}getMainFwdBufferInfo(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,te.MAIN)}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=N.IDLE}checkFragmentChanged(){const e=this.media;let t=null;if(e&&e.readyState>1&&e.seeking===!1){const s=e.currentTime;if(Le.isBuffered(e,s)?t=this.getAppendedFrag(s):Le.isBuffered(e,s+.1)&&(t=this.getAppendedFrag(s+.1)),t){this.backtrackFragment=null;const r=this.fragPlaying,n=t.level;(!r||t.sn!==r.sn||r.level!==n)&&(this.fragPlaying=t,this.hls.trigger(E.FRAG_CHANGED,{frag:t}),(!r||r.level!==n)&&this.hls.trigger(E.LEVEL_SWITCHED,{level:n}))}}}get nextLevel(){const e=this.nextBufferedFrag;return e?e.level:-1}get currentFrag(){const e=this.media;return e?this.fragPlaying||this.getAppendedFrag(e.currentTime):null}get currentProgramDateTime(){const e=this.media;if(e){const t=e.currentTime,s=this.currentFrag;if(s&&j(t)&&j(s.programDateTime)){const r=s.programDateTime+(t-s.start)*1e3;return new Date(r)}}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 rr{static get version(){return"1.5.11"}static isMSESupported(){return OE()}static isSupported(){return qL()}static getMediaSource(){return _r()}static get Events(){return E}static get ErrorTypes(){return se}static get ErrorDetails(){return M}static get DefaultConfig(){return rr.defaultConfig?rr.defaultConfig:DE}static set DefaultConfig(e){rr.defaultConfig=e}constructor(e={}){this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new _m,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.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,GA(e.debug||!1,"Hls instance");const t=this.config=HL(rr.DefaultConfig,e);this.userConfig=e,t.progressive&&WL(t);const{abrController:s,bufferController:r,capLevelController:n,errorController:a,fpsController:o}=t,l=new a(this),d=this.abrController=new s(this),c=this.bufferController=new r(this),u=this.capLevelController=new n(this),h=new o(this),f=new PS(this),m=new BS(this),p=t.contentSteeringController,g=p?new p(this):null,v=this.levelController=new KL(this,g),y=new px(this),b=new VL(this.config),x=this.streamController=new JL(this,y,b);u.setStreamController(x),h.setStreamController(x);const _=[f,v,x];g&&_.splice(1,0,g),this.networkControllers=_;const S=[d,c,u,h,m,y];this.audioTrackController=this.createController(t.audioTrackController,_);const A=t.audioStreamController;A&&_.push(new A(this,y,b)),this.subtitleTrackController=this.createController(t.subtitleTrackController,_);const D=t.subtitleStreamController;D&&_.push(new D(this,y,b)),this.createController(t.timelineController,S),b.emeController=this.emeController=this.createController(t.emeController,S),this.cmcdController=this.createController(t.cmcdController,S),this.latencyController=this.createController(GS,S),this.coreComponents=S,_.push(l);const O=l.onErrorOut;typeof O=="function"&&this.on(E.ERROR,O,l)}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,r){this._emitter.off(e,t,s,r)}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(R.error("An internal error happened while handling event "+e+'. Error message: "'+s.message+'". Here is a stacktrace:',s),!this.triggeringException){this.triggeringException=!0;const r=e===E.ERROR;this.trigger(E.ERROR,{type:se.OTHER_ERROR,details:M.INTERNAL_EXCEPTION,fatal:r,event:e,error:s}),this.triggeringException=!1}}return!1}listenerCount(e){return this._emitter.listenerCount(e)}destroy(){R.log("destroy"),this.trigger(E.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){R.log("attachMedia"),this._media=e,this.trigger(E.MEDIA_ATTACHING,{media:e})}detachMedia(){R.log("detachMedia"),this.trigger(E.MEDIA_DETACHING,void 0),this._media=null}loadSource(e){this.stopLoad();const t=this.media,s=this.url,r=this.url=dm.buildAbsoluteURL(self.location.href,e,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,R.log(`loadSource:${r}`),t&&s&&(s!==r||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(t)),this.trigger(E.MANIFEST_LOADING,{url:e})}startLoad(e=-1){R.log(`startLoad(${e})`),this.started=!0,this.networkControllers.forEach(t=>{t.startLoad(e)})}stopLoad(){R.log("stopLoad"),this.started=!1,this.networkControllers.forEach(e=>{e.stopLoad()})}resumeBuffering(){this.started&&this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.startLoad(-1)})}pauseBuffering(){this.networkControllers.forEach(e=>{"fragmentLoader"in e&&e.stopLoad()})}swapAudioCodec(){R.log("swapAudioCodec"),this.streamController.swapAudioCodec()}recoverMediaError(){R.log("recoverMediaError");const e=this._media;this.detachMedia(),e&&this.attachMedia(e)}removeLevel(e){this.levelController.removeLevel(e)}get levels(){const e=this.levelController.levels;return e||[]}get currentLevel(){return this.streamController.currentLevel}set currentLevel(e){R.log(`set currentLevel:${e}`),this.levelController.manualLevel=e,this.streamController.immediateLevelSwitch()}get nextLevel(){return this.streamController.nextLevel}set nextLevel(e){R.log(`set nextLevel:${e}`),this.levelController.manualLevel=e,this.streamController.nextLevelSwitch()}get loadLevel(){return this.levelController.level}set loadLevel(e){R.log(`set loadLevel:${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){R.log(`set firstLevel:${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){R.log(`set startLevel:${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 ttfbEstimate(){const{bwEstimator:e}=this.abrController;return e?e.getEstimateTTFB():NaN}set autoLevelCapping(e){this._autoLevelCapping!==e&&(R.log(`set autoLevelCapping:${e}`),this._autoLevelCapping=e,this.levelController.checkMaxAutoUpdated())}get maxHdcpLevel(){return this._maxHdcpLevel}set maxHdcpLevel(e){HS(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 r=0;r<s;r++)if(e[r].maxBitrate>=t)return r;return 0}get maxAutoLevel(){const{levels:e,autoLevelCapping:t,maxHdcpLevel:s}=this;let r;if(t===-1&&e!=null&&e.length?r=e.length-1:r=t,s)for(let n=r;n--;){const a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=s)return n}return r}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()}setAudioOption(e){var t;return(t=this.audioTrackController)==null?void 0:t.setAudioOption(e)}setSubtitleOption(e){var t;return(t=this.subtitleTrackController)==null||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}get drift(){return this.latencyController.drift}get forceStartLoad(){return this.streamController.forceStartLoad}}rr.defaultConfig=void 0;var Ne=rr,as=class aa extends Error{constructor(e,t=aa.MEDIA_ERR_CUSTOM,s,r){var n;super(e),this.name="MediaError",this.code=t,this.context=r,this.fatal=s??(t>=aa.MEDIA_ERR_NETWORK&&t<=aa.MEDIA_ERR_ENCRYPTED),this.message||(this.message=(n=aa.defaultMessages[this.code])!=null?n:"")}};as.MEDIA_ERR_ABORTED=1,as.MEDIA_ERR_NETWORK=2,as.MEDIA_ERR_DECODE=3,as.MEDIA_ERR_SRC_NOT_SUPPORTED=4,as.MEDIA_ERR_ENCRYPTED=5,as.MEDIA_ERR_CUSTOM=100,as.defaultMessages={1:"You aborted the media playback",2:"A network error caused the media download to fail.",3:"A media error caused playback to be aborted. The media could be corrupt or your browser does not support this format.",4:"An unsupported error occurred. The server or network failed, or your browser does not support this format.",5:"The media is encrypted and there are no keys to decrypt it."};var Ct=as,eI=i=>i==null,PE=(i,e)=>eI(e)?!1:i in e,lh={ANY:"any",MUTED:"muted"},_e={ON_DEMAND:"on-demand",LIVE:"live",UNKNOWN:"unknown"},Ci={MSE:"mse",NATIVE:"native"},dl={HEADER:"header",QUERY:"query",NONE:"none"},jd=Object.values(dl),Ss={M3U8:"application/vnd.apple.mpegurl",MP4:"video/mp4"},H0={HLS:Ss.M3U8};[...Object.values(Ss)];var st=(i,e,t,s,r=i)=>{r.addEventListener(e,t,s),i.addEventListener("teardown",()=>{r.removeEventListener(e,t)},{once:!0})};function tI(i,e,t){e&&t>e&&(t=e);for(let s=0;s<i.length;s++)if(i.start(s)<=t&&i.end(s)>=t)return!0;return!1}var iI=i=>{let e=i.indexOf("?");if(e<0)return[i];let t=i.slice(0,e),s=i.slice(e);return[t,s]},Ic=i=>{let e=i.type;if(e){let s=e.toUpperCase();return PE(s,H0)?H0[s]:e}let{src:t}=i;return t?sI(t):""},NE=i=>i==="VOD"?_e.ON_DEMAND:_e.LIVE,UE=i=>i==="EVENT"?Number.POSITIVE_INFINITY:i==="VOD"?Number.NaN:0,sI=i=>{let e="";try{e=new URL(i).pathname}catch{console.error("invalid url")}let t=e.lastIndexOf(".");if(t<0)return"";let s=e.slice(t+1).toUpperCase();return PE(s,Ss)?Ss[s]:""},rI=Object.values(lh),W0=i=>typeof i=="boolean"||typeof i=="string"&&rI.includes(i),nI=(i,e,t)=>{let{autoplay:s}=i,r=!1,n=!1,a=W0(s)?s:!!s,o=()=>{r||st(e,"playing",()=>{r=!0},{once:!0})};if(o(),st(e,"loadstart",()=>{r=!1,o(),mu(e,a)},{once:!0}),st(e,"loadstart",()=>{t||(i.streamType&&i.streamType!==_e.UNKNOWN?n=i.streamType===_e.LIVE:n=!Number.isFinite(e.duration)),mu(e,a)},{once:!0}),t&&t.once(Ne.Events.LEVEL_LOADED,(l,d)=>{var c;i.streamType&&i.streamType!==_e.UNKNOWN?n=i.streamType===_e.LIVE:n=(c=d.details.live)!=null?c:!1}),!a){let l=()=>{!n||Number.isFinite(i.startTime)||(t!=null&&t.liveSyncPosition?e.currentTime=t.liveSyncPosition:Number.isFinite(e.seekable.end(0))&&(e.currentTime=e.seekable.end(0)))};t&&st(e,"play",()=>{e.preload==="metadata"?t.once(Ne.Events.LEVEL_UPDATED,l):l()},{once:!0})}return l=>{r||(a=W0(l)?l:!!l,mu(e,a))}},mu=(i,e)=>{if(!e)return;let t=i.muted,s=()=>i.muted=t;switch(e){case lh.ANY:i.play().catch(()=>{i.muted=!0,i.play().catch(s)});break;case lh.MUTED:i.muted=!0,i.play().catch(s);break;default:i.play().catch(()=>{});break}},aI=({preload:i,src:e},t,s)=>{let r=u=>{u!=null&&["","none","metadata","auto"].includes(u)?t.setAttribute("preload",u):t.removeAttribute("preload")};if(!s)return r(i),r;let n=!1,a=!1,o=s.config.maxBufferLength,l=s.config.maxBufferSize,d=u=>{r(u);let h=u??t.preload;a||h==="none"||(h==="metadata"?(s.config.maxBufferLength=1,s.config.maxBufferSize=1):(s.config.maxBufferLength=o,s.config.maxBufferSize=l),c())},c=()=>{!n&&e&&(n=!0,s.loadSource(e))};return st(t,"play",()=>{a=!0,s.config.maxBufferLength=o,s.config.maxBufferSize=l,c()},{once:!0}),d(i),d};function oI(i,e){var t;if(!("videoTracks"in i))return;let s=new WeakMap;e.on(Ne.Events.MANIFEST_PARSED,function(d,c){l();let u=i.addVideoTrack("main");u.selected=!0;for(let[h,f]of c.levels.entries()){let m=u.addRendition(f.url[0],f.width,f.height,f.videoCodec,f.bitrate);s.set(f,`${h}`),m.id=`${h}`}}),e.on(Ne.Events.AUDIO_TRACKS_UPDATED,function(d,c){o();for(let u of c.audioTracks){let h=u.default?"main":"alternative",f=i.addAudioTrack(h,u.name,u.lang);f.id=`${u.id}`,u.default&&(f.enabled=!0)}}),i.audioTracks.addEventListener("change",()=>{var d;let c=+((d=[...i.audioTracks].find(h=>h.enabled))==null?void 0:d.id),u=e.audioTracks.map(h=>h.id);c!=e.audioTrack&&u.includes(c)&&(e.audioTrack=c)}),e.on(Ne.Events.LEVELS_UPDATED,function(d,c){var u;let h=i.videoTracks[(u=i.videoTracks.selectedIndex)!=null?u:0];if(!h)return;let f=c.levels.map(m=>s.get(m));for(let m of i.videoRenditions)m.id&&!f.includes(m.id)&&h.removeRendition(m)});let r=d=>{let c=d.target.selectedIndex;c!=e.nextLevel&&n(c)},n=d=>{let c=i.currentTime,u=!1,h=(f,m)=>{u||(u=!Number.isFinite(m.endOffset))};e.on(Ne.Events.BUFFER_FLUSHING,h),e.nextLevel=d,e.off(Ne.Events.BUFFER_FLUSHING,h),u||e.trigger(Ne.Events.BUFFER_FLUSHING,{startOffset:c+10,endOffset:1/0,type:"video"})};(t=i.videoRenditions)==null||t.addEventListener("change",r);let a=()=>{for(let d of i.videoTracks)i.removeVideoTrack(d)},o=()=>{for(let d of i.audioTracks)i.removeAudioTrack(d)},l=()=>{a(),o()};e.once(Ne.Events.DESTROYING,l)}var pu=i=>"time"in i?i.time:i.startTime;function lI(i,e){e.on(Ne.Events.NON_NATIVE_TEXT_TRACKS_FOUND,(r,{tracks:n})=>{n.forEach(a=>{var o;let l=(o=a.subtitleTrack)!=null?o:a.closedCaptions,d=e.subtitleTracks.findIndex(({lang:c,name:u,type:h})=>c==(l==null?void 0:l.lang)&&u===a.label&&h.toLowerCase()===a.kind);Lm(i,a.kind,a.label,l==null?void 0:l.lang,`${a.kind}${d}`)})});let t=()=>{var r;if(!e.subtitleTracks.length)return;let n=Array.from(i.textTracks).find(o=>o.id&&o.mode==="showing"&&["subtitles","captions"].includes(o.kind)),a=`${(r=e.subtitleTracks[e.subtitleTrack])==null?void 0:r.type.toLowerCase()}${e.subtitleTrack}`;if(n&&(e.subtitleTrack<0||(n==null?void 0:n.id)!==a)){let o=e.subtitleTracks.findIndex(({lang:l,name:d,type:c})=>l==n.language&&d===n.label&&c.toLowerCase()===n.kind);e.subtitleTrack=o}n&&(n==null?void 0:n.id)===a&&n.cues&&Array.from(n.cues).forEach(o=>{n.addCue(o)})};i.textTracks.addEventListener("change",t),e.on(Ne.Events.CUES_PARSED,(r,{track:n,cues:a})=>{let o=i.textTracks.getTrackById(n);if(!o)return;let l=o.mode==="disabled";l&&(o.mode="hidden"),a.forEach(d=>{var c;(c=o.cues)!=null&&c.getCueById(d.id)||o.addCue(d)}),l&&(o.mode="disabled")}),e.once(Ne.Events.DESTROYING,()=>{i.textTracks.removeEventListener("change",t),i.querySelectorAll("track[data-removeondestroy]").forEach(r=>{r.remove()})});let s=()=>{Array.from(i.textTracks).forEach(r=>{var n,a;if(!["subtitles","caption"].includes(r.kind)&&r.label==="thumbnails"){if(!((n=r.cues)!=null&&n.length)){let o=i.querySelector('track[label="thumbnails"]'),l=(a=o==null?void 0:o.getAttribute("src"))!=null?a:"";o==null||o.removeAttribute("src"),setTimeout(()=>{o==null||o.setAttribute("src",l)},0)}r.mode!=="hidden"&&(r.mode="hidden")}})};e.once(Ne.Events.MANIFEST_LOADED,s),e.once(Ne.Events.MEDIA_ATTACHED,s)}function Lm(i,e,t,s,r){let n=document.createElement("track");return n.kind=e,n.label=t,s&&(n.srclang=s),r&&(n.id=r),n.track.mode=["subtitles","captions"].includes(e)?"disabled":"hidden",n.setAttribute("data-removeondestroy",""),i.append(n),n.track}function dI(i,e){let t=Array.prototype.find.call(i.querySelectorAll("track"),s=>s.track===e);t==null||t.remove()}function co(i,e,t){var s;return(s=Array.from(i.querySelectorAll("track")).find(r=>r.track.label===e&&r.track.kind===t))==null?void 0:s.track}async function FE(i,e,t,s){let r=co(i,t,s);return r||(r=Lm(i,s,t),r.mode="hidden",await new Promise(n=>setTimeout(()=>n(void 0),0))),r.mode!=="hidden"&&(r.mode="hidden"),[...e].sort((n,a)=>pu(a)-pu(n)).forEach(n=>{var a,o;let l=n.value,d=pu(n);if("endTime"in n&&n.endTime!=null)r==null||r.addCue(new VTTCue(d,n.endTime,s==="chapters"?l:JSON.stringify(l??null)));else{let c=Array.prototype.findIndex.call(r==null?void 0:r.cues,m=>m.startTime>=d),u=(a=r==null?void 0:r.cues)==null?void 0:a[c],h=u?u.startTime:Number.isFinite(i.duration)?i.duration:Number.MAX_SAFE_INTEGER,f=(o=r==null?void 0:r.cues)==null?void 0:o[c-1];f&&(f.endTime=d),r==null||r.addCue(new VTTCue(d,h,s==="chapters"?l:JSON.stringify(l??null)))}}),i.textTracks.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),r}var Im="cuepoints",$E=Object.freeze({label:Im});async function BE(i,e,t=$E){return FE(i,e,t.label,"metadata")}var dh=i=>({time:i.startTime,value:JSON.parse(i.text)});function cI(i,e={label:Im}){let t=co(i,e.label,"metadata");return t!=null&&t.cues?Array.from(t.cues,s=>dh(s)):[]}function GE(i,e={label:Im}){var t,s;let r=co(i,e.label,"metadata");if(!((t=r==null?void 0:r.activeCues)!=null&&t.length))return;if(r.activeCues.length===1)return dh(r.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:o,endTime:l})=>o<=n&&l>n);return dh(a||r.activeCues[0])}async function uI(i,e=$E){return new Promise(t=>{st(i,"loadstart",async()=>{let s=await BE(i,[],e);st(i,"cuechange",()=>{let r=GE(i);if(r){let n=new CustomEvent("cuepointchange",{composed:!0,bubbles:!0,detail:r});i.dispatchEvent(n)}},{},s),t(s)})})}var Rm="chapters",HE=Object.freeze({label:Rm}),ch=i=>({startTime:i.startTime,endTime:i.endTime,value:i.text});async function WE(i,e,t=HE){return FE(i,e,t.label,"chapters")}function hI(i,e={label:Rm}){var t;let s=co(i,e.label,"chapters");return(t=s==null?void 0:s.cues)!=null&&t.length?Array.from(s.cues,r=>ch(r)):[]}function KE(i,e={label:Rm}){var t,s;let r=co(i,e.label,"chapters");if(!((t=r==null?void 0:r.activeCues)!=null&&t.length))return;if(r.activeCues.length===1)return ch(r.activeCues[0]);let{currentTime:n}=i,a=Array.prototype.find.call((s=r.activeCues)!=null?s:[],({startTime:o,endTime:l})=>o<=n&&l>n);return ch(a||r.activeCues[0])}async function fI(i,e=HE){return new Promise(t=>{st(i,"loadstart",async()=>{let s=await WE(i,[],e);st(i,"cuechange",()=>{let r=KE(i);if(r){let n=new CustomEvent("chapterchange",{composed:!0,bubbles:!0,detail:r});i.dispatchEvent(n)}},{},s),t(s)})})}function mI(i,e){if(e){let t=e.playingDate;if(t!=null)return new Date(t.getTime()-i.currentTime*1e3)}return typeof i.getStartDate=="function"?i.getStartDate():new Date(NaN)}function pI(i,e){if(e&&e.playingDate)return e.playingDate;if(typeof i.getStartDate=="function"){let t=i.getStartDate();return new Date(t.getTime()+i.currentTime*1e3)}return new Date(NaN)}var gI=async i=>fetch(i).then(e=>e.text()).then(e=>{let t=e.split(`
47
47
  `).find((s,r,n)=>r&&n[r-1].startsWith("#EXT-X-STREAM-INF"));return fetch(t).then(s=>s.text()).then(s=>s.split(`
48
- `))}),gI=i=>{var e,t,s;let r=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=NE(r),a=UE(r),o;if(n===_e.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(u=>u.startsWith("#EXT-X-TARGETDURATION")),c=(s=d==null?void 0:d.split(":"))==null?void 0:s[1];o=+(c??6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},vI=async(i,e)=>{if(e===Ss.MP4)return{streamType:_e.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Ss.M3U8){let t=await pI(i);return gI(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},gu=async(i,e,t=Ic({src:i}))=>{var s,r,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await vI(i,t);((s=gt.get(e))!=null?s:{}).liveEdgeStartOffset=l,((r=gt.get(e))!=null?r:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=gt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},EI=i=>{var e;let t=i.type,s=NE(t),r=UE(t),n,a=!!((e=i.partList)!=null&&e.length);return s===_e.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:s,targetLiveWindow:r,liveEdgeStartOffset:n,lowLatency:a}},bI=(i,e,t)=>{var s,r,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=EI(i);if(u===_e.LIVE){m?(t.config.backBufferLength=(s=t.userConfig.backBufferLength)!=null?s:4,t.config.maxFragLookUpTolerance=(r=t.userConfig.maxFragLookUpTolerance)!=null?r:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var v;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(v=t.liveSyncPosition)!=null?v:e.seekable.end(g)}});((o=gt.get(e))!=null?o:{}).seekable=p}((l=gt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=gt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=gt.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},K0,V0,yI=(V0=(K0=globalThis==null?void 0:globalThis.navigator)==null?void 0:K0.userAgent)!=null?V0:"",TI=yI.toLowerCase().indexOf("android")!==-1,gt=new WeakMap,VE="mux.com",q0,Y0,qE=(Y0=(q0=Ne).isSupported)==null?void 0:Y0.call(q0),_I=TI,AI=()=>lm.utils.now(),SI=lm.utils.generateUUID,uh=({playbackId:i,customDomain:e=VE,maxResolution:t,minResolution:s,renditionOrder:r,programStartTime:n,programEndTime:a,tokens:{playback:o}={},extraSourceParams:l={}}={})=>{if(!i)return;let[d,c=""]=tI(i),u=new URL(`https://stream.${e}/${d}.m3u8${c}`);return o||u.searchParams.has("token")?(u.searchParams.forEach((h,f)=>{f!="token"&&u.searchParams.delete(f)}),o&&u.searchParams.set("token",o)):(t&&u.searchParams.set("max_resolution",t),s&&(u.searchParams.set("min_resolution",s),t&&+t.slice(0,-1)<+s.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",s,"maxResolution",t)),r&&u.searchParams.set("rendition_order",r),n&&u.searchParams.set("program_start_time",`${n}`),a&&u.searchParams.set("program_end_time",`${a}`),Object.entries(l).forEach(([h,f])=>{f!=null&&u.searchParams.set(h,f)})),u.toString()},xI=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},kI=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},LI=i=>{var e,t,s;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:ZE(i)&&(s=(t=xI(i.playbackId))!=null?t:kI(i.src))!=null?s:i.src},II=i=>{var e;return(e=gt.get(i))==null?void 0:e.error},hh=i=>{var e,t;return(t=(e=gt.get(i))==null?void 0:e.streamType)!=null?t:_e.UNKNOWN},RI=i=>{var e,t;return(t=(e=gt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},zd=i=>{var e,t;return(t=(e=gt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},wI=i=>{var e;let t=(e=gt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let s=zd(i);return s.length?s.end(s.length-1)-t:Number.NaN},wm=.034,CI=(i,e,t=wm)=>Math.abs(i-e)<=t,YE=(i,e,t=wm)=>i>e||CI(i,e,t),DI=(i,e=wm)=>i.paused&&YE(i.currentTime,i.duration,e),jE=(i,e)=>{var t,s,r;if(!e)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(s=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:s.details:(r=e.levels.find(u=>!!u.details))==null?void 0:r.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),c=i.buffered.end(i.buffered.length-1);return l>d&&l<c},zE=(i,e)=>i.ended||i.loop?i.ended:e&&jE(i,e)?!0:DI(i),MI=(i,e,t)=>{XE(e,t);let{metadata:s={}}=i,{view_session_id:r=SI()}=s,n=LI(i);s.view_session_id=r,s.video_id=n,i.metadata=s,gt.set(e,{});let a=OI(i,e),o=nI(i,e,a);NI(i,e,a),UI(i,e,a),cI(e),hI(e);let l=rI(i,e,a);return{engine:a,setAutoplay:l,setPreload:o}},XE=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",eb),i.removeEventListener("error",fh),i.removeEventListener("durationchange",JE),gt.delete(i),i.dispatchEvent(new Event("teardown")))};function QE(i,e){var t;let s=Ic(i);if(s!==Ss.M3U8)return!0;let r=!s||((t=e.canPlayType(s))!=null?t:!0),{preferPlayback:n}=i,a=n===Ci.MSE,o=n===Ci.NATIVE;return r&&(o||!(qE&&(a||_I)))}var OI=(i,e)=>{let{debug:t,streamType:s,startTime:r=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Ic(i)===Ss.M3U8,d=QE(i,e);if(l&&!d&&qE){let c={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},u=PI(s),h=a!==dl.NONE?{useHeaders:a===dl.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new Ne({debug:t,startPosition:r,cmcd:h,xhrSetup:(f,m)=>{var p,g;if(a&&a!==dl.QUERY)return;let v=new URL(m);if(!v.searchParams.has("CMCD"))return;let y=((g=(p=v.searchParams.get("CMCD"))==null?void 0:p.split(","))!=null?g:[]).filter(b=>b.startsWith("sid")||b.startsWith("cid")).join(",");v.searchParams.set("CMCD",y),f.open("GET",v)},...c,...u,...o})}},PI=i=>i===_e.LIVE?{backBufferLength:8}:{},ZE=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let s=window==null?void 0:window.location.href,r=new URL(e,s).hostname.toLocaleLowerCase();return r.includes(VE)||!!t&&r.includes(t.toLocaleLowerCase())},NI=(i,e,t)=>{var s;let{envKey:r,disableTracking:n}=i,a=ZE(i);if(!n&&(r||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:c,debug:u,disableCookies:h}=i,f={...i.metadata,video_title:((s=i==null?void 0:i.metadata)==null?void 0:s.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;lm.monitor(e,{debug:u,beaconCollectionDomain:c,hlsjs:t,Hls:t?Ne:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...r?{env_key:r}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},UI=(i,e,t)=>{var s;let r=QE(i,e),{src:n}=i,a=()=>{e.ended||!zE(e,t)||(jE(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},o,l,d=()=>{var c,u;let h=(c=zd(e))==null?void 0:c.start(0),f=(u=zd(e))==null?void 0:u.end(0);(l!==f||o!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),o=h,l=f};if(st(e,"durationchange",d),e&&r){let c=Ic(i);if(typeof n=="string"){let u=()=>{if(hh(e)!==_e.LIVE||Number.isFinite(e.duration))return;let h=setInterval(d,1e3);e.addEventListener("teardown",()=>{clearInterval(h)},{once:!0}),st(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(h)})};if(e.preload==="none"){let h=()=>{gu(n,e,c).then(u),e.removeEventListener("loadedmetadata",f)},f=()=>{gu(n,e,c).then(u),e.removeEventListener("play",h)};st(e,"play",h,{once:!0}),st(e,"loadedmetadata",f,{once:!0})}else gu(n,e,c).then(u);e.setAttribute("src",n),i.startTime&&(((s=gt.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",JE,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",eb),e.addEventListener("error",fh),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(u=>{u.remove()})},{once:!0}),st(e,"pause",a),st(e,"seeked",a),st(e,"play",()=>{e.ended||YE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(Ne.Events.LEVEL_LOADED,(c,u)=>{bI(u.details,e,t),d(),hh(e)===_e.LIVE&&!Number.isFinite(e.duration)&&(t.on(Ne.Events.LEVEL_UPDATED,d),st(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(Ne.Events.LEVELS_UPDATED,d)}))}),t.on(Ne.Events.ERROR,(c,u)=>{let h={[Ne.ErrorTypes.NETWORK_ERROR]:Ct.MEDIA_ERR_NETWORK,[Ne.ErrorTypes.MEDIA_ERROR]:Ct.MEDIA_ERR_DECODE},f=new Ct("",h[u.type]);f.fatal=u.fatal,f.data=u,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",fh),st(e,"waiting",a),aI(i,t),oI(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function JE(i){var e;let t=i.target,s=(e=gt.get(t))==null?void 0:e.startTime;if(s&&eI(t.seekable,t.duration,s)){let r=t.preload==="auto";r&&(t.preload="none"),t.currentTime=s,r&&(t.preload="auto")}}async function eb(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:s}=e.error,r=new Ct(t,s);if(e.src&&(s!==Ct.MEDIA_ERR_DECODE||s!==void 0))try{let{status:n}=await fetch(e.src);r.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:r}))}function fh(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof Ct))return;let s=i.target,r=i.detail;!r||!r.fatal||(((e=gt.get(s))!=null?e:{}).error=r,(t=s.mux)==null||t.emit("error",{player_error_code:r.code,player_error_message:r.message,player_error_context:r.context}))}const K={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ue={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},tb={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},ib=Object.entries(tb),T=ib.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),Ir=ib.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"});Object.entries(Ir).reduce((i,[e,t])=>{const s=T[e];return s&&(i[t]=s),i},{userinactivechange:"userinactive"});const FI=Object.entries(T).reduce((i,[e,t])=>{const s=Ir[e];return s&&(i[t]=s),i},{userinactive:"userinactivechange"}),_s={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},yn={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"},j0={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Bt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},Xi={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},$I={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"},Ut={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},At={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"};function BI(i){return i==null?void 0:i.map(GI).join(" ")}function sb(i){return i==null?void 0:i.split(/\s+/).map(HI)}function GI(i){if(i){const{id:e,width:t,height:s}=i;return[e,t,s].filter(r=>r!=null).join(":")}}function HI(i){if(i){const[e,t,s]=i.split(":");return{id:e,width:t,height:s}}}function WI(i){return i==null?void 0:i.map(KI).join(" ")}function rb(i){return i==null?void 0:i.split(/\s+/).map(VI)}function KI(i){if(i){const{id:e,kind:t,language:s,label:r}=i;return[e,t,s,r].filter(n=>n!=null).join(":")}}function VI(i){if(i){const[e,t,s,r]=i.split(":");return{id:e,kind:t,language:s,label:r}}}function qI(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function YI(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function nb(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}const ab=i=>new Promise(e=>setTimeout(e,i)),z0=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],jI=(i,e)=>{const t=i===1?z0[e].singular:z0[e].plural;return`${i} ${t}`},Pa=i=>{if(!YI(i))return"";const e=Math.abs(i),t=e!==i,s=new Date(0,0,0,0,0,e,0);return`${[s.getHours(),s.getMinutes(),s.getSeconds()].map((o,l)=>o&&jI(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function hr(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let s=Math.floor(i%60),r=Math.floor(i/60%60),n=Math.floor(i/3600);const a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=r=s="0"),n=n>0||o>0?n+":":"",r=((n||a>=10)&&r<10?"0"+r:r)+":",s=s<10?"0"+s:s,(t?"-":"")+n+r+s}let ob=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};class X0 extends ob{}class zI{observe(){}unobserve(){}disconnect(){}}const lb={createElement:function(){return new Xd.HTMLElement},createElementNS:function(){return new Xd.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},Xd={ResizeObserver:zI,document:lb,Node:X0,HTMLElement:class extends X0{},DocumentFragment:class extends ob{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},db=typeof window>"u"||typeof window.customElements>"u",cb=Object.keys(Xd).every(i=>i in globalThis),k=db&&!cb?Xd:globalThis,z=db&&!cb?lb:globalThis.document,Q0=new WeakMap,Cm=i=>{let e=Q0.get(i);return e||Q0.set(i,e=new Set),e},ub=new k.ResizeObserver(i=>{for(let e of i)for(let t of Cm(e.target))t(e)});function xs(i,e){Cm(i).add(e),ub.observe(i)}function Ar(i,e){const t=Cm(i);t.delete(e),t.size||ub.unobserve(i)}function oi(i){var e;return(e=mh(i))!=null?e:Rr(i,"media-controller")}function mh(i){var e;const{MEDIA_CONTROLLER:t}=ue,s=i.getAttribute(t);if(s)return(e=wc(i))==null?void 0:e.getElementById(s)}const hb=(i,e,t=".value")=>{const s=i.querySelector(t);s&&(s.textContent=e)},XI=(i,e)=>{const t=`slot[name="${e}"]`,s=i.shadowRoot.querySelector(t);return s?s.children:[]},fb=(i,e)=>XI(i,e)[0],Ni=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:Ni(i,e.getRootNode().host),Rr=(i,e)=>{if(!i)return null;const t=i.closest(e);return t||Rr(i.getRootNode().host,e)};function Rc(i=document){var e;const t=i==null?void 0:i.activeElement;return t?(e=Rc(t.shadowRoot))!=null?e:t:null}function wc(i){var e;const t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function QI(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){const s=getComputedStyle(t);if(s.opacity==="0"||s.visibility==="hidden"||s.display==="none")return!1;t=t.parentElement,e--}return!0}function ZI(i,e,t,s){const r=vu(t,s),n=vu(t,{x:i,y:e}),a=vu(s,{x:i,y:e});return n>r||a>r?n>a?1:0:n/r}function vu(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Ge(i,e){const t=JI(i,s=>s===e);return t||mb(i,e)}function JI(i,e){var t;let s;for(s of i.querySelectorAll("style")){let r;try{r=(t=s.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of r??[])if(e(n.selectorText))return n}}function mb(i,e){var t,s;const r=(t=i.querySelectorAll("style"))!=null?t:[],n=r==null?void 0:r[r.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(s=n.sheet.cssRules)==null?void 0:s[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function $e(i,e,t=Number.NaN){const s=i.getAttribute(e);return s!=null?+s:t}function nt(i,e,t){const s=+t;if(t==null||Number.isNaN(s)){i.hasAttribute(e)&&i.removeAttribute(e);return}$e(i,e,void 0)!==s&&i.setAttribute(e,`${s}`)}function at(i,e){return i.hasAttribute(e)}function ot(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}at(i,e)!=t&&i.toggleAttribute(e,t)}function Ve(i,e,t=null){var s;return(s=i.getAttribute(e))!=null?s:t}function qe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}const s=`${t}`;Ve(i,e,void 0)!==s&&i.setAttribute(e,s)}var pb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ss=(i,e,t)=>(pb(i,e,"read from private field"),t?t.call(i):e.get(i)),eR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},wo=(i,e,t,s)=>(pb(i,e,"write to private field"),e.set(i,t),t),It;const gb=z.createElement("template");gb.innerHTML=`
48
+ `))}),vI=i=>{var e,t,s;let r=(t=((e=i.find(l=>l.startsWith("#EXT-X-PLAYLIST-TYPE")))!=null?e:"").split(":")[1])==null?void 0:t.trim(),n=NE(r),a=UE(r),o;if(n===_e.LIVE){let l=i.find(d=>d.startsWith("#EXT-X-PART-INF"));if(l)o=+l.split(":")[1].split("=")[1]*2;else{let d=i.find(u=>u.startsWith("#EXT-X-TARGETDURATION")),c=(s=d==null?void 0:d.split(":"))==null?void 0:s[1];o=+(c??6)*3}}return{streamType:n,targetLiveWindow:a,liveEdgeStartOffset:o}},EI=async(i,e)=>{if(e===Ss.MP4)return{streamType:_e.ON_DEMAND,targetLiveWindow:Number.NaN,liveEdgeStartOffset:void 0};if(e===Ss.M3U8){let t=await gI(i);return vI(t)}return console.error(`Media type ${e} is an unrecognized or unsupported type for src ${i}.`),{streamType:void 0,targetLiveWindow:void 0,liveEdgeStartOffset:void 0}},gu=async(i,e,t=Ic({src:i}))=>{var s,r,n;let{streamType:a,targetLiveWindow:o,liveEdgeStartOffset:l}=await EI(i,t);((s=gt.get(e))!=null?s:{}).liveEdgeStartOffset=l,((r=gt.get(e))!=null?r:{}).targetLiveWindow=o,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((n=gt.get(e))!=null?n:{}).streamType=a,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},bI=i=>{var e;let t=i.type,s=NE(t),r=UE(t),n,a=!!((e=i.partList)!=null&&e.length);return s===_e.LIVE&&(n=a?i.partTarget*2:i.targetduration*3),{streamType:s,targetLiveWindow:r,liveEdgeStartOffset:n,lowLatency:a}},yI=(i,e,t)=>{var s,r,n,a,o,l,d,c;let{streamType:u,targetLiveWindow:h,liveEdgeStartOffset:f,lowLatency:m}=bI(i);if(u===_e.LIVE){m?(t.config.backBufferLength=(s=t.userConfig.backBufferLength)!=null?s:4,t.config.maxFragLookUpTolerance=(r=t.userConfig.maxFragLookUpTolerance)!=null?r:.001,t.config.abrBandWidthUpFactor=(n=t.userConfig.abrBandWidthUpFactor)!=null?n:t.config.abrBandWidthFactor):t.config.backBufferLength=(a=t.userConfig.backBufferLength)!=null?a:8;let p=Object.freeze({get length(){return e.seekable.length},start(g){return e.seekable.start(g)},end(g){var v;return g>this.length||g<0||Number.isFinite(e.duration)?e.seekable.end(g):(v=t.liveSyncPosition)!=null?v:e.seekable.end(g)}});((o=gt.get(e))!=null?o:{}).seekable=p}((l=gt.get(e))!=null?l:{}).liveEdgeStartOffset=f,((d=gt.get(e))!=null?d:{}).targetLiveWindow=h,e.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0})),((c=gt.get(e))!=null?c:{}).streamType=u,e.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}))},K0,V0,TI=(V0=(K0=globalThis==null?void 0:globalThis.navigator)==null?void 0:K0.userAgent)!=null?V0:"",_I=TI.toLowerCase().indexOf("android")!==-1,gt=new WeakMap,VE="mux.com",q0,Y0,qE=(Y0=(q0=Ne).isSupported)==null?void 0:Y0.call(q0),AI=_I,SI=()=>lm.utils.now(),xI=lm.utils.generateUUID,uh=({playbackId:i,customDomain:e=VE,maxResolution:t,minResolution:s,renditionOrder:r,programStartTime:n,programEndTime:a,tokens:{playback:o}={},extraSourceParams:l={}}={})=>{if(!i)return;let[d,c=""]=iI(i),u=new URL(`https://stream.${e}/${d}.m3u8${c}`);return o||u.searchParams.has("token")?(u.searchParams.forEach((h,f)=>{f!="token"&&u.searchParams.delete(f)}),o&&u.searchParams.set("token",o)):(t&&u.searchParams.set("max_resolution",t),s&&(u.searchParams.set("min_resolution",s),t&&+t.slice(0,-1)<+s.slice(0,-1)&&console.error("minResolution must be <= maxResolution","minResolution",s,"maxResolution",t)),r&&u.searchParams.set("rendition_order",r),n&&u.searchParams.set("program_start_time",`${n}`),a&&u.searchParams.set("program_end_time",`${a}`),Object.entries(l).forEach(([h,f])=>{f!=null&&u.searchParams.set(h,f)})),u.toString()},kI=i=>{if(!i)return;let[e]=i.split("?");return e||void 0},LI=i=>{if(!i||!i.startsWith("https://stream."))return;let[e]=new URL(i).pathname.slice(1).split(".m3u8");return e||void 0},II=i=>{var e,t,s;return(e=i==null?void 0:i.metadata)!=null&&e.video_id?i.metadata.video_id:ZE(i)&&(s=(t=kI(i.playbackId))!=null?t:LI(i.src))!=null?s:i.src},RI=i=>{var e;return(e=gt.get(i))==null?void 0:e.error},hh=i=>{var e,t;return(t=(e=gt.get(i))==null?void 0:e.streamType)!=null?t:_e.UNKNOWN},wI=i=>{var e,t;return(t=(e=gt.get(i))==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN},zd=i=>{var e,t;return(t=(e=gt.get(i))==null?void 0:e.seekable)!=null?t:i.seekable},CI=i=>{var e;let t=(e=gt.get(i))==null?void 0:e.liveEdgeStartOffset;if(typeof t!="number")return Number.NaN;let s=zd(i);return s.length?s.end(s.length-1)-t:Number.NaN},wm=.034,DI=(i,e,t=wm)=>Math.abs(i-e)<=t,YE=(i,e,t=wm)=>i>e||DI(i,e,t),MI=(i,e=wm)=>i.paused&&YE(i.currentTime,i.duration,e),jE=(i,e)=>{var t,s,r;if(!e)return;if(i.readyState>2)return!1;let n=e.currentLevel>=0?(s=(t=e.levels)==null?void 0:t[e.currentLevel])==null?void 0:s.details:(r=e.levels.find(u=>!!u.details))==null?void 0:r.details;if(!n||n.live)return;let{fragments:a}=n;if(!(a!=null&&a.length))return;if(i.currentTime<i.duration-(n.targetduration+.5))return!1;let o=a[a.length-1];if(i.currentTime<=o.start)return!1;let l=o.start+o.duration/2,d=i.buffered.start(i.buffered.length-1),c=i.buffered.end(i.buffered.length-1);return l>d&&l<c},zE=(i,e)=>i.ended||i.loop?i.ended:e&&jE(i,e)?!0:MI(i),OI=(i,e,t)=>{XE(e,t);let{metadata:s={}}=i,{view_session_id:r=xI()}=s,n=II(i);s.view_session_id=r,s.video_id=n,i.metadata=s,gt.set(e,{});let a=PI(i,e),o=aI(i,e,a);UI(i,e,a),FI(i,e,a),uI(e),fI(e);let l=nI(i,e,a);return{engine:a,setAutoplay:l,setPreload:o}},XE=(i,e)=>{let t=e==null?void 0:e.engine;t&&(t.detachMedia(),t.destroy()),i!=null&&i.mux&&!i.mux.deleted&&(i.mux.destroy(),delete i.mux),i&&(i.removeAttribute("src"),i.load(),i.removeEventListener("error",eb),i.removeEventListener("error",fh),i.removeEventListener("durationchange",JE),gt.delete(i),i.dispatchEvent(new Event("teardown")))};function QE(i,e){var t;let s=Ic(i);if(s!==Ss.M3U8)return!0;let r=!s||((t=e.canPlayType(s))!=null?t:!0),{preferPlayback:n}=i,a=n===Ci.MSE,o=n===Ci.NATIVE;return r&&(o||!(qE&&(a||AI)))}var PI=(i,e)=>{let{debug:t,streamType:s,startTime:r=-1,metadata:n,preferCmcd:a,_hlsConfig:o={}}=i,l=Ic(i)===Ss.M3U8,d=QE(i,e);if(l&&!d&&qE){let c={backBufferLength:30,renderTextTracksNatively:!1,liveDurationInfinity:!0,capLevelToPlayerSize:!0,capLevelOnFPSDrop:!0},u=NI(s),h=a!==dl.NONE?{useHeaders:a===dl.HEADER,sessionId:n==null?void 0:n.view_session_id,contentId:n==null?void 0:n.video_id}:void 0;return new Ne({debug:t,startPosition:r,cmcd:h,xhrSetup:(f,m)=>{var p,g;if(a&&a!==dl.QUERY)return;let v=new URL(m);if(!v.searchParams.has("CMCD"))return;let y=((g=(p=v.searchParams.get("CMCD"))==null?void 0:p.split(","))!=null?g:[]).filter(b=>b.startsWith("sid")||b.startsWith("cid")).join(",");v.searchParams.set("CMCD",y),f.open("GET",v)},...c,...u,...o})}},NI=i=>i===_e.LIVE?{backBufferLength:8}:{},ZE=({playbackId:i,src:e,customDomain:t})=>{if(i)return!0;if(typeof e!="string")return!1;let s=window==null?void 0:window.location.href,r=new URL(e,s).hostname.toLocaleLowerCase();return r.includes(VE)||!!t&&r.includes(t.toLocaleLowerCase())},UI=(i,e,t)=>{var s;let{envKey:r,disableTracking:n}=i,a=ZE(i);if(!n&&(r||a)){let{playerInitTime:o,playerSoftwareName:l,playerSoftwareVersion:d,beaconCollectionDomain:c,debug:u,disableCookies:h}=i,f={...i.metadata,video_title:((s=i==null?void 0:i.metadata)==null?void 0:s.video_title)||void 0},m=p=>typeof p.player_error_code=="string"?!1:typeof i.errorTranslator=="function"?i.errorTranslator(p):p;lm.monitor(e,{debug:u,beaconCollectionDomain:c,hlsjs:t,Hls:t?Ne:void 0,automaticErrorTracking:!1,errorTranslator:m,disableCookies:h,data:{...r?{env_key:r}:{},player_software_name:l,player_software:l,player_software_version:d,player_init_time:o,...f}})}},FI=(i,e,t)=>{var s;let r=QE(i,e),{src:n}=i,a=()=>{e.ended||!zE(e,t)||(jE(e,t)?e.currentTime=e.buffered.end(e.buffered.length-1):e.dispatchEvent(new Event("ended")))},o,l,d=()=>{var c,u;let h=(c=zd(e))==null?void 0:c.start(0),f=(u=zd(e))==null?void 0:u.end(0);(l!==f||o!==h)&&e.dispatchEvent(new CustomEvent("seekablechange",{composed:!0})),o=h,l=f};if(st(e,"durationchange",d),e&&r){let c=Ic(i);if(typeof n=="string"){let u=()=>{if(hh(e)!==_e.LIVE||Number.isFinite(e.duration))return;let h=setInterval(d,1e3);e.addEventListener("teardown",()=>{clearInterval(h)},{once:!0}),st(e,"durationchange",()=>{Number.isFinite(e.duration)&&clearInterval(h)})};if(e.preload==="none"){let h=()=>{gu(n,e,c).then(u),e.removeEventListener("loadedmetadata",f)},f=()=>{gu(n,e,c).then(u),e.removeEventListener("play",h)};st(e,"play",h,{once:!0}),st(e,"loadedmetadata",f,{once:!0})}else gu(n,e,c).then(u);e.setAttribute("src",n),i.startTime&&(((s=gt.get(e))!=null?s:{}).startTime=i.startTime,e.addEventListener("durationchange",JE,{once:!0}))}else e.removeAttribute("src");e.addEventListener("error",eb),e.addEventListener("error",fh),e.addEventListener("emptied",()=>{e.querySelectorAll("track[data-removeondestroy]").forEach(u=>{u.remove()})},{once:!0}),st(e,"pause",a),st(e,"seeked",a),st(e,"play",()=>{e.ended||YE(e.currentTime,e.duration)&&(e.currentTime=e.seekable.start(0))})}else t&&n?(t.once(Ne.Events.LEVEL_LOADED,(c,u)=>{yI(u.details,e,t),d(),hh(e)===_e.LIVE&&!Number.isFinite(e.duration)&&(t.on(Ne.Events.LEVEL_UPDATED,d),st(e,"durationchange",()=>{Number.isFinite(e.duration)&&t.off(Ne.Events.LEVELS_UPDATED,d)}))}),t.on(Ne.Events.ERROR,(c,u)=>{let h={[Ne.ErrorTypes.NETWORK_ERROR]:Ct.MEDIA_ERR_NETWORK,[Ne.ErrorTypes.MEDIA_ERROR]:Ct.MEDIA_ERR_DECODE},f=new Ct("",h[u.type]);f.fatal=u.fatal,f.data=u,e.dispatchEvent(new CustomEvent("error",{detail:f}))}),e.addEventListener("error",fh),st(e,"waiting",a),oI(i,t),lI(e,t),t.attachMedia(e)):console.error("It looks like the video you're trying to play will not work on this system! If possible, try upgrading to the newest versions of your browser or software.")};function JE(i){var e;let t=i.target,s=(e=gt.get(t))==null?void 0:e.startTime;if(s&&tI(t.seekable,t.duration,s)){let r=t.preload==="auto";r&&(t.preload="none"),t.currentTime=s,r&&(t.preload="auto")}}async function eb(i){if(!i.isTrusted)return;i.stopImmediatePropagation();let e=i.target;if(!(e!=null&&e.error))return;let{message:t,code:s}=e.error,r=new Ct(t,s);if(e.src&&(s!==Ct.MEDIA_ERR_DECODE||s!==void 0))try{let{status:n}=await fetch(e.src);r.data={response:{code:n}}}catch{}e.dispatchEvent(new CustomEvent("error",{detail:r}))}function fh(i){var e,t;if(!(i instanceof CustomEvent)||!(i.detail instanceof Ct))return;let s=i.target,r=i.detail;!r||!r.fatal||(((e=gt.get(s))!=null?e:{}).error=r,(t=s.mux)==null||t.emit("error",{player_error_code:r.code,player_error_message:r.message,player_error_context:r.context}))}const K={MEDIA_PLAY_REQUEST:"mediaplayrequest",MEDIA_PAUSE_REQUEST:"mediapauserequest",MEDIA_MUTE_REQUEST:"mediamuterequest",MEDIA_UNMUTE_REQUEST:"mediaunmuterequest",MEDIA_VOLUME_REQUEST:"mediavolumerequest",MEDIA_SEEK_REQUEST:"mediaseekrequest",MEDIA_AIRPLAY_REQUEST:"mediaairplayrequest",MEDIA_ENTER_FULLSCREEN_REQUEST:"mediaenterfullscreenrequest",MEDIA_EXIT_FULLSCREEN_REQUEST:"mediaexitfullscreenrequest",MEDIA_PREVIEW_REQUEST:"mediapreviewrequest",MEDIA_ENTER_PIP_REQUEST:"mediaenterpiprequest",MEDIA_EXIT_PIP_REQUEST:"mediaexitpiprequest",MEDIA_ENTER_CAST_REQUEST:"mediaentercastrequest",MEDIA_EXIT_CAST_REQUEST:"mediaexitcastrequest",MEDIA_SHOW_TEXT_TRACKS_REQUEST:"mediashowtexttracksrequest",MEDIA_HIDE_TEXT_TRACKS_REQUEST:"mediahidetexttracksrequest",MEDIA_SHOW_SUBTITLES_REQUEST:"mediashowsubtitlesrequest",MEDIA_DISABLE_SUBTITLES_REQUEST:"mediadisablesubtitlesrequest",MEDIA_TOGGLE_SUBTITLES_REQUEST:"mediatogglesubtitlesrequest",MEDIA_PLAYBACK_RATE_REQUEST:"mediaplaybackraterequest",MEDIA_RENDITION_REQUEST:"mediarenditionrequest",MEDIA_AUDIO_TRACK_REQUEST:"mediaaudiotrackrequest",MEDIA_SEEK_TO_LIVE_REQUEST:"mediaseektoliverequest",REGISTER_MEDIA_STATE_RECEIVER:"registermediastatereceiver",UNREGISTER_MEDIA_STATE_RECEIVER:"unregistermediastatereceiver"},ue={MEDIA_CHROME_ATTRIBUTES:"mediachromeattributes",MEDIA_CONTROLLER:"mediacontroller"},tb={MEDIA_AIRPLAY_UNAVAILABLE:"mediaAirplayUnavailable",MEDIA_FULLSCREEN_UNAVAILABLE:"mediaFullscreenUnavailable",MEDIA_PIP_UNAVAILABLE:"mediaPipUnavailable",MEDIA_CAST_UNAVAILABLE:"mediaCastUnavailable",MEDIA_RENDITION_UNAVAILABLE:"mediaRenditionUnavailable",MEDIA_AUDIO_TRACK_UNAVAILABLE:"mediaAudioTrackUnavailable",MEDIA_PAUSED:"mediaPaused",MEDIA_HAS_PLAYED:"mediaHasPlayed",MEDIA_ENDED:"mediaEnded",MEDIA_MUTED:"mediaMuted",MEDIA_VOLUME_LEVEL:"mediaVolumeLevel",MEDIA_VOLUME:"mediaVolume",MEDIA_VOLUME_UNAVAILABLE:"mediaVolumeUnavailable",MEDIA_IS_PIP:"mediaIsPip",MEDIA_IS_CASTING:"mediaIsCasting",MEDIA_IS_AIRPLAYING:"mediaIsAirplaying",MEDIA_SUBTITLES_LIST:"mediaSubtitlesList",MEDIA_SUBTITLES_SHOWING:"mediaSubtitlesShowing",MEDIA_IS_FULLSCREEN:"mediaIsFullscreen",MEDIA_PLAYBACK_RATE:"mediaPlaybackRate",MEDIA_CURRENT_TIME:"mediaCurrentTime",MEDIA_DURATION:"mediaDuration",MEDIA_SEEKABLE:"mediaSeekable",MEDIA_PREVIEW_TIME:"mediaPreviewTime",MEDIA_PREVIEW_IMAGE:"mediaPreviewImage",MEDIA_PREVIEW_COORDS:"mediaPreviewCoords",MEDIA_PREVIEW_CHAPTER:"mediaPreviewChapter",MEDIA_LOADING:"mediaLoading",MEDIA_BUFFERED:"mediaBuffered",MEDIA_STREAM_TYPE:"mediaStreamType",MEDIA_TARGET_LIVE_WINDOW:"mediaTargetLiveWindow",MEDIA_TIME_IS_LIVE:"mediaTimeIsLive",MEDIA_RENDITION_LIST:"mediaRenditionList",MEDIA_RENDITION_SELECTED:"mediaRenditionSelected",MEDIA_AUDIO_TRACK_LIST:"mediaAudioTrackList",MEDIA_AUDIO_TRACK_ENABLED:"mediaAudioTrackEnabled",MEDIA_CHAPTERS_CUES:"mediaChaptersCues"},ib=Object.entries(tb),T=ib.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{}),Ir=ib.reduce((i,[e,t])=>(i[e]=`${t.toLowerCase()}`,i),{USER_INACTIVE:"userinactivechange",BREAKPOINTS_CHANGE:"breakpointchange",BREAKPOINTS_COMPUTED:"breakpointscomputed"});Object.entries(Ir).reduce((i,[e,t])=>{const s=T[e];return s&&(i[t]=s),i},{userinactivechange:"userinactive"});const $I=Object.entries(T).reduce((i,[e,t])=>{const s=Ir[e];return s&&(i[t]=s),i},{userinactive:"userinactivechange"}),_s={SUBTITLES:"subtitles",CAPTIONS:"captions",DESCRIPTIONS:"descriptions",CHAPTERS:"chapters",METADATA:"metadata"},yn={DISABLED:"disabled",HIDDEN:"hidden",SHOWING:"showing"},j0={MOUSE:"mouse",PEN:"pen",TOUCH:"touch"},Bt={UNAVAILABLE:"unavailable",UNSUPPORTED:"unsupported"},Xi={LIVE:"live",ON_DEMAND:"on-demand",UNKNOWN:"unknown"},BI={INLINE:"inline",FULLSCREEN:"fullscreen",PICTURE_IN_PICTURE:"picture-in-picture"},Ut={AUDIO_PLAYER:()=>"audio player",VIDEO_PLAYER:()=>"video player",VOLUME:()=>"volume",SEEK:()=>"seek",CLOSED_CAPTIONS:()=>"closed captions",PLAYBACK_RATE:({playbackRate:i=1}={})=>`current playback rate ${i}`,PLAYBACK_TIME:()=>"playback time",MEDIA_LOADING:()=>"media loading",SETTINGS:()=>"settings",AUDIO_TRACKS:()=>"audio tracks",QUALITY:()=>"quality"},At={PLAY:()=>"play",PAUSE:()=>"pause",MUTE:()=>"mute",UNMUTE:()=>"unmute",ENTER_AIRPLAY:()=>"start airplay",EXIT_AIRPLAY:()=>"stop airplay",ENTER_CAST:()=>"start casting",EXIT_CAST:()=>"stop casting",ENTER_FULLSCREEN:()=>"enter fullscreen mode",EXIT_FULLSCREEN:()=>"exit fullscreen mode",ENTER_PIP:()=>"enter picture in picture mode",EXIT_PIP:()=>"exit picture in picture mode",SEEK_FORWARD_N_SECS:({seekOffset:i=30}={})=>`seek forward ${i} seconds`,SEEK_BACK_N_SECS:({seekOffset:i=30}={})=>`seek back ${i} seconds`,SEEK_LIVE:()=>"seek to live",PLAYING_LIVE:()=>"playing live"};function GI(i){return i==null?void 0:i.map(HI).join(" ")}function sb(i){return i==null?void 0:i.split(/\s+/).map(WI)}function HI(i){if(i){const{id:e,width:t,height:s}=i;return[e,t,s].filter(r=>r!=null).join(":")}}function WI(i){if(i){const[e,t,s]=i.split(":");return{id:e,width:t,height:s}}}function KI(i){return i==null?void 0:i.map(VI).join(" ")}function rb(i){return i==null?void 0:i.split(/\s+/).map(qI)}function VI(i){if(i){const{id:e,kind:t,language:s,label:r}=i;return[e,t,s,r].filter(n=>n!=null).join(":")}}function qI(i){if(i){const[e,t,s,r]=i.split(":");return{id:e,kind:t,language:s,label:r}}}function YI(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function jI(i){return typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i)}function nb(i){return typeof i!="string"?!1:!isNaN(i)&&!isNaN(parseFloat(i))}const ab=i=>new Promise(e=>setTimeout(e,i)),z0=[{singular:"hour",plural:"hours"},{singular:"minute",plural:"minutes"},{singular:"second",plural:"seconds"}],zI=(i,e)=>{const t=i===1?z0[e].singular:z0[e].plural;return`${i} ${t}`},Pa=i=>{if(!jI(i))return"";const e=Math.abs(i),t=e!==i,s=new Date(0,0,0,0,0,e,0);return`${[s.getHours(),s.getMinutes(),s.getSeconds()].map((o,l)=>o&&zI(o,l)).filter(o=>o).join(", ")}${t?" remaining":""}`};function hr(i,e){let t=!1;i<0&&(t=!0,i=0-i),i=i<0?0:i;let s=Math.floor(i%60),r=Math.floor(i/60%60),n=Math.floor(i/3600);const a=Math.floor(e/60%60),o=Math.floor(e/3600);return(isNaN(i)||i===1/0)&&(n=r=s="0"),n=n>0||o>0?n+":":"",r=((n||a>=10)&&r<10?"0"+r:r)+":",s=s<10?"0"+s:s,(t?"-":"")+n+r+s}let ob=class{addEventListener(){}removeEventListener(){}dispatchEvent(){return!0}};class X0 extends ob{}class XI{observe(){}unobserve(){}disconnect(){}}const lb={createElement:function(){return new Xd.HTMLElement},createElementNS:function(){return new Xd.HTMLElement},addEventListener(){},removeEventListener(){},dispatchEvent(i){return!1}},Xd={ResizeObserver:XI,document:lb,Node:X0,HTMLElement:class extends X0{},DocumentFragment:class extends ob{},customElements:{get:function(){},define:function(){},whenDefined:function(){}},localStorage:{getItem(i){return null},setItem(i,e){},removeItem(i){}},CustomEvent:function(){},getComputedStyle:function(){},navigator:{languages:[],get userAgent(){return""}},matchMedia(i){return{matches:!1,media:i}}},db=typeof window>"u"||typeof window.customElements>"u",cb=Object.keys(Xd).every(i=>i in globalThis),k=db&&!cb?Xd:globalThis,z=db&&!cb?lb:globalThis.document,Q0=new WeakMap,Cm=i=>{let e=Q0.get(i);return e||Q0.set(i,e=new Set),e},ub=new k.ResizeObserver(i=>{for(let e of i)for(let t of Cm(e.target))t(e)});function xs(i,e){Cm(i).add(e),ub.observe(i)}function Ar(i,e){const t=Cm(i);t.delete(e),t.size||ub.unobserve(i)}function oi(i){var e;return(e=mh(i))!=null?e:Rr(i,"media-controller")}function mh(i){var e;const{MEDIA_CONTROLLER:t}=ue,s=i.getAttribute(t);if(s)return(e=wc(i))==null?void 0:e.getElementById(s)}const hb=(i,e,t=".value")=>{const s=i.querySelector(t);s&&(s.textContent=e)},QI=(i,e)=>{const t=`slot[name="${e}"]`,s=i.shadowRoot.querySelector(t);return s?s.children:[]},fb=(i,e)=>QI(i,e)[0],Ni=(i,e)=>!i||!e?!1:i!=null&&i.contains(e)?!0:Ni(i,e.getRootNode().host),Rr=(i,e)=>{if(!i)return null;const t=i.closest(e);return t||Rr(i.getRootNode().host,e)};function Rc(i=document){var e;const t=i==null?void 0:i.activeElement;return t?(e=Rc(t.shadowRoot))!=null?e:t:null}function wc(i){var e;const t=(e=i==null?void 0:i.getRootNode)==null?void 0:e.call(i);return t instanceof ShadowRoot||t instanceof Document?t:null}function ZI(i,e=3){if(i.checkVisibility)return i.checkVisibility({checkOpacity:!0,checkVisibilityCSS:!0});let t=i;for(;t&&e>0;){const s=getComputedStyle(t);if(s.opacity==="0"||s.visibility==="hidden"||s.display==="none")return!1;t=t.parentElement,e--}return!0}function JI(i,e,t,s){const r=vu(t,s),n=vu(t,{x:i,y:e}),a=vu(s,{x:i,y:e});return n>r||a>r?n>a?1:0:n/r}function vu(i,e){return Math.sqrt(Math.pow(e.x-i.x,2)+Math.pow(e.y-i.y,2))}function Ge(i,e){const t=eR(i,s=>s===e);return t||mb(i,e)}function eR(i,e){var t;let s;for(s of i.querySelectorAll("style")){let r;try{r=(t=s.sheet)==null?void 0:t.cssRules}catch{continue}for(let n of r??[])if(e(n.selectorText))return n}}function mb(i,e){var t,s;const r=(t=i.querySelectorAll("style"))!=null?t:[],n=r==null?void 0:r[r.length-1];return n!=null&&n.sheet?(n==null||n.sheet.insertRule(`${e}{}`,n.sheet.cssRules.length),(s=n.sheet.cssRules)==null?void 0:s[n.sheet.cssRules.length-1]):(console.warn("Media Chrome: No style sheet found on style tag of",i),{style:{setProperty:()=>{},removeProperty:()=>"",getPropertyValue:()=>""}})}function $e(i,e,t=Number.NaN){const s=i.getAttribute(e);return s!=null?+s:t}function nt(i,e,t){const s=+t;if(t==null||Number.isNaN(s)){i.hasAttribute(e)&&i.removeAttribute(e);return}$e(i,e,void 0)!==s&&i.setAttribute(e,`${s}`)}function at(i,e){return i.hasAttribute(e)}function ot(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}at(i,e)!=t&&i.toggleAttribute(e,t)}function Ve(i,e,t=null){var s;return(s=i.getAttribute(e))!=null?s:t}function qe(i,e,t){if(t==null){i.hasAttribute(e)&&i.removeAttribute(e);return}const s=`${t}`;Ve(i,e,void 0)!==s&&i.setAttribute(e,s)}var pb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ss=(i,e,t)=>(pb(i,e,"read from private field"),t?t.call(i):e.get(i)),tR=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},wo=(i,e,t,s)=>(pb(i,e,"write to private field"),e.set(i,t),t),It;const gb=z.createElement("template");gb.innerHTML=`
49
49
  <style>
50
50
  :host {
51
51
  display: var(--media-control-display, var(--media-gesture-receiver-display, inline-block));
52
52
  box-sizing: border-box;
53
53
  }
54
54
  </style>
55
- `;class tR extends k.HTMLElement{constructor(e={}){if(super(),eR(this,It,void 0),!this.shadowRoot){const t=this.attachShadow({mode:"open"}),s=gb.content.cloneNode(!0);this.nativeEl=s;let r=e.slotTemplate;r||(r=z.createElement("template"),r.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(r.content.cloneNode(!0)),t.appendChild(s)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,T.MEDIA_PAUSED]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=ss(this,It))==null?void 0:r.unassociateElement)==null||n.call(r,this),wo(this,It,null)),s&&this.isConnected&&(wo(this,It,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=ss(this,It))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s,r;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),wo(this,It,iR(this)),this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=ss(this,It))==null?void 0:e.associateElement)==null||t.call(e,this)),(s=ss(this,It))==null||s.addEventListener("pointerdown",this),(r=ss(this,It))==null||r.addEventListener("click",this)}disconnectedCallback(){var e,t,s,r;this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=ss(this,It))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(s=ss(this,It))==null||s.removeEventListener("pointerdown",this),(r=ss(this,It))==null||r.removeEventListener("click",this),wo(this,It,null)}handleEvent(e){var t;const s=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(s==null?void 0:s.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){const{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>c||d===0&&c===0)return;const{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===j0.TOUCH){this.handleTap(e);return}else if(f===j0.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){const t=this.mediaPaused?K.MEDIA_PLAY_REQUEST:K.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new k.CustomEvent(t,{composed:!0,bubbles:!0}))}}It=new WeakMap;function iR(i){var e;const t=i.getAttribute(ue.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):Rr(i,"media-controller")}k.customElements.get("media-gesture-receiver")||k.customElements.define("media-gesture-receiver",tR);var sR=Object.defineProperty,rR=(i,e,t)=>e in i?sR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,nR=(i,e,t)=>(rR(i,e+"",t),t),Dm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ph=(i,e,t)=>(Dm(i,e,"read from private field"),e.get(i)),Rs=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Eu=(i,e,t,s)=>(Dm(i,e,"write to private field"),e.set(i,t),t),ni=(i,e,t)=>(Dm(i,e,"access private method"),t),Qd,Br,gh,vb,vh,Eb,Xa,Cc,Dc,Mm,Mn,Qa;const ge={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},bb=z.createElement("template");bb.innerHTML=`
55
+ `;class iR extends k.HTMLElement{constructor(e={}){if(super(),tR(this,It,void 0),!this.shadowRoot){const t=this.attachShadow({mode:"open"}),s=gb.content.cloneNode(!0);this.nativeEl=s;let r=e.slotTemplate;r||(r=z.createElement("template"),r.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(r.content.cloneNode(!0)),t.appendChild(s)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,T.MEDIA_PAUSED]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=ss(this,It))==null?void 0:r.unassociateElement)==null||n.call(r,this),wo(this,It,null)),s&&this.isConnected&&(wo(this,It,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=ss(this,It))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s,r;this.tabIndex=-1,this.setAttribute("aria-hidden","true"),wo(this,It,sR(this)),this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=ss(this,It))==null?void 0:e.associateElement)==null||t.call(e,this)),(s=ss(this,It))==null||s.addEventListener("pointerdown",this),(r=ss(this,It))==null||r.addEventListener("click",this)}disconnectedCallback(){var e,t,s,r;this.getAttribute(ue.MEDIA_CONTROLLER)&&((t=(e=ss(this,It))==null?void 0:e.unassociateElement)==null||t.call(e,this)),(s=ss(this,It))==null||s.removeEventListener("pointerdown",this),(r=ss(this,It))==null||r.removeEventListener("click",this),wo(this,It,null)}handleEvent(e){var t;const s=(t=e.composedPath())==null?void 0:t[0];if(["video","media-controller"].includes(s==null?void 0:s.localName)){if(e.type==="pointerdown")this._pointerType=e.pointerType;else if(e.type==="click"){const{clientX:n,clientY:a}=e,{left:o,top:l,width:d,height:c}=this.getBoundingClientRect(),u=n-o,h=a-l;if(u<0||h<0||u>d||h>c||d===0&&c===0)return;const{pointerType:f=this._pointerType}=e;if(this._pointerType=void 0,f===j0.TOUCH){this.handleTap(e);return}else if(f===j0.MOUSE){this.handleMouseClick(e);return}}}}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleTap(e){}handleMouseClick(e){const t=this.mediaPaused?K.MEDIA_PLAY_REQUEST:K.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new k.CustomEvent(t,{composed:!0,bubbles:!0}))}}It=new WeakMap;function sR(i){var e;const t=i.getAttribute(ue.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):Rr(i,"media-controller")}k.customElements.get("media-gesture-receiver")||k.customElements.define("media-gesture-receiver",iR);var rR=Object.defineProperty,nR=(i,e,t)=>e in i?rR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,aR=(i,e,t)=>(nR(i,e+"",t),t),Dm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ph=(i,e,t)=>(Dm(i,e,"read from private field"),e.get(i)),Rs=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Eu=(i,e,t,s)=>(Dm(i,e,"write to private field"),e.set(i,t),t),ni=(i,e,t)=>(Dm(i,e,"access private method"),t),Qd,Br,gh,vb,vh,Eb,Xa,Cc,Dc,Mm,Mn,Qa;const ge={AUDIO:"audio",AUTOHIDE:"autohide",BREAKPOINTS:"breakpoints",GESTURES_DISABLED:"gesturesdisabled",KEYBOARD_CONTROL:"keyboardcontrol",NO_AUTOHIDE:"noautohide",USER_INACTIVE:"userinactive"},bb=z.createElement("template");bb.innerHTML=`
56
56
  <style>
57
57
 
58
58
  :host([${T.MEDIA_IS_FULLSCREEN}]) ::slotted([slot=media]) {
@@ -189,7 +189,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
189
189
 
190
190
  <slot part="bottom chrome"></slot>
191
191
  </span>
192
- `;const aR=Object.values(T),oR="sm:384 md:576 lg:768 xl:960";function lR(i){dR(i.target,i.contentRect.width)}function dR(i,e){var t;if(!i.isConnected)return;const s=(t=i.getAttribute(ge.BREAKPOINTS))!=null?t:oR,r=cR(s),n=uR(r,e);let a=!1;if(Object.keys(r).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){const o=new CustomEvent(Ir.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function cR(i){const e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function uR(i,e){return Object.keys(i).filter(t=>e>=i[t])}class yb extends k.HTMLElement{constructor(){super(),Rs(this,gh),Rs(this,vh),Rs(this,Xa),Rs(this,Dc),Rs(this,Mn),Rs(this,Qd,0),Rs(this,Br,void 0),nR(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(bb.content.cloneNode(!0)));const e=a=>{const o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let c=l.previousSibling&&l.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(d);else{let u=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(u=!1);u&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let s=!1;xs(this,a=>{s||(setTimeout(()=>{lR(a),s=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Ir.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),s=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){ph(this,Br)&&this.mediaUnsetCallback(ph(this,Br));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ge.AUTOHIDE,ge.GESTURES_DISABLED].concat(aR).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,s){e.toLowerCase()==ge.AUTOHIDE&&(this.autohide=s)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Eu(this,Br,e),e.localName.includes("-")&&await k.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;const s=this.getAttribute(ge.AUDIO)!=null?Ut.AUDIO_PLAYER():Ut.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",s),this.handleMediaUpdated(this.media),this.setAttribute(ge.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=k.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=k.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Eu(this,Br,null)}handleEvent(e){switch(e.type){case"pointerdown":Eu(this,Qd,e.timeStamp);break;case"pointermove":ni(this,gh,vb).call(this,e);break;case"pointerup":ni(this,vh,Eb).call(this,e);break;case"mouseleave":ni(this,Xa,Cc).call(this);break;case"mouseup":this.removeAttribute(ge.KEYBOARD_CONTROL);break;case"keyup":ni(this,Mn,Qa).call(this),this.setAttribute(ge.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}}Qd=new WeakMap;Br=new WeakMap;gh=new WeakSet;vb=function(i){i.pointerType!=="mouse"&&i.timeStamp-ph(this,Qd)<250||(ni(this,Dc,Mm).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&ni(this,Mn,Qa).call(this))};vh=new WeakSet;Eb=function(i){if(i.pointerType==="touch"){const e=!this.hasAttribute(ge.USER_INACTIVE);[this,this.media].includes(i.target)&&e?ni(this,Xa,Cc).call(this):ni(this,Mn,Qa).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&ni(this,Mn,Qa).call(this)};Xa=new WeakSet;Cc=function(){if(this.autohide<0||this.hasAttribute(ge.USER_INACTIVE))return;this.setAttribute(ge.USER_INACTIVE,"");const i=new k.CustomEvent(Ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};Dc=new WeakSet;Mm=function(){if(!this.hasAttribute(ge.USER_INACTIVE))return;this.removeAttribute(ge.USER_INACTIVE);const i=new k.CustomEvent(Ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Mn=new WeakSet;Qa=function(){ni(this,Dc,Mm).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{ni(this,Xa,Cc).call(this)},this.autohide*1e3))};k.customElements.get("media-container")||k.customElements.define("media-container",yb);var Tb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},it=(i,e,t)=>(Tb(i,e,"read from private field"),t?t.call(i):e.get(i)),qn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Co=(i,e,t,s)=>(Tb(i,e,"write to private field"),e.set(i,t),t),Gr,Hr,Zd,nr,Ki,os;class uo{constructor(e,t,{defaultValue:s}={defaultValue:void 0}){qn(this,Ki),qn(this,Gr,void 0),qn(this,Hr,void 0),qn(this,Zd,void 0),qn(this,nr,new Set),Co(this,Gr,e),Co(this,Hr,t),Co(this,Zd,new Set(s))}[Symbol.iterator](){return it(this,Ki,os).values()}get length(){return it(this,Ki,os).size}get value(){var e;return(e=[...it(this,Ki,os)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Co(this,nr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...it(this,Ki,os)][e]}values(){return it(this,Ki,os).values()}forEach(e){it(this,Ki,os).forEach(e)}add(...e){var t,s;e.forEach(r=>it(this,nr).add(r)),!(this.value===""&&!((t=it(this,Gr))!=null&&t.hasAttribute(`${it(this,Hr)}`)))&&((s=it(this,Gr))==null||s.setAttribute(`${it(this,Hr)}`,`${this.value}`))}remove(...e){var t;e.forEach(s=>it(this,nr).delete(s)),(t=it(this,Gr))==null||t.setAttribute(`${it(this,Hr)}`,`${this.value}`)}contains(e){return it(this,Ki,os).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}Gr=new WeakMap;Hr=new WeakMap;Zd=new WeakMap;nr=new WeakMap;Ki=new WeakSet;os=function(){return it(this,nr).size?it(this,nr):it(this,Zd)};const hR=(i="")=>i.split(/\s+/),_b=(i="")=>{let[e,t,s]=i.split(":");const r=s?decodeURIComponent(s):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:r}},ho=(i="",e={})=>hR(i).map(t=>{const s=_b(t);return{...e,...s}}),Ab=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?_b(e):e):typeof i=="string"?ho(i):[i]:[],Za=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,On=(i=[])=>Array.prototype.map.call(i,Za).join(" "),fR=(i,e)=>t=>t[i]===e,Sb=i=>{const e=Object.entries(i).map(([t,s])=>fR(t,s));return t=>e.every(s=>s(t))},Na=(i,e=[],t=[])=>{const s=Ab(t).map(Sb),r=n=>s.some(a=>a(n));Array.from(e).filter(r).forEach(n=>{n.mode=i})},Mc=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];const t=typeof e=="function"?e:Sb(e);return Array.from(i.textTracks).filter(t)},xb=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)},Me={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};z.fullscreenElement===void 0&&(Me.enter="webkitRequestFullScreen",Me.exit=z.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Me.rootEvents=["webkitfullscreenchange"],Me.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],Me.element="webkitFullscreenElement",Me.error="webkitfullscreenerror",Me.enabled="webkitFullscreenEnabled");let Do;const Om=()=>{var i,e;return Do||(Do=(e=(i=z)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),Do)},mR=async(i=Om())=>{if(!i)return!1;const e=i.volume;return i.volume=e/2+.1,await ab(0),i.volume!==e},pR=/.*Version\/.*Safari\/.*/.test(k.navigator.userAgent),kb=(i=Om())=>k.matchMedia("(display-mode: standalone)").matches&&pR?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Lb=(i=Om())=>{let e=z[Me.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},gR=Lb(),vR=kb(),ER=!!k.WebKitPlaybackTargetAvailabilityEvent,bR=!!k.chrome,Jd=i=>Mc(i.media,e=>[_s.SUBTITLES,_s.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Ib=i=>Mc(i.media,e=>e.mode===yn.SHOWING&&[_s.SUBTITLES,_s.CAPTIONS].includes(e.kind)),Rb=(i,e)=>{const t=Jd(i),s=Ib(i),r=!!s.length;if(t.length){if(e===!1||r&&e!==!0)Na(yn.DISABLED,t,s);else if(e===!0||!r&&e!==!1){let n=t[0];const{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){const c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{const p=u.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),g=u.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return p-g});h[0]&&(n=h[0])}const{language:o,label:l,kind:d}=n;Na(yn.DISABLED,t,s),Na(yn.SHOWING,t,[{language:o,label:l,kind:d}])}}},Pm=(i,e)=>i===e?!0:typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?yR(i,e):Object.entries(i).every(([t,s])=>t in e&&Pm(s,e[t])),yR=(i,e)=>{const t=Array.isArray(i),s=Array.isArray(e);return t!==s?!1:t||s?i.length!==e.length?!1:i.every((r,n)=>Pm(r,e[n])):!0},TR=Object.values(Xi);let ec;const _R=mR().then(i=>(ec=i,ec)),AR=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof k.HTMLElement))return;const t=e.localName;if(!t.includes("-"))return;const s=k.customElements.get(t);s&&e instanceof s||(await k.customElements.whenDefined(t),k.customElements.upgrade(e))}))},cl={mediaPaused:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;const{media:s}=e;s&&(i?s.pause():(t=s.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){const{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){const{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){const{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){const{media:t}=e;if(t){try{i==null?k.localStorage.removeItem("media-chrome-pref-volume"):k.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{const{options:{noVolumePref:t}}=e;if(!t)try{const s=k.localStorage.getItem("media-chrome-pref-volume");if(s==null)return;cl.mediaVolume.set(+s,e),i(s)}catch(s){console.debug("Error getting volume pref",s)}}]},mediaVolumeLevel:{get(i){const{media:e}=i;return typeof(e==null?void 0:e.volume)>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){const{media:t}=e;!t||t.readyState===0||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){const{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){const{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;const{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;const s=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!s&&!r))return[Number(s.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;const{media:t}=i,s=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(s).map((r,n)=>[Number(s.start(n).toFixed(3)),Number(s.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){const{media:e,options:{defaultStreamType:t}={}}=i,s=[Xi.LIVE,Xi.ON_DEMAND].includes(t)?t:void 0;if(!e)return s;const{streamType:r}=e;if(TR.includes(r))return r===Xi.UNKNOWN?s:r;const n=e.duration;return n===1/0?Xi.LIVE:Number.isFinite(n)?Xi.ON_DEMAND:s},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){const{media:e}=i;if(!e)return Number.NaN;const{targetLiveWindow:t}=e,s=cl.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&s===Xi.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){const{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(cl.mediaStreamType.get(i)===Xi.LIVE))return!1;const r=e.seekable;if(!r)return!0;if(!r.length)return!1;const n=r.end(r.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return Jd(i).map(({kind:e,label:t,language:s})=>({kind:e,label:t,language:s}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return Ib(i).map(({kind:e,label:t,language:s})=>({kind:e,label:t,language:s}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,s;const{media:r,options:n}=e;if(!r)return;const a=o=>{var l;!n.defaultSubtitles||o&&![_s.CAPTIONS,_s.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||Rb(e,!0)};return(t=r.textTracks)==null||t.addEventListener("addtrack",a),(s=r.textTracks)==null||s.addEventListener("removetrack",a),a(),()=>{var o,l;(o=r.textTracks)==null||o.removeEventListener("addtrack",a),(l=r.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;const{media:t}=i;if(!t)return[];const[s]=Mc(t,{kind:_s.CHAPTERS});return Array.from((e=s==null?void 0:s.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:r,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{const{media:t}=e;if(!t)return;const s=t.querySelector('track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;const{media:s,documentElement:r}=i;if(!s||!r||!r.pictureInPictureElement)return!1;if(r.pictureInPictureElement===s)return!0;if(r.pictureInPictureElement instanceof HTMLMediaElement)return(e=s.localName)!=null&&e.includes("-")?Ni(s,r.pictureInPictureElement):!1;if(r.pictureInPictureElement.localName.includes("-")){let n=r.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===s)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){const{media:t}=e;if(t)if(i){if(!z.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}const s=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(r=>{if(r.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){const n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(s),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&s(),n()},1e3)}else throw r}else throw r})}else z.pictureInPictureElement&&z.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(s=>({...s}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,s;const{media:r}=i;return(s=(t=r==null?void 0:r.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:s.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}const s=i,r=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==s);t.videoRenditions.selectedIndex!=r&&(t.videoRenditions.selectedIndex=r)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;const{media:s}=i;return(t=[...(e=s==null?void 0:s.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}const s=i;for(let r of t.audioTracks)r.enabled=s==r.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){var e;const{media:t,documentElement:s,fullscreenElement:r=t}=i;if(!t||!s)return!1;if(!s[Me.element])return"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t?t.webkitDisplayingFullscreen&&t.webkitPresentationMode===$I.FULLSCREEN:!1;if(s[Me.element]===r)return!0;if(s[Me.element].localName.includes("-")){let n=s[Me.element].shadowRoot;if(!(Me.element in n))return Ni(s[Me.element],r);for(;n!=null&&n[Me.element];){if(n[Me.element]===r)return!0;n=(e=n[Me.element])==null?void 0:e.shadowRoot}}return!1},set(i,e){var t,s;const{media:r,fullscreenElement:n,documentElement:a}=e;if(!i&&(a!=null&&a[Me.exit])){const o=(t=a==null?void 0:a[Me.exit])==null?void 0:t.call(a);o instanceof Promise&&o.catch(()=>{});return}if(n!=null&&n[Me.enter]){const o=(s=n[Me.enter])==null?void 0:s.call(n);o instanceof Promise&&o.catch(()=>{})}else r!=null&&r.webkitEnterFullscreen?r.webkitEnterFullscreen():r!=null&&r.requestFullscreen&&r.requestFullscreen()},rootEvents:Me.rootEvents,mediaEvents:Me.mediaEvents},mediaIsCasting:{get(i){var e;const{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,s;const{media:r}=e;if(r&&!(i&&((t=r.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((s=r.remote)==null?void 0:s.state)!=="connected")){if(typeof r.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}r.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){const{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&k.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){const{media:e}=i;if(!gR||!Lb(e))return Bt.UNSUPPORTED}},mediaPipUnavailable:{get(i){const{media:e}=i;if(!vR||!kb(e))return Bt.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){const{media:e}=i;if(ec===!1||(e==null?void 0:e.volume)==null)return Bt.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{ec==null&&_R.then(e=>i(e?void 0:Bt.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;const{media:s}=i;if(!bR||!((t=s==null?void 0:s.remote)!=null&&t.state))return Bt.UNSUPPORTED;if(!(e==null||e==="available"))return Bt.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:s}=e;return s?(s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(t=s==null?void 0:s.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=s==null?void 0:s.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!ER)return Bt.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Bt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:s}=e;return s?(s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(t=s==null?void 0:s.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=s==null?void 0:s.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;const{media:t}=i;if(!(t!=null&&t.videoRenditions))return Bt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;const{media:s}=i;if(!(s!=null&&s.audioTracks))return Bt.UNSUPPORTED;if(((t=(e=s.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}},SR={[K.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var s,r,n;const{media:a}=e,o=t??void 0;let l,d;if(a&&o!=null){const[f]=Mc(a,{kind:_s.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((s=f==null?void 0:f.cues)!=null?s:[],(p,g,v)=>g===0?p.endTime>o:g===v.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){const p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(r=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(y=>+y),l=g.href}}const c=i.mediaDuration.get(e);let h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&c===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[K.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[K.MEDIA_PLAY_REQUEST](i,e){var t;const s="mediaPaused";if(i.mediaStreamType.get(e)===Xi.LIVE){const a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[s].set(!1,e)},[K.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){const s="mediaPlaybackRate",r=t;i[s].set(r,e)},[K.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[K.MEDIA_UNMUTE_REQUEST](i,e){const t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[K.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){const s="mediaVolume",r=t;r&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[s].set(r,e)},[K.MEDIA_SEEK_REQUEST](i,e,{detail:t}){const s="mediaCurrentTime",r=t;i[s].set(r,e)},[K.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;const s="mediaCurrentTime",r=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(r))&&i[s].set(r,e)},[K.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var s;const{options:r}=e,n=Jd(e),a=Ab(t),o=(s=a[0])==null?void 0:s.language;o&&!r.noSubtitlesLangPref&&k.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Na(yn.SHOWING,n,a)},[K.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){const s=Jd(e),r=t??[];Na(yn.DISABLED,s,r)},[K.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){Rb(e,t)},[K.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){const s="mediaRenditionSelected",r=t;i[s].set(r,e)},[K.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){const s="mediaAudioTrackEnabled",r=t;i[s].set(r,e)},[K.MEDIA_ENTER_PIP_REQUEST](i,e){const t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[K.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[K.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){const t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[K.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[K.MEDIA_ENTER_CAST_REQUEST](i,e){const t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[K.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[K.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}},xR=({media:i,fullscreenElement:e,documentElement:t,stateMediator:s=cl,requestMap:r=SR,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{const o=[],l={options:{...n}};let d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0});const c=p=>{p!=null&&(Pm(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},u=()=>{const p=Object.entries(s).reduce((g,[v,{get:y}])=>(g[v]=y(l),g),{});c(p)},h={};let f;const m=async(p,g)=>{var v,y,b,x,_,S,A,D,O,L,C,H,U,Q,q,Y;const oe=!!f;if(f={...l,...f??{},...p},oe)return;await AR(...Object.values(p));const ae=o.length>0&&g===0&&a,G=l.media!==f.media,F=((v=l.media)==null?void 0:v.textTracks)!==((y=f.media)==null?void 0:y.textTracks),re=((b=l.media)==null?void 0:b.videoRenditions)!==((x=f.media)==null?void 0:x.videoRenditions),J=((_=l.media)==null?void 0:_.audioTracks)!==((S=f.media)==null?void 0:S.audioTracks),de=((A=l.media)==null?void 0:A.remote)!==((D=f.media)==null?void 0:D.remote),Ae=l.documentElement!==f.documentElement,Ce=!!l.media&&(G||ae),He=!!((O=l.media)!=null&&O.textTracks)&&(F||ae),St=!!((L=l.media)!=null&&L.videoRenditions)&&(re||ae),ts=!!((C=l.media)!=null&&C.audioTracks)&&(J||ae),wr=!!((H=l.media)!=null&&H.remote)&&(de||ae),Ap=!!l.documentElement&&(Ae||ae),Sp=Ce||He||St||ts||wr||Ap,Cr=o.length===0&&g===1&&a,xp=!!f.media&&(G||Cr),kp=!!((U=f.media)!=null&&U.textTracks)&&(F||Cr),Lp=!!((Q=f.media)!=null&&Q.videoRenditions)&&(re||Cr),Ip=!!((q=f.media)!=null&&q.audioTracks)&&(J||Cr),Rp=!!((Y=f.media)!=null&&Y.remote)&&(de||Cr),wp=!!f.documentElement&&(Ae||Cr),Cp=xp||kp||Lp||Ip||Rp||wp;if(!(Sp||Cp)){Object.entries(f).forEach(([Se,Hn])=>{l[Se]=Hn}),u(),f=void 0;return}Object.entries(s).forEach(([Se,{get:Hn,mediaEvents:n_=[],textTracksEvents:a_=[],videoRenditionsEvents:o_=[],audioTracksEvents:l_=[],remoteEvents:d_=[],rootEvents:c_=[],stateOwnersUpdateHandlers:u_=[]}])=>{h[Se]||(h[Se]={});const Mt=Be=>{const Ot=Hn(l,Be);c({[Se]:Ot})};let Ze;Ze=h[Se].mediaEvents,n_.forEach(Be=>{Ze&&Ce&&(l.media.removeEventListener(Be,Ze),h[Se].mediaEvents=void 0),xp&&(f.media.addEventListener(Be,Mt),h[Se].mediaEvents=Mt)}),Ze=h[Se].textTracksEvents,a_.forEach(Be=>{var Ot,qt;Ze&&He&&((Ot=l.media.textTracks)==null||Ot.removeEventListener(Be,Ze),h[Se].textTracksEvents=void 0),kp&&((qt=f.media.textTracks)==null||qt.addEventListener(Be,Mt),h[Se].textTracksEvents=Mt)}),Ze=h[Se].videoRenditionsEvents,o_.forEach(Be=>{var Ot,qt;Ze&&St&&((Ot=l.media.videoRenditions)==null||Ot.removeEventListener(Be,Ze),h[Se].videoRenditionsEvents=void 0),Lp&&((qt=f.media.videoRenditions)==null||qt.addEventListener(Be,Mt),h[Se].videoRenditionsEvents=Mt)}),Ze=h[Se].audioTracksEvents,l_.forEach(Be=>{var Ot,qt;Ze&&ts&&((Ot=l.media.audioTracks)==null||Ot.removeEventListener(Be,Ze),h[Se].audioTracksEvents=void 0),Ip&&((qt=f.media.audioTracks)==null||qt.addEventListener(Be,Mt),h[Se].audioTracksEvents=Mt)}),Ze=h[Se].remoteEvents,d_.forEach(Be=>{var Ot,qt;Ze&&wr&&((Ot=l.media.remote)==null||Ot.removeEventListener(Be,Ze),h[Se].remoteEvents=void 0),Rp&&((qt=f.media.remote)==null||qt.addEventListener(Be,Mt),h[Se].remoteEvents=Mt)}),Ze=h[Se].rootEvents,c_.forEach(Be=>{Ze&&Ap&&(l.documentElement.removeEventListener(Be,Ze),h[Se].rootEvents=void 0),wp&&(f.documentElement.addEventListener(Be,Mt),h[Se].rootEvents=Mt)});const Dp=h[Se].stateOwnersUpdateHandlers;u_.forEach(Be=>{Dp&&Sp&&Dp(),Cp&&(h[Se].stateOwnersUpdateHandlers=Be(Mt,f))})}),Object.entries(f).forEach(([Se,Hn])=>{l[Se]=Hn}),u(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){const{type:g,detail:v}=p;if(r[g]){c(r[g](s,l,p));return}g==="mediaelementchangerequest"?m({media:v}):g==="fullscreenelementchangerequest"?m({fullscreenElement:v}):g==="documentelementchangerequest"?m({documentElement:v}):g==="optionschangerequest"&&Object.entries(v??{}).forEach(([y,b])=>{l.options[y]=b})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{const g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var kR=xR,Nm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},he=(i,e,t)=>(Nm(i,e,"read from private field"),t?t.call(i):e.get(i)),Gi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},rs=(i,e,t,s)=>(Nm(i,e,"write to private field"),e.set(i,t),t),vs=(i,e,t)=>(Nm(i,e,"access private method"),t),Es,oa,Re,la,hi,ul,hl,Eh,Pn,Ja,fl,bh;const wb=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Z0=10,me={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"};class Cb extends yb{constructor(){super(),Gi(this,hl),Gi(this,Pn),Gi(this,fl),Gi(this,Es,new uo(this,me.HOTKEYS)),Gi(this,oa,void 0),Gi(this,Re,void 0),Gi(this,la,void 0),Gi(this,hi,void 0),Gi(this,ul,t=>{var s;(s=he(this,Re))==null||s.dispatch(t)}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this);let e={};rs(this,la,t=>{Object.entries(t).forEach(([s,r])=>{if(s in e&&e[s]===r)return;this.propagateMediaState(s,r);const n=s.toLowerCase(),a=new k.CustomEvent(FI[n],{composed:!0,detail:r});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(me.NO_HOTKEYS,me.HOTKEYS,me.DEFAULT_STREAM_TYPE,me.DEFAULT_SUBTITLES,me.DEFAULT_DURATION)}get mediaStore(){return he(this,Re)}set mediaStore(e){var t,s;if(he(this,Re)&&((t=he(this,hi))==null||t.call(this),rs(this,hi,void 0)),rs(this,Re,e),!he(this,Re)&&!this.hasAttribute(me.NO_DEFAULT_STORE)){vs(this,hl,Eh).call(this);return}rs(this,hi,(s=he(this,Re))==null?void 0:s.subscribe(he(this,la)))}get fullscreenElement(){var e;return(e=he(this,oa))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(me.FULLSCREEN_ELEMENT)&&this.removeAttribute(me.FULLSCREEN_ELEMENT),rs(this,oa,e),(t=he(this,Re))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,s){var r,n,a,o,l,d;if(super.attributeChangedCallback(e,t,s),e===me.NO_HOTKEYS)s!==t&&s===""?(this.hasAttribute(me.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):s!==t&&s===null&&this.enableHotkeys();else if(e===me.HOTKEYS)he(this,Es).value=s;else if(e===me.DEFAULT_SUBTITLES&&s!==t)(r=he(this,Re))==null||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(me.DEFAULT_SUBTITLES)}});else if(e===me.DEFAULT_STREAM_TYPE)(a=he(this,Re))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(me.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===me.LIVE_EDGE_OFFSET)(o=he(this,Re))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(me.LIVE_EDGE_OFFSET)?+this.getAttribute(me.LIVE_EDGE_OFFSET):void 0}});else if(e===me.FULLSCREEN_ELEMENT){const c=s?(l=this.getRootNode())==null?void 0:l.getElementById(s):void 0;rs(this,oa,c),(d=he(this,Re))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!he(this,Re)&&!this.hasAttribute(me.NO_DEFAULT_STORE)&&vs(this,hl,Eh).call(this),(e=he(this,Re))==null||e.dispatch({type:"documentelementchangerequest",detail:z}),super.connectedCallback(),he(this,Re)&&!he(this,hi)&&rs(this,hi,(t=he(this,Re))==null?void 0:t.subscribe(he(this,la))),this.enableHotkeys()}disconnectedCallback(){var e,t,s,r;(e=super.disconnectedCallback)==null||e.call(this),he(this,Re)&&((t=he(this,Re))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(s=he(this,Re))==null||s.dispatch({type:K.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),he(this,hi)&&((r=he(this,hi))==null||r.call(this),rs(this,hi,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=he(this,Re))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=he(this,Re))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){tg(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(t.has(e))return;const s=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=DR(e,s,r);Object.values(K).forEach(a=>{e.addEventListener(a,he(this,ul))}),t.set(e,n)}unassociateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(K).forEach(r=>{e.removeEventListener(r,he(this,ul))})}registerMediaStateReceiver(e){if(!e)return;const t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),he(this,Re)&&Object.entries(he(this,Re).getState()).forEach(([r,n])=>{tg([e],r,n)}))}unregisterMediaStateReceiver(e){const t=this.mediaStateReceivers,s=t.indexOf(e);s<0||t.splice(s,1)}enableHotkeys(){this.addEventListener("keydown",vs(this,fl,bh))}disableHotkeys(){this.removeEventListener("keydown",vs(this,fl,bh)),this.removeEventListener("keyup",vs(this,Pn,Ja))}get hotkeys(){return he(this,Es)}keyboardShortcutHandler(e){var t,s,r,n,a,o;if(((n=(r=(t=e.target.getAttribute(me.KEYS_USED))==null?void 0:t.split(" "))!=null?r:(s=e.target)==null?void 0:s.keysUsed)!=null?n:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,c,u;if(!he(this,Es).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&he(this,Es).contains("nospace")))switch(e.key){case" ":case"k":d=he(this,Re).getState().mediaPaused?K.MEDIA_PLAY_REQUEST:K.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new k.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?K.MEDIA_UNMUTE_REQUEST:K.MEDIA_MUTE_REQUEST,this.dispatchEvent(new k.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?K.MEDIA_EXIT_FULLSCREEN_REQUEST:K.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new k.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new k.CustomEvent(K.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{const h=this.hasAttribute(me.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(me.KEYBOARD_BACKWARD_SEEK_OFFSET):Z0;c=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)-h,0),u=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}case"ArrowRight":{const h=this.hasAttribute(me.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(me.KEYBOARD_FORWARD_SEEK_OFFSET):Z0;c=Math.max(((o=this.mediaStore.getState().mediaCurrentTime)!=null?o:0)+h,0),u=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}}}}Es=new WeakMap;oa=new WeakMap;Re=new WeakMap;la=new WeakMap;hi=new WeakMap;ul=new WeakMap;hl=new WeakSet;Eh=function(){var i;this.mediaStore=kR({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(me.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(me.DEFAULT_DURATION)?+this.getAttribute(me.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(me.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(me.LIVE_EDGE_OFFSET)?+this.getAttribute(me.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(me.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(me.NO_SUBTITLES_LANG_PREF)}})};Pn=new WeakSet;Ja=function(i){const{key:e}=i;if(!wb.includes(e)){this.removeEventListener("keyup",vs(this,Pn,Ja));return}this.keyboardShortcutHandler(i)};fl=new WeakSet;bh=function(i){const{metaKey:e,altKey:t,key:s}=i;if(e||t||!wb.includes(s)){this.removeEventListener("keyup",vs(this,Pn,Ja));return}[" ","ArrowLeft","ArrowRight"].includes(s)&&!(he(this,Es).contains(`no${s.toLowerCase()}`)||s===" "&&he(this,Es).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",vs(this,Pn,Ja),{once:!0})};const LR=Object.values(T),IR=Object.values(tb),Db=i=>{var e,t,s,r;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(k.customElements.upgrade(i),{observedAttributes:n}=i.constructor);const a=(r=(s=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,ue.MEDIA_CHROME_ATTRIBUTES))==null?void 0:s.split)==null?void 0:r.call(s,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>LR.includes(o)):[]},RR=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&k.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof k.customElements.get(i.nodeName.toLowerCase()))&&k.customElements.upgrade(i),IR.some(s=>s in i)},yh=i=>RR(i)||!!Db(i).length,J0=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},eg={[T.MEDIA_SUBTITLES_LIST]:On,[T.MEDIA_SUBTITLES_SHOWING]:On,[T.MEDIA_SEEKABLE]:J0,[T.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(J0).join(" "),[T.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[T.MEDIA_RENDITION_LIST]:BI,[T.MEDIA_AUDIO_TRACK_LIST]:WI},wR=async(i,e,t)=>{var s,r;if(i.isConnected||await ab(0),typeof t=="boolean"||t==null)return ot(i,e,t);if(typeof t=="number")return nt(i,e,t);if(typeof t=="string")return qe(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);const n=(r=(s=eg[e])==null?void 0:s.call(eg,t))!=null?r:t;return i.setAttribute(e,n)},CR=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Ps=(i,e)=>{if(CR(i))return;const t=(r,n)=>{var a,o;yh(r)&&n(r);const{children:l=[]}=r??{},d=(o=(a=r==null?void 0:r.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Ps(u,n))},s=i==null?void 0:i.nodeName.toLowerCase();if(s.includes("-")&&!yh(i)){k.customElements.whenDefined(s).then(()=>{t(i,e)});return}t(i,e)},tg=(i,e,t)=>{i.forEach(s=>{if(e in s){s[e]=t;return}const r=Db(s),n=e.toLowerCase();r.includes(n)&&wR(s,n,t)})},DR=(i,e,t)=>{Ps(i,e);const s=c=>{var u;const h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;e(h)},r=c=>{var u;const h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;t(h)};i.addEventListener(K.REGISTER_MEDIA_STATE_RECEIVER,s),i.addEventListener(K.UNREGISTER_MEDIA_STATE_RECEIVER,r);const n=c=>{c.forEach(u=>{const{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=u;m==="childList"?(Array.prototype.forEach.call(h,v=>Ps(v,e)),Array.prototype.forEach.call(f,v=>Ps(v,t))):m==="attributes"&&g===ue.MEDIA_CHROME_ATTRIBUTES&&(yh(p)?e(p):t(p))})};let a=[];const o=c=>{const u=c.target;u.name!=="media"&&(a.forEach(h=>Ps(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Ps(h,e)))};i.addEventListener("slotchange",o);const l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Ps(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(K.REGISTER_MEDIA_STATE_RECEIVER,s),i.removeEventListener(K.UNREGISTER_MEDIA_STATE_RECEIVER,r)}};k.customElements.get("media-controller")||k.customElements.define("media-controller",Cb);var MR=Cb,OR=Object.defineProperty,PR=(i,e,t)=>e in i?OR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,NR=(i,e,t)=>(PR(i,e+"",t),t),Mb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Gt=(i,e,t)=>(Mb(i,e,"read from private field"),t?t.call(i):e.get(i)),Mo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Oo=(i,e,t,s)=>(Mb(i,e,"write to private field"),e.set(i,t),t),fi,ml,Wr,pl;const Ob=z.createElement("template");Ob.innerHTML=`
192
+ `;const oR=Object.values(T),lR="sm:384 md:576 lg:768 xl:960";function dR(i){cR(i.target,i.contentRect.width)}function cR(i,e){var t;if(!i.isConnected)return;const s=(t=i.getAttribute(ge.BREAKPOINTS))!=null?t:lR,r=uR(s),n=hR(r,e);let a=!1;if(Object.keys(r).forEach(o=>{if(n.includes(o)){i.hasAttribute(`breakpoint${o}`)||(i.setAttribute(`breakpoint${o}`,""),a=!0);return}i.hasAttribute(`breakpoint${o}`)&&(i.removeAttribute(`breakpoint${o}`),a=!0)}),a){const o=new CustomEvent(Ir.BREAKPOINTS_CHANGE,{detail:n});i.dispatchEvent(o)}}function uR(i){const e=i.split(/\s+/);return Object.fromEntries(e.map(t=>t.split(":")))}function hR(i,e){return Object.keys(i).filter(t=>e>=i[t])}class yb extends k.HTMLElement{constructor(){super(),Rs(this,gh),Rs(this,vh),Rs(this,Xa),Rs(this,Dc),Rs(this,Mn),Rs(this,Qd,0),Rs(this,Br,void 0),aR(this,"breakpointsComputed",!1),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(bb.content.cloneNode(!0)));const e=a=>{const o=this.media;for(let l of a)l.type==="childList"&&(l.removedNodes.forEach(d=>{if(d.slot=="media"&&l.target==this){let c=l.previousSibling&&l.previousSibling.previousElementSibling;if(!c||!o)this.mediaUnsetCallback(d);else{let u=c.slot!=="media";for(;(c=c.previousSibling)!==null;)c.slot=="media"&&(u=!1);u&&this.mediaUnsetCallback(d)}}}),o&&l.addedNodes.forEach(d=>{d===o&&this.handleMediaUpdated(o)}))};new MutationObserver(e).observe(this,{childList:!0,subtree:!0});let s=!1;xs(this,a=>{s||(setTimeout(()=>{dR(a),s=!1,this.breakpointsComputed||(this.breakpointsComputed=!0,this.dispatchEvent(new CustomEvent(Ir.BREAKPOINTS_COMPUTED,{bubbles:!0,composed:!0})))},0),s=!0)});let n=this.querySelector(":scope > slot[slot=media]");n&&n.addEventListener("slotchange",()=>{if(!n.assignedElements({flatten:!0}).length){ph(this,Br)&&this.mediaUnsetCallback(ph(this,Br));return}this.handleMediaUpdated(this.media)})}static get observedAttributes(){return[ge.AUTOHIDE,ge.GESTURES_DISABLED].concat(oR).filter(e=>![T.MEDIA_RENDITION_LIST,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_CHAPTERS_CUES].includes(e))}attributeChangedCallback(e,t,s){e.toLowerCase()==ge.AUTOHIDE&&(this.autohide=s)}get media(){let e=this.querySelector(":scope > [slot=media]");return(e==null?void 0:e.nodeName)=="SLOT"&&(e=e.assignedElements({flatten:!0})[0]),e}async handleMediaUpdated(e){e&&(Eu(this,Br,e),e.localName.includes("-")&&await k.customElements.whenDefined(e.localName),this.mediaSetCallback(e))}connectedCallback(){var e;const s=this.getAttribute(ge.AUDIO)!=null?Ut.AUDIO_PLAYER():Ut.VIDEO_PLAYER();this.setAttribute("role","region"),this.setAttribute("aria-label",s),this.handleMediaUpdated(this.media),this.setAttribute(ge.USER_INACTIVE,""),this.addEventListener("pointerdown",this),this.addEventListener("pointermove",this),this.addEventListener("pointerup",this),this.addEventListener("mouseleave",this),this.addEventListener("keyup",this),(e=k.window)==null||e.addEventListener("mouseup",this)}disconnectedCallback(){var e;this.media&&this.mediaUnsetCallback(this.media),(e=k.window)==null||e.removeEventListener("mouseup",this)}mediaSetCallback(e){}mediaUnsetCallback(e){Eu(this,Br,null)}handleEvent(e){switch(e.type){case"pointerdown":Eu(this,Qd,e.timeStamp);break;case"pointermove":ni(this,gh,vb).call(this,e);break;case"pointerup":ni(this,vh,Eb).call(this,e);break;case"mouseleave":ni(this,Xa,Cc).call(this);break;case"mouseup":this.removeAttribute(ge.KEYBOARD_CONTROL);break;case"keyup":ni(this,Mn,Qa).call(this),this.setAttribute(ge.KEYBOARD_CONTROL,"");break}}set autohide(e){e=Number(e),this._autohide=isNaN(e)?0:e}get autohide(){return this._autohide===void 0?2:this._autohide}}Qd=new WeakMap;Br=new WeakMap;gh=new WeakSet;vb=function(i){i.pointerType!=="mouse"&&i.timeStamp-ph(this,Qd)<250||(ni(this,Dc,Mm).call(this),clearTimeout(this._inactiveTimeout),[this,this.media].includes(i.target)&&ni(this,Mn,Qa).call(this))};vh=new WeakSet;Eb=function(i){if(i.pointerType==="touch"){const e=!this.hasAttribute(ge.USER_INACTIVE);[this,this.media].includes(i.target)&&e?ni(this,Xa,Cc).call(this):ni(this,Mn,Qa).call(this)}else i.composedPath().some(e=>["media-play-button","media-fullscreen-button"].includes(e==null?void 0:e.localName))&&ni(this,Mn,Qa).call(this)};Xa=new WeakSet;Cc=function(){if(this.autohide<0||this.hasAttribute(ge.USER_INACTIVE))return;this.setAttribute(ge.USER_INACTIVE,"");const i=new k.CustomEvent(Ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!0});this.dispatchEvent(i)};Dc=new WeakSet;Mm=function(){if(!this.hasAttribute(ge.USER_INACTIVE))return;this.removeAttribute(ge.USER_INACTIVE);const i=new k.CustomEvent(Ir.USER_INACTIVE,{composed:!0,bubbles:!0,detail:!1});this.dispatchEvent(i)};Mn=new WeakSet;Qa=function(){ni(this,Dc,Mm).call(this),clearTimeout(this._inactiveTimeout),!(this.autohide<0)&&(this._inactiveTimeout=setTimeout(()=>{ni(this,Xa,Cc).call(this)},this.autohide*1e3))};k.customElements.get("media-container")||k.customElements.define("media-container",yb);var Tb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},it=(i,e,t)=>(Tb(i,e,"read from private field"),t?t.call(i):e.get(i)),qn=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Co=(i,e,t,s)=>(Tb(i,e,"write to private field"),e.set(i,t),t),Gr,Hr,Zd,nr,Ki,os;class uo{constructor(e,t,{defaultValue:s}={defaultValue:void 0}){qn(this,Ki),qn(this,Gr,void 0),qn(this,Hr,void 0),qn(this,Zd,void 0),qn(this,nr,new Set),Co(this,Gr,e),Co(this,Hr,t),Co(this,Zd,new Set(s))}[Symbol.iterator](){return it(this,Ki,os).values()}get length(){return it(this,Ki,os).size}get value(){var e;return(e=[...it(this,Ki,os)].join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Co(this,nr,new Set),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return[...it(this,Ki,os)][e]}values(){return it(this,Ki,os).values()}forEach(e){it(this,Ki,os).forEach(e)}add(...e){var t,s;e.forEach(r=>it(this,nr).add(r)),!(this.value===""&&!((t=it(this,Gr))!=null&&t.hasAttribute(`${it(this,Hr)}`)))&&((s=it(this,Gr))==null||s.setAttribute(`${it(this,Hr)}`,`${this.value}`))}remove(...e){var t;e.forEach(s=>it(this,nr).delete(s)),(t=it(this,Gr))==null||t.setAttribute(`${it(this,Hr)}`,`${this.value}`)}contains(e){return it(this,Ki,os).has(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){return this.remove(e),this.add(t),e===t}}Gr=new WeakMap;Hr=new WeakMap;Zd=new WeakMap;nr=new WeakMap;Ki=new WeakSet;os=function(){return it(this,nr).size?it(this,nr):it(this,Zd)};const fR=(i="")=>i.split(/\s+/),_b=(i="")=>{let[e,t,s]=i.split(":");const r=s?decodeURIComponent(s):void 0;return e=e==="cc"?"captions":"subtitles",{kind:e,language:t,label:r}},ho=(i="",e={})=>fR(i).map(t=>{const s=_b(t);return{...e,...s}}),Ab=i=>i?Array.isArray(i)?i.map(e=>typeof e=="string"?_b(e):e):typeof i=="string"?ho(i):[i]:[],Za=({kind:i,label:e,language:t}={kind:"subtitles"})=>e?`${i==="captions"?"cc":"sb"}:${t}:${encodeURIComponent(e)}`:t,On=(i=[])=>Array.prototype.map.call(i,Za).join(" "),mR=(i,e)=>t=>t[i]===e,Sb=i=>{const e=Object.entries(i).map(([t,s])=>mR(t,s));return t=>e.every(s=>s(t))},Na=(i,e=[],t=[])=>{const s=Ab(t).map(Sb),r=n=>s.some(a=>a(n));Array.from(e).filter(r).forEach(n=>{n.mode=i})},Mc=(i,e=()=>!0)=>{if(!(i!=null&&i.textTracks))return[];const t=typeof e=="function"?e:Sb(e);return Array.from(i.textTracks).filter(t)},xb=i=>{var e;return!!((e=i.mediaSubtitlesShowing)!=null&&e.length)||i.hasAttribute(T.MEDIA_SUBTITLES_SHOWING)},Me={enter:"requestFullscreen",exit:"exitFullscreen",rootEvents:["fullscreenchange"],mediaEvents:[],element:"fullscreenElement",error:"fullscreenerror",enabled:"fullscreenEnabled"};z.fullscreenElement===void 0&&(Me.enter="webkitRequestFullScreen",Me.exit=z.webkitExitFullscreen!=null?"webkitExitFullscreen":"webkitCancelFullScreen",Me.rootEvents=["webkitfullscreenchange"],Me.mediaEvents=["webkitbeginfullscreen","webkitendfullscreen"],Me.element="webkitFullscreenElement",Me.error="webkitfullscreenerror",Me.enabled="webkitFullscreenEnabled");let Do;const Om=()=>{var i,e;return Do||(Do=(e=(i=z)==null?void 0:i.createElement)==null?void 0:e.call(i,"video"),Do)},pR=async(i=Om())=>{if(!i)return!1;const e=i.volume;return i.volume=e/2+.1,await ab(0),i.volume!==e},gR=/.*Version\/.*Safari\/.*/.test(k.navigator.userAgent),kb=(i=Om())=>k.matchMedia("(display-mode: standalone)").matches&&gR?!1:typeof(i==null?void 0:i.requestPictureInPicture)=="function",Lb=(i=Om())=>{let e=z[Me.enabled];return!e&&i&&(e="webkitSupportsFullscreen"in i),e},vR=Lb(),ER=kb(),bR=!!k.WebKitPlaybackTargetAvailabilityEvent,yR=!!k.chrome,Jd=i=>Mc(i.media,e=>[_s.SUBTITLES,_s.CAPTIONS].includes(e.kind)).sort((e,t)=>e.kind>=t.kind?1:-1),Ib=i=>Mc(i.media,e=>e.mode===yn.SHOWING&&[_s.SUBTITLES,_s.CAPTIONS].includes(e.kind)),Rb=(i,e)=>{const t=Jd(i),s=Ib(i),r=!!s.length;if(t.length){if(e===!1||r&&e!==!0)Na(yn.DISABLED,t,s);else if(e===!0||!r&&e!==!1){let n=t[0];const{options:a}=i;if(!(a!=null&&a.noSubtitlesLangPref)){const c=globalThis.localStorage.getItem("media-chrome-pref-subtitles-lang"),u=c?[c,...globalThis.navigator.languages]:globalThis.navigator.languages,h=t.filter(f=>u.some(m=>f.language.toLowerCase().startsWith(m.split("-")[0]))).sort((f,m)=>{const p=u.findIndex(v=>f.language.toLowerCase().startsWith(v.split("-")[0])),g=u.findIndex(v=>m.language.toLowerCase().startsWith(v.split("-")[0]));return p-g});h[0]&&(n=h[0])}const{language:o,label:l,kind:d}=n;Na(yn.DISABLED,t,s),Na(yn.SHOWING,t,[{language:o,label:l,kind:d}])}}},Pm=(i,e)=>i===e?!0:typeof i!=typeof e?!1:typeof i=="number"&&Number.isNaN(i)&&Number.isNaN(e)?!0:typeof i!="object"?!1:Array.isArray(i)?TR(i,e):Object.entries(i).every(([t,s])=>t in e&&Pm(s,e[t])),TR=(i,e)=>{const t=Array.isArray(i),s=Array.isArray(e);return t!==s?!1:t||s?i.length!==e.length?!1:i.every((r,n)=>Pm(r,e[n])):!0},_R=Object.values(Xi);let ec;const AR=pR().then(i=>(ec=i,ec)),SR=async(...i)=>{await Promise.all(i.filter(e=>e).map(async e=>{if(!("localName"in e&&e instanceof k.HTMLElement))return;const t=e.localName;if(!t.includes("-"))return;const s=k.customElements.get(t);s&&e instanceof s||(await k.customElements.whenDefined(t),k.customElements.upgrade(e))}))},cl={mediaPaused:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.paused)!=null?e:!0},set(i,e){var t;const{media:s}=e;s&&(i?s.pause():(t=s.play())==null||t.catch(()=>{}))},mediaEvents:["play","playing","pause","emptied"]},mediaHasPlayed:{get(i,e){const{media:t}=i;return t?e?e.type==="playing":!t.paused:!1},mediaEvents:["playing","emptied"]},mediaEnded:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.ended)!=null?e:!1},mediaEvents:["seeked","ended","emptied"]},mediaPlaybackRate:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.playbackRate)!=null?e:1},set(i,e){const{media:t}=e;t&&Number.isFinite(+i)&&(t.playbackRate=+i)},mediaEvents:["ratechange","loadstart"]},mediaMuted:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.muted)!=null?e:!1},set(i,e){const{media:t}=e;t&&(t.muted=i)},mediaEvents:["volumechange"]},mediaVolume:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.volume)!=null?e:1},set(i,e){const{media:t}=e;if(t){try{i==null?k.localStorage.removeItem("media-chrome-pref-volume"):k.localStorage.setItem("media-chrome-pref-volume",i.toString())}catch{}Number.isFinite(+i)&&(t.volume=+i)}},mediaEvents:["volumechange"],stateOwnersUpdateHandlers:[(i,e)=>{const{options:{noVolumePref:t}}=e;if(!t)try{const s=k.localStorage.getItem("media-chrome-pref-volume");if(s==null)return;cl.mediaVolume.set(+s,e),i(s)}catch(s){console.debug("Error getting volume pref",s)}}]},mediaVolumeLevel:{get(i){const{media:e}=i;return typeof(e==null?void 0:e.volume)>"u"?"high":e.muted||e.volume===0?"off":e.volume<.5?"low":e.volume<.75?"medium":"high"},mediaEvents:["volumechange"]},mediaCurrentTime:{get(i){var e;const{media:t}=i;return(e=t==null?void 0:t.currentTime)!=null?e:0},set(i,e){const{media:t}=e;!t||t.readyState===0||(t.currentTime=i)},mediaEvents:["timeupdate","loadedmetadata"]},mediaDuration:{get(i){const{media:e,options:{defaultDuration:t}={}}=i;return t&&(!e||!e.duration||Number.isNaN(e.duration)||!Number.isFinite(e.duration))?t:Number.isFinite(e==null?void 0:e.duration)?e.duration:Number.NaN},mediaEvents:["durationchange","loadedmetadata","emptied"]},mediaLoading:{get(i){const{media:e}=i;return(e==null?void 0:e.readyState)<3},mediaEvents:["waiting","playing","emptied"]},mediaSeekable:{get(i){var e;const{media:t}=i;if(!((e=t==null?void 0:t.seekable)!=null&&e.length))return;const s=t.seekable.start(0),r=t.seekable.end(t.seekable.length-1);if(!(!s&&!r))return[Number(s.toFixed(3)),Number(r.toFixed(3))]},mediaEvents:["loadedmetadata","emptied","progress","seekablechange"]},mediaBuffered:{get(i){var e;const{media:t}=i,s=(e=t==null?void 0:t.buffered)!=null?e:[];return Array.from(s).map((r,n)=>[Number(s.start(n).toFixed(3)),Number(s.end(n).toFixed(3))])},mediaEvents:["progress","emptied"]},mediaStreamType:{get(i){const{media:e,options:{defaultStreamType:t}={}}=i,s=[Xi.LIVE,Xi.ON_DEMAND].includes(t)?t:void 0;if(!e)return s;const{streamType:r}=e;if(_R.includes(r))return r===Xi.UNKNOWN?s:r;const n=e.duration;return n===1/0?Xi.LIVE:Number.isFinite(n)?Xi.ON_DEMAND:s},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange"]},mediaTargetLiveWindow:{get(i){const{media:e}=i;if(!e)return Number.NaN;const{targetLiveWindow:t}=e,s=cl.mediaStreamType.get(i);return(t==null||Number.isNaN(t))&&s===Xi.LIVE?0:t},mediaEvents:["emptied","durationchange","loadedmetadata","streamtypechange","targetlivewindowchange"]},mediaTimeIsLive:{get(i){const{media:e,options:{liveEdgeOffset:t=10}={}}=i;if(!e)return!1;if(typeof e.liveEdgeStart=="number")return Number.isNaN(e.liveEdgeStart)?!1:e.currentTime>=e.liveEdgeStart;if(!(cl.mediaStreamType.get(i)===Xi.LIVE))return!1;const r=e.seekable;if(!r)return!0;if(!r.length)return!1;const n=r.end(r.length-1)-t;return e.currentTime>=n},mediaEvents:["playing","timeupdate","progress","waiting","emptied"]},mediaSubtitlesList:{get(i){return Jd(i).map(({kind:e,label:t,language:s})=>({kind:e,label:t,language:s}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack"]},mediaSubtitlesShowing:{get(i){return Ib(i).map(({kind:e,label:t,language:s})=>({kind:e,label:t,language:s}))},mediaEvents:["loadstart"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{var t,s;const{media:r,options:n}=e;if(!r)return;const a=o=>{var l;!n.defaultSubtitles||o&&![_s.CAPTIONS,_s.SUBTITLES].includes((l=o==null?void 0:o.track)==null?void 0:l.kind)||Rb(e,!0)};return(t=r.textTracks)==null||t.addEventListener("addtrack",a),(s=r.textTracks)==null||s.addEventListener("removetrack",a),a(),()=>{var o,l;(o=r.textTracks)==null||o.removeEventListener("addtrack",a),(l=r.textTracks)==null||l.removeEventListener("removetrack",a)}}]},mediaChaptersCues:{get(i){var e;const{media:t}=i;if(!t)return[];const[s]=Mc(t,{kind:_s.CHAPTERS});return Array.from((e=s==null?void 0:s.cues)!=null?e:[]).map(({text:r,startTime:n,endTime:a})=>({text:r,startTime:n,endTime:a}))},mediaEvents:["loadstart","loadedmetadata"],textTracksEvents:["addtrack","removetrack","change"],stateOwnersUpdateHandlers:[(i,e)=>{const{media:t}=e;if(!t)return;const s=t.querySelector('track[kind="chapters"][default][src]');return s==null||s.addEventListener("load",i),()=>{s==null||s.removeEventListener("load",i)}}]},mediaIsPip:{get(i){var e,t;const{media:s,documentElement:r}=i;if(!s||!r||!r.pictureInPictureElement)return!1;if(r.pictureInPictureElement===s)return!0;if(r.pictureInPictureElement instanceof HTMLMediaElement)return(e=s.localName)!=null&&e.includes("-")?Ni(s,r.pictureInPictureElement):!1;if(r.pictureInPictureElement.localName.includes("-")){let n=r.pictureInPictureElement.shadowRoot;for(;n!=null&&n.pictureInPictureElement;){if(n.pictureInPictureElement===s)return!0;n=(t=n.pictureInPictureElement)==null?void 0:t.shadowRoot}}return!1},set(i,e){const{media:t}=e;if(t)if(i){if(!z.pictureInPictureEnabled){console.warn("MediaChrome: Picture-in-picture is not enabled");return}if(!t.requestPictureInPicture){console.warn("MediaChrome: The current media does not support picture-in-picture");return}const s=()=>{console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a readyState > 0.")};t.requestPictureInPicture().catch(r=>{if(r.code===11){if(!t.src){console.warn("MediaChrome: The media is not ready for picture-in-picture. It must have a src set.");return}if(t.readyState===0&&t.preload==="none"){const n=()=>{t.removeEventListener("loadedmetadata",a),t.preload="none"},a=()=>{t.requestPictureInPicture().catch(s),n()};t.addEventListener("loadedmetadata",a),t.preload="metadata",setTimeout(()=>{t.readyState===0&&s(),n()},1e3)}else throw r}else throw r})}else z.pictureInPictureElement&&z.exitPictureInPicture()},mediaEvents:["enterpictureinpicture","leavepictureinpicture"]},mediaRenditionList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.videoRenditions)!=null?e:[]].map(s=>({...s}))},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaRenditionSelected:{get(i){var e,t,s;const{media:r}=i;return(s=(t=r==null?void 0:r.videoRenditions)==null?void 0:t[(e=r.videoRenditions)==null?void 0:e.selectedIndex])==null?void 0:s.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.videoRenditions)){console.warn("MediaController: Rendition selection not supported by this media.");return}const s=i,r=Array.prototype.findIndex.call(t.videoRenditions,n=>n.id==s);t.videoRenditions.selectedIndex!=r&&(t.videoRenditions.selectedIndex=r)},mediaEvents:["emptied"],videoRenditionsEvents:["addrendition","removerendition","change"]},mediaAudioTrackList:{get(i){var e;const{media:t}=i;return[...(e=t==null?void 0:t.audioTracks)!=null?e:[]]},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]},mediaAudioTrackEnabled:{get(i){var e,t;const{media:s}=i;return(t=[...(e=s==null?void 0:s.audioTracks)!=null?e:[]].find(r=>r.enabled))==null?void 0:t.id},set(i,e){const{media:t}=e;if(!(t!=null&&t.audioTracks)){console.warn("MediaChrome: Audio track selection not supported by this media.");return}const s=i;for(let r of t.audioTracks)r.enabled=s==r.id},mediaEvents:["emptied"],audioTracksEvents:["addtrack","removetrack","change"]},mediaIsFullscreen:{get(i){var e;const{media:t,documentElement:s,fullscreenElement:r=t}=i;if(!t||!s)return!1;if(!s[Me.element])return"webkitDisplayingFullscreen"in t&&"webkitPresentationMode"in t?t.webkitDisplayingFullscreen&&t.webkitPresentationMode===BI.FULLSCREEN:!1;if(s[Me.element]===r)return!0;if(s[Me.element].localName.includes("-")){let n=s[Me.element].shadowRoot;if(!(Me.element in n))return Ni(s[Me.element],r);for(;n!=null&&n[Me.element];){if(n[Me.element]===r)return!0;n=(e=n[Me.element])==null?void 0:e.shadowRoot}}return!1},set(i,e){var t,s;const{media:r,fullscreenElement:n,documentElement:a}=e;if(!i&&(a!=null&&a[Me.exit])){const o=(t=a==null?void 0:a[Me.exit])==null?void 0:t.call(a);o instanceof Promise&&o.catch(()=>{});return}if(n!=null&&n[Me.enter]){const o=(s=n[Me.enter])==null?void 0:s.call(n);o instanceof Promise&&o.catch(()=>{})}else r!=null&&r.webkitEnterFullscreen?r.webkitEnterFullscreen():r!=null&&r.requestFullscreen&&r.requestFullscreen()},rootEvents:Me.rootEvents,mediaEvents:Me.mediaEvents},mediaIsCasting:{get(i){var e;const{media:t}=i;return!(t!=null&&t.remote)||((e=t.remote)==null?void 0:e.state)==="disconnected"?!1:!!t.remote.state},set(i,e){var t,s;const{media:r}=e;if(r&&!(i&&((t=r.remote)==null?void 0:t.state)!=="disconnected")&&!(!i&&((s=r.remote)==null?void 0:s.state)!=="connected")){if(typeof r.remote.prompt!="function"){console.warn("MediaChrome: Casting is not supported in this environment");return}r.remote.prompt().catch(()=>{})}},remoteEvents:["connect","connecting","disconnect"]},mediaIsAirplaying:{get(){return!1},set(i,e){const{media:t}=e;if(t){if(!(t.webkitShowPlaybackTargetPicker&&k.WebKitPlaybackTargetAvailabilityEvent)){console.warn("MediaChrome: received a request to select AirPlay but AirPlay is not supported in this environment");return}t.webkitShowPlaybackTargetPicker()}},mediaEvents:["webkitcurrentplaybacktargetiswirelesschanged"]},mediaFullscreenUnavailable:{get(i){const{media:e}=i;if(!vR||!Lb(e))return Bt.UNSUPPORTED}},mediaPipUnavailable:{get(i){const{media:e}=i;if(!ER||!kb(e))return Bt.UNSUPPORTED}},mediaVolumeUnavailable:{get(i){const{media:e}=i;if(ec===!1||(e==null?void 0:e.volume)==null)return Bt.UNSUPPORTED},stateOwnersUpdateHandlers:[i=>{ec==null&&AR.then(e=>i(e?void 0:Bt.UNSUPPORTED))}]},mediaCastUnavailable:{get(i,{availability:e="not-available"}={}){var t;const{media:s}=i;if(!yR||!((t=s==null?void 0:s.remote)!=null&&t.state))return Bt.UNSUPPORTED;if(!(e==null||e==="available"))return Bt.UNAVAILABLE},stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:s}=e;return s?(s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(t=s==null?void 0:s.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=s==null?void 0:s.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaAirplayUnavailable:{get(i,e){if(!bR)return Bt.UNSUPPORTED;if((e==null?void 0:e.availability)==="not-available")return Bt.UNAVAILABLE},mediaEvents:["webkitplaybacktargetavailabilitychanged"],stateOwnersUpdateHandlers:[(i,e)=>{var t;const{media:s}=e;return s?(s.disableRemotePlayback||s.hasAttribute("disableremoteplayback")||(t=s==null?void 0:s.remote)==null||t.watchAvailability(n=>{i({availability:n?"available":"not-available"})}).catch(n=>{n.name==="NotSupportedError"?i({availability:null}):i({availability:"not-available"})}),()=>{var n;(n=s==null?void 0:s.remote)==null||n.cancelWatchAvailability().catch(()=>{})}):void 0}]},mediaRenditionUnavailable:{get(i){var e;const{media:t}=i;if(!(t!=null&&t.videoRenditions))return Bt.UNSUPPORTED;if(!((e=t.videoRenditions)!=null&&e.length))return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],videoRenditionsEvents:["addrendition","removerendition"]},mediaAudioTrackUnavailable:{get(i){var e,t;const{media:s}=i;if(!(s!=null&&s.audioTracks))return Bt.UNSUPPORTED;if(((t=(e=s.audioTracks)==null?void 0:e.length)!=null?t:0)<=1)return Bt.UNAVAILABLE},mediaEvents:["emptied","loadstart"],audioTracksEvents:["addtrack","removetrack"]}},xR={[K.MEDIA_PREVIEW_REQUEST](i,e,{detail:t}){var s,r,n;const{media:a}=e,o=t??void 0;let l,d;if(a&&o!=null){const[f]=Mc(a,{kind:_s.METADATA,label:"thumbnails"}),m=Array.prototype.find.call((s=f==null?void 0:f.cues)!=null?s:[],(p,g,v)=>g===0?p.endTime>o:g===v.length-1?p.startTime<=o:p.startTime<=o&&p.endTime>o);if(m){const p=/'^(?:[a-z]+:)?\/\//i.test(m.text)||(r=a==null?void 0:a.querySelector('track[label="thumbnails"]'))==null?void 0:r.src,g=new URL(m.text,p);d=new URLSearchParams(g.hash).get("#xywh").split(",").map(y=>+y),l=g.href}}const c=i.mediaDuration.get(e);let h=(n=i.mediaChaptersCues.get(e).find((f,m,p)=>m===p.length-1&&c===f.endTime?f.startTime<=o&&f.endTime>=o:f.startTime<=o&&f.endTime>o))==null?void 0:n.text;return t!=null&&h==null&&(h=""),{mediaPreviewTime:o,mediaPreviewImage:l,mediaPreviewCoords:d,mediaPreviewChapter:h}},[K.MEDIA_PAUSE_REQUEST](i,e){i["mediaPaused"].set(!0,e)},[K.MEDIA_PLAY_REQUEST](i,e){var t;const s="mediaPaused";if(i.mediaStreamType.get(e)===Xi.LIVE){const a=!(i.mediaTargetLiveWindow.get(e)>0),o=(t=i.mediaSeekable.get(e))==null?void 0:t[1];a&&o&&i.mediaCurrentTime.set(o,e)}i[s].set(!1,e)},[K.MEDIA_PLAYBACK_RATE_REQUEST](i,e,{detail:t}){const s="mediaPlaybackRate",r=t;i[s].set(r,e)},[K.MEDIA_MUTE_REQUEST](i,e){i["mediaMuted"].set(!0,e)},[K.MEDIA_UNMUTE_REQUEST](i,e){const t="mediaMuted";i.mediaVolume.get(e)||i.mediaVolume.set(.25,e),i[t].set(!1,e)},[K.MEDIA_VOLUME_REQUEST](i,e,{detail:t}){const s="mediaVolume",r=t;r&&i.mediaMuted.get(e)&&i.mediaMuted.set(!1,e),i[s].set(r,e)},[K.MEDIA_SEEK_REQUEST](i,e,{detail:t}){const s="mediaCurrentTime",r=t;i[s].set(r,e)},[K.MEDIA_SEEK_TO_LIVE_REQUEST](i,e){var t;const s="mediaCurrentTime",r=(t=i.mediaSeekable.get(e))==null?void 0:t[1];Number.isNaN(Number(r))&&i[s].set(r,e)},[K.MEDIA_SHOW_SUBTITLES_REQUEST](i,e,{detail:t}){var s;const{options:r}=e,n=Jd(e),a=Ab(t),o=(s=a[0])==null?void 0:s.language;o&&!r.noSubtitlesLangPref&&k.localStorage.setItem("media-chrome-pref-subtitles-lang",o),Na(yn.SHOWING,n,a)},[K.MEDIA_DISABLE_SUBTITLES_REQUEST](i,e,{detail:t}){const s=Jd(e),r=t??[];Na(yn.DISABLED,s,r)},[K.MEDIA_TOGGLE_SUBTITLES_REQUEST](i,e,{detail:t}){Rb(e,t)},[K.MEDIA_RENDITION_REQUEST](i,e,{detail:t}){const s="mediaRenditionSelected",r=t;i[s].set(r,e)},[K.MEDIA_AUDIO_TRACK_REQUEST](i,e,{detail:t}){const s="mediaAudioTrackEnabled",r=t;i[s].set(r,e)},[K.MEDIA_ENTER_PIP_REQUEST](i,e){const t="mediaIsPip";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[K.MEDIA_EXIT_PIP_REQUEST](i,e){i["mediaIsPip"].set(!1,e)},[K.MEDIA_ENTER_FULLSCREEN_REQUEST](i,e){const t="mediaIsFullscreen";i.mediaIsPip.get(e)&&i.mediaIsPip.set(!1,e),i[t].set(!0,e)},[K.MEDIA_EXIT_FULLSCREEN_REQUEST](i,e){i["mediaIsFullscreen"].set(!1,e)},[K.MEDIA_ENTER_CAST_REQUEST](i,e){const t="mediaIsCasting";i.mediaIsFullscreen.get(e)&&i.mediaIsFullscreen.set(!1,e),i[t].set(!0,e)},[K.MEDIA_EXIT_CAST_REQUEST](i,e){i["mediaIsCasting"].set(!1,e)},[K.MEDIA_AIRPLAY_REQUEST](i,e){i["mediaIsAirplaying"].set(!0,e)}},kR=({media:i,fullscreenElement:e,documentElement:t,stateMediator:s=cl,requestMap:r=xR,options:n={},monitorStateOwnersOnlyWithSubscriptions:a=!0})=>{const o=[],l={options:{...n}};let d=Object.freeze({mediaPreviewTime:void 0,mediaPreviewImage:void 0,mediaPreviewCoords:void 0,mediaPreviewChapter:void 0});const c=p=>{p!=null&&(Pm(p,d)||(d=Object.freeze({...d,...p}),o.forEach(g=>g(d))))},u=()=>{const p=Object.entries(s).reduce((g,[v,{get:y}])=>(g[v]=y(l),g),{});c(p)},h={};let f;const m=async(p,g)=>{var v,y,b,x,_,S,A,D,O,L,C,H,U,Q,q,Y;const oe=!!f;if(f={...l,...f??{},...p},oe)return;await SR(...Object.values(p));const ae=o.length>0&&g===0&&a,G=l.media!==f.media,F=((v=l.media)==null?void 0:v.textTracks)!==((y=f.media)==null?void 0:y.textTracks),re=((b=l.media)==null?void 0:b.videoRenditions)!==((x=f.media)==null?void 0:x.videoRenditions),J=((_=l.media)==null?void 0:_.audioTracks)!==((S=f.media)==null?void 0:S.audioTracks),de=((A=l.media)==null?void 0:A.remote)!==((D=f.media)==null?void 0:D.remote),Ae=l.documentElement!==f.documentElement,Ce=!!l.media&&(G||ae),He=!!((O=l.media)!=null&&O.textTracks)&&(F||ae),St=!!((L=l.media)!=null&&L.videoRenditions)&&(re||ae),ts=!!((C=l.media)!=null&&C.audioTracks)&&(J||ae),wr=!!((H=l.media)!=null&&H.remote)&&(de||ae),Ap=!!l.documentElement&&(Ae||ae),Sp=Ce||He||St||ts||wr||Ap,Cr=o.length===0&&g===1&&a,xp=!!f.media&&(G||Cr),kp=!!((U=f.media)!=null&&U.textTracks)&&(F||Cr),Lp=!!((Q=f.media)!=null&&Q.videoRenditions)&&(re||Cr),Ip=!!((q=f.media)!=null&&q.audioTracks)&&(J||Cr),Rp=!!((Y=f.media)!=null&&Y.remote)&&(de||Cr),wp=!!f.documentElement&&(Ae||Cr),Cp=xp||kp||Lp||Ip||Rp||wp;if(!(Sp||Cp)){Object.entries(f).forEach(([Se,Hn])=>{l[Se]=Hn}),u(),f=void 0;return}Object.entries(s).forEach(([Se,{get:Hn,mediaEvents:n_=[],textTracksEvents:a_=[],videoRenditionsEvents:o_=[],audioTracksEvents:l_=[],remoteEvents:d_=[],rootEvents:c_=[],stateOwnersUpdateHandlers:u_=[]}])=>{h[Se]||(h[Se]={});const Mt=Be=>{const Ot=Hn(l,Be);c({[Se]:Ot})};let Ze;Ze=h[Se].mediaEvents,n_.forEach(Be=>{Ze&&Ce&&(l.media.removeEventListener(Be,Ze),h[Se].mediaEvents=void 0),xp&&(f.media.addEventListener(Be,Mt),h[Se].mediaEvents=Mt)}),Ze=h[Se].textTracksEvents,a_.forEach(Be=>{var Ot,qt;Ze&&He&&((Ot=l.media.textTracks)==null||Ot.removeEventListener(Be,Ze),h[Se].textTracksEvents=void 0),kp&&((qt=f.media.textTracks)==null||qt.addEventListener(Be,Mt),h[Se].textTracksEvents=Mt)}),Ze=h[Se].videoRenditionsEvents,o_.forEach(Be=>{var Ot,qt;Ze&&St&&((Ot=l.media.videoRenditions)==null||Ot.removeEventListener(Be,Ze),h[Se].videoRenditionsEvents=void 0),Lp&&((qt=f.media.videoRenditions)==null||qt.addEventListener(Be,Mt),h[Se].videoRenditionsEvents=Mt)}),Ze=h[Se].audioTracksEvents,l_.forEach(Be=>{var Ot,qt;Ze&&ts&&((Ot=l.media.audioTracks)==null||Ot.removeEventListener(Be,Ze),h[Se].audioTracksEvents=void 0),Ip&&((qt=f.media.audioTracks)==null||qt.addEventListener(Be,Mt),h[Se].audioTracksEvents=Mt)}),Ze=h[Se].remoteEvents,d_.forEach(Be=>{var Ot,qt;Ze&&wr&&((Ot=l.media.remote)==null||Ot.removeEventListener(Be,Ze),h[Se].remoteEvents=void 0),Rp&&((qt=f.media.remote)==null||qt.addEventListener(Be,Mt),h[Se].remoteEvents=Mt)}),Ze=h[Se].rootEvents,c_.forEach(Be=>{Ze&&Ap&&(l.documentElement.removeEventListener(Be,Ze),h[Se].rootEvents=void 0),wp&&(f.documentElement.addEventListener(Be,Mt),h[Se].rootEvents=Mt)});const Dp=h[Se].stateOwnersUpdateHandlers;u_.forEach(Be=>{Dp&&Sp&&Dp(),Cp&&(h[Se].stateOwnersUpdateHandlers=Be(Mt,f))})}),Object.entries(f).forEach(([Se,Hn])=>{l[Se]=Hn}),u(),f=void 0};return m({media:i,fullscreenElement:e,documentElement:t,options:n}),{dispatch(p){const{type:g,detail:v}=p;if(r[g]){c(r[g](s,l,p));return}g==="mediaelementchangerequest"?m({media:v}):g==="fullscreenelementchangerequest"?m({fullscreenElement:v}):g==="documentelementchangerequest"?m({documentElement:v}):g==="optionschangerequest"&&Object.entries(v??{}).forEach(([y,b])=>{l.options[y]=b})},getState(){return d},subscribe(p){return m({},o.length+1),o.push(p),p(d),()=>{const g=o.indexOf(p);g>=0&&(m({},o.length-1),o.splice(g,1))}}}};var LR=kR,Nm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},he=(i,e,t)=>(Nm(i,e,"read from private field"),t?t.call(i):e.get(i)),Gi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},rs=(i,e,t,s)=>(Nm(i,e,"write to private field"),e.set(i,t),t),vs=(i,e,t)=>(Nm(i,e,"access private method"),t),Es,oa,Re,la,hi,ul,hl,Eh,Pn,Ja,fl,bh;const wb=["ArrowLeft","ArrowRight","Enter"," ","f","m","k","c"],Z0=10,me={DEFAULT_SUBTITLES:"defaultsubtitles",DEFAULT_STREAM_TYPE:"defaultstreamtype",DEFAULT_DURATION:"defaultduration",FULLSCREEN_ELEMENT:"fullscreenelement",HOTKEYS:"hotkeys",KEYS_USED:"keysused",LIVE_EDGE_OFFSET:"liveedgeoffset",NO_AUTO_SEEK_TO_LIVE:"noautoseektolive",NO_HOTKEYS:"nohotkeys",NO_VOLUME_PREF:"novolumepref",NO_SUBTITLES_LANG_PREF:"nosubtitleslangpref",NO_DEFAULT_STORE:"nodefaultstore",KEYBOARD_FORWARD_SEEK_OFFSET:"keyboardforwardseekoffset",KEYBOARD_BACKWARD_SEEK_OFFSET:"keyboardbackwardseekoffset"};class Cb extends yb{constructor(){super(),Gi(this,hl),Gi(this,Pn),Gi(this,fl),Gi(this,Es,new uo(this,me.HOTKEYS)),Gi(this,oa,void 0),Gi(this,Re,void 0),Gi(this,la,void 0),Gi(this,hi,void 0),Gi(this,ul,t=>{var s;(s=he(this,Re))==null||s.dispatch(t)}),this.mediaStateReceivers=[],this.associatedElementSubscriptions=new Map,this.associateElement(this);let e={};rs(this,la,t=>{Object.entries(t).forEach(([s,r])=>{if(s in e&&e[s]===r)return;this.propagateMediaState(s,r);const n=s.toLowerCase(),a=new k.CustomEvent($I[n],{composed:!0,detail:r});this.dispatchEvent(a)}),e=t}),this.enableHotkeys()}static get observedAttributes(){return super.observedAttributes.concat(me.NO_HOTKEYS,me.HOTKEYS,me.DEFAULT_STREAM_TYPE,me.DEFAULT_SUBTITLES,me.DEFAULT_DURATION)}get mediaStore(){return he(this,Re)}set mediaStore(e){var t,s;if(he(this,Re)&&((t=he(this,hi))==null||t.call(this),rs(this,hi,void 0)),rs(this,Re,e),!he(this,Re)&&!this.hasAttribute(me.NO_DEFAULT_STORE)){vs(this,hl,Eh).call(this);return}rs(this,hi,(s=he(this,Re))==null?void 0:s.subscribe(he(this,la)))}get fullscreenElement(){var e;return(e=he(this,oa))!=null?e:this}set fullscreenElement(e){var t;this.hasAttribute(me.FULLSCREEN_ELEMENT)&&this.removeAttribute(me.FULLSCREEN_ELEMENT),rs(this,oa,e),(t=he(this,Re))==null||t.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}attributeChangedCallback(e,t,s){var r,n,a,o,l,d;if(super.attributeChangedCallback(e,t,s),e===me.NO_HOTKEYS)s!==t&&s===""?(this.hasAttribute(me.HOTKEYS)&&console.warn("Media Chrome: Both `hotkeys` and `nohotkeys` have been set. All hotkeys will be disabled."),this.disableHotkeys()):s!==t&&s===null&&this.enableHotkeys();else if(e===me.HOTKEYS)he(this,Es).value=s;else if(e===me.DEFAULT_SUBTITLES&&s!==t)(r=he(this,Re))==null||r.dispatch({type:"optionschangerequest",detail:{defaultSubtitles:this.hasAttribute(me.DEFAULT_SUBTITLES)}});else if(e===me.DEFAULT_STREAM_TYPE)(a=he(this,Re))==null||a.dispatch({type:"optionschangerequest",detail:{defaultStreamType:(n=this.getAttribute(me.DEFAULT_STREAM_TYPE))!=null?n:void 0}});else if(e===me.LIVE_EDGE_OFFSET)(o=he(this,Re))==null||o.dispatch({type:"optionschangerequest",detail:{liveEdgeOffset:this.hasAttribute(me.LIVE_EDGE_OFFSET)?+this.getAttribute(me.LIVE_EDGE_OFFSET):void 0}});else if(e===me.FULLSCREEN_ELEMENT){const c=s?(l=this.getRootNode())==null?void 0:l.getElementById(s):void 0;rs(this,oa,c),(d=he(this,Re))==null||d.dispatch({type:"fullscreenelementchangerequest",detail:this.fullscreenElement})}}connectedCallback(){var e,t;!he(this,Re)&&!this.hasAttribute(me.NO_DEFAULT_STORE)&&vs(this,hl,Eh).call(this),(e=he(this,Re))==null||e.dispatch({type:"documentelementchangerequest",detail:z}),super.connectedCallback(),he(this,Re)&&!he(this,hi)&&rs(this,hi,(t=he(this,Re))==null?void 0:t.subscribe(he(this,la))),this.enableHotkeys()}disconnectedCallback(){var e,t,s,r;(e=super.disconnectedCallback)==null||e.call(this),he(this,Re)&&((t=he(this,Re))==null||t.dispatch({type:"documentelementchangerequest",detail:void 0}),(s=he(this,Re))==null||s.dispatch({type:K.MEDIA_TOGGLE_SUBTITLES_REQUEST,detail:!1})),he(this,hi)&&((r=he(this,hi))==null||r.call(this),rs(this,hi,void 0))}mediaSetCallback(e){var t;super.mediaSetCallback(e),(t=he(this,Re))==null||t.dispatch({type:"mediaelementchangerequest",detail:e}),e.hasAttribute("tabindex")||(e.tabIndex=-1)}mediaUnsetCallback(e){var t;super.mediaUnsetCallback(e),(t=he(this,Re))==null||t.dispatch({type:"mediaelementchangerequest",detail:void 0})}propagateMediaState(e,t){tg(this.mediaStateReceivers,e,t)}associateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(t.has(e))return;const s=this.registerMediaStateReceiver.bind(this),r=this.unregisterMediaStateReceiver.bind(this),n=MR(e,s,r);Object.values(K).forEach(a=>{e.addEventListener(a,he(this,ul))}),t.set(e,n)}unassociateElement(e){if(!e)return;const{associatedElementSubscriptions:t}=this;if(!t.has(e))return;t.get(e)(),t.delete(e),Object.values(K).forEach(r=>{e.removeEventListener(r,he(this,ul))})}registerMediaStateReceiver(e){if(!e)return;const t=this.mediaStateReceivers;t.indexOf(e)>-1||(t.push(e),he(this,Re)&&Object.entries(he(this,Re).getState()).forEach(([r,n])=>{tg([e],r,n)}))}unregisterMediaStateReceiver(e){const t=this.mediaStateReceivers,s=t.indexOf(e);s<0||t.splice(s,1)}enableHotkeys(){this.addEventListener("keydown",vs(this,fl,bh))}disableHotkeys(){this.removeEventListener("keydown",vs(this,fl,bh)),this.removeEventListener("keyup",vs(this,Pn,Ja))}get hotkeys(){return he(this,Es)}keyboardShortcutHandler(e){var t,s,r,n,a,o;if(((n=(r=(t=e.target.getAttribute(me.KEYS_USED))==null?void 0:t.split(" "))!=null?r:(s=e.target)==null?void 0:s.keysUsed)!=null?n:[]).map(h=>h==="Space"?" ":h).filter(Boolean).includes(e.key))return;let d,c,u;if(!he(this,Es).contains(`no${e.key.toLowerCase()}`)&&!(e.key===" "&&he(this,Es).contains("nospace")))switch(e.key){case" ":case"k":d=he(this,Re).getState().mediaPaused?K.MEDIA_PLAY_REQUEST:K.MEDIA_PAUSE_REQUEST,this.dispatchEvent(new k.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"m":d=this.mediaStore.getState().mediaVolumeLevel==="off"?K.MEDIA_UNMUTE_REQUEST:K.MEDIA_MUTE_REQUEST,this.dispatchEvent(new k.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"f":d=this.mediaStore.getState().mediaIsFullscreen?K.MEDIA_EXIT_FULLSCREEN_REQUEST:K.MEDIA_ENTER_FULLSCREEN_REQUEST,this.dispatchEvent(new k.CustomEvent(d,{composed:!0,bubbles:!0}));break;case"c":this.dispatchEvent(new k.CustomEvent(K.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}));break;case"ArrowLeft":{const h=this.hasAttribute(me.KEYBOARD_BACKWARD_SEEK_OFFSET)?+this.getAttribute(me.KEYBOARD_BACKWARD_SEEK_OFFSET):Z0;c=Math.max(((a=this.mediaStore.getState().mediaCurrentTime)!=null?a:0)-h,0),u=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}case"ArrowRight":{const h=this.hasAttribute(me.KEYBOARD_FORWARD_SEEK_OFFSET)?+this.getAttribute(me.KEYBOARD_FORWARD_SEEK_OFFSET):Z0;c=Math.max(((o=this.mediaStore.getState().mediaCurrentTime)!=null?o:0)+h,0),u=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:c}),this.dispatchEvent(u);break}}}}Es=new WeakMap;oa=new WeakMap;Re=new WeakMap;la=new WeakMap;hi=new WeakMap;ul=new WeakMap;hl=new WeakSet;Eh=function(){var i;this.mediaStore=LR({media:this.media,fullscreenElement:this.fullscreenElement,options:{defaultSubtitles:this.hasAttribute(me.DEFAULT_SUBTITLES),defaultDuration:this.hasAttribute(me.DEFAULT_DURATION)?+this.getAttribute(me.DEFAULT_DURATION):void 0,defaultStreamType:(i=this.getAttribute(me.DEFAULT_STREAM_TYPE))!=null?i:void 0,liveEdgeOffset:this.hasAttribute(me.LIVE_EDGE_OFFSET)?+this.getAttribute(me.LIVE_EDGE_OFFSET):void 0,noVolumePref:this.hasAttribute(me.NO_VOLUME_PREF),noSubtitlesLangPref:this.hasAttribute(me.NO_SUBTITLES_LANG_PREF)}})};Pn=new WeakSet;Ja=function(i){const{key:e}=i;if(!wb.includes(e)){this.removeEventListener("keyup",vs(this,Pn,Ja));return}this.keyboardShortcutHandler(i)};fl=new WeakSet;bh=function(i){const{metaKey:e,altKey:t,key:s}=i;if(e||t||!wb.includes(s)){this.removeEventListener("keyup",vs(this,Pn,Ja));return}[" ","ArrowLeft","ArrowRight"].includes(s)&&!(he(this,Es).contains(`no${s.toLowerCase()}`)||s===" "&&he(this,Es).contains("nospace"))&&i.preventDefault(),this.addEventListener("keyup",vs(this,Pn,Ja),{once:!0})};const IR=Object.values(T),RR=Object.values(tb),Db=i=>{var e,t,s,r;let{observedAttributes:n}=i.constructor;!n&&((e=i.nodeName)!=null&&e.includes("-"))&&(k.customElements.upgrade(i),{observedAttributes:n}=i.constructor);const a=(r=(s=(t=i==null?void 0:i.getAttribute)==null?void 0:t.call(i,ue.MEDIA_CHROME_ATTRIBUTES))==null?void 0:s.split)==null?void 0:r.call(s,/\s+/);return Array.isArray(n||a)?(n||a).filter(o=>IR.includes(o)):[]},wR=i=>{var e,t;return(e=i.nodeName)!=null&&e.includes("-")&&k.customElements.get((t=i.nodeName)==null?void 0:t.toLowerCase())&&!(i instanceof k.customElements.get(i.nodeName.toLowerCase()))&&k.customElements.upgrade(i),RR.some(s=>s in i)},yh=i=>wR(i)||!!Db(i).length,J0=i=>{var e;return(e=i==null?void 0:i.join)==null?void 0:e.call(i,":")},eg={[T.MEDIA_SUBTITLES_LIST]:On,[T.MEDIA_SUBTITLES_SHOWING]:On,[T.MEDIA_SEEKABLE]:J0,[T.MEDIA_BUFFERED]:i=>i==null?void 0:i.map(J0).join(" "),[T.MEDIA_PREVIEW_COORDS]:i=>i==null?void 0:i.join(" "),[T.MEDIA_RENDITION_LIST]:GI,[T.MEDIA_AUDIO_TRACK_LIST]:KI},CR=async(i,e,t)=>{var s,r;if(i.isConnected||await ab(0),typeof t=="boolean"||t==null)return ot(i,e,t);if(typeof t=="number")return nt(i,e,t);if(typeof t=="string")return qe(i,e,t);if(Array.isArray(t)&&!t.length)return i.removeAttribute(e);const n=(r=(s=eg[e])==null?void 0:s.call(eg,t))!=null?r:t;return i.setAttribute(e,n)},DR=i=>{var e;return!!((e=i.closest)!=null&&e.call(i,'*[slot="media"]'))},Ps=(i,e)=>{if(DR(i))return;const t=(r,n)=>{var a,o;yh(r)&&n(r);const{children:l=[]}=r??{},d=(o=(a=r==null?void 0:r.shadowRoot)==null?void 0:a.children)!=null?o:[];[...l,...d].forEach(u=>Ps(u,n))},s=i==null?void 0:i.nodeName.toLowerCase();if(s.includes("-")&&!yh(i)){k.customElements.whenDefined(s).then(()=>{t(i,e)});return}t(i,e)},tg=(i,e,t)=>{i.forEach(s=>{if(e in s){s[e]=t;return}const r=Db(s),n=e.toLowerCase();r.includes(n)&&CR(s,n,t)})},MR=(i,e,t)=>{Ps(i,e);const s=c=>{var u;const h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;e(h)},r=c=>{var u;const h=(u=c==null?void 0:c.composedPath()[0])!=null?u:c.target;t(h)};i.addEventListener(K.REGISTER_MEDIA_STATE_RECEIVER,s),i.addEventListener(K.UNREGISTER_MEDIA_STATE_RECEIVER,r);const n=c=>{c.forEach(u=>{const{addedNodes:h=[],removedNodes:f=[],type:m,target:p,attributeName:g}=u;m==="childList"?(Array.prototype.forEach.call(h,v=>Ps(v,e)),Array.prototype.forEach.call(f,v=>Ps(v,t))):m==="attributes"&&g===ue.MEDIA_CHROME_ATTRIBUTES&&(yh(p)?e(p):t(p))})};let a=[];const o=c=>{const u=c.target;u.name!=="media"&&(a.forEach(h=>Ps(h,t)),a=[...u.assignedElements({flatten:!0})],a.forEach(h=>Ps(h,e)))};i.addEventListener("slotchange",o);const l=new MutationObserver(n);return l.observe(i,{childList:!0,attributes:!0,subtree:!0}),()=>{Ps(i,t),i.removeEventListener("slotchange",o),l.disconnect(),i.removeEventListener(K.REGISTER_MEDIA_STATE_RECEIVER,s),i.removeEventListener(K.UNREGISTER_MEDIA_STATE_RECEIVER,r)}};k.customElements.get("media-controller")||k.customElements.define("media-controller",Cb);var OR=Cb,PR=Object.defineProperty,NR=(i,e,t)=>e in i?PR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,UR=(i,e,t)=>(NR(i,e+"",t),t),Mb=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Gt=(i,e,t)=>(Mb(i,e,"read from private field"),t?t.call(i):e.get(i)),Mo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Oo=(i,e,t,s)=>(Mb(i,e,"write to private field"),e.set(i,t),t),fi,ml,Wr,pl;const Ob=z.createElement("template");Ob.innerHTML=`
193
193
  <style>
194
194
  :host {
195
195
  font: var(--media-font,
@@ -238,7 +238,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
238
238
  min-width: 100%;
239
239
  }
240
240
  </style>
241
- `;class xt extends k.HTMLElement{constructor(e={}){if(super(),Mo(this,fi,void 0),NR(this,"preventClick",!1),Mo(this,ml,t=>{this.preventClick||this.handleClick(t)}),Mo(this,Wr,t=>{const{key:s}=t;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",Gt(this,Wr));return}this.preventClick||this.handleClick(t)}),Mo(this,pl,t=>{const{metaKey:s,altKey:r,key:n}=t;if(s||r||!this.keysUsed.includes(n)){this.removeEventListener("keyup",Gt(this,Wr));return}this.addEventListener("keyup",Gt(this,Wr),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});const t=Ob.content.cloneNode(!0);this.nativeEl=t;let s=e.slotTemplate;s||(s=z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(t)}}static get observedAttributes(){return["disabled",ue.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Gt(this,ml)),this.addEventListener("keydown",Gt(this,pl)),this.tabIndex=0}disable(){this.removeEventListener("click",Gt(this,ml)),this.removeEventListener("keydown",Gt(this,pl)),this.removeEventListener("keyup",Gt(this,Wr)),this.tabIndex=-1}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(r=Gt(this,fi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Oo(this,fi,null)),s&&this.isConnected&&(Oo(this,fi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=Gt(this,fi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(Oo(this,fi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=Gt(this,fi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Gt(this,fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Oo(this,fi,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}}fi=new WeakMap;ml=new WeakMap;Wr=new WeakMap;pl=new WeakMap;k.customElements.get("media-chrome-button")||k.customElements.define("media-chrome-button",xt);const ig=`<svg aria-hidden="true" viewBox="0 0 26 24">
241
+ `;class xt extends k.HTMLElement{constructor(e={}){if(super(),Mo(this,fi,void 0),UR(this,"preventClick",!1),Mo(this,ml,t=>{this.preventClick||this.handleClick(t)}),Mo(this,Wr,t=>{const{key:s}=t;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",Gt(this,Wr));return}this.preventClick||this.handleClick(t)}),Mo(this,pl,t=>{const{metaKey:s,altKey:r,key:n}=t;if(s||r||!this.keysUsed.includes(n)){this.removeEventListener("keyup",Gt(this,Wr));return}this.addEventListener("keyup",Gt(this,Wr),{once:!0})}),!this.shadowRoot){this.attachShadow({mode:"open"});const t=Ob.content.cloneNode(!0);this.nativeEl=t;let s=e.slotTemplate;s||(s=z.createElement("template"),s.innerHTML=`<slot>${e.defaultContent||""}</slot>`),this.nativeEl.appendChild(s.content.cloneNode(!0)),this.shadowRoot.appendChild(t)}}static get observedAttributes(){return["disabled",ue.MEDIA_CONTROLLER]}enable(){this.addEventListener("click",Gt(this,ml)),this.addEventListener("keydown",Gt(this,pl)),this.tabIndex=0}disable(){this.removeEventListener("click",Gt(this,ml)),this.removeEventListener("keydown",Gt(this,pl)),this.removeEventListener("keyup",Gt(this,Wr)),this.tabIndex=-1}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(r=Gt(this,fi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Oo(this,fi,null)),s&&this.isConnected&&(Oo(this,fi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=Gt(this,fi))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","button");const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(Oo(this,fi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=Gt(this,fi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=Gt(this,fi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Oo(this,fi,null)}get keysUsed(){return["Enter"," "]}handleClick(e){}}fi=new WeakMap;ml=new WeakMap;Wr=new WeakMap;pl=new WeakMap;k.customElements.get("media-chrome-button")||k.customElements.define("media-chrome-button",xt);const ig=`<svg aria-hidden="true" viewBox="0 0 26 24">
242
242
  <path d="M22.13 3H3.87a.87.87 0 0 0-.87.87v13.26a.87.87 0 0 0 .87.87h3.4L9 16H5V5h16v11h-4l1.72 2h3.4a.87.87 0 0 0 .87-.87V3.87a.87.87 0 0 0-.86-.87Zm-8.75 11.44a.5.5 0 0 0-.76 0l-4.91 5.73a.5.5 0 0 0 .38.83h9.82a.501.501 0 0 0 .38-.83l-4.91-5.73Z"/>
243
243
  </svg>
244
244
  `,Pb=z.createElement("template");Pb.innerHTML=`
@@ -257,7 +257,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
257
257
  <slot name="enter">${ig}</slot>
258
258
  <slot name="exit">${ig}</slot>
259
259
  </slot>
260
- `;const sg=i=>{const e=i.mediaIsAirplaying?At.EXIT_AIRPLAY():At.ENTER_AIRPLAY();i.setAttribute("aria-label",e)};class UR extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Pb,...e})}connectedCallback(){super.connectedCallback(),sg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_IS_AIRPLAYING&&sg(this)}get mediaIsAirplaying(){return at(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){ot(this,T.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Ve(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){qe(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){const e=new k.CustomEvent(K.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}k.customElements.get("media-airplay-button")||k.customElements.define("media-airplay-button",UR);function FR({anchor:i,floating:e,placement:t}){let s=$R({anchor:i,floating:e}),{x:r,y:n}=GR(s,t);return{x:r,y:n}}function $R({anchor:i,floating:e}){return{anchor:BR(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function BR(i,e){let t=i.getBoundingClientRect(),s=e.getBoundingClientRect();return{x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}function GR({anchor:i,floating:e},t){const s=HR(t)==="x"?"y":"x",r=s==="y"?"height":"width",n=Nb(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[r]/2-e[r]/2;let d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[s]-=l;break;case"end":d[s]+=l;break}return d}function Nb(i){return i.split("-")[0]}function HR(i){return["top","bottom"].includes(Nb(i))?"y":"x"}var WR=Object.defineProperty,KR=(i,e,t)=>e in i?WR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,tc=(i,e,t)=>(KR(i,typeof e!="symbol"?e+"":e,t),t);class Um extends Event{constructor({action:e="auto",relatedTarget:t,...s}){super("invoke",s),tc(this,"action"),tc(this,"relatedTarget"),this.action=e,this.relatedTarget=t}}class VR extends Event{constructor({newState:e,oldState:t,...s}){super("toggle",s),tc(this,"newState"),tc(this,"oldState"),this.newState=e,this.oldState=t}}var qR=Object.defineProperty,YR=(i,e,t)=>e in i?qR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,jR=(i,e,t)=>(YR(i,e+"",t),t),Fm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ee=(i,e,t)=>(Fm(i,e,"read from private field"),t?t.call(i):e.get(i)),ye=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vi=(i,e,t,s)=>(Fm(i,e,"write to private field"),e.set(i,t),t),xe=(i,e,t)=>(Fm(i,e,"access private method"),t),mi,fr,ks,Ub,Fb,gl,vl,mr,Th,$b,ic,El,_h,Ah,Bb,Sh,Gb,xh,Hb,Tn,_n,pr,Nn,sc,$m,kh,Wb,Bm,Kb,Lh,Vb,Gm,qb,Ih,Yb,Rh,jb,Ua,rc,wh,zb,Fa,nc,bl,Ch;function Un({type:i,text:e,value:t,checked:s}){const r=z.createElement("media-chrome-menu-item");r.type=i??"",r.part.add("menu-item"),i&&r.part.add(i),r.value=t,r.checked=s;const n=z.createElement("span");return n.textContent=e,r.append(n),r}function gr(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let s=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return s?s.cloneNode(!0):""}const Xb=z.createElement("template");Xb.innerHTML=`
260
+ `;const sg=i=>{const e=i.mediaIsAirplaying?At.EXIT_AIRPLAY():At.ENTER_AIRPLAY();i.setAttribute("aria-label",e)};class FR extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_AIRPLAYING,T.MEDIA_AIRPLAY_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Pb,...e})}connectedCallback(){super.connectedCallback(),sg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_IS_AIRPLAYING&&sg(this)}get mediaIsAirplaying(){return at(this,T.MEDIA_IS_AIRPLAYING)}set mediaIsAirplaying(e){ot(this,T.MEDIA_IS_AIRPLAYING,e)}get mediaAirplayUnavailable(){return Ve(this,T.MEDIA_AIRPLAY_UNAVAILABLE)}set mediaAirplayUnavailable(e){qe(this,T.MEDIA_AIRPLAY_UNAVAILABLE,e)}handleClick(){const e=new k.CustomEvent(K.MEDIA_AIRPLAY_REQUEST,{composed:!0,bubbles:!0});this.dispatchEvent(e)}}k.customElements.get("media-airplay-button")||k.customElements.define("media-airplay-button",FR);function $R({anchor:i,floating:e,placement:t}){let s=BR({anchor:i,floating:e}),{x:r,y:n}=HR(s,t);return{x:r,y:n}}function BR({anchor:i,floating:e}){return{anchor:GR(i,e.offsetParent),floating:{x:0,y:0,width:e.offsetWidth,height:e.offsetHeight}}}function GR(i,e){let t=i.getBoundingClientRect(),s=e.getBoundingClientRect();return{x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}function HR({anchor:i,floating:e},t){const s=WR(t)==="x"?"y":"x",r=s==="y"?"height":"width",n=Nb(t),a=i.x+i.width/2-e.width/2,o=i.y+i.height/2-e.height/2,l=i[r]/2-e[r]/2;let d;switch(n){case"top":d={x:a,y:i.y-e.height};break;case"bottom":d={x:a,y:i.y+i.height};break;case"right":d={x:i.x+i.width,y:o};break;case"left":d={x:i.x-e.width,y:o};break;default:d={x:i.x,y:i.y}}switch(t.split("-")[1]){case"start":d[s]-=l;break;case"end":d[s]+=l;break}return d}function Nb(i){return i.split("-")[0]}function WR(i){return["top","bottom"].includes(Nb(i))?"y":"x"}var KR=Object.defineProperty,VR=(i,e,t)=>e in i?KR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,tc=(i,e,t)=>(VR(i,typeof e!="symbol"?e+"":e,t),t);class Um extends Event{constructor({action:e="auto",relatedTarget:t,...s}){super("invoke",s),tc(this,"action"),tc(this,"relatedTarget"),this.action=e,this.relatedTarget=t}}class qR extends Event{constructor({newState:e,oldState:t,...s}){super("toggle",s),tc(this,"newState"),tc(this,"oldState"),this.newState=e,this.oldState=t}}var YR=Object.defineProperty,jR=(i,e,t)=>e in i?YR(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,zR=(i,e,t)=>(jR(i,e+"",t),t),Fm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ee=(i,e,t)=>(Fm(i,e,"read from private field"),t?t.call(i):e.get(i)),ye=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vi=(i,e,t,s)=>(Fm(i,e,"write to private field"),e.set(i,t),t),xe=(i,e,t)=>(Fm(i,e,"access private method"),t),mi,fr,ks,Ub,Fb,gl,vl,mr,Th,$b,ic,El,_h,Ah,Bb,Sh,Gb,xh,Hb,Tn,_n,pr,Nn,sc,$m,kh,Wb,Bm,Kb,Lh,Vb,Gm,qb,Ih,Yb,Rh,jb,Ua,rc,wh,zb,Fa,nc,bl,Ch;function Un({type:i,text:e,value:t,checked:s}){const r=z.createElement("media-chrome-menu-item");r.type=i??"",r.part.add("menu-item"),i&&r.part.add(i),r.value=t,r.checked=s;const n=z.createElement("span");return n.textContent=e,r.append(n),r}function gr(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);if((t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t)return t=t.cloneNode(!0),t;let s=i.shadowRoot.querySelector(`[name="${e}"] > svg`);return s?s.cloneNode(!0):""}const Xb=z.createElement("template");Xb.innerHTML=`
261
261
  <style>
262
262
  :host {
263
263
  font: var(--media-font,
@@ -419,14 +419,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
419
419
  <slot></slot>
420
420
  </div>
421
421
  <slot name="checked-indicator" hidden></slot>
422
- `;const ws={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"};class es extends k.HTMLElement{constructor(){super(),ye(this,Th),ye(this,El),ye(this,Ah),ye(this,Sh),ye(this,xh),ye(this,pr),ye(this,sc),ye(this,kh),ye(this,Bm),ye(this,Lh),ye(this,Gm),ye(this,Ih),ye(this,Rh),ye(this,Ua),ye(this,wh),ye(this,Fa),ye(this,bl),ye(this,mi,void 0),ye(this,fr,void 0),ye(this,ks,void 0),ye(this,Ub,""),ye(this,Fb,null),ye(this,gl,new Set),ye(this,vl,void 0),ye(this,mr,!1),ye(this,ic,()=>{const e=Ee(this,gl),t=new Set(this.items);for(const s of e)t.has(s)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:s}));for(const s of t)e.has(s)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:s}));Vi(this,gl,t)}),ye(this,Tn,()=>{xe(this,pr,Nn).call(this,!1),xe(this,sc,$m).call(this,!1)}),ye(this,_n,()=>{xe(this,pr,Nn).call(this,!1)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),Vi(this,vl,new MutationObserver(Ee(this,ic))),Ee(this,vl).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[ws.DISABLED,ws.HIDDEN,ws.STYLE,ws.ANCHOR,ue.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":xe(this,Th,$b).call(this,e);break;case"invoke":xe(this,Ah,Bb).call(this,e);break;case"click":xe(this,kh,Wb).call(this,e);break;case"toggle":xe(this,Lh,Vb).call(this,e);break;case"focusout":xe(this,Ih,Yb).call(this,e);break;case"keydown":xe(this,Rh,jb).call(this,e);break}}connectedCallback(){var e,t;xe(this,El,_h).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Vi(this,mi,mh(this)),(t=(e=Ee(this,mi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(xs(eo(this),Ee(this,Tn)),xs(this,Ee(this,_n)))}disconnectedCallback(){var e,t;Ar(eo(this),Ee(this,Tn)),Ar(this,Ee(this,_n)),this.disable(),(t=(e=Ee(this,mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Vi(this,mi,null)}attributeChangedCallback(e,t,s){var r,n,a,o;e===ws.HIDDEN&&s!==t?(Ee(this,mr)||Vi(this,mr,!0),this.hidden?xe(this,xh,Hb).call(this):xe(this,Sh,Gb).call(this),this.dispatchEvent(new VR({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===ue.MEDIA_CONTROLLER?(t&&((n=(r=Ee(this,mi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Vi(this,mi,null)),s&&this.isConnected&&(Vi(this,mi,mh(this)),(o=(a=Ee(this,mi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===ws.DISABLED&&s!==t?s==null?this.enable():this.disable():e===ws.STYLE&&s!==t&&xe(this,El,_h).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=wc(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(zR)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){const t=this.items.find(s=>s.value===e);t&&xe(this,bl,Ch).call(this,t)}focus(){if(Vi(this,fr,Rc()),this.items.length){xe(this,Fa,nc).call(this,this.items[0]),this.items[0].focus();return}const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;const s=xe(this,Ua,rc).call(this,e);s&&(xe(this,bl,Ch).call(this,s,s.type==="checkbox"),Ee(this,ks)&&!this.hidden&&((t=Ee(this,fr))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,s;const{key:r}=e,n=this.items,a=(s=(t=xe(this,Ua,rc).call(this,e))!=null?t:xe(this,wh,zb).call(this))!=null?s:n[0],o=n.indexOf(a);let l=Math.max(0,o);r==="ArrowDown"?l++:r==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),xe(this,Fa,nc).call(this,n[l]),n[l].focus()}}mi=new WeakMap;fr=new WeakMap;ks=new WeakMap;Ub=new WeakMap;Fb=new WeakMap;gl=new WeakMap;vl=new WeakMap;mr=new WeakMap;Th=new WeakSet;$b=function(i){const e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){const t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Ee(this,ic).call(this)};ic=new WeakMap;El=new WeakSet;_h=function(){var i;const e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Ah=new WeakSet;Bb=function(i){Vi(this,ks,i.relatedTarget),Ni(this,i.relatedTarget)||(this.hidden=!this.hidden)};Sh=new WeakSet;Gb=function(){var i;(i=Ee(this,ks))==null||i.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>xe(this,pr,Nn).call(this,!1)),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),xs(eo(this),Ee(this,Tn)),xs(this,Ee(this,_n))};xh=new WeakSet;Hb=function(){var i;(i=Ee(this,ks))==null||i.setAttribute("aria-expanded","false"),Ar(eo(this),Ee(this,Tn)),Ar(this,Ee(this,_n))};Tn=new WeakMap;_n=new WeakMap;pr=new WeakSet;Nn=function(i,e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;const{x:t,y:s}=FR({anchor:this.anchorElement,floating:this,placement:"top-start"});e??(e=this.offsetWidth);const n=eo(this).getBoundingClientRect(),a=this.anchorElement.getBoundingClientRect(),o=n.width-t-e,l=n.height-s-this.offsetHeight,d=n.height-a.height,{style:c}=Ge(this.shadowRoot,":host");i||c.setProperty("--media-menu-transition-in","none"),c.setProperty("position","absolute"),c.setProperty("right",`${Math.max(0,o)}px`),c.setProperty("bottom",`${l}px`),c.setProperty("--_menu-max-height",`${d}px`),c.removeProperty("--media-menu-transition-in")};sc=new WeakSet;$m=function(i){const e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:s}=Ge(this.shadowRoot,":host");if(i||s.setProperty("--media-menu-transition-in","none"),t){const r=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${r}px`),xe(this,pr,Nn).call(this,i,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),xe(this,pr,Nn).call(this,i);s.removeProperty("--media-menu-transition-in")};kh=new WeakSet;Wb=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Ee(this,Bm,Kb))){(e=Ee(this,fr))==null||e.focus(),this.hidden=!0;return}const t=xe(this,Ua,rc).call(this,i);!t||t.hasAttribute("disabled")||(xe(this,Fa,nc).call(this,t),this.handleSelect(i))};Bm=new WeakSet;Kb=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.part.contains("back")&&t.part.contains("button"))};Lh=new WeakSet;Vb=function(i){if(i.target===this)return;xe(this,Gm,qb).call(this);const e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(const t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Um({relatedTarget:t}));for(const t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);xe(this,sc,$m).call(this,!0)};Gm=new WeakSet;qb=function(){const e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};Ih=new WeakSet;Yb=function(i){var e;Ni(this,i.relatedTarget)||(Ee(this,mr)&&((e=Ee(this,fr))==null||e.focus()),Ee(this,ks)&&Ee(this,ks)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Rh=new WeakSet;jb=function(i){var e,t,s,r,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Ee(this,mr)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(s=this.nextElementSibling)==null?void 0:s.focus)==null||r.call(s),this.blur()}else a==="Escape"?((n=Ee(this,fr))==null||n.focus(),Ee(this,mr)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};Ua=new WeakSet;rc=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};wh=new WeakSet;zb=function(){return this.items.find(i=>i.tabIndex===0)};Fa=new WeakSet;nc=function(i){for(const e of this.items)e.tabIndex=e===i?0:-1};bl=new WeakSet;Ch=function(i,e){const t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(s=>s.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((s,r)=>s!=t[r])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};jR(es,"template",Xb);function zR(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function eo(i){var e;return(e=i.getAttribute("bounds")?Rr(i,`#${i.getAttribute("bounds")}`):oi(i)||i.parentElement)!=null?e:i}k.customElements.get("media-chrome-menu")||k.customElements.define("media-chrome-menu",es);var Hm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Qb=(i,e,t)=>(Hm(i,e,"read from private field"),t?t.call(i):e.get(i)),Po=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Dh=(i,e,t,s)=>(Hm(i,e,"write to private field"),e.set(i,t),t),No=(i,e,t)=>(Hm(i,e,"access private method"),t),da,ac,yl,Mh,Tl,Oh;class XR extends es{constructor(){super(...arguments),Po(this,yl),Po(this,Tl),Po(this,da,[]),Po(this,ac,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==s?this.value=s:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==s&&(Dh(this,da,rb(s)),No(this,yl,Mh).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",No(this,Tl,Oh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",No(this,Tl,Oh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return Qb(this,da)}set mediaAudioTrackList(e){Dh(this,da,e),No(this,yl,Mh).call(this)}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}da=new WeakMap;ac=new WeakMap;yl=new WeakSet;Mh=function(){if(Qb(this,ac)===JSON.stringify(this.mediaAudioTrackList))return;Dh(this,ac,JSON.stringify(this.mediaAudioTrackList));const i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(const e of i){const t=this.formatMenuItemText(e.label,e),s=Un({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});s.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(s)}};Tl=new WeakSet;Oh=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-audio-track-menu")||k.customElements.define("media-audio-track-menu",XR);class Bn extends xt{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=wc(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){this.invokeTargetElement.dispatchEvent(new Um({relatedTarget:this}))}}k.customElements.get("media-chrome-menu-button")||k.customElements.define("media-chrome-menu-button",Bn);const QR=`<svg aria-hidden="true" viewBox="0 0 24 24">
422
+ `;const ws={STYLE:"style",HIDDEN:"hidden",DISABLED:"disabled",ANCHOR:"anchor"};class es extends k.HTMLElement{constructor(){super(),ye(this,Th),ye(this,El),ye(this,Ah),ye(this,Sh),ye(this,xh),ye(this,pr),ye(this,sc),ye(this,kh),ye(this,Bm),ye(this,Lh),ye(this,Gm),ye(this,Ih),ye(this,Rh),ye(this,Ua),ye(this,wh),ye(this,Fa),ye(this,bl),ye(this,mi,void 0),ye(this,fr,void 0),ye(this,ks,void 0),ye(this,Ub,""),ye(this,Fb,null),ye(this,gl,new Set),ye(this,vl,void 0),ye(this,mr,!1),ye(this,ic,()=>{const e=Ee(this,gl),t=new Set(this.items);for(const s of e)t.has(s)||this.dispatchEvent(new CustomEvent("removemenuitem",{detail:s}));for(const s of t)e.has(s)||this.dispatchEvent(new CustomEvent("addmenuitem",{detail:s}));Vi(this,gl,t)}),ye(this,Tn,()=>{xe(this,pr,Nn).call(this,!1),xe(this,sc,$m).call(this,!1)}),ye(this,_n,()=>{xe(this,pr,Nn).call(this,!1)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.defaultSlot=this.shadowRoot.querySelector("slot:not([name])"),this.shadowRoot.addEventListener("slotchange",this),Vi(this,vl,new MutationObserver(Ee(this,ic))),Ee(this,vl).observe(this.defaultSlot,{childList:!0})}static get observedAttributes(){return[ws.DISABLED,ws.HIDDEN,ws.STYLE,ws.ANCHOR,ue.MEDIA_CONTROLLER]}static formatMenuItemText(e){return e}enable(){this.addEventListener("click",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this),this.addEventListener("invoke",this),this.addEventListener("toggle",this)}disable(){this.removeEventListener("click",this),this.removeEventListener("focusout",this),this.removeEventListener("keyup",this),this.removeEventListener("invoke",this),this.removeEventListener("toggle",this)}handleEvent(e){switch(e.type){case"slotchange":xe(this,Th,$b).call(this,e);break;case"invoke":xe(this,Ah,Bb).call(this,e);break;case"click":xe(this,kh,Wb).call(this,e);break;case"toggle":xe(this,Lh,Vb).call(this,e);break;case"focusout":xe(this,Ih,Yb).call(this,e);break;case"keydown":xe(this,Rh,jb).call(this,e);break}}connectedCallback(){var e,t;xe(this,El,_h).call(this),this.hasAttribute("disabled")||this.enable(),this.role||(this.role="menu"),Vi(this,mi,mh(this)),(t=(e=Ee(this,mi))==null?void 0:e.associateElement)==null||t.call(e,this),this.hidden||(xs(eo(this),Ee(this,Tn)),xs(this,Ee(this,_n)))}disconnectedCallback(){var e,t;Ar(eo(this),Ee(this,Tn)),Ar(this,Ee(this,_n)),this.disable(),(t=(e=Ee(this,mi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Vi(this,mi,null)}attributeChangedCallback(e,t,s){var r,n,a,o;e===ws.HIDDEN&&s!==t?(Ee(this,mr)||Vi(this,mr,!0),this.hidden?xe(this,xh,Hb).call(this):xe(this,Sh,Gb).call(this),this.dispatchEvent(new qR({oldState:this.hidden?"open":"closed",newState:this.hidden?"closed":"open",bubbles:!0}))):e===ue.MEDIA_CONTROLLER?(t&&((n=(r=Ee(this,mi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Vi(this,mi,null)),s&&this.isConnected&&(Vi(this,mi,mh(this)),(o=(a=Ee(this,mi))==null?void 0:a.associateElement)==null||o.call(a,this))):e===ws.DISABLED&&s!==t?s==null?this.enable():this.disable():e===ws.STYLE&&s!==t&&xe(this,El,_h).call(this)}formatMenuItemText(e,t){return this.constructor.formatMenuItemText(e,t)}get anchor(){return this.getAttribute("anchor")}set anchor(e){this.setAttribute("anchor",`${e}`)}get anchorElement(){var e;return this.anchor?(e=wc(this))==null?void 0:e.querySelector(`#${this.anchor}`):null}get items(){return this.defaultSlot.assignedElements({flatten:!0}).filter(XR)}get radioGroupItems(){return this.items.filter(e=>e.role==="menuitemradio")}get checkedItems(){return this.items.filter(e=>e.checked)}get value(){var e,t;return(t=(e=this.checkedItems[0])==null?void 0:e.value)!=null?t:""}set value(e){const t=this.items.find(s=>s.value===e);t&&xe(this,bl,Ch).call(this,t)}focus(){if(Vi(this,fr,Rc()),this.items.length){xe(this,Fa,nc).call(this,this.items[0]),this.items[0].focus();return}const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}handleSelect(e){var t;const s=xe(this,Ua,rc).call(this,e);s&&(xe(this,bl,Ch).call(this,s,s.type==="checkbox"),Ee(this,ks)&&!this.hidden&&((t=Ee(this,fr))==null||t.focus(),this.hidden=!0))}get keysUsed(){return["Enter","Escape","Tab"," ","ArrowDown","ArrowUp","Home","End"]}handleMove(e){var t,s;const{key:r}=e,n=this.items,a=(s=(t=xe(this,Ua,rc).call(this,e))!=null?t:xe(this,wh,zb).call(this))!=null?s:n[0],o=n.indexOf(a);let l=Math.max(0,o);r==="ArrowDown"?l++:r==="ArrowUp"?l--:e.key==="Home"?l=0:e.key==="End"&&(l=n.length-1),l<0&&(l=n.length-1),l>n.length-1&&(l=0),xe(this,Fa,nc).call(this,n[l]),n[l].focus()}}mi=new WeakMap;fr=new WeakMap;ks=new WeakMap;Ub=new WeakMap;Fb=new WeakMap;gl=new WeakMap;vl=new WeakMap;mr=new WeakMap;Th=new WeakSet;$b=function(i){const e=i.target;for(let t of e.assignedNodes({flatten:!0}))t.nodeType===3&&t.textContent.trim()===""&&t.remove();if(["header","title"].includes(e.name)){const t=this.shadowRoot.querySelector('slot[name="header"]');t.hidden=e.assignedNodes().length===0}e.name||Ee(this,ic).call(this)};ic=new WeakMap;El=new WeakSet;_h=function(){var i;const e=this.shadowRoot.querySelector("#layout-row"),t=(i=getComputedStyle(this).getPropertyValue("--media-menu-layout"))==null?void 0:i.trim();e.setAttribute("media",t==="row"?"":"width:0")};Ah=new WeakSet;Bb=function(i){Vi(this,ks,i.relatedTarget),Ni(this,i.relatedTarget)||(this.hidden=!this.hidden)};Sh=new WeakSet;Gb=function(){var i;(i=Ee(this,ks))==null||i.setAttribute("aria-expanded","true"),requestAnimationFrame(()=>xe(this,pr,Nn).call(this,!1)),this.addEventListener("transitionend",()=>this.focus(),{once:!0}),xs(eo(this),Ee(this,Tn)),xs(this,Ee(this,_n))};xh=new WeakSet;Hb=function(){var i;(i=Ee(this,ks))==null||i.setAttribute("aria-expanded","false"),Ar(eo(this),Ee(this,Tn)),Ar(this,Ee(this,_n))};Tn=new WeakMap;_n=new WeakMap;pr=new WeakSet;Nn=function(i,e){if(this.hasAttribute("mediacontroller")&&!this.anchor||this.hidden||!this.anchorElement)return;const{x:t,y:s}=$R({anchor:this.anchorElement,floating:this,placement:"top-start"});e??(e=this.offsetWidth);const n=eo(this).getBoundingClientRect(),a=this.anchorElement.getBoundingClientRect(),o=n.width-t-e,l=n.height-s-this.offsetHeight,d=n.height-a.height,{style:c}=Ge(this.shadowRoot,":host");i||c.setProperty("--media-menu-transition-in","none"),c.setProperty("position","absolute"),c.setProperty("right",`${Math.max(0,o)}px`),c.setProperty("bottom",`${l}px`),c.setProperty("--_menu-max-height",`${d}px`),c.removeProperty("--media-menu-transition-in")};sc=new WeakSet;$m=function(i){const e=this.querySelector('[role="menuitem"][aria-haspopup][aria-expanded="true"]'),t=e==null?void 0:e.querySelector('[role="menu"]'),{style:s}=Ge(this.shadowRoot,":host");if(i||s.setProperty("--media-menu-transition-in","none"),t){const r=t.offsetHeight,n=Math.max(t.offsetWidth,e.offsetWidth);this.style.setProperty("min-width",`${n}px`),this.style.setProperty("min-height",`${r}px`),xe(this,pr,Nn).call(this,i,n)}else this.style.removeProperty("min-width"),this.style.removeProperty("min-height"),xe(this,pr,Nn).call(this,i);s.removeProperty("--media-menu-transition-in")};kh=new WeakSet;Wb=function(i){var e;if(i.stopPropagation(),i.composedPath().includes(Ee(this,Bm,Kb))){(e=Ee(this,fr))==null||e.focus(),this.hidden=!0;return}const t=xe(this,Ua,rc).call(this,i);!t||t.hasAttribute("disabled")||(xe(this,Fa,nc).call(this,t),this.handleSelect(i))};Bm=new WeakSet;Kb=function(){var i;return(i=this.shadowRoot.querySelector('slot[name="header"]').assignedElements({flatten:!0}))==null?void 0:i.find(t=>t.part.contains("back")&&t.part.contains("button"))};Lh=new WeakSet;Vb=function(i){if(i.target===this)return;xe(this,Gm,qb).call(this);const e=Array.from(this.querySelectorAll('[role="menuitem"][aria-haspopup]'));for(const t of e)t.invokeTargetElement!=i.target&&i.newState=="open"&&t.getAttribute("aria-expanded")=="true"&&!t.invokeTargetElement.hidden&&t.invokeTargetElement.dispatchEvent(new Um({relatedTarget:t}));for(const t of e)t.setAttribute("aria-expanded",`${!t.submenuElement.hidden}`);xe(this,sc,$m).call(this,!0)};Gm=new WeakSet;qb=function(){const e=this.querySelector('[role="menuitem"] > [role="menu"]:not([hidden])');this.container.classList.toggle("has-expanded",!!e)};Ih=new WeakSet;Yb=function(i){var e;Ni(this,i.relatedTarget)||(Ee(this,mr)&&((e=Ee(this,fr))==null||e.focus()),Ee(this,ks)&&Ee(this,ks)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Rh=new WeakSet;jb=function(i){var e,t,s,r,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;if(!(o||l||d)&&this.keysUsed.includes(a))if(i.preventDefault(),i.stopPropagation(),a==="Tab"){if(Ee(this,mr)){this.hidden=!0;return}i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(s=this.nextElementSibling)==null?void 0:s.focus)==null||r.call(s),this.blur()}else a==="Escape"?((n=Ee(this,fr))==null||n.focus(),Ee(this,mr)&&(this.hidden=!0)):a==="Enter"||a===" "?this.handleSelect(i):this.handleMove(i)};Ua=new WeakSet;rc=function(i){return i.composedPath().find(e=>["menuitemradio","menuitemcheckbox"].includes(e.role))};wh=new WeakSet;zb=function(){return this.items.find(i=>i.tabIndex===0)};Fa=new WeakSet;nc=function(i){for(const e of this.items)e.tabIndex=e===i?0:-1};bl=new WeakSet;Ch=function(i,e){const t=[...this.checkedItems];i.type==="radio"&&this.radioGroupItems.forEach(s=>s.checked=!1),e?i.checked=!i.checked:i.checked=!0,this.checkedItems.some((s,r)=>s!=t[r])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};zR(es,"template",Xb);function XR(i){return["menuitem","menuitemradio","menuitemcheckbox"].includes(i==null?void 0:i.role)}function eo(i){var e;return(e=i.getAttribute("bounds")?Rr(i,`#${i.getAttribute("bounds")}`):oi(i)||i.parentElement)!=null?e:i}k.customElements.get("media-chrome-menu")||k.customElements.define("media-chrome-menu",es);var Hm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Qb=(i,e,t)=>(Hm(i,e,"read from private field"),t?t.call(i):e.get(i)),Po=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Dh=(i,e,t,s)=>(Hm(i,e,"write to private field"),e.set(i,t),t),No=(i,e,t)=>(Hm(i,e,"access private method"),t),da,ac,yl,Mh,Tl,Oh;class QR extends es{constructor(){super(...arguments),Po(this,yl),Po(this,Tl),Po(this,da,[]),Po(this,ac,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==s?this.value=s:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==s&&(Dh(this,da,rb(s)),No(this,yl,Mh).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",No(this,Tl,Oh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",No(this,Tl,Oh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-audio-track-menu-button")}get mediaAudioTrackList(){return Qb(this,da)}set mediaAudioTrackList(e){Dh(this,da,e),No(this,yl,Mh).call(this)}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}da=new WeakMap;ac=new WeakMap;yl=new WeakSet;Mh=function(){if(Qb(this,ac)===JSON.stringify(this.mediaAudioTrackList))return;Dh(this,ac,JSON.stringify(this.mediaAudioTrackList));const i=this.mediaAudioTrackList;this.defaultSlot.textContent="";for(const e of i){const t=this.formatMenuItemText(e.label,e),s=Un({type:"radio",text:t,value:`${e.id}`,checked:e.enabled});s.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(s)}};Tl=new WeakSet;Oh=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-audio-track-menu")||k.customElements.define("media-audio-track-menu",QR);class Bn extends xt{connectedCallback(){super.connectedCallback(),this.invokeTargetElement&&this.setAttribute("aria-haspopup","menu")}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=wc(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):null}handleClick(){this.invokeTargetElement.dispatchEvent(new Um({relatedTarget:this}))}}k.customElements.get("media-chrome-menu-button")||k.customElements.define("media-chrome-menu-button",Bn);const ZR=`<svg aria-hidden="true" viewBox="0 0 24 24">
423
423
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
424
424
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
425
425
  </svg>`,Zb=z.createElement("template");Zb.innerHTML=`
426
- <slot name="icon">${QR}</slot>
427
- `;class ZR extends Bn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:Zb})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.AUDIO_TRACKS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}k.customElements.get("media-audio-track-menu-button")||k.customElements.define("media-audio-track-menu-button",ZR);const JR=`<svg aria-hidden="true" viewBox="0 0 26 24">
426
+ <slot name="icon">${ZR}</slot>
427
+ `;class JR extends Bn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:Zb})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.AUDIO_TRACKS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-audio-track-menu")}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}k.customElements.get("media-audio-track-menu-button")||k.customElements.define("media-audio-track-menu-button",JR);const ew=`<svg aria-hidden="true" viewBox="0 0 26 24">
428
428
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
429
- </svg>`,ew=`<svg aria-hidden="true" viewBox="0 0 26 24">
429
+ </svg>`,tw=`<svg aria-hidden="true" viewBox="0 0 26 24">
430
430
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
431
431
  </svg>`,Jb=z.createElement("template");Jb.innerHTML=`
432
432
  <style>
@@ -441,16 +441,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
441
441
  </style>
442
442
 
443
443
  <slot name="icon">
444
- <slot name="on">${JR}</slot>
445
- <slot name="off">${ew}</slot>
444
+ <slot name="on">${ew}</slot>
445
+ <slot name="off">${tw}</slot>
446
446
  </slot>
447
- `;const rg=i=>{i.setAttribute("aria-checked",xb(i))};class tw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Jb,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Ut.CLOSED_CAPTIONS()),rg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_SHOWING&&rg(this)}get mediaSubtitlesList(){return ng(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ag(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return ng(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ag(this,T.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new k.CustomEvent(K.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}const ng=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},ag=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-button")||k.customElements.define("media-captions-button",tw);var iw=Object.defineProperty,sw=(i,e,t)=>e in i?iw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,rw=(i,e,t)=>(sw(i,e+"",t),t),Wm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},nw=(i,e,t)=>(Wm(i,e,"read from private field"),t?t.call(i):e.get(i)),bu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},aw=(i,e,t,s)=>(Wm(i,e,"write to private field"),e.set(i,t),t),yu=(i,e,t)=>(Wm(i,e,"access private method"),t),oc,Ph,ey,_l,Nh;const ow=`
447
+ `;const rg=i=>{i.setAttribute("aria-checked",xb(i))};class iw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:Jb,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("role","switch"),this.setAttribute("aria-label",Ut.CLOSED_CAPTIONS()),rg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_SHOWING&&rg(this)}get mediaSubtitlesList(){return ng(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ag(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return ng(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ag(this,T.MEDIA_SUBTITLES_SHOWING,e)}handleClick(){this.dispatchEvent(new k.CustomEvent(K.MEDIA_TOGGLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0}))}}const ng=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},ag=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-button")||k.customElements.define("media-captions-button",iw);var sw=Object.defineProperty,rw=(i,e,t)=>e in i?sw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,nw=(i,e,t)=>(rw(i,e+"",t),t),Wm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},aw=(i,e,t)=>(Wm(i,e,"read from private field"),t?t.call(i):e.get(i)),bu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ow=(i,e,t,s)=>(Wm(i,e,"write to private field"),e.set(i,t),t),yu=(i,e,t)=>(Wm(i,e,"access private method"),t),oc,Ph,ey,_l,Nh;const lw=`
448
448
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
449
449
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
450
450
  </svg>`,ty=z.createElement("template");ty.innerHTML=es.template.innerHTML+`
451
- <slot name="captions-indicator" hidden>${ow}</slot>`;class iy extends es{constructor(){super(...arguments),bu(this,Ph),bu(this,_l),bu(this,oc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_LIST&&t!==s?yu(this,Ph,ey).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==s&&(this.value=s)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",yu(this,_l,Nh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",yu(this,_l,Nh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return og(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){lg(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return og(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){lg(this,T.MEDIA_SUBTITLES_SHOWING,e)}}oc=new WeakMap;Ph=new WeakSet;ey=function(){var i;if(nw(this,oc)===JSON.stringify(this.mediaSubtitlesList))return;aw(this,oc,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";const e=!this.value,t=Un({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(t);const s=this.mediaSubtitlesList;for(const r of s){const n=Un({type:"radio",text:this.formatMenuItemText(r.label,r),value:Za(r),checked:this.value==Za(r)});n.prepend(gr(this,"checked-indicator")),((i=r.kind)!=null?i:"subs")==="captions"&&n.append(gr(this,"captions-indicator")),this.defaultSlot.append(n)}};_l=new WeakSet;Nh=function(){const i=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new k.CustomEvent(K.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;const s=new k.CustomEvent(K.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};rw(iy,"template",ty);const og=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},lg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-menu")||k.customElements.define("media-captions-menu",iy);const lw=`<svg aria-hidden="true" viewBox="0 0 26 24">
451
+ <slot name="captions-indicator" hidden>${lw}</slot>`;class iy extends es{constructor(){super(...arguments),bu(this,Ph),bu(this,_l),bu(this,oc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_LIST&&t!==s?yu(this,Ph,ey).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==s&&(this.value=s)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",yu(this,_l,Nh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",yu(this,_l,Nh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-captions-menu-button")}get mediaSubtitlesList(){return og(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){lg(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return og(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){lg(this,T.MEDIA_SUBTITLES_SHOWING,e)}}oc=new WeakMap;Ph=new WeakSet;ey=function(){var i;if(aw(this,oc)===JSON.stringify(this.mediaSubtitlesList))return;ow(this,oc,JSON.stringify(this.mediaSubtitlesList)),this.defaultSlot.textContent="";const e=!this.value,t=Un({type:"radio",text:this.formatMenuItemText("Off"),value:"off",checked:e});t.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(t);const s=this.mediaSubtitlesList;for(const r of s){const n=Un({type:"radio",text:this.formatMenuItemText(r.label,r),value:Za(r),checked:this.value==Za(r)});n.prepend(gr(this,"checked-indicator")),((i=r.kind)!=null?i:"subs")==="captions"&&n.append(gr(this,"captions-indicator")),this.defaultSlot.append(n)}};_l=new WeakSet;Nh=function(){const i=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new k.CustomEvent(K.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;const s=new k.CustomEvent(K.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};nw(iy,"template",ty);const og=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},lg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-menu")||k.customElements.define("media-captions-menu",iy);const dw=`<svg aria-hidden="true" viewBox="0 0 26 24">
452
452
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
453
- </svg>`,dw=`<svg aria-hidden="true" viewBox="0 0 26 24">
453
+ </svg>`,cw=`<svg aria-hidden="true" viewBox="0 0 26 24">
454
454
  <path d="M17.73 14.09a1.4 1.4 0 0 1-1 .37 1.579 1.579 0 0 1-1.27-.58A3 3 0 0 1 15 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34A2.89 2.89 0 0 0 19 9.07a3 3 0 0 0-2.14-.78 3.14 3.14 0 0 0-2.42 1 3.91 3.91 0 0 0-.93 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.17 3.17 0 0 0 1.07-1.74l-1.4-.45c-.083.43-.3.822-.62 1.12Zm-7.22 0a1.43 1.43 0 0 1-1 .37 1.58 1.58 0 0 1-1.27-.58A3 3 0 0 1 7.76 12a2.8 2.8 0 0 1 .5-1.85 1.63 1.63 0 0 1 1.29-.57 1.47 1.47 0 0 1 1.51 1.2l1.43-.34a2.81 2.81 0 0 0-.74-1.32 2.94 2.94 0 0 0-2.13-.78 3.18 3.18 0 0 0-2.43 1 4 4 0 0 0-.92 2.78 3.74 3.74 0 0 0 .92 2.66 3.07 3.07 0 0 0 2.34 1 3.07 3.07 0 0 0 1.91-.57 3.23 3.23 0 0 0 1.07-1.74l-1.4-.45a2.06 2.06 0 0 1-.6 1.07Zm12.32-8.41a2.59 2.59 0 0 0-2.3-2.51C18.72 3.05 15.86 3 13 3c-2.86 0-5.72.05-7.53.17a2.59 2.59 0 0 0-2.3 2.51c-.23 4.207-.23 8.423 0 12.63a2.57 2.57 0 0 0 2.3 2.5c1.81.13 4.67.19 7.53.19 2.86 0 5.72-.06 7.53-.19a2.57 2.57 0 0 0 2.3-2.5c.23-4.207.23-8.423 0-12.63Zm-1.49 12.53a1.11 1.11 0 0 1-.91 1.11c-1.67.11-4.45.18-7.43.18-2.98 0-5.76-.07-7.43-.18a1.11 1.11 0 0 1-.91-1.11c-.21-4.14-.21-8.29 0-12.43a1.11 1.11 0 0 1 .91-1.11C7.24 4.56 10 4.49 13 4.49s5.76.07 7.43.18a1.11 1.11 0 0 1 .91 1.11c.21 4.14.21 8.29 0 12.43Z"/>
455
455
  </svg>`,sy=z.createElement("template");sy.innerHTML=`
456
456
  <style>
@@ -465,10 +465,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
465
465
  </style>
466
466
 
467
467
  <slot name="icon">
468
- <slot name="on">${lw}</slot>
469
- <slot name="off">${dw}</slot>
468
+ <slot name="on">${dw}</slot>
469
+ <slot name="off">${cw}</slot>
470
470
  </slot>
471
- `;const dg=i=>{i.setAttribute("aria-checked",xb(i))};class cw extends Bn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:sy,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.CLOSED_CAPTIONS()),dg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_SHOWING&&dg(this)}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-captions-menu")}get mediaSubtitlesList(){return cg(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ug(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return cg(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ug(this,T.MEDIA_SUBTITLES_SHOWING,e)}}const cg=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},ug=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-menu-button")||k.customElements.define("media-captions-menu-button",cw);const uw='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',hw='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',ry=z.createElement("template");ry.innerHTML=`
471
+ `;const dg=i=>{i.setAttribute("aria-checked",xb(i))};class uw extends Bn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}constructor(e={}){super({slotTemplate:sy,...e}),this._captionsReady=!1}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.CLOSED_CAPTIONS()),dg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_SHOWING&&dg(this)}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-captions-menu")}get mediaSubtitlesList(){return cg(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){ug(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return cg(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){ug(this,T.MEDIA_SUBTITLES_SHOWING,e)}}const cg=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},ug=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-menu-button")||k.customElements.define("media-captions-menu-button",uw);const hw='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/></g></svg>',fw='<svg aria-hidden="true" viewBox="0 0 24 24"><g><path class="cast_caf_icon_arch0" d="M1,18 L1,21 L4,21 C4,19.3 2.66,18 1,18 L1,18 Z"/><path class="cast_caf_icon_arch1" d="M1,14 L1,16 C3.76,16 6,18.2 6,21 L8,21 C8,17.13 4.87,14 1,14 L1,14 Z"/><path class="cast_caf_icon_arch2" d="M1,10 L1,12 C5.97,12 10,16.0 10,21 L12,21 C12,14.92 7.07,10 1,10 L1,10 Z"/><path class="cast_caf_icon_box" d="M21,3 L3,3 C1.9,3 1,3.9 1,5 L1,8 L3,8 L3,5 L21,5 L21,19 L14,19 L14,21 L21,21 C22.1,21 23,20.1 23,19 L23,5 C23,3.9 22.1,3 21,3 L21,3 Z"/><path class="cast_caf_icon_boxfill" d="M5,7 L5,8.63 C8,8.6 13.37,14 13.37,17 L19,17 L19,7 Z"/></g></svg>',ry=z.createElement("template");ry.innerHTML=`
472
472
  <style>
473
473
  :host([${T.MEDIA_IS_CASTING}]) slot:not([name=exit]):not([name=icon]) {
474
474
  display: none !important;
@@ -481,10 +481,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
481
481
  </style>
482
482
 
483
483
  <slot name="icon">
484
- <slot name="enter">${uw}</slot>
485
- <slot name="exit">${hw}</slot>
484
+ <slot name="enter">${hw}</slot>
485
+ <slot name="exit">${fw}</slot>
486
486
  </slot>
487
- `;const hg=i=>{const e=i.mediaIsCasting?At.EXIT_CAST():At.ENTER_CAST();i.setAttribute("aria-label",e)};class fw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:ry,...e})}connectedCallback(){super.connectedCallback(),hg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_IS_CASTING&&hg(this)}get mediaIsCasting(){return at(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){ot(this,T.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Ve(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){qe(this,T.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){const e=this.mediaIsCasting?K.MEDIA_EXIT_CAST_REQUEST:K.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-cast-button")||k.customElements.define("media-cast-button",fw);var mw=Object.defineProperty,pw=(i,e,t)=>e in i?mw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,gw=(i,e,t)=>(pw(i,e+"",t),t),Km=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},An=(i,e,t)=>(Km(i,e,"read from private field"),t?t.call(i):e.get(i)),Cs=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ny=(i,e,t,s)=>(Km(i,e,"write to private field"),e.set(i,t),t),Yn=(i,e,t)=>(Km(i,e,"access private method"),t),to,Sr,Uh,ay,Fh,oy,$h,ly,Bh,dy,Gh,cy;const uy=z.createElement("template");uy.innerHTML=`
487
+ `;const hg=i=>{const e=i.mediaIsCasting?At.EXIT_CAST():At.ENTER_CAST();i.setAttribute("aria-label",e)};class mw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_CASTING,T.MEDIA_CAST_UNAVAILABLE]}constructor(e={}){super({slotTemplate:ry,...e})}connectedCallback(){super.connectedCallback(),hg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_IS_CASTING&&hg(this)}get mediaIsCasting(){return at(this,T.MEDIA_IS_CASTING)}set mediaIsCasting(e){ot(this,T.MEDIA_IS_CASTING,e)}get mediaCastUnavailable(){return Ve(this,T.MEDIA_CAST_UNAVAILABLE)}set mediaCastUnavailable(e){qe(this,T.MEDIA_CAST_UNAVAILABLE,e)}handleClick(){const e=this.mediaIsCasting?K.MEDIA_EXIT_CAST_REQUEST:K.MEDIA_ENTER_CAST_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-cast-button")||k.customElements.define("media-cast-button",mw);var pw=Object.defineProperty,gw=(i,e,t)=>e in i?pw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,vw=(i,e,t)=>(gw(i,e+"",t),t),Km=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},An=(i,e,t)=>(Km(i,e,"read from private field"),t?t.call(i):e.get(i)),Cs=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ny=(i,e,t,s)=>(Km(i,e,"write to private field"),e.set(i,t),t),Yn=(i,e,t)=>(Km(i,e,"access private method"),t),to,Sr,Uh,ay,Fh,oy,$h,ly,Bh,dy,Gh,cy;const uy=z.createElement("template");uy.innerHTML=`
488
488
  <style>
489
489
  :host {
490
490
  font: var(--media-font,
@@ -521,7 +521,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
521
521
  }
522
522
  </style>
523
523
  <slot></slot>
524
- `;const Tu={HIDDEN:"hidden",ANCHOR:"anchor"};class hy extends k.HTMLElement{constructor(){super(),Cs(this,Uh),Cs(this,Fh),Cs(this,$h),Cs(this,Bh),Cs(this,Gh),Cs(this,to,void 0),Cs(this,Sr,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[Tu.HIDDEN,Tu.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":Yn(this,$h,ly).call(this,e);break;case"focusout":Yn(this,Bh,dy).call(this,e);break;case"keydown":Yn(this,Gh,cy).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,s){e===Tu.HIDDEN&&s!==t&&(this.hidden?Yn(this,Fh,oy).call(this):Yn(this,Uh,ay).call(this))}focus(){ny(this,to,Rc());const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}get keysUsed(){return["Escape","Tab"]}}to=new WeakMap;Sr=new WeakMap;Uh=new WeakSet;ay=function(){var i;(i=An(this,Sr))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Fh=new WeakSet;oy=function(){var i;(i=An(this,Sr))==null||i.setAttribute("aria-expanded","false")};$h=new WeakSet;ly=function(i){ny(this,Sr,i.relatedTarget),Ni(this,i.relatedTarget)||(this.hidden=!this.hidden)};Bh=new WeakSet;dy=function(i){var e;Ni(this,i.relatedTarget)||((e=An(this,to))==null||e.focus(),An(this,Sr)&&An(this,Sr)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Gh=new WeakSet;cy=function(i){var e,t,s,r,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(s=this.nextElementSibling)==null?void 0:s.focus)==null||r.call(s),this.blur()):a==="Escape"&&((n=An(this,to))==null||n.focus(),this.hidden=!0))};gw(hy,"template",uy);k.customElements.get("media-chrome-dialog")||k.customElements.define("media-chrome-dialog",hy);var vw=Object.defineProperty,Ew=(i,e,t)=>e in i?vw(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,bw=(i,e,t)=>(Ew(i,e+"",t),t),Vm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Di=(i,e,t)=>(Vm(i,e,"read from private field"),e.get(i)),Hi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},_u=(i,e,t,s)=>(Vm(i,e,"write to private field"),e.set(i,t),t),Li=(i,e,t)=>(Vm(i,e,"access private method"),t),Al,$a,Hh,fy,qm,my,Ym,py,Mi,Fn,io,Wh,gy,Sl,Kh;const vy=z.createElement("template");vy.innerHTML=`
524
+ `;const Tu={HIDDEN:"hidden",ANCHOR:"anchor"};class hy extends k.HTMLElement{constructor(){super(),Cs(this,Uh),Cs(this,Fh),Cs(this,$h),Cs(this,Bh),Cs(this,Gh),Cs(this,to,void 0),Cs(this,Sr,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=this.constructor.template.content.cloneNode(!0),this.shadowRoot.append(this.nativeEl)),this.addEventListener("invoke",this),this.addEventListener("focusout",this),this.addEventListener("keydown",this)}static get observedAttributes(){return[Tu.HIDDEN,Tu.ANCHOR]}handleEvent(e){switch(e.type){case"invoke":Yn(this,$h,ly).call(this,e);break;case"focusout":Yn(this,Bh,dy).call(this,e);break;case"keydown":Yn(this,Gh,cy).call(this,e);break}}connectedCallback(){this.role||(this.role="dialog")}attributeChangedCallback(e,t,s){e===Tu.HIDDEN&&s!==t&&(this.hidden?Yn(this,Fh,oy).call(this):Yn(this,Uh,ay).call(this))}focus(){ny(this,to,Rc());const e=this.querySelector('[autofocus], [tabindex]:not([tabindex="-1"]), [role="menu"]');e==null||e.focus()}get keysUsed(){return["Escape","Tab"]}}to=new WeakMap;Sr=new WeakMap;Uh=new WeakSet;ay=function(){var i;(i=An(this,Sr))==null||i.setAttribute("aria-expanded","true"),this.addEventListener("transitionend",()=>this.focus(),{once:!0})};Fh=new WeakSet;oy=function(){var i;(i=An(this,Sr))==null||i.setAttribute("aria-expanded","false")};$h=new WeakSet;ly=function(i){ny(this,Sr,i.relatedTarget),Ni(this,i.relatedTarget)||(this.hidden=!this.hidden)};Bh=new WeakSet;dy=function(i){var e;Ni(this,i.relatedTarget)||((e=An(this,to))==null||e.focus(),An(this,Sr)&&An(this,Sr)!==i.relatedTarget&&!this.hidden&&(this.hidden=!0))};Gh=new WeakSet;cy=function(i){var e,t,s,r,n;const{key:a,ctrlKey:o,altKey:l,metaKey:d}=i;o||l||d||this.keysUsed.includes(a)&&(i.preventDefault(),i.stopPropagation(),a==="Tab"?(i.shiftKey?(t=(e=this.previousElementSibling)==null?void 0:e.focus)==null||t.call(e):(r=(s=this.nextElementSibling)==null?void 0:s.focus)==null||r.call(s),this.blur()):a==="Escape"&&((n=An(this,to))==null||n.focus(),this.hidden=!0))};vw(hy,"template",uy);k.customElements.get("media-chrome-dialog")||k.customElements.define("media-chrome-dialog",hy);var Ew=Object.defineProperty,bw=(i,e,t)=>e in i?Ew(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,yw=(i,e,t)=>(bw(i,e+"",t),t),Vm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Di=(i,e,t)=>(Vm(i,e,"read from private field"),e.get(i)),Hi=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},_u=(i,e,t,s)=>(Vm(i,e,"write to private field"),e.set(i,t),t),Li=(i,e,t)=>(Vm(i,e,"access private method"),t),Al,$a,Hh,fy,qm,my,Ym,py,Mi,Fn,io,Wh,gy,Sl,Kh;const vy=z.createElement("template");vy.innerHTML=`
525
525
  <style>
526
526
  :host {
527
527
  transition: var(--media-menu-item-transition,
@@ -637,7 +637,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
637
637
  <slot name="description"></slot>
638
638
  <slot name="suffix"></slot>
639
639
  <slot name="submenu"></slot>
640
- `;const Ht={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"};class Oc extends k.HTMLElement{constructor(){super(),Hi(this,Hh),Hi(this,qm),Hi(this,Ym),Hi(this,Fn),Hi(this,Wh),Hi(this,Sl),Hi(this,Al,!1),Hi(this,$a,void 0),Hi(this,Mi,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);const s=this.shadowRoot.querySelector('slot[name="description"]'),r=(t=(e=this.submenuElement.checkedItems)==null?void 0:e[0])==null?void 0:t.text,n=z.createElement("span");n.textContent=r??"",s.replaceChildren(n)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[Ht.TYPE,Ht.DISABLED,Ht.CHECKED,Ht.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),jn(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Li(this,Hh,fy).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Li(this,Wh,gy).call(this,e);break;case"keyup":Li(this,Fn,io).call(this,e);break}}attributeChangedCallback(e,t,s){e===Ht.CHECKED&&jn(this)&&!Di(this,Al)?this.setAttribute("aria-checked",s!=null?"true":"false"):e===Ht.TYPE&&s!==t?this.role="menuitem"+s:e===Ht.DISABLED&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Ht.DISABLED)||this.enable(),this.role="menuitem"+this.type,_u(this,$a,Vh(this,this.parentNode)),Li(this,Sl,Kh).call(this)}disconnectedCallback(){this.disable(),Li(this,Sl,Kh).call(this),_u(this,$a,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=wc(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(Ht.TYPE))!=null?e:""}set type(e){this.setAttribute(Ht.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(Ht.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Ht.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(jn(this))return this.getAttribute("aria-checked")==="true"}set checked(e){jn(this)&&(_u(this,Al,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){jn(this)||this.invokeTargetElement&&Ni(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Um({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}}Al=new WeakMap;$a=new WeakMap;Hh=new WeakSet;fy=function(i){const e=i.target;if(!(e!=null&&e.name))for(let s of e.assignedNodes({flatten:!0}))s instanceof Text&&s.textContent.trim()===""&&s.remove();e.name==="submenu"&&(this.submenuElement?Li(this,qm,my).call(this):Li(this,Ym,py).call(this))};qm=new WeakSet;my=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Di(this,Mi)),this.submenuElement.addEventListener("addmenuitem",Di(this,Mi)),this.submenuElement.addEventListener("removemenuitem",Di(this,Mi)),Di(this,Mi).call(this)};Ym=new WeakSet;py=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Di(this,Mi)),this.submenuElement.removeEventListener("addmenuitem",Di(this,Mi)),this.submenuElement.removeEventListener("removemenuitem",Di(this,Mi)),Di(this,Mi).call(this)};Mi=new WeakMap;Fn=new WeakSet;io=function(i){const{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Li(this,Fn,io));return}this.handleClick(i)};Wh=new WeakSet;gy=function(i){const{metaKey:e,altKey:t,key:s}=i;if(e||t||!this.keysUsed.includes(s)){this.removeEventListener("keyup",Li(this,Fn,io));return}this.addEventListener("keyup",Li(this,Fn,io),{once:!0})};Sl=new WeakSet;Kh=function(){var i;const e=(i=Di(this,$a))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(s=>s.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(const s of e)s.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};bw(Oc,"template",vy);function jn(i){return i.type==="radio"||i.type==="checkbox"}function Vh(i,e){if(!i)return null;const{host:t}=i.getRootNode();return!e&&t?Vh(i,t):e!=null&&e.items?e:Vh(e,e==null?void 0:e.parentNode)}k.customElements.get("media-chrome-menu-item")||k.customElements.define("media-chrome-menu-item",Oc);var jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},De=(i,e,t)=>(jm(i,e,"read from private field"),t?t.call(i):e.get(i)),ut=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ls=(i,e,t,s)=>(jm(i,e,"write to private field"),e.set(i,t),t),Qt=(i,e,t)=>(jm(i,e,"access private method"),t),pi,Pc,xl,kl,Zt,lc,Ll,Il,Rl,zm,Ey,wl,qh,Cl,Yh,dc,Xm,jh,by,zh,yy,Xh,Ty,Qh,_y;const Ay=z.createElement("template");Ay.innerHTML=`
640
+ `;const Ht={TYPE:"type",VALUE:"value",CHECKED:"checked",DISABLED:"disabled"};class Oc extends k.HTMLElement{constructor(){super(),Hi(this,Hh),Hi(this,qm),Hi(this,Ym),Hi(this,Fn),Hi(this,Wh),Hi(this,Sl),Hi(this,Al,!1),Hi(this,$a,void 0),Hi(this,Mi,()=>{var e,t;this.setAttribute("submenusize",`${this.submenuElement.items.length}`);const s=this.shadowRoot.querySelector('slot[name="description"]'),r=(t=(e=this.submenuElement.checkedItems)==null?void 0:e[0])==null?void 0:t.text,n=z.createElement("span");n.textContent=r??"",s.replaceChildren(n)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0))),this.shadowRoot.addEventListener("slotchange",this)}static get observedAttributes(){return[Ht.TYPE,Ht.DISABLED,Ht.CHECKED,Ht.VALUE]}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex","-1"),jn(this)&&!this.hasAttribute("aria-checked")&&this.setAttribute("aria-checked","false"),this.addEventListener("click",this),this.addEventListener("keydown",this)}disable(){this.removeAttribute("tabindex"),this.removeEventListener("click",this),this.removeEventListener("keydown",this),this.removeEventListener("keyup",this)}handleEvent(e){switch(e.type){case"slotchange":Li(this,Hh,fy).call(this,e);break;case"click":this.handleClick(e);break;case"keydown":Li(this,Wh,gy).call(this,e);break;case"keyup":Li(this,Fn,io).call(this,e);break}}attributeChangedCallback(e,t,s){e===Ht.CHECKED&&jn(this)&&!Di(this,Al)?this.setAttribute("aria-checked",s!=null?"true":"false"):e===Ht.TYPE&&s!==t?this.role="menuitem"+s:e===Ht.DISABLED&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(Ht.DISABLED)||this.enable(),this.role="menuitem"+this.type,_u(this,$a,Vh(this,this.parentNode)),Li(this,Sl,Kh).call(this)}disconnectedCallback(){this.disable(),Li(this,Sl,Kh).call(this),_u(this,$a,null)}get invokeTarget(){return this.getAttribute("invoketarget")}set invokeTarget(e){this.setAttribute("invoketarget",`${e}`)}get invokeTargetElement(){var e;return this.invokeTarget?(e=wc(this))==null?void 0:e.querySelector(`#${this.invokeTarget}`):this.submenuElement}get submenuElement(){return this.shadowRoot.querySelector('slot[name="submenu"]').assignedElements({flatten:!0})[0]}get type(){var e;return(e=this.getAttribute(Ht.TYPE))!=null?e:""}set type(e){this.setAttribute(Ht.TYPE,`${e}`)}get value(){var e;return(e=this.getAttribute(Ht.VALUE))!=null?e:this.text}set value(e){this.setAttribute(Ht.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get checked(){if(jn(this))return this.getAttribute("aria-checked")==="true"}set checked(e){jn(this)&&(_u(this,Al,!0),this.setAttribute("aria-checked",e?"true":"false"),e?this.part.add("checked"):this.part.remove("checked"))}handleClick(e){jn(this)||this.invokeTargetElement&&Ni(this,e.target)&&this.invokeTargetElement.dispatchEvent(new Um({relatedTarget:this}))}get keysUsed(){return["Enter"," "]}}Al=new WeakMap;$a=new WeakMap;Hh=new WeakSet;fy=function(i){const e=i.target;if(!(e!=null&&e.name))for(let s of e.assignedNodes({flatten:!0}))s instanceof Text&&s.textContent.trim()===""&&s.remove();e.name==="submenu"&&(this.submenuElement?Li(this,qm,my).call(this):Li(this,Ym,py).call(this))};qm=new WeakSet;my=async function(){this.setAttribute("aria-haspopup","menu"),this.setAttribute("aria-expanded",`${!this.submenuElement.hidden}`),this.submenuElement.addEventListener("change",Di(this,Mi)),this.submenuElement.addEventListener("addmenuitem",Di(this,Mi)),this.submenuElement.addEventListener("removemenuitem",Di(this,Mi)),Di(this,Mi).call(this)};Ym=new WeakSet;py=function(){this.removeAttribute("aria-haspopup"),this.removeAttribute("aria-expanded"),this.submenuElement.removeEventListener("change",Di(this,Mi)),this.submenuElement.removeEventListener("addmenuitem",Di(this,Mi)),this.submenuElement.removeEventListener("removemenuitem",Di(this,Mi)),Di(this,Mi).call(this)};Mi=new WeakMap;Fn=new WeakSet;io=function(i){const{key:e}=i;if(!this.keysUsed.includes(e)){this.removeEventListener("keyup",Li(this,Fn,io));return}this.handleClick(i)};Wh=new WeakSet;gy=function(i){const{metaKey:e,altKey:t,key:s}=i;if(e||t||!this.keysUsed.includes(s)){this.removeEventListener("keyup",Li(this,Fn,io));return}this.addEventListener("keyup",Li(this,Fn,io),{once:!0})};Sl=new WeakSet;Kh=function(){var i;const e=(i=Di(this,$a))==null?void 0:i.radioGroupItems;if(!e)return;let t=e.filter(s=>s.getAttribute("aria-checked")==="true").pop();t||(t=e[0]);for(const s of e)s.setAttribute("aria-checked","false");t==null||t.setAttribute("aria-checked","true")};yw(Oc,"template",vy);function jn(i){return i.type==="radio"||i.type==="checkbox"}function Vh(i,e){if(!i)return null;const{host:t}=i.getRootNode();return!e&&t?Vh(i,t):e!=null&&e.items?e:Vh(e,e==null?void 0:e.parentNode)}k.customElements.get("media-chrome-menu-item")||k.customElements.define("media-chrome-menu-item",Oc);var jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},De=(i,e,t)=>(jm(i,e,"read from private field"),t?t.call(i):e.get(i)),ut=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ls=(i,e,t,s)=>(jm(i,e,"write to private field"),e.set(i,t),t),Qt=(i,e,t)=>(jm(i,e,"access private method"),t),pi,Pc,xl,kl,Zt,lc,Ll,Il,Rl,zm,Ey,wl,qh,Cl,Yh,dc,Xm,jh,by,zh,yy,Xh,Ty,Qh,_y;const Ay=z.createElement("template");Ay.innerHTML=`
641
641
  <style>
642
642
  :host {
643
643
  --_focus-box-shadow: var(--media-focus-box-shadow, inset 0 0 0 2px rgb(27 127 204 / .9));
@@ -873,7 +873,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
873
873
  <input id="range" type="range" min="0" max="1" step="any" value="0">
874
874
  </div>
875
875
  <div id="rightgap"></div>
876
- `;class Qm extends k.HTMLElement{constructor(){super(),ut(this,zm),ut(this,wl),ut(this,Cl),ut(this,dc),ut(this,jh),ut(this,zh),ut(this,Xh),ut(this,Qh),ut(this,pi,void 0),ut(this,Pc,void 0),ut(this,xl,void 0),ut(this,kl,void 0),ut(this,Zt,{}),ut(this,lc,[]),ut(this,Ll,()=>{if(this.range.matches(":focus-visible")){const{style:e}=Ge(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),ut(this,Il,()=>{const{style:e}=Ge(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),ut(this,Rl,()=>{const e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ay.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),ls(this,xl,this.shadowRoot.querySelector("#startpoint")),ls(this,kl,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(r=De(this,pi))==null?void 0:r.unassociateElement)==null||n.call(r,this),ls(this,pi,null)),s&&this.isConnected&&(ls(this,pi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=De(this,pi))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==s)&&(s==null?(this.range.removeAttribute(e),Qt(this,wl,qh).call(this)):(this.range.setAttribute(e,s),Qt(this,Cl,Yh).call(this)))}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),De(this,Zt).pointer=Ge(this.shadowRoot,"#pointer"),De(this,Zt).progress=Ge(this.shadowRoot,"#progress"),De(this,Zt).thumb=Ge(this.shadowRoot,"#thumb");const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(ls(this,pi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=De(this,pi))==null?void 0:t.associateElement)==null||s.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",De(this,Ll)),this.shadowRoot.addEventListener("focusout",De(this,Il)),Qt(this,wl,qh).call(this),xs(this.container,De(this,Rl))}disconnectedCallback(){var e,t;Qt(this,Cl,Yh).call(this),(t=(e=De(this,pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),ls(this,pi,null),this.shadowRoot.removeEventListener("focusin",De(this,Ll)),this.shadowRoot.removeEventListener("focusout",De(this,Il)),Ar(this.container,De(this,Rl))}updatePointerBar(e){var t;(t=De(this,Zt).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;const s=this.range.valueAsNumber*100;(e=De(this,Zt).progress)==null||e.style.setProperty("width",`${s}%`),(t=De(this,Zt).thumb)==null||t.style.setProperty("left",`${s}%`)}updateSegments(e){const t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;De(this,Zt).activeSegment=mb(this.shadowRoot,"#segments-clipping rect:nth-child(0)");const s=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];ls(this,lc,[...s]);const r=s.pop();for(const[n,a]of s.entries()){const[o,l]=[n===0,n===s.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((l?r:s[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=z.createElementNS("http://www.w3.org/2000/svg","rect"),f=Ge(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",u),t.append(h)}}getPointerRatio(e){let t=ZI(e.clientX,e.clientY,De(this,xl).getBoundingClientRect(),De(this,kl).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Qt(this,Qh,_y).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Qt(this,jh,by).call(this,e);break;case"pointerdown":Qt(this,dc,Xm).call(this,e);break;case"pointerup":Qt(this,zh,yy).call(this);break;case"pointerleave":Qt(this,Xh,Ty).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}pi=new WeakMap;Pc=new WeakMap;xl=new WeakMap;kl=new WeakMap;Zt=new WeakMap;lc=new WeakMap;Ll=new WeakMap;Il=new WeakMap;Rl=new WeakMap;zm=new WeakSet;Ey=function(i){const e=De(this,Zt).activeSegment;if(!e)return;const t=this.getPointerRatio(i),r=`#segments-clipping rect:nth-child(${De(this,lc).findIndex((n,a,o)=>{const l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=r||!e.style.transform)&&(e.selectorText=r,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};wl=new WeakSet;qh=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};Cl=new WeakSet;Yh=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=k.window)==null||i.removeEventListener("pointerup",this),(e=k.window)==null||e.removeEventListener("pointermove",this)};dc=new WeakSet;Xm=function(i){var e;ls(this,Pc,i.composedPath().includes(this.range)),(e=k.window)==null||e.addEventListener("pointerup",this)};jh=new WeakSet;by=function(i){var e;i.pointerType!=="mouse"&&Qt(this,dc,Xm).call(this,i),this.addEventListener("pointerleave",this),(e=k.window)==null||e.addEventListener("pointermove",this)};zh=new WeakSet;yy=function(){var i;(i=k.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Xh=new WeakSet;Ty=function(){var i,e;this.removeEventListener("pointerleave",this),(i=k.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=De(this,Zt).activeSegment)==null||e.style.removeProperty("transform")};Qh=new WeakSet;_y=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),Qt(this,zm,Ey).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!De(this,Pc))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};k.customElements.get("media-chrome-range")||k.customElements.define("media-chrome-range",Qm);var Sy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Uo=(i,e,t)=>(Sy(i,e,"read from private field"),t?t.call(i):e.get(i)),yw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Fo=(i,e,t,s)=>(Sy(i,e,"write to private field"),e.set(i,t),t),gi;const xy=z.createElement("template");xy.innerHTML=`
876
+ `;class Qm extends k.HTMLElement{constructor(){super(),ut(this,zm),ut(this,wl),ut(this,Cl),ut(this,dc),ut(this,jh),ut(this,zh),ut(this,Xh),ut(this,Qh),ut(this,pi,void 0),ut(this,Pc,void 0),ut(this,xl,void 0),ut(this,kl,void 0),ut(this,Zt,{}),ut(this,lc,[]),ut(this,Ll,()=>{if(this.range.matches(":focus-visible")){const{style:e}=Ge(this.shadowRoot,":host");e.setProperty("--_focus-visible-box-shadow","var(--_focus-box-shadow)")}}),ut(this,Il,()=>{const{style:e}=Ge(this.shadowRoot,":host");e.removeProperty("--_focus-visible-box-shadow")}),ut(this,Rl,()=>{const e=this.shadowRoot.querySelector("#segments-clipping");e&&e.parentNode.append(e)}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ay.content.cloneNode(!0))),this.container=this.shadowRoot.querySelector("#container"),ls(this,xl,this.shadowRoot.querySelector("#startpoint")),ls(this,kl,this.shadowRoot.querySelector("#endpoint")),this.range=this.shadowRoot.querySelector("#range"),this.appearance=this.shadowRoot.querySelector("#appearance")}static get observedAttributes(){return["disabled","aria-disabled",ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(r=De(this,pi))==null?void 0:r.unassociateElement)==null||n.call(r,this),ls(this,pi,null)),s&&this.isConnected&&(ls(this,pi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=De(this,pi))==null?void 0:o.associateElement)==null||l.call(o,this))):(e==="disabled"||e==="aria-disabled"&&t!==s)&&(s==null?(this.range.removeAttribute(e),Qt(this,wl,qh).call(this)):(this.range.setAttribute(e,s),Qt(this,Cl,Yh).call(this)))}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`),De(this,Zt).pointer=Ge(this.shadowRoot,"#pointer"),De(this,Zt).progress=Ge(this.shadowRoot,"#progress"),De(this,Zt).thumb=Ge(this.shadowRoot,"#thumb");const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(ls(this,pi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=De(this,pi))==null?void 0:t.associateElement)==null||s.call(t,this)),this.updateBar(),this.shadowRoot.addEventListener("focusin",De(this,Ll)),this.shadowRoot.addEventListener("focusout",De(this,Il)),Qt(this,wl,qh).call(this),xs(this.container,De(this,Rl))}disconnectedCallback(){var e,t;Qt(this,Cl,Yh).call(this),(t=(e=De(this,pi))==null?void 0:e.unassociateElement)==null||t.call(e,this),ls(this,pi,null),this.shadowRoot.removeEventListener("focusin",De(this,Ll)),this.shadowRoot.removeEventListener("focusout",De(this,Il)),Ar(this.container,De(this,Rl))}updatePointerBar(e){var t;(t=De(this,Zt).pointer)==null||t.style.setProperty("width",`${this.getPointerRatio(e)*100}%`)}updateBar(){var e,t;const s=this.range.valueAsNumber*100;(e=De(this,Zt).progress)==null||e.style.setProperty("width",`${s}%`),(t=De(this,Zt).thumb)==null||t.style.setProperty("left",`${s}%`)}updateSegments(e){const t=this.shadowRoot.querySelector("#segments-clipping");if(t.textContent="",this.container.classList.toggle("segments",!!(e!=null&&e.length)),!(e!=null&&e.length))return;De(this,Zt).activeSegment=mb(this.shadowRoot,"#segments-clipping rect:nth-child(0)");const s=[...new Set([+this.range.min,...e.flatMap(n=>[n.start,n.end]),+this.range.max])];ls(this,lc,[...s]);const r=s.pop();for(const[n,a]of s.entries()){const[o,l]=[n===0,n===s.length-1],d=o?"calc(var(--segments-gap) / -1)":`${a*100}%`,u=`calc(${((l?r:s[n+1])-a)*100}%${o||l?"":" - var(--segments-gap)"})`,h=z.createElementNS("http://www.w3.org/2000/svg","rect"),f=Ge(this.shadowRoot,`#segments-clipping rect:nth-child(${n+1})`);f.style.setProperty("x",d),f.style.setProperty("width",u),t.append(h)}}getPointerRatio(e){let t=JI(e.clientX,e.clientY,De(this,xl).getBoundingClientRect(),De(this,kl).getBoundingClientRect());return Math.max(0,Math.min(1,t))}get dragging(){return this.hasAttribute("dragging")}handleEvent(e){switch(e.type){case"pointermove":Qt(this,Qh,_y).call(this,e);break;case"input":this.updateBar();break;case"pointerenter":Qt(this,jh,by).call(this,e);break;case"pointerdown":Qt(this,dc,Xm).call(this,e);break;case"pointerup":Qt(this,zh,yy).call(this);break;case"pointerleave":Qt(this,Xh,Ty).call(this);break}}get keysUsed(){return["ArrowUp","ArrowRight","ArrowDown","ArrowLeft"]}}pi=new WeakMap;Pc=new WeakMap;xl=new WeakMap;kl=new WeakMap;Zt=new WeakMap;lc=new WeakMap;Ll=new WeakMap;Il=new WeakMap;Rl=new WeakMap;zm=new WeakSet;Ey=function(i){const e=De(this,Zt).activeSegment;if(!e)return;const t=this.getPointerRatio(i),r=`#segments-clipping rect:nth-child(${De(this,lc).findIndex((n,a,o)=>{const l=o[a+1];return l!=null&&t>=n&&t<=l})+1})`;(e.selectorText!=r||!e.style.transform)&&(e.selectorText=r,e.style.setProperty("transform","var(--media-range-segment-hover-transform, scaleY(2))"))};wl=new WeakSet;qh=function(){this.hasAttribute("disabled")||(this.addEventListener("input",this),this.addEventListener("pointerdown",this),this.addEventListener("pointerenter",this))};Cl=new WeakSet;Yh=function(){var i,e;this.removeEventListener("input",this),this.removeEventListener("pointerdown",this),this.removeEventListener("pointerenter",this),(i=k.window)==null||i.removeEventListener("pointerup",this),(e=k.window)==null||e.removeEventListener("pointermove",this)};dc=new WeakSet;Xm=function(i){var e;ls(this,Pc,i.composedPath().includes(this.range)),(e=k.window)==null||e.addEventListener("pointerup",this)};jh=new WeakSet;by=function(i){var e;i.pointerType!=="mouse"&&Qt(this,dc,Xm).call(this,i),this.addEventListener("pointerleave",this),(e=k.window)==null||e.addEventListener("pointermove",this)};zh=new WeakSet;yy=function(){var i;(i=k.window)==null||i.removeEventListener("pointerup",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled")};Xh=new WeakSet;Ty=function(){var i,e;this.removeEventListener("pointerleave",this),(i=k.window)==null||i.removeEventListener("pointermove",this),this.toggleAttribute("dragging",!1),this.range.disabled=this.hasAttribute("disabled"),(e=De(this,Zt).activeSegment)==null||e.style.removeProperty("transform")};Qh=new WeakSet;_y=function(i){this.toggleAttribute("dragging",i.buttons===1||i.pointerType!=="mouse"),this.updatePointerBar(i),Qt(this,zm,Ey).call(this,i),this.dragging&&(i.pointerType!=="mouse"||!De(this,Pc))&&(this.range.disabled=!0,this.range.valueAsNumber=this.getPointerRatio(i),this.range.dispatchEvent(new Event("input",{bubbles:!0,composed:!0})))};k.customElements.get("media-chrome-range")||k.customElements.define("media-chrome-range",Qm);var Sy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Uo=(i,e,t)=>(Sy(i,e,"read from private field"),t?t.call(i):e.get(i)),Tw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Fo=(i,e,t,s)=>(Sy(i,e,"write to private field"),e.set(i,t),t),gi;const xy=z.createElement("template");xy.innerHTML=`
877
877
  <style>
878
878
  :host {
879
879
 
@@ -895,7 +895,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
895
895
  </style>
896
896
 
897
897
  <slot></slot>
898
- `;class Tw extends k.HTMLElement{constructor(){super(),yw(this,gi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(xy.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=Uo(this,gi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Fo(this,gi,null)),s&&this.isConnected&&(Fo(this,gi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=Uo(this,gi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s;const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(Fo(this,gi,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=Uo(this,gi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Uo(this,gi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Fo(this,gi,null)}}gi=new WeakMap;k.customElements.get("media-control-bar")||k.customElements.define("media-control-bar",Tw);var ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$o=(i,e,t)=>(ky(i,e,"read from private field"),t?t.call(i):e.get(i)),_w=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Bo=(i,e,t,s)=>(ky(i,e,"write to private field"),e.set(i,t),t),vi;const Ly=z.createElement("template");Ly.innerHTML=`
898
+ `;class _w extends k.HTMLElement{constructor(){super(),Tw(this,gi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(xy.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=Uo(this,gi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Fo(this,gi,null)),s&&this.isConnected&&(Fo(this,gi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=Uo(this,gi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s;const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(Fo(this,gi,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=Uo(this,gi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Uo(this,gi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Fo(this,gi,null)}}gi=new WeakMap;k.customElements.get("media-control-bar")||k.customElements.define("media-control-bar",_w);var ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},$o=(i,e,t)=>(ky(i,e,"read from private field"),t?t.call(i):e.get(i)),Aw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Bo=(i,e,t,s)=>(ky(i,e,"write to private field"),e.set(i,t),t),vi;const Ly=z.createElement("template");Ly.innerHTML=`
899
899
  <style>
900
900
  :host {
901
901
  font: var(--media-font,
@@ -928,9 +928,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
928
928
  }
929
929
  </style>
930
930
  <slot></slot>
931
- `;class fo extends k.HTMLElement{constructor(){super(),_w(this,vi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ly.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=$o(this,vi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Bo(this,vi,null)),s&&this.isConnected&&(Bo(this,vi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=$o(this,vi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(Bo(this,vi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=$o(this,vi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=$o(this,vi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Bo(this,vi,null)}}vi=new WeakMap;k.customElements.get("media-text-display")||k.customElements.define("media-text-display",fo);var Aw=fo,Iy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fg=(i,e,t)=>(Iy(i,e,"read from private field"),t?t.call(i):e.get(i)),Sw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},xw=(i,e,t,s)=>(Iy(i,e,"write to private field"),e.set(i,t),t),ca;class kw extends fo{constructor(){super(),Sw(this,ca,void 0),xw(this,ca,this.shadowRoot.querySelector("slot")),fg(this,ca).textContent=hr(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,s){e===T.MEDIA_DURATION&&(fg(this,ca).textContent=hr(+s)),super.attributeChangedCallback(e,t,s)}get mediaDuration(){return $e(this,T.MEDIA_DURATION)}set mediaDuration(e){nt(this,T.MEDIA_DURATION,e)}}ca=new WeakMap;k.customElements.get("media-duration-display")||k.customElements.define("media-duration-display",kw);const Lw=`<svg aria-hidden="true" viewBox="0 0 26 24">
931
+ `;class fo extends k.HTMLElement{constructor(){super(),Aw(this,vi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Ly.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=$o(this,vi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Bo(this,vi,null)),s&&this.isConnected&&(Bo(this,vi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=$o(this,vi))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(Bo(this,vi,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=$o(this,vi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=$o(this,vi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Bo(this,vi,null)}}vi=new WeakMap;k.customElements.get("media-text-display")||k.customElements.define("media-text-display",fo);var Sw=fo,Iy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},fg=(i,e,t)=>(Iy(i,e,"read from private field"),t?t.call(i):e.get(i)),xw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},kw=(i,e,t,s)=>(Iy(i,e,"write to private field"),e.set(i,t),t),ca;class Lw extends fo{constructor(){super(),xw(this,ca,void 0),kw(this,ca,this.shadowRoot.querySelector("slot")),fg(this,ca).textContent=hr(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_DURATION]}attributeChangedCallback(e,t,s){e===T.MEDIA_DURATION&&(fg(this,ca).textContent=hr(+s)),super.attributeChangedCallback(e,t,s)}get mediaDuration(){return $e(this,T.MEDIA_DURATION)}set mediaDuration(e){nt(this,T.MEDIA_DURATION,e)}}ca=new WeakMap;k.customElements.get("media-duration-display")||k.customElements.define("media-duration-display",Lw);const Iw=`<svg aria-hidden="true" viewBox="0 0 26 24">
932
932
  <path d="M16 3v2.5h3.5V9H22V3h-6ZM4 9h2.5V5.5H10V3H4v6Zm15.5 9.5H16V21h6v-6h-2.5v3.5ZM6.5 15H4v6h6v-2.5H6.5V15Z"/>
933
- </svg>`,Iw=`<svg aria-hidden="true" viewBox="0 0 26 24">
933
+ </svg>`,Rw=`<svg aria-hidden="true" viewBox="0 0 26 24">
934
934
  <path d="M18.5 6.5V3H16v6h6V6.5h-3.5ZM16 21h2.5v-3.5H22V15h-6v6ZM4 17.5h3.5V21H10v-6H4v2.5Zm3.5-11H4V9h6V3H7.5v3.5Z"/>
935
935
  </svg>`,Ry=z.createElement("template");Ry.innerHTML=`
936
936
  <style>
@@ -945,10 +945,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
945
945
  </style>
946
946
 
947
947
  <slot name="icon">
948
- <slot name="enter">${Lw}</slot>
949
- <slot name="exit">${Iw}</slot>
948
+ <slot name="enter">${Iw}</slot>
949
+ <slot name="exit">${Rw}</slot>
950
950
  </slot>
951
- `;const mg=i=>{const e=i.mediaIsFullscreen?At.EXIT_FULLSCREEN():At.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)};class Rw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ry,...e})}connectedCallback(){super.connectedCallback(),mg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_IS_FULLSCREEN&&mg(this)}get mediaFullscreenUnavailable(){return Ve(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){qe(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return at(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){ot(this,T.MEDIA_IS_FULLSCREEN,e)}handleClick(){const e=this.mediaIsFullscreen?K.MEDIA_EXIT_FULLSCREEN_REQUEST:K.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-fullscreen-button")||k.customElements.define("media-fullscreen-button",Rw);const{MEDIA_TIME_IS_LIVE:Dl,MEDIA_PAUSED:Ba}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:ww,MEDIA_PLAY_REQUEST:Cw}=K,Dw='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',wy=z.createElement("template");wy.innerHTML=`
951
+ `;const mg=i=>{const e=i.mediaIsFullscreen?At.EXIT_FULLSCREEN():At.ENTER_FULLSCREEN();i.setAttribute("aria-label",e)};class ww extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_FULLSCREEN,T.MEDIA_FULLSCREEN_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Ry,...e})}connectedCallback(){super.connectedCallback(),mg(this)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_IS_FULLSCREEN&&mg(this)}get mediaFullscreenUnavailable(){return Ve(this,T.MEDIA_FULLSCREEN_UNAVAILABLE)}set mediaFullscreenUnavailable(e){qe(this,T.MEDIA_FULLSCREEN_UNAVAILABLE,e)}get mediaIsFullscreen(){return at(this,T.MEDIA_IS_FULLSCREEN)}set mediaIsFullscreen(e){ot(this,T.MEDIA_IS_FULLSCREEN,e)}handleClick(){const e=this.mediaIsFullscreen?K.MEDIA_EXIT_FULLSCREEN_REQUEST:K.MEDIA_ENTER_FULLSCREEN_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-fullscreen-button")||k.customElements.define("media-fullscreen-button",ww);const{MEDIA_TIME_IS_LIVE:Dl,MEDIA_PAUSED:Ba}=T,{MEDIA_SEEK_TO_LIVE_REQUEST:Cw,MEDIA_PLAY_REQUEST:Dw}=K,Mw='<svg viewBox="0 0 6 12"><circle cx="3" cy="6" r="2"></circle></svg>',wy=z.createElement("template");wy.innerHTML=`
952
952
  <style>
953
953
 
954
954
  slot[name=indicator] > *,
@@ -971,10 +971,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
971
971
 
972
972
  </style>
973
973
 
974
- <slot name="indicator">${Dw}</slot>
974
+ <slot name="indicator">${Mw}</slot>
975
975
 
976
976
  <slot name="spacer">&nbsp;</slot><slot name="text">LIVE</slot>
977
- `;const pg=i=>{const e=i.mediaPaused||!i.mediaTimeIsLive,t=e?At.SEEK_LIVE():At.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")};class Mw extends xt{static get observedAttributes(){return[...super.observedAttributes,Ba,Dl]}constructor(e={}){super({slotTemplate:wy,...e})}connectedCallback(){pg(this),super.connectedCallback()}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),pg(this)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return at(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){ot(this,T.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new k.CustomEvent(ww,{composed:!0,bubbles:!0})),this.hasAttribute(Ba)&&this.dispatchEvent(new k.CustomEvent(Cw,{composed:!0,bubbles:!0})))}}k.customElements.get("media-live-button")||k.customElements.define("media-live-button",Mw);var Cy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zn=(i,e,t)=>(Cy(i,e,"read from private field"),t?t.call(i):e.get(i)),gg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xn=(i,e,t,s)=>(Cy(i,e,"write to private field"),e.set(i,t),t),Ei,Ml;const vg={LOADING_DELAY:"loadingdelay"},Dy=500,My=z.createElement("template"),Ow=`
977
+ `;const pg=i=>{const e=i.mediaPaused||!i.mediaTimeIsLive,t=e?At.SEEK_LIVE():At.PLAYING_LIVE();i.setAttribute("aria-label",t),e?i.removeAttribute("aria-disabled"):i.setAttribute("aria-disabled","true")};class Ow extends xt{static get observedAttributes(){return[...super.observedAttributes,Ba,Dl]}constructor(e={}){super({slotTemplate:wy,...e})}connectedCallback(){pg(this),super.connectedCallback()}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),pg(this)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaTimeIsLive(){return at(this,T.MEDIA_TIME_IS_LIVE)}set mediaTimeIsLive(e){ot(this,T.MEDIA_TIME_IS_LIVE,e)}handleClick(){!this.mediaPaused&&this.mediaTimeIsLive||(this.dispatchEvent(new k.CustomEvent(Cw,{composed:!0,bubbles:!0})),this.hasAttribute(Ba)&&this.dispatchEvent(new k.CustomEvent(Dw,{composed:!0,bubbles:!0})))}}k.customElements.get("media-live-button")||k.customElements.define("media-live-button",Ow);var Cy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zn=(i,e,t)=>(Cy(i,e,"read from private field"),t?t.call(i):e.get(i)),gg=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Xn=(i,e,t,s)=>(Cy(i,e,"write to private field"),e.set(i,t),t),Ei,Ml;const vg={LOADING_DELAY:"loadingdelay"},Dy=500,My=z.createElement("template"),Pw=`
978
978
  <svg aria-hidden="true" viewBox="0 0 100 100">
979
979
  <path d="M73,50c0-12.7-10.3-23-23-23S27,37.3,27,50 M30.9,50c0-10.5,8.5-19.1,19.1-19.1S69.1,39.5,69.1,50">
980
980
  <animateTransform
@@ -1032,13 +1032,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
1032
1032
  }
1033
1033
  </style>
1034
1034
 
1035
- <slot name="icon">${Ow}</slot>
1035
+ <slot name="icon">${Pw}</slot>
1036
1036
  <div id="status" role="status" aria-live="polite">${Ut.MEDIA_LOADING()}</div>
1037
- `;class Pw extends k.HTMLElement{constructor(){if(super(),gg(this,Ei,void 0),gg(this,Ml,Dy),!this.shadowRoot){const e=this.attachShadow({mode:"open"}),t=My.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,T.MEDIA_PAUSED,T.MEDIA_LOADING,vg.LOADING_DELAY]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===vg.LOADING_DELAY&&t!==s?this.loadingDelay=Number(s):e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=zn(this,Ei))==null?void 0:r.unassociateElement)==null||n.call(r,this),Xn(this,Ei,null)),s&&this.isConnected&&(Xn(this,Ei,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=zn(this,Ei))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s;const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(Xn(this,Ei,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=zn(this,Ei))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=zn(this,Ei))==null?void 0:e.unassociateElement)==null||t.call(e,this),Xn(this,Ei,null)}get loadingDelay(){return zn(this,Ml)}set loadingDelay(e){Xn(this,Ml,e);const{style:t}=Ge(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}}Ei=new WeakMap;Ml=new WeakMap;k.customElements.get("media-loading-indicator")||k.customElements.define("media-loading-indicator",Pw);const{MEDIA_VOLUME_LEVEL:Qn}=T,Nw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1037
+ `;class Nw extends k.HTMLElement{constructor(){if(super(),gg(this,Ei,void 0),gg(this,Ml,Dy),!this.shadowRoot){const e=this.attachShadow({mode:"open"}),t=My.content.cloneNode(!0);e.appendChild(t)}}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,T.MEDIA_PAUSED,T.MEDIA_LOADING,vg.LOADING_DELAY]}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===vg.LOADING_DELAY&&t!==s?this.loadingDelay=Number(s):e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=zn(this,Ei))==null?void 0:r.unassociateElement)==null||n.call(r,this),Xn(this,Ei,null)),s&&this.isConnected&&(Xn(this,Ei,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=zn(this,Ei))==null?void 0:o.associateElement)==null||l.call(o,this)))}connectedCallback(){var e,t,s;const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(Xn(this,Ei,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=zn(this,Ei))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=zn(this,Ei))==null?void 0:e.unassociateElement)==null||t.call(e,this),Xn(this,Ei,null)}get loadingDelay(){return zn(this,Ml)}set loadingDelay(e){Xn(this,Ml,e);const{style:t}=Ge(this.shadowRoot,":host");t.setProperty("--_loading-indicator-delay",`var(--media-loading-indicator-transition-delay, ${e}ms)`)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}}Ei=new WeakMap;Ml=new WeakMap;k.customElements.get("media-loading-indicator")||k.customElements.define("media-loading-indicator",Nw);const{MEDIA_VOLUME_LEVEL:Qn}=T,Uw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1038
1038
  <path d="M16.5 12A4.5 4.5 0 0 0 14 8v2.18l2.45 2.45a4.22 4.22 0 0 0 .05-.63Zm2.5 0a6.84 6.84 0 0 1-.54 2.64L20 16.15A8.8 8.8 0 0 0 21 12a9 9 0 0 0-7-8.77v2.06A7 7 0 0 1 19 12ZM4.27 3 3 4.27 7.73 9H3v6h4l5 5v-6.73l4.25 4.25A6.92 6.92 0 0 1 14 18.7v2.06A9 9 0 0 0 17.69 19l2 2.05L21 19.73l-9-9L4.27 3ZM12 4 9.91 6.09 12 8.18V4Z"/>
1039
1039
  </svg>`,Eg=`<svg aria-hidden="true" viewBox="0 0 24 24">
1040
1040
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4Z"/>
1041
- </svg>`,Uw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1041
+ </svg>`,Fw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1042
1042
  <path d="M3 9v6h4l5 5V4L7 9H3Zm13.5 3A4.5 4.5 0 0 0 14 8v8a4.47 4.47 0 0 0 2.5-4ZM14 3.23v2.06a7 7 0 0 1 0 13.42v2.06a9 9 0 0 0 0-17.54Z"/>
1043
1043
  </svg>`,Oy=z.createElement("template");Oy.innerHTML=`
1044
1044
  <style>
@@ -1062,12 +1062,12 @@ svg, img, ::slotted(svg), ::slotted(img) {
1062
1062
  </style>
1063
1063
 
1064
1064
  <slot name="icon">
1065
- <slot name="off">${Nw}</slot>
1065
+ <slot name="off">${Uw}</slot>
1066
1066
  <slot name="low">${Eg}</slot>
1067
1067
  <slot name="medium">${Eg}</slot>
1068
- <slot name="high">${Uw}</slot>
1068
+ <slot name="high">${Fw}</slot>
1069
1069
  </slot>
1070
- `;const bg=i=>{const t=i.mediaVolumeLevel==="off"?At.UNMUTE():At.MUTE();i.setAttribute("aria-label",t)};class Fw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Oy,...e})}connectedCallback(){bg(this),super.connectedCallback()}attributeChangedCallback(e,t,s){e===T.MEDIA_VOLUME_LEVEL&&bg(this),super.attributeChangedCallback(e,t,s)}get mediaVolumeLevel(){return Ve(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){qe(this,T.MEDIA_VOLUME_LEVEL,e)}handleClick(){const e=this.mediaVolumeLevel==="off"?K.MEDIA_UNMUTE_REQUEST:K.MEDIA_MUTE_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-mute-button")||k.customElements.define("media-mute-button",Fw);const yg=`<svg aria-hidden="true" viewBox="0 0 28 24">
1070
+ `;const bg=i=>{const t=i.mediaVolumeLevel==="off"?At.UNMUTE():At.MUTE();i.setAttribute("aria-label",t)};class $w extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME_LEVEL]}constructor(e={}){super({slotTemplate:Oy,...e})}connectedCallback(){bg(this),super.connectedCallback()}attributeChangedCallback(e,t,s){e===T.MEDIA_VOLUME_LEVEL&&bg(this),super.attributeChangedCallback(e,t,s)}get mediaVolumeLevel(){return Ve(this,T.MEDIA_VOLUME_LEVEL)}set mediaVolumeLevel(e){qe(this,T.MEDIA_VOLUME_LEVEL,e)}handleClick(){const e=this.mediaVolumeLevel==="off"?K.MEDIA_UNMUTE_REQUEST:K.MEDIA_MUTE_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-mute-button")||k.customElements.define("media-mute-button",$w);const yg=`<svg aria-hidden="true" viewBox="0 0 28 24">
1071
1071
  <path d="M24 3H4a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h20a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1Zm-1 16H5V5h18v14Zm-3-8h-7v5h7v-5Z"/>
1072
1072
  </svg>`,Py=z.createElement("template");Py.innerHTML=`
1073
1073
  <style>
@@ -1085,7 +1085,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1085
1085
  <slot name="enter">${yg}</slot>
1086
1086
  <slot name="exit">${yg}</slot>
1087
1087
  </slot>
1088
- `;const Tg=i=>{const e=i.mediaIsPip?At.EXIT_PIP():At.ENTER_PIP();i.setAttribute("aria-label",e)};class $w extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Py,...e})}connectedCallback(){Tg(this),super.connectedCallback()}attributeChangedCallback(e,t,s){e===T.MEDIA_IS_PIP&&Tg(this),super.attributeChangedCallback(e,t,s)}get mediaPipUnavailable(){return Ve(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){qe(this,T.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return at(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){ot(this,T.MEDIA_IS_PIP,e)}handleClick(){const e=this.mediaIsPip?K.MEDIA_EXIT_PIP_REQUEST:K.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-pip-button")||k.customElements.define("media-pip-button",$w);var Bw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Go=(i,e,t)=>(Bw(i,e,"read from private field"),t?t.call(i):e.get(i)),Gw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Kr;const Au={RATES:"rates"},Zm=[1,1.2,1.5,1.7,2],mn=1,Ny=z.createElement("template");Ny.innerHTML=`
1088
+ `;const Tg=i=>{const e=i.mediaIsPip?At.EXIT_PIP():At.ENTER_PIP();i.setAttribute("aria-label",e)};class Bw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_IS_PIP,T.MEDIA_PIP_UNAVAILABLE]}constructor(e={}){super({slotTemplate:Py,...e})}connectedCallback(){Tg(this),super.connectedCallback()}attributeChangedCallback(e,t,s){e===T.MEDIA_IS_PIP&&Tg(this),super.attributeChangedCallback(e,t,s)}get mediaPipUnavailable(){return Ve(this,T.MEDIA_PIP_UNAVAILABLE)}set mediaPipUnavailable(e){qe(this,T.MEDIA_PIP_UNAVAILABLE,e)}get mediaIsPip(){return at(this,T.MEDIA_IS_PIP)}set mediaIsPip(e){ot(this,T.MEDIA_IS_PIP,e)}handleClick(){const e=this.mediaIsPip?K.MEDIA_EXIT_PIP_REQUEST:K.MEDIA_ENTER_PIP_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-pip-button")||k.customElements.define("media-pip-button",Bw);var Gw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Go=(i,e,t)=>(Gw(i,e,"read from private field"),t?t.call(i):e.get(i)),Hw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Kr;const Au={RATES:"rates"},Zm=[1,1.2,1.5,1.7,2],mn=1,Ny=z.createElement("template");Ny.innerHTML=`
1089
1089
  <style>
1090
1090
  :host {
1091
1091
  min-width: 5ch;
@@ -1093,7 +1093,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1093
1093
  }
1094
1094
  </style>
1095
1095
  <slot name="icon"></slot>
1096
- `;class Hw extends xt{constructor(e={}){super({slotTemplate:Ny,...e}),Gw(this,Kr,new uo(this,Au.RATES,{defaultValue:Zm})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${mn}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Au.RATES]}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback(e,t,s),e===Au.RATES&&(Go(this,Kr).value=s),e===T.MEDIA_PLAYBACK_RATE){const r=s?+s:Number.NaN,n=Number.isNaN(r)?mn:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Ut.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return Go(this,Kr)}set rates(e){e?Array.isArray(e)&&(Go(this,Kr).value=e.join(" ")):Go(this,Kr).value=""}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,mn)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;const s=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),r=(t=(e=s.find(a=>a>this.mediaPlaybackRate))!=null?e:s[0])!=null?t:mn,n=new k.CustomEvent(K.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(n)}}Kr=new WeakMap;k.customElements.get("media-playback-rate-button")||k.customElements.define("media-playback-rate-button",Hw);var Uy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ho=(i,e,t)=>(Uy(i,e,"read from private field"),t?t.call(i):e.get(i)),Su=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zn=(i,e,t)=>(Uy(i,e,"access private method"),t),Vr,ua,Ol,Pl,Zh;const xu={RATES:"rates"};class Ww extends es{constructor(){super(),Su(this,ua),Su(this,Pl),Su(this,Vr,new uo(this,xu.RATES,{defaultValue:Zm})),Zn(this,ua,Ol).call(this)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,xu.RATES]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PLAYBACK_RATE&&t!=s?this.value=s:e===xu.RATES&&t!=s&&(Ho(this,Vr).value=s,Zn(this,ua,Ol).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Zn(this,Pl,Zh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Zn(this,Pl,Zh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-playback-rate-menu-button")}get rates(){return Ho(this,Vr)}set rates(e){e?Array.isArray(e)&&(Ho(this,Vr).value=e.join(" ")):Ho(this,Vr).value="",Zn(this,ua,Ol).call(this)}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,mn)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}}Vr=new WeakMap;ua=new WeakSet;Ol=function(){this.defaultSlot.textContent="";for(const i of this.rates){const e=Un({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(e)}};Pl=new WeakSet;Zh=function(){if(!this.value)return;const i=new k.CustomEvent(K.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-playback-rate-menu")||k.customElements.define("media-playback-rate-menu",Ww);var Kw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wo=(i,e,t)=>(Kw(i,e,"read from private field"),t?t.call(i):e.get(i)),Vw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qr;const ku={RATES:"rates"},qw=[1,1.2,1.5,1.7,2],Lu=1,Fy=z.createElement("template");Fy.innerHTML=`
1096
+ `;class Ww extends xt{constructor(e={}){super({slotTemplate:Ny,...e}),Hw(this,Kr,new uo(this,Au.RATES,{defaultValue:Zm})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${mn}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,Au.RATES]}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback(e,t,s),e===Au.RATES&&(Go(this,Kr).value=s),e===T.MEDIA_PLAYBACK_RATE){const r=s?+s:Number.NaN,n=Number.isNaN(r)?mn:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Ut.PLAYBACK_RATE({playbackRate:n}))}}get rates(){return Go(this,Kr)}set rates(e){e?Array.isArray(e)&&(Go(this,Kr).value=e.join(" ")):Go(this,Kr).value=""}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,mn)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}handleClick(){var e,t;const s=Array.from(this.rates.values(),a=>+a).sort((a,o)=>a-o),r=(t=(e=s.find(a=>a>this.mediaPlaybackRate))!=null?e:s[0])!=null?t:mn,n=new k.CustomEvent(K.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:r});this.dispatchEvent(n)}}Kr=new WeakMap;k.customElements.get("media-playback-rate-button")||k.customElements.define("media-playback-rate-button",Ww);var Uy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ho=(i,e,t)=>(Uy(i,e,"read from private field"),t?t.call(i):e.get(i)),Su=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zn=(i,e,t)=>(Uy(i,e,"access private method"),t),Vr,ua,Ol,Pl,Zh;const xu={RATES:"rates"};class Kw extends es{constructor(){super(),Su(this,ua),Su(this,Pl),Su(this,Vr,new uo(this,xu.RATES,{defaultValue:Zm})),Zn(this,ua,Ol).call(this)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,xu.RATES]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PLAYBACK_RATE&&t!=s?this.value=s:e===xu.RATES&&t!=s&&(Ho(this,Vr).value=s,Zn(this,ua,Ol).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Zn(this,Pl,Zh))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Zn(this,Pl,Zh))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-playback-rate-menu-button")}get rates(){return Ho(this,Vr)}set rates(e){e?Array.isArray(e)&&(Ho(this,Vr).value=e.join(" ")):Ho(this,Vr).value="",Zn(this,ua,Ol).call(this)}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,mn)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}}Vr=new WeakMap;ua=new WeakSet;Ol=function(){this.defaultSlot.textContent="";for(const i of this.rates){const e=Un({type:"radio",text:this.formatMenuItemText(`${i}x`,i),value:i,checked:this.mediaPlaybackRate==i});e.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(e)}};Pl=new WeakSet;Zh=function(){if(!this.value)return;const i=new k.CustomEvent(K.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-playback-rate-menu")||k.customElements.define("media-playback-rate-menu",Kw);var Vw=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wo=(i,e,t)=>(Vw(i,e,"read from private field"),t?t.call(i):e.get(i)),qw=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},qr;const ku={RATES:"rates"},Yw=[1,1.2,1.5,1.7,2],Lu=1,Fy=z.createElement("template");Fy.innerHTML=`
1097
1097
  <style>
1098
1098
  :host {
1099
1099
  min-width: 5ch;
@@ -1101,9 +1101,9 @@ svg, img, ::slotted(svg), ::slotted(img) {
1101
1101
  }
1102
1102
  </style>
1103
1103
  <slot name="icon"></slot>
1104
- `;class Yw extends Bn{constructor(e={}){super({slotTemplate:Fy,...e}),Vw(this,qr,new uo(this,ku.RATES,{defaultValue:qw})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Lu}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,ku.RATES]}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback(e,t,s),e===ku.RATES&&(Wo(this,qr).value=s),e===T.MEDIA_PLAYBACK_RATE){const r=s?+s:Number.NaN,n=Number.isNaN(r)?Lu:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Ut.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-playback-rate-menu")}get rates(){return Wo(this,qr)}set rates(e){e?Array.isArray(e)&&(Wo(this,qr).value=e.join(" ")):Wo(this,qr).value=""}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,Lu)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}}qr=new WeakMap;k.customElements.get("media-playback-rate-menu-button")||k.customElements.define("media-playback-rate-menu-button",Yw);const jw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1104
+ `;class jw extends Bn{constructor(e={}){super({slotTemplate:Fy,...e}),qw(this,qr,new uo(this,ku.RATES,{defaultValue:Yw})),this.container=this.shadowRoot.querySelector('slot[name="icon"]'),this.container.innerHTML=`${Lu}x`}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PLAYBACK_RATE,ku.RATES]}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback(e,t,s),e===ku.RATES&&(Wo(this,qr).value=s),e===T.MEDIA_PLAYBACK_RATE){const r=s?+s:Number.NaN,n=Number.isNaN(r)?Lu:r;this.container.innerHTML=`${n}x`,this.setAttribute("aria-label",Ut.PLAYBACK_RATE({playbackRate:n}))}}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-playback-rate-menu")}get rates(){return Wo(this,qr)}set rates(e){e?Array.isArray(e)&&(Wo(this,qr).value=e.join(" ")):Wo(this,qr).value=""}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,Lu)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}}qr=new WeakMap;k.customElements.get("media-playback-rate-menu-button")||k.customElements.define("media-playback-rate-menu-button",jw);const zw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1105
1105
  <path d="m6 21 15-9L6 3v18Z"/>
1106
- </svg>`,zw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1106
+ </svg>`,Xw=`<svg aria-hidden="true" viewBox="0 0 24 24">
1107
1107
  <path d="M6 20h4V4H6v16Zm8-16v16h4V4h-4Z"/>
1108
1108
  </svg>`,$y=z.createElement("template");$y.innerHTML=`
1109
1109
  <style>
@@ -1117,10 +1117,10 @@ svg, img, ::slotted(svg), ::slotted(img) {
1117
1117
  </style>
1118
1118
 
1119
1119
  <slot name="icon">
1120
- <slot name="play">${jw}</slot>
1121
- <slot name="pause">${zw}</slot>
1120
+ <slot name="play">${zw}</slot>
1121
+ <slot name="pause">${Xw}</slot>
1122
1122
  </slot>
1123
- `;const _g=i=>{const e=i.mediaPaused?At.PLAY():At.PAUSE();i.setAttribute("aria-label",e)};class Xw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:$y,...e})}connectedCallback(){_g(this),super.connectedCallback()}attributeChangedCallback(e,t,s){e===T.MEDIA_PAUSED&&_g(this),super.attributeChangedCallback(e,t,s)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleClick(){const e=this.mediaPaused?K.MEDIA_PLAY_REQUEST:K.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-play-button")||k.customElements.define("media-play-button",Xw);const di={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},By=z.createElement("template");By.innerHTML=`
1123
+ `;const _g=i=>{const e=i.mediaPaused?At.PLAY():At.PAUSE();i.setAttribute("aria-label",e)};class Qw extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_ENDED]}constructor(e={}){super({slotTemplate:$y,...e})}connectedCallback(){_g(this),super.connectedCallback()}attributeChangedCallback(e,t,s){e===T.MEDIA_PAUSED&&_g(this),super.attributeChangedCallback(e,t,s)}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}handleClick(){const e=this.mediaPaused?K.MEDIA_PLAY_REQUEST:K.MEDIA_PAUSE_REQUEST;this.dispatchEvent(new k.CustomEvent(e,{composed:!0,bubbles:!0}))}}k.customElements.get("media-play-button")||k.customElements.define("media-play-button",Qw);const di={PLACEHOLDER_SRC:"placeholdersrc",SRC:"src"},By=z.createElement("template");By.innerHTML=`
1124
1124
  <style>
1125
1125
  :host {
1126
1126
  pointer-events: none;
@@ -1142,7 +1142,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1142
1142
  </style>
1143
1143
 
1144
1144
  <img part="poster img" aria-hidden="true" id="image"/>
1145
- `;const Qw=i=>{i.style.removeProperty("background-image")},Zw=(i,e)=>{i.style["background-image"]=`url('${e}')`};class Jw extends k.HTMLElement{static get observedAttributes(){return[di.PLACEHOLDER_SRC,di.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(By.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,s){e===di.SRC&&(s==null?this.image.removeAttribute(di.SRC):this.image.setAttribute(di.SRC,s)),e===di.PLACEHOLDER_SRC&&(s==null?Qw(this.image):Zw(this.image,s))}get placeholderSrc(){return Ve(this,di.PLACEHOLDER_SRC)}set placeholderSrc(e){qe(this,di.SRC,e)}get src(){return Ve(this,di.SRC)}set src(e){qe(this,di.SRC,e)}}k.customElements.get("media-poster-image")||k.customElements.define("media-poster-image",Jw);var Gy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},eC=(i,e,t)=>(Gy(i,e,"read from private field"),t?t.call(i):e.get(i)),tC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},iC=(i,e,t,s)=>(Gy(i,e,"write to private field"),e.set(i,t),t),Nl;class sC extends Aw{constructor(){super(),tC(this,Nl,void 0),iC(this,Nl,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PREVIEW_CHAPTER&&s!==t&&s!=null&&(eC(this,Nl).textContent=s,s!==""?this.setAttribute("aria-valuetext",`chapter: ${s}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return Ve(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){qe(this,T.MEDIA_PREVIEW_CHAPTER,e)}}Nl=new WeakMap;k.customElements.get("media-preview-chapter-display")||k.customElements.define("media-preview-chapter-display",sC);var Hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ko=(i,e,t)=>(Hy(i,e,"read from private field"),t?t.call(i):e.get(i)),rC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vo=(i,e,t,s)=>(Hy(i,e,"write to private field"),e.set(i,t),t),bi;const Wy=z.createElement("template");Wy.innerHTML=`
1145
+ `;const Zw=i=>{i.style.removeProperty("background-image")},Jw=(i,e)=>{i.style["background-image"]=`url('${e}')`};class eC extends k.HTMLElement{static get observedAttributes(){return[di.PLACEHOLDER_SRC,di.SRC]}constructor(){super(),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(By.content.cloneNode(!0))),this.image=this.shadowRoot.querySelector("#image")}attributeChangedCallback(e,t,s){e===di.SRC&&(s==null?this.image.removeAttribute(di.SRC):this.image.setAttribute(di.SRC,s)),e===di.PLACEHOLDER_SRC&&(s==null?Zw(this.image):Jw(this.image,s))}get placeholderSrc(){return Ve(this,di.PLACEHOLDER_SRC)}set placeholderSrc(e){qe(this,di.SRC,e)}get src(){return Ve(this,di.SRC)}set src(e){qe(this,di.SRC,e)}}k.customElements.get("media-poster-image")||k.customElements.define("media-poster-image",eC);var Gy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},tC=(i,e,t)=>(Gy(i,e,"read from private field"),t?t.call(i):e.get(i)),iC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},sC=(i,e,t,s)=>(Gy(i,e,"write to private field"),e.set(i,t),t),Nl;class rC extends Sw{constructor(){super(),iC(this,Nl,void 0),sC(this,Nl,this.shadowRoot.querySelector("slot"))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_CHAPTER]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PREVIEW_CHAPTER&&s!==t&&s!=null&&(tC(this,Nl).textContent=s,s!==""?this.setAttribute("aria-valuetext",`chapter: ${s}`):this.removeAttribute("aria-valuetext"))}get mediaPreviewChapter(){return Ve(this,T.MEDIA_PREVIEW_CHAPTER)}set mediaPreviewChapter(e){qe(this,T.MEDIA_PREVIEW_CHAPTER,e)}}Nl=new WeakMap;k.customElements.get("media-preview-chapter-display")||k.customElements.define("media-preview-chapter-display",rC);var Hy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ko=(i,e,t)=>(Hy(i,e,"read from private field"),t?t.call(i):e.get(i)),nC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Vo=(i,e,t,s)=>(Hy(i,e,"write to private field"),e.set(i,t),t),bi;const Wy=z.createElement("template");Wy.innerHTML=`
1146
1146
  <style>
1147
1147
  :host {
1148
1148
  box-sizing: border-box;
@@ -1156,15 +1156,15 @@ svg, img, ::slotted(svg), ::slotted(img) {
1156
1156
  }
1157
1157
  </style>
1158
1158
  <img crossorigin loading="eager" decoding="async">
1159
- `;class nC extends k.HTMLElement{constructor(){super(),rC(this,bi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Wy.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,s;const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(Vo(this,bi,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=Ko(this,bi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ko(this,bi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Vo(this,bi,null)}attributeChangedCallback(e,t,s){var r,n,a,o,l;[T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=Ko(this,bi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Vo(this,bi,null)),s&&this.isConnected&&(Vo(this,bi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=Ko(this,bi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return Ve(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){qe(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){const e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){const e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;const[s,r,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),m=Math.max(parseInt(u)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:v}=Ge(this.shadowRoot,":host"),y=Ge(this.shadowRoot,"img").style,b=this.shadowRoot.querySelector("img"),x=p?"min":"max";v.setProperty(`${x}-width`,"initial","important"),v.setProperty(`${x}-height`,"initial","important"),v.width=`${n*g}px`,v.height=`${a*g}px`;const _=()=>{y.width=`${this.imgWidth*g}px`,y.height=`${this.imgHeight*g}px`,y.display="block"};b.src!==o&&(b.onload=()=>{this.imgWidth=b.naturalWidth,this.imgHeight=b.naturalHeight,_()},b.src=o,_()),_(),y.transform=`translate(-${s*g}px, -${r*g}px)`}}bi=new WeakMap;k.customElements.get("media-preview-thumbnail")||k.customElements.define("media-preview-thumbnail",nC);var Ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ag=(i,e,t)=>(Ky(i,e,"read from private field"),t?t.call(i):e.get(i)),aC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},oC=(i,e,t,s)=>(Ky(i,e,"write to private field"),e.set(i,t),t),ha;class lC extends fo{constructor(){super(),aC(this,ha,void 0),oC(this,ha,this.shadowRoot.querySelector("slot")),Ag(this,ha).textContent=hr(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PREVIEW_TIME&&s!=null&&(Ag(this,ha).textContent=hr(s))}get mediaPreviewTime(){return $e(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){nt(this,T.MEDIA_PREVIEW_TIME,e)}}ha=new WeakMap;k.customElements.get("media-preview-time-display")||k.customElements.define("media-preview-time-display",lC);var Jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vy=(i,e,t)=>(Jm(i,e,"read from private field"),t?t.call(i):e.get(i)),qo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Jh=(i,e,t,s)=>(Jm(i,e,"write to private field"),e.set(i,t),t),Yo=(i,e,t)=>(Jm(i,e,"access private method"),t),fa,cc,Ul,ef,Fl,tf;class dC extends es{constructor(){super(...arguments),qo(this,Ul),qo(this,Fl),qo(this,fa,[]),qo(this,cc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_RENDITION_SELECTED&&t!==s?this.value=s??"auto":e===T.MEDIA_RENDITION_LIST&&t!==s&&(Jh(this,fa,sb(s)),Yo(this,Ul,ef).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Yo(this,Fl,tf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Yo(this,Fl,tf))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return Vy(this,fa)}set mediaRenditionList(e){Jh(this,fa,e),Yo(this,Ul,ef).call(this)}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}fa=new WeakMap;cc=new WeakMap;Ul=new WeakSet;ef=function(){if(Vy(this,cc)===JSON.stringify(this.mediaRenditionList))return;Jh(this,cc,JSON.stringify(this.mediaRenditionList));const i=this.mediaRenditionList.sort((s,r)=>r.height-s.height);this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(const s of i){const r=this.formatMenuItemText(`${Math.min(s.width,s.height)}p`,s),n=Un({type:"radio",text:r,value:`${s.id}`,checked:s.selected&&!e});n.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(n)}const t=Un({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e});t.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(t)};Fl=new WeakSet;tf=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-rendition-menu")||k.customElements.define("media-rendition-menu",dC);const cC=`<svg aria-hidden="true" viewBox="0 0 24 24">
1159
+ `;class aC extends k.HTMLElement{constructor(){super(),nC(this,bi,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(Wy.content.cloneNode(!0)))}static get observedAttributes(){return[ue.MEDIA_CONTROLLER,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS]}connectedCallback(){var e,t,s;const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(Vo(this,bi,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=Ko(this,bi))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;(t=(e=Ko(this,bi))==null?void 0:e.unassociateElement)==null||t.call(e,this),Vo(this,bi,null)}attributeChangedCallback(e,t,s){var r,n,a,o,l;[T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_COORDS].includes(e)&&this.update(),e===ue.MEDIA_CONTROLLER&&(t&&((n=(r=Ko(this,bi))==null?void 0:r.unassociateElement)==null||n.call(r,this),Vo(this,bi,null)),s&&this.isConnected&&(Vo(this,bi,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=Ko(this,bi))==null?void 0:o.associateElement)==null||l.call(o,this)))}get mediaPreviewImage(){return Ve(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){qe(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewCoords(){const e=this.getAttribute(T.MEDIA_PREVIEW_COORDS);if(e)return e.split(/\s+/).map(t=>+t)}set mediaPreviewCoords(e){if(!e){this.removeAttribute(T.MEDIA_PREVIEW_COORDS);return}this.setAttribute(T.MEDIA_PREVIEW_COORDS,e.join(" "))}update(){const e=this.mediaPreviewCoords,t=this.mediaPreviewImage;if(!(e&&t))return;const[s,r,n,a]=e,o=t.split("#")[0],l=getComputedStyle(this),{maxWidth:d,maxHeight:c,minWidth:u,minHeight:h}=l,f=Math.min(parseInt(d)/n,parseInt(c)/a),m=Math.max(parseInt(u)/n,parseInt(h)/a),p=f<1,g=p?f:m>1?m:1,{style:v}=Ge(this.shadowRoot,":host"),y=Ge(this.shadowRoot,"img").style,b=this.shadowRoot.querySelector("img"),x=p?"min":"max";v.setProperty(`${x}-width`,"initial","important"),v.setProperty(`${x}-height`,"initial","important"),v.width=`${n*g}px`,v.height=`${a*g}px`;const _=()=>{y.width=`${this.imgWidth*g}px`,y.height=`${this.imgHeight*g}px`,y.display="block"};b.src!==o&&(b.onload=()=>{this.imgWidth=b.naturalWidth,this.imgHeight=b.naturalHeight,_()},b.src=o,_()),_(),y.transform=`translate(-${s*g}px, -${r*g}px)`}}bi=new WeakMap;k.customElements.get("media-preview-thumbnail")||k.customElements.define("media-preview-thumbnail",aC);var Ky=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Ag=(i,e,t)=>(Ky(i,e,"read from private field"),t?t.call(i):e.get(i)),oC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},lC=(i,e,t,s)=>(Ky(i,e,"write to private field"),e.set(i,t),t),ha;class dC extends fo{constructor(){super(),oC(this,ha,void 0),lC(this,ha,this.shadowRoot.querySelector("slot")),Ag(this,ha).textContent=hr(0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PREVIEW_TIME]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PREVIEW_TIME&&s!=null&&(Ag(this,ha).textContent=hr(s))}get mediaPreviewTime(){return $e(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){nt(this,T.MEDIA_PREVIEW_TIME,e)}}ha=new WeakMap;k.customElements.get("media-preview-time-display")||k.customElements.define("media-preview-time-display",dC);var Jm=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Vy=(i,e,t)=>(Jm(i,e,"read from private field"),t?t.call(i):e.get(i)),qo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Jh=(i,e,t,s)=>(Jm(i,e,"write to private field"),e.set(i,t),t),Yo=(i,e,t)=>(Jm(i,e,"access private method"),t),fa,cc,Ul,ef,Fl,tf;class cC extends es{constructor(){super(...arguments),qo(this,Ul),qo(this,Fl),qo(this,fa,[]),qo(this,cc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_RENDITION_SELECTED&&t!==s?this.value=s??"auto":e===T.MEDIA_RENDITION_LIST&&t!==s&&(Jh(this,fa,sb(s)),Yo(this,Ul,ef).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Yo(this,Fl,tf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Yo(this,Fl,tf))}get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-rendition-menu-button")}get mediaRenditionList(){return Vy(this,fa)}set mediaRenditionList(e){Jh(this,fa,e),Yo(this,Ul,ef).call(this)}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}fa=new WeakMap;cc=new WeakMap;Ul=new WeakSet;ef=function(){if(Vy(this,cc)===JSON.stringify(this.mediaRenditionList))return;Jh(this,cc,JSON.stringify(this.mediaRenditionList));const i=this.mediaRenditionList.sort((s,r)=>r.height-s.height);this.defaultSlot.textContent="";let e=!this.mediaRenditionSelected;for(const s of i){const r=this.formatMenuItemText(`${Math.min(s.width,s.height)}p`,s),n=Un({type:"radio",text:r,value:`${s.id}`,checked:s.selected&&!e});n.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(n)}const t=Un({type:"radio",text:this.formatMenuItemText("Auto"),value:"auto",checked:e});t.prepend(gr(this,"checked-indicator")),this.defaultSlot.append(t)};Fl=new WeakSet;tf=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-rendition-menu")||k.customElements.define("media-rendition-menu",cC);const uC=`<svg aria-hidden="true" viewBox="0 0 24 24">
1160
1160
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1161
1161
  </svg>`,qy=z.createElement("template");qy.innerHTML=`
1162
- <slot name="icon">${cC}</slot>
1163
- `;class uC extends Bn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:qy})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}k.customElements.get("media-rendition-menu-button")||k.customElements.define("media-rendition-menu-button",uC);const Ur={SEEK_OFFSET:"seekoffset"},$l=30,hC=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${$l}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,Yy=z.createElement("template");Yy.innerHTML=`
1164
- <slot name="icon">${hC}</slot>
1165
- `;const fC=0;class mC extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,Ur.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Yy,...e})}connectedCallback(){this.seekOffset=$e(this,Ur.SEEK_OFFSET,$l),super.connectedCallback()}attributeChangedCallback(e,t,s){e===Ur.SEEK_OFFSET&&(this.seekOffset=$e(this,Ur.SEEK_OFFSET,$l)),super.attributeChangedCallback(e,t,s)}get seekOffset(){return $e(this,Ur.SEEK_OFFSET,$l)}set seekOffset(e){nt(this,Ur.SEEK_OFFSET,e),this.setAttribute("aria-label",At.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),hb(fb(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME,fC)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}k.customElements.get("media-seek-backward-button")||k.customElements.define("media-seek-backward-button",mC);const Fr={SEEK_OFFSET:"seekoffset"},Bl=30,pC=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Bl}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,jy=z.createElement("template");jy.innerHTML=`
1166
- <slot name="icon">${pC}</slot>
1167
- `;const gC=0;class vC extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,Fr.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:jy,...e})}connectedCallback(){this.seekOffset=$e(this,Fr.SEEK_OFFSET,Bl),super.connectedCallback()}attributeChangedCallback(e,t,s){e===Fr.SEEK_OFFSET&&(this.seekOffset=$e(this,Fr.SEEK_OFFSET,Bl)),super.attributeChangedCallback(e,t,s)}get seekOffset(){return $e(this,Fr.SEEK_OFFSET,Bl)}set seekOffset(e){nt(this,Fr.SEEK_OFFSET,e),this.setAttribute("aria-label",At.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),hb(fb(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME,gC)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=this.mediaCurrentTime+this.seekOffset,t=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}k.customElements.get("media-seek-forward-button")||k.customElements.define("media-seek-forward-button",vC);var EC=Object.defineProperty,bC=(i,e,t)=>e in i?EC(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,yC=(i,e,t)=>(bC(i,e+"",t),t);const zy=z.createElement("template");zy.innerHTML=es.template.innerHTML+`
1162
+ <slot name="icon">${uC}</slot>
1163
+ `;class hC extends Bn{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:qy})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.QUALITY())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-rendition-menu")}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}k.customElements.get("media-rendition-menu-button")||k.customElements.define("media-rendition-menu-button",hC);const Ur={SEEK_OFFSET:"seekoffset"},$l=30,fC=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(2.18 19.87)">${$l}</text><path d="M10 6V3L4.37 7 10 10.94V8a5.54 5.54 0 0 1 1.9 10.48v2.12A7.5 7.5 0 0 0 10 6Z"/></svg>`,Yy=z.createElement("template");Yy.innerHTML=`
1164
+ <slot name="icon">${fC}</slot>
1165
+ `;const mC=0;class pC extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,Ur.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:Yy,...e})}connectedCallback(){this.seekOffset=$e(this,Ur.SEEK_OFFSET,$l),super.connectedCallback()}attributeChangedCallback(e,t,s){e===Ur.SEEK_OFFSET&&(this.seekOffset=$e(this,Ur.SEEK_OFFSET,$l)),super.attributeChangedCallback(e,t,s)}get seekOffset(){return $e(this,Ur.SEEK_OFFSET,$l)}set seekOffset(e){nt(this,Ur.SEEK_OFFSET,e),this.setAttribute("aria-label",At.SEEK_BACK_N_SECS({seekOffset:this.seekOffset})),hb(fb(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME,mC)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=Math.max(this.mediaCurrentTime-this.seekOffset,0),t=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}k.customElements.get("media-seek-backward-button")||k.customElements.define("media-seek-backward-button",pC);const Fr={SEEK_OFFSET:"seekoffset"},Bl=30,gC=`<svg aria-hidden="true" viewBox="0 0 20 24"><defs><style>.text{font-size:8px;font-family:Arial-BoldMT, Arial;font-weight:700;}</style></defs><text class="text value" transform="translate(8.9 19.87)">${Bl}</text><path d="M10 6V3l5.61 4L10 10.94V8a5.54 5.54 0 0 0-1.9 10.48v2.12A7.5 7.5 0 0 1 10 6Z"/></svg>`,jy=z.createElement("template");jy.innerHTML=`
1166
+ <slot name="icon">${gC}</slot>
1167
+ `;const vC=0;class EC extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_CURRENT_TIME,Fr.SEEK_OFFSET]}constructor(e={}){super({slotTemplate:jy,...e})}connectedCallback(){this.seekOffset=$e(this,Fr.SEEK_OFFSET,Bl),super.connectedCallback()}attributeChangedCallback(e,t,s){e===Fr.SEEK_OFFSET&&(this.seekOffset=$e(this,Fr.SEEK_OFFSET,Bl)),super.attributeChangedCallback(e,t,s)}get seekOffset(){return $e(this,Fr.SEEK_OFFSET,Bl)}set seekOffset(e){nt(this,Fr.SEEK_OFFSET,e),this.setAttribute("aria-label",At.SEEK_FORWARD_N_SECS({seekOffset:this.seekOffset})),hb(fb(this,"icon"),this.seekOffset)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME,vC)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}handleClick(){const e=this.mediaCurrentTime+this.seekOffset,t=new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)}}k.customElements.get("media-seek-forward-button")||k.customElements.define("media-seek-forward-button",EC);var bC=Object.defineProperty,yC=(i,e,t)=>e in i?bC(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,TC=(i,e,t)=>(yC(i,e+"",t),t);const zy=z.createElement("template");zy.innerHTML=es.template.innerHTML+`
1168
1168
  <style>
1169
1169
  :host {
1170
1170
  background: var(--media-settings-menu-background,
@@ -1191,13 +1191,13 @@ svg, img, ::slotted(svg), ::slotted(img) {
1191
1191
  --media-settings-menu-item-opacity: 0;
1192
1192
  }
1193
1193
  </style>
1194
- `;class Xy extends es{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-settings-menu-button")}}yC(Xy,"template",zy);k.customElements.get("media-settings-menu")||k.customElements.define("media-settings-menu",Xy);const Qy=z.createElement("template");Qy.innerHTML=`
1194
+ `;class Xy extends es{get anchorElement(){return this.anchor!=="auto"?super.anchorElement:oi(this).querySelector("media-settings-menu-button")}}TC(Xy,"template",zy);k.customElements.get("media-settings-menu")||k.customElements.define("media-settings-menu",Xy);const Qy=z.createElement("template");Qy.innerHTML=`
1195
1195
  <slot name="icon">
1196
1196
  <svg aria-hidden="true" viewBox="0 0 24 24">
1197
1197
  <path d="M4.5 14.5a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Zm7.5 0a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5Z"/>
1198
1198
  </svg>
1199
1199
  </slot>
1200
- `;class TC extends Bn{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:Qy})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-settings-menu")}}k.customElements.get("media-settings-menu-button")||k.customElements.define("media-settings-menu-button",TC);var _C=Object.defineProperty,AC=(i,e,t)=>e in i?_C(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,SC=(i,e,t)=>(AC(i,e+"",t),t),Sg;const uc=z.createElement("template");uc.innerHTML=Oc.template.innerHTML+`
1200
+ `;class _C extends Bn{static get observedAttributes(){return[...super.observedAttributes,"target"]}constructor(){super({slotTemplate:Qy})}connectedCallback(){super.connectedCallback(),this.setAttribute("aria-label",Ut.SETTINGS())}get invokeTargetElement(){return this.invokeTarget!=null?super.invokeTargetElement:oi(this).querySelector("media-settings-menu")}}k.customElements.get("media-settings-menu-button")||k.customElements.define("media-settings-menu-button",_C);var AC=Object.defineProperty,SC=(i,e,t)=>e in i?AC(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,xC=(i,e,t)=>(SC(i,e+"",t),t),Sg;const uc=z.createElement("template");uc.innerHTML=Oc.template.innerHTML+`
1201
1201
  <style>
1202
1202
  slot:not([name="submenu"]) {
1203
1203
  opacity: var(--media-settings-menu-item-opacity, var(--media-menu-item-opacity));
@@ -1211,7 +1211,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1211
1211
  <svg aria-hidden="true" viewBox="0 0 20 24">
1212
1212
  <path d="m8.12 17.585-.742-.669 4.2-4.665-4.2-4.666.743-.669 4.803 5.335-4.803 5.334Z"/>
1213
1213
  </svg>
1214
- `);class Zy extends Oc{}SC(Zy,"template",uc);k.customElements.get("media-settings-menu-item")||k.customElements.define("media-settings-menu-item",Zy);var Jy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Iu=(i,e,t)=>(Jy(i,e,"read from private field"),t?t.call(i):e.get(i)),xC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},kC=(i,e,t,s)=>(Jy(i,e,"write to private field"),e.set(i,t),t),Yr;const ti={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},xg=[...Object.values(ti),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],kg=["Enter"," "],LC="&nbsp;/&nbsp;",Lg=(i,{timesSep:e=LC}={})=>{var t,s;const r=i.hasAttribute(ti.REMAINING),n=i.hasAttribute(ti.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(s=i.mediaSeekable)!=null?s:[];let l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);const d=hr(r?0-(l-a):a);return n?`${d}${e}${hr(l)}`:d},IC="video not loaded, unknown time.",RC=i=>{var e;const t=i.mediaCurrentTime,[,s]=(e=i.mediaSeekable)!=null?e:[];let r=null;if(Number.isFinite(i.mediaDuration)?r=i.mediaDuration:Number.isFinite(s)&&(r=s),t==null||r===null){i.setAttribute("aria-valuetext",IC);return}const n=i.hasAttribute(ti.REMAINING),a=i.hasAttribute(ti.SHOW_DURATION),o=Pa(n?0-(r-t):t);if(!a){i.setAttribute("aria-valuetext",o);return}const l=Pa(r),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)};class wC extends fo{constructor(){super(),xC(this,Yr,void 0),kC(this,Yr,this.shadowRoot.querySelector("slot")),Iu(this,Yr).innerHTML=`${Lg(this)}`}static get observedAttributes(){return[...super.observedAttributes,...xg,"disabled"]}connectedCallback(){const{style:e}=Ge(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Ut.PLAYBACK_TIME());const t=s=>{const{key:r}=s;if(!kg.includes(r)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",s=>{const{metaKey:r,altKey:n,key:a}=s;if(r||n||!kg.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,s){xg.includes(e)?this.update():e==="disabled"&&s!==t&&(s==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,s)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return at(this,ti.REMAINING)}set remaining(e){ot(this,ti.REMAINING,e)}get showDuration(){return at(this,ti.SHOW_DURATION)}set showDuration(e){ot(this,ti.SHOW_DURATION,e)}get noToggle(){return at(this,ti.NO_TOGGLE)}set noToggle(e){ot(this,ti.NO_TOGGLE,e)}get mediaDuration(){return $e(this,T.MEDIA_DURATION)}set mediaDuration(e){nt(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}update(){const e=Lg(this);RC(this),e!==Iu(this,Yr).innerHTML&&(Iu(this,Yr).innerHTML=e)}}Yr=new WeakMap;k.customElements.get("media-time-display")||k.customElements.define("media-time-display",wC);var eT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},tt=(i,e,t)=>(eT(i,e,"read from private field"),t?t.call(i):e.get(i)),ci=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Nt=(i,e,t,s)=>(eT(i,e,"write to private field"),e.set(i,t),t),CC=(i,e,t,s)=>({set _(r){Nt(i,e,r)},get _(){return tt(i,e,s)}}),jr,Gl,zr,ma,Hl,Wl,Kl,Xr,Ns,Vl;class DC{constructor(e,t,s){ci(this,jr,void 0),ci(this,Gl,void 0),ci(this,zr,void 0),ci(this,ma,void 0),ci(this,Hl,void 0),ci(this,Wl,void 0),ci(this,Kl,void 0),ci(this,Xr,void 0),ci(this,Ns,0),ci(this,Vl,(r=performance.now())=>{Nt(this,Ns,requestAnimationFrame(tt(this,Vl))),Nt(this,ma,performance.now()-tt(this,zr));const n=1e3/this.fps;if(tt(this,ma)>n){Nt(this,zr,r-tt(this,ma)%n);const a=1e3/((r-tt(this,Gl))/++CC(this,Hl)._),o=(r-tt(this,Wl))/1e3/this.duration;let l=tt(this,Kl)+o*this.playbackRate;l-tt(this,jr).valueAsNumber>0?Nt(this,Xr,this.playbackRate/this.duration/a):(Nt(this,Xr,.995*tt(this,Xr)),l=tt(this,jr).valueAsNumber+tt(this,Xr)),this.callback(l)}}),Nt(this,jr,e),this.callback=t,this.fps=s}start(){tt(this,Ns)===0&&(Nt(this,zr,performance.now()),Nt(this,Gl,tt(this,zr)),Nt(this,Hl,0),tt(this,Vl).call(this))}stop(){tt(this,Ns)!==0&&(cancelAnimationFrame(tt(this,Ns)),Nt(this,Ns,0))}update({start:e,duration:t,playbackRate:s}){const r=e-tt(this,jr).valueAsNumber,n=Math.abs(t-this.duration);(r>0||r<-.03||n>=.5)&&this.callback(e),Nt(this,Kl,e),Nt(this,Wl,performance.now()),this.duration=t,this.playbackRate=s}}jr=new WeakMap;Gl=new WeakMap;zr=new WeakMap;ma=new WeakMap;Hl=new WeakMap;Wl=new WeakMap;Kl=new WeakMap;Xr=new WeakMap;Ns=new WeakMap;Vl=new WeakMap;var ep=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Xe=(i,e,t)=>(ep(i,e,"read from private field"),t?t.call(i):e.get(i)),et=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},yi=(i,e,t,s)=>(ep(i,e,"write to private field"),e.set(i,t),t),_t=(i,e,t)=>(ep(i,e,"access private method"),t),Qr,vr,hc,Ga,fc,ql,so,ro,Zr,Jr,pa,tp,tT,sf,mc,ip,pc,sp,gc,rp,rf,iT,no,vc,nf,sT;const MC="video not loaded, unknown time.",OC=i=>{const e=i.range,t=Pa(+nT(i)),s=Pa(+i.mediaSeekableEnd),r=t&&s?`${t} of ${s}`:MC;e.setAttribute("aria-valuetext",r)},rT=z.createElement("template");rT.innerHTML=`
1214
+ `);class Zy extends Oc{}xC(Zy,"template",uc);k.customElements.get("media-settings-menu-item")||k.customElements.define("media-settings-menu-item",Zy);var Jy=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Iu=(i,e,t)=>(Jy(i,e,"read from private field"),t?t.call(i):e.get(i)),kC=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},LC=(i,e,t,s)=>(Jy(i,e,"write to private field"),e.set(i,t),t),Yr;const ti={REMAINING:"remaining",SHOW_DURATION:"showduration",NO_TOGGLE:"notoggle"},xg=[...Object.values(ti),T.MEDIA_CURRENT_TIME,T.MEDIA_DURATION,T.MEDIA_SEEKABLE],kg=["Enter"," "],IC="&nbsp;/&nbsp;",Lg=(i,{timesSep:e=IC}={})=>{var t,s;const r=i.hasAttribute(ti.REMAINING),n=i.hasAttribute(ti.SHOW_DURATION),a=(t=i.mediaCurrentTime)!=null?t:0,[,o]=(s=i.mediaSeekable)!=null?s:[];let l=0;Number.isFinite(i.mediaDuration)?l=i.mediaDuration:Number.isFinite(o)&&(l=o);const d=hr(r?0-(l-a):a);return n?`${d}${e}${hr(l)}`:d},RC="video not loaded, unknown time.",wC=i=>{var e;const t=i.mediaCurrentTime,[,s]=(e=i.mediaSeekable)!=null?e:[];let r=null;if(Number.isFinite(i.mediaDuration)?r=i.mediaDuration:Number.isFinite(s)&&(r=s),t==null||r===null){i.setAttribute("aria-valuetext",RC);return}const n=i.hasAttribute(ti.REMAINING),a=i.hasAttribute(ti.SHOW_DURATION),o=Pa(n?0-(r-t):t);if(!a){i.setAttribute("aria-valuetext",o);return}const l=Pa(r),d=`${o} of ${l}`;i.setAttribute("aria-valuetext",d)};class CC extends fo{constructor(){super(),kC(this,Yr,void 0),LC(this,Yr,this.shadowRoot.querySelector("slot")),Iu(this,Yr).innerHTML=`${Lg(this)}`}static get observedAttributes(){return[...super.observedAttributes,...xg,"disabled"]}connectedCallback(){const{style:e}=Ge(this.shadowRoot,":host(:hover:not([notoggle]))");e.setProperty("cursor","pointer"),e.setProperty("background","var(--media-control-hover-background, rgba(50 50 70 / .7))"),this.hasAttribute("disabled")||this.enable(),this.setAttribute("role","progressbar"),this.setAttribute("aria-label",Ut.PLAYBACK_TIME());const t=s=>{const{key:r}=s;if(!kg.includes(r)){this.removeEventListener("keyup",t);return}this.toggleTimeDisplay()};this.addEventListener("keydown",s=>{const{metaKey:r,altKey:n,key:a}=s;if(r||n||!kg.includes(a)){this.removeEventListener("keyup",t);return}this.addEventListener("keyup",t)}),this.addEventListener("click",this.toggleTimeDisplay),super.connectedCallback()}toggleTimeDisplay(){this.noToggle||(this.hasAttribute("remaining")?this.removeAttribute("remaining"):this.setAttribute("remaining",""))}disconnectedCallback(){this.disable(),super.disconnectedCallback()}attributeChangedCallback(e,t,s){xg.includes(e)?this.update():e==="disabled"&&s!==t&&(s==null?this.enable():this.disable()),super.attributeChangedCallback(e,t,s)}enable(){this.tabIndex=0}disable(){this.tabIndex=-1}get remaining(){return at(this,ti.REMAINING)}set remaining(e){ot(this,ti.REMAINING,e)}get showDuration(){return at(this,ti.SHOW_DURATION)}set showDuration(e){ot(this,ti.SHOW_DURATION,e)}get noToggle(){return at(this,ti.NO_TOGGLE)}set noToggle(e){ot(this,ti.NO_TOGGLE,e)}get mediaDuration(){return $e(this,T.MEDIA_DURATION)}set mediaDuration(e){nt(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}update(){const e=Lg(this);wC(this),e!==Iu(this,Yr).innerHTML&&(Iu(this,Yr).innerHTML=e)}}Yr=new WeakMap;k.customElements.get("media-time-display")||k.customElements.define("media-time-display",CC);var eT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},tt=(i,e,t)=>(eT(i,e,"read from private field"),t?t.call(i):e.get(i)),ci=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Nt=(i,e,t,s)=>(eT(i,e,"write to private field"),e.set(i,t),t),DC=(i,e,t,s)=>({set _(r){Nt(i,e,r)},get _(){return tt(i,e,s)}}),jr,Gl,zr,ma,Hl,Wl,Kl,Xr,Ns,Vl;class MC{constructor(e,t,s){ci(this,jr,void 0),ci(this,Gl,void 0),ci(this,zr,void 0),ci(this,ma,void 0),ci(this,Hl,void 0),ci(this,Wl,void 0),ci(this,Kl,void 0),ci(this,Xr,void 0),ci(this,Ns,0),ci(this,Vl,(r=performance.now())=>{Nt(this,Ns,requestAnimationFrame(tt(this,Vl))),Nt(this,ma,performance.now()-tt(this,zr));const n=1e3/this.fps;if(tt(this,ma)>n){Nt(this,zr,r-tt(this,ma)%n);const a=1e3/((r-tt(this,Gl))/++DC(this,Hl)._),o=(r-tt(this,Wl))/1e3/this.duration;let l=tt(this,Kl)+o*this.playbackRate;l-tt(this,jr).valueAsNumber>0?Nt(this,Xr,this.playbackRate/this.duration/a):(Nt(this,Xr,.995*tt(this,Xr)),l=tt(this,jr).valueAsNumber+tt(this,Xr)),this.callback(l)}}),Nt(this,jr,e),this.callback=t,this.fps=s}start(){tt(this,Ns)===0&&(Nt(this,zr,performance.now()),Nt(this,Gl,tt(this,zr)),Nt(this,Hl,0),tt(this,Vl).call(this))}stop(){tt(this,Ns)!==0&&(cancelAnimationFrame(tt(this,Ns)),Nt(this,Ns,0))}update({start:e,duration:t,playbackRate:s}){const r=e-tt(this,jr).valueAsNumber,n=Math.abs(t-this.duration);(r>0||r<-.03||n>=.5)&&this.callback(e),Nt(this,Kl,e),Nt(this,Wl,performance.now()),this.duration=t,this.playbackRate=s}}jr=new WeakMap;Gl=new WeakMap;zr=new WeakMap;ma=new WeakMap;Hl=new WeakMap;Wl=new WeakMap;Kl=new WeakMap;Xr=new WeakMap;Ns=new WeakMap;Vl=new WeakMap;var ep=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Xe=(i,e,t)=>(ep(i,e,"read from private field"),t?t.call(i):e.get(i)),et=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},yi=(i,e,t,s)=>(ep(i,e,"write to private field"),e.set(i,t),t),_t=(i,e,t)=>(ep(i,e,"access private method"),t),Qr,vr,hc,Ga,fc,ql,so,ro,Zr,Jr,pa,tp,tT,sf,mc,ip,pc,sp,gc,rp,rf,iT,no,vc,nf,sT;const OC="video not loaded, unknown time.",PC=i=>{const e=i.range,t=Pa(+nT(i)),s=Pa(+i.mediaSeekableEnd),r=t&&s?`${t} of ${s}`:OC;e.setAttribute("aria-valuetext",r)},rT=z.createElement("template");rT.innerHTML=`
1215
1215
  <style>
1216
1216
  :host {
1217
1217
  --media-box-border-radius: 4px;
@@ -1422,7 +1422,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1422
1422
 
1423
1423
  </slot>
1424
1424
  </div>
1425
- `;const jo=(i,e=i.mediaCurrentTime)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,s=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(s))return 0;const r=(e-t)/(s-t);return Math.max(0,Math.min(r,1))},nT=(i,e=i.range.valueAsNumber)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,s=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(s)?0:e*(s-t)+t};class PC extends Qm{constructor(){super(),et(this,Jr),et(this,tp),et(this,mc),et(this,pc),et(this,gc),et(this,rf),et(this,no),et(this,nf),et(this,Qr,void 0),et(this,vr,void 0),et(this,hc,void 0),et(this,Ga,void 0),et(this,fc,void 0),et(this,ql,void 0),et(this,so,void 0),et(this,ro,void 0),et(this,Zr,void 0),et(this,sf,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(rT.content.cloneNode(!0)),yi(this,hc,this.shadowRoot.querySelectorAll('[part~="box"]')),yi(this,fc,this.shadowRoot.querySelector('[part~="preview-box"]')),yi(this,ql,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);yi(this,so,parseInt(e.getPropertyValue("--media-box-padding-left"))),yi(this,ro,parseInt(e.getPropertyValue("--media-box-padding-right"))),yi(this,vr,new DC(this.range,Xe(this,sf),60))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Ut.SEEK()),_t(this,Jr,pa).call(this),yi(this,Qr,this.getRootNode()),(e=Xe(this,Qr))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),_t(this,Jr,pa).call(this),(e=Xe(this,Qr))==null||e.removeEventListener("transitionstart",this),yi(this,Qr,null)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),t!=s&&(e===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(Xe(this,vr).update({start:jo(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),_t(this,Jr,pa).call(this),OC(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Xe(this,Zr),this.updateBar()))}get mediaChaptersCues(){return Xe(this,Zr)}set mediaChaptersCues(e){var t;yi(this,Zr,e),this.updateSegments((t=Xe(this,Zr))==null?void 0:t.map(s=>({start:jo(this,s.startTime),end:jo(this,s.endTime)})))}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}get mediaDuration(){return $e(this,T.MEDIA_DURATION)}set mediaDuration(e){nt(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){const e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(s=>+s)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}const t=e.map(s=>s.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;const[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;const[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Ve(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){qe(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return $e(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){nt(this,T.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return at(this,T.MEDIA_ENDED)}set mediaEnded(e){ot(this,T.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;const t=this.mediaBuffered;if(!t.length)return;let s;if(this.mediaEnded)s=1;else{const n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];s=jo(this,a)}const{style:r}=Ge(this.shadowRoot,"#highlight");r.setProperty("width",`${s*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;const t=Ge(this.shadowRoot,"#current-rail"),s=Ge(this.shadowRoot,'[part~="current-box"]'),r=_t(this,mc,ip).call(this,Xe(this,ql)),n=_t(this,pc,sp).call(this,r,this.range.valueAsNumber),a=_t(this,gc,rp).call(this,r,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${r.range.width}`),s.style.setProperty("--_box-shift",`${a}`),s.style.setProperty("--_box-width",`${r.box.width}px`),s.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":_t(this,nf,sT).call(this);break;case"pointermove":_t(this,rf,iT).call(this,e);break;case"pointerup":case"pointerleave":_t(this,no,vc).call(this,null);break;case"transitionstart":Ni(e.target,this)&&setTimeout(()=>_t(this,Jr,pa).call(this),0);break}}}Qr=new WeakMap;vr=new WeakMap;hc=new WeakMap;Ga=new WeakMap;fc=new WeakMap;ql=new WeakMap;so=new WeakMap;ro=new WeakMap;Zr=new WeakMap;Jr=new WeakSet;pa=function(){_t(this,tp,tT).call(this)?Xe(this,vr).start():Xe(this,vr).stop()};tp=new WeakSet;tT=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&QI(this)};sf=new WeakMap;mc=new WeakSet;ip=function(i){var e;const s=((e=this.getAttribute("bounds")?Rr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(r.left-s.left-n/2),o=s.right-r.left-n/2;return{box:{width:n,min:a,max:o},bounds:s,range:r}};pc=new WeakSet;sp=function(i,e){let t=`${e*100}%`;const{width:s,min:r,max:n}=i.box;if(!s)return t;if(Number.isNaN(r)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${r}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){const o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};gc=new WeakSet;rp=function(i,e){const{width:t,min:s,max:r}=i.box,n=e*i.range.width;if(n<s+Xe(this,so)){const a=i.range.left-i.bounds.left-Xe(this,so);return`${n-t/2+a}px`}if(n>r-Xe(this,ro)){const a=i.bounds.right-i.range.right-Xe(this,ro);return`${n+t/2-a-i.range.width}px`}return 0};rf=new WeakSet;iT=function(i){const e=[...Xe(this,hc)].some(c=>i.composedPath().includes(c));if(!this.dragging&&(e||!i.composedPath().includes(this))){_t(this,no,vc).call(this,null);return}const t=this.mediaSeekableEnd;if(!t)return;const s=Ge(this.shadowRoot,"#preview-rail"),r=Ge(this.shadowRoot,'[part~="preview-box"]'),n=_t(this,mc,ip).call(this,Xe(this,fc));let a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));const o=_t(this,pc,sp).call(this,n,a),l=_t(this,gc,rp).call(this,n,a);s.style.transform=`translateX(${o})`,s.style.setProperty("--_range-width",`${n.range.width}`),r.style.setProperty("--_box-shift",`${l}`),r.style.setProperty("--_box-width",`${n.box.width}px`);const d=Math.round(Xe(this,Ga))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(yi(this,Ga,a*t),_t(this,no,vc).call(this,Xe(this,Ga)))};no=new WeakSet;vc=function(i){this.dispatchEvent(new k.CustomEvent(K.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};nf=new WeakSet;sT=function(){Xe(this,vr).stop();const i=nT(this);this.dispatchEvent(new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};k.customElements.get("media-time-range")||k.customElements.define("media-time-range",PC);const NC=1,UC=i=>i.mediaMuted?0:i.mediaVolume,FC=({value:i})=>`${Math.round(i*100)}%`;class $C extends Qm{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{const e=this.range.value,t=new k.CustomEvent(K.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Ut.VOLUME())}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),(e===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=UC(this),this.range.setAttribute("aria-valuetext",FC(this.range)),this.updateBar())}get mediaVolume(){return $e(this,T.MEDIA_VOLUME,NC)}set mediaVolume(e){nt(this,T.MEDIA_VOLUME,e)}get mediaMuted(){return at(this,T.MEDIA_MUTED)}set mediaMuted(e){ot(this,T.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Ve(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){qe(this,T.MEDIA_VOLUME_UNAVAILABLE,e)}}k.customElements.get("media-volume-range")||k.customElements.define("media-volume-range",$C);var np=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ft=(i,e,t)=>(np(i,e,"read from private field"),t?t.call(i):e.get(i)),Pt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ii=(i,e,t,s)=>(np(i,e,"write to private field"),e.set(i,t),t),jt=(i,e,t)=>(np(i,e,"access private method"),t),Ti,bs,pn,ga,Yl,jl,af,en,of,zl,lf,va,Xl,Ql,df,cf,aT,ap,oT;const BC=`
1425
+ `;const jo=(i,e=i.mediaCurrentTime)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,s=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;if(Number.isNaN(s))return 0;const r=(e-t)/(s-t);return Math.max(0,Math.min(r,1))},nT=(i,e=i.range.valueAsNumber)=>{const t=Number.isFinite(i.mediaSeekableStart)?i.mediaSeekableStart:0,s=Number.isFinite(i.mediaDuration)?i.mediaDuration:i.mediaSeekableEnd;return Number.isNaN(s)?0:e*(s-t)+t};class NC extends Qm{constructor(){super(),et(this,Jr),et(this,tp),et(this,mc),et(this,pc),et(this,gc),et(this,rf),et(this,no),et(this,nf),et(this,Qr,void 0),et(this,vr,void 0),et(this,hc,void 0),et(this,Ga,void 0),et(this,fc,void 0),et(this,ql,void 0),et(this,so,void 0),et(this,ro,void 0),et(this,Zr,void 0),et(this,sf,t=>{this.dragging||(this.range.valueAsNumber=t,this.updateBar())}),this.container.appendChild(rT.content.cloneNode(!0)),yi(this,hc,this.shadowRoot.querySelectorAll('[part~="box"]')),yi(this,fc,this.shadowRoot.querySelector('[part~="preview-box"]')),yi(this,ql,this.shadowRoot.querySelector('[part~="current-box"]'));const e=getComputedStyle(this);yi(this,so,parseInt(e.getPropertyValue("--media-box-padding-left"))),yi(this,ro,parseInt(e.getPropertyValue("--media-box-padding-right"))),yi(this,vr,new MC(this.range,Xe(this,sf),60))}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_PAUSED,T.MEDIA_DURATION,T.MEDIA_SEEKABLE,T.MEDIA_CURRENT_TIME,T.MEDIA_PREVIEW_IMAGE,T.MEDIA_PREVIEW_TIME,T.MEDIA_PREVIEW_CHAPTER,T.MEDIA_BUFFERED,T.MEDIA_PLAYBACK_RATE,T.MEDIA_LOADING,T.MEDIA_ENDED]}connectedCallback(){var e;super.connectedCallback(),this.range.setAttribute("aria-label",Ut.SEEK()),_t(this,Jr,pa).call(this),yi(this,Qr,this.getRootNode()),(e=Xe(this,Qr))==null||e.addEventListener("transitionstart",this)}disconnectedCallback(){var e;super.disconnectedCallback(),_t(this,Jr,pa).call(this),(e=Xe(this,Qr))==null||e.removeEventListener("transitionstart",this),yi(this,Qr,null)}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),t!=s&&(e===T.MEDIA_CURRENT_TIME||e===T.MEDIA_PAUSED||e===T.MEDIA_ENDED||e===T.MEDIA_LOADING||e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE?(Xe(this,vr).update({start:jo(this),duration:this.mediaSeekableEnd-this.mediaSeekableStart,playbackRate:this.mediaPlaybackRate}),_t(this,Jr,pa).call(this),PC(this)):e===T.MEDIA_BUFFERED&&this.updateBufferedBar(),(e===T.MEDIA_DURATION||e===T.MEDIA_SEEKABLE)&&(this.mediaChaptersCues=Xe(this,Zr),this.updateBar()))}get mediaChaptersCues(){return Xe(this,Zr)}set mediaChaptersCues(e){var t;yi(this,Zr,e),this.updateSegments((t=Xe(this,Zr))==null?void 0:t.map(s=>({start:jo(this,s.startTime),end:jo(this,s.endTime)})))}get mediaPaused(){return at(this,T.MEDIA_PAUSED)}set mediaPaused(e){ot(this,T.MEDIA_PAUSED,e)}get mediaLoading(){return at(this,T.MEDIA_LOADING)}set mediaLoading(e){ot(this,T.MEDIA_LOADING,e)}get mediaDuration(){return $e(this,T.MEDIA_DURATION)}set mediaDuration(e){nt(this,T.MEDIA_DURATION,e)}get mediaCurrentTime(){return $e(this,T.MEDIA_CURRENT_TIME)}set mediaCurrentTime(e){nt(this,T.MEDIA_CURRENT_TIME,e)}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,1)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}get mediaBuffered(){const e=this.getAttribute(T.MEDIA_BUFFERED);return e?e.split(" ").map(t=>t.split(":").map(s=>+s)):[]}set mediaBuffered(e){if(!e){this.removeAttribute(T.MEDIA_BUFFERED);return}const t=e.map(s=>s.join(":")).join(" ");this.setAttribute(T.MEDIA_BUFFERED,t)}get mediaSeekable(){const e=this.getAttribute(T.MEDIA_SEEKABLE);if(e)return e.split(":").map(t=>+t)}set mediaSeekable(e){if(e==null){this.removeAttribute(T.MEDIA_SEEKABLE);return}this.setAttribute(T.MEDIA_SEEKABLE,e.join(":"))}get mediaSeekableEnd(){var e;const[,t=this.mediaDuration]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaSeekableStart(){var e;const[t=0]=(e=this.mediaSeekable)!=null?e:[];return t}get mediaPreviewImage(){return Ve(this,T.MEDIA_PREVIEW_IMAGE)}set mediaPreviewImage(e){qe(this,T.MEDIA_PREVIEW_IMAGE,e)}get mediaPreviewTime(){return $e(this,T.MEDIA_PREVIEW_TIME)}set mediaPreviewTime(e){nt(this,T.MEDIA_PREVIEW_TIME,e)}get mediaEnded(){return at(this,T.MEDIA_ENDED)}set mediaEnded(e){ot(this,T.MEDIA_ENDED,e)}updateBar(){super.updateBar(),this.updateBufferedBar(),this.updateCurrentBox()}updateBufferedBar(){var e;const t=this.mediaBuffered;if(!t.length)return;let s;if(this.mediaEnded)s=1;else{const n=this.mediaCurrentTime,[,a=this.mediaSeekableStart]=(e=t.find(([o,l])=>o<=n&&n<=l))!=null?e:[];s=jo(this,a)}const{style:r}=Ge(this.shadowRoot,"#highlight");r.setProperty("width",`${s*100}%`)}updateCurrentBox(){if(!this.shadowRoot.querySelector('slot[name="current"]').assignedElements().length)return;const t=Ge(this.shadowRoot,"#current-rail"),s=Ge(this.shadowRoot,'[part~="current-box"]'),r=_t(this,mc,ip).call(this,Xe(this,ql)),n=_t(this,pc,sp).call(this,r,this.range.valueAsNumber),a=_t(this,gc,rp).call(this,r,this.range.valueAsNumber);t.style.transform=`translateX(${n})`,t.style.setProperty("--_range-width",`${r.range.width}`),s.style.setProperty("--_box-shift",`${a}`),s.style.setProperty("--_box-width",`${r.box.width}px`),s.style.setProperty("visibility","initial")}handleEvent(e){switch(super.handleEvent(e),e.type){case"input":_t(this,nf,sT).call(this);break;case"pointermove":_t(this,rf,iT).call(this,e);break;case"pointerup":case"pointerleave":_t(this,no,vc).call(this,null);break;case"transitionstart":Ni(e.target,this)&&setTimeout(()=>_t(this,Jr,pa).call(this),0);break}}}Qr=new WeakMap;vr=new WeakMap;hc=new WeakMap;Ga=new WeakMap;fc=new WeakMap;ql=new WeakMap;so=new WeakMap;ro=new WeakMap;Zr=new WeakMap;Jr=new WeakSet;pa=function(){_t(this,tp,tT).call(this)?Xe(this,vr).start():Xe(this,vr).stop()};tp=new WeakSet;tT=function(){return this.isConnected&&!this.mediaPaused&&!this.mediaLoading&&!this.mediaEnded&&this.mediaSeekableEnd>0&&ZI(this)};sf=new WeakMap;mc=new WeakSet;ip=function(i){var e;const s=((e=this.getAttribute("bounds")?Rr(this,`#${this.getAttribute("bounds")}`):this.parentElement)!=null?e:this).getBoundingClientRect(),r=this.range.getBoundingClientRect(),n=i.offsetWidth,a=-(r.left-s.left-n/2),o=s.right-r.left-n/2;return{box:{width:n,min:a,max:o},bounds:s,range:r}};pc=new WeakSet;sp=function(i,e){let t=`${e*100}%`;const{width:s,min:r,max:n}=i.box;if(!s)return t;if(Number.isNaN(r)||(t=`max(${`calc(1 / var(--_range-width) * 100 * ${r}% + var(--media-box-padding-left))`}, ${t})`),!Number.isNaN(n)){const o=`calc(1 / var(--_range-width) * 100 * ${n}% - var(--media-box-padding-right))`;t=`min(${t}, ${o})`}return t};gc=new WeakSet;rp=function(i,e){const{width:t,min:s,max:r}=i.box,n=e*i.range.width;if(n<s+Xe(this,so)){const a=i.range.left-i.bounds.left-Xe(this,so);return`${n-t/2+a}px`}if(n>r-Xe(this,ro)){const a=i.bounds.right-i.range.right-Xe(this,ro);return`${n+t/2-a-i.range.width}px`}return 0};rf=new WeakSet;iT=function(i){const e=[...Xe(this,hc)].some(c=>i.composedPath().includes(c));if(!this.dragging&&(e||!i.composedPath().includes(this))){_t(this,no,vc).call(this,null);return}const t=this.mediaSeekableEnd;if(!t)return;const s=Ge(this.shadowRoot,"#preview-rail"),r=Ge(this.shadowRoot,'[part~="preview-box"]'),n=_t(this,mc,ip).call(this,Xe(this,fc));let a=(i.clientX-n.range.left)/n.range.width;a=Math.max(0,Math.min(1,a));const o=_t(this,pc,sp).call(this,n,a),l=_t(this,gc,rp).call(this,n,a);s.style.transform=`translateX(${o})`,s.style.setProperty("--_range-width",`${n.range.width}`),r.style.setProperty("--_box-shift",`${l}`),r.style.setProperty("--_box-width",`${n.box.width}px`);const d=Math.round(Xe(this,Ga))-Math.round(a*t);Math.abs(d)<1&&a>.01&&a<.99||(yi(this,Ga,a*t),_t(this,no,vc).call(this,Xe(this,Ga)))};no=new WeakSet;vc=function(i){this.dispatchEvent(new k.CustomEvent(K.MEDIA_PREVIEW_REQUEST,{composed:!0,bubbles:!0,detail:i}))};nf=new WeakSet;sT=function(){Xe(this,vr).stop();const i=nT(this);this.dispatchEvent(new k.CustomEvent(K.MEDIA_SEEK_REQUEST,{composed:!0,bubbles:!0,detail:i}))};k.customElements.get("media-time-range")||k.customElements.define("media-time-range",NC);const UC=1,FC=i=>i.mediaMuted?0:i.mediaVolume,$C=({value:i})=>`${Math.round(i*100)}%`;class BC extends Qm{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_VOLUME,T.MEDIA_MUTED,T.MEDIA_VOLUME_UNAVAILABLE]}constructor(){super(),this.range.addEventListener("input",()=>{const e=this.range.value,t=new k.CustomEvent(K.MEDIA_VOLUME_REQUEST,{composed:!0,bubbles:!0,detail:e});this.dispatchEvent(t)})}connectedCallback(){super.connectedCallback(),this.range.setAttribute("aria-label",Ut.VOLUME())}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),(e===T.MEDIA_VOLUME||e===T.MEDIA_MUTED)&&(this.range.valueAsNumber=FC(this),this.range.setAttribute("aria-valuetext",$C(this.range)),this.updateBar())}get mediaVolume(){return $e(this,T.MEDIA_VOLUME,UC)}set mediaVolume(e){nt(this,T.MEDIA_VOLUME,e)}get mediaMuted(){return at(this,T.MEDIA_MUTED)}set mediaMuted(e){ot(this,T.MEDIA_MUTED,e)}get mediaVolumeUnavailable(){return Ve(this,T.MEDIA_VOLUME_UNAVAILABLE)}set mediaVolumeUnavailable(e){qe(this,T.MEDIA_VOLUME_UNAVAILABLE,e)}}k.customElements.get("media-volume-range")||k.customElements.define("media-volume-range",BC);var np=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ft=(i,e,t)=>(np(i,e,"read from private field"),t?t.call(i):e.get(i)),Pt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ii=(i,e,t,s)=>(np(i,e,"write to private field"),e.set(i,t),t),jt=(i,e,t)=>(np(i,e,"access private method"),t),Ti,bs,pn,ga,Yl,jl,af,en,of,zl,lf,va,Xl,Ql,df,cf,aT,ap,oT;const GC=`
1426
1426
  <svg aria-hidden="true" viewBox="0 1 24 24" part="select-indicator indicator">
1427
1427
  <path d="m10 15.17 9.193-9.191 1.414 1.414-10.606 10.606-6.364-6.364 1.414-1.414 4.95 4.95Z"/>
1428
1428
  </svg>`;function $n(i,e,t){const s=z.createElement("media-chrome-option");s.part.add("option"),s.value=e,s.selected=t;const r=z.createElement("span");return r.textContent=i,s.append(r),s}function Er(i,e){let t=i.querySelector(`:scope > [slot="${e}"]`);return(t==null?void 0:t.nodeName)=="SLOT"&&(t=t.assignedElements({flatten:!0})[0]),t?(t=t.cloneNode(!0),t.removeAttribute("slot"),t):i.shadowRoot.querySelector(`[name="${e}"] > svg`).cloneNode(!0)}const lT=z.createElement("template");lT.innerHTML=`
@@ -1504,7 +1504,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1504
1504
  </style>
1505
1505
  <slot name="header"></slot>
1506
1506
  <slot id="container"></slot>
1507
- <slot name="select-indicator" hidden>${BC}</slot>
1507
+ <slot name="select-indicator" hidden>${GC}</slot>
1508
1508
  `;class mo extends k.HTMLElement{constructor(e={}){super(),Pt(this,jl),Pt(this,zl),Pt(this,va),Pt(this,Ql),Pt(this,cf),Pt(this,ap),Pt(this,Ti,void 0),Pt(this,bs,""),Pt(this,pn,null),Pt(this,ga,!1),Pt(this,Yl,t=>{this.handleClick(t)}),Pt(this,en,t=>{const{key:s}=t;if(s==="Escape"){this.removeEventListener("keyup",ft(this,en));return}if(s==="Meta"){ii(this,ga,!1);return}jt(this,jl,af).call(this,t)}),Pt(this,of,t=>{const{key:s,altKey:r}=t;if(r){this.removeEventListener("keyup",ft(this,en));return}if(s==="Meta"){ii(this,ga,!0);return}if(this.keysUsed.includes(s)&&t.preventDefault(),ft(this,ga)&&this.keysUsed.includes(s)){jt(this,jl,af).call(this,t);return}this.addEventListener("keyup",ft(this,en),{once:!0})}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.nativeEl=lT.content.cloneNode(!0),e.slotTemplate&&this.nativeEl.append(e.slotTemplate.content.cloneNode(!0)),this.shadowRoot.append(this.nativeEl)),this.container=this.shadowRoot.querySelector("#container"),this.container.addEventListener("slotchange",t=>{for(let s of t.target.assignedNodes({flatten:!0}))s.nodeType===3&&s.textContent.trim()===""&&s.remove()})}static get observedAttributes(){return["disabled","style",ue.MEDIA_CONTROLLER]}static formatOptionText(e){return e}formatOptionText(e,t){return this.constructor.formatOptionText(e,t)}get options(){var e;let t=this.querySelectorAll("media-chrome-option");return t.length||(t=(e=this.container)==null?void 0:e.querySelectorAll("media-chrome-option")),Array.from(t)}get selectedOptions(){return this.options.filter(e=>e.selected)}get value(){var e,t;return(t=(e=this.selectedOptions[0])==null?void 0:e.value)!=null?t:""}set value(e){const t=this.options.find(s=>s.value===e);t&&jt(this,Ql,df).call(this,t)}focus(){var e;(e=this.selectedOptions[0])==null||e.focus()}enable(){this.addEventListener("click",ft(this,Yl)),this.addEventListener("keydown",ft(this,of))}disable(){this.removeEventListener("click",ft(this,Yl)),this.removeEventListener("keyup",ft(this,en))}attributeChangedCallback(e,t,s){var r,n,a,o,l;e==="style"&&s!==t?jt(this,zl,lf).call(this):e===ue.MEDIA_CONTROLLER?(t&&((n=(r=ft(this,Ti))==null?void 0:r.unassociateElement)==null||n.call(r,this),ii(this,Ti,null)),s&&this.isConnected&&(ii(this,Ti,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=ft(this,Ti))==null?void 0:o.associateElement)==null||l.call(o,this))):e==="disabled"&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){var e,t,s;jt(this,zl,lf).call(this),this.hasAttribute("disabled")||this.enable(),this.hasAttribute("role")||this.setAttribute("role","listbox");const r=this.getAttribute(ue.MEDIA_CONTROLLER);r&&(ii(this,Ti,(e=this.getRootNode())==null?void 0:e.getElementById(r)),(s=(t=ft(this,Ti))==null?void 0:t.associateElement)==null||s.call(t,this))}disconnectedCallback(){var e,t;this.disable(),(t=(e=ft(this,Ti))==null?void 0:e.unassociateElement)==null||t.call(e,this),ii(this,Ti,null)}get keysUsed(){return["Enter"," ","ArrowDown","ArrowUp","Home","End"]}handleSelection(e,t){const s=jt(this,va,Xl).call(this,e);s&&jt(this,Ql,df).call(this,s,t)}handleMovement(e){const{key:t}=e,s=this.options;let r=jt(this,va,Xl).call(this,e);r||(r=s.filter(a=>a.getAttribute("tabindex")==="0")[0]);let n;switch(t){case"ArrowDown":n=r.nextElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.nextElementSibling);break;case"ArrowUp":n=r.previousElementSibling,n!=null&&n.hasAttribute("disabled")&&(n=n.previousElementSibling);break;case"Home":n=s[0];break;case"End":n=s[s.length-1];break;default:n=jt(this,cf,aT).call(this,t);break}n&&(s.forEach(a=>a.setAttribute("tabindex","-1")),n.setAttribute("tabindex","0"),n.focus())}handleClick(e){const t=jt(this,va,Xl).call(this,e);!t||t.hasAttribute("disabled")||(this.options.forEach(s=>s.setAttribute("tabindex","-1")),t.setAttribute("tabindex","0"),this.handleSelection(e,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"))}}Ti=new WeakMap;bs=new WeakMap;pn=new WeakMap;ga=new WeakMap;Yl=new WeakMap;jl=new WeakSet;af=function(i){const{key:e}=i;e==="Enter"||e===" "?this.handleSelection(i,this.hasAttribute("aria-multiselectable")&&this.getAttribute("aria-multiselectable")==="true"):this.handleMovement(i)};en=new WeakMap;of=new WeakMap;zl=new WeakSet;lf=function(){var i;const e=this.shadowRoot.querySelector("#layout-row"),t=((i=getComputedStyle(this).getPropertyValue("--media-listbox-layout"))==null?void 0:i.trim())==="row";e.setAttribute("media",t?"":"width:0")};va=new WeakSet;Xl=function(i){const e=i.composedPath(),t=e.findIndex(s=>s.nodeName==="MEDIA-CHROME-OPTION");return e[t]};Ql=new WeakSet;df=function(i,e){const t=[...this.selectedOptions];(!this.hasAttribute("aria-multiselectable")||this.getAttribute("aria-multiselectable")!=="true")&&this.options.forEach(s=>s.selected=!1),e?i.selected=!i.selected:i.selected=!0,this.selectedOptions.some((s,r)=>s!=t[r])&&this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0}))};cf=new WeakSet;aT=function(i){jt(this,ap,oT).call(this);const e=this.options,t=e.findIndex(d=>d.getAttribute("tabindex")==="0");ii(this,bs,ft(this,bs)+i);const s=ft(this,bs).split("").every(d=>d===i),r=e.slice(t+(s?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(ft(this,bs))),n=e.slice(0,t-(s?1:0)).filter(d=>d.textContent.toLowerCase().startsWith(ft(this,bs)));let a=[],o=[];return s&&(a=e.slice(t+(s?1:0)).filter(d=>d.textContent.startsWith(i)),o=e.slice(0,t-(s?1:0)).filter(d=>d.textContent.startsWith(i))),[...r,...n,...a,...o][0]};ap=new WeakSet;oT=function(){clearTimeout(ft(this,pn)),ii(this,pn,null),ii(this,pn,setTimeout(()=>{ii(this,bs,""),ii(this,pn,null)},500))};k.customElements.get("media-chrome-listbox")||k.customElements.define("media-chrome-listbox",mo);var op=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},uf=(i,e,t)=>(op(i,e,"read from private field"),e.get(i)),Ru=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},wu=(i,e,t,s)=>(op(i,e,"write to private field"),e.set(i,t),t),Ig=(i,e,t)=>(op(i,e,"access private method"),t),Zl,Sn,Jl,hf;const dT=z.createElement("template");dT.innerHTML=`
1509
1509
  <style>
1510
1510
  :host {
@@ -1543,7 +1543,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1543
1543
  }
1544
1544
  </style>
1545
1545
  <slot></slot>
1546
- `;const ns={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"};class GC extends k.HTMLElement{constructor(){super(),Ru(this,Jl),Ru(this,Zl,!1),Ru(this,Sn,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(dT.content.cloneNode(!0)))}static get observedAttributes(){return[ns.DISABLED,ns.SELECTED,ns.VALUE]}get value(){var e;return(e=this.getAttribute(ns.VALUE))!=null?e:this.text}set value(e){this.setAttribute(ns.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){wu(this,Zl,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,s){e===ns.SELECTED&&!uf(this,Zl)?this.setAttribute("aria-selected",s!=null?"true":"false"):e===ns.DISABLED&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(ns.DISABLED)||this.enable(),this.setAttribute("role","option"),wu(this,Sn,ff(this,this.parentNode)),Ig(this,Jl,hf).call(this)}disconnectedCallback(){this.disable(),Ig(this,Jl,hf).call(this),wu(this,Sn,null)}handleClick(){}}Zl=new WeakMap;Sn=new WeakMap;Jl=new WeakSet;hf=function(){var i;const e=(i=uf(this,Sn))==null?void 0:i.options;if(!e)return;let t=e.filter(s=>s.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),uf(this,Sn).getAttribute("aria-multiselectable")!=="true"&&e.forEach(s=>{s.setAttribute("tabindex","-1"),s.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function ff(i,e){if(!i)return null;const{host:t}=i.getRootNode();return!e&&t?ff(i,t):e!=null&&e.options?e:ff(e,e==null?void 0:e.parentNode)}k.customElements.get("media-chrome-option")||k.customElements.define("media-chrome-option",GC);var lp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},X=(i,e,t)=>(lp(i,e,"read from private field"),t?t.call(i):e.get(i)),kt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ui=(i,e,t,s)=>(lp(i,e,"write to private field"),e.set(i,t),t),er=(i,e,t)=>(lp(i,e,"access private method"),t),_i,Tt,Ea,Ue,si,tn,ed,td,id,sd,rd,mf,dp,cT,gn,Ha,br;const uT=z.createElement("template");uT.innerHTML=`
1546
+ `;const ns={VALUE:"value",SELECTED:"selected",DISABLED:"disabled"};class HC extends k.HTMLElement{constructor(){super(),Ru(this,Jl),Ru(this,Zl,!1),Ru(this,Sn,void 0),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(dT.content.cloneNode(!0)))}static get observedAttributes(){return[ns.DISABLED,ns.SELECTED,ns.VALUE]}get value(){var e;return(e=this.getAttribute(ns.VALUE))!=null?e:this.text}set value(e){this.setAttribute(ns.VALUE,e)}get text(){var e;return((e=this.textContent)!=null?e:"").trim()}get selected(){return this.getAttribute("aria-selected")==="true"}set selected(e){wu(this,Zl,!0),this.setAttribute("aria-selected",e?"true":"false"),e?this.part.add("option-selected"):this.part.remove("option-selected")}enable(){this.hasAttribute("tabindex")||this.setAttribute("tabindex",-1),this.hasAttribute("aria-selected")||this.setAttribute("aria-selected","false")}disable(){this.removeAttribute("tabindex")}attributeChangedCallback(e,t,s){e===ns.SELECTED&&!uf(this,Zl)?this.setAttribute("aria-selected",s!=null?"true":"false"):e===ns.DISABLED&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){this.hasAttribute(ns.DISABLED)||this.enable(),this.setAttribute("role","option"),wu(this,Sn,ff(this,this.parentNode)),Ig(this,Jl,hf).call(this)}disconnectedCallback(){this.disable(),Ig(this,Jl,hf).call(this),wu(this,Sn,null)}handleClick(){}}Zl=new WeakMap;Sn=new WeakMap;Jl=new WeakSet;hf=function(){var i;const e=(i=uf(this,Sn))==null?void 0:i.options;if(!e)return;let t=e.filter(s=>s.getAttribute("aria-selected")==="true").pop();t||(t=e[0]),uf(this,Sn).getAttribute("aria-multiselectable")!=="true"&&e.forEach(s=>{s.setAttribute("tabindex","-1"),s.setAttribute("aria-selected","false")}),t==null||t.setAttribute("tabindex","0"),t==null||t.setAttribute("aria-selected","true")};function ff(i,e){if(!i)return null;const{host:t}=i.getRootNode();return!e&&t?ff(i,t):e!=null&&e.options?e:ff(e,e==null?void 0:e.parentNode)}k.customElements.get("media-chrome-option")||k.customElements.define("media-chrome-option",HC);var lp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},X=(i,e,t)=>(lp(i,e,"read from private field"),t?t.call(i):e.get(i)),kt=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ui=(i,e,t,s)=>(lp(i,e,"write to private field"),e.set(i,t),t),er=(i,e,t)=>(lp(i,e,"access private method"),t),_i,Tt,Ea,Ue,si,tn,ed,td,id,sd,rd,mf,dp,cT,gn,Ha,br;const uT=z.createElement("template");uT.innerHTML=`
1547
1547
  <style>
1548
1548
  :host {
1549
1549
  font: var(--media-font,
@@ -1594,21 +1594,21 @@ svg, img, ::slotted(svg), ::slotted(img) {
1594
1594
  <slot></slot>
1595
1595
  </media-chrome-listbox>
1596
1596
  </slot>
1597
- `;class po extends k.HTMLElement{constructor(){var e;super(),kt(this,rd),kt(this,dp),kt(this,gn),kt(this,_i,void 0),kt(this,Tt,void 0),kt(this,Ea,void 0),kt(this,Ue,void 0),kt(this,si,void 0),kt(this,tn,t=>{const{key:s}=t;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",X(this,tn));return}t.composedPath().includes(X(this,Tt))&&(s==="Enter"||s===" ")?er(this,rd,mf).call(this):s==="Escape"&&er(this,gn,Ha).call(this)}),kt(this,ed,t=>{const{metaKey:s,altKey:r,key:n}=t;if(s||r||!this.keysUsed.includes(n)){this.removeEventListener("keyup",X(this,tn));return}t.preventDefault(),this.addEventListener("keyup",X(this,tn),{once:!0})}),kt(this,td,t=>{t.composedPath().includes(this)||er(this,gn,Ha).call(this)}),kt(this,id,t=>{t.composedPath().includes(X(this,Tt))&&er(this,rd,mf).call(this)}),kt(this,sd,()=>{er(this,gn,Ha).call(this)}),kt(this,br,()=>{if(X(this,Ue).offsetWidth===0)return;const t=X(this,Ue).offsetWidth,s=X(this,Tt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||X(this,Tt).hasAttribute("mediacontroller")||X(this,Ue).hasAttribute("mediacontroller")){X(this,Ue).style.zIndex="1",X(this,Ue).style.bottom="unset",X(this,Ue).style.right=null,X(this,Ue).style.left="0",X(this,Ue).style.top=`${s.height}px`;return}const n=Wa(this).getBoundingClientRect(),a=s.x+t,o=Math.max(s.right-a,s.right-n.right);X(this,Ue).style.left=null,X(this,Ue).style.right=`${o}px`,X(this,Ue).style.maxHeight=`${n.height-s.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(uT.content.cloneNode(!0))),(e=this.init)==null||e.call(this),ui(this,Tt,this.shadowRoot.querySelector("[part=button]")),ui(this,Ue,this.shadowRoot.querySelector("[part=listbox]")),ui(this,Ea,this.shadowRoot.querySelector("slot[name=button]")),X(this,Ea).addEventListener("slotchange",()=>{const t=X(this,Ea).assignedElements()[0];if(!t)return;ui(this,Tt,t),X(this,Tt).preventClick=!0,this.hasAttribute("disabled")||X(this,Tt).hasAttribute("disabled")?this.disable():(this.enable(),X(this,Tt).setAttribute("aria-haspopup","listbox"))}),ui(this,si,this.shadowRoot.querySelector("slot[name=listbox]")),X(this,si).addEventListener("slotchange",()=>{ui(this,Ue,X(this,si).assignedElements()[0]||X(this,Ue))})}static get observedAttributes(){return["disabled",ue.MEDIA_CONTROLLER]}enable(){X(this,Tt).toggleAttribute("disabled",!1),this.addEventListener("change",X(this,sd)),this.addEventListener("keydown",X(this,ed)),this.addEventListener("click",X(this,id)),z.addEventListener("click",X(this,td))}disable(){X(this,Tt).toggleAttribute("disabled",!0),this.removeEventListener("change",X(this,sd)),this.removeEventListener("keydown",X(this,ed)),this.removeEventListener("keyup",X(this,tn)),this.removeEventListener("click",X(this,id)),z.removeEventListener("click",X(this,td))}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(r=X(this,_i))==null?void 0:r.unassociateElement)==null||n.call(r,this),ui(this,_i,null),X(this,Ue).removeAttribute(ue.MEDIA_CONTROLLER)),s&&this.isConnected&&(ui(this,_i,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=X(this,_i))==null?void 0:o.associateElement)==null||l.call(o,this),X(this,Ue).setAttribute(ue.MEDIA_CONTROLLER,s))):e==="disabled"&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(ui(this,_i,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=X(this,_i))==null?void 0:t.associateElement)==null||s.call(t,this),X(this,Ue).setAttribute(ue.MEDIA_CONTROLLER,n)),this.hasAttribute("disabled")||this.enable(),X(this,si).hidden||xs(Wa(this),X(this,br))}disconnectedCallback(){var e,t;Ar(Wa(this),X(this,br)),this.disable(),(t=(e=X(this,_i))==null?void 0:e.unassociateElement)==null||t.call(e,this),ui(this,_i,null),X(this,Ue).removeAttribute(ue.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}}_i=new WeakMap;Tt=new WeakMap;Ea=new WeakMap;Ue=new WeakMap;si=new WeakMap;tn=new WeakMap;ed=new WeakMap;td=new WeakMap;id=new WeakMap;sd=new WeakMap;rd=new WeakSet;mf=function(){X(this,si).hidden?er(this,dp,cT).call(this):er(this,gn,Ha).call(this)};dp=new WeakSet;cT=function(){X(this,si).hidden&&(X(this,si).hidden=!1,X(this,Tt).setAttribute("aria-expanded","true"),X(this,br).call(this),X(this,Ue).focus(),xs(Wa(this),X(this,br)))};gn=new WeakSet;Ha=function(){if(X(this,si).hidden)return;Ar(Wa(this),X(this,br));const i=Rc();X(this,si).hidden=!0,X(this,Tt).setAttribute("aria-expanded","false"),Ni(X(this,Ue),i)&&X(this,Tt).focus()};br=new WeakMap;function Wa(i){var e;return(e=i.getAttribute("bounds")?Rr(i,`#${i.getAttribute("bounds")}`):HC(i)||i.parentElement)!=null?e:i}function HC(i){var e;const t=i.getAttribute(ue.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):Rr(i,"media-controller")}k.customElements.get("media-chrome-selectmenu")||k.customElements.define("media-chrome-selectmenu",po);var cp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},WC=(i,e,t)=>(cp(i,e,"read from private field"),t?t.call(i):e.get(i)),Cu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},KC=(i,e,t,s)=>(cp(i,e,"write to private field"),e.set(i,t),t),Du=(i,e,t)=>(cp(i,e,"access private method"),t),Ec,pf,hT,nd,gf;const VC=`
1597
+ `;class po extends k.HTMLElement{constructor(){var e;super(),kt(this,rd),kt(this,dp),kt(this,gn),kt(this,_i,void 0),kt(this,Tt,void 0),kt(this,Ea,void 0),kt(this,Ue,void 0),kt(this,si,void 0),kt(this,tn,t=>{const{key:s}=t;if(!this.keysUsed.includes(s)){this.removeEventListener("keyup",X(this,tn));return}t.composedPath().includes(X(this,Tt))&&(s==="Enter"||s===" ")?er(this,rd,mf).call(this):s==="Escape"&&er(this,gn,Ha).call(this)}),kt(this,ed,t=>{const{metaKey:s,altKey:r,key:n}=t;if(s||r||!this.keysUsed.includes(n)){this.removeEventListener("keyup",X(this,tn));return}t.preventDefault(),this.addEventListener("keyup",X(this,tn),{once:!0})}),kt(this,td,t=>{t.composedPath().includes(this)||er(this,gn,Ha).call(this)}),kt(this,id,t=>{t.composedPath().includes(X(this,Tt))&&er(this,rd,mf).call(this)}),kt(this,sd,()=>{er(this,gn,Ha).call(this)}),kt(this,br,()=>{if(X(this,Ue).offsetWidth===0)return;const t=X(this,Ue).offsetWidth,s=X(this,Tt).getBoundingClientRect();if(this.hasAttribute("mediacontroller")||X(this,Tt).hasAttribute("mediacontroller")||X(this,Ue).hasAttribute("mediacontroller")){X(this,Ue).style.zIndex="1",X(this,Ue).style.bottom="unset",X(this,Ue).style.right=null,X(this,Ue).style.left="0",X(this,Ue).style.top=`${s.height}px`;return}const n=Wa(this).getBoundingClientRect(),a=s.x+t,o=Math.max(s.right-a,s.right-n.right);X(this,Ue).style.left=null,X(this,Ue).style.right=`${o}px`,X(this,Ue).style.maxHeight=`${n.height-s.height}px`}),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.appendChild(uT.content.cloneNode(!0))),(e=this.init)==null||e.call(this),ui(this,Tt,this.shadowRoot.querySelector("[part=button]")),ui(this,Ue,this.shadowRoot.querySelector("[part=listbox]")),ui(this,Ea,this.shadowRoot.querySelector("slot[name=button]")),X(this,Ea).addEventListener("slotchange",()=>{const t=X(this,Ea).assignedElements()[0];if(!t)return;ui(this,Tt,t),X(this,Tt).preventClick=!0,this.hasAttribute("disabled")||X(this,Tt).hasAttribute("disabled")?this.disable():(this.enable(),X(this,Tt).setAttribute("aria-haspopup","listbox"))}),ui(this,si,this.shadowRoot.querySelector("slot[name=listbox]")),X(this,si).addEventListener("slotchange",()=>{ui(this,Ue,X(this,si).assignedElements()[0]||X(this,Ue))})}static get observedAttributes(){return["disabled",ue.MEDIA_CONTROLLER]}enable(){X(this,Tt).toggleAttribute("disabled",!1),this.addEventListener("change",X(this,sd)),this.addEventListener("keydown",X(this,ed)),this.addEventListener("click",X(this,id)),z.addEventListener("click",X(this,td))}disable(){X(this,Tt).toggleAttribute("disabled",!0),this.removeEventListener("change",X(this,sd)),this.removeEventListener("keydown",X(this,ed)),this.removeEventListener("keyup",X(this,tn)),this.removeEventListener("click",X(this,id)),z.removeEventListener("click",X(this,td))}attributeChangedCallback(e,t,s){var r,n,a,o,l;e===ue.MEDIA_CONTROLLER?(t&&((n=(r=X(this,_i))==null?void 0:r.unassociateElement)==null||n.call(r,this),ui(this,_i,null),X(this,Ue).removeAttribute(ue.MEDIA_CONTROLLER)),s&&this.isConnected&&(ui(this,_i,(a=this.getRootNode())==null?void 0:a.getElementById(s)),(l=(o=X(this,_i))==null?void 0:o.associateElement)==null||l.call(o,this),X(this,Ue).setAttribute(ue.MEDIA_CONTROLLER,s))):e==="disabled"&&s!==t&&(s==null?this.enable():this.disable())}connectedCallback(){var e,t,s;const{style:r}=Ge(this.shadowRoot,":host");r.setProperty("display",`var(--media-control-display, var(--${this.localName}-display, inline-flex))`);const n=this.getAttribute(ue.MEDIA_CONTROLLER);n&&(ui(this,_i,(e=this.getRootNode())==null?void 0:e.getElementById(n)),(s=(t=X(this,_i))==null?void 0:t.associateElement)==null||s.call(t,this),X(this,Ue).setAttribute(ue.MEDIA_CONTROLLER,n)),this.hasAttribute("disabled")||this.enable(),X(this,si).hidden||xs(Wa(this),X(this,br))}disconnectedCallback(){var e,t;Ar(Wa(this),X(this,br)),this.disable(),(t=(e=X(this,_i))==null?void 0:e.unassociateElement)==null||t.call(e,this),ui(this,_i,null),X(this,Ue).removeAttribute(ue.MEDIA_CONTROLLER)}get keysUsed(){return["Enter","Escape"," ","ArrowUp","ArrowDown","f","c","k","m"]}}_i=new WeakMap;Tt=new WeakMap;Ea=new WeakMap;Ue=new WeakMap;si=new WeakMap;tn=new WeakMap;ed=new WeakMap;td=new WeakMap;id=new WeakMap;sd=new WeakMap;rd=new WeakSet;mf=function(){X(this,si).hidden?er(this,dp,cT).call(this):er(this,gn,Ha).call(this)};dp=new WeakSet;cT=function(){X(this,si).hidden&&(X(this,si).hidden=!1,X(this,Tt).setAttribute("aria-expanded","true"),X(this,br).call(this),X(this,Ue).focus(),xs(Wa(this),X(this,br)))};gn=new WeakSet;Ha=function(){if(X(this,si).hidden)return;Ar(Wa(this),X(this,br));const i=Rc();X(this,si).hidden=!0,X(this,Tt).setAttribute("aria-expanded","false"),Ni(X(this,Ue),i)&&X(this,Tt).focus()};br=new WeakMap;function Wa(i){var e;return(e=i.getAttribute("bounds")?Rr(i,`#${i.getAttribute("bounds")}`):WC(i)||i.parentElement)!=null?e:i}function WC(i){var e;const t=i.getAttribute(ue.MEDIA_CONTROLLER);return t?(e=i.getRootNode())==null?void 0:e.getElementById(t):Rr(i,"media-controller")}k.customElements.get("media-chrome-selectmenu")||k.customElements.define("media-chrome-selectmenu",po);var cp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},KC=(i,e,t)=>(cp(i,e,"read from private field"),t?t.call(i):e.get(i)),Cu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},VC=(i,e,t,s)=>(cp(i,e,"write to private field"),e.set(i,t),t),Du=(i,e,t)=>(cp(i,e,"access private method"),t),Ec,pf,hT,nd,gf;const qC=`
1598
1598
  <svg aria-hidden="true" viewBox="0 0 26 24" part="captions-indicator indicator">
1599
1599
  <path d="M22.83 5.68a2.58 2.58 0 0 0-2.3-2.5c-3.62-.24-11.44-.24-15.06 0a2.58 2.58 0 0 0-2.3 2.5c-.23 4.21-.23 8.43 0 12.64a2.58 2.58 0 0 0 2.3 2.5c3.62.24 11.44.24 15.06 0a2.58 2.58 0 0 0 2.3-2.5c.23-4.21.23-8.43 0-12.64Zm-11.39 9.45a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.92 3.92 0 0 1 .92-2.77 3.18 3.18 0 0 1 2.43-1 2.94 2.94 0 0 1 2.13.78c.364.359.62.813.74 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.17 1.61 1.61 0 0 0-1.29.58 2.79 2.79 0 0 0-.5 1.89 3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.48 1.48 0 0 0 1-.37 2.1 2.1 0 0 0 .59-1.14l1.4.44a3.23 3.23 0 0 1-1.07 1.69Zm7.22 0a3.07 3.07 0 0 1-1.91.57 3.06 3.06 0 0 1-2.34-1 3.75 3.75 0 0 1-.92-2.67 3.88 3.88 0 0 1 .93-2.77 3.14 3.14 0 0 1 2.42-1 3 3 0 0 1 2.16.82 2.8 2.8 0 0 1 .73 1.31l-1.43.35a1.49 1.49 0 0 0-1.51-1.21 1.61 1.61 0 0 0-1.29.58A2.79 2.79 0 0 0 15 12a3 3 0 0 0 .49 1.93 1.61 1.61 0 0 0 1.27.58 1.44 1.44 0 0 0 1-.37 2.1 2.1 0 0 0 .6-1.15l1.4.44a3.17 3.17 0 0 1-1.1 1.7Z"/>
1600
1600
  </svg>`,fT=z.createElement("template");fT.innerHTML=`
1601
- <slot name="captions-indicator" hidden>${VC}</slot>
1602
- `;class qC extends mo{constructor(){super({slotTemplate:fT}),Cu(this,pf),Cu(this,nd),Cu(this,Ec,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_LIST&&t!==s?Du(this,pf,hT).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==s?this.value=s:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Du(this,nd,gf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Du(this,nd,gf))}get mediaSubtitlesList(){return Rg(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){wg(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Rg(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){wg(this,T.MEDIA_SUBTITLES_SHOWING,e)}}Ec=new WeakMap;pf=new WeakSet;hT=function(){var i;if(WC(this,Ec)===JSON.stringify(this.mediaSubtitlesList))return;KC(this,Ec,JSON.stringify(this.mediaSubtitlesList));const e=this.shadowRoot.querySelector("#container");e.textContent="";const t=!this.value,s=$n(this.formatOptionText("Off"),"off",t);s.prepend(Er(this,"select-indicator")),e.append(s);const r=this.mediaSubtitlesList;for(const n of r){const a=$n(this.formatOptionText(n.label,n),Za(n),this.value==Za(n));a.prepend(Er(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(Er(this,"captions-indicator")),e.append(a)}};nd=new WeakSet;gf=function(){const i=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new k.CustomEvent(K.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;const s=new k.CustomEvent(K.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};const Rg=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},wg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-listbox")||k.customElements.define("media-captions-listbox",qC);class YC extends po{init(){const e=z.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-captions-selectmenu")||k.customElements.define("media-captions-selectmenu",YC);var mT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zo=(i,e,t)=>(mT(i,e,"read from private field"),t?t.call(i):e.get(i)),Mu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Jn=(i,e,t)=>(mT(i,e,"access private method"),t),sn,ba,ad,od,vf;const Ou={RATES:"rates"};class jC extends mo{constructor(){super(),Mu(this,ba),Mu(this,od),Mu(this,sn,new uo(this,Ou.RATES,{defaultValue:Zm})),Jn(this,ba,ad).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",T.MEDIA_PLAYBACK_RATE,Ou.RATES]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PLAYBACK_RATE&&t!=s?this.value=s:e===Ou.RATES&&t!=s&&(zo(this,sn).value=s,Jn(this,ba,ad).call(this))}get rates(){return zo(this,sn)}set rates(e){e?Array.isArray(e)&&(zo(this,sn).value=e.join(" ")):zo(this,sn).value="",Jn(this,ba,ad).call(this)}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,mn)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Jn(this,od,vf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Jn(this,od,vf))}}sn=new WeakMap;ba=new WeakSet;ad=function(){const i=this.shadowRoot.querySelector("#container");i.textContent="";for(const e of this.rates){const t=$n(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(Er(this,"select-indicator")),i.append(t)}};od=new WeakSet;vf=function(){if(!this.value)return;const i=new k.CustomEvent(K.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-playback-rate-listbox")||k.customElements.define("media-playback-rate-listbox",jC);class zC extends po{init(){const e=z.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-playback-rate-selectmenu")||k.customElements.define("media-playback-rate-selectmenu",zC);var up=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pT=(i,e,t)=>(up(i,e,"read from private field"),t?t.call(i):e.get(i)),Xo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ef=(i,e,t,s)=>(up(i,e,"write to private field"),e.set(i,t),t),Qo=(i,e,t)=>(up(i,e,"access private method"),t),ya,bc,ld,bf,dd,yf;class XC extends mo{constructor(){super(...arguments),Xo(this,ld),Xo(this,dd),Xo(this,ya,[]),Xo(this,bc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_RENDITION_SELECTED&&t!==s?this.value=s??"auto":e===T.MEDIA_RENDITION_LIST&&t!==s&&(Ef(this,ya,sb(s)),Qo(this,ld,bf).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Qo(this,dd,yf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Qo(this,dd,yf))}get mediaRenditionList(){return pT(this,ya)}set mediaRenditionList(e){Ef(this,ya,e),Qo(this,ld,bf).call(this)}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}ya=new WeakMap;bc=new WeakMap;ld=new WeakSet;bf=function(){if(pT(this,bc)===JSON.stringify(this.mediaRenditionList))return;Ef(this,bc,JSON.stringify(this.mediaRenditionList));const i=this.mediaRenditionList.sort((r,n)=>n.height-r.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(const r of i){const n=this.formatOptionText(`${Math.min(r.width,r.height)}p`,r),a=$n(n,`${r.id}`,r.selected&&!t);a.prepend(Er(this,"select-indicator")),e.append(a)}const s=$n(this.formatOptionText("Auto"),"auto",t);s.prepend(Er(this,"select-indicator")),e.append(s)};dd=new WeakSet;yf=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-rendition-listbox")||k.customElements.define("media-rendition-listbox",XC);const QC=`<svg aria-hidden="true" viewBox="0 0 24 24">
1601
+ <slot name="captions-indicator" hidden>${qC}</slot>
1602
+ `;class YC extends mo{constructor(){super({slotTemplate:fT}),Cu(this,pf),Cu(this,nd),Cu(this,Ec,void 0)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",T.MEDIA_SUBTITLES_LIST,T.MEDIA_SUBTITLES_SHOWING]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_SUBTITLES_LIST&&t!==s?Du(this,pf,hT).call(this):e===T.MEDIA_SUBTITLES_SHOWING&&t!==s?this.value=s:e==="aria-multiselectable"&&(this.removeAttribute("aria-multiselectable"),console.warn("Captions List doesn't currently support multiple selections. You can enable multiple items via the media.textTracks API."))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Du(this,nd,gf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Du(this,nd,gf))}get mediaSubtitlesList(){return Rg(this,T.MEDIA_SUBTITLES_LIST)}set mediaSubtitlesList(e){wg(this,T.MEDIA_SUBTITLES_LIST,e)}get mediaSubtitlesShowing(){return Rg(this,T.MEDIA_SUBTITLES_SHOWING)}set mediaSubtitlesShowing(e){wg(this,T.MEDIA_SUBTITLES_SHOWING,e)}}Ec=new WeakMap;pf=new WeakSet;hT=function(){var i;if(KC(this,Ec)===JSON.stringify(this.mediaSubtitlesList))return;VC(this,Ec,JSON.stringify(this.mediaSubtitlesList));const e=this.shadowRoot.querySelector("#container");e.textContent="";const t=!this.value,s=$n(this.formatOptionText("Off"),"off",t);s.prepend(Er(this,"select-indicator")),e.append(s);const r=this.mediaSubtitlesList;for(const n of r){const a=$n(this.formatOptionText(n.label,n),Za(n),this.value==Za(n));a.prepend(Er(this,"select-indicator")),((i=n.kind)!=null?i:"subs")==="captions"&&a.append(Er(this,"captions-indicator")),e.append(a)}};nd=new WeakSet;gf=function(){const i=this.mediaSubtitlesShowing,e=this.getAttribute(T.MEDIA_SUBTITLES_SHOWING),t=this.value!==e;if(i!=null&&i.length&&t&&this.dispatchEvent(new k.CustomEvent(K.MEDIA_DISABLE_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:i})),!this.value||!t)return;const s=new k.CustomEvent(K.MEDIA_SHOW_SUBTITLES_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(s)};const Rg=(i,e)=>{const t=i.getAttribute(e);return t?ho(t):[]},wg=(i,e,t)=>{if(!(t!=null&&t.length)){i.removeAttribute(e);return}const s=On(t);i.getAttribute(e)!==s&&i.setAttribute(e,s)};k.customElements.get("media-captions-listbox")||k.customElements.define("media-captions-listbox",YC);class jC extends po{init(){const e=z.createElement("media-captions-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-captions-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-captions-selectmenu")||k.customElements.define("media-captions-selectmenu",jC);var mT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},zo=(i,e,t)=>(mT(i,e,"read from private field"),t?t.call(i):e.get(i)),Mu=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Jn=(i,e,t)=>(mT(i,e,"access private method"),t),sn,ba,ad,od,vf;const Ou={RATES:"rates"};class zC extends mo{constructor(){super(),Mu(this,ba),Mu(this,od),Mu(this,sn,new uo(this,Ou.RATES,{defaultValue:Zm})),Jn(this,ba,ad).call(this)}static get observedAttributes(){return[...super.observedAttributes,"aria-multiselectable",T.MEDIA_PLAYBACK_RATE,Ou.RATES]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_PLAYBACK_RATE&&t!=s?this.value=s:e===Ou.RATES&&t!=s&&(zo(this,sn).value=s,Jn(this,ba,ad).call(this))}get rates(){return zo(this,sn)}set rates(e){e?Array.isArray(e)&&(zo(this,sn).value=e.join(" ")):zo(this,sn).value="",Jn(this,ba,ad).call(this)}get mediaPlaybackRate(){return $e(this,T.MEDIA_PLAYBACK_RATE,mn)}set mediaPlaybackRate(e){nt(this,T.MEDIA_PLAYBACK_RATE,e)}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Jn(this,od,vf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Jn(this,od,vf))}}sn=new WeakMap;ba=new WeakSet;ad=function(){const i=this.shadowRoot.querySelector("#container");i.textContent="";for(const e of this.rates){const t=$n(this.formatOptionText(`${e}x`,e),e,this.mediaPlaybackRate==e);t.prepend(Er(this,"select-indicator")),i.append(t)}};od=new WeakSet;vf=function(){if(!this.value)return;const i=new k.CustomEvent(K.MEDIA_PLAYBACK_RATE_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-playback-rate-listbox")||k.customElements.define("media-playback-rate-listbox",zC);class XC extends po{init(){const e=z.createElement("media-playback-rate-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-playback-rate-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-playback-rate-selectmenu")||k.customElements.define("media-playback-rate-selectmenu",XC);var up=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},pT=(i,e,t)=>(up(i,e,"read from private field"),t?t.call(i):e.get(i)),Xo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Ef=(i,e,t,s)=>(up(i,e,"write to private field"),e.set(i,t),t),Qo=(i,e,t)=>(up(i,e,"access private method"),t),ya,bc,ld,bf,dd,yf;class QC extends mo{constructor(){super(...arguments),Xo(this,ld),Xo(this,dd),Xo(this,ya,[]),Xo(this,bc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_LIST,T.MEDIA_RENDITION_SELECTED]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_RENDITION_SELECTED&&t!==s?this.value=s??"auto":e===T.MEDIA_RENDITION_LIST&&t!==s&&(Ef(this,ya,sb(s)),Qo(this,ld,bf).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Qo(this,dd,yf))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Qo(this,dd,yf))}get mediaRenditionList(){return pT(this,ya)}set mediaRenditionList(e){Ef(this,ya,e),Qo(this,ld,bf).call(this)}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}ya=new WeakMap;bc=new WeakMap;ld=new WeakSet;bf=function(){if(pT(this,bc)===JSON.stringify(this.mediaRenditionList))return;Ef(this,bc,JSON.stringify(this.mediaRenditionList));const i=this.mediaRenditionList.sort((r,n)=>n.height-r.height),e=this.shadowRoot.querySelector("#container");e.textContent="";let t=!this.mediaRenditionSelected;for(const r of i){const n=this.formatOptionText(`${Math.min(r.width,r.height)}p`,r),a=$n(n,`${r.id}`,r.selected&&!t);a.prepend(Er(this,"select-indicator")),e.append(a)}const s=$n(this.formatOptionText("Auto"),"auto",t);s.prepend(Er(this,"select-indicator")),e.append(s)};dd=new WeakSet;yf=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_RENDITION_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-rendition-listbox")||k.customElements.define("media-rendition-listbox",QC);const ZC=`<svg aria-hidden="true" viewBox="0 0 24 24">
1603
1603
  <path d="M13.5 2.5h2v6h-2v-2h-11v-2h11v-2Zm4 2h4v2h-4v-2Zm-12 4h2v6h-2v-2h-3v-2h3v-2Zm4 2h12v2h-12v-2Zm1 4h2v6h-2v-2h-8v-2h8v-2Zm4 2h7v2h-7v-2Z" />
1604
1604
  </svg>`,gT=z.createElement("template");gT.innerHTML=`
1605
- <slot name="icon">${QC}</slot>
1606
- `;class ZC extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:gT})}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}k.customElements.get("media-rendition-button")||k.customElements.define("media-rendition-button",ZC);class JC extends po{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}init(){const e=z.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-rendition-selectmenu")||k.customElements.define("media-rendition-selectmenu",JC);var hp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vT=(i,e,t)=>(hp(i,e,"read from private field"),t?t.call(i):e.get(i)),Zo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Tf=(i,e,t,s)=>(hp(i,e,"write to private field"),e.set(i,t),t),Jo=(i,e,t)=>(hp(i,e,"access private method"),t),Ta,yc,cd,_f,ud,Af;class eD extends mo{constructor(){super(...arguments),Zo(this,cd),Zo(this,ud),Zo(this,Ta,[]),Zo(this,yc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==s?this.value=s:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==s&&(Tf(this,Ta,rb(s)),Jo(this,cd,_f).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Jo(this,ud,Af))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Jo(this,ud,Af))}get mediaAudioTrackList(){return vT(this,Ta)}set mediaAudioTrackList(e){Tf(this,Ta,e),Jo(this,cd,_f).call(this)}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}Ta=new WeakMap;yc=new WeakMap;cd=new WeakSet;_f=function(){if(vT(this,yc)===JSON.stringify(this.mediaAudioTrackList))return;Tf(this,yc,JSON.stringify(this.mediaAudioTrackList));const i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(const t of i){const s=this.formatOptionText(t.label,t),r=$n(s,`${t.id}`,t.enabled);r.prepend(Er(this,"select-indicator")),e.append(r)}};ud=new WeakSet;Af=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-audio-track-listbox")||k.customElements.define("media-audio-track-listbox",eD);const tD=`<svg aria-hidden="true" viewBox="0 0 24 24">
1605
+ <slot name="icon">${ZC}</slot>
1606
+ `;class JC extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}constructor(){super({slotTemplate:gT})}get mediaRenditionSelected(){return Ve(this,T.MEDIA_RENDITION_SELECTED)}set mediaRenditionSelected(e){qe(this,T.MEDIA_RENDITION_SELECTED,e)}}k.customElements.get("media-rendition-button")||k.customElements.define("media-rendition-button",JC);class eD extends po{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_RENDITION_SELECTED,T.MEDIA_RENDITION_UNAVAILABLE]}init(){const e=z.createElement("media-rendition-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-rendition-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-rendition-selectmenu")||k.customElements.define("media-rendition-selectmenu",eD);var hp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},vT=(i,e,t)=>(hp(i,e,"read from private field"),t?t.call(i):e.get(i)),Zo=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Tf=(i,e,t,s)=>(hp(i,e,"write to private field"),e.set(i,t),t),Jo=(i,e,t)=>(hp(i,e,"access private method"),t),Ta,yc,cd,_f,ud,Af;class tD extends mo{constructor(){super(...arguments),Zo(this,cd),Zo(this,ud),Zo(this,Ta,[]),Zo(this,yc,void 0)}static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_LIST,T.MEDIA_AUDIO_TRACK_ENABLED]}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e===T.MEDIA_AUDIO_TRACK_ENABLED&&t!==s?this.value=s:e===T.MEDIA_AUDIO_TRACK_LIST&&t!==s&&(Tf(this,Ta,rb(s)),Jo(this,cd,_f).call(this))}connectedCallback(){super.connectedCallback(),this.addEventListener("change",Jo(this,ud,Af))}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("change",Jo(this,ud,Af))}get mediaAudioTrackList(){return vT(this,Ta)}set mediaAudioTrackList(e){Tf(this,Ta,e),Jo(this,cd,_f).call(this)}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}Ta=new WeakMap;yc=new WeakMap;cd=new WeakSet;_f=function(){if(vT(this,yc)===JSON.stringify(this.mediaAudioTrackList))return;Tf(this,yc,JSON.stringify(this.mediaAudioTrackList));const i=this.mediaAudioTrackList,e=this.shadowRoot.querySelector("#container");e.textContent="";for(const t of i){const s=this.formatOptionText(t.label,t),r=$n(s,`${t.id}`,t.enabled);r.prepend(Er(this,"select-indicator")),e.append(r)}};ud=new WeakSet;Af=function(){if(this.value==null)return;const i=new k.CustomEvent(K.MEDIA_AUDIO_TRACK_REQUEST,{composed:!0,bubbles:!0,detail:this.value});this.dispatchEvent(i)};k.customElements.get("media-audio-track-listbox")||k.customElements.define("media-audio-track-listbox",tD);const iD=`<svg aria-hidden="true" viewBox="0 0 24 24">
1607
1607
  <path d="M11 17H9.5V7H11v10Zm-3-3H6.5v-4H8v4Zm6-5h-1.5v6H14V9Zm3 7h-1.5V8H17v8Z"/>
1608
1608
  <path d="M22 12c0 5.523-4.477 10-10 10S2 17.523 2 12 6.477 2 12 2s10 4.477 10 10Zm-2 0a8 8 0 1 0-16 0 8 8 0 0 0 16 0Z"/>
1609
1609
  </svg>`,ET=z.createElement("template");ET.innerHTML=`
1610
- <slot name="icon">${tD}</slot>
1611
- `;class iD extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:ET})}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}k.customElements.get("media-audio-track-button")||k.customElements.define("media-audio-track-button",iD);class sD extends po{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){const e=z.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-audio-track-selectmenu")||k.customElements.define("media-audio-track-selectmenu",sD);var rD=Object.defineProperty,nD=Object.getPrototypeOf,aD=Reflect.get,oD=(i,e,t)=>e in i?rD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ie=(i,e,t)=>(oD(i,typeof e!="symbol"?e+"":e,t),t),fp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},I=(i,e,t)=>(fp(i,e,"read from private field"),t?t.call(i):e.get(i)),Z=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ie=(i,e,t,s)=>(fp(i,e,"write to private field"),e.set(i,t),t),Fe=(i,e,t)=>(fp(i,e,"access private method"),t),Pu=(i,e,t)=>aD(nD(i),t,e),Nc=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment>"u"){class i extends Nc{}globalThis.DocumentFragment=i}var mp=class extends Nc{},lD=class extends Nc{},dD={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(mp)}},hd,cD=class{constructor(e,t={}){Z(this,hd,void 0),ie(this,hd,t==null?void 0:t.detail)}get detail(){return I(this,hd)}initCustomEvent(){}};hd=new WeakMap;function uD(i,e){return new mp}var hD={document:{createElement:uD},DocumentFragment,customElements:dD,CustomEvent:cD,EventTarget:Nc,HTMLElement:mp,HTMLVideoElement:lD},fD=typeof window>"u"||typeof globalThis.customElements>"u",Nu=fD?hD:globalThis,mD=()=>{try{return"0.19.0"}catch{}return"UNKNOWN"},pD=mD(),gD=()=>pD,pp=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Cg,Sf=(Cg=globalThis.document)==null?void 0:Cg.createElement("template");Sf&&(Sf.innerHTML=`
1610
+ <slot name="icon">${iD}</slot>
1611
+ `;class sD extends xt{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}constructor(){super({slotTemplate:ET})}get mediaAudioTrackEnabled(){return Ve(this,T.MEDIA_AUDIO_TRACK_ENABLED)}set mediaAudioTrackEnabled(e){qe(this,T.MEDIA_AUDIO_TRACK_ENABLED,e)}}k.customElements.get("media-audio-track-button")||k.customElements.define("media-audio-track-button",sD);class rD extends po{static get observedAttributes(){return[...super.observedAttributes,T.MEDIA_AUDIO_TRACK_ENABLED,T.MEDIA_AUDIO_TRACK_UNAVAILABLE]}init(){const e=z.createElement("media-audio-track-button");e.part.add("button"),e.preventClick=!0;const t=z.createElement("media-audio-track-listbox");t.part.add("listbox"),t.setAttribute("exportparts","option, option-selected, indicator");const s=this.shadowRoot.querySelector("slot[name=button]"),r=this.shadowRoot.querySelector("slot[name=listbox]");s.textContent="",r.textContent="",s.append(e),r.append(t)}}k.customElements.get("media-audio-track-selectmenu")||k.customElements.define("media-audio-track-selectmenu",rD);var nD=Object.defineProperty,aD=Object.getPrototypeOf,oD=Reflect.get,lD=(i,e,t)=>e in i?nD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,Ie=(i,e,t)=>(lD(i,typeof e!="symbol"?e+"":e,t),t),fp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},I=(i,e,t)=>(fp(i,e,"read from private field"),t?t.call(i):e.get(i)),Z=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},ie=(i,e,t,s)=>(fp(i,e,"write to private field"),e.set(i,t),t),Fe=(i,e,t)=>(fp(i,e,"access private method"),t),Pu=(i,e,t)=>oD(aD(i),t,e),Nc=class{addEventListener(){}removeEventListener(){}dispatchEvent(e){return!0}};if(typeof DocumentFragment>"u"){class i extends Nc{}globalThis.DocumentFragment=i}var mp=class extends Nc{},dD=class extends Nc{},cD={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(mp)}},hd,uD=class{constructor(e,t={}){Z(this,hd,void 0),ie(this,hd,t==null?void 0:t.detail)}get detail(){return I(this,hd)}initCustomEvent(){}};hd=new WeakMap;function hD(i,e){return new mp}var fD={document:{createElement:hD},DocumentFragment,customElements:cD,CustomEvent:uD,EventTarget:Nc,HTMLElement:mp,HTMLVideoElement:dD},mD=typeof window>"u"||typeof globalThis.customElements>"u",Nu=mD?fD:globalThis,pD=()=>{try{return"0.19.0"}catch{}return"UNKNOWN"},gD=pD(),vD=()=>gD,pp=["abort","canplay","canplaythrough","durationchange","emptied","encrypted","ended","error","loadeddata","loadedmetadata","loadstart","pause","play","playing","progress","ratechange","seeked","seeking","stalled","suspend","timeupdate","volumechange","waiting","waitingforkey","resize","enterpictureinpicture","leavepictureinpicture","webkitbeginfullscreen","webkitendfullscreen","webkitpresentationmodechanged"],Cg,Sf=(Cg=globalThis.document)==null?void 0:Cg.createElement("template");Sf&&(Sf.innerHTML=`
1612
1612
  <style>
1613
1613
  :host {
1614
1614
  display: inline-flex;
@@ -1646,7 +1646,7 @@ svg, img, ::slotted(svg), ::slotted(img) {
1646
1646
  </style>
1647
1647
  <slot name="media"></slot>
1648
1648
  <slot></slot>
1649
- `);var bT=(i,{tag:e,is:t})=>{var s,r,n,a,o,l,d,c,u,h,f,m,p,g,v,y;let b=(s=globalThis.document)==null?void 0:s.createElement(e,{is:t}),x=b?vD(b):[];return r=class extends i{constructor(){super(),Z(this,u),Z(this,f),Z(this,p),Z(this,v),Z(this,l,void 0),Z(this,d,void 0),Z(this,c,new Map),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var _,S,A;return Fe(_=r,a,o).call(_),[...(A=(S=b==null?void 0:b.constructor)==null?void 0:S.observedAttributes)!=null?A:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var _,S,A;return(A=(S=(_=I(this,d))!=null?_:this.shadowRoot.querySelector(e))!=null?S:this.querySelector(":scope > [slot=media]"))!=null?A:this.querySelector(e)}set nativeEl(_){ie(this,d,_)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(_){this.toggleAttribute("muted",!!_)}get src(){return this.getAttribute("src")}set src(_){this.setAttribute("src",`${_}`)}get preload(){var _,S;return(S=this.getAttribute("preload"))!=null?S:(_=this.nativeEl)==null?void 0:_.preload}set preload(_){this.setAttribute("preload",`${_}`)}init(){var _,S;if(!this.nativeEl){let A=document.createElement(e,{is:t});A.part=e,this.shadowRoot.querySelector('slot[name="media"]').append(A)}this.nativeEl.muted=this.hasAttribute("muted");for(let A of x)Fe(this,p,g).call(this,A);this.shadowRoot.addEventListener("slotchange",this);for(let A of this.constructor.Events)(S=(_=this.shadowRoot).addEventListener)==null||S.call(_,A,this,!0)}handleEvent(_){if(_.type==="slotchange"){Fe(this,f,m).call(this);return}_.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(_.type,{detail:_.detail}))}attributeChangedCallback(_,S,A){Fe(this,u,h).call(this),Fe(this,v,y).call(this,_,S,A)}connectedCallback(){Fe(this,u,h).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(I(this,n))return;ie(this,n,!0);let _=new Set(this.observedAttributes);_.delete("muted");for(let S of x)if(!(S in this.prototype))if(typeof b[S]=="function")this.prototype[S]=function(...A){return Fe(this,u,h).call(this),this.call?this.call(S,...A):this.nativeEl[S].apply(this.nativeEl,A)};else{let A={get(){var D,O,L;Fe(this,u,h).call(this);let C=S.toLowerCase();if(_.has(C)){let H=this.getAttribute(C);return H===null?!1:H===""?!0:H}return(L=(D=this.get)==null?void 0:D.call(this,S))!=null?L:(O=this.nativeEl)==null?void 0:O[S]}};S!==S.toUpperCase()&&(A.set=function(D){Fe(this,u,h).call(this);let O=S.toLowerCase();if(_.has(O)){D===!0||D===!1||D==null?this.toggleAttribute(O,!!D):this.setAttribute(O,D);return}if(this.set){this.set(S,D);return}this.nativeEl[S]=D}),Object.defineProperty(this.prototype,S,A)}},l=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakSet,h=function(){I(this,l)||(ie(this,l,!0),this.init())},f=new WeakSet,m=function(){let _=new Map(I(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements().filter(S=>["track","source"].includes(S.localName)).forEach(S=>{var A,D;_.delete(S);let O=I(this,c).get(S);O||(O=S.cloneNode(),I(this,c).set(S,O)),(D=(A=this.nativeEl).append)==null||D.call(A,O),O.localName==="track"&&O.default&&(O.kind==="chapters"||O.kind==="metadata")&&O.track.mode==="disabled"&&(O.track.mode="hidden")}),_.forEach(S=>S.remove())},p=new WeakSet,g=function(_){if(Object.prototype.hasOwnProperty.call(this,_)){let S=this[_];delete this[_],this[_]=S}},v=new WeakSet,y=function(_,S,A){var D,O,L,C,H,U;["id","class"].includes(_)||!r.observedAttributes.includes(_)&&this.constructor.observedAttributes.includes(_)||(A===null?(O=(D=this.nativeEl).removeAttribute)==null||O.call(D,_):((C=(L=this.nativeEl).getAttribute)==null?void 0:C.call(L,_))!=A&&((U=(H=this.nativeEl).setAttribute)==null||U.call(H,_,A)))},Z(r,a),Ie(r,"Events",pp),Ie(r,"template",e.endsWith("audio")?Sf:xf),Z(r,n,void 0),r};function vD(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Uu=globalThis.document?bT(HTMLElement,{tag:"video"}):class{};globalThis.document&&bT(HTMLElement,{tag:"audio"});var yr=new WeakMap,Fu=class extends Error{},ED=class extends Error{},bD=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function yD(i){yT()?TT()?i(chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable)):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable))}}function TD(){return globalThis.chrome}function _D(){let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function yT(){return typeof chrome<"u"&&chrome.cast&&chrome.cast.isAvailable}function TT(){return typeof cast<"u"&&cast.framework}function xr(){if(TT())return cast.framework.CastContext.getInstance()}function gp(){var i;return(i=xr())==null?void 0:i.getCurrentSession()}function vp(){var i;return(i=gp())==null?void 0:i.getSessionObj().media[0]}function AD(i){return new Promise((e,t)=>{vp().editTracksInfo(i,e,t)})}function SD(i){return new Promise((e,t)=>{vp().getStatus(i,e,t)})}function _T(i){return xr().setOptions({...AT(),...i})}function AT(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var fd=new bD,ys=new WeakSet,Ye;yD(i=>{i&&!Ye&&(Ye=cast.framework,xr().addEventListener(Ye.CastContextEventType.CAST_STATE_CHANGED,e=>{fd.forEach(t=>{var s,r;return(r=(s=yr.get(t)).onCastStateChanged)==null?void 0:r.call(s,e)})}),xr().addEventListener(Ye.CastContextEventType.SESSION_STATE_CHANGED,e=>{fd.forEach(t=>{var s,r;return(r=(s=yr.get(t)).onSessionStateChanged)==null?void 0:r.call(s,e)})}),fd.forEach(e=>{var t,s;return(s=(t=yr.get(e)).init)==null?void 0:s.call(t)}))});var Mg=0,ve,md,Wt,ps,vn,rn,ar,kf,gs,Us,Lf,Og,Tc,If,Rf,ST,pd,wf,Cf,Pg,gd,$u,xD=class extends EventTarget{constructor(i){super(),Z(this,gs),Z(this,Lf),Z(this,Tc),Z(this,Rf),Z(this,pd),Z(this,Cf),Z(this,gd),Z(this,ve,void 0),Z(this,md,void 0),Z(this,Wt,void 0),Z(this,ps,void 0),Z(this,vn,"disconnected"),Z(this,rn,!1),Z(this,ar,new Set),Z(this,kf,new WeakMap),ie(this,ve,i),fd.add(this),yr.set(this,{init:()=>Fe(this,pd,wf).call(this),onCastStateChanged:()=>Fe(this,Tc,If).call(this),onSessionStateChanged:()=>Fe(this,Rf,ST).call(this),getCastPlayer:()=>I(this,gs,Us)}),Fe(this,pd,wf).call(this)}get state(){return I(this,vn)}async watchAvailability(i){if(I(this,ve).disableRemotePlayback)throw new Fu("disableRemotePlayback attribute is present.");return I(this,kf).set(i,++Mg),I(this,ar).add(i),Mg}async cancelWatchAvailability(i){if(I(this,ve).disableRemotePlayback)throw new Fu("disableRemotePlayback attribute is present.");i?I(this,ar).delete(i):I(this,ar).clear()}async prompt(){var i,e;if(I(this,ve).disableRemotePlayback)throw new Fu("disableRemotePlayback attribute is present.");if(!yT())throw new ED("The RemotePlayback API is disabled on this platform.");let t=ys.has(I(this,ve));ys.add(I(this,ve)),_T(I(this,ve).castOptions),Object.entries(I(this,ps)).forEach(([s,r])=>{I(this,Wt).controller.addEventListener(s,r)});try{await xr().requestSession()}catch(s){if(s==="cancel"){t||ys.delete(I(this,ve));return}throw new Error(s)}(e=(i=yr.get(I(this,ve)))==null?void 0:i.loadOnPrompt)==null||e.call(i)}};ve=new WeakMap,md=new WeakMap,Wt=new WeakMap,ps=new WeakMap,vn=new WeakMap,rn=new WeakMap,ar=new WeakMap,kf=new WeakMap,gs=new WeakSet,Us=function(){if(ys.has(I(this,ve)))return I(this,Wt)},Lf=new WeakSet,Og=function(){ys.has(I(this,ve))&&(Object.entries(I(this,ps)).forEach(([i,e])=>{I(this,Wt).controller.removeEventListener(i,e)}),ys.delete(I(this,ve)),I(this,ve).muted=I(this,Wt).isMuted,I(this,ve).currentTime=I(this,Wt).savedPlayerState.currentTime,I(this,Wt).savedPlayerState.isPaused===!1&&I(this,ve).play())},Tc=new WeakSet,If=function(){let i=xr().getCastState();if(ys.has(I(this,ve))&&i==="CONNECTING"&&(ie(this,vn,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,rn)&&i!=null&&i.includes("CONNECT")){ie(this,rn,!0);for(let e of I(this,ar))e(!0)}else if(I(this,rn)&&(!i||i==="NO_DEVICES_AVAILABLE")){ie(this,rn,!1);for(let e of I(this,ar))e(!1)}},Rf=new WeakSet,ST=async function(){var i;let{SESSION_RESUMED:e}=Ye.SessionState;if(xr().getSessionState()===e&&I(this,ve).castSrc===((i=vp())==null?void 0:i.media.contentId)){ys.add(I(this,ve)),Object.entries(I(this,ps)).forEach(([t,s])=>{I(this,Wt).controller.addEventListener(t,s)});try{await SD(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}I(this,ps)[Ye.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,ps)[Ye.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},pd=new WeakSet,wf=function(){!Ye||I(this,md)||(ie(this,md,!0),_T(I(this,ve).castOptions),I(this,ve).textTracks.addEventListener("change",()=>Fe(this,gd,$u).call(this)),Fe(this,Tc,If).call(this),ie(this,Wt,new Ye.RemotePlayer),new Ye.RemotePlayerController(I(this,Wt)),ie(this,ps,{[Ye.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(ie(this,vn,"connected"),this.dispatchEvent(new Event("connect"))):(Fe(this,Lf,Og).call(this),ie(this,vn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[Ye.RemotePlayerEventType.DURATION_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("durationchange"))},[Ye.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("volumechange"))},[Ye.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("volumechange"))},[Ye.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=I(this,gs,Us))!=null&&i.isMediaLoaded&&I(this,ve).dispatchEvent(new Event("timeupdate"))},[Ye.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("resize"))},[Ye.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event(this.paused?"pause":"play"))},[Ye.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=I(this,gs,Us))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&I(this,ve).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=I(this,gs,Us))==null?void 0:e.playerState]))},[Ye.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=I(this,gs,Us))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Fe(this,Cf,Pg).call(this))}}))},Cf=new WeakSet,Pg=function(){Fe(this,gd,$u).call(this)},gd=new WeakSet,$u=async function(){var i,e,t,s,r;if(!I(this,gs,Us))return;let n=((e=(i=I(this,Wt).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...I(this,ve).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(v=>v.language===h&&v.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),c=(r=(s=(t=gp())==null?void 0:t.getSessionObj().media[0])==null?void 0:s.activeTrackIds)!=null?r:[],u=c;if(c.length&&(u=u.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(u=[...u,d.trackId]),u=[...new Set(u)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(c,u))try{let h=new chrome.cast.media.EditTracksInfoRequest(u);await AD(h)}catch(h){console.error(h)}};var kD=i=>{var e,t,s,r,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),Z(this,a),Z(this,l),Z(this,s,{paused:!1}),Z(this,r,AT()),Z(this,n,void 0)}get remote(){return I(this,n)?I(this,n):TD()?(_D(),yr.set(this,{loadOnPrompt:()=>Fe(this,l,d).call(this)}),ie(this,n,new xD(this))):super.remote}attributeChangedCallback(c,u,h){if(super.attributeChangedCallback(c,u,h),c==="cast-receiver"&&h){I(this,r).receiverApplicationId=h;return}if(I(this,a,o))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,u;if(!I(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:v,src:y})=>y&&(v==="subtitles"||v==="captions")),m=[],p=0;f.length&&(h.tracks=f.map(v=>{let y=++p;m.length===0&&v.track.mode==="showing"&&m.push(y);let b=new chrome.cast.media.Track(y,chrome.cast.media.TrackType.TEXT);return b.trackContentId=v.src,b.trackContentType="text/vtt",b.subtype=v.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,b.name=v.label,b.language=v.srclang,b})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(c=super.currentTime)!=null?c:0,g.autoplay=!I(this,s).paused,g.activeTrackIds=m,await((u=gp())==null?void 0:u.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(I(this,a,o)){I(this,a,o).isPaused&&((c=I(this,a,o).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(I(this,a,o)){I(this,a,o).isPaused||(c=I(this,a,o).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return I(this,r)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,u,h;return(h=(u=this.getAttribute("cast-src"))!=null?u:(c=this.querySelector("source"))==null?void 0:c.src)!=null?h:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,u;return(u=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?u:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get readyState(){if(I(this,a,o))switch(I(this,a,o).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return I(this,a,o)?I(this,a,o).isPaused:super.paused}get muted(){var c;return I(this,a,o)?(c=I(this,a,o))==null?void 0:c.isMuted:super.muted}set muted(c){var u;if(I(this,a,o)){(c&&!I(this,a,o).isMuted||!c&&I(this,a,o).isMuted)&&((u=I(this,a,o).controller)==null||u.muteOrUnmute());return}super.muted=c}get volume(){var c,u;return I(this,a,o)?(u=(c=I(this,a,o))==null?void 0:c.volumeLevel)!=null?u:1:super.volume}set volume(c){var u;if(I(this,a,o)){I(this,a,o).volumeLevel=+c,(u=I(this,a,o).controller)==null||u.setVolumeLevel();return}super.volume=c}get duration(){var c,u,h;return I(this,a,o)&&(c=I(this,a,o))!=null&&c.isMediaLoaded?(h=(u=I(this,a,o))==null?void 0:u.duration)!=null?h:NaN:super.duration}get currentTime(){var c,u,h;return I(this,a,o)&&(c=I(this,a,o))!=null&&c.isMediaLoaded?(h=(u=I(this,a,o))==null?void 0:u.currentTime)!=null?h:0:super.currentTime}set currentTime(c){var u;if(I(this,a,o)){I(this,a,o).currentTime=c,(u=I(this,a,o).controller)==null||u.seek();return}super.currentTime=c}},s=new WeakMap,r=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var c,u;return(u=(c=yr.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:u.call(c)},l=new WeakSet,d=async function(){I(this,s).paused=Pu(t.prototype,this,"paused"),Pu(t.prototype,this,"pause").call(this),this.muted=Pu(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},Ie(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Uc=class extends Event{constructor(e,t){super(e),Ie(this,"track"),this.track=t.track}},Df=new WeakMap;function V(i){var e;return(e=Df.get(i))!=null?e:LD(i,{})}function LD(i,e){let t=Df.get(i);return t||Df.set(i,t={}),Object.assign(t,e)}function Mf(i,e){let t=i.videoTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let s=V(t).trackSet;s.add(e);let r=s.size-1;r in Pf.prototype||Object.defineProperty(Pf.prototype,r,{get(){return[...V(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new Uc("addtrack",{track:e}))})}function Of(i){var e;let t=(e=V(i).media)==null?void 0:e.videoTracks;t&&(V(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Uc("removetrack",{track:i}))}))}function ID(i){var e;let t=(e=V(i).media.videoTracks)!=null?e:[],s=!1;for(let r of t)r!==i&&(r.selected=!1,s=!0);if(s){if(V(t).changeRequested)return;V(t).changeRequested=!0,queueMicrotask(()=>{delete V(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Fs,$s,Bs,nn,_a,Pf=class extends EventTarget{constructor(){super(),Z(this,nn),Z(this,Fs,void 0),Z(this,$s,void 0),Z(this,Bs,void 0),V(this).trackSet=new Set}[Symbol.iterator](){return I(this,nn,_a).values()}get length(){return I(this,nn,_a).size}getTrackById(e){var t;return(t=[...I(this,nn,_a)].find(s=>s.id===e))!=null?t:null}get selectedIndex(){return[...I(this,nn,_a)].findIndex(e=>e.selected)}get onaddtrack(){return I(this,Fs)}set onaddtrack(e){I(this,Fs)&&(this.removeEventListener("addtrack",I(this,Fs)),ie(this,Fs,void 0)),typeof e=="function"&&(ie(this,Fs,e),this.addEventListener("addtrack",e))}get onremovetrack(){return I(this,$s)}set onremovetrack(e){I(this,$s)&&(this.removeEventListener("removetrack",I(this,$s)),ie(this,$s,void 0)),typeof e=="function"&&(ie(this,$s,e),this.addEventListener("removetrack",e))}get onchange(){return I(this,Bs)}set onchange(e){I(this,Bs)&&(this.removeEventListener("change",I(this,Bs)),ie(this,Bs,void 0)),typeof e=="function"&&(ie(this,Bs,e),this.addEventListener("change",e))}};Fs=new WeakMap,$s=new WeakMap,Bs=new WeakMap,nn=new WeakSet,_a=function(){return V(this).trackSet};var Fc=class extends Event{constructor(i,e){super(i),Ie(this,"rendition"),this.rendition=e.rendition}};function RD(i,e){let t=V(i).media.videoRenditions;V(e).media=V(i).media,V(e).track=i;let s=V(i).renditionSet;s.add(e);let r=s.size-1;r in Nf.prototype||Object.defineProperty(Nf.prototype,r,{get(){return an(this)[r]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Fc("addrendition",{rendition:e}))})}function wD(i){let e=V(i).media.videoRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.selected&&e.dispatchEvent(new Fc("removerendition",{rendition:i}))})}function CD(i){let e=V(i).media.videoRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function an(i){return[...V(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...V(e).renditionSet])}var Gs,Hs,Ws,Nf=class extends EventTarget{constructor(){super(...arguments),Z(this,Gs,void 0),Z(this,Hs,void 0),Z(this,Ws,void 0)}[Symbol.iterator](){return an(this).values()}get length(){return an(this).length}getRenditionById(e){var t;return(t=an(this).find(s=>`${s.id}`==`${e}`))!=null?t:null}get selectedIndex(){return an(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,s]of an(this).entries())s.selected=t===e}get onaddrendition(){return I(this,Gs)}set onaddrendition(e){I(this,Gs)&&(this.removeEventListener("addrendition",I(this,Gs)),ie(this,Gs,void 0)),typeof e=="function"&&(ie(this,Gs,e),this.addEventListener("addrendition",e))}get onremoverendition(){return I(this,Hs)}set onremoverendition(e){I(this,Hs)&&(this.removeEventListener("removerendition",I(this,Hs)),ie(this,Hs,void 0)),typeof e=="function"&&(ie(this,Hs,e),this.addEventListener("removerendition",e))}get onchange(){return I(this,Ws)}set onchange(e){I(this,Ws)&&(this.removeEventListener("change",I(this,Ws)),ie(this,Ws,void 0)),typeof e=="function"&&(ie(this,Ws,e),this.addEventListener("change",e))}};Gs=new WeakMap,Hs=new WeakMap,Ws=new WeakMap;var Aa,DD=class{constructor(){Ie(this,"src"),Ie(this,"id"),Ie(this,"width"),Ie(this,"height"),Ie(this,"bitrate"),Ie(this,"frameRate"),Ie(this,"codec"),Z(this,Aa,!1)}get selected(){return I(this,Aa)}set selected(i){I(this,Aa)!==i&&(ie(this,Aa,i),CD(this))}};Aa=new WeakMap;var Sa,xT=class{constructor(){Ie(this,"id"),Ie(this,"kind"),Ie(this,"label",""),Ie(this,"language",""),Ie(this,"sourceBuffer"),Z(this,Sa,!1)}addRendition(i,e,t,s,r,n){let a=new DD;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=r,a.codec=s,RD(this,a),a}removeRendition(i){wD(i)}get selected(){return I(this,Sa)}set selected(i){I(this,Sa)!==i&&(ie(this,Sa,i),i===!0&&ID(this))}};Sa=new WeakMap;function MD(i,e){let t=V(i).media.audioRenditions;V(e).media=V(i).media,V(e).track=i;let s=V(i).renditionSet;s.add(e);let r=s.size-1;r in Uf.prototype||Object.defineProperty(Uf.prototype,r,{get(){return on(this)[r]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Fc("addrendition",{rendition:e}))})}function OD(i){let e=V(i).media.audioRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.enabled&&e.dispatchEvent(new Fc("removerendition",{rendition:i}))})}function PD(i){let e=V(i).media.audioRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function on(i){return[...V(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...V(e).renditionSet])}var Ks,Vs,qs,Uf=class extends EventTarget{constructor(){super(...arguments),Z(this,Ks,void 0),Z(this,Vs,void 0),Z(this,qs,void 0)}[Symbol.iterator](){return on(this).values()}get length(){return on(this).length}getRenditionById(e){var t;return(t=on(this).find(s=>`${s.id}`==`${e}`))!=null?t:null}get selectedIndex(){return on(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,s]of on(this).entries())s.selected=t===e}get onaddrendition(){return I(this,Ks)}set onaddrendition(e){I(this,Ks)&&(this.removeEventListener("addrendition",I(this,Ks)),ie(this,Ks,void 0)),typeof e=="function"&&(ie(this,Ks,e),this.addEventListener("addrendition",e))}get onremoverendition(){return I(this,Vs)}set onremoverendition(e){I(this,Vs)&&(this.removeEventListener("removerendition",I(this,Vs)),ie(this,Vs,void 0)),typeof e=="function"&&(ie(this,Vs,e),this.addEventListener("removerendition",e))}get onchange(){return I(this,qs)}set onchange(e){I(this,qs)&&(this.removeEventListener("change",I(this,qs)),ie(this,qs,void 0)),typeof e=="function"&&(ie(this,qs,e),this.addEventListener("change",e))}};Ks=new WeakMap,Vs=new WeakMap,qs=new WeakMap;var xa,ND=class{constructor(){Ie(this,"src"),Ie(this,"id"),Ie(this,"bitrate"),Ie(this,"codec"),Z(this,xa,!1)}get selected(){return I(this,xa)}set selected(e){I(this,xa)!==e&&(ie(this,xa,e),PD(this))}};xa=new WeakMap;function Ff(i,e){let t=i.audioTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let s=V(t).trackSet;s.add(e);let r=s.size-1;r in Bf.prototype||Object.defineProperty(Bf.prototype,r,{get(){return[...V(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new Uc("addtrack",{track:e}))})}function $f(i){var e;let t=(e=V(i).media)==null?void 0:e.audioTracks;t&&(V(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Uc("removetrack",{track:i}))}))}function UD(i){let e=V(i).media.audioTracks;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var Ys,js,zs,ka,vd,Bf=class extends EventTarget{constructor(){super(),Z(this,ka),Z(this,Ys,void 0),Z(this,js,void 0),Z(this,zs,void 0),V(this).trackSet=new Set}[Symbol.iterator](){return I(this,ka,vd).values()}get length(){return I(this,ka,vd).size}getTrackById(i){var e;return(e=[...I(this,ka,vd)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return I(this,Ys)}set onaddtrack(i){I(this,Ys)&&(this.removeEventListener("addtrack",I(this,Ys)),ie(this,Ys,void 0)),typeof i=="function"&&(ie(this,Ys,i),this.addEventListener("addtrack",i))}get onremovetrack(){return I(this,js)}set onremovetrack(i){I(this,js)&&(this.removeEventListener("removetrack",I(this,js)),ie(this,js,void 0)),typeof i=="function"&&(ie(this,js,i),this.addEventListener("removetrack",i))}get onchange(){return I(this,zs)}set onchange(i){I(this,zs)&&(this.removeEventListener("change",I(this,zs)),ie(this,zs,void 0)),typeof i=="function"&&(ie(this,zs,i),this.addEventListener("change",i))}};Ys=new WeakMap,js=new WeakMap,zs=new WeakMap,ka=new WeakSet,vd=function(){return V(this).trackSet};var La,kT=class{constructor(){Ie(this,"id"),Ie(this,"kind"),Ie(this,"label",""),Ie(this,"language",""),Ie(this,"sourceBuffer"),Z(this,La,!1)}addRendition(e,t,s){let r=new ND;return r.src=e,r.codec=t,r.bitrate=s,MD(this,r),r}removeRendition(e){OD(e)}get enabled(){return I(this,La)}set enabled(e){I(this,La)!==e&&(ie(this,La,e),UD(this))}};La=new WeakMap;var Ng=_c(globalThis.HTMLMediaElement,"video"),Ug=_c(globalThis.HTMLMediaElement,"audio");function FD(i){if(!(i!=null&&i.prototype))return i;let e=_c(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return $D(this)}});let t=_c(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return BD(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new xT;return l.kind=n,l.label=a,l.language=o,Mf(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Of),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new kT;return l.kind=n,l.label=a,l.language=o,Ff(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=$f),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return s(this)}});let s=n=>{let a=V(n).videoRenditions;return a||(a=new Nf,V(a).media=n,V(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return r(this)}});let r=n=>{let a=V(n).audioRenditions;return a||(a=new Uf,V(a).media=n,V(n).audioRenditions=a),a};return i}function _c(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function $D(i){var e;let t=V(i).videoTracks;if(!t&&(t=new Pf,V(i).videoTracks=t,Ng)){let s=Ng.call((e=i.nativeEl)!=null?e:i);for(let r of s)Mf(i,r);s.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),s.addEventListener("addtrack",r=>{if([...t].some(n=>n instanceof xT)){for(let n of s)Of(n);return}Mf(i,r.track)}),s.addEventListener("removetrack",r=>{Of(r.track)})}return t}function BD(i){var e;let t=V(i).audioTracks;if(!t&&(t=new Bf,V(i).audioTracks=t,Ug)){let s=Ug.call((e=i.nativeEl)!=null?e:i);for(let r of s)Ff(i,r);s.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),s.addEventListener("addtrack",r=>{if([...t].some(n=>n instanceof kT)){for(let n of s)$f(n);return}Ff(i,r.track)}),s.addEventListener("removetrack",r=>{$f(r.track)})}return t}pp.push("castchange","entercast","leavecast");var P={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},GD=Object.values(P),HD=gD(),WD="mux-video",Ai,Ia,Ed,Ra,bd,yd,Td,_d,wa,Ad,KD=class extends Uu{constructor(){super(),Z(this,wa),Z(this,Ai,void 0),Z(this,Ia,void 0),Z(this,Ed,void 0),Z(this,Ra,{}),Z(this,bd,void 0),Z(this,yd,void 0),Z(this,Td,void 0),Z(this,_d,void 0),ie(this,Ed,AI())}static get observedAttributes(){var e;return[...GD,...(e=Uu.observedAttributes)!=null?e:[]]}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?jd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${jd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get playerInitTime(){return I(this,Ed)}get playerSoftwareName(){var e;return(e=I(this,Td))!=null?e:WD}set playerSoftwareName(e){ie(this,Td,e)}get playerSoftwareVersion(){var e;return(e=I(this,yd))!=null?e:HD}set playerSoftwareVersion(e){ie(this,yd,e)}get _hls(){var e;return(e=I(this,Ai))==null?void 0:e.engine}get mux(){var e;return(e=this.nativeEl)==null?void 0:e.mux}get error(){var e;return(e=II(this.nativeEl))!=null?e:null}get errorTranslator(){return I(this,_d)}set errorTranslator(e){ie(this,_d,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(e==null?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return(e=this.getAttribute(P.TYPE))!=null?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(P.TYPE,e):this.removeAttribute(P.TYPE))}get autoplay(){let e=this.getAttribute("autoplay");return e===null?!1:e===""?!0:e}set autoplay(e){let t=this.autoplay;e!==t&&(e?this.setAttribute("autoplay",typeof e=="string"?e:""):this.removeAttribute("autoplay"))}get preload(){let e=this.getAttribute("preload");return e===""?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return this.getAttribute(P.DEBUG)!=null}set debug(e){e!==this.debug&&(e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG))}get disableTracking(){return this.hasAttribute(P.DISABLE_TRACKING)}set disableTracking(e){e!==this.disableTracking&&this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return this.hasAttribute(P.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES))}get startTime(){let e=this.getAttribute(P.START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set startTime(e){e!==this.startTime&&(e==null?this.removeAttribute(P.START_TIME):this.setAttribute(P.START_TIME,`${e}`))}get playbackId(){var e;return(e=this.getAttribute(P.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){let e=this.getAttribute(P.PROGRAM_START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){let e=this.getAttribute(P.PROGRAM_END_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get ended(){return zE(this.nativeEl,this._hls)}get envKey(){var e;return(e=this.getAttribute(P.ENV_KEY))!=null?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(P.ENV_KEY,e):this.removeAttribute(P.ENV_KEY))}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return(e=this.getAttribute(P.STREAM_TYPE))!=null?e:hh(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(P.STREAM_TYPE,e):this.removeAttribute(P.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(P.TARGET_LIVE_WINDOW)?+this.getAttribute(P.TARGET_LIVE_WINDOW):RI(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.TARGET_LIVE_WINDOW):this.setAttribute(P.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,t;if(this.hasAttribute(P.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:s}=this,r=(e=this.nativeEl.seekable.end(0))!=null?e:0,n=(t=this.nativeEl.seekable.start(0))!=null?t:0;return Math.max(n,r-s)}return wI(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(P.LIVE_EDGE_OFFSET))return+this.getAttribute(P.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.LIVE_EDGE_OFFSET):this.setAttribute(P.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return zd(this.nativeEl)}async addCuePoints(e){return BE(this.nativeEl,e)}get activeCuePoint(){return GE(this.nativeEl)}get cuePoints(){return dI(this.nativeEl)}async addChapters(e){return WE(this.nativeEl,e)}get activeChapter(){return KE(this.nativeEl)}get chapters(){return uI(this.nativeEl)}getStartDate(){return fI(this.nativeEl,this._hls)}get currentPdt(){return mI(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ci.MSE||e===Ci.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ci.MSE||e===Ci.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(e=>e.startsWith("metadata-")&&![P.METADATA_URL].includes(e)).reduce((e,t)=>{let s=this.getAttribute(t);return s!=null&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=s),e},{}),...I(this,Ra)}}set metadata(e){ie(this,Ra,e??{}),this.mux&&this.mux.emit("hb",I(this,Ra))}get _hlsConfig(){return I(this,bd)}set _hlsConfig(e){ie(this,bd,e)}load(){ie(this,Ai,MI(this,this.nativeEl,I(this,Ai)))}unload(){XE(this.nativeEl,I(this,Ai)),ie(this,Ai,void 0)}attributeChangedCallback(e,t,s){var r,n;switch(Uu.observedAttributes.includes(e)&&!["src","autoplay","preload"].includes(e)&&super.attributeChangedCallback(e,t,s),e){case P.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=s??void 0;break;case P.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=s??void 0;break;case"src":{let a=!!t,o=!!s;!a&&o?Fe(this,wa,Ad).call(this):a&&!o?this.unload():a&&o&&(this.unload(),Fe(this,wa,Ad).call(this));break}case"autoplay":if(s===t)break;(r=I(this,Ai))==null||r.setAutoplay(this.autoplay);break;case"preload":if(s===t)break;(n=I(this,Ai))==null||n.setPreload(s);break;case P.PLAYBACK_ID:this.src=uh(this);break;case P.DEBUG:{let a=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=a);break}case P.METADATA_URL:s&&fetch(s).then(a=>a.json()).then(a=>this.metadata=a).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${s}!`));break;case P.STREAM_TYPE:(s==null||s!==t)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case P.TARGET_LIVE_WINDOW:(s==null||s!==t)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break}}connectedCallback(){var e;(e=super.connectedCallback)==null||e.call(this),this.nativeEl&&this.src&&!I(this,Ai)&&Fe(this,wa,Ad).call(this)}disconnectedCallback(){this.unload()}};Ai=new WeakMap,Ia=new WeakMap,Ed=new WeakMap,Ra=new WeakMap,bd=new WeakMap,yd=new WeakMap,Td=new WeakMap,_d=new WeakMap,wa=new WeakSet,Ad=async function(){I(this,Ia)||(await ie(this,Ia,Promise.resolve()),ie(this,Ia,null),this.load())};var Gf=class extends kD(FD(KD)){};Nu.customElements.get("mux-video")||(Nu.customElements.define("mux-video",Gf),Nu.MuxVideoElement=Gf);var VD=Gf,qD=Object.defineProperty,YD=(i,e,t)=>e in i?qD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,jD=(i,e,t)=>(YD(i,e+"",t),t),LT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ce=(i,e,t)=>(LT(i,e,"read from private field"),t?t.call(i):e.get(i)),Ii=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qi=(i,e,t,s)=>(LT(i,e,"write to private field"),e.set(i,t),t),ln,Sd,Xs,Ca,ds,cs,us,Qs,dn,xd,zt;const Fg=1,$g=0,zD=1,XD={processCallback(i,e,t){if(t){for(const[s,r]of e)if(s in t){const n=t[s];typeof n=="boolean"&&r instanceof ai&&typeof r.element[r.attributeName]=="boolean"?r.booleanValue=n:typeof n=="function"&&r instanceof ai?r.element[r.attributeName]=n:r.value=n}}}};class $c extends k.DocumentFragment{constructor(e,t,s=XD){var r;super(),Ii(this,ln,void 0),Ii(this,Sd,void 0),this.append(e.content.cloneNode(!0)),Qi(this,ln,IT(this)),Qi(this,Sd,s),(r=s.createCallback)==null||r.call(s,this,ce(this,ln),t),s.processCallback(this,ce(this,ln),t)}update(e){ce(this,Sd).processCallback(this,ce(this,ln),e)}}ln=new WeakMap;Sd=new WeakMap;const IT=(i,e=[])=>{let t,s;for(let r of i.attributes||[])if(r.value.includes("{{")){const n=new ZD;for([t,s]of Gg(r.value))if(!t)n.append(s);else{const a=new ai(i,r.name,r.namespaceURI);n.append(a),e.push([s,a])}r.value=n.toString()}for(let r of i.childNodes)if(r.nodeType===Fg&&!(r instanceof HTMLTemplateElement))IT(r,e);else if(r.nodeType===Fg||r.data.includes("{{")){const n=[];if(r.data)for([t,s]of Gg(r.data))if(!t)n.push(new Text(s));else{const a=new Gn(i);n.push(a),e.push([s,a])}else if(r instanceof HTMLTemplateElement){const a=new CT(i,r);n.push(a),e.push([a.expression,a])}r.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},Bg={},Gg=i=>{let e="",t=0,s=Bg[i],r=0,n;if(s)return s;for(s=[];n=i[r];r++)n==="{"&&i[r+1]==="{"&&i[r-1]!=="\\"&&i[r+2]&&++t==1?(e&&s.push([$g,e]),e="",r++):n==="}"&&i[r+1]==="}"&&i[r-1]!=="\\"&&!--t?(s.push([zD,e.trim()]),e="",r++):e+=n||"";return e&&s.push([$g,(t>0?"{{":"")+e]),Bg[i]=s},QD=11;class RT{get value(){return""}set value(e){}toString(){return this.value}}const wT=new WeakMap;class ZD{constructor(){Ii(this,Xs,[])}[Symbol.iterator](){return ce(this,Xs).values()}get length(){return ce(this,Xs).length}item(e){return ce(this,Xs)[e]}append(...e){for(const t of e)t instanceof ai&&wT.set(t,this),ce(this,Xs).push(t)}toString(){return ce(this,Xs).join("")}}Xs=new WeakMap;class ai extends RT{constructor(e,t,s){super(),Ii(this,Qs),Ii(this,Ca,""),Ii(this,ds,void 0),Ii(this,cs,void 0),Ii(this,us,void 0),Qi(this,ds,e),Qi(this,cs,t),Qi(this,us,s)}get attributeName(){return ce(this,cs)}get attributeNamespace(){return ce(this,us)}get element(){return ce(this,ds)}get value(){return ce(this,Ca)}set value(e){ce(this,Ca)!==e&&(Qi(this,Ca,e),!ce(this,Qs,dn)||ce(this,Qs,dn).length===1?e==null?ce(this,ds).removeAttributeNS(ce(this,us),ce(this,cs)):ce(this,ds).setAttributeNS(ce(this,us),ce(this,cs),e):ce(this,ds).setAttributeNS(ce(this,us),ce(this,cs),ce(this,Qs,dn)))}get booleanValue(){return ce(this,ds).hasAttributeNS(ce(this,us),ce(this,cs))}set booleanValue(e){if(!ce(this,Qs,dn)||ce(this,Qs,dn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}}Ca=new WeakMap;ds=new WeakMap;cs=new WeakMap;us=new WeakMap;Qs=new WeakSet;dn=function(){return wT.get(this)};class Gn extends RT{constructor(e,t){super(),Ii(this,xd,void 0),Ii(this,zt,void 0),Qi(this,xd,e),Qi(this,zt,t?[...t]:[new Text])}get replacementNodes(){return ce(this,zt)}get parentNode(){return ce(this,xd)}get nextSibling(){return ce(this,zt)[ce(this,zt).length-1].nextSibling}get previousSibling(){return ce(this,zt)[0].previousSibling}get value(){return ce(this,zt).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){const t=e.flat().flatMap(s=>s==null?[new Text]:s.forEach?[...s]:s.nodeType===QD?[...s.childNodes]:s.nodeType?[s]:[new Text(s)]);t.length||t.push(new Text),Qi(this,zt,JD(ce(this,zt)[0].parentNode,ce(this,zt),t,this.nextSibling))}}xd=new WeakMap;zt=new WeakMap;class CT extends Gn{constructor(e,t){let s=t.getAttribute("directive")||t.getAttribute("type"),r=t.getAttribute("expression")||t.getAttribute(s)||"";r.startsWith("{{")&&(r=r.trim().slice(2,-2).trim()),super(e),jD(this,"directive"),this.expression=r,this.template=t,this.directive=s}}function JD(i,e,t,s=null){let r=0,n,a,o,l=t.length,d=e.length;for(;r<l&&r<d&&e[r]==t[r];)r++;for(;r<l&&r<d&&t[l-1]==e[d-1];)s=t[--d,--l];if(r==d)for(;r<l;)i.insertBefore(t[r++],s);if(r==l)for(;r<d;)i.removeChild(e[r++]);else{for(n=e[r];r<l;)o=t[r++],a=n?n.nextSibling:s,n==o?n=a:r<l&&t[r]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=s;)a=n.nextSibling,i.removeChild(n),n=a}return t}const Hg={string:i=>String(i)};class DT{constructor(e){this.template=e,this.state=void 0}}const or=new WeakMap,lr=new WeakMap,Hf={partial:(i,e)=>{e[i.expression]=new DT(i.template)},if:(i,e)=>{var t;if(MT(i.expression,e))if(or.get(i)!==i.template){or.set(i,i.template);const s=new $c(i.template,e,Ep);i.replace(s),lr.set(i,s)}else(t=lr.get(i))==null||t.update(e);else i.replace(""),or.delete(i),lr.delete(i)}},eM=Object.keys(Hf),Ep={processCallback(i,e,t){var s,r;if(t)for(const[n,a]of e){if(a instanceof CT){if(!a.directive){const l=eM.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(s=Hf[a.directive])==null||s.call(Hf,a,t);continue}let o=MT(n,t);if(o instanceof DT){or.get(a)!==o.template?(or.set(a,o.template),o=new $c(o.template,o.state,Ep),a.value=o,lr.set(a,o)):(r=lr.get(a))==null||r.update(o.state);continue}o?(a instanceof ai&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof ai?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,or.delete(a),lr.delete(a))):a instanceof ai?a.value=void 0:(a.value=void 0,or.delete(a),lr.delete(a))}}},Wg={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i??e,"|":(i,e)=>{var t;return(t=Hg[e])==null?void 0:t.call(Hg,i)}};function tM(i){return iM(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function MT(i,e={}){var t,s,r,n,a,o,l;const d=tM(i);if(d.length===0||d.some(({type:c})=>!c))return ea(i);if(((t=d[0])==null?void 0:t.token)===">"){const c=e[(s=d[1])==null?void 0:s.token];if(!c)return ea(i);const u={...e};c.state=u;const h=d.slice(2);for(let f=0;f<h.length;f+=3){const m=(r=h[f])==null?void 0:r.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(u[m]=ta(g,e))}return c}if(d.length===1)return el(d[0])?ta(d[0].token,e):ea(i);if(d.length===2){const c=(o=d[0])==null?void 0:o.token,u=Wg[c];if(!u||!el(d[1]))return ea(i);const h=ta(d[1].token,e);return u(h)}if(d.length===3){const c=(l=d[1])==null?void 0:l.token,u=Wg[c];if(!u||!el(d[0])||!el(d[2]))return ea(i);const h=ta(d[0].token,e);if(c==="|")return u(h,d[2].token);const f=ta(d[2].token,e);return u(h,f)}}function ea(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function el({type:i}){return["number","boolean","string","param"].includes(i)}function ta(i,e){const t=i[0],s=i.slice(-1);return i==="true"||i==="false"?i==="true":t===s&&["'",'"'].includes(t)?i.slice(1,-1):nb(i)?parseFloat(i):e[i]}function iM(i,e){let t,s,r,n=[];for(;i;){r=null,t=i.length;for(let a in e)s=e[a].exec(i),s&&s.index<t&&(r={token:s[0],type:a,matches:s.slice(1)},t=s.index);t&&n.push({token:i.substr(0,t),type:void 0}),r&&n.push(r),i=i.substr(t+(r?r.token.length:0))}return n}var sM=Object.defineProperty,rM=(i,e,t)=>e in i?sM(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ao=(i,e,t)=>(rM(i,typeof e!="symbol"?e+"":e,t),t),bp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wf=(i,e,t)=>(bp(i,e,"read from private field"),t?t.call(i):e.get(i)),ia=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},dr=(i,e,t,s)=>(bp(i,e,"write to private field"),e.set(i,t),t),Bu=(i,e,t)=>(bp(i,e,"access private method"),t),xn,kd,kn,Kf,OT,Ld,Vf;const Gu={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},PT=z.createElement("template");PT.innerHTML=`
1649
+ `);var bT=(i,{tag:e,is:t})=>{var s,r,n,a,o,l,d,c,u,h,f,m,p,g,v,y;let b=(s=globalThis.document)==null?void 0:s.createElement(e,{is:t}),x=b?ED(b):[];return r=class extends i{constructor(){super(),Z(this,u),Z(this,f),Z(this,p),Z(this,v),Z(this,l,void 0),Z(this,d,void 0),Z(this,c,new Map),this.shadowRoot||(this.attachShadow({mode:"open"}),this.shadowRoot.append(this.constructor.template.content.cloneNode(!0)))}static get observedAttributes(){var _,S,A;return Fe(_=r,a,o).call(_),[...(A=(S=b==null?void 0:b.constructor)==null?void 0:S.observedAttributes)!=null?A:[],"autopictureinpicture","disablepictureinpicture","disableremoteplayback","autoplay","controls","controlslist","crossorigin","loop","muted","playsinline","poster","preload","src"]}get nativeEl(){var _,S,A;return(A=(S=(_=I(this,d))!=null?_:this.shadowRoot.querySelector(e))!=null?S:this.querySelector(":scope > [slot=media]"))!=null?A:this.querySelector(e)}set nativeEl(_){ie(this,d,_)}get defaultMuted(){return this.hasAttribute("muted")}set defaultMuted(_){this.toggleAttribute("muted",!!_)}get src(){return this.getAttribute("src")}set src(_){this.setAttribute("src",`${_}`)}get preload(){var _,S;return(S=this.getAttribute("preload"))!=null?S:(_=this.nativeEl)==null?void 0:_.preload}set preload(_){this.setAttribute("preload",`${_}`)}init(){var _,S;if(!this.nativeEl){let A=document.createElement(e,{is:t});A.part=e,this.shadowRoot.querySelector('slot[name="media"]').append(A)}this.nativeEl.muted=this.hasAttribute("muted");for(let A of x)Fe(this,p,g).call(this,A);this.shadowRoot.addEventListener("slotchange",this);for(let A of this.constructor.Events)(S=(_=this.shadowRoot).addEventListener)==null||S.call(_,A,this,!0)}handleEvent(_){if(_.type==="slotchange"){Fe(this,f,m).call(this);return}_.target===this.nativeEl&&this.dispatchEvent(new CustomEvent(_.type,{detail:_.detail}))}attributeChangedCallback(_,S,A){Fe(this,u,h).call(this),Fe(this,v,y).call(this,_,S,A)}connectedCallback(){Fe(this,u,h).call(this)}},n=new WeakMap,a=new WeakSet,o=function(){if(I(this,n))return;ie(this,n,!0);let _=new Set(this.observedAttributes);_.delete("muted");for(let S of x)if(!(S in this.prototype))if(typeof b[S]=="function")this.prototype[S]=function(...A){return Fe(this,u,h).call(this),this.call?this.call(S,...A):this.nativeEl[S].apply(this.nativeEl,A)};else{let A={get(){var D,O,L;Fe(this,u,h).call(this);let C=S.toLowerCase();if(_.has(C)){let H=this.getAttribute(C);return H===null?!1:H===""?!0:H}return(L=(D=this.get)==null?void 0:D.call(this,S))!=null?L:(O=this.nativeEl)==null?void 0:O[S]}};S!==S.toUpperCase()&&(A.set=function(D){Fe(this,u,h).call(this);let O=S.toLowerCase();if(_.has(O)){D===!0||D===!1||D==null?this.toggleAttribute(O,!!D):this.setAttribute(O,D);return}if(this.set){this.set(S,D);return}this.nativeEl[S]=D}),Object.defineProperty(this.prototype,S,A)}},l=new WeakMap,d=new WeakMap,c=new WeakMap,u=new WeakSet,h=function(){I(this,l)||(ie(this,l,!0),this.init())},f=new WeakSet,m=function(){let _=new Map(I(this,c));this.shadowRoot.querySelector("slot:not([name])").assignedElements().filter(S=>["track","source"].includes(S.localName)).forEach(S=>{var A,D;_.delete(S);let O=I(this,c).get(S);O||(O=S.cloneNode(),I(this,c).set(S,O)),(D=(A=this.nativeEl).append)==null||D.call(A,O),O.localName==="track"&&O.default&&(O.kind==="chapters"||O.kind==="metadata")&&O.track.mode==="disabled"&&(O.track.mode="hidden")}),_.forEach(S=>S.remove())},p=new WeakSet,g=function(_){if(Object.prototype.hasOwnProperty.call(this,_)){let S=this[_];delete this[_],this[_]=S}},v=new WeakSet,y=function(_,S,A){var D,O,L,C,H,U;["id","class"].includes(_)||!r.observedAttributes.includes(_)&&this.constructor.observedAttributes.includes(_)||(A===null?(O=(D=this.nativeEl).removeAttribute)==null||O.call(D,_):((C=(L=this.nativeEl).getAttribute)==null?void 0:C.call(L,_))!=A&&((U=(H=this.nativeEl).setAttribute)==null||U.call(H,_,A)))},Z(r,a),Ie(r,"Events",pp),Ie(r,"template",e.endsWith("audio")?Sf:xf),Z(r,n,void 0),r};function ED(i){let e=[];for(let t=Object.getPrototypeOf(i);t&&t!==HTMLElement.prototype;t=Object.getPrototypeOf(t))e.push(...Object.getOwnPropertyNames(t));return e}var Uu=globalThis.document?bT(HTMLElement,{tag:"video"}):class{};globalThis.document&&bT(HTMLElement,{tag:"audio"});var yr=new WeakMap,Fu=class extends Error{},bD=class extends Error{},yD=globalThis.WeakRef?class extends Set{add(i){super.add(new WeakRef(i))}forEach(i){super.forEach(e=>{let t=e.deref();t&&i(t)})}}:Set;function TD(i){yT()?TT()?i(chrome.cast.isAvailable):customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable)):globalThis.__onGCastApiAvailable=()=>{customElements.whenDefined("google-cast-button").then(()=>i(chrome.cast.isAvailable))}}function _D(){return globalThis.chrome}function AD(){let i="https://www.gstatic.com/cv/js/sender/v1/cast_sender.js?loadCastFramework=1";if(globalThis.chrome.cast||document.querySelector(`script[src="${i}"]`))return;let e=document.createElement("script");e.src=i,document.head.append(e)}function yT(){return typeof chrome<"u"&&chrome.cast&&chrome.cast.isAvailable}function TT(){return typeof cast<"u"&&cast.framework}function xr(){if(TT())return cast.framework.CastContext.getInstance()}function gp(){var i;return(i=xr())==null?void 0:i.getCurrentSession()}function vp(){var i;return(i=gp())==null?void 0:i.getSessionObj().media[0]}function SD(i){return new Promise((e,t)=>{vp().editTracksInfo(i,e,t)})}function xD(i){return new Promise((e,t)=>{vp().getStatus(i,e,t)})}function _T(i){return xr().setOptions({...AT(),...i})}function AT(){return{receiverApplicationId:"CC1AD845",autoJoinPolicy:"origin_scoped",androidReceiverCompatible:!1,language:"en-US",resumeSavedSession:!0}}var fd=new yD,ys=new WeakSet,Ye;TD(i=>{i&&!Ye&&(Ye=cast.framework,xr().addEventListener(Ye.CastContextEventType.CAST_STATE_CHANGED,e=>{fd.forEach(t=>{var s,r;return(r=(s=yr.get(t)).onCastStateChanged)==null?void 0:r.call(s,e)})}),xr().addEventListener(Ye.CastContextEventType.SESSION_STATE_CHANGED,e=>{fd.forEach(t=>{var s,r;return(r=(s=yr.get(t)).onSessionStateChanged)==null?void 0:r.call(s,e)})}),fd.forEach(e=>{var t,s;return(s=(t=yr.get(e)).init)==null?void 0:s.call(t)}))});var Mg=0,ve,md,Wt,ps,vn,rn,ar,kf,gs,Us,Lf,Og,Tc,If,Rf,ST,pd,wf,Cf,Pg,gd,$u,kD=class extends EventTarget{constructor(i){super(),Z(this,gs),Z(this,Lf),Z(this,Tc),Z(this,Rf),Z(this,pd),Z(this,Cf),Z(this,gd),Z(this,ve,void 0),Z(this,md,void 0),Z(this,Wt,void 0),Z(this,ps,void 0),Z(this,vn,"disconnected"),Z(this,rn,!1),Z(this,ar,new Set),Z(this,kf,new WeakMap),ie(this,ve,i),fd.add(this),yr.set(this,{init:()=>Fe(this,pd,wf).call(this),onCastStateChanged:()=>Fe(this,Tc,If).call(this),onSessionStateChanged:()=>Fe(this,Rf,ST).call(this),getCastPlayer:()=>I(this,gs,Us)}),Fe(this,pd,wf).call(this)}get state(){return I(this,vn)}async watchAvailability(i){if(I(this,ve).disableRemotePlayback)throw new Fu("disableRemotePlayback attribute is present.");return I(this,kf).set(i,++Mg),I(this,ar).add(i),Mg}async cancelWatchAvailability(i){if(I(this,ve).disableRemotePlayback)throw new Fu("disableRemotePlayback attribute is present.");i?I(this,ar).delete(i):I(this,ar).clear()}async prompt(){var i,e;if(I(this,ve).disableRemotePlayback)throw new Fu("disableRemotePlayback attribute is present.");if(!yT())throw new bD("The RemotePlayback API is disabled on this platform.");let t=ys.has(I(this,ve));ys.add(I(this,ve)),_T(I(this,ve).castOptions),Object.entries(I(this,ps)).forEach(([s,r])=>{I(this,Wt).controller.addEventListener(s,r)});try{await xr().requestSession()}catch(s){if(s==="cancel"){t||ys.delete(I(this,ve));return}throw new Error(s)}(e=(i=yr.get(I(this,ve)))==null?void 0:i.loadOnPrompt)==null||e.call(i)}};ve=new WeakMap,md=new WeakMap,Wt=new WeakMap,ps=new WeakMap,vn=new WeakMap,rn=new WeakMap,ar=new WeakMap,kf=new WeakMap,gs=new WeakSet,Us=function(){if(ys.has(I(this,ve)))return I(this,Wt)},Lf=new WeakSet,Og=function(){ys.has(I(this,ve))&&(Object.entries(I(this,ps)).forEach(([i,e])=>{I(this,Wt).controller.removeEventListener(i,e)}),ys.delete(I(this,ve)),I(this,ve).muted=I(this,Wt).isMuted,I(this,ve).currentTime=I(this,Wt).savedPlayerState.currentTime,I(this,Wt).savedPlayerState.isPaused===!1&&I(this,ve).play())},Tc=new WeakSet,If=function(){let i=xr().getCastState();if(ys.has(I(this,ve))&&i==="CONNECTING"&&(ie(this,vn,"connecting"),this.dispatchEvent(new Event("connecting"))),!I(this,rn)&&i!=null&&i.includes("CONNECT")){ie(this,rn,!0);for(let e of I(this,ar))e(!0)}else if(I(this,rn)&&(!i||i==="NO_DEVICES_AVAILABLE")){ie(this,rn,!1);for(let e of I(this,ar))e(!1)}},Rf=new WeakSet,ST=async function(){var i;let{SESSION_RESUMED:e}=Ye.SessionState;if(xr().getSessionState()===e&&I(this,ve).castSrc===((i=vp())==null?void 0:i.media.contentId)){ys.add(I(this,ve)),Object.entries(I(this,ps)).forEach(([t,s])=>{I(this,Wt).controller.addEventListener(t,s)});try{await xD(new chrome.cast.media.GetStatusRequest)}catch(t){console.error(t)}I(this,ps)[Ye.RemotePlayerEventType.IS_PAUSED_CHANGED](),I(this,ps)[Ye.RemotePlayerEventType.PLAYER_STATE_CHANGED]()}},pd=new WeakSet,wf=function(){!Ye||I(this,md)||(ie(this,md,!0),_T(I(this,ve).castOptions),I(this,ve).textTracks.addEventListener("change",()=>Fe(this,gd,$u).call(this)),Fe(this,Tc,If).call(this),ie(this,Wt,new Ye.RemotePlayer),new Ye.RemotePlayerController(I(this,Wt)),ie(this,ps,{[Ye.RemotePlayerEventType.IS_CONNECTED_CHANGED]:({value:i})=>{i===!0?(ie(this,vn,"connected"),this.dispatchEvent(new Event("connect"))):(Fe(this,Lf,Og).call(this),ie(this,vn,"disconnected"),this.dispatchEvent(new Event("disconnect")))},[Ye.RemotePlayerEventType.DURATION_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("durationchange"))},[Ye.RemotePlayerEventType.VOLUME_LEVEL_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("volumechange"))},[Ye.RemotePlayerEventType.IS_MUTED_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("volumechange"))},[Ye.RemotePlayerEventType.CURRENT_TIME_CHANGED]:()=>{var i;(i=I(this,gs,Us))!=null&&i.isMediaLoaded&&I(this,ve).dispatchEvent(new Event("timeupdate"))},[Ye.RemotePlayerEventType.VIDEO_INFO_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event("resize"))},[Ye.RemotePlayerEventType.IS_PAUSED_CHANGED]:()=>{I(this,ve).dispatchEvent(new Event(this.paused?"pause":"play"))},[Ye.RemotePlayerEventType.PLAYER_STATE_CHANGED]:()=>{var i,e;((i=I(this,gs,Us))==null?void 0:i.playerState)!==chrome.cast.media.PlayerState.PAUSED&&I(this,ve).dispatchEvent(new Event({[chrome.cast.media.PlayerState.PLAYING]:"playing",[chrome.cast.media.PlayerState.BUFFERING]:"waiting",[chrome.cast.media.PlayerState.IDLE]:"emptied"}[(e=I(this,gs,Us))==null?void 0:e.playerState]))},[Ye.RemotePlayerEventType.IS_MEDIA_LOADED_CHANGED]:async()=>{var i;(i=I(this,gs,Us))!=null&&i.isMediaLoaded&&(await Promise.resolve(),Fe(this,Cf,Pg).call(this))}}))},Cf=new WeakSet,Pg=function(){Fe(this,gd,$u).call(this)},gd=new WeakSet,$u=async function(){var i,e,t,s,r;if(!I(this,gs,Us))return;let n=((e=(i=I(this,Wt).mediaInfo)==null?void 0:i.tracks)!=null?e:[]).filter(({type:h})=>h===chrome.cast.media.TrackType.TEXT),a=[...I(this,ve).textTracks].filter(({kind:h})=>h==="subtitles"||h==="captions"),o=n.map(({language:h,name:f,trackId:m})=>{var p;let{mode:g}=(p=a.find(v=>v.language===h&&v.label===f))!=null?p:{};return g?{mode:g,trackId:m}:!1}).filter(Boolean),l=o.filter(({mode:h})=>h!=="showing").map(({trackId:h})=>h),d=o.find(({mode:h})=>h==="showing"),c=(r=(s=(t=gp())==null?void 0:t.getSessionObj().media[0])==null?void 0:s.activeTrackIds)!=null?r:[],u=c;if(c.length&&(u=u.filter(h=>!l.includes(h))),d!=null&&d.trackId&&(u=[...u,d.trackId]),u=[...new Set(u)],!((h,f)=>h.length===f.length&&h.every(m=>f.includes(m)))(c,u))try{let h=new chrome.cast.media.EditTracksInfoRequest(u);await SD(h)}catch(h){console.error(h)}};var LD=i=>{var e,t,s,r,n,a,o,l,d;return t=class extends i{constructor(){super(...arguments),Z(this,a),Z(this,l),Z(this,s,{paused:!1}),Z(this,r,AT()),Z(this,n,void 0)}get remote(){return I(this,n)?I(this,n):_D()?(AD(),yr.set(this,{loadOnPrompt:()=>Fe(this,l,d).call(this)}),ie(this,n,new kD(this))):super.remote}attributeChangedCallback(c,u,h){if(super.attributeChangedCallback(c,u,h),c==="cast-receiver"&&h){I(this,r).receiverApplicationId=h;return}if(I(this,a,o))switch(c){case"cast-stream-type":case"cast-src":this.load();break}}async load(){var c,u;if(!I(this,a,o))return super.load();let h=new chrome.cast.media.MediaInfo(this.castSrc,this.castContentType),f=[...this.querySelectorAll("track")].filter(({kind:v,src:y})=>y&&(v==="subtitles"||v==="captions")),m=[],p=0;f.length&&(h.tracks=f.map(v=>{let y=++p;m.length===0&&v.track.mode==="showing"&&m.push(y);let b=new chrome.cast.media.Track(y,chrome.cast.media.TrackType.TEXT);return b.trackContentId=v.src,b.trackContentType="text/vtt",b.subtype=v.kind==="captions"?chrome.cast.media.TextTrackType.CAPTIONS:chrome.cast.media.TextTrackType.SUBTITLES,b.name=v.label,b.language=v.srclang,b})),this.castStreamType==="live"?h.streamType=chrome.cast.media.StreamType.LIVE:h.streamType=chrome.cast.media.StreamType.BUFFERED,h.metadata=new chrome.cast.media.GenericMediaMetadata,h.metadata.title=this.title,h.metadata.images=[{url:this.poster}];let g=new chrome.cast.media.LoadRequest(h);g.currentTime=(c=super.currentTime)!=null?c:0,g.autoplay=!I(this,s).paused,g.activeTrackIds=m,await((u=gp())==null?void 0:u.loadMedia(g)),this.dispatchEvent(new Event("volumechange"))}play(){var c;if(I(this,a,o)){I(this,a,o).isPaused&&((c=I(this,a,o).controller)==null||c.playOrPause());return}return super.play()}pause(){var c;if(I(this,a,o)){I(this,a,o).isPaused||(c=I(this,a,o).controller)==null||c.playOrPause();return}super.pause()}get castOptions(){return I(this,r)}get castReceiver(){var c;return(c=this.getAttribute("cast-receiver"))!=null?c:void 0}set castReceiver(c){this.castReceiver!=c&&this.setAttribute("cast-receiver",`${c}`)}get castSrc(){var c,u,h;return(h=(u=this.getAttribute("cast-src"))!=null?u:(c=this.querySelector("source"))==null?void 0:c.src)!=null?h:this.currentSrc}set castSrc(c){this.castSrc!=c&&this.setAttribute("cast-src",`${c}`)}get castContentType(){var c;return(c=this.getAttribute("cast-content-type"))!=null?c:void 0}set castContentType(c){this.setAttribute("cast-content-type",`${c}`)}get castStreamType(){var c,u;return(u=(c=this.getAttribute("cast-stream-type"))!=null?c:this.streamType)!=null?u:void 0}set castStreamType(c){this.setAttribute("cast-stream-type",`${c}`)}get readyState(){if(I(this,a,o))switch(I(this,a,o).playerState){case chrome.cast.media.PlayerState.IDLE:return 0;case chrome.cast.media.PlayerState.BUFFERING:return 2;default:return 3}return super.readyState}get paused(){return I(this,a,o)?I(this,a,o).isPaused:super.paused}get muted(){var c;return I(this,a,o)?(c=I(this,a,o))==null?void 0:c.isMuted:super.muted}set muted(c){var u;if(I(this,a,o)){(c&&!I(this,a,o).isMuted||!c&&I(this,a,o).isMuted)&&((u=I(this,a,o).controller)==null||u.muteOrUnmute());return}super.muted=c}get volume(){var c,u;return I(this,a,o)?(u=(c=I(this,a,o))==null?void 0:c.volumeLevel)!=null?u:1:super.volume}set volume(c){var u;if(I(this,a,o)){I(this,a,o).volumeLevel=+c,(u=I(this,a,o).controller)==null||u.setVolumeLevel();return}super.volume=c}get duration(){var c,u,h;return I(this,a,o)&&(c=I(this,a,o))!=null&&c.isMediaLoaded?(h=(u=I(this,a,o))==null?void 0:u.duration)!=null?h:NaN:super.duration}get currentTime(){var c,u,h;return I(this,a,o)&&(c=I(this,a,o))!=null&&c.isMediaLoaded?(h=(u=I(this,a,o))==null?void 0:u.currentTime)!=null?h:0:super.currentTime}set currentTime(c){var u;if(I(this,a,o)){I(this,a,o).currentTime=c,(u=I(this,a,o).controller)==null||u.seek();return}super.currentTime=c}},s=new WeakMap,r=new WeakMap,n=new WeakMap,a=new WeakSet,o=function(){var c,u;return(u=(c=yr.get(this.remote))==null?void 0:c.getCastPlayer)==null?void 0:u.call(c)},l=new WeakSet,d=async function(){I(this,s).paused=Pu(t.prototype,this,"paused"),Pu(t.prototype,this,"pause").call(this),this.muted=Pu(t.prototype,this,"muted");try{await this.load()}catch(c){console.error(c)}},Ie(t,"observedAttributes",[...(e=i.observedAttributes)!=null?e:[],"cast-src","cast-content-type","cast-stream-type","cast-receiver"]),t},Uc=class extends Event{constructor(e,t){super(e),Ie(this,"track"),this.track=t.track}},Df=new WeakMap;function V(i){var e;return(e=Df.get(i))!=null?e:ID(i,{})}function ID(i,e){let t=Df.get(i);return t||Df.set(i,t={}),Object.assign(t,e)}function Mf(i,e){let t=i.videoTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let s=V(t).trackSet;s.add(e);let r=s.size-1;r in Pf.prototype||Object.defineProperty(Pf.prototype,r,{get(){return[...V(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new Uc("addtrack",{track:e}))})}function Of(i){var e;let t=(e=V(i).media)==null?void 0:e.videoTracks;t&&(V(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Uc("removetrack",{track:i}))}))}function RD(i){var e;let t=(e=V(i).media.videoTracks)!=null?e:[],s=!1;for(let r of t)r!==i&&(r.selected=!1,s=!0);if(s){if(V(t).changeRequested)return;V(t).changeRequested=!0,queueMicrotask(()=>{delete V(t).changeRequested,t.dispatchEvent(new Event("change"))})}}var Fs,$s,Bs,nn,_a,Pf=class extends EventTarget{constructor(){super(),Z(this,nn),Z(this,Fs,void 0),Z(this,$s,void 0),Z(this,Bs,void 0),V(this).trackSet=new Set}[Symbol.iterator](){return I(this,nn,_a).values()}get length(){return I(this,nn,_a).size}getTrackById(e){var t;return(t=[...I(this,nn,_a)].find(s=>s.id===e))!=null?t:null}get selectedIndex(){return[...I(this,nn,_a)].findIndex(e=>e.selected)}get onaddtrack(){return I(this,Fs)}set onaddtrack(e){I(this,Fs)&&(this.removeEventListener("addtrack",I(this,Fs)),ie(this,Fs,void 0)),typeof e=="function"&&(ie(this,Fs,e),this.addEventListener("addtrack",e))}get onremovetrack(){return I(this,$s)}set onremovetrack(e){I(this,$s)&&(this.removeEventListener("removetrack",I(this,$s)),ie(this,$s,void 0)),typeof e=="function"&&(ie(this,$s,e),this.addEventListener("removetrack",e))}get onchange(){return I(this,Bs)}set onchange(e){I(this,Bs)&&(this.removeEventListener("change",I(this,Bs)),ie(this,Bs,void 0)),typeof e=="function"&&(ie(this,Bs,e),this.addEventListener("change",e))}};Fs=new WeakMap,$s=new WeakMap,Bs=new WeakMap,nn=new WeakSet,_a=function(){return V(this).trackSet};var Fc=class extends Event{constructor(i,e){super(i),Ie(this,"rendition"),this.rendition=e.rendition}};function wD(i,e){let t=V(i).media.videoRenditions;V(e).media=V(i).media,V(e).track=i;let s=V(i).renditionSet;s.add(e);let r=s.size-1;r in Nf.prototype||Object.defineProperty(Nf.prototype,r,{get(){return an(this)[r]}}),queueMicrotask(()=>{i.selected&&t.dispatchEvent(new Fc("addrendition",{rendition:e}))})}function CD(i){let e=V(i).media.videoRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.selected&&e.dispatchEvent(new Fc("removerendition",{rendition:i}))})}function DD(i){let e=V(i).media.videoRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.selected&&e.dispatchEvent(new Event("change"))}))}function an(i){return[...V(i).media.videoTracks].filter(e=>e.selected).flatMap(e=>[...V(e).renditionSet])}var Gs,Hs,Ws,Nf=class extends EventTarget{constructor(){super(...arguments),Z(this,Gs,void 0),Z(this,Hs,void 0),Z(this,Ws,void 0)}[Symbol.iterator](){return an(this).values()}get length(){return an(this).length}getRenditionById(e){var t;return(t=an(this).find(s=>`${s.id}`==`${e}`))!=null?t:null}get selectedIndex(){return an(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,s]of an(this).entries())s.selected=t===e}get onaddrendition(){return I(this,Gs)}set onaddrendition(e){I(this,Gs)&&(this.removeEventListener("addrendition",I(this,Gs)),ie(this,Gs,void 0)),typeof e=="function"&&(ie(this,Gs,e),this.addEventListener("addrendition",e))}get onremoverendition(){return I(this,Hs)}set onremoverendition(e){I(this,Hs)&&(this.removeEventListener("removerendition",I(this,Hs)),ie(this,Hs,void 0)),typeof e=="function"&&(ie(this,Hs,e),this.addEventListener("removerendition",e))}get onchange(){return I(this,Ws)}set onchange(e){I(this,Ws)&&(this.removeEventListener("change",I(this,Ws)),ie(this,Ws,void 0)),typeof e=="function"&&(ie(this,Ws,e),this.addEventListener("change",e))}};Gs=new WeakMap,Hs=new WeakMap,Ws=new WeakMap;var Aa,MD=class{constructor(){Ie(this,"src"),Ie(this,"id"),Ie(this,"width"),Ie(this,"height"),Ie(this,"bitrate"),Ie(this,"frameRate"),Ie(this,"codec"),Z(this,Aa,!1)}get selected(){return I(this,Aa)}set selected(i){I(this,Aa)!==i&&(ie(this,Aa,i),DD(this))}};Aa=new WeakMap;var Sa,xT=class{constructor(){Ie(this,"id"),Ie(this,"kind"),Ie(this,"label",""),Ie(this,"language",""),Ie(this,"sourceBuffer"),Z(this,Sa,!1)}addRendition(i,e,t,s,r,n){let a=new MD;return a.src=i,a.width=e,a.height=t,a.frameRate=n,a.bitrate=r,a.codec=s,wD(this,a),a}removeRendition(i){CD(i)}get selected(){return I(this,Sa)}set selected(i){I(this,Sa)!==i&&(ie(this,Sa,i),i===!0&&RD(this))}};Sa=new WeakMap;function OD(i,e){let t=V(i).media.audioRenditions;V(e).media=V(i).media,V(e).track=i;let s=V(i).renditionSet;s.add(e);let r=s.size-1;r in Uf.prototype||Object.defineProperty(Uf.prototype,r,{get(){return on(this)[r]}}),queueMicrotask(()=>{i.enabled&&t.dispatchEvent(new Fc("addrendition",{rendition:e}))})}function PD(i){let e=V(i).media.audioRenditions,t=V(i).track;V(t).renditionSet.delete(i),queueMicrotask(()=>{V(i).track.enabled&&e.dispatchEvent(new Fc("removerendition",{rendition:i}))})}function ND(i){let e=V(i).media.audioRenditions;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,V(i).track.enabled&&e.dispatchEvent(new Event("change"))}))}function on(i){return[...V(i).media.audioTracks].filter(e=>e.enabled).flatMap(e=>[...V(e).renditionSet])}var Ks,Vs,qs,Uf=class extends EventTarget{constructor(){super(...arguments),Z(this,Ks,void 0),Z(this,Vs,void 0),Z(this,qs,void 0)}[Symbol.iterator](){return on(this).values()}get length(){return on(this).length}getRenditionById(e){var t;return(t=on(this).find(s=>`${s.id}`==`${e}`))!=null?t:null}get selectedIndex(){return on(this).findIndex(e=>e.selected)}set selectedIndex(e){for(let[t,s]of on(this).entries())s.selected=t===e}get onaddrendition(){return I(this,Ks)}set onaddrendition(e){I(this,Ks)&&(this.removeEventListener("addrendition",I(this,Ks)),ie(this,Ks,void 0)),typeof e=="function"&&(ie(this,Ks,e),this.addEventListener("addrendition",e))}get onremoverendition(){return I(this,Vs)}set onremoverendition(e){I(this,Vs)&&(this.removeEventListener("removerendition",I(this,Vs)),ie(this,Vs,void 0)),typeof e=="function"&&(ie(this,Vs,e),this.addEventListener("removerendition",e))}get onchange(){return I(this,qs)}set onchange(e){I(this,qs)&&(this.removeEventListener("change",I(this,qs)),ie(this,qs,void 0)),typeof e=="function"&&(ie(this,qs,e),this.addEventListener("change",e))}};Ks=new WeakMap,Vs=new WeakMap,qs=new WeakMap;var xa,UD=class{constructor(){Ie(this,"src"),Ie(this,"id"),Ie(this,"bitrate"),Ie(this,"codec"),Z(this,xa,!1)}get selected(){return I(this,xa)}set selected(e){I(this,xa)!==e&&(ie(this,xa,e),ND(this))}};xa=new WeakMap;function Ff(i,e){let t=i.audioTracks;V(e).media=i,V(e).renditionSet||(V(e).renditionSet=new Set);let s=V(t).trackSet;s.add(e);let r=s.size-1;r in Bf.prototype||Object.defineProperty(Bf.prototype,r,{get(){return[...V(this).trackSet][r]}}),queueMicrotask(()=>{t.dispatchEvent(new Uc("addtrack",{track:e}))})}function $f(i){var e;let t=(e=V(i).media)==null?void 0:e.audioTracks;t&&(V(t).trackSet.delete(i),queueMicrotask(()=>{t.dispatchEvent(new Uc("removetrack",{track:i}))}))}function FD(i){let e=V(i).media.audioTracks;!e||V(e).changeRequested||(V(e).changeRequested=!0,queueMicrotask(()=>{delete V(e).changeRequested,e.dispatchEvent(new Event("change"))}))}var Ys,js,zs,ka,vd,Bf=class extends EventTarget{constructor(){super(),Z(this,ka),Z(this,Ys,void 0),Z(this,js,void 0),Z(this,zs,void 0),V(this).trackSet=new Set}[Symbol.iterator](){return I(this,ka,vd).values()}get length(){return I(this,ka,vd).size}getTrackById(i){var e;return(e=[...I(this,ka,vd)].find(t=>t.id===i))!=null?e:null}get onaddtrack(){return I(this,Ys)}set onaddtrack(i){I(this,Ys)&&(this.removeEventListener("addtrack",I(this,Ys)),ie(this,Ys,void 0)),typeof i=="function"&&(ie(this,Ys,i),this.addEventListener("addtrack",i))}get onremovetrack(){return I(this,js)}set onremovetrack(i){I(this,js)&&(this.removeEventListener("removetrack",I(this,js)),ie(this,js,void 0)),typeof i=="function"&&(ie(this,js,i),this.addEventListener("removetrack",i))}get onchange(){return I(this,zs)}set onchange(i){I(this,zs)&&(this.removeEventListener("change",I(this,zs)),ie(this,zs,void 0)),typeof i=="function"&&(ie(this,zs,i),this.addEventListener("change",i))}};Ys=new WeakMap,js=new WeakMap,zs=new WeakMap,ka=new WeakSet,vd=function(){return V(this).trackSet};var La,kT=class{constructor(){Ie(this,"id"),Ie(this,"kind"),Ie(this,"label",""),Ie(this,"language",""),Ie(this,"sourceBuffer"),Z(this,La,!1)}addRendition(e,t,s){let r=new UD;return r.src=e,r.codec=t,r.bitrate=s,OD(this,r),r}removeRendition(e){PD(e)}get enabled(){return I(this,La)}set enabled(e){I(this,La)!==e&&(ie(this,La,e),FD(this))}};La=new WeakMap;var Ng=_c(globalThis.HTMLMediaElement,"video"),Ug=_c(globalThis.HTMLMediaElement,"audio");function $D(i){if(!(i!=null&&i.prototype))return i;let e=_c(i,"video");(!e||`${e}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"videoTracks",{get(){return BD(this)}});let t=_c(i,"audio");(!t||`${t}`.includes("[native code]"))&&Object.defineProperty(i.prototype,"audioTracks",{get(){return GD(this)}}),"addVideoTrack"in i.prototype||(i.prototype.addVideoTrack=function(n,a="",o=""){let l=new xT;return l.kind=n,l.label=a,l.language=o,Mf(this,l),l}),"removeVideoTrack"in i.prototype||(i.prototype.removeVideoTrack=Of),"addAudioTrack"in i.prototype||(i.prototype.addAudioTrack=function(n,a="",o=""){let l=new kT;return l.kind=n,l.label=a,l.language=o,Ff(this,l),l}),"removeAudioTrack"in i.prototype||(i.prototype.removeAudioTrack=$f),"videoRenditions"in i.prototype||Object.defineProperty(i.prototype,"videoRenditions",{get(){return s(this)}});let s=n=>{let a=V(n).videoRenditions;return a||(a=new Nf,V(a).media=n,V(n).videoRenditions=a),a};"audioRenditions"in i.prototype||Object.defineProperty(i.prototype,"audioRenditions",{get(){return r(this)}});let r=n=>{let a=V(n).audioRenditions;return a||(a=new Uf,V(a).media=n,V(n).audioRenditions=a),a};return i}function _c(i,e){var t;if(i!=null&&i.prototype)return(t=Object.getOwnPropertyDescriptor(i.prototype,`${e}Tracks`))==null?void 0:t.get}function BD(i){var e;let t=V(i).videoTracks;if(!t&&(t=new Pf,V(i).videoTracks=t,Ng)){let s=Ng.call((e=i.nativeEl)!=null?e:i);for(let r of s)Mf(i,r);s.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),s.addEventListener("addtrack",r=>{if([...t].some(n=>n instanceof xT)){for(let n of s)Of(n);return}Mf(i,r.track)}),s.addEventListener("removetrack",r=>{Of(r.track)})}return t}function GD(i){var e;let t=V(i).audioTracks;if(!t&&(t=new Bf,V(i).audioTracks=t,Ug)){let s=Ug.call((e=i.nativeEl)!=null?e:i);for(let r of s)Ff(i,r);s.addEventListener("change",()=>{t.dispatchEvent(new Event("change"))}),s.addEventListener("addtrack",r=>{if([...t].some(n=>n instanceof kT)){for(let n of s)$f(n);return}Ff(i,r.track)}),s.addEventListener("removetrack",r=>{$f(r.track)})}return t}pp.push("castchange","entercast","leavecast");var P={BEACON_COLLECTION_DOMAIN:"beacon-collection-domain",CUSTOM_DOMAIN:"custom-domain",DEBUG:"debug",DISABLE_TRACKING:"disable-tracking",DISABLE_COOKIES:"disable-cookies",ENV_KEY:"env-key",MAX_RESOLUTION:"max-resolution",MIN_RESOLUTION:"min-resolution",RENDITION_ORDER:"rendition-order",PROGRAM_START_TIME:"program-start-time",PROGRAM_END_TIME:"program-end-time",METADATA_URL:"metadata-url",PLAYBACK_ID:"playback-id",PLAYER_SOFTWARE_NAME:"player-software-name",PLAYER_SOFTWARE_VERSION:"player-software-version",PREFER_CMCD:"prefer-cmcd",PREFER_PLAYBACK:"prefer-playback",START_TIME:"start-time",STREAM_TYPE:"stream-type",TARGET_LIVE_WINDOW:"target-live-window",LIVE_EDGE_OFFSET:"live-edge-offset",TYPE:"type"},HD=Object.values(P),WD=vD(),KD="mux-video",Ai,Ia,Ed,Ra,bd,yd,Td,_d,wa,Ad,VD=class extends Uu{constructor(){super(),Z(this,wa),Z(this,Ai,void 0),Z(this,Ia,void 0),Z(this,Ed,void 0),Z(this,Ra,{}),Z(this,bd,void 0),Z(this,yd,void 0),Z(this,Td,void 0),Z(this,_d,void 0),ie(this,Ed,SI())}static get observedAttributes(){var e;return[...HD,...(e=Uu.observedAttributes)!=null?e:[]]}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?jd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):console.warn(`Invalid value for preferCmcd. Must be one of ${jd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get playerInitTime(){return I(this,Ed)}get playerSoftwareName(){var e;return(e=I(this,Td))!=null?e:KD}set playerSoftwareName(e){ie(this,Td,e)}get playerSoftwareVersion(){var e;return(e=I(this,yd))!=null?e:WD}set playerSoftwareVersion(e){ie(this,yd,e)}get _hls(){var e;return(e=I(this,Ai))==null?void 0:e.engine}get mux(){var e;return(e=this.nativeEl)==null?void 0:e.mux}get error(){var e;return(e=RI(this.nativeEl))!=null?e:null}get errorTranslator(){return I(this,_d)}set errorTranslator(e){ie(this,_d,e)}get src(){return this.getAttribute("src")}set src(e){e!==this.src&&(e==null?this.removeAttribute("src"):this.setAttribute("src",e))}get type(){var e;return(e=this.getAttribute(P.TYPE))!=null?e:void 0}set type(e){e!==this.type&&(e?this.setAttribute(P.TYPE,e):this.removeAttribute(P.TYPE))}get autoplay(){let e=this.getAttribute("autoplay");return e===null?!1:e===""?!0:e}set autoplay(e){let t=this.autoplay;e!==t&&(e?this.setAttribute("autoplay",typeof e=="string"?e:""):this.removeAttribute("autoplay"))}get preload(){let e=this.getAttribute("preload");return e===""?"auto":["none","metadata","auto"].includes(e)?e:super.preload}set preload(e){e!=this.getAttribute("preload")&&(["","none","metadata","auto"].includes(e)?this.setAttribute("preload",e):this.removeAttribute("preload"))}get debug(){return this.getAttribute(P.DEBUG)!=null}set debug(e){e!==this.debug&&(e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG))}get disableTracking(){return this.hasAttribute(P.DISABLE_TRACKING)}set disableTracking(e){e!==this.disableTracking&&this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return this.hasAttribute(P.DISABLE_COOKIES)}set disableCookies(e){e!==this.disableCookies&&(e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES))}get startTime(){let e=this.getAttribute(P.START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set startTime(e){e!==this.startTime&&(e==null?this.removeAttribute(P.START_TIME):this.setAttribute(P.START_TIME,`${e}`))}get playbackId(){var e;return(e=this.getAttribute(P.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e!==this.playbackId&&(e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){let e=this.getAttribute(P.PROGRAM_START_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){let e=this.getAttribute(P.PROGRAM_END_TIME);if(e==null)return;let t=+e;return Number.isNaN(t)?void 0:t}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get ended(){return zE(this.nativeEl,this._hls)}get envKey(){var e;return(e=this.getAttribute(P.ENV_KEY))!=null?e:void 0}set envKey(e){e!==this.envKey&&(e?this.setAttribute(P.ENV_KEY,e):this.removeAttribute(P.ENV_KEY))}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get streamType(){var e;return(e=this.getAttribute(P.STREAM_TYPE))!=null?e:hh(this.nativeEl)}set streamType(e){e!==this.streamType&&(e?this.setAttribute(P.STREAM_TYPE,e):this.removeAttribute(P.STREAM_TYPE))}get targetLiveWindow(){return this.hasAttribute(P.TARGET_LIVE_WINDOW)?+this.getAttribute(P.TARGET_LIVE_WINDOW):wI(this.nativeEl)}set targetLiveWindow(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.TARGET_LIVE_WINDOW):this.setAttribute(P.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e,t;if(this.hasAttribute(P.LIVE_EDGE_OFFSET)){let{liveEdgeOffset:s}=this,r=(e=this.nativeEl.seekable.end(0))!=null?e:0,n=(t=this.nativeEl.seekable.start(0))!=null?t:0;return Math.max(n,r-s)}return CI(this.nativeEl)}get liveEdgeOffset(){if(this.hasAttribute(P.LIVE_EDGE_OFFSET))return+this.getAttribute(P.LIVE_EDGE_OFFSET)}set liveEdgeOffset(e){e!=this.targetLiveWindow&&(e==null?this.removeAttribute(P.LIVE_EDGE_OFFSET):this.setAttribute(P.LIVE_EDGE_OFFSET,`${+e}`))}get seekable(){return zd(this.nativeEl)}async addCuePoints(e){return BE(this.nativeEl,e)}get activeCuePoint(){return GE(this.nativeEl)}get cuePoints(){return cI(this.nativeEl)}async addChapters(e){return WE(this.nativeEl,e)}get activeChapter(){return KE(this.nativeEl)}get chapters(){return hI(this.nativeEl)}getStartDate(){return mI(this.nativeEl,this._hls)}get currentPdt(){return pI(this.nativeEl,this._hls)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ci.MSE||e===Ci.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ci.MSE||e===Ci.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){return{...this.getAttributeNames().filter(e=>e.startsWith("metadata-")&&![P.METADATA_URL].includes(e)).reduce((e,t)=>{let s=this.getAttribute(t);return s!=null&&(e[t.replace(/^metadata-/,"").replace(/-/g,"_")]=s),e},{}),...I(this,Ra)}}set metadata(e){ie(this,Ra,e??{}),this.mux&&this.mux.emit("hb",I(this,Ra))}get _hlsConfig(){return I(this,bd)}set _hlsConfig(e){ie(this,bd,e)}load(){ie(this,Ai,OI(this,this.nativeEl,I(this,Ai)))}unload(){XE(this.nativeEl,I(this,Ai)),ie(this,Ai,void 0)}attributeChangedCallback(e,t,s){var r,n;switch(Uu.observedAttributes.includes(e)&&!["src","autoplay","preload"].includes(e)&&super.attributeChangedCallback(e,t,s),e){case P.PLAYER_SOFTWARE_NAME:this.playerSoftwareName=s??void 0;break;case P.PLAYER_SOFTWARE_VERSION:this.playerSoftwareVersion=s??void 0;break;case"src":{let a=!!t,o=!!s;!a&&o?Fe(this,wa,Ad).call(this):a&&!o?this.unload():a&&o&&(this.unload(),Fe(this,wa,Ad).call(this));break}case"autoplay":if(s===t)break;(r=I(this,Ai))==null||r.setAutoplay(this.autoplay);break;case"preload":if(s===t)break;(n=I(this,Ai))==null||n.setPreload(s);break;case P.PLAYBACK_ID:this.src=uh(this);break;case P.DEBUG:{let a=this.debug;this.mux&&console.info("Cannot toggle debug mode of mux data after initialization. Make sure you set all metadata to override before setting the src."),this._hls&&(this._hls.config.debug=a);break}case P.METADATA_URL:s&&fetch(s).then(a=>a.json()).then(a=>this.metadata=a).catch(()=>console.error(`Unable to load or parse metadata JSON from metadata-url ${s}!`));break;case P.STREAM_TYPE:(s==null||s!==t)&&this.dispatchEvent(new CustomEvent("streamtypechange",{composed:!0,bubbles:!0}));break;case P.TARGET_LIVE_WINDOW:(s==null||s!==t)&&this.dispatchEvent(new CustomEvent("targetlivewindowchange",{composed:!0,bubbles:!0,detail:this.targetLiveWindow}));break}}connectedCallback(){var e;(e=super.connectedCallback)==null||e.call(this),this.nativeEl&&this.src&&!I(this,Ai)&&Fe(this,wa,Ad).call(this)}disconnectedCallback(){this.unload()}};Ai=new WeakMap,Ia=new WeakMap,Ed=new WeakMap,Ra=new WeakMap,bd=new WeakMap,yd=new WeakMap,Td=new WeakMap,_d=new WeakMap,wa=new WeakSet,Ad=async function(){I(this,Ia)||(await ie(this,Ia,Promise.resolve()),ie(this,Ia,null),this.load())};var Gf=class extends LD($D(VD)){};Nu.customElements.get("mux-video")||(Nu.customElements.define("mux-video",Gf),Nu.MuxVideoElement=Gf);var qD=Gf,YD=Object.defineProperty,jD=(i,e,t)=>e in i?YD(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,zD=(i,e,t)=>(jD(i,e+"",t),t),LT=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},ce=(i,e,t)=>(LT(i,e,"read from private field"),t?t.call(i):e.get(i)),Ii=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Qi=(i,e,t,s)=>(LT(i,e,"write to private field"),e.set(i,t),t),ln,Sd,Xs,Ca,ds,cs,us,Qs,dn,xd,zt;const Fg=1,$g=0,XD=1,QD={processCallback(i,e,t){if(t){for(const[s,r]of e)if(s in t){const n=t[s];typeof n=="boolean"&&r instanceof ai&&typeof r.element[r.attributeName]=="boolean"?r.booleanValue=n:typeof n=="function"&&r instanceof ai?r.element[r.attributeName]=n:r.value=n}}}};class $c extends k.DocumentFragment{constructor(e,t,s=QD){var r;super(),Ii(this,ln,void 0),Ii(this,Sd,void 0),this.append(e.content.cloneNode(!0)),Qi(this,ln,IT(this)),Qi(this,Sd,s),(r=s.createCallback)==null||r.call(s,this,ce(this,ln),t),s.processCallback(this,ce(this,ln),t)}update(e){ce(this,Sd).processCallback(this,ce(this,ln),e)}}ln=new WeakMap;Sd=new WeakMap;const IT=(i,e=[])=>{let t,s;for(let r of i.attributes||[])if(r.value.includes("{{")){const n=new JD;for([t,s]of Gg(r.value))if(!t)n.append(s);else{const a=new ai(i,r.name,r.namespaceURI);n.append(a),e.push([s,a])}r.value=n.toString()}for(let r of i.childNodes)if(r.nodeType===Fg&&!(r instanceof HTMLTemplateElement))IT(r,e);else if(r.nodeType===Fg||r.data.includes("{{")){const n=[];if(r.data)for([t,s]of Gg(r.data))if(!t)n.push(new Text(s));else{const a=new Gn(i);n.push(a),e.push([s,a])}else if(r instanceof HTMLTemplateElement){const a=new CT(i,r);n.push(a),e.push([a.expression,a])}r.replaceWith(...n.flatMap(a=>a.replacementNodes||[a]))}return e},Bg={},Gg=i=>{let e="",t=0,s=Bg[i],r=0,n;if(s)return s;for(s=[];n=i[r];r++)n==="{"&&i[r+1]==="{"&&i[r-1]!=="\\"&&i[r+2]&&++t==1?(e&&s.push([$g,e]),e="",r++):n==="}"&&i[r+1]==="}"&&i[r-1]!=="\\"&&!--t?(s.push([XD,e.trim()]),e="",r++):e+=n||"";return e&&s.push([$g,(t>0?"{{":"")+e]),Bg[i]=s},ZD=11;class RT{get value(){return""}set value(e){}toString(){return this.value}}const wT=new WeakMap;class JD{constructor(){Ii(this,Xs,[])}[Symbol.iterator](){return ce(this,Xs).values()}get length(){return ce(this,Xs).length}item(e){return ce(this,Xs)[e]}append(...e){for(const t of e)t instanceof ai&&wT.set(t,this),ce(this,Xs).push(t)}toString(){return ce(this,Xs).join("")}}Xs=new WeakMap;class ai extends RT{constructor(e,t,s){super(),Ii(this,Qs),Ii(this,Ca,""),Ii(this,ds,void 0),Ii(this,cs,void 0),Ii(this,us,void 0),Qi(this,ds,e),Qi(this,cs,t),Qi(this,us,s)}get attributeName(){return ce(this,cs)}get attributeNamespace(){return ce(this,us)}get element(){return ce(this,ds)}get value(){return ce(this,Ca)}set value(e){ce(this,Ca)!==e&&(Qi(this,Ca,e),!ce(this,Qs,dn)||ce(this,Qs,dn).length===1?e==null?ce(this,ds).removeAttributeNS(ce(this,us),ce(this,cs)):ce(this,ds).setAttributeNS(ce(this,us),ce(this,cs),e):ce(this,ds).setAttributeNS(ce(this,us),ce(this,cs),ce(this,Qs,dn)))}get booleanValue(){return ce(this,ds).hasAttributeNS(ce(this,us),ce(this,cs))}set booleanValue(e){if(!ce(this,Qs,dn)||ce(this,Qs,dn).length===1)this.value=e?"":null;else throw new DOMException("Value is not fully templatized")}}Ca=new WeakMap;ds=new WeakMap;cs=new WeakMap;us=new WeakMap;Qs=new WeakSet;dn=function(){return wT.get(this)};class Gn extends RT{constructor(e,t){super(),Ii(this,xd,void 0),Ii(this,zt,void 0),Qi(this,xd,e),Qi(this,zt,t?[...t]:[new Text])}get replacementNodes(){return ce(this,zt)}get parentNode(){return ce(this,xd)}get nextSibling(){return ce(this,zt)[ce(this,zt).length-1].nextSibling}get previousSibling(){return ce(this,zt)[0].previousSibling}get value(){return ce(this,zt).map(e=>e.textContent).join("")}set value(e){this.replace(e)}replace(...e){const t=e.flat().flatMap(s=>s==null?[new Text]:s.forEach?[...s]:s.nodeType===ZD?[...s.childNodes]:s.nodeType?[s]:[new Text(s)]);t.length||t.push(new Text),Qi(this,zt,eM(ce(this,zt)[0].parentNode,ce(this,zt),t,this.nextSibling))}}xd=new WeakMap;zt=new WeakMap;class CT extends Gn{constructor(e,t){let s=t.getAttribute("directive")||t.getAttribute("type"),r=t.getAttribute("expression")||t.getAttribute(s)||"";r.startsWith("{{")&&(r=r.trim().slice(2,-2).trim()),super(e),zD(this,"directive"),this.expression=r,this.template=t,this.directive=s}}function eM(i,e,t,s=null){let r=0,n,a,o,l=t.length,d=e.length;for(;r<l&&r<d&&e[r]==t[r];)r++;for(;r<l&&r<d&&t[l-1]==e[d-1];)s=t[--d,--l];if(r==d)for(;r<l;)i.insertBefore(t[r++],s);if(r==l)for(;r<d;)i.removeChild(e[r++]);else{for(n=e[r];r<l;)o=t[r++],a=n?n.nextSibling:s,n==o?n=a:r<l&&t[r]==a?(i.replaceChild(o,n),n=a):i.insertBefore(o,n);for(;n!=s;)a=n.nextSibling,i.removeChild(n),n=a}return t}const Hg={string:i=>String(i)};class DT{constructor(e){this.template=e,this.state=void 0}}const or=new WeakMap,lr=new WeakMap,Hf={partial:(i,e)=>{e[i.expression]=new DT(i.template)},if:(i,e)=>{var t;if(MT(i.expression,e))if(or.get(i)!==i.template){or.set(i,i.template);const s=new $c(i.template,e,Ep);i.replace(s),lr.set(i,s)}else(t=lr.get(i))==null||t.update(e);else i.replace(""),or.delete(i),lr.delete(i)}},tM=Object.keys(Hf),Ep={processCallback(i,e,t){var s,r;if(t)for(const[n,a]of e){if(a instanceof CT){if(!a.directive){const l=tM.find(d=>a.template.hasAttribute(d));l&&(a.directive=l,a.expression=a.template.getAttribute(l))}(s=Hf[a.directive])==null||s.call(Hf,a,t);continue}let o=MT(n,t);if(o instanceof DT){or.get(a)!==o.template?(or.set(a,o.template),o=new $c(o.template,o.state,Ep),a.value=o,lr.set(a,o)):(r=lr.get(a))==null||r.update(o.state);continue}o?(a instanceof ai&&a.attributeName.startsWith("aria-")&&(o=String(o)),a instanceof ai?typeof o=="boolean"?a.booleanValue=o:typeof o=="function"?a.element[a.attributeName]=o:a.value=o:(a.value=o,or.delete(a),lr.delete(a))):a instanceof ai?a.value=void 0:(a.value=void 0,or.delete(a),lr.delete(a))}}},Wg={"!":i=>!i,"!!":i=>!!i,"==":(i,e)=>i==e,"!=":(i,e)=>i!=e,">":(i,e)=>i>e,">=":(i,e)=>i>=e,"<":(i,e)=>i<e,"<=":(i,e)=>i<=e,"??":(i,e)=>i??e,"|":(i,e)=>{var t;return(t=Hg[e])==null?void 0:t.call(Hg,i)}};function iM(i){return sM(i,{boolean:/true|false/,number:/-?\d+\.?\d*/,string:/(["'])((?:\\.|[^\\])*?)\1/,operator:/[!=><][=!]?|\?\?|\|/,ws:/\s+/,param:/[$a-z_][$\w]*/i}).filter(({type:e})=>e!=="ws")}function MT(i,e={}){var t,s,r,n,a,o,l;const d=iM(i);if(d.length===0||d.some(({type:c})=>!c))return ea(i);if(((t=d[0])==null?void 0:t.token)===">"){const c=e[(s=d[1])==null?void 0:s.token];if(!c)return ea(i);const u={...e};c.state=u;const h=d.slice(2);for(let f=0;f<h.length;f+=3){const m=(r=h[f])==null?void 0:r.token,p=(n=h[f+1])==null?void 0:n.token,g=(a=h[f+2])==null?void 0:a.token;m&&p==="="&&(u[m]=ta(g,e))}return c}if(d.length===1)return el(d[0])?ta(d[0].token,e):ea(i);if(d.length===2){const c=(o=d[0])==null?void 0:o.token,u=Wg[c];if(!u||!el(d[1]))return ea(i);const h=ta(d[1].token,e);return u(h)}if(d.length===3){const c=(l=d[1])==null?void 0:l.token,u=Wg[c];if(!u||!el(d[0])||!el(d[2]))return ea(i);const h=ta(d[0].token,e);if(c==="|")return u(h,d[2].token);const f=ta(d[2].token,e);return u(h,f)}}function ea(i){return console.warn(`Warning: invalid expression \`${i}\``),!1}function el({type:i}){return["number","boolean","string","param"].includes(i)}function ta(i,e){const t=i[0],s=i.slice(-1);return i==="true"||i==="false"?i==="true":t===s&&["'",'"'].includes(t)?i.slice(1,-1):nb(i)?parseFloat(i):e[i]}function sM(i,e){let t,s,r,n=[];for(;i;){r=null,t=i.length;for(let a in e)s=e[a].exec(i),s&&s.index<t&&(r={token:s[0],type:a,matches:s.slice(1)},t=s.index);t&&n.push({token:i.substr(0,t),type:void 0}),r&&n.push(r),i=i.substr(t+(r?r.token.length:0))}return n}var rM=Object.defineProperty,nM=(i,e,t)=>e in i?rM(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t,ao=(i,e,t)=>(nM(i,typeof e!="symbol"?e+"":e,t),t),bp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Wf=(i,e,t)=>(bp(i,e,"read from private field"),t?t.call(i):e.get(i)),ia=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},dr=(i,e,t,s)=>(bp(i,e,"write to private field"),e.set(i,t),t),Bu=(i,e,t)=>(bp(i,e,"access private method"),t),xn,kd,kn,Kf,OT,Ld,Vf;const Gu={mediatargetlivewindow:"targetlivewindow",mediastreamtype:"streamtype"},PT=z.createElement("template");PT.innerHTML=`
1650
1650
  <style>
1651
1651
  :host {
1652
1652
  display: inline-block;
@@ -1670,8 +1670,8 @@ svg, img, ::slotted(svg), ::slotted(img) {
1670
1670
  display: none;
1671
1671
  }
1672
1672
  </style>
1673
- `;class go extends k.HTMLElement{constructor(){super(),ia(this,Kf),ia(this,Ld),ao(this,"renderRoot"),ao(this,"renderer"),ia(this,xn,void 0),ia(this,kd,void 0),ia(this,kn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());const e=new MutationObserver(t=>{var s;this.mediaController&&!((s=this.mediaController)!=null&&s.breakpointsComputed)||t.some(r=>{const n=r.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Gu[r.attributeName]||r.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Ir.BREAKPOINTS_COMPUTED,this.render),Bu(this,Kf,OT).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Wf(this,xn))!=null?e:this.constructor.template}set template(e){dr(this,kn,null),dr(this,xn,e),this.createRenderer()}get props(){var e,t,s;const r=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Gu[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of r){const o=(s=Gu[a.name])!=null?s:qI(a.name);let{value:l}=a;l!=null?(nb(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,s){e==="template"&&t!=s&&Bu(this,Ld,Vf).call(this)}connectedCallback(){Bu(this,Ld,Vf).call(this)}createRenderer(){this.template&&this.template!==Wf(this,kd)&&(dr(this,kd,this.template),this.renderer=new $c(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(PT.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}}xn=new WeakMap;kd=new WeakMap;kn=new WeakMap;Kf=new WeakSet;OT=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){const e=this[i];delete this[i],this[i]=e}};Ld=new WeakSet;Vf=function(){var i;const e=this.getAttribute("template");if(!e||e===Wf(this,kn))return;const t=this.getRootNode(),s=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(s){dr(this,kn,e),dr(this,xn,s),this.createRenderer();return}nM(e)&&(dr(this,kn,e),aM(e).then(r=>{const n=z.createElement("template");n.innerHTML=r,dr(this,xn,n),this.createRenderer()}).catch(console.error))};ao(go,"template");ao(go,"observedAttributes",["template"]);ao(go,"processor",Ep);function nM(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;const e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function aM(i){const e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}k.customElements.get("media-theme")||k.customElements.define("media-theme",go);var yp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Te=(i,e,t)=>(yp(i,e,"read from private field"),t?t.call(i):e.get(i)),ht=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zi=(i,e,t,s)=>(yp(i,e,"write to private field"),e.set(i,t),t),ze=(i,e,t)=>(yp(i,e,"access private method"),t),Bc=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment>"u"){class i extends Bc{}globalThis.DocumentFragment=i}var Tp=class extends Bc{},oM=class extends Bc{},lM={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Tp)}},Id,dM=class{constructor(i,e={}){ht(this,Id,void 0),Zi(this,Id,e==null?void 0:e.detail)}get detail(){return Te(this,Id)}initCustomEvent(){}};Id=new WeakMap;function cM(i,e){return new Tp}var NT={document:{createElement:cM},DocumentFragment,customElements:lM,CustomEvent:dM,EventTarget:Bc,HTMLElement:Tp,HTMLVideoElement:oM},UT=typeof window>"u"||typeof globalThis.customElements>"u",lt=UT?NT:globalThis,As=UT?NT.document:globalThis.document,uM="en",oo={code:uM},FT="en";function fe(i,e=!0){var t,s;let r=e&&(s=(t=oo)==null?void 0:t[i])!=null?s:i,n=e?oo.code:FT;return new hM(r,n)}var hM=class{constructor(i,e=(t=>(t=oo.code)!=null?t:FT)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var s;return(s=i[t])!=null?s:""})}toString(){return this.message}};function fM(i){let e="";return Object.entries(i).forEach(([t,s])=>{s!=null&&(e+=`${qf(t)}: ${s}; `)}),e?e.trim():void 0}function qf(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $T(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function xi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function BT(i){let e=mM(i).toString();return e?"?"+e:""}function mM(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function lo(i){let e=(i??"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(s)}var GT=(i,e)=>!i||!e?!1:i.contains(e)?!0:GT(i,e.getRootNode().host),HT="mux.com",pM=()=>{try{return"2.7.0"}catch{}return"UNKNOWN"},gM=pM(),WT=()=>gM,vM=(i,{token:e,customDomain:t=HT,thumbnailTime:s,programTime:r}={})=>{let n=e==null?s:void 0,{aud:a}=lo(e);if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${BT({token:e,time:n,program_time:r})}`},EM=(i,{token:e,customDomain:t=HT,programStartTime:s,programEndTime:r}={})=>{let{aud:n}=lo(e);if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${BT({token:e,format:"webp",program_start_time:s,program_end_time:r})}`},_p=i=>{if(i){if([_e.LIVE,_e.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return _e.LIVE}},bM={crossorigin:"crossOrigin",playsinline:"playsInline"};function yM(i){var e;return(e=bM[i])!=null?e:$T(i)}var cn,un,Rt,TM=class{constructor(e,t){ht(this,cn,void 0),ht(this,un,void 0),ht(this,Rt,[]),Zi(this,cn,e),Zi(this,un,t)}[Symbol.iterator](){return Te(this,Rt).values()}get length(){return Te(this,Rt).length}get value(){var e;return(e=Te(this,Rt).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Zi(this,Rt,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Te(this,Rt)[e]}values(){return Te(this,Rt).values()}keys(){return Te(this,Rt).keys()}forEach(e){Te(this,Rt).forEach(e)}add(...e){var t,s;e.forEach(r=>{this.contains(r)||Te(this,Rt).push(r)}),!(this.value===""&&!((t=Te(this,cn))!=null&&t.hasAttribute(`${Te(this,un)}`)))&&((s=Te(this,cn))==null||s.setAttribute(`${Te(this,un)}`,`${this.value}`))}remove(...e){var t;e.forEach(s=>{Te(this,Rt).splice(Te(this,Rt).indexOf(s),1)}),(t=Te(this,cn))==null||t.setAttribute(`${Te(this,un)}`,`${this.value}`)}contains(e){return Te(this,Rt).includes(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};cn=new WeakMap,un=new WeakMap,Rt=new WeakMap;var KT=`[mux-player ${WT()}]`;function cr(...i){console.warn(KT,...i)}function ri(...i){console.error(KT,...i)}function VT(i){var e;let t=(e=i.message)!=null?e:"";i.context&&(t+=` ${i.context}`),i.file&&(t+=` ${fe("Read more: ")}
1674
- https://github.com/muxinc/elements/blob/main/errors/${i.file}`),cr(t)}var bt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Zs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Kg=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),_M=pp.filter(i=>i!=="error"),AM=Object.values(bt).filter(i=>![bt.PLAYSINLINE].includes(i)),SM=Object.values(Zs);function xM(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),_M.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,s=>{i.dispatchEvent(new Event(s.type))})})}var kM=class extends lt.HTMLElement{static get observedAttributes(){return[...AM,...SM]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(e=>{var t;(t=this.media)==null||t.append(e.cloneNode())});let i=e=>{for(let t of e)t.type==="childList"&&(t.removedNodes.forEach(s=>{var r,n;let a=(r=this.media)==null?void 0:r.querySelector(`track[src="${s.src}"]`);a&&((n=this.media)==null||n.removeChild(a))}),t.addedNodes.forEach(s=>{var r;(r=this.media)==null||r.append(s.cloneNode())}))};new MutationObserver(i).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(i,e,t){var s,r;switch(i){case Zs.MUTED:{this.media&&(this.media.muted=t!=null,this.media.defaultMuted=t!=null);return}case Zs.VOLUME:{let n=(s=xi(t))!=null?s:1;this.media&&(this.media.volume=n);return}case Zs.PLAYBACKRATE:{let n=(r=xi(t))!=null?r:1;this.media&&(this.media.playbackRate=n,this.media.defaultPlaybackRate=n);return}}}play(){var i,e;return(e=(i=this.media)==null?void 0:i.play())!=null?e:Promise.reject()}pause(){var i;(i=this.media)==null||i.pause()}requestCast(i){var e;return(e=this.media)==null?void 0:e.requestCast(i)}get media(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var i,e;return(e=(i=this.media)==null?void 0:i.paused)!=null?e:!0}get duration(){var i,e;return(e=(i=this.media)==null?void 0:i.duration)!=null?e:NaN}get ended(){var i,e;return(e=(i=this.media)==null?void 0:i.ended)!=null?e:!1}get buffered(){var i,e;return(e=(i=this.media)==null?void 0:i.buffered)!=null?e:Kg}get seekable(){var i,e;return(e=(i=this.media)==null?void 0:i.seekable)!=null?e:Kg}get readyState(){var i,e;return(e=(i=this.media)==null?void 0:i.readyState)!=null?e:0}get videoWidth(){var i,e;return(e=(i=this.media)==null?void 0:i.videoWidth)!=null?e:0}get videoHeight(){var i,e;return(e=(i=this.media)==null?void 0:i.videoHeight)!=null?e:0}get currentTime(){var i,e;return(e=(i=this.media)==null?void 0:i.currentTime)!=null?e:0}set currentTime(i){this.media&&(this.media.currentTime=Number(i))}get volume(){var i,e;return(e=(i=this.media)==null?void 0:i.volume)!=null?e:1}set volume(i){this.media&&(this.media.volume=Number(i))}get playbackRate(){var i,e;return(e=(i=this.media)==null?void 0:i.playbackRate)!=null?e:1}set playbackRate(i){this.media&&(this.media.playbackRate=Number(i))}get defaultPlaybackRate(){var i;return(i=xi(this.getAttribute(Zs.PLAYBACKRATE)))!=null?i:1}set defaultPlaybackRate(i){i!=null?this.setAttribute(Zs.PLAYBACKRATE,`${i}`):this.removeAttribute(Zs.PLAYBACKRATE)}get crossOrigin(){return sa(this,bt.CROSSORIGIN)}set crossOrigin(i){this.setAttribute(bt.CROSSORIGIN,`${i}`)}get autoplay(){return sa(this,bt.AUTOPLAY)!=null}set autoplay(i){i?this.setAttribute(bt.AUTOPLAY,typeof i=="string"?i:""):this.removeAttribute(bt.AUTOPLAY)}get loop(){return sa(this,bt.LOOP)!=null}set loop(i){i?this.setAttribute(bt.LOOP,""):this.removeAttribute(bt.LOOP)}get muted(){var i,e;return(e=(i=this.media)==null?void 0:i.muted)!=null?e:!1}set muted(i){this.media&&(this.media.muted=!!i)}get defaultMuted(){return sa(this,bt.MUTED)!=null}set defaultMuted(i){i?this.setAttribute(bt.MUTED,""):this.removeAttribute(bt.MUTED)}get playsInline(){return sa(this,bt.PLAYSINLINE)!=null}set playsInline(i){ri("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(i){["","none","metadata","auto"].includes(i)?this.setAttribute(bt.PRELOAD,i):this.removeAttribute(bt.PRELOAD)}};function sa(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Vg=kM,LM=`:host {
1673
+ `;class go extends k.HTMLElement{constructor(){super(),ia(this,Kf),ia(this,Ld),ao(this,"renderRoot"),ao(this,"renderer"),ia(this,xn,void 0),ia(this,kd,void 0),ia(this,kn,void 0),this.shadowRoot?this.renderRoot=this.shadowRoot:(this.renderRoot=this.attachShadow({mode:"open"}),this.createRenderer());const e=new MutationObserver(t=>{var s;this.mediaController&&!((s=this.mediaController)!=null&&s.breakpointsComputed)||t.some(r=>{const n=r.target;return n===this?!0:n.localName!=="media-controller"?!1:!!(Gu[r.attributeName]||r.attributeName.startsWith("breakpoint"))})&&this.render()});e.observe(this,{attributes:!0}),e.observe(this.renderRoot,{attributes:!0,subtree:!0}),this.addEventListener(Ir.BREAKPOINTS_COMPUTED,this.render),Bu(this,Kf,OT).call(this,"template")}get mediaController(){return this.renderRoot.querySelector("media-controller")}get template(){var e;return(e=Wf(this,xn))!=null?e:this.constructor.template}set template(e){dr(this,kn,null),dr(this,xn,e),this.createRenderer()}get props(){var e,t,s;const r=[...Array.from((t=(e=this.mediaController)==null?void 0:e.attributes)!=null?t:[]).filter(({name:a})=>Gu[a]||a.startsWith("breakpoint")),...Array.from(this.attributes)],n={};for(let a of r){const o=(s=Gu[a.name])!=null?s:YI(a.name);let{value:l}=a;l!=null?(nb(l)&&(l=parseFloat(l)),n[o]=l===""?!0:l):n[o]=!1}return n}attributeChangedCallback(e,t,s){e==="template"&&t!=s&&Bu(this,Ld,Vf).call(this)}connectedCallback(){Bu(this,Ld,Vf).call(this)}createRenderer(){this.template&&this.template!==Wf(this,kd)&&(dr(this,kd,this.template),this.renderer=new $c(this.template,this.props,this.constructor.processor),this.renderRoot.textContent="",this.renderRoot.append(PT.content.cloneNode(!0),this.renderer))}render(){var e;(e=this.renderer)==null||e.update(this.props)}}xn=new WeakMap;kd=new WeakMap;kn=new WeakMap;Kf=new WeakSet;OT=function(i){if(Object.prototype.hasOwnProperty.call(this,i)){const e=this[i];delete this[i],this[i]=e}};Ld=new WeakSet;Vf=function(){var i;const e=this.getAttribute("template");if(!e||e===Wf(this,kn))return;const t=this.getRootNode(),s=(i=t==null?void 0:t.getElementById)==null?void 0:i.call(t,e);if(s){dr(this,kn,e),dr(this,xn,s),this.createRenderer();return}aM(e)&&(dr(this,kn,e),oM(e).then(r=>{const n=z.createElement("template");n.innerHTML=r,dr(this,xn,n),this.createRenderer()}).catch(console.error))};ao(go,"template");ao(go,"observedAttributes",["template"]);ao(go,"processor",Ep);function aM(i){if(!/^(\/|\.\/|https?:\/\/)/.test(i))return!1;const e=/^https?:\/\//.test(i)?void 0:location.origin;try{new URL(i,e)}catch{return!1}return!0}async function oM(i){const e=await fetch(i);if(e.status!==200)throw new Error(`Failed to load resource: the server responded with a status of ${e.status}`);return e.text()}k.customElements.get("media-theme")||k.customElements.define("media-theme",go);var yp=(i,e,t)=>{if(!e.has(i))throw TypeError("Cannot "+t)},Te=(i,e,t)=>(yp(i,e,"read from private field"),t?t.call(i):e.get(i)),ht=(i,e,t)=>{if(e.has(i))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(i):e.set(i,t)},Zi=(i,e,t,s)=>(yp(i,e,"write to private field"),e.set(i,t),t),ze=(i,e,t)=>(yp(i,e,"access private method"),t),Bc=class{addEventListener(){}removeEventListener(){}dispatchEvent(i){return!0}};if(typeof DocumentFragment>"u"){class i extends Bc{}globalThis.DocumentFragment=i}var Tp=class extends Bc{},lM=class extends Bc{},dM={get(i){},define(i,e,t){},upgrade(i){},whenDefined(i){return Promise.resolve(Tp)}},Id,cM=class{constructor(i,e={}){ht(this,Id,void 0),Zi(this,Id,e==null?void 0:e.detail)}get detail(){return Te(this,Id)}initCustomEvent(){}};Id=new WeakMap;function uM(i,e){return new Tp}var NT={document:{createElement:uM},DocumentFragment,customElements:dM,CustomEvent:cM,EventTarget:Bc,HTMLElement:Tp,HTMLVideoElement:lM},UT=typeof window>"u"||typeof globalThis.customElements>"u",lt=UT?NT:globalThis,As=UT?NT.document:globalThis.document,hM="en",oo={code:hM},FT="en";function fe(i,e=!0){var t,s;let r=e&&(s=(t=oo)==null?void 0:t[i])!=null?s:i,n=e?oo.code:FT;return new fM(r,n)}var fM=class{constructor(i,e=(t=>(t=oo.code)!=null?t:FT)()){this.message=i,this.locale=e}format(i){return this.message.replace(/\{(\w+)\}/g,(e,t)=>{var s;return(s=i[t])!=null?s:""})}toString(){return this.message}};function mM(i){let e="";return Object.entries(i).forEach(([t,s])=>{s!=null&&(e+=`${qf(t)}: ${s}; `)}),e?e.trim():void 0}function qf(i){return i.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function $T(i){return i.replace(/[-_]([a-z])/g,(e,t)=>t.toUpperCase())}function xi(i){if(i==null)return;let e=+i;return Number.isNaN(e)?void 0:e}function BT(i){let e=pM(i).toString();return e?"?"+e:""}function pM(i){let e={};for(let t in i)i[t]!=null&&(e[t]=i[t]);return new URLSearchParams(e)}function lo(i){let e=(i??"").split(".")[1];if(!e)return{};let t=e.replace(/-/g,"+").replace(/_/g,"/"),s=decodeURIComponent(atob(t).split("").map(function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)}).join(""));return JSON.parse(s)}var GT=(i,e)=>!i||!e?!1:i.contains(e)?!0:GT(i,e.getRootNode().host),HT="mux.com",gM=()=>{try{return"2.7.0"}catch{}return"UNKNOWN"},vM=gM(),WT=()=>vM,EM=(i,{token:e,customDomain:t=HT,thumbnailTime:s,programTime:r}={})=>{let n=e==null?s:void 0,{aud:a}=lo(e);if(!(e&&a!=="t"))return`https://image.${t}/${i}/thumbnail.webp${BT({token:e,time:n,program_time:r})}`},bM=(i,{token:e,customDomain:t=HT,programStartTime:s,programEndTime:r}={})=>{let{aud:n}=lo(e);if(!(e&&n!=="s"))return`https://image.${t}/${i}/storyboard.vtt${BT({token:e,format:"webp",program_start_time:s,program_end_time:r})}`},_p=i=>{if(i){if([_e.LIVE,_e.ON_DEMAND].includes(i))return i;if(i!=null&&i.includes("live"))return _e.LIVE}},yM={crossorigin:"crossOrigin",playsinline:"playsInline"};function TM(i){var e;return(e=yM[i])!=null?e:$T(i)}var cn,un,Rt,_M=class{constructor(e,t){ht(this,cn,void 0),ht(this,un,void 0),ht(this,Rt,[]),Zi(this,cn,e),Zi(this,un,t)}[Symbol.iterator](){return Te(this,Rt).values()}get length(){return Te(this,Rt).length}get value(){var e;return(e=Te(this,Rt).join(" "))!=null?e:""}set value(e){var t;e!==this.value&&(Zi(this,Rt,[]),this.add(...(t=e==null?void 0:e.split(" "))!=null?t:[]))}toString(){return this.value}item(e){return Te(this,Rt)[e]}values(){return Te(this,Rt).values()}keys(){return Te(this,Rt).keys()}forEach(e){Te(this,Rt).forEach(e)}add(...e){var t,s;e.forEach(r=>{this.contains(r)||Te(this,Rt).push(r)}),!(this.value===""&&!((t=Te(this,cn))!=null&&t.hasAttribute(`${Te(this,un)}`)))&&((s=Te(this,cn))==null||s.setAttribute(`${Te(this,un)}`,`${this.value}`))}remove(...e){var t;e.forEach(s=>{Te(this,Rt).splice(Te(this,Rt).indexOf(s),1)}),(t=Te(this,cn))==null||t.setAttribute(`${Te(this,un)}`,`${this.value}`)}contains(e){return Te(this,Rt).includes(e)}toggle(e,t){return typeof t<"u"?t?(this.add(e),!0):(this.remove(e),!1):this.contains(e)?(this.remove(e),!1):(this.add(e),!0)}replace(e,t){this.remove(e),this.add(t)}};cn=new WeakMap,un=new WeakMap,Rt=new WeakMap;var KT=`[mux-player ${WT()}]`;function cr(...i){console.warn(KT,...i)}function ri(...i){console.error(KT,...i)}function VT(i){var e;let t=(e=i.message)!=null?e:"";i.context&&(t+=` ${i.context}`),i.file&&(t+=` ${fe("Read more: ")}
1674
+ https://github.com/muxinc/elements/blob/main/errors/${i.file}`),cr(t)}var bt={AUTOPLAY:"autoplay",CROSSORIGIN:"crossorigin",LOOP:"loop",MUTED:"muted",PLAYSINLINE:"playsinline",PRELOAD:"preload"},Zs={VOLUME:"volume",PLAYBACKRATE:"playbackrate",MUTED:"muted"},Kg=Object.freeze({length:0,start(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'start' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0},end(i){let e=i>>>0;if(e>=this.length)throw new DOMException(`Failed to execute 'end' on 'TimeRanges': The index provided (${e}) is greater than or equal to the maximum bound (${this.length}).`);return 0}}),AM=pp.filter(i=>i!=="error"),SM=Object.values(bt).filter(i=>![bt.PLAYSINLINE].includes(i)),xM=Object.values(Zs);function kM(i){i.querySelectorAll(":scope > track").forEach(e=>{var t;(t=i.media)==null||t.append(e.cloneNode())}),AM.forEach(e=>{var t;(t=i.media)==null||t.addEventListener(e,s=>{i.dispatchEvent(new Event(s.type))})})}var LM=class extends lt.HTMLElement{static get observedAttributes(){return[...SM,...xM]}constructor(){super(),this.querySelectorAll(":scope > track").forEach(e=>{var t;(t=this.media)==null||t.append(e.cloneNode())});let i=e=>{for(let t of e)t.type==="childList"&&(t.removedNodes.forEach(s=>{var r,n;let a=(r=this.media)==null?void 0:r.querySelector(`track[src="${s.src}"]`);a&&((n=this.media)==null||n.removeChild(a))}),t.addedNodes.forEach(s=>{var r;(r=this.media)==null||r.append(s.cloneNode())}))};new MutationObserver(i).observe(this,{childList:!0,subtree:!0})}attributeChangedCallback(i,e,t){var s,r;switch(i){case Zs.MUTED:{this.media&&(this.media.muted=t!=null,this.media.defaultMuted=t!=null);return}case Zs.VOLUME:{let n=(s=xi(t))!=null?s:1;this.media&&(this.media.volume=n);return}case Zs.PLAYBACKRATE:{let n=(r=xi(t))!=null?r:1;this.media&&(this.media.playbackRate=n,this.media.defaultPlaybackRate=n);return}}}play(){var i,e;return(e=(i=this.media)==null?void 0:i.play())!=null?e:Promise.reject()}pause(){var i;(i=this.media)==null||i.pause()}requestCast(i){var e;return(e=this.media)==null?void 0:e.requestCast(i)}get media(){var i;return(i=this.shadowRoot)==null?void 0:i.querySelector("mux-video")}get audioTracks(){return this.media.audioTracks}get videoTracks(){return this.media.videoTracks}get audioRenditions(){return this.media.audioRenditions}get videoRenditions(){return this.media.videoRenditions}get paused(){var i,e;return(e=(i=this.media)==null?void 0:i.paused)!=null?e:!0}get duration(){var i,e;return(e=(i=this.media)==null?void 0:i.duration)!=null?e:NaN}get ended(){var i,e;return(e=(i=this.media)==null?void 0:i.ended)!=null?e:!1}get buffered(){var i,e;return(e=(i=this.media)==null?void 0:i.buffered)!=null?e:Kg}get seekable(){var i,e;return(e=(i=this.media)==null?void 0:i.seekable)!=null?e:Kg}get readyState(){var i,e;return(e=(i=this.media)==null?void 0:i.readyState)!=null?e:0}get videoWidth(){var i,e;return(e=(i=this.media)==null?void 0:i.videoWidth)!=null?e:0}get videoHeight(){var i,e;return(e=(i=this.media)==null?void 0:i.videoHeight)!=null?e:0}get currentTime(){var i,e;return(e=(i=this.media)==null?void 0:i.currentTime)!=null?e:0}set currentTime(i){this.media&&(this.media.currentTime=Number(i))}get volume(){var i,e;return(e=(i=this.media)==null?void 0:i.volume)!=null?e:1}set volume(i){this.media&&(this.media.volume=Number(i))}get playbackRate(){var i,e;return(e=(i=this.media)==null?void 0:i.playbackRate)!=null?e:1}set playbackRate(i){this.media&&(this.media.playbackRate=Number(i))}get defaultPlaybackRate(){var i;return(i=xi(this.getAttribute(Zs.PLAYBACKRATE)))!=null?i:1}set defaultPlaybackRate(i){i!=null?this.setAttribute(Zs.PLAYBACKRATE,`${i}`):this.removeAttribute(Zs.PLAYBACKRATE)}get crossOrigin(){return sa(this,bt.CROSSORIGIN)}set crossOrigin(i){this.setAttribute(bt.CROSSORIGIN,`${i}`)}get autoplay(){return sa(this,bt.AUTOPLAY)!=null}set autoplay(i){i?this.setAttribute(bt.AUTOPLAY,typeof i=="string"?i:""):this.removeAttribute(bt.AUTOPLAY)}get loop(){return sa(this,bt.LOOP)!=null}set loop(i){i?this.setAttribute(bt.LOOP,""):this.removeAttribute(bt.LOOP)}get muted(){var i,e;return(e=(i=this.media)==null?void 0:i.muted)!=null?e:!1}set muted(i){this.media&&(this.media.muted=!!i)}get defaultMuted(){return sa(this,bt.MUTED)!=null}set defaultMuted(i){i?this.setAttribute(bt.MUTED,""):this.removeAttribute(bt.MUTED)}get playsInline(){return sa(this,bt.PLAYSINLINE)!=null}set playsInline(i){ri("playsInline is set to true by default and is not currently supported as a setter.")}get preload(){return this.media?this.media.preload:this.getAttribute("preload")}set preload(i){["","none","metadata","auto"].includes(i)?this.setAttribute(bt.PRELOAD,i):this.removeAttribute(bt.PRELOAD)}};function sa(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}var Vg=LM,IM=`:host {
1675
1675
  --media-control-display: var(--controls);
1676
1676
  --media-loading-indicator-display: var(--loading-indicator);
1677
1677
  --media-dialog-display: var(--dialog);
@@ -1878,7 +1878,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1878
1878
  <div class="dialog">
1879
1879
  <slot></slot>
1880
1880
  </div>
1881
- `;var Ln=class extends lt.HTMLElement{constructor(){var i;super(),this.attachShadow({mode:"open"}),(i=this.shadowRoot)==null||i.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),qg(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),IM(this))}attributeChangedCallback(i,e,t){i==="open"&&e!==t&&(t!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&qg(this)}};Ln.styles=qT,Ln.template=YT,Ln.observedAttributes=["open"];function qg(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=jT(i.shadowRoot)),i._previouslyFocusedElement=As.activeElement,As.activeElement instanceof HTMLElement&&As.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function jT(i){let e=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});e.push('[tabindex]:not([disabled]):not([tabindex=""])');let t=i==null?void 0:i.querySelector(e.join(", "));if(!t&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let r=0;r<s.length&&!(s[r].tagName&&s[r].shadowRoot&&(t=jT(s[r].shadowRoot),t));r++);}return t}function IM(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}lt.customElements.get("media-dialog")||(lt.customElements.define("media-dialog",Ln),lt.MediaDialog=Ln);var zT=Ln,XT=As.createElement("template");XT.innerHTML=`
1881
+ `;var Ln=class extends lt.HTMLElement{constructor(){var i;super(),this.attachShadow({mode:"open"}),(i=this.shadowRoot)==null||i.appendChild(this.constructor.template.content.cloneNode(!0))}show(){this.setAttribute("open",""),this.dispatchEvent(new CustomEvent("open",{composed:!0,bubbles:!0})),qg(this)}close(){this.hasAttribute("open")&&(this.removeAttribute("open"),this.dispatchEvent(new CustomEvent("close",{composed:!0,bubbles:!0})),RM(this))}attributeChangedCallback(i,e,t){i==="open"&&e!==t&&(t!=null?this.show():this.close())}connectedCallback(){this.hasAttribute("role")||this.setAttribute("role","dialog"),this.hasAttribute("open")&&qg(this)}};Ln.styles=qT,Ln.template=YT,Ln.observedAttributes=["open"];function qg(i){let e=new CustomEvent("initfocus",{composed:!0,bubbles:!0,cancelable:!0});if(i.dispatchEvent(e),e.defaultPrevented)return;let t=i.querySelector("[autofocus]:not([disabled])");!t&&i.tabIndex>=0&&(t=i),t||(t=jT(i.shadowRoot)),i._previouslyFocusedElement=As.activeElement,As.activeElement instanceof HTMLElement&&As.activeElement.blur(),i.addEventListener("transitionend",()=>{t instanceof HTMLElement&&t.focus({preventScroll:!0})},{once:!0})}function jT(i){let e=["button","input","keygen","select","textarea"].map(function(s){return s+":not([disabled])"});e.push('[tabindex]:not([disabled]):not([tabindex=""])');let t=i==null?void 0:i.querySelector(e.join(", "));if(!t&&"attachShadow"in Element.prototype){let s=(i==null?void 0:i.querySelectorAll("*"))||[];for(let r=0;r<s.length&&!(s[r].tagName&&s[r].shadowRoot&&(t=jT(s[r].shadowRoot),t));r++);}return t}function RM(i){i._previouslyFocusedElement instanceof HTMLElement&&i._previouslyFocusedElement.focus()}lt.customElements.get("media-dialog")||(lt.customElements.define("media-dialog",Ln),lt.MediaDialog=Ln);var zT=Ln,XT=As.createElement("template");XT.innerHTML=`
1882
1882
  <style>
1883
1883
  ${zT.styles}
1884
1884
 
@@ -1909,22 +1909,22 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1909
1909
  </svg>
1910
1910
  </button>
1911
1911
  </slot>
1912
- `;var Yf=class extends zT{constructor(){var i,e;super(),(e=(i=this.shadowRoot)==null?void 0:i.querySelector(".close"))==null||e.addEventListener("click",()=>{this.close()})}};Yf.template=XT;lt.customElements.get("mxp-dialog")||(lt.customElements.define("mxp-dialog",Yf),lt.MxpDialog=Yf);var ra=new WeakMap,RM=class QT{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let s=ra.get(this.element);s&&s.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=ra.get(this.element);t&&t.delete(this.type)}}static for(e){ra.has(e.element)||ra.set(e.element,new Map);let t=e.attributeName.slice(2),s=ra.get(e.element);return s&&s.has(t)?s.get(t):new QT(e.element,t)}};function wM(i,e){return i instanceof ai&&i.attributeName.startsWith("on")?(RM.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function CM(i,e){return e instanceof ZT&&i instanceof Gn?(e.renderInto(i),!0):!1}function DM(i,e){return e instanceof DocumentFragment&&i instanceof Gn?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function MM(i,e){if(i instanceof ai){let t=i.attributeNamespace,s=i.element.getAttributeNS(t,i.attributeName);return String(e)!==s&&(i.value=String(e)),!0}return i.value=String(e),!0}function OM(i,e){if(i instanceof ai&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function PM(i,e){if(typeof e=="boolean"&&i instanceof ai){let t=i.attributeNamespace,s=i.element.hasAttributeNS(t,i.attributeName);return e!==s&&(i.booleanValue=e),!0}return!1}function NM(i,e){return e===!1&&i instanceof Gn?(i.replace(""),!0):!1}function UM(i,e){OM(i,e)||PM(i,e)||wM(i,e)||NM(i,e)||CM(i,e)||DM(i,e)||MM(i,e)}var Hu=new Map,Yg=new WeakMap,jg=new WeakMap,ZT=class{constructor(i,e,t){this.strings=i,this.values=e,this.processor=t,this.stringsKey=this.strings.join("")}get template(){if(Hu.has(this.stringsKey))return Hu.get(this.stringsKey);{let i=As.createElement("template"),e=this.strings.length-1;return i.innerHTML=this.strings.reduce((t,s,r)=>t+s+(r<e?`{{ ${r} }}`:""),""),Hu.set(this.stringsKey,i),i}}renderInto(i){var e;let t=this.template;if(Yg.get(i)!==t){Yg.set(i,t);let r=new $c(t,this.values,this.processor);jg.set(i,r),i instanceof Gn?i.replace(...r.children):i.appendChild(r);return}let s=jg.get(i);(e=s==null?void 0:s.update)==null||e.call(s,this.values)}},FM={processCallback(i,e,t){var s;if(t){for(let[r,n]of e)if(r in t){let a=(s=t[r])!=null?s:"";UM(n,a)}}}};function hs(i,...e){return new ZT(i,e,FM)}function $M(i,e){i.renderInto(e)}var BM=i=>hs`
1912
+ `;var Yf=class extends zT{constructor(){var i,e;super(),(e=(i=this.shadowRoot)==null?void 0:i.querySelector(".close"))==null||e.addEventListener("click",()=>{this.close()})}};Yf.template=XT;lt.customElements.get("mxp-dialog")||(lt.customElements.define("mxp-dialog",Yf),lt.MxpDialog=Yf);var ra=new WeakMap,wM=class QT{constructor(e,t){this.element=e,this.type=t,this.element.addEventListener(this.type,this);let s=ra.get(this.element);s&&s.set(this.type,this)}set(e){if(typeof e=="function")this.handleEvent=e.bind(this.element);else if(typeof e=="object"&&typeof e.handleEvent=="function")this.handleEvent=e.handleEvent.bind(e);else{this.element.removeEventListener(this.type,this);let t=ra.get(this.element);t&&t.delete(this.type)}}static for(e){ra.has(e.element)||ra.set(e.element,new Map);let t=e.attributeName.slice(2),s=ra.get(e.element);return s&&s.has(t)?s.get(t):new QT(e.element,t)}};function CM(i,e){return i instanceof ai&&i.attributeName.startsWith("on")?(wM.for(i).set(e),i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),!0):!1}function DM(i,e){return e instanceof ZT&&i instanceof Gn?(e.renderInto(i),!0):!1}function MM(i,e){return e instanceof DocumentFragment&&i instanceof Gn?(e.childNodes.length&&i.replace(...e.childNodes),!0):!1}function OM(i,e){if(i instanceof ai){let t=i.attributeNamespace,s=i.element.getAttributeNS(t,i.attributeName);return String(e)!==s&&(i.value=String(e)),!0}return i.value=String(e),!0}function PM(i,e){if(i instanceof ai&&e instanceof Element){let t=i.element;return t[i.attributeName]!==e&&(i.element.removeAttributeNS(i.attributeNamespace,i.attributeName),t[i.attributeName]=e),!0}return!1}function NM(i,e){if(typeof e=="boolean"&&i instanceof ai){let t=i.attributeNamespace,s=i.element.hasAttributeNS(t,i.attributeName);return e!==s&&(i.booleanValue=e),!0}return!1}function UM(i,e){return e===!1&&i instanceof Gn?(i.replace(""),!0):!1}function FM(i,e){PM(i,e)||NM(i,e)||CM(i,e)||UM(i,e)||DM(i,e)||MM(i,e)||OM(i,e)}var Hu=new Map,Yg=new WeakMap,jg=new WeakMap,ZT=class{constructor(i,e,t){this.strings=i,this.values=e,this.processor=t,this.stringsKey=this.strings.join("")}get template(){if(Hu.has(this.stringsKey))return Hu.get(this.stringsKey);{let i=As.createElement("template"),e=this.strings.length-1;return i.innerHTML=this.strings.reduce((t,s,r)=>t+s+(r<e?`{{ ${r} }}`:""),""),Hu.set(this.stringsKey,i),i}}renderInto(i){var e;let t=this.template;if(Yg.get(i)!==t){Yg.set(i,t);let r=new $c(t,this.values,this.processor);jg.set(i,r),i instanceof Gn?i.replace(...r.children):i.appendChild(r);return}let s=jg.get(i);(e=s==null?void 0:s.update)==null||e.call(s,this.values)}},$M={processCallback(i,e,t){var s;if(t){for(let[r,n]of e)if(r in t){let a=(s=t[r])!=null?s:"";FM(n,a)}}}};function hs(i,...e){return new ZT(i,e,$M)}function BM(i,e){i.renderInto(e)}var GM=i=>hs`
1913
1913
  <style>
1914
- ${LM}
1914
+ ${IM}
1915
1915
  </style>
1916
- ${KM(i)}
1917
- `,GM=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return _p(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},HM={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},WM=Object.values(HM).join(", "),KM=i=>{var e,t,s,r,n,a,o,l,d,c,u,h,f,m,p,g,v,y,b,x,_,S,A,D,O,L,C,H,U,Q,q,Y,oe,ae,G,F;return hs`
1916
+ ${VM(i)}
1917
+ `,HM=i=>{let e=i.hotKeys?`${i.hotKeys}`:"";return _p(i.streamType)==="live"&&(e+=" noarrowleft noarrowright"),e},WM={TOP:"top",CENTER:"center",BOTTOM:"bottom",LAYER:"layer",MEDIA_LAYER:"media-layer",POSTER_LAYER:"poster-layer",VERTICAL_LAYER:"vertical-layer",CENTERED_LAYER:"centered-layer",GESTURE_LAYER:"gesture-layer",CONTROLLER_LAYER:"controller",BUTTON:"button",RANGE:"range",DISPLAY:"display",CONTROL_BAR:"control-bar",SELECTMENU:"selectmenu",LISTBOX:"listbox",OPTION:"option",POSTER:"poster",LIVE:"live",PLAY:"play",PRE_PLAY:"pre-play",SEEK_BACKWARD:"seek-backward",SEEK_FORWARD:"seek-forward",MUTE:"mute",CAPTIONS:"captions",AIRPLAY:"airplay",PIP:"pip",FULLSCREEN:"fullscreen",CAST:"cast",PLAYBACK_RATE:"playback-rate",VOLUME:"volume",TIME:"time",TITLE:"title",AUDIO_TRACK:"audio-track",RENDITION:"rendition"},KM=Object.values(WM).join(", "),VM=i=>{var e,t,s,r,n,a,o,l,d,c,u,h,f,m,p,g,v,y,b,x,_,S,A,D,O,L,C,H,U,Q,q,Y,oe,ae,G,F;return hs`
1918
1918
  <media-theme
1919
1919
  template="${i.themeTemplate||!1}"
1920
1920
  defaultstreamtype="${(e=i.defaultStreamType)!=null?e:!1}"
1921
- hotkeys="${GM(i)||!1}"
1921
+ hotkeys="${HM(i)||!1}"
1922
1922
  nohotkeys="${i.noHotKeys||!i.hasSrc||i.isDialogOpen||!1}"
1923
1923
  noautoseektolive="${!!((t=i.streamType)!=null&&t.includes(_e.LIVE))&&i.targetLiveWindow!==0}"
1924
1924
  novolumepref="${i.novolumepref||!1}"
1925
1925
  disabled="${!i.hasSrc||i.isDialogOpen}"
1926
1926
  audio="${(s=i.audio)!=null?s:!1}"
1927
- style="${(r=fM({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?r:!1}"
1927
+ style="${(r=mM({"--media-primary-color":i.primaryColor,"--media-secondary-color":i.secondaryColor,"--media-accent-color":i.accentColor}))!=null?r:!1}"
1928
1928
  defaultsubtitles="${!i.defaultHiddenCaptions}"
1929
1929
  forwardseekoffset="${(n=i.forwardSeekOffset)!=null?n:!1}"
1930
1930
  backwardseekoffset="${(a=i.backwardSeekOffset)!=null?a:!1}"
@@ -1933,7 +1933,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1933
1933
  defaultduration="${(d=i.defaultDuration)!=null?d:!1}"
1934
1934
  hideduration="${(c=i.hideDuration)!=null?c:!1}"
1935
1935
  title="${(u=i.title)!=null?u:!1}"
1936
- exportparts="${WM}"
1936
+ exportparts="${KM}"
1937
1937
  >
1938
1938
  <mux-video
1939
1939
  slot="media"
@@ -1989,7 +1989,7 @@ media-poster-image:not([src]):not([placeholdersrc]) {
1989
1989
  </p>
1990
1990
  </mxp-dialog>
1991
1991
  </media-theme>
1992
- `};function jf(i,e,t,s,r){var n,a,o;let l={},d={};switch(i.code){case Ct.MEDIA_ERR_NETWORK:{switch(l.title=fe("Network Error",r),l.message=i.message,(n=i.data)==null?void 0:n.response.code){case 412:{l.title=fe("Video is not currently available",r),l.message=fe("The live stream or video file are not yet ready.",r),d.message=fe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",r),d.file="412-not-playable.md";break}case 404:{l.title=fe("Video does not exist",r),l.message="",d.message=fe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",r),d.file="404-not-found.md";break}case 403:{if(l.title=fe("Invalid playback URL",r),l.message=fe("The video URL or playback-token are formatted with incorrect or incomplete information.",r),d.message=fe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",r),d.file="missing-signed-tokens.md",!s)break;let{exp:c,aud:u,sub:h}=lo(s),f=Date.now()>c*1e3,m=h!==t,p=u!=="v",g={timeStyle:"medium",dateStyle:"medium"};if(f){l.title=fe("Video URL has expired",r),l.message=fe("The video’s secured playback-token has expired.",r),d.message=fe("The video’s secured playback-token has expired.",r),d.context=fe("Expired at: {expiredDate}. Current time: {currentDate}.",r).format({expiredDate:new Intl.DateTimeFormat(oo.code,g).format(c*1e3),currentDate:new Intl.DateTimeFormat(oo.code,g).format(Date.now())}),d.file="403-expired-token.md";break}if(m){l.title=fe("Video URL is formatted incorrectly",r),l.message=fe("The video’s playback ID does not match the one encoded in the playback-token.",r),d.message=fe("The video’s playback ID does not match the one encoded in the playback-token.",r),d.context=fe("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",r).format({playbackId:t,tokenPlaybackId:h}),d.file="403-playback-id-mismatch.md";break}if(p){l.title=fe("Video URL is formatted incorrectly",r),l.message=fe("The playback-token is formatted with incorrect information.",r),d.message=fe("The playback-token is formatted with incorrect information.",r),d.context=fe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",r).format({tokenType:u}),d.file="403-incorrect-aud-value.md";break}d.message=fe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",r),d.file="403-malformatted-token.md";break}}break}case Ct.MEDIA_ERR_DECODE:{let{message:c}=i;l={title:fe("Media Error",r),message:c},d.file="media-decode-error.md";break}case Ct.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(o=(a=i.data)==null?void 0:a.response)==null?void 0:o.code;if(c>=400&&c<500){i.code=Ct.MEDIA_ERR_NETWORK,i.data={response:{code:c}},{dialog:l,devlog:d}=jf(i,e,t,s);break}l={title:fe("Source Not Supported",r),message:i.message},d.file="media-src-not-supported.md";break}default:l={title:fe("Error",r),message:i.message};break}return e&&(l={title:fe("Your device appears to be offline",r),message:fe("Check your internet connection and try reloading this video.",r)}),{dialog:l,devlog:d}}var VM=`<template id="media-theme-gerwig">
1992
+ `};function jf(i,e,t,s,r){var n,a,o;let l={},d={};switch(i.code){case Ct.MEDIA_ERR_NETWORK:{switch(l.title=fe("Network Error",r),l.message=i.message,(n=i.data)==null?void 0:n.response.code){case 412:{l.title=fe("Video is not currently available",r),l.message=fe("The live stream or video file are not yet ready.",r),d.message=fe("This playback-id may belong to a live stream that is not currently active or an asset that is not ready.",r),d.file="412-not-playable.md";break}case 404:{l.title=fe("Video does not exist",r),l.message="",d.message=fe("This playback-id does not exist. You may have used an Asset ID or an ID from a different resource.",r),d.file="404-not-found.md";break}case 403:{if(l.title=fe("Invalid playback URL",r),l.message=fe("The video URL or playback-token are formatted with incorrect or incomplete information.",r),d.message=fe("403 error trying to access this playback URL. If this is a signed URL, you might need to provide a playback-token.",r),d.file="missing-signed-tokens.md",!s)break;let{exp:c,aud:u,sub:h}=lo(s),f=Date.now()>c*1e3,m=h!==t,p=u!=="v",g={timeStyle:"medium",dateStyle:"medium"};if(f){l.title=fe("Video URL has expired",r),l.message=fe("The video’s secured playback-token has expired.",r),d.message=fe("The video’s secured playback-token has expired.",r),d.context=fe("Expired at: {expiredDate}. Current time: {currentDate}.",r).format({expiredDate:new Intl.DateTimeFormat(oo.code,g).format(c*1e3),currentDate:new Intl.DateTimeFormat(oo.code,g).format(Date.now())}),d.file="403-expired-token.md";break}if(m){l.title=fe("Video URL is formatted incorrectly",r),l.message=fe("The video’s playback ID does not match the one encoded in the playback-token.",r),d.message=fe("The video’s playback ID does not match the one encoded in the playback-token.",r),d.context=fe("Specified playback ID: {playbackId} and the playback ID encoded in the playback-token: {tokenPlaybackId}",r).format({playbackId:t,tokenPlaybackId:h}),d.file="403-playback-id-mismatch.md";break}if(p){l.title=fe("Video URL is formatted incorrectly",r),l.message=fe("The playback-token is formatted with incorrect information.",r),d.message=fe("The playback-token is formatted with incorrect information.",r),d.context=fe("The playback-token has an incorrect aud value: {tokenType}. aud value should be v.",r).format({tokenType:u}),d.file="403-incorrect-aud-value.md";break}d.message=fe("403 error trying to access this playback URL. If this is a signed playback ID, the token might not have been generated correctly.",r),d.file="403-malformatted-token.md";break}}break}case Ct.MEDIA_ERR_DECODE:{let{message:c}=i;l={title:fe("Media Error",r),message:c},d.file="media-decode-error.md";break}case Ct.MEDIA_ERR_SRC_NOT_SUPPORTED:{let c=(o=(a=i.data)==null?void 0:a.response)==null?void 0:o.code;if(c>=400&&c<500){i.code=Ct.MEDIA_ERR_NETWORK,i.data={response:{code:c}},{dialog:l,devlog:d}=jf(i,e,t,s);break}l={title:fe("Source Not Supported",r),message:i.message},d.file="media-src-not-supported.md";break}default:l={title:fe("Error",r),message:i.message};break}return e&&(l={title:fe("Your device appears to be offline",r),message:fe("Check your internet connection and try reloading this video.",r)}),{dialog:l,devlog:d}}var qM=`<template id="media-theme-gerwig">
1993
1993
  <style>
1994
1994
  @keyframes pre-play-hide {
1995
1995
  0% {
@@ -2983,6 +2983,6 @@ media-poster-image:not([src]):not([placeholdersrc]) {
2983
2983
  <slot></slot>
2984
2984
  </media-controller>
2985
2985
  </template>
2986
- `,zf=As.createElement("template");"innerHTML"in zf&&(zf.innerHTML=VM);var zg,Xg,JT=class extends go{};JT.template=(Xg=(zg=zf.content)==null?void 0:zg.children)==null?void 0:Xg[0];lt.customElements.get("media-theme-gerwig")||lt.customElements.define("media-theme-gerwig",JT);var qM="gerwig",qi={SRC:"src",POSTER:"poster"},$={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},Xf=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function YM(i,e){var t;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute($.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:jM(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute($.NOHOTKEYS),hotKeys:i.getAttribute($.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(P.TARGET_LIVE_WINDOW),streamType:_p(i.getAttribute(P.STREAM_TYPE)),primaryColor:i.getAttribute($.PRIMARY_COLOR),secondaryColor:i.getAttribute($.SECONDARY_COLOR),accentColor:i.getAttribute($.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:zM(i),playbackRates:i.getAttribute($.PLAYBACK_RATES),customDomain:(t=i.getAttribute(P.CUSTOM_DOMAIN))!=null?t:void 0,title:i.getAttribute($.TITLE),novolumepref:i.hasAttribute($.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function jM(i){var e,t;let s=i.theme;if(s){let r=(t=(e=i.getRootNode())==null?void 0:e.getElementById)==null?void 0:t.call(e,s);if(r&&r instanceof HTMLTemplateElement)return r;s.startsWith("media-theme-")||(s=`media-theme-${s}`);let n=lt.customElements.get(s);if(n!=null&&n.template)return n.template}}function zM(i){var e;let t=(e=i.mediaController)==null?void 0:e.querySelector("media-time-display");return t&&getComputedStyle(t).getPropertyValue("--media-duration-display-display").trim()==="none"}function Qg(i){let e=i.hasAttribute($.TITLE)?{video_title:i.getAttribute($.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,s)=>{let r=i.getAttribute(s);return r!==null&&(t[s.replace(/^metadata-/,"").replace(/-/g,"_")]=r),t},e)}var XM=Object.values(P),QM=Object.values(qi),ZM=Object.values($),JM=WT(),e2="mux-player",Zg={dialog:void 0,isDialogOpen:!1},t2={redundant_streams:!0},Rd,wd,Js,Cd,In,Yi,fs,Qf,e_,Ac,Zf,tr,hn,Jf,Jg,em,ev,tm,tv,im,iv,sv=class extends Vg{constructor(){super(),ht(this,Yi),ht(this,Qf),ht(this,Ac),ht(this,tr),ht(this,Jf),ht(this,em),ht(this,tm),ht(this,im),ht(this,Rd,!1),ht(this,wd,{}),ht(this,Js,!0),ht(this,Cd,new TM(this,"hotkeys")),ht(this,In,{...Zg,onCloseErrorDialog:()=>ze(this,Ac,Zf).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{GT(this,As.activeElement)||e.preventDefault()}}),this.attachShadow({mode:"open"}),ze(this,Qf,e_).call(this),this.isConnected&&ze(this,Yi,fs).call(this)}static get observedAttributes(){var e;return[...(e=Vg.observedAttributes)!=null?e:[],...QM,...XM,...ZM]}get mediaTheme(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("media-theme")}get mediaController(){var e,t;return(t=(e=this.mediaTheme)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("media-controller")}connectedCallback(){var e;let t=(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video");t&&(t.metadata=Qg(this))}attributeChangedCallback(e,t,s){switch(ze(this,Yi,fs).call(this),super.attributeChangedCallback(e,t,s),e){case $.HOTKEYS:Te(this,Cd).value=s;break;case $.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&cr(fe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case $.THUMBNAIL_TOKEN:{let{aud:r}=lo(s);s&&r!=="t"&&cr(fe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:r}));break}case $.STORYBOARD_TOKEN:{let{aud:r}=lo(s);s&&r!=="s"&&cr(fe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:r}));break}case P.PLAYBACK_ID:{s!=null&&s.includes("?token")&&ri(fe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case P.STREAM_TYPE:s&&![_e.LIVE,_e.ON_DEMAND,_e.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:VT({file:"invalid-stream-type.md",message:fe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===_e.LIVE?this.getAttribute($.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[P.PLAYBACK_ID,qi.SRC,$.PLAYBACK_TOKEN].includes(e)&&t!==s&&Zi(this,In,{...Te(this,In),...Zg}),ze(this,tr,hn).call(this,{[yM(e)]:s})}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?jd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):cr(`Invalid value for preferCmcd. Must be one of ${jd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get hasPlayed(){var e,t;return(t=(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_HAS_PLAYED))!=null?t:!1}get inLiveWindow(){var e;return(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_TIME_IS_LIVE)}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get theme(){var e;return(e=this.getAttribute($.THEME))!=null?e:qM}set theme(e){this.setAttribute($.THEME,`${e}`)}get themeProps(){let e=this.mediaTheme;if(!e)return;let t={};for(let s of e.getAttributeNames()){if(Xf.includes(s))continue;let r=e.getAttribute(s);t[$T(s)]=r===""?!0:r}return t}set themeProps(e){var t,s;ze(this,Yi,fs).call(this);let r={...this.themeProps,...e};for(let n in r){if(Xf.includes(n))continue;let a=e==null?void 0:e[n];typeof a=="boolean"||a==null?(t=this.mediaTheme)==null||t.toggleAttribute(qf(n),!!a):(s=this.mediaTheme)==null||s.setAttribute(qf(n),a)}}get playbackId(){var e;return(e=this.getAttribute(P.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID)}get src(){var e,t;return this.playbackId?(e=Ds(this,qi.SRC))!=null?e:void 0:(t=this.getAttribute(qi.SRC))!=null?t:void 0}set src(e){e?this.setAttribute(qi.SRC,e):this.removeAttribute(qi.SRC)}get poster(){var e;let t=this.getAttribute(qi.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return vM(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(e=this.thumbnailTime)!=null?e:this.startTime,programTime:this.programStartTime,token:this.tokens.thumbnail})}set poster(e){e||e===""?this.setAttribute(qi.POSTER,e):this.removeAttribute(qi.POSTER)}get storyboardSrc(){var e;return(e=this.getAttribute($.STORYBOARD_SRC))!=null?e:void 0}set storyboardSrc(e){e?this.setAttribute($.STORYBOARD_SRC,e):this.removeAttribute($.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[_e.LIVE,_e.UNKNOWN].includes(this.streamType)))return EM(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute($.AUDIO)}set audio(e){if(!e){this.removeAttribute($.AUDIO);return}this.setAttribute($.AUDIO,"")}get hotkeys(){return Te(this,Cd)}get nohotkeys(){return this.hasAttribute($.NOHOTKEYS)}set nohotkeys(e){if(!e){this.removeAttribute($.NOHOTKEYS);return}this.setAttribute($.NOHOTKEYS,"")}get thumbnailTime(){return xi(this.getAttribute($.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute($.THUMBNAIL_TIME,`${e}`)}get title(){var e;return(e=this.getAttribute($.TITLE))!=null?e:""}set title(e){e!==this.title&&(e?this.setAttribute($.TITLE,e):this.removeAttribute("title"),super.title=e)}get placeholder(){var e;return(e=Ds(this,$.PLACEHOLDER))!=null?e:""}set placeholder(e){this.setAttribute($.PLACEHOLDER,`${e}`)}get primaryColor(){var e,t;let s=this.getAttribute($.PRIMARY_COLOR);if(s!=null||this.mediaTheme&&(s=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_primary-color"))==null?void 0:t.trim(),s))return s}set primaryColor(e){this.setAttribute($.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e,t;let s=this.getAttribute($.SECONDARY_COLOR);if(s!=null||this.mediaTheme&&(s=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_secondary-color"))==null?void 0:t.trim(),s))return s}set secondaryColor(e){this.setAttribute($.SECONDARY_COLOR,`${e}`)}get accentColor(){var e,t;let s=this.getAttribute($.ACCENT_COLOR);if(s!=null||this.mediaTheme&&(s=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_accent-color"))==null?void 0:t.trim(),s))return s}set accentColor(e){this.setAttribute($.ACCENT_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute($.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute($.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute($.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute($.PLAYBACK_RATES))return this.getAttribute($.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,t)=>e-t)}set playbackRates(e){if(!e){this.removeAttribute($.PLAYBACK_RATES);return}this.setAttribute($.PLAYBACK_RATES,e.join(" "))}get forwardSeekOffset(){var e;return(e=xi(this.getAttribute($.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute($.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=xi(this.getAttribute($.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute($.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute($.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute($.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute($.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return xi(this.getAttribute($.DEFAULT_DURATION))}set defaultDuration(e){e==null?this.removeAttribute($.DEFAULT_DURATION):this.setAttribute($.DEFAULT_DURATION,`${e}`)}get playerSoftwareName(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_NAME))!=null?e:e2}get playerSoftwareVersion(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_VERSION))!=null?e:JM}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){return xi(this.getAttribute(P.PROGRAM_START_TIME))}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){return xi(this.getAttribute(P.PROGRAM_END_TIME))}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get extraSourceParams(){return this.hasAttribute($.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute($.EXTRA_SOURCE_PARAMS)).entries()].reduce((e,[t,s])=>(e[t]=s,e),{}):t2}set extraSourceParams(e){e==null?this.removeAttribute($.EXTRA_SOURCE_PARAMS):this.setAttribute($.EXTRA_SOURCE_PARAMS,new URLSearchParams(e).toString())}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get envKey(){var e;return(e=Ds(this,P.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(P.ENV_KEY,`${e}`)}get noVolumePref(){return this.hasAttribute($.NO_VOLUME_PREF)}set noVolumePref(e){e?this.setAttribute($.NO_VOLUME_PREF,""):this.removeAttribute($.NO_VOLUME_PREF)}get debug(){return Ds(this,P.DEBUG)!=null}set debug(e){e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG)}get disableTracking(){return Ds(this,P.DISABLE_TRACKING)!=null}set disableTracking(e){this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return Ds(this,P.DISABLE_COOKIES)!=null}set disableCookies(e){e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES)}get streamType(){var e,t,s;return(s=(t=this.getAttribute(P.STREAM_TYPE))!=null?t:(e=this.media)==null?void 0:e.streamType)!=null?s:_e.UNKNOWN}set streamType(e){this.setAttribute(P.STREAM_TYPE,`${e}`)}get defaultStreamType(){var e,t,s;return(s=(t=this.getAttribute($.DEFAULT_STREAM_TYPE))!=null?t:(e=this.mediaController)==null?void 0:e.getAttribute($.DEFAULT_STREAM_TYPE))!=null?s:_e.ON_DEMAND}set defaultStreamType(e){e?this.setAttribute($.DEFAULT_STREAM_TYPE,e):this.removeAttribute($.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var e,t;return this.hasAttribute($.TARGET_LIVE_WINDOW)?+this.getAttribute($.TARGET_LIVE_WINDOW):(t=(e=this.media)==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN}set targetLiveWindow(e){e==this.targetLiveWindow||Number.isNaN(e)&&Number.isNaN(this.targetLiveWindow)||(e==null?this.removeAttribute($.TARGET_LIVE_WINDOW):this.setAttribute($.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e;return(e=this.media)==null?void 0:e.liveEdgeStart}get startTime(){return xi(Ds(this,P.START_TIME))}set startTime(e){this.setAttribute(P.START_TIME,`${e}`)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ci.MSE||e===Ci.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ci.MSE||e===Ci.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...Qg(this),...e}}get _hlsConfig(){var e;return(e=this.media)==null?void 0:e._hlsConfig}set _hlsConfig(e){if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=e}async addCuePoints(e){var t;if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(t=this.media)==null?void 0:t.addCuePoints(e)}get activeCuePoint(){var e;return(e=this.media)==null?void 0:e.activeCuePoint}get cuePoints(){var e,t;return(t=(e=this.media)==null?void 0:e.cuePoints)!=null?t:[]}addChapters(e){var t;if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(t=this.media)==null?void 0:t.addChapters(e)}get activeChapter(){var e;return(e=this.media)==null?void 0:e.activeChapter}get chapters(){var e,t;return(t=(e=this.media)==null?void 0:e.chapters)!=null?t:[]}getStartDate(){var e;return(e=this.media)==null?void 0:e.getStartDate()}get currentPdt(){var e;return(e=this.media)==null?void 0:e.currentPdt}get tokens(){let e=this.getAttribute($.PLAYBACK_TOKEN),t=this.getAttribute($.THUMBNAIL_TOKEN),s=this.getAttribute($.STORYBOARD_TOKEN);return{...Te(this,wd),...e!=null?{playback:e}:{},...t!=null?{thumbnail:t}:{},...s!=null?{storyboard:s}:{}}}set tokens(e){Zi(this,wd,e??{})}get playbackToken(){var e;return(e=this.getAttribute($.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute($.PLAYBACK_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute($.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute($.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute($.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute($.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,s,r){var n;let a=(n=this.media)==null?void 0:n.nativeEl;if(a)return Lm(a,e,t,s,r)}removeTextTrack(e){var t;let s=(t=this.media)==null?void 0:t.nativeEl;if(s)return lI(s,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}};Rd=new WeakMap,wd=new WeakMap,Js=new WeakMap,Cd=new WeakMap,In=new WeakMap,Yi=new WeakSet,fs=function(){var i,e,t;if(!Te(this,Rd)){Zi(this,Rd,!0),ze(this,tr,hn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof lt.HTMLElement))throw""}catch{ri("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof VD))throw""}catch{ri("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof MR))throw""}catch{ri("<media-controller> failed to upgrade!")}xM(this),ze(this,Jf,Jg).call(this),ze(this,em,ev).call(this),ze(this,tm,tv).call(this),Zi(this,Js,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(ge.USER_INACTIVE))!=null?e:!0),ze(this,im,iv).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>{ze(this,tr,hn).call(this)})}},Qf=new WeakSet,e_=function(){var i,e;try{(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ac=new WeakSet,Zf=function(i){Object.assign(Te(this,In),i),ze(this,tr,hn).call(this)},tr=new WeakSet,hn=function(i={}){$M(BM(YM(this,{...Te(this,In),...i})),this.shadowRoot)},Jf=new WeakSet,Jg=function(){let i=e=>{var t,s;if(!(e!=null&&e.startsWith("theme-")))return;let r=e.replace(/^theme-/,"");if(Xf.includes(r))return;let n=this.getAttribute(e);n!=null?(t=this.mediaTheme)==null||t.setAttribute(r,n):(s=this.mediaTheme)==null||s.removeAttribute(r)};new MutationObserver(e=>{for(let{attributeName:t}of e)i(t)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(i)},em=new WeakSet,ev=function(){var i;let e=t=>{let{detail:s}=t;if(s instanceof Ct||(s=new Ct(s.message,s.code,s.fatal)),!(s!=null&&s.fatal)){cr(s),s.data&&cr(`${s.name} data:`,s.data);return}let{dialog:r,devlog:n}=jf(s,!window.navigator.onLine,this.playbackId,this.playbackToken);n.message&&VT(n),ri(s),s.data&&ri(`${s.name} data:`,s.data),ze(this,Ac,Zf).call(this,{isDialogOpen:!0,dialog:r})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(t={})=>{var s,r,n;if(!(((s=this.media)==null?void 0:s.error)instanceof Ct))return t;let{devlog:a}=jf((r=this.media)==null?void 0:r.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(n=this.media)==null?void 0:n.error.code,player_error_message:a.message?String(a.message):t.player_error_message,player_error_context:a.context?String(a.context):t.player_error_context}}),(i=this.media)==null||i.addEventListener("error",t=>{var s,r;let{detail:n}=t;if(!n){let{message:a,code:o}=(r=(s=this.media)==null?void 0:s.error)!=null?r:{};n=new Ct(a,o)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},tm=new WeakSet,tv=function(){var i,e,t,s;let r=()=>ze(this,tr,hn).call(this);(e=(i=this.media)==null?void 0:i.textTracks)==null||e.addEventListener("addtrack",r),(s=(t=this.media)==null?void 0:t.textTracks)==null||s.addEventListener("removetrack",r)},im=new WeakSet,iv=function(){var i,e;if(!/Firefox/i.test(navigator.userAgent))return;let t,s=new WeakMap,r=()=>this.streamType===_e.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(l,d,c=!1)=>{r()||Array.from(l&&l.activeCues||[]).forEach(u=>{if(!(!u.snapToLines||u.line<-5||u.line>=0&&u.line<10))if(!d||this.paused){let h=u.text.split(`
2987
- `).length,f=-3;this.streamType===_e.LIVE&&(f=-2);let m=f-h;if(u.line===m&&!c)return;s.has(u)||s.set(u,u.line),u.line=m}else setTimeout(()=>{u.line=s.get(u)||"auto"},500)})},a=()=>{var l,d;n(t,(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ge.USER_INACTIVE))!=null?d:!1)},o=()=>{var l,d;let c=Array.from(((d=(l=this.mediaController)==null?void 0:l.media)==null?void 0:d.textTracks)||[]).filter(u=>["subtitles","captions"].includes(u.kind)&&u.mode==="showing")[0];c!==t&&(t==null||t.removeEventListener("cuechange",a)),t=c,t==null||t.addEventListener("cuechange",a),n(t,Te(this,Js))};o(),(i=this.textTracks)==null||i.addEventListener("change",o),(e=this.textTracks)==null||e.addEventListener("addtrack",o),this.addEventListener("userinactivechange",()=>{var l,d;let c=(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ge.USER_INACTIVE))!=null?d:!0;Te(this,Js)!==c&&(Zi(this,Js,c),n(t,Te(this,Js)))})};function Ds(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}lt.customElements.get("mux-player")||(lt.customElements.define("mux-player",sv),lt.MuxPlayerElement=sv);var rv={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay",playbackRate:"playbackrate"},i2=i=>i==null,s2=(i,e)=>i2(e)?!1:i in e,r2=i=>i.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),n2=(i,e)=>{if(!(typeof e=="boolean"&&!e)){if(s2(i,rv))return rv[i];if(typeof e!=null)return/[A-Z]/.test(i)?r2(i):i}},a2=(i,e)=>typeof i=="boolean"?"":i,o2=(i={})=>Object.entries(i).reduce((e,[t,s])=>{let r=n2(t,s);if(!r)return e;let n=a2(s);return e[r]=n,e},{}),l2=(...i)=>{let e=pt.useRef(null);return pt.useEffect(()=>{i.forEach(t=>{t&&(typeof t=="function"?t(e.current):t.current=e.current)})},[i]),e},d2=Object.prototype.hasOwnProperty,c2=(i,e)=>{if(Object.is(i,e))return!0;if(typeof i!="object"||i===null||typeof e!="object"||e===null)return!1;if(Array.isArray(i))return!Array.isArray(e)||i.length!==e.length?!1:i.some((r,n)=>e[n]===r);let t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r=0;r<t.length;r++)if(!d2.call(e,t[r])||!Object.is(i[t[r]],e[t[r]]))return!1;return!0},t_=(i,e,t)=>!c2(e,i[t]),u2=(i,e,t)=>{i[t]=e},h2=(i,e,t,s=u2,r=t_)=>pt.useEffect(()=>{let n=t==null?void 0:t.current;n&&r(n,e,i)&&s(n,e,i)},[t==null?void 0:t.current,e]),Wi=h2,f2=()=>{try{return"2.7.0"}catch{}return"UNKNOWN"},m2=f2(),p2=()=>m2,g2=Dd.forwardRef(({children:i,...e},t)=>Dd.createElement("mux-player",o2({...e,ref:t}),i)),ke=(i,e,t)=>pt.useEffect(()=>{let s=e==null?void 0:e.current;if(!(!s||!t))return s.addEventListener(i,t),()=>{s.removeEventListener(i,t)}},[e==null?void 0:e.current,t]),v2=(i,e)=>{let{onAbort:t,onCanPlay:s,onCanPlayThrough:r,onEmptied:n,onLoadStart:a,onLoadedData:o,onLoadedMetadata:l,onProgress:d,onDurationChange:c,onVolumeChange:u,onRateChange:h,onResize:f,onWaiting:m,onPlay:p,onPlaying:g,onTimeUpdate:v,onPause:y,onSeeking:b,onSeeked:x,onStalled:_,onSuspend:S,onEnded:A,onError:D,onCuePointChange:O,onCuePointsChange:L,onChapterChange:C,metadata:H,tokens:U,paused:Q,playbackId:q,playbackRates:Y,currentTime:oe,themeProps:ae,extraSourceParams:G,_hlsConfig:F,...re}=e;return Wi("playbackRates",Y,i),Wi("metadata",H,i),Wi("extraSourceParams",G,i),Wi("_hlsConfig",F,i),Wi("themeProps",ae,i),Wi("tokens",U,i),Wi("playbackId",q,i),Wi("paused",Q,i,(J,de)=>{de!=null&&(de?J.pause():J.play())},(J,de,Ae)=>J.hasAttribute("autoplay")&&!J.hasPlayed?!1:t_(J,de,Ae)),Wi("currentTime",oe,i,(J,de)=>{de!=null&&(J.currentTime=de)}),ke("abort",i,t),ke("canplay",i,s),ke("canplaythrough",i,r),ke("emptied",i,n),ke("loadstart",i,a),ke("loadeddata",i,o),ke("loadedmetadata",i,l),ke("progress",i,d),ke("durationchange",i,c),ke("volumechange",i,u),ke("ratechange",i,h),ke("resize",i,f),ke("waiting",i,m),ke("play",i,p),ke("playing",i,g),ke("timeupdate",i,v),ke("pause",i,y),ke("seeking",i,b),ke("seeked",i,x),ke("stalled",i,_),ke("suspend",i,S),ke("ended",i,A),ke("error",i,D),ke("cuepointchange",i,O),ke("cuepointschange",i,L),ke("chapterchange",i,C),[re]},E2=p2(),b2="mux-player-react",y2=Dd.forwardRef((i,e)=>{let t=pt.useRef(null),s=l2(t,e),[r]=v2(t,i);return Dd.createElement(g2,{ref:s,playerSoftwareName:b2,playerSoftwareVersion:E2,...r})}),T2=y2;const _2=Gc.object({time:Gc.number(),expiresAt:Gc.string()}).transform(i=>({time:Number(i.time),expiresAt:new Date(i.expiresAt)}));function A2(){var e;const i=v_("root");return((e=i==null?void 0:i.preferences)==null?void 0:e.player)??null}const S2=["input","select","button","textarea","mux-player","summary"];function nv(i){const e=pt.useRef(i);return pt.useEffect(()=>{e.current=i},[i]),e}function x2({muxPlayerRef:i,...e}){const t=A2(),s=g_(),[r,n]=pt.useState(!1),a=`${e.playbackId}:currentTime`,[o,l]=pt.useState(0),d=nv(s),c=nv(t);pt.useEffect(()=>{if(typeof document>"u")return;const h=sessionStorage.getItem(a);if(h)try{const{time:f,expiresAt:m}=_2.parse(JSON.parse(h));if(m.getTime()<Date.now())throw new Error("Time expired");l(f)}catch{sessionStorage.removeItem(a)}},[a]),pt.useEffect(()=>{function h(f){if(!i.current)return;const m=document.activeElement,p=m instanceof HTMLElement?m.contentEditable==="true":!1;m&&!S2.includes(m.tagName.toLowerCase())&&!p&&(f.key===" "&&(f.preventDefault(),i.current.paused?i.current.play():i.current.pause()),f.key==="ArrowRight"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime+(i.current.forwardSeekOffset||10)),f.key==="ArrowLeft"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime-(i.current.forwardSeekOffset||10)),f.key==="f"&&!f.metaKey&&!f.ctrlKey&&(f.preventDefault(),document.fullscreenElement?document.exitFullscreen():i.current.requestFullscreen()))}return window.document.addEventListener("keydown",h),()=>{window.document.removeEventListener("keydown",h)}},[i]);const u=f_(()=>{const h=i.current;if(!h)return;const f=Array.from(h.textTracks??[]).find(p=>p.kind==="subtitles"),m={playbackRate:h.playbackRate,volumeRate:h.volume,subtitle:f?{id:f.id,mode:f.mode}:{id:null,mode:"disabled"}};sm(m,c.current)||d.current.submit(m,{method:"POST",action:"/video-player",encType:"application/json"})},300);return pt.useEffect(()=>{var m,p;if(!r)return;const h=(m=i.current)==null?void 0:m.textTracks;if(!h)return;const f=(p=c.current)==null?void 0:p.subtitle;if(f!=null&&f.id){const g=h.getTrackById(f.id);g&&(g.mode=f.mode??"hidden")}return h.addEventListener("change",u),()=>{h.removeEventListener("change",u)}},[r,i,c,u]),W.jsx("div",{className:"flex aspect-video flex-col",children:W.jsx(T2,{ref:i,playbackRates:[.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4],volume:(t==null?void 0:t.volumeRate)??1,playbackRate:(t==null?void 0:t.playbackRate)??1,thumbnailTime:o,onRateChange:u,onVolumeChange:u,streamType:"on-demand",defaultHiddenCaptions:!0,currentTime:o,onTimeUpdate:()=>{var h;return sessionStorage.setItem(a,JSON.stringify({time:(h=i.current)==null?void 0:h.currentTime,expiresAt:new Date(Date.now()+1e3*60*30).toISOString()}))},accentColor:"#427cf0",targetLiveWindow:NaN,onLoadedMetadata:()=>n(!0),...e})})}function sm(i,e){if(i===e)return!0;if(typeof i!=typeof e||typeof i!="object"||typeof e!="object"||i===null||e===null||Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(!sm(i[r],e[r]))return!1;return!0}const t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(const r of t)if(!sm(i[r],e[r]))return!1;return!0}const i_=pt.createContext(null);function rO({children:i,epicVideoInfosPromise:e}){return W.jsx(i_.Provider,{value:e,children:i})}function s_(i){let e=new URL("https://epicweb.dev");try{e=new URL(i)}catch(u){return console.error(u),"EpicWeb.dev Video"}const t=e.pathname.split("/").filter(Boolean),s=t.includes("solution");let r=t.pop();const n=["problem","solution","embed","exercise"],a=u=>u&&!n.includes(u);for(;!a(r);)r=t.pop();if(!r)return"EpicWeb.dev Video";const o=r.split("-"),l=["the","a","an","and","but","or","for","nor","on","at","to","from","by","of","in","with","as","npm","git","ssh","cli"],d=["OAuth","UI","UX","API","CSS","HTML","JS","TS","SVG","AI","CSRF","CORS","HTTP","HTTPS","URL","URI","DB","SQL","JSON","YAML","YML","useActionData","useAsyncError","useAsyncValue","useBeforeUnload","useFetcher","useFetchers","useFormAction","useHref","useLoaderData","useLocation","useMatches","useNavigate","useNavigation","useNavigationType","useOutlet","useOutletContext","useParams","useResolvedPath","useRevalidator","useRouteError","useRouteLoaderData","useSearchParams","useSubmit","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition","useForm","useFieldset","useFieldList","useEventSource","useHydrated","useAuthenticityToken","useShouldHydrate","useGlobalNavigationState","useLocales","useDelegatedAnchors","useDebounceFetcher","useFetcherType"],c=o.filter(Boolean).map((u,h)=>{var p;const f=u.toLowerCase(),m=d.find(g=>g.toLowerCase()===f);return m||(l.includes(f)&&h>0?f:((p=f[0])==null?void 0:p.toUpperCase())+f.slice(1))}).join(" ");return s?`${c} (🏁 solution)`:c}function k2({url:i,title:e="Video Embed",loadingContent:t=W.jsx(rm,{children:W.jsxs("span",{children:['Loading "',e,'"']})})}){const[s,r]=pt.useState(!1);return W.jsxs("div",{className:"relative aspect-video w-full flex-shrink-0 shadow-lg dark:shadow-gray-800",children:[s?null:W.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t}),W.jsx("iframe",{onLoad:()=>r(!0),onError:()=>r(!0),src:i,className:m_("absolute inset-0 flex h-full w-full transition-opacity duration-300",s?"opacity-100":"opacity-0"),title:e,sandbox:"allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allowFullScreen:!0})]})}function r_({url:i,title:e}){return W.jsxs("a",{href:i,target:"_blank",className:"flex items-center gap-1 text-base no-underline opacity-70 transition hover:underline hover:opacity-100",rel:"noreferrer",children:[W.jsx(p_,{className:"flex-shrink-0",name:"Video",size:"lg"}),e," ",W.jsx("span",{"aria-hidden":!0,children:"↗︎"})]})}function nO({url:i,title:e=s_(i)}){const t=b_(),s=pt.useContext(i_),r=W.jsx("div",{children:W.jsx(r_,{url:i,title:e})});return W.jsx("div",{children:W.jsx(pt.Suspense,{fallback:W.jsxs("div",{children:[W.jsx("div",{className:"flex aspect-video w-full items-center justify-center",children:W.jsx(rm,{children:e})}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,W.jsx("div",{className:"h-[32px]"})]})]}),children:W.jsx(E_,{errorElement:W.jsx("div",{children:"Sorry, failed loading videos. Check the terminal output?"}),resolve:s,children:n=>{const a=n==null?void 0:n[i],o=ENV.EPICSHOP_DEPLOYED?W.jsxs("div",{children:[W.jsx(vo,{to:ENV.EPICSHOP_GITHUB_REPO,className:"underline",children:"Run locally"})," for transcripts"]}):W.jsxs("div",{children:[W.jsx(vo,{to:"/login",className:"underline",children:t?"Upgrade":"Login"})," for transcripts"]});if(!a)return W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,o]})]});const l=a;return l.status==="success"?W.jsx(L2,{url:i,title:e,muxPlaybackId:l.muxPlaybackId,transcript:l.transcript}):l.type==="region-restricted"?W.jsxs("div",{children:[W.jsxs("div",{className:"flex aspect-video min-h-full min-w-full flex-col items-center justify-start gap-2 overflow-y-scroll border-2 p-4 lg:justify-center lg:gap-4 lg:text-xl",children:[W.jsx("div",{className:"!text-foreground-danger",children:"Error: Region Restricted"}),W.jsxs("div",{children:["We've detected you're connecting from"," ",l.requestCountry," but your license has restricted access to ",l.restrictedCountry]}),W.jsxs("div",{children:["To continue watching uninterrupted, please"," ",W.jsx("a",{href:"https://www.epicweb.dev/products/full-stack-vol-1",className:"underline",children:"upgrade your EpicWeb.dev license"})," ","to a full Pro license."]})]}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,W.jsxs("div",{children:[W.jsx(vo,{to:"https://www.epicweb.dev/products",className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):l.statusCode===401?W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,o]})]}):l.statusCode===403?W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,W.jsxs("div",{children:[W.jsx(vo,{to:"https://www.epicweb.dev/products",className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):l.statusCode===404?W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,W.jsx("div",{children:"Transcripts not found"})]})]}):(console.error(l),W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[r,W.jsx("div",{className:"!text-foreground-danger",children:"Unknown error (check console)"})]})]}))}})})})}function L2({url:i,title:e=s_(i),muxPlaybackId:t,transcript:s}){const r=pt.useRef(null),n=/(\d+:\d+)/g,a=[];let o,l=0;for(;o=n.exec(s);){const d=o[1];if(!n.lastIndex||!d)break;const c=o.index,u=n.lastIndex,h=s.slice(l+1,c-1);a.push(W.jsx("span",{children:h},c)),a.push(W.jsx("button",{className:"underline",onClick:f=>{r.current&&(r.current.currentTime=I2(d),r.current.play(),r.current.scrollIntoView({behavior:"smooth",inline:"center",block:"start"}),f.currentTarget.blur())},children:d},d)),l=u}return a.push(W.jsx("span",{children:s.slice(l+1,s.length)},s.length)),W.jsxs("div",{children:[W.jsx("div",{className:"shadow-lg dark:shadow-gray-800",children:W.jsx(x2,{playbackId:t,muxPlayerRef:r,title:e})}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[W.jsx(r_,{url:i,title:e}),W.jsxs("details",{children:[W.jsx("summary",{children:"Transcript"}),W.jsx("div",{className:"whitespace-pre-line rounded-md bg-accent p-2 text-accent-foreground",children:a})]})]})]})}function I2(i){const e=i.split(":");let t=0,s=1;for(;e.length>0;)t+=s*parseInt(e.pop()??"0",10),s*=60;return t}function na({url:i,title:e}){const t=h_();let s=new URL("https://epicweb.dev");try{s=new URL(i)}catch(r){return console.error(r),W.jsxs("div",{children:['Invalid URL: "',i,'"']})}return s.pathname=s.pathname.endsWith("/")?`${s.pathname}embed`:`${s.pathname}/embed`,s.searchParams.set("theme",t),W.jsx(k2,{url:s.toString(),title:e,loadingContent:W.jsx(rm,{children:W.jsxs("span",{children:['Loading "',W.jsx("a",{className:"underline",href:i,children:e}),'"']})})})}export{nO as D,rO as E,k2 as V};
2988
- //# sourceMappingURL=epic-video-CxZy3iqK.js.map
2986
+ `,zf=As.createElement("template");"innerHTML"in zf&&(zf.innerHTML=qM);var zg,Xg,JT=class extends go{};JT.template=(Xg=(zg=zf.content)==null?void 0:zg.children)==null?void 0:Xg[0];lt.customElements.get("media-theme-gerwig")||lt.customElements.define("media-theme-gerwig",JT);var YM="gerwig",qi={SRC:"src",POSTER:"poster"},$={STYLE:"style",DEFAULT_HIDDEN_CAPTIONS:"default-hidden-captions",PRIMARY_COLOR:"primary-color",SECONDARY_COLOR:"secondary-color",ACCENT_COLOR:"accent-color",FORWARD_SEEK_OFFSET:"forward-seek-offset",BACKWARD_SEEK_OFFSET:"backward-seek-offset",PLAYBACK_TOKEN:"playback-token",THUMBNAIL_TOKEN:"thumbnail-token",STORYBOARD_TOKEN:"storyboard-token",STORYBOARD_SRC:"storyboard-src",THUMBNAIL_TIME:"thumbnail-time",AUDIO:"audio",NOHOTKEYS:"nohotkeys",HOTKEYS:"hotkeys",PLAYBACK_RATES:"playbackrates",DEFAULT_SHOW_REMAINING_TIME:"default-show-remaining-time",DEFAULT_DURATION:"default-duration",TITLE:"title",PLACEHOLDER:"placeholder",THEME:"theme",DEFAULT_STREAM_TYPE:"default-stream-type",TARGET_LIVE_WINDOW:"target-live-window",EXTRA_SOURCE_PARAMS:"extra-source-params",NO_VOLUME_PREF:"no-volume-pref"},Xf=["audio","backwardseekoffset","defaultduration","defaultshowremainingtime","defaultsubtitles","noautoseektolive","disabled","exportparts","forwardseekoffset","hideduration","hotkeys","nohotkeys","playbackrates","defaultstreamtype","streamtype","style","targetlivewindow","template","title","novolumepref"];function jM(i,e){var t;return{src:!i.playbackId&&i.src,playbackId:i.playbackId,hasSrc:!!i.playbackId||!!i.src,poster:i.poster,storyboard:i.storyboard,storyboardSrc:i.getAttribute($.STORYBOARD_SRC),placeholder:i.getAttribute("placeholder"),themeTemplate:zM(i),thumbnailTime:!i.tokens.thumbnail&&i.thumbnailTime,autoplay:i.autoplay,crossOrigin:i.crossOrigin,loop:i.loop,noHotKeys:i.hasAttribute($.NOHOTKEYS),hotKeys:i.getAttribute($.HOTKEYS),muted:i.muted,paused:i.paused,preload:i.preload,envKey:i.envKey,preferCmcd:i.preferCmcd,debug:i.debug,disableTracking:i.disableTracking,disableCookies:i.disableCookies,tokens:i.tokens,beaconCollectionDomain:i.beaconCollectionDomain,maxResolution:i.maxResolution,minResolution:i.minResolution,programStartTime:i.programStartTime,programEndTime:i.programEndTime,renditionOrder:i.renditionOrder,metadata:i.metadata,playerSoftwareName:i.playerSoftwareName,playerSoftwareVersion:i.playerSoftwareVersion,startTime:i.startTime,preferPlayback:i.preferPlayback,audio:i.audio,defaultStreamType:i.defaultStreamType,targetLiveWindow:i.getAttribute(P.TARGET_LIVE_WINDOW),streamType:_p(i.getAttribute(P.STREAM_TYPE)),primaryColor:i.getAttribute($.PRIMARY_COLOR),secondaryColor:i.getAttribute($.SECONDARY_COLOR),accentColor:i.getAttribute($.ACCENT_COLOR),forwardSeekOffset:i.forwardSeekOffset,backwardSeekOffset:i.backwardSeekOffset,defaultHiddenCaptions:i.defaultHiddenCaptions,defaultDuration:i.defaultDuration,defaultShowRemainingTime:i.defaultShowRemainingTime,hideDuration:XM(i),playbackRates:i.getAttribute($.PLAYBACK_RATES),customDomain:(t=i.getAttribute(P.CUSTOM_DOMAIN))!=null?t:void 0,title:i.getAttribute($.TITLE),novolumepref:i.hasAttribute($.NO_VOLUME_PREF),...e,extraSourceParams:i.extraSourceParams}}function zM(i){var e,t;let s=i.theme;if(s){let r=(t=(e=i.getRootNode())==null?void 0:e.getElementById)==null?void 0:t.call(e,s);if(r&&r instanceof HTMLTemplateElement)return r;s.startsWith("media-theme-")||(s=`media-theme-${s}`);let n=lt.customElements.get(s);if(n!=null&&n.template)return n.template}}function XM(i){var e;let t=(e=i.mediaController)==null?void 0:e.querySelector("media-time-display");return t&&getComputedStyle(t).getPropertyValue("--media-duration-display-display").trim()==="none"}function Qg(i){let e=i.hasAttribute($.TITLE)?{video_title:i.getAttribute($.TITLE)}:{};return i.getAttributeNames().filter(t=>t.startsWith("metadata-")).reduce((t,s)=>{let r=i.getAttribute(s);return r!==null&&(t[s.replace(/^metadata-/,"").replace(/-/g,"_")]=r),t},e)}var QM=Object.values(P),ZM=Object.values(qi),JM=Object.values($),e2=WT(),t2="mux-player",Zg={dialog:void 0,isDialogOpen:!1},i2={redundant_streams:!0},Rd,wd,Js,Cd,In,Yi,fs,Qf,e_,Ac,Zf,tr,hn,Jf,Jg,em,ev,tm,tv,im,iv,sv=class extends Vg{constructor(){super(),ht(this,Yi),ht(this,Qf),ht(this,Ac),ht(this,tr),ht(this,Jf),ht(this,em),ht(this,tm),ht(this,im),ht(this,Rd,!1),ht(this,wd,{}),ht(this,Js,!0),ht(this,Cd,new _M(this,"hotkeys")),ht(this,In,{...Zg,onCloseErrorDialog:()=>ze(this,Ac,Zf).call(this,{dialog:void 0,isDialogOpen:!1}),onInitFocusDialog:e=>{GT(this,As.activeElement)||e.preventDefault()}}),this.attachShadow({mode:"open"}),ze(this,Qf,e_).call(this),this.isConnected&&ze(this,Yi,fs).call(this)}static get observedAttributes(){var e;return[...(e=Vg.observedAttributes)!=null?e:[],...ZM,...QM,...JM]}get mediaTheme(){var e;return(e=this.shadowRoot)==null?void 0:e.querySelector("media-theme")}get mediaController(){var e,t;return(t=(e=this.mediaTheme)==null?void 0:e.shadowRoot)==null?void 0:t.querySelector("media-controller")}connectedCallback(){var e;let t=(e=this.shadowRoot)==null?void 0:e.querySelector("mux-video");t&&(t.metadata=Qg(this))}attributeChangedCallback(e,t,s){switch(ze(this,Yi,fs).call(this),super.attributeChangedCallback(e,t,s),e){case $.HOTKEYS:Te(this,Cd).value=s;break;case $.THUMBNAIL_TIME:{s!=null&&this.tokens.thumbnail&&cr(fe("Use of thumbnail-time with thumbnail-token is currently unsupported. Ignore thumbnail-time.").format({}));break}case $.THUMBNAIL_TOKEN:{let{aud:r}=lo(s);s&&r!=="t"&&cr(fe("The provided thumbnail-token should have audience value 't' instead of '{aud}'.").format({aud:r}));break}case $.STORYBOARD_TOKEN:{let{aud:r}=lo(s);s&&r!=="s"&&cr(fe("The provided storyboard-token should have audience value 's' instead of '{aud}'.").format({aud:r}));break}case P.PLAYBACK_ID:{s!=null&&s.includes("?token")&&ri(fe("The specificed playback ID {playbackId} contains a token which must be provided via the playback-token attribute.").format({playbackId:s}));break}case P.STREAM_TYPE:s&&![_e.LIVE,_e.ON_DEMAND,_e.UNKNOWN].includes(s)?["ll-live","live:dvr","ll-live:dvr"].includes(this.streamType)?this.targetLiveWindow=s.includes("dvr")?Number.POSITIVE_INFINITY:0:VT({file:"invalid-stream-type.md",message:fe("Invalid stream-type value supplied: `{streamType}`. Please provide stream-type as either: `on-demand` or `live`").format({streamType:this.streamType})}):s===_e.LIVE?this.getAttribute($.TARGET_LIVE_WINDOW)==null&&(this.targetLiveWindow=0):this.targetLiveWindow=Number.NaN}[P.PLAYBACK_ID,qi.SRC,$.PLAYBACK_TOKEN].includes(e)&&t!==s&&Zi(this,In,{...Te(this,In),...Zg}),ze(this,tr,hn).call(this,{[TM(e)]:s})}get preferCmcd(){var e;return(e=this.getAttribute(P.PREFER_CMCD))!=null?e:void 0}set preferCmcd(e){e!==this.preferCmcd&&(e?jd.includes(e)?this.setAttribute(P.PREFER_CMCD,e):cr(`Invalid value for preferCmcd. Must be one of ${jd.join()}`):this.removeAttribute(P.PREFER_CMCD))}get hasPlayed(){var e,t;return(t=(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_HAS_PLAYED))!=null?t:!1}get inLiveWindow(){var e;return(e=this.mediaController)==null?void 0:e.hasAttribute(T.MEDIA_TIME_IS_LIVE)}get _hls(){var e;return(e=this.media)==null?void 0:e._hls}get mux(){var e;return(e=this.media)==null?void 0:e.mux}get theme(){var e;return(e=this.getAttribute($.THEME))!=null?e:YM}set theme(e){this.setAttribute($.THEME,`${e}`)}get themeProps(){let e=this.mediaTheme;if(!e)return;let t={};for(let s of e.getAttributeNames()){if(Xf.includes(s))continue;let r=e.getAttribute(s);t[$T(s)]=r===""?!0:r}return t}set themeProps(e){var t,s;ze(this,Yi,fs).call(this);let r={...this.themeProps,...e};for(let n in r){if(Xf.includes(n))continue;let a=e==null?void 0:e[n];typeof a=="boolean"||a==null?(t=this.mediaTheme)==null||t.toggleAttribute(qf(n),!!a):(s=this.mediaTheme)==null||s.setAttribute(qf(n),a)}}get playbackId(){var e;return(e=this.getAttribute(P.PLAYBACK_ID))!=null?e:void 0}set playbackId(e){e?this.setAttribute(P.PLAYBACK_ID,e):this.removeAttribute(P.PLAYBACK_ID)}get src(){var e,t;return this.playbackId?(e=Ds(this,qi.SRC))!=null?e:void 0:(t=this.getAttribute(qi.SRC))!=null?t:void 0}set src(e){e?this.setAttribute(qi.SRC,e):this.removeAttribute(qi.SRC)}get poster(){var e;let t=this.getAttribute(qi.POSTER);if(t!=null)return t;if(this.playbackId&&!this.audio)return EM(this.playbackId,{customDomain:this.customDomain,thumbnailTime:(e=this.thumbnailTime)!=null?e:this.startTime,programTime:this.programStartTime,token:this.tokens.thumbnail})}set poster(e){e||e===""?this.setAttribute(qi.POSTER,e):this.removeAttribute(qi.POSTER)}get storyboardSrc(){var e;return(e=this.getAttribute($.STORYBOARD_SRC))!=null?e:void 0}set storyboardSrc(e){e?this.setAttribute($.STORYBOARD_SRC,e):this.removeAttribute($.STORYBOARD_SRC)}get storyboard(){if(this.storyboardSrc&&!this.tokens.storyboard)return this.storyboardSrc;if(!(this.audio||!this.playbackId||!this.streamType||[_e.LIVE,_e.UNKNOWN].includes(this.streamType)))return bM(this.playbackId,{customDomain:this.customDomain,token:this.tokens.storyboard,programStartTime:this.programStartTime,programEndTime:this.programEndTime})}get audio(){return this.hasAttribute($.AUDIO)}set audio(e){if(!e){this.removeAttribute($.AUDIO);return}this.setAttribute($.AUDIO,"")}get hotkeys(){return Te(this,Cd)}get nohotkeys(){return this.hasAttribute($.NOHOTKEYS)}set nohotkeys(e){if(!e){this.removeAttribute($.NOHOTKEYS);return}this.setAttribute($.NOHOTKEYS,"")}get thumbnailTime(){return xi(this.getAttribute($.THUMBNAIL_TIME))}set thumbnailTime(e){this.setAttribute($.THUMBNAIL_TIME,`${e}`)}get title(){var e;return(e=this.getAttribute($.TITLE))!=null?e:""}set title(e){e!==this.title&&(e?this.setAttribute($.TITLE,e):this.removeAttribute("title"),super.title=e)}get placeholder(){var e;return(e=Ds(this,$.PLACEHOLDER))!=null?e:""}set placeholder(e){this.setAttribute($.PLACEHOLDER,`${e}`)}get primaryColor(){var e,t;let s=this.getAttribute($.PRIMARY_COLOR);if(s!=null||this.mediaTheme&&(s=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_primary-color"))==null?void 0:t.trim(),s))return s}set primaryColor(e){this.setAttribute($.PRIMARY_COLOR,`${e}`)}get secondaryColor(){var e,t;let s=this.getAttribute($.SECONDARY_COLOR);if(s!=null||this.mediaTheme&&(s=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_secondary-color"))==null?void 0:t.trim(),s))return s}set secondaryColor(e){this.setAttribute($.SECONDARY_COLOR,`${e}`)}get accentColor(){var e,t;let s=this.getAttribute($.ACCENT_COLOR);if(s!=null||this.mediaTheme&&(s=(t=(e=lt.getComputedStyle(this.mediaTheme))==null?void 0:e.getPropertyValue("--_accent-color"))==null?void 0:t.trim(),s))return s}set accentColor(e){this.setAttribute($.ACCENT_COLOR,`${e}`)}get defaultShowRemainingTime(){return this.hasAttribute($.DEFAULT_SHOW_REMAINING_TIME)}set defaultShowRemainingTime(e){e?this.setAttribute($.DEFAULT_SHOW_REMAINING_TIME,""):this.removeAttribute($.DEFAULT_SHOW_REMAINING_TIME)}get playbackRates(){if(this.hasAttribute($.PLAYBACK_RATES))return this.getAttribute($.PLAYBACK_RATES).trim().split(/\s*,?\s+/).map(e=>Number(e)).filter(e=>!Number.isNaN(e)).sort((e,t)=>e-t)}set playbackRates(e){if(!e){this.removeAttribute($.PLAYBACK_RATES);return}this.setAttribute($.PLAYBACK_RATES,e.join(" "))}get forwardSeekOffset(){var e;return(e=xi(this.getAttribute($.FORWARD_SEEK_OFFSET)))!=null?e:10}set forwardSeekOffset(e){this.setAttribute($.FORWARD_SEEK_OFFSET,`${e}`)}get backwardSeekOffset(){var e;return(e=xi(this.getAttribute($.BACKWARD_SEEK_OFFSET)))!=null?e:10}set backwardSeekOffset(e){this.setAttribute($.BACKWARD_SEEK_OFFSET,`${e}`)}get defaultHiddenCaptions(){return this.hasAttribute($.DEFAULT_HIDDEN_CAPTIONS)}set defaultHiddenCaptions(e){e?this.setAttribute($.DEFAULT_HIDDEN_CAPTIONS,""):this.removeAttribute($.DEFAULT_HIDDEN_CAPTIONS)}get defaultDuration(){return xi(this.getAttribute($.DEFAULT_DURATION))}set defaultDuration(e){e==null?this.removeAttribute($.DEFAULT_DURATION):this.setAttribute($.DEFAULT_DURATION,`${e}`)}get playerSoftwareName(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_NAME))!=null?e:t2}get playerSoftwareVersion(){var e;return(e=this.getAttribute(P.PLAYER_SOFTWARE_VERSION))!=null?e:e2}get beaconCollectionDomain(){var e;return(e=this.getAttribute(P.BEACON_COLLECTION_DOMAIN))!=null?e:void 0}set beaconCollectionDomain(e){e!==this.beaconCollectionDomain&&(e?this.setAttribute(P.BEACON_COLLECTION_DOMAIN,e):this.removeAttribute(P.BEACON_COLLECTION_DOMAIN))}get maxResolution(){var e;return(e=this.getAttribute(P.MAX_RESOLUTION))!=null?e:void 0}set maxResolution(e){e!==this.maxResolution&&(e?this.setAttribute(P.MAX_RESOLUTION,e):this.removeAttribute(P.MAX_RESOLUTION))}get minResolution(){var e;return(e=this.getAttribute(P.MIN_RESOLUTION))!=null?e:void 0}set minResolution(e){e!==this.minResolution&&(e?this.setAttribute(P.MIN_RESOLUTION,e):this.removeAttribute(P.MIN_RESOLUTION))}get renditionOrder(){var e;return(e=this.getAttribute(P.RENDITION_ORDER))!=null?e:void 0}set renditionOrder(e){e!==this.renditionOrder&&(e?this.setAttribute(P.RENDITION_ORDER,e):this.removeAttribute(P.RENDITION_ORDER))}get programStartTime(){return xi(this.getAttribute(P.PROGRAM_START_TIME))}set programStartTime(e){e==null?this.removeAttribute(P.PROGRAM_START_TIME):this.setAttribute(P.PROGRAM_START_TIME,`${e}`)}get programEndTime(){return xi(this.getAttribute(P.PROGRAM_END_TIME))}set programEndTime(e){e==null?this.removeAttribute(P.PROGRAM_END_TIME):this.setAttribute(P.PROGRAM_END_TIME,`${e}`)}get extraSourceParams(){return this.hasAttribute($.EXTRA_SOURCE_PARAMS)?[...new URLSearchParams(this.getAttribute($.EXTRA_SOURCE_PARAMS)).entries()].reduce((e,[t,s])=>(e[t]=s,e),{}):i2}set extraSourceParams(e){e==null?this.removeAttribute($.EXTRA_SOURCE_PARAMS):this.setAttribute($.EXTRA_SOURCE_PARAMS,new URLSearchParams(e).toString())}get customDomain(){var e;return(e=this.getAttribute(P.CUSTOM_DOMAIN))!=null?e:void 0}set customDomain(e){e!==this.customDomain&&(e?this.setAttribute(P.CUSTOM_DOMAIN,e):this.removeAttribute(P.CUSTOM_DOMAIN))}get envKey(){var e;return(e=Ds(this,P.ENV_KEY))!=null?e:void 0}set envKey(e){this.setAttribute(P.ENV_KEY,`${e}`)}get noVolumePref(){return this.hasAttribute($.NO_VOLUME_PREF)}set noVolumePref(e){e?this.setAttribute($.NO_VOLUME_PREF,""):this.removeAttribute($.NO_VOLUME_PREF)}get debug(){return Ds(this,P.DEBUG)!=null}set debug(e){e?this.setAttribute(P.DEBUG,""):this.removeAttribute(P.DEBUG)}get disableTracking(){return Ds(this,P.DISABLE_TRACKING)!=null}set disableTracking(e){this.toggleAttribute(P.DISABLE_TRACKING,!!e)}get disableCookies(){return Ds(this,P.DISABLE_COOKIES)!=null}set disableCookies(e){e?this.setAttribute(P.DISABLE_COOKIES,""):this.removeAttribute(P.DISABLE_COOKIES)}get streamType(){var e,t,s;return(s=(t=this.getAttribute(P.STREAM_TYPE))!=null?t:(e=this.media)==null?void 0:e.streamType)!=null?s:_e.UNKNOWN}set streamType(e){this.setAttribute(P.STREAM_TYPE,`${e}`)}get defaultStreamType(){var e,t,s;return(s=(t=this.getAttribute($.DEFAULT_STREAM_TYPE))!=null?t:(e=this.mediaController)==null?void 0:e.getAttribute($.DEFAULT_STREAM_TYPE))!=null?s:_e.ON_DEMAND}set defaultStreamType(e){e?this.setAttribute($.DEFAULT_STREAM_TYPE,e):this.removeAttribute($.DEFAULT_STREAM_TYPE)}get targetLiveWindow(){var e,t;return this.hasAttribute($.TARGET_LIVE_WINDOW)?+this.getAttribute($.TARGET_LIVE_WINDOW):(t=(e=this.media)==null?void 0:e.targetLiveWindow)!=null?t:Number.NaN}set targetLiveWindow(e){e==this.targetLiveWindow||Number.isNaN(e)&&Number.isNaN(this.targetLiveWindow)||(e==null?this.removeAttribute($.TARGET_LIVE_WINDOW):this.setAttribute($.TARGET_LIVE_WINDOW,`${+e}`))}get liveEdgeStart(){var e;return(e=this.media)==null?void 0:e.liveEdgeStart}get startTime(){return xi(Ds(this,P.START_TIME))}set startTime(e){this.setAttribute(P.START_TIME,`${e}`)}get preferPlayback(){let e=this.getAttribute(P.PREFER_PLAYBACK);if(e===Ci.MSE||e===Ci.NATIVE)return e}set preferPlayback(e){e!==this.preferPlayback&&(e===Ci.MSE||e===Ci.NATIVE?this.setAttribute(P.PREFER_PLAYBACK,e):this.removeAttribute(P.PREFER_PLAYBACK))}get metadata(){var e;return(e=this.media)==null?void 0:e.metadata}set metadata(e){if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to set metadata. metadata will not be set.");return}this.media.metadata={...Qg(this),...e}}get _hlsConfig(){var e;return(e=this.media)==null?void 0:e._hlsConfig}set _hlsConfig(e){if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to set _hlsConfig. _hlsConfig will not be set.");return}this.media._hlsConfig=e}async addCuePoints(e){var t;if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to addCuePoints. cuePoints will not be added.");return}return(t=this.media)==null?void 0:t.addCuePoints(e)}get activeCuePoint(){var e;return(e=this.media)==null?void 0:e.activeCuePoint}get cuePoints(){var e,t;return(t=(e=this.media)==null?void 0:e.cuePoints)!=null?t:[]}addChapters(e){var t;if(ze(this,Yi,fs).call(this),!this.media){ri("underlying media element missing when trying to addChapters. chapters will not be added.");return}return(t=this.media)==null?void 0:t.addChapters(e)}get activeChapter(){var e;return(e=this.media)==null?void 0:e.activeChapter}get chapters(){var e,t;return(t=(e=this.media)==null?void 0:e.chapters)!=null?t:[]}getStartDate(){var e;return(e=this.media)==null?void 0:e.getStartDate()}get currentPdt(){var e;return(e=this.media)==null?void 0:e.currentPdt}get tokens(){let e=this.getAttribute($.PLAYBACK_TOKEN),t=this.getAttribute($.THUMBNAIL_TOKEN),s=this.getAttribute($.STORYBOARD_TOKEN);return{...Te(this,wd),...e!=null?{playback:e}:{},...t!=null?{thumbnail:t}:{},...s!=null?{storyboard:s}:{}}}set tokens(e){Zi(this,wd,e??{})}get playbackToken(){var e;return(e=this.getAttribute($.PLAYBACK_TOKEN))!=null?e:void 0}set playbackToken(e){this.setAttribute($.PLAYBACK_TOKEN,`${e}`)}get thumbnailToken(){var e;return(e=this.getAttribute($.THUMBNAIL_TOKEN))!=null?e:void 0}set thumbnailToken(e){this.setAttribute($.THUMBNAIL_TOKEN,`${e}`)}get storyboardToken(){var e;return(e=this.getAttribute($.STORYBOARD_TOKEN))!=null?e:void 0}set storyboardToken(e){this.setAttribute($.STORYBOARD_TOKEN,`${e}`)}addTextTrack(e,t,s,r){var n;let a=(n=this.media)==null?void 0:n.nativeEl;if(a)return Lm(a,e,t,s,r)}removeTextTrack(e){var t;let s=(t=this.media)==null?void 0:t.nativeEl;if(s)return dI(s,e)}get textTracks(){var e;return(e=this.media)==null?void 0:e.textTracks}};Rd=new WeakMap,wd=new WeakMap,Js=new WeakMap,Cd=new WeakMap,In=new WeakMap,Yi=new WeakSet,fs=function(){var i,e,t;if(!Te(this,Rd)){Zi(this,Rd,!0),ze(this,tr,hn).call(this);try{if(customElements.upgrade(this.mediaTheme),!(this.mediaTheme instanceof lt.HTMLElement))throw""}catch{ri("<media-theme> failed to upgrade!")}try{if(customElements.upgrade(this.media),!(this.media instanceof qD))throw""}catch{ri("<mux-video> failed to upgrade!")}try{if(customElements.upgrade(this.mediaController),!(this.mediaController instanceof OR))throw""}catch{ri("<media-controller> failed to upgrade!")}kM(this),ze(this,Jf,Jg).call(this),ze(this,em,ev).call(this),ze(this,tm,tv).call(this),Zi(this,Js,(e=(i=this.mediaController)==null?void 0:i.hasAttribute(ge.USER_INACTIVE))!=null?e:!0),ze(this,im,iv).call(this),(t=this.media)==null||t.addEventListener("streamtypechange",()=>{ze(this,tr,hn).call(this)})}},Qf=new WeakSet,e_=function(){var i,e;try{(i=window==null?void 0:window.CSS)==null||i.registerProperty({name:"--media-primary-color",syntax:"<color>",inherits:!0}),(e=window==null?void 0:window.CSS)==null||e.registerProperty({name:"--media-secondary-color",syntax:"<color>",inherits:!0})}catch{}},Ac=new WeakSet,Zf=function(i){Object.assign(Te(this,In),i),ze(this,tr,hn).call(this)},tr=new WeakSet,hn=function(i={}){BM(GM(jM(this,{...Te(this,In),...i})),this.shadowRoot)},Jf=new WeakSet,Jg=function(){let i=e=>{var t,s;if(!(e!=null&&e.startsWith("theme-")))return;let r=e.replace(/^theme-/,"");if(Xf.includes(r))return;let n=this.getAttribute(e);n!=null?(t=this.mediaTheme)==null||t.setAttribute(r,n):(s=this.mediaTheme)==null||s.removeAttribute(r)};new MutationObserver(e=>{for(let{attributeName:t}of e)i(t)}).observe(this,{attributes:!0}),this.getAttributeNames().forEach(i)},em=new WeakSet,ev=function(){var i;let e=t=>{let{detail:s}=t;if(s instanceof Ct||(s=new Ct(s.message,s.code,s.fatal)),!(s!=null&&s.fatal)){cr(s),s.data&&cr(`${s.name} data:`,s.data);return}let{dialog:r,devlog:n}=jf(s,!window.navigator.onLine,this.playbackId,this.playbackToken);n.message&&VT(n),ri(s),s.data&&ri(`${s.name} data:`,s.data),ze(this,Ac,Zf).call(this,{isDialogOpen:!0,dialog:r})};this.addEventListener("error",e),this.media&&(this.media.errorTranslator=(t={})=>{var s,r,n;if(!(((s=this.media)==null?void 0:s.error)instanceof Ct))return t;let{devlog:a}=jf((r=this.media)==null?void 0:r.error,!window.navigator.onLine,this.playbackId,this.playbackToken,!1);return{player_error_code:(n=this.media)==null?void 0:n.error.code,player_error_message:a.message?String(a.message):t.player_error_message,player_error_context:a.context?String(a.context):t.player_error_context}}),(i=this.media)==null||i.addEventListener("error",t=>{var s,r;let{detail:n}=t;if(!n){let{message:a,code:o}=(r=(s=this.media)==null?void 0:s.error)!=null?r:{};n=new Ct(a,o)}n!=null&&n.fatal&&this.dispatchEvent(new CustomEvent("error",{detail:n}))})},tm=new WeakSet,tv=function(){var i,e,t,s;let r=()=>ze(this,tr,hn).call(this);(e=(i=this.media)==null?void 0:i.textTracks)==null||e.addEventListener("addtrack",r),(s=(t=this.media)==null?void 0:t.textTracks)==null||s.addEventListener("removetrack",r)},im=new WeakSet,iv=function(){var i,e;if(!/Firefox/i.test(navigator.userAgent))return;let t,s=new WeakMap,r=()=>this.streamType===_e.LIVE&&!this.secondaryColor&&this.offsetWidth>=800,n=(l,d,c=!1)=>{r()||Array.from(l&&l.activeCues||[]).forEach(u=>{if(!(!u.snapToLines||u.line<-5||u.line>=0&&u.line<10))if(!d||this.paused){let h=u.text.split(`
2987
+ `).length,f=-3;this.streamType===_e.LIVE&&(f=-2);let m=f-h;if(u.line===m&&!c)return;s.has(u)||s.set(u,u.line),u.line=m}else setTimeout(()=>{u.line=s.get(u)||"auto"},500)})},a=()=>{var l,d;n(t,(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ge.USER_INACTIVE))!=null?d:!1)},o=()=>{var l,d;let c=Array.from(((d=(l=this.mediaController)==null?void 0:l.media)==null?void 0:d.textTracks)||[]).filter(u=>["subtitles","captions"].includes(u.kind)&&u.mode==="showing")[0];c!==t&&(t==null||t.removeEventListener("cuechange",a)),t=c,t==null||t.addEventListener("cuechange",a),n(t,Te(this,Js))};o(),(i=this.textTracks)==null||i.addEventListener("change",o),(e=this.textTracks)==null||e.addEventListener("addtrack",o),this.addEventListener("userinactivechange",()=>{var l,d;let c=(d=(l=this.mediaController)==null?void 0:l.hasAttribute(ge.USER_INACTIVE))!=null?d:!0;Te(this,Js)!==c&&(Zi(this,Js,c),n(t,Te(this,Js)))})};function Ds(i,e){return i.media?i.media.getAttribute(e):i.getAttribute(e)}lt.customElements.get("mux-player")||(lt.customElements.define("mux-player",sv),lt.MuxPlayerElement=sv);var rv={className:"class",classname:"class",htmlFor:"for",crossOrigin:"crossorigin",viewBox:"viewBox",playsInline:"playsinline",autoPlay:"autoplay",playbackRate:"playbackrate"},s2=i=>i==null,r2=(i,e)=>s2(e)?!1:i in e,n2=i=>i.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`),a2=(i,e)=>{if(!(typeof e=="boolean"&&!e)){if(r2(i,rv))return rv[i];if(typeof e!=null)return/[A-Z]/.test(i)?n2(i):i}},o2=(i,e)=>typeof i=="boolean"?"":i,l2=(i={})=>Object.entries(i).reduce((e,[t,s])=>{let r=a2(t,s);if(!r)return e;let n=o2(s);return e[r]=n,e},{}),d2=(...i)=>{let e=pt.useRef(null);return pt.useEffect(()=>{i.forEach(t=>{t&&(typeof t=="function"?t(e.current):t.current=e.current)})},[i]),e},c2=Object.prototype.hasOwnProperty,u2=(i,e)=>{if(Object.is(i,e))return!0;if(typeof i!="object"||i===null||typeof e!="object"||e===null)return!1;if(Array.isArray(i))return!Array.isArray(e)||i.length!==e.length?!1:i.some((r,n)=>e[n]===r);let t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(let r=0;r<t.length;r++)if(!c2.call(e,t[r])||!Object.is(i[t[r]],e[t[r]]))return!1;return!0},t_=(i,e,t)=>!u2(e,i[t]),h2=(i,e,t)=>{i[t]=e},f2=(i,e,t,s=h2,r=t_)=>pt.useEffect(()=>{let n=t==null?void 0:t.current;n&&r(n,e,i)&&s(n,e,i)},[t==null?void 0:t.current,e]),Wi=f2,m2=()=>{try{return"2.7.0"}catch{}return"UNKNOWN"},p2=m2(),g2=()=>p2,v2=Dd.forwardRef(({children:i,...e},t)=>Dd.createElement("mux-player",l2({...e,ref:t}),i)),ke=(i,e,t)=>pt.useEffect(()=>{let s=e==null?void 0:e.current;if(!(!s||!t))return s.addEventListener(i,t),()=>{s.removeEventListener(i,t)}},[e==null?void 0:e.current,t]),E2=(i,e)=>{let{onAbort:t,onCanPlay:s,onCanPlayThrough:r,onEmptied:n,onLoadStart:a,onLoadedData:o,onLoadedMetadata:l,onProgress:d,onDurationChange:c,onVolumeChange:u,onRateChange:h,onResize:f,onWaiting:m,onPlay:p,onPlaying:g,onTimeUpdate:v,onPause:y,onSeeking:b,onSeeked:x,onStalled:_,onSuspend:S,onEnded:A,onError:D,onCuePointChange:O,onCuePointsChange:L,onChapterChange:C,metadata:H,tokens:U,paused:Q,playbackId:q,playbackRates:Y,currentTime:oe,themeProps:ae,extraSourceParams:G,_hlsConfig:F,...re}=e;return Wi("playbackRates",Y,i),Wi("metadata",H,i),Wi("extraSourceParams",G,i),Wi("_hlsConfig",F,i),Wi("themeProps",ae,i),Wi("tokens",U,i),Wi("playbackId",q,i),Wi("paused",Q,i,(J,de)=>{de!=null&&(de?J.pause():J.play())},(J,de,Ae)=>J.hasAttribute("autoplay")&&!J.hasPlayed?!1:t_(J,de,Ae)),Wi("currentTime",oe,i,(J,de)=>{de!=null&&(J.currentTime=de)}),ke("abort",i,t),ke("canplay",i,s),ke("canplaythrough",i,r),ke("emptied",i,n),ke("loadstart",i,a),ke("loadeddata",i,o),ke("loadedmetadata",i,l),ke("progress",i,d),ke("durationchange",i,c),ke("volumechange",i,u),ke("ratechange",i,h),ke("resize",i,f),ke("waiting",i,m),ke("play",i,p),ke("playing",i,g),ke("timeupdate",i,v),ke("pause",i,y),ke("seeking",i,b),ke("seeked",i,x),ke("stalled",i,_),ke("suspend",i,S),ke("ended",i,A),ke("error",i,D),ke("cuepointchange",i,O),ke("cuepointschange",i,L),ke("chapterchange",i,C),[re]},b2=g2(),y2="mux-player-react",T2=Dd.forwardRef((i,e)=>{let t=pt.useRef(null),s=d2(t,e),[r]=E2(t,i);return Dd.createElement(v2,{ref:s,playerSoftwareName:y2,playerSoftwareVersion:b2,...r})}),_2=T2;const A2=Gc.object({time:Gc.number(),expiresAt:Gc.string()}).transform(i=>({time:Number(i.time),expiresAt:new Date(i.expiresAt)}));function S2(){var e;const i=v_("root");return((e=i==null?void 0:i.preferences)==null?void 0:e.player)??null}const x2=["input","select","button","textarea","mux-player","summary"];function nv(i){const e=pt.useRef(i);return pt.useEffect(()=>{e.current=i},[i]),e}function k2({muxPlayerRef:i,...e}){const t=S2(),s=g_(),[r,n]=pt.useState(!1),a=`${e.playbackId}:currentTime`,[o,l]=pt.useState(0),d=nv(s),c=nv(t);pt.useEffect(()=>{if(typeof document>"u")return;const h=sessionStorage.getItem(a);if(h)try{const{time:f,expiresAt:m}=A2.parse(JSON.parse(h));if(m.getTime()<Date.now())throw new Error("Time expired");l(f)}catch{sessionStorage.removeItem(a)}},[a]),pt.useEffect(()=>{function h(f){if(!i.current)return;const m=document.activeElement,p=m instanceof HTMLElement?m.contentEditable==="true":!1;m&&!x2.includes(m.tagName.toLowerCase())&&!p&&(f.key===" "&&(f.preventDefault(),i.current.paused?i.current.play():i.current.pause()),f.key==="ArrowRight"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime+(i.current.forwardSeekOffset||10)),f.key==="ArrowLeft"&&(f.preventDefault(),i.current.currentTime=i.current.currentTime-(i.current.forwardSeekOffset||10)),f.key==="f"&&!f.metaKey&&!f.ctrlKey&&(f.preventDefault(),document.fullscreenElement?document.exitFullscreen():i.current.requestFullscreen()))}return window.document.addEventListener("keydown",h),()=>{window.document.removeEventListener("keydown",h)}},[i]);const u=f_(()=>{const h=i.current;if(!h)return;const f=Array.from(h.textTracks??[]).find(p=>p.kind==="subtitles"),m={playbackRate:h.playbackRate,volumeRate:h.volume,subtitle:f?{id:f.id,mode:f.mode}:{id:null,mode:"disabled"}};sm(m,c.current)||d.current.submit(m,{method:"POST",action:"/video-player",encType:"application/json"})},300);return pt.useEffect(()=>{var m,p;if(!r)return;const h=(m=i.current)==null?void 0:m.textTracks;if(!h)return;const f=(p=c.current)==null?void 0:p.subtitle;if(f!=null&&f.id){const g=h.getTrackById(f.id);g&&(g.mode=f.mode??"hidden")}return h.addEventListener("change",u),()=>{h.removeEventListener("change",u)}},[r,i,c,u]),W.jsx("div",{className:"flex aspect-video flex-col",children:W.jsx(_2,{ref:i,playbackRates:[.5,.75,1,1.25,1.5,1.75,2,2.5,3,3.5,4],volume:(t==null?void 0:t.volumeRate)??1,playbackRate:(t==null?void 0:t.playbackRate)??1,thumbnailTime:o,onRateChange:u,onVolumeChange:u,streamType:"on-demand",defaultHiddenCaptions:!0,currentTime:o,onTimeUpdate:()=>{var h;return sessionStorage.setItem(a,JSON.stringify({time:(h=i.current)==null?void 0:h.currentTime,expiresAt:new Date(Date.now()+1e3*60*30).toISOString()}))},accentColor:"#427cf0",targetLiveWindow:NaN,onLoadedMetadata:()=>n(!0),...e})})}function sm(i,e){if(i===e)return!0;if(typeof i!=typeof e||typeof i!="object"||typeof e!="object"||i===null||e===null||Array.isArray(i)!==Array.isArray(e))return!1;if(Array.isArray(i)&&Array.isArray(e)){if(i.length!==e.length)return!1;for(let r=0;r<i.length;r++)if(!sm(i[r],e[r]))return!1;return!0}const t=Object.keys(i),s=Object.keys(e);if(t.length!==s.length)return!1;for(const r of t)if(!sm(i[r],e[r]))return!1;return!0}const i_=pt.createContext(null);function aO({children:i,epicVideoInfosPromise:e}){return W.jsx(i_.Provider,{value:e,children:i})}function s_(i){let e=new URL("https://epicweb.dev");try{e=new URL(i)}catch(u){return console.error(u),"EpicWeb.dev Video"}const t=e.pathname.split("/").filter(Boolean),s=t.includes("solution");let r=t.pop();const n=["problem","solution","embed","exercise"],a=u=>u&&!n.includes(u);for(;!a(r);)r=t.pop();if(!r)return"EpicWeb.dev Video";const o=r.split("-"),l=["the","a","an","and","but","or","for","nor","on","at","to","from","by","of","in","with","as","npm","git","ssh","cli"],d=["OAuth","UI","UX","API","CSS","HTML","JS","TS","SVG","AI","CSRF","CORS","HTTP","HTTPS","URL","URI","DB","SQL","JSON","YAML","YML","useActionData","useAsyncError","useAsyncValue","useBeforeUnload","useFetcher","useFetchers","useFormAction","useHref","useLoaderData","useLocation","useMatches","useNavigate","useNavigation","useNavigationType","useOutlet","useOutletContext","useParams","useResolvedPath","useRevalidator","useRouteError","useRouteLoaderData","useSearchParams","useSubmit","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition","useForm","useFieldset","useFieldList","useEventSource","useHydrated","useAuthenticityToken","useShouldHydrate","useGlobalNavigationState","useLocales","useDelegatedAnchors","useDebounceFetcher","useFetcherType"],c=o.filter(Boolean).map((u,h)=>{var p;const f=u.toLowerCase(),m=d.find(g=>g.toLowerCase()===f);return m||(l.includes(f)&&h>0?f:((p=f[0])==null?void 0:p.toUpperCase())+f.slice(1))}).join(" ");return s?`${c} (🏁 solution)`:c}function L2({url:i,title:e="Video Embed",loadingContent:t=W.jsx(rm,{children:W.jsxs("span",{children:['Loading "',e,'"']})})}){const[s,r]=pt.useState(!1);return W.jsxs("div",{className:"relative aspect-video w-full flex-shrink-0 shadow-lg dark:shadow-gray-800",children:[s?null:W.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center",children:t}),W.jsx("iframe",{onLoad:()=>r(!0),onError:()=>r(!0),src:i,className:m_("absolute inset-0 flex h-full w-full transition-opacity duration-300",s?"opacity-100":"opacity-0"),title:e,sandbox:"allow-forms allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox",allowFullScreen:!0})]})}function r_({url:i,title:e}){return W.jsxs("a",{href:i,target:"_blank",className:"flex items-center gap-1 text-base no-underline opacity-70 transition hover:underline hover:opacity-100",rel:"noreferrer",children:[W.jsx(p_,{className:"flex-shrink-0",name:"Video",size:"lg"}),e," ",W.jsx("span",{"aria-hidden":!0,children:"↗︎"})]})}function oO({url:i,title:e=s_(i)}){const{product:{host:t,displayName:s}}=y_(),r=b_(),n=pt.useContext(i_),a=W.jsx("div",{children:W.jsx(r_,{url:i,title:e})});return W.jsx("div",{children:W.jsx(pt.Suspense,{fallback:W.jsxs("div",{children:[W.jsx("div",{className:"flex aspect-video w-full items-center justify-center",children:W.jsx(rm,{children:e})}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,W.jsx("div",{className:"h-[32px]"})]})]}),children:W.jsx(E_,{errorElement:W.jsx("div",{children:"Sorry, failed loading videos. Check the terminal output?"}),resolve:n,children:o=>{const l=o==null?void 0:o[i],d=ENV.EPICSHOP_DEPLOYED?W.jsxs("div",{children:[W.jsx(vo,{to:ENV.EPICSHOP_GITHUB_REPO,className:"underline",children:"Run locally"})," for transcripts"]}):W.jsxs("div",{children:[W.jsx(vo,{to:"/login",className:"underline",children:r?"Upgrade":"Login"})," for transcripts"]});if(!l)return W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,d]})]});const c=l;return c.status==="success"?W.jsx(I2,{url:i,title:e,muxPlaybackId:c.muxPlaybackId,transcript:c.transcript}):c.type==="region-restricted"?W.jsxs("div",{children:[W.jsxs("div",{className:"flex aspect-video min-h-full min-w-full flex-col items-center justify-start gap-2 overflow-y-scroll border-2 p-4 lg:justify-center lg:gap-4 lg:text-xl",children:[W.jsx("div",{className:"!text-foreground-danger",children:"Error: Region Restricted"}),W.jsxs("div",{children:["We've detected you're connecting from"," ",c.requestCountry," but your license has restricted access to ",c.restrictedCountry]}),W.jsxs("div",{children:["To continue watching uninterrupted, please"," ",W.jsxs("a",{href:`https://${t}/products`,className:"underline",children:["upgrade your ",s," license"]})," ","to a full Pro license."]})]}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,W.jsxs("div",{children:[W.jsx(vo,{to:`https://${t}/products`,className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):c.statusCode===401?W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,d]})]}):c.statusCode===403?W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,W.jsxs("div",{children:[W.jsx(vo,{to:`https://${t}/products`,className:"underline",children:"Upgrade"})," for transcripts"]})]})]}):c.statusCode===404?W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,W.jsx("div",{children:"Transcripts not found"})]})]}):(console.error(c),W.jsxs("div",{children:[W.jsx(na,{url:i,title:e}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[a,W.jsx("div",{className:"!text-foreground-danger",children:"Unknown error (check console)"})]})]}))}})})})}function I2({url:i,title:e=s_(i),muxPlaybackId:t,transcript:s}){const r=pt.useRef(null),n=/(\d+:\d+)/g,a=[];let o,l=0;for(;o=n.exec(s);){const d=o[1];if(!n.lastIndex||!d)break;const c=o.index,u=n.lastIndex,h=s.slice(l+1,c-1);a.push(W.jsx("span",{children:h},c)),a.push(W.jsx("button",{className:"underline",onClick:f=>{r.current&&(r.current.currentTime=R2(d),r.current.play(),r.current.scrollIntoView({behavior:"smooth",inline:"center",block:"start"}),f.currentTarget.blur())},children:d},d)),l=u}return a.push(W.jsx("span",{children:s.slice(l+1,s.length)},s.length)),W.jsxs("div",{children:[W.jsx("div",{className:"shadow-lg dark:shadow-gray-800",children:W.jsx(k2,{playbackId:t,muxPlayerRef:r,title:e})}),W.jsxs("div",{className:"mt-4 flex flex-col gap-2",children:[W.jsx(r_,{url:i,title:e}),W.jsxs("details",{children:[W.jsx("summary",{children:"Transcript"}),W.jsx("div",{className:"whitespace-pre-line rounded-md bg-accent p-2 text-accent-foreground",children:a})]})]})]})}function R2(i){const e=i.split(":");let t=0,s=1;for(;e.length>0;)t+=s*parseInt(e.pop()??"0",10),s*=60;return t}function na({url:i,title:e}){const t=h_();let s=new URL("https://epicweb.dev");try{s=new URL(i)}catch(r){return console.error(r),W.jsxs("div",{children:['Invalid URL: "',i,'"']})}return s.pathname=s.pathname.endsWith("/")?`${s.pathname}embed`:`${s.pathname}/embed`,s.searchParams.set("theme",t),W.jsx(L2,{url:s.toString(),title:e,loadingContent:W.jsx(rm,{children:W.jsxs("span",{children:['Loading "',W.jsx("a",{className:"underline",href:i,children:e}),'"']})})})}export{oO as D,aO as E,L2 as V};
2988
+ //# sourceMappingURL=epic-video-D8tfMIv8.js.map