@tarojs/components 3.6.5-canary.1 → 3.7.0-alpha.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 (460) hide show
  1. package/dist/cjs/{hls-0f2d4d85.js → hls-67cbc62d.js} +10270 -9325
  2. package/dist/cjs/{index-067a58c1.js → index-f9d21cc5.js} +10 -11
  3. package/dist/cjs/loader.cjs.js +2 -2
  4. package/dist/cjs/taro-ad-core.cjs.entry.js +1 -1
  5. package/dist/cjs/taro-ad-custom-core.cjs.entry.js +1 -1
  6. package/dist/cjs/taro-animation-video-core.cjs.entry.js +1 -1
  7. package/dist/cjs/taro-animation-view-core.cjs.entry.js +1 -1
  8. package/dist/cjs/taro-ar-camera-core.cjs.entry.js +1 -1
  9. package/dist/cjs/taro-audio-core.cjs.entry.js +1 -1
  10. package/dist/cjs/taro-aweme-data-core.cjs.entry.js +1 -1
  11. package/dist/cjs/taro-block-core.cjs.entry.js +1 -1
  12. package/dist/cjs/taro-button-core.cjs.entry.js +2 -2
  13. package/dist/cjs/taro-camera-core.cjs.entry.js +1 -1
  14. package/dist/cjs/taro-canvas-core.cjs.entry.js +1 -1
  15. package/dist/cjs/taro-channel-live-core.cjs.entry.js +1 -1
  16. package/dist/cjs/taro-channel-video-core.cjs.entry.js +1 -1
  17. package/dist/cjs/taro-checkbox-core_2.cjs.entry.js +1 -1
  18. package/dist/cjs/taro-comment-detail-core.cjs.entry.js +1 -1
  19. package/dist/cjs/taro-comment-list-core.cjs.entry.js +1 -1
  20. package/dist/cjs/taro-components.cjs.js +2 -2
  21. package/dist/cjs/taro-contact-button-core.cjs.entry.js +1 -1
  22. package/dist/cjs/taro-cover-image-core.cjs.entry.js +1 -1
  23. package/dist/cjs/taro-cover-view-core.cjs.entry.js +2 -2
  24. package/dist/cjs/taro-custom-wrapper-core.cjs.entry.js +1 -1
  25. package/dist/cjs/taro-editor-core.cjs.entry.js +1 -1
  26. package/dist/cjs/taro-follow-swan-core.cjs.entry.js +1 -1
  27. package/dist/cjs/taro-form-core.cjs.entry.js +1 -1
  28. package/dist/cjs/taro-functional-page-navigator-core.cjs.entry.js +1 -1
  29. package/dist/cjs/taro-grid-view-core.cjs.entry.js +1 -1
  30. package/dist/cjs/taro-icon-core.cjs.entry.js +2 -2
  31. package/dist/cjs/taro-image-core.cjs.entry.js +2 -2
  32. package/dist/cjs/taro-inline-payment-panel-core.cjs.entry.js +1 -1
  33. package/dist/cjs/taro-input-core.cjs.entry.js +1 -1
  34. package/dist/cjs/taro-keyboard-accessory-core.cjs.entry.js +1 -1
  35. package/dist/cjs/taro-label-core.cjs.entry.js +1 -1
  36. package/dist/cjs/taro-lifestyle-core.cjs.entry.js +1 -1
  37. package/dist/cjs/taro-like-core.cjs.entry.js +1 -1
  38. package/dist/cjs/taro-list-view-core.cjs.entry.js +1 -1
  39. package/dist/cjs/taro-live-player-core.cjs.entry.js +1 -1
  40. package/dist/cjs/taro-live-pusher-core.cjs.entry.js +1 -1
  41. package/dist/cjs/taro-login-core.cjs.entry.js +1 -1
  42. package/dist/cjs/taro-lottie-core.cjs.entry.js +1 -1
  43. package/dist/cjs/taro-map-core.cjs.entry.js +1 -1
  44. package/dist/cjs/taro-match-media-core.cjs.entry.js +1 -1
  45. package/dist/cjs/taro-movable-area-core_2.cjs.entry.js +1 -1
  46. package/dist/cjs/taro-native-slot-core.cjs.entry.js +1 -1
  47. package/dist/cjs/taro-navigation-bar-core.cjs.entry.js +1 -1
  48. package/dist/cjs/taro-navigator-core.cjs.entry.js +2 -2
  49. package/dist/cjs/taro-official-account-core.cjs.entry.js +1 -1
  50. package/dist/cjs/taro-open-data-core.cjs.entry.js +1 -1
  51. package/dist/cjs/taro-page-container-core.cjs.entry.js +1 -1
  52. package/dist/cjs/taro-page-meta-core.cjs.entry.js +1 -1
  53. package/dist/cjs/taro-picker-core_2.cjs.entry.js +2 -2
  54. package/dist/cjs/taro-picker-view-column-core_2.cjs.entry.js +2 -2
  55. package/dist/cjs/taro-progress-core.cjs.entry.js +1 -1
  56. package/dist/cjs/taro-pull-to-refresh.cjs.entry.js +2 -2
  57. package/dist/cjs/taro-radio-core_2.cjs.entry.js +1 -1
  58. package/dist/cjs/taro-rich-text-core.cjs.entry.js +1 -1
  59. package/dist/cjs/taro-root-portal-core.cjs.entry.js +1 -1
  60. package/dist/cjs/taro-rtc-room-core.cjs.entry.js +1 -1
  61. package/dist/cjs/taro-rtc-room-item-core.cjs.entry.js +1 -1
  62. package/dist/cjs/taro-scroll-view-core.cjs.entry.js +2 -2
  63. package/dist/cjs/taro-share-element-core.cjs.entry.js +1 -1
  64. package/dist/cjs/taro-slider-core.cjs.entry.js +1 -1
  65. package/dist/cjs/taro-slot-core.cjs.entry.js +1 -1
  66. package/dist/cjs/taro-sticky-header-core.cjs.entry.js +1 -1
  67. package/dist/cjs/taro-sticky-section-core.cjs.entry.js +1 -1
  68. package/dist/cjs/taro-swiper-core_2.cjs.entry.js +16 -5
  69. package/dist/cjs/taro-switch-core.cjs.entry.js +1 -1
  70. package/dist/cjs/taro-tab-item-core.cjs.entry.js +1 -1
  71. package/dist/cjs/taro-tabbar.cjs.entry.js +2 -2
  72. package/dist/cjs/taro-tabs-core.cjs.entry.js +1 -1
  73. package/dist/cjs/taro-text-core.cjs.entry.js +2 -2
  74. package/dist/cjs/taro-textarea-core.cjs.entry.js +15 -2
  75. package/dist/cjs/taro-video-control_3.cjs.entry.js +3 -3
  76. package/dist/cjs/taro-view-core.cjs.entry.js +2 -2
  77. package/dist/cjs/taro-voip-room-core.cjs.entry.js +1 -1
  78. package/dist/cjs/taro-web-view-core.cjs.entry.js +1 -1
  79. package/dist/collection/collection-manifest.json +1 -1
  80. package/dist/collection/components/swiper/swiper.js +14 -3
  81. package/dist/collection/components/textarea/textarea.js +42 -1
  82. package/dist/components/hls.js +10269 -9324
  83. package/dist/components/index2.js +10 -11
  84. package/dist/components/taro-swiper-core.js +14 -3
  85. package/dist/components/taro-textarea-core.js +14 -1
  86. package/dist/esm/{hls-0e83e558.js → hls-221423a1.js} +10270 -9325
  87. package/dist/esm/{index-394db4c1.js → index-1d8e8acd.js} +10 -11
  88. package/dist/esm/loader.js +3 -3
  89. package/dist/esm/taro-ad-core.entry.js +1 -1
  90. package/dist/esm/taro-ad-custom-core.entry.js +1 -1
  91. package/dist/esm/taro-animation-video-core.entry.js +1 -1
  92. package/dist/esm/taro-animation-view-core.entry.js +1 -1
  93. package/dist/esm/taro-ar-camera-core.entry.js +1 -1
  94. package/dist/esm/taro-audio-core.entry.js +1 -1
  95. package/dist/esm/taro-aweme-data-core.entry.js +1 -1
  96. package/dist/esm/taro-block-core.entry.js +1 -1
  97. package/dist/esm/taro-button-core.entry.js +2 -2
  98. package/dist/esm/taro-camera-core.entry.js +1 -1
  99. package/dist/esm/taro-canvas-core.entry.js +1 -1
  100. package/dist/esm/taro-channel-live-core.entry.js +1 -1
  101. package/dist/esm/taro-channel-video-core.entry.js +1 -1
  102. package/dist/esm/taro-checkbox-core_2.entry.js +1 -1
  103. package/dist/esm/taro-comment-detail-core.entry.js +1 -1
  104. package/dist/esm/taro-comment-list-core.entry.js +1 -1
  105. package/dist/esm/taro-components.js +3 -3
  106. package/dist/esm/taro-contact-button-core.entry.js +1 -1
  107. package/dist/esm/taro-cover-image-core.entry.js +1 -1
  108. package/dist/esm/taro-cover-view-core.entry.js +2 -2
  109. package/dist/esm/taro-custom-wrapper-core.entry.js +1 -1
  110. package/dist/esm/taro-editor-core.entry.js +1 -1
  111. package/dist/esm/taro-follow-swan-core.entry.js +1 -1
  112. package/dist/esm/taro-form-core.entry.js +1 -1
  113. package/dist/esm/taro-functional-page-navigator-core.entry.js +1 -1
  114. package/dist/esm/taro-grid-view-core.entry.js +1 -1
  115. package/dist/esm/taro-icon-core.entry.js +2 -2
  116. package/dist/esm/taro-image-core.entry.js +2 -2
  117. package/dist/esm/taro-inline-payment-panel-core.entry.js +1 -1
  118. package/dist/esm/taro-input-core.entry.js +1 -1
  119. package/dist/esm/taro-keyboard-accessory-core.entry.js +1 -1
  120. package/dist/esm/taro-label-core.entry.js +1 -1
  121. package/dist/esm/taro-lifestyle-core.entry.js +1 -1
  122. package/dist/esm/taro-like-core.entry.js +1 -1
  123. package/dist/esm/taro-list-view-core.entry.js +1 -1
  124. package/dist/esm/taro-live-player-core.entry.js +1 -1
  125. package/dist/esm/taro-live-pusher-core.entry.js +1 -1
  126. package/dist/esm/taro-login-core.entry.js +1 -1
  127. package/dist/esm/taro-lottie-core.entry.js +1 -1
  128. package/dist/esm/taro-map-core.entry.js +1 -1
  129. package/dist/esm/taro-match-media-core.entry.js +1 -1
  130. package/dist/esm/taro-movable-area-core_2.entry.js +1 -1
  131. package/dist/esm/taro-native-slot-core.entry.js +1 -1
  132. package/dist/esm/taro-navigation-bar-core.entry.js +1 -1
  133. package/dist/esm/taro-navigator-core.entry.js +2 -2
  134. package/dist/esm/taro-official-account-core.entry.js +1 -1
  135. package/dist/esm/taro-open-data-core.entry.js +1 -1
  136. package/dist/esm/taro-page-container-core.entry.js +1 -1
  137. package/dist/esm/taro-page-meta-core.entry.js +1 -1
  138. package/dist/esm/taro-picker-core_2.entry.js +2 -2
  139. package/dist/esm/taro-picker-view-column-core_2.entry.js +2 -2
  140. package/dist/esm/taro-progress-core.entry.js +1 -1
  141. package/dist/esm/taro-pull-to-refresh.entry.js +2 -2
  142. package/dist/esm/taro-radio-core_2.entry.js +1 -1
  143. package/dist/esm/taro-rich-text-core.entry.js +1 -1
  144. package/dist/esm/taro-root-portal-core.entry.js +1 -1
  145. package/dist/esm/taro-rtc-room-core.entry.js +1 -1
  146. package/dist/esm/taro-rtc-room-item-core.entry.js +1 -1
  147. package/dist/esm/taro-scroll-view-core.entry.js +2 -2
  148. package/dist/esm/taro-share-element-core.entry.js +1 -1
  149. package/dist/esm/taro-slider-core.entry.js +1 -1
  150. package/dist/esm/taro-slot-core.entry.js +1 -1
  151. package/dist/esm/taro-sticky-header-core.entry.js +1 -1
  152. package/dist/esm/taro-sticky-section-core.entry.js +1 -1
  153. package/dist/esm/taro-swiper-core_2.entry.js +16 -5
  154. package/dist/esm/taro-switch-core.entry.js +1 -1
  155. package/dist/esm/taro-tab-item-core.entry.js +1 -1
  156. package/dist/esm/taro-tabbar.entry.js +2 -2
  157. package/dist/esm/taro-tabs-core.entry.js +1 -1
  158. package/dist/esm/taro-text-core.entry.js +2 -2
  159. package/dist/esm/taro-textarea-core.entry.js +15 -2
  160. package/dist/esm/taro-video-control_3.entry.js +3 -3
  161. package/dist/esm/taro-view-core.entry.js +2 -2
  162. package/dist/esm/taro-voip-room-core.entry.js +1 -1
  163. package/dist/esm/taro-web-view-core.entry.js +1 -1
  164. package/dist/esm-es5/hls-221423a1.js +365 -0
  165. package/dist/esm-es5/index-1d8e8acd.js +7 -0
  166. package/dist/esm-es5/loader.js +1 -1
  167. package/dist/esm-es5/taro-ad-core.entry.js +1 -1
  168. package/dist/esm-es5/taro-ad-custom-core.entry.js +1 -1
  169. package/dist/esm-es5/taro-animation-video-core.entry.js +1 -1
  170. package/dist/esm-es5/taro-animation-view-core.entry.js +1 -1
  171. package/dist/esm-es5/taro-ar-camera-core.entry.js +1 -1
  172. package/dist/esm-es5/taro-audio-core.entry.js +1 -1
  173. package/dist/esm-es5/taro-aweme-data-core.entry.js +1 -1
  174. package/dist/esm-es5/taro-block-core.entry.js +1 -1
  175. package/dist/esm-es5/taro-button-core.entry.js +1 -1
  176. package/dist/esm-es5/taro-camera-core.entry.js +1 -1
  177. package/dist/esm-es5/taro-canvas-core.entry.js +1 -1
  178. package/dist/esm-es5/taro-channel-live-core.entry.js +1 -1
  179. package/dist/esm-es5/taro-channel-video-core.entry.js +1 -1
  180. package/dist/esm-es5/taro-checkbox-core_2.entry.js +1 -1
  181. package/dist/esm-es5/taro-comment-detail-core.entry.js +1 -1
  182. package/dist/esm-es5/taro-comment-list-core.entry.js +1 -1
  183. package/dist/esm-es5/taro-components.js +1 -1
  184. package/dist/esm-es5/taro-contact-button-core.entry.js +1 -1
  185. package/dist/esm-es5/taro-cover-image-core.entry.js +1 -1
  186. package/dist/esm-es5/taro-cover-view-core.entry.js +1 -1
  187. package/dist/esm-es5/taro-custom-wrapper-core.entry.js +1 -1
  188. package/dist/esm-es5/taro-editor-core.entry.js +1 -1
  189. package/dist/esm-es5/taro-follow-swan-core.entry.js +1 -1
  190. package/dist/esm-es5/taro-form-core.entry.js +1 -1
  191. package/dist/esm-es5/taro-functional-page-navigator-core.entry.js +1 -1
  192. package/dist/esm-es5/taro-grid-view-core.entry.js +1 -1
  193. package/dist/esm-es5/taro-icon-core.entry.js +1 -1
  194. package/dist/esm-es5/taro-image-core.entry.js +1 -1
  195. package/dist/esm-es5/taro-inline-payment-panel-core.entry.js +1 -1
  196. package/dist/esm-es5/taro-input-core.entry.js +1 -1
  197. package/dist/esm-es5/taro-keyboard-accessory-core.entry.js +1 -1
  198. package/dist/esm-es5/taro-label-core.entry.js +1 -1
  199. package/dist/esm-es5/taro-lifestyle-core.entry.js +1 -1
  200. package/dist/esm-es5/taro-like-core.entry.js +1 -1
  201. package/dist/esm-es5/taro-list-view-core.entry.js +1 -1
  202. package/dist/esm-es5/taro-live-player-core.entry.js +1 -1
  203. package/dist/esm-es5/taro-live-pusher-core.entry.js +1 -1
  204. package/dist/esm-es5/taro-login-core.entry.js +1 -1
  205. package/dist/esm-es5/taro-lottie-core.entry.js +1 -1
  206. package/dist/esm-es5/taro-map-core.entry.js +1 -1
  207. package/dist/esm-es5/taro-match-media-core.entry.js +1 -1
  208. package/dist/esm-es5/taro-movable-area-core_2.entry.js +1 -1
  209. package/dist/esm-es5/taro-native-slot-core.entry.js +1 -1
  210. package/dist/esm-es5/taro-navigation-bar-core.entry.js +1 -1
  211. package/dist/esm-es5/taro-navigator-core.entry.js +1 -1
  212. package/dist/esm-es5/taro-official-account-core.entry.js +1 -1
  213. package/dist/esm-es5/taro-open-data-core.entry.js +1 -1
  214. package/dist/esm-es5/taro-page-container-core.entry.js +1 -1
  215. package/dist/esm-es5/taro-page-meta-core.entry.js +1 -1
  216. package/dist/esm-es5/taro-picker-core_2.entry.js +1 -1
  217. package/dist/esm-es5/taro-picker-view-column-core_2.entry.js +1 -1
  218. package/dist/esm-es5/taro-progress-core.entry.js +1 -1
  219. package/dist/esm-es5/taro-pull-to-refresh.entry.js +1 -1
  220. package/dist/esm-es5/taro-radio-core_2.entry.js +1 -1
  221. package/dist/esm-es5/taro-rich-text-core.entry.js +1 -1
  222. package/dist/esm-es5/taro-root-portal-core.entry.js +1 -1
  223. package/dist/esm-es5/taro-rtc-room-core.entry.js +1 -1
  224. package/dist/esm-es5/taro-rtc-room-item-core.entry.js +1 -1
  225. package/dist/esm-es5/taro-scroll-view-core.entry.js +1 -1
  226. package/dist/esm-es5/taro-share-element-core.entry.js +1 -1
  227. package/dist/esm-es5/taro-slider-core.entry.js +1 -1
  228. package/dist/esm-es5/taro-slot-core.entry.js +1 -1
  229. package/dist/esm-es5/taro-sticky-header-core.entry.js +1 -1
  230. package/dist/esm-es5/taro-sticky-section-core.entry.js +1 -1
  231. package/dist/esm-es5/taro-swiper-core_2.entry.js +1 -1
  232. package/dist/esm-es5/taro-switch-core.entry.js +1 -1
  233. package/dist/esm-es5/taro-tab-item-core.entry.js +1 -1
  234. package/dist/esm-es5/taro-tabbar.entry.js +1 -1
  235. package/dist/esm-es5/taro-tabs-core.entry.js +1 -1
  236. package/dist/esm-es5/taro-text-core.entry.js +1 -1
  237. package/dist/esm-es5/taro-textarea-core.entry.js +1 -1
  238. package/dist/esm-es5/taro-video-control_3.entry.js +1 -1
  239. package/dist/esm-es5/taro-view-core.entry.js +1 -1
  240. package/dist/esm-es5/taro-voip-room-core.entry.js +1 -1
  241. package/dist/esm-es5/taro-web-view-core.entry.js +1 -1
  242. package/dist/taro-components/{p-ebdd350f.system.entry.js → p-02aa7366.system.entry.js} +1 -1
  243. package/dist/taro-components/p-0393ed55.entry.js +1 -0
  244. package/dist/taro-components/{p-9b6550fc.entry.js → p-05bc0fce.entry.js} +1 -1
  245. package/dist/taro-components/{p-8c0b740e.entry.js → p-05c757b7.entry.js} +1 -1
  246. package/dist/taro-components/p-07293238.entry.js +1 -0
  247. package/dist/taro-components/{p-e53508c1.system.entry.js → p-087bf23a.system.entry.js} +1 -1
  248. package/dist/taro-components/{p-052da7f0.system.entry.js → p-08bb8dfc.system.entry.js} +1 -1
  249. package/dist/taro-components/{p-fd7ff0f3.system.entry.js → p-0939fd26.system.entry.js} +1 -1
  250. package/dist/taro-components/{p-898db637.system.entry.js → p-0a165ad3.system.entry.js} +1 -1
  251. package/dist/taro-components/{p-9d9ede17.system.entry.js → p-0a9b984e.system.entry.js} +1 -1
  252. package/dist/taro-components/{p-a132ebb9.entry.js → p-0b8b3af5.entry.js} +1 -1
  253. package/dist/taro-components/{p-e6481671.system.entry.js → p-10be7fb5.system.entry.js} +1 -1
  254. package/dist/taro-components/{p-6db97374.entry.js → p-11936d9a.entry.js} +1 -1
  255. package/dist/taro-components/p-1249cb09.entry.js +1 -0
  256. package/dist/taro-components/{p-ed011ff9.entry.js → p-1385d50f.entry.js} +1 -1
  257. package/dist/taro-components/{p-ca3a269f.entry.js → p-1493866a.entry.js} +1 -1
  258. package/dist/taro-components/p-16e03200.entry.js +1 -0
  259. package/dist/taro-components/{p-f7927285.system.entry.js → p-17302fe9.system.entry.js} +1 -1
  260. package/dist/taro-components/p-1743a04b.system.js +365 -0
  261. package/dist/taro-components/{p-f420680c.system.entry.js → p-1941d333.system.entry.js} +1 -1
  262. package/dist/taro-components/{p-2a071adf.system.entry.js → p-1b501f32.system.entry.js} +1 -1
  263. package/dist/taro-components/{p-46b8f89b.entry.js → p-1be83ed3.entry.js} +1 -1
  264. package/dist/taro-components/{p-fa6c022a.system.entry.js → p-1c320250.system.entry.js} +1 -1
  265. package/dist/taro-components/{p-ed331c06.system.js → p-1c446c65.system.js} +1 -1
  266. package/dist/taro-components/{p-1404c119.entry.js → p-1e8c8ae1.entry.js} +1 -1
  267. package/dist/taro-components/{p-c2322741.system.entry.js → p-2024e133.system.entry.js} +1 -1
  268. package/dist/taro-components/p-22dc57d4.entry.js +1 -0
  269. package/dist/taro-components/{p-968b7c1d.entry.js → p-23cb8a7f.entry.js} +1 -1
  270. package/dist/taro-components/{p-81f2ad70.system.entry.js → p-26889f3c.system.entry.js} +1 -1
  271. package/dist/taro-components/{p-469ee343.entry.js → p-27c4878c.entry.js} +1 -1
  272. package/dist/taro-components/{p-ba7cb688.entry.js → p-2bac359b.entry.js} +1 -1
  273. package/dist/taro-components/p-2e28cb1c.entry.js +1 -0
  274. package/dist/taro-components/p-2f7dba29.entry.js +1 -0
  275. package/dist/taro-components/p-30f32fa2.system.entry.js +1 -0
  276. package/dist/taro-components/{p-f534057e.system.entry.js → p-30fe0e81.system.entry.js} +1 -1
  277. package/dist/taro-components/{p-fa0f6dab.system.entry.js → p-33223303.system.entry.js} +1 -1
  278. package/dist/taro-components/{p-9aeb7995.entry.js → p-369fb262.entry.js} +1 -1
  279. package/dist/taro-components/{p-407ca16e.entry.js → p-38a51bd2.entry.js} +1 -1
  280. package/dist/taro-components/{p-2af69b72.entry.js → p-38de410e.entry.js} +1 -1
  281. package/dist/taro-components/{p-735c2a72.system.entry.js → p-39685396.system.entry.js} +1 -1
  282. package/dist/taro-components/{p-c490cd45.entry.js → p-3c5ac930.entry.js} +1 -1
  283. package/dist/taro-components/p-3c91f59b.entry.js +1 -0
  284. package/dist/taro-components/p-3d60bd58.entry.js +1 -0
  285. package/dist/taro-components/{p-3094bda6.system.entry.js → p-4190e20b.system.entry.js} +1 -1
  286. package/dist/taro-components/p-429a0f99.entry.js +1 -0
  287. package/dist/taro-components/p-42bcb98a.entry.js +1 -0
  288. package/dist/taro-components/{p-0517f107.system.entry.js → p-4402972b.system.entry.js} +1 -1
  289. package/dist/taro-components/{p-8201ee31.system.entry.js → p-4514dc53.system.entry.js} +1 -1
  290. package/dist/taro-components/{p-30805bdf.entry.js → p-4542b767.entry.js} +1 -1
  291. package/dist/taro-components/{p-69cd1f2a.system.entry.js → p-46244579.system.entry.js} +1 -1
  292. package/dist/taro-components/{p-6800ccdc.system.entry.js → p-4915fdc1.system.entry.js} +1 -1
  293. package/dist/taro-components/{p-97f0ad72.system.entry.js → p-491c6272.system.entry.js} +1 -1
  294. package/dist/taro-components/{p-7e8e355b.system.entry.js → p-4d0da795.system.entry.js} +1 -1
  295. package/dist/taro-components/{p-88d2b41b.system.entry.js → p-4d7182f4.system.entry.js} +1 -1
  296. package/dist/taro-components/{p-ab2d4f12.entry.js → p-4e77bdea.entry.js} +1 -1
  297. package/dist/taro-components/{p-eaa370a9.system.entry.js → p-518146fd.system.entry.js} +1 -1
  298. package/dist/taro-components/{p-9ac947ac.system.entry.js → p-51b6fc09.system.entry.js} +1 -1
  299. package/dist/taro-components/{p-43720011.entry.js → p-58690684.entry.js} +1 -1
  300. package/dist/taro-components/{p-16336cc6.system.entry.js → p-58877ef2.system.entry.js} +1 -1
  301. package/dist/taro-components/{p-b027181b.entry.js → p-58b7e960.entry.js} +1 -1
  302. package/dist/taro-components/p-5931c82e.entry.js +1 -0
  303. package/dist/taro-components/{p-117633e9.system.entry.js → p-59590806.system.entry.js} +1 -1
  304. package/dist/taro-components/p-61f225ef.system.js +7 -0
  305. package/dist/taro-components/{p-cd90bead.system.entry.js → p-623b3eb6.system.entry.js} +1 -1
  306. package/dist/taro-components/{p-fa43177b.system.entry.js → p-651586f8.system.entry.js} +1 -1
  307. package/dist/taro-components/{p-18703731.system.entry.js → p-69f6784d.system.entry.js} +1 -1
  308. package/dist/taro-components/{p-473afc8e.system.entry.js → p-69fa7272.system.entry.js} +1 -1
  309. package/dist/taro-components/{p-edbb1a17.system.entry.js → p-6dae898a.system.entry.js} +1 -1
  310. package/dist/taro-components/p-6de6eb4e.entry.js +1 -0
  311. package/dist/taro-components/{p-afb3895c.system.entry.js → p-6f048097.system.entry.js} +1 -1
  312. package/dist/taro-components/{p-208e438c.system.entry.js → p-6f214fc3.system.entry.js} +1 -1
  313. package/dist/taro-components/{p-0d7a705b.system.entry.js → p-70b5e81e.system.entry.js} +1 -1
  314. package/dist/taro-components/{p-cc70bb7a.system.entry.js → p-736053bb.system.entry.js} +1 -1
  315. package/dist/taro-components/p-7377a117.entry.js +1 -0
  316. package/dist/taro-components/p-744a6b99.entry.js +1 -0
  317. package/dist/taro-components/{p-53ef8a6c.system.entry.js → p-74bf8246.system.entry.js} +1 -1
  318. package/dist/taro-components/p-76724e58.js +7 -0
  319. package/dist/taro-components/{p-3f9f3448.entry.js → p-7722f33f.entry.js} +1 -1
  320. package/dist/taro-components/{p-b6d4634f.system.entry.js → p-78c30850.system.entry.js} +1 -1
  321. package/dist/taro-components/{p-df4c2f21.entry.js → p-79c41bc2.entry.js} +1 -1
  322. package/dist/taro-components/{p-5c1e6b1c.system.entry.js → p-7c1fc8f5.system.entry.js} +1 -1
  323. package/dist/taro-components/{p-357ba712.system.entry.js → p-7dd9c8da.system.entry.js} +1 -1
  324. package/dist/taro-components/{p-da239b8b.system.entry.js → p-7df9de66.system.entry.js} +1 -1
  325. package/dist/taro-components/{p-07302165.system.entry.js → p-8027e1c6.system.entry.js} +1 -1
  326. package/dist/taro-components/p-80970d8f.entry.js +1 -0
  327. package/dist/taro-components/{p-0fe855c6.entry.js → p-80f3d88d.entry.js} +1 -1
  328. package/dist/taro-components/{p-1e739fcb.system.entry.js → p-88d64daa.system.entry.js} +1 -1
  329. package/dist/taro-components/{p-af3fa859.system.entry.js → p-895cd7c9.system.entry.js} +1 -1
  330. package/dist/taro-components/{p-139e6251.entry.js → p-8b8a8e39.entry.js} +1 -1
  331. package/dist/taro-components/{p-af8e521a.entry.js → p-8d037fc0.entry.js} +1 -1
  332. package/dist/taro-components/{p-e5f78321.system.entry.js → p-8d2101be.system.entry.js} +1 -1
  333. package/dist/taro-components/{p-79c3fde3.system.entry.js → p-8e5cc8fe.system.entry.js} +1 -1
  334. package/dist/taro-components/{p-dcbb7b2d.entry.js → p-8feeb7ce.entry.js} +1 -1
  335. package/dist/taro-components/{p-25adb80c.entry.js → p-90e4274e.entry.js} +1 -1
  336. package/dist/taro-components/{p-cc164fa3.entry.js → p-9318da32.entry.js} +1 -1
  337. package/dist/taro-components/{p-90333d0a.system.entry.js → p-95f70aea.system.entry.js} +1 -1
  338. package/dist/taro-components/{p-5dab46cd.system.entry.js → p-97782cdd.system.entry.js} +1 -1
  339. package/dist/taro-components/{p-5640e9f4.system.entry.js → p-9d4fa0d3.system.entry.js} +1 -1
  340. package/dist/taro-components/{p-f0340edf.entry.js → p-9df17ea6.entry.js} +1 -1
  341. package/dist/taro-components/{p-7c2454dd.system.entry.js → p-9e8619a6.system.entry.js} +1 -1
  342. package/dist/taro-components/p-a294e169.entry.js +1 -0
  343. package/dist/taro-components/{p-cc7b95fd.system.entry.js → p-a5afdc47.system.entry.js} +1 -1
  344. package/dist/taro-components/p-a6d2e81b.entry.js +1 -0
  345. package/dist/taro-components/p-a9b51167.entry.js +1 -0
  346. package/dist/taro-components/{p-a1763153.entry.js → p-acd9a9da.entry.js} +1 -1
  347. package/dist/taro-components/{p-b5b30493.system.entry.js → p-ae3f1ed4.system.entry.js} +1 -1
  348. package/dist/taro-components/p-ae8fd8c8.entry.js +1 -0
  349. package/dist/taro-components/{p-589293fd.entry.js → p-affb28de.entry.js} +1 -1
  350. package/dist/taro-components/{p-907d9d01.system.entry.js → p-b1249ebb.system.entry.js} +1 -1
  351. package/dist/taro-components/p-b16eddaa.entry.js +1 -0
  352. package/dist/taro-components/{p-6127b1b6.system.entry.js → p-b1c972e2.system.entry.js} +1 -1
  353. package/dist/taro-components/{p-2d1b4dcc.system.entry.js → p-b2bb02d7.system.entry.js} +1 -1
  354. package/dist/taro-components/{p-962f28cb.entry.js → p-b5ad2aec.entry.js} +1 -1
  355. package/dist/taro-components/p-b708e9fe.entry.js +1 -0
  356. package/dist/taro-components/{p-227e33fc.system.entry.js → p-bac3deb0.system.entry.js} +1 -1
  357. package/dist/taro-components/{p-6f84e936.entry.js → p-badfb3be.entry.js} +1 -1
  358. package/dist/taro-components/{p-6d4b7e5c.system.entry.js → p-bba8c3a7.system.entry.js} +1 -1
  359. package/dist/taro-components/{p-f7baa03f.system.entry.js → p-be6050fd.system.entry.js} +1 -1
  360. package/dist/taro-components/p-beba1657.entry.js +1 -0
  361. package/dist/taro-components/{p-385d8aed.entry.js → p-c2391de5.entry.js} +1 -1
  362. package/dist/taro-components/{p-bf0e0394.entry.js → p-c2c498d9.entry.js} +1 -1
  363. package/dist/taro-components/{p-e67755f0.system.entry.js → p-c33733b3.system.entry.js} +1 -1
  364. package/dist/taro-components/{p-5613907c.entry.js → p-c3d35ae5.entry.js} +1 -1
  365. package/dist/taro-components/{p-38ee526a.entry.js → p-c3d3eca2.entry.js} +1 -1
  366. package/dist/taro-components/{p-50902cd0.entry.js → p-c4dd85b6.entry.js} +1 -1
  367. package/dist/taro-components/{p-1f39576a.system.entry.js → p-c4fdb669.system.entry.js} +1 -1
  368. package/dist/taro-components/{p-f11c9c37.system.entry.js → p-c586a796.system.entry.js} +1 -1
  369. package/dist/taro-components/{p-c0ec2f41.system.entry.js → p-c6385fc2.system.entry.js} +1 -1
  370. package/dist/taro-components/{p-1974e52e.system.entry.js → p-c6e6dab1.system.entry.js} +1 -1
  371. package/dist/taro-components/{p-bcf80126.system.entry.js → p-c70dd956.system.entry.js} +1 -1
  372. package/dist/taro-components/{p-137531b6.entry.js → p-d42e41ff.entry.js} +1 -1
  373. package/dist/taro-components/p-d5234e7e.js +365 -0
  374. package/dist/taro-components/{p-904df510.entry.js → p-d797cdc4.entry.js} +1 -1
  375. package/dist/taro-components/{p-ab726c20.system.entry.js → p-da5cdbf5.system.entry.js} +1 -1
  376. package/dist/taro-components/p-dcb5b505.system.entry.js +1 -0
  377. package/dist/taro-components/{p-b235e43c.entry.js → p-dccf1ae9.entry.js} +1 -1
  378. package/dist/taro-components/{p-3d8c9dfb.entry.js → p-dfc405a5.entry.js} +1 -1
  379. package/dist/taro-components/p-e2f2fbe5.entry.js +1 -0
  380. package/dist/taro-components/{p-c1073ed6.system.entry.js → p-e3f8265d.system.entry.js} +1 -1
  381. package/dist/taro-components/{p-355e4dbc.entry.js → p-e753b776.entry.js} +1 -1
  382. package/dist/taro-components/p-e8b1ea64.entry.js +1 -0
  383. package/dist/taro-components/p-e9eeb060.entry.js +1 -0
  384. package/dist/taro-components/{p-85a7daeb.system.entry.js → p-ef7e7d73.system.entry.js} +1 -1
  385. package/dist/taro-components/p-efcfdb97.entry.js +1 -0
  386. package/dist/taro-components/{p-31bba7c3.entry.js → p-f44e975b.entry.js} +1 -1
  387. package/dist/taro-components/{p-66b0b419.system.entry.js → p-f499c0a0.system.entry.js} +1 -1
  388. package/dist/taro-components/{p-a8565231.entry.js → p-f671ed7d.entry.js} +1 -1
  389. package/dist/taro-components/{p-57b9943c.system.entry.js → p-f9ac515e.system.entry.js} +1 -1
  390. package/dist/taro-components/{p-b641e598.entry.js → p-f9c26678.entry.js} +1 -1
  391. package/dist/taro-components/{p-1b3d41d3.system.entry.js → p-fa36fe8e.system.entry.js} +1 -1
  392. package/dist/taro-components/p-fb585037.entry.js +1 -0
  393. package/dist/taro-components/{p-c43c5e89.system.entry.js → p-fcdac6ec.system.entry.js} +1 -1
  394. package/dist/taro-components/p-fdecdc25.entry.js +1 -0
  395. package/dist/taro-components/taro-components.esm.js +1 -1
  396. package/dist/taro-components/taro-components.js +1 -1
  397. package/dist/types/components/textarea/textarea.d.ts +3 -0
  398. package/dist/types/components.d.ts +2 -0
  399. package/lib/react/component-lib/index.d.ts +1 -1
  400. package/lib/react/components.d.ts +80 -80
  401. package/lib/react/index.d.ts +1 -1
  402. package/lib/react/react-component-lib/createComponent.d.ts +1 -1
  403. package/lib/react/react-component-lib/createOverlayComponent.d.ts +2 -2
  404. package/lib/react/react-component-lib/index.d.ts +2 -2
  405. package/lib/react/react-component-lib/utils/index.d.ts +3 -3
  406. package/lib/vue2/components.js +1 -1
  407. package/lib/vue2/components.js.map +1 -1
  408. package/lib/vue2/index.d.ts +1 -1
  409. package/lib/vue3/component-lib/index.d.ts +4 -4
  410. package/lib/vue3/components.d.ts +80 -80
  411. package/lib/vue3/components.js +3 -1
  412. package/lib/vue3/components.js.map +1 -1
  413. package/lib/vue3/index.d.ts +1 -1
  414. package/package.json +4 -4
  415. package/types/Input.d.ts +0 -1
  416. package/types/Map.d.ts +1 -0
  417. package/types/Picker.d.ts +4 -4
  418. package/types/Textarea.d.ts +1 -1
  419. package/dist/esm-es5/hls-0e83e558.js +0 -289
  420. package/dist/esm-es5/index-394db4c1.js +0 -7
  421. package/dist/taro-components/p-198000d8.system.js +0 -289
  422. package/dist/taro-components/p-1c4e3899.entry.js +0 -1
  423. package/dist/taro-components/p-204bd245.entry.js +0 -1
  424. package/dist/taro-components/p-2fad2a65.js +0 -7
  425. package/dist/taro-components/p-387314fa.system.js +0 -7
  426. package/dist/taro-components/p-3e701660.js +0 -289
  427. package/dist/taro-components/p-486d0ec7.entry.js +0 -1
  428. package/dist/taro-components/p-4e9bd4f6.entry.js +0 -1
  429. package/dist/taro-components/p-58b19305.system.entry.js +0 -1
  430. package/dist/taro-components/p-5b67a98e.entry.js +0 -1
  431. package/dist/taro-components/p-66f7eea6.entry.js +0 -1
  432. package/dist/taro-components/p-6e115968.entry.js +0 -1
  433. package/dist/taro-components/p-71b54f06.entry.js +0 -1
  434. package/dist/taro-components/p-72b118b0.entry.js +0 -1
  435. package/dist/taro-components/p-7b3b8057.entry.js +0 -1
  436. package/dist/taro-components/p-7d635413.entry.js +0 -1
  437. package/dist/taro-components/p-801f09b8.entry.js +0 -1
  438. package/dist/taro-components/p-86280254.entry.js +0 -1
  439. package/dist/taro-components/p-9046110a.entry.js +0 -1
  440. package/dist/taro-components/p-9a5fbb2e.entry.js +0 -1
  441. package/dist/taro-components/p-a3a1a779.entry.js +0 -1
  442. package/dist/taro-components/p-a940a65b.entry.js +0 -1
  443. package/dist/taro-components/p-af9ef8b4.entry.js +0 -1
  444. package/dist/taro-components/p-b4ea72ea.entry.js +0 -1
  445. package/dist/taro-components/p-b4f3d0ab.entry.js +0 -1
  446. package/dist/taro-components/p-b898d734.entry.js +0 -1
  447. package/dist/taro-components/p-bdc30301.entry.js +0 -1
  448. package/dist/taro-components/p-c11a42e0.entry.js +0 -1
  449. package/dist/taro-components/p-cfb01848.system.entry.js +0 -1
  450. package/dist/taro-components/p-d34a6c04.entry.js +0 -1
  451. package/dist/taro-components/p-d8831b3c.entry.js +0 -1
  452. package/dist/taro-components/p-e3480c4c.entry.js +0 -1
  453. package/dist/taro-components/p-f533bc2f.entry.js +0 -1
  454. package/dist/taro-components/p-f7b32c6b.entry.js +0 -1
  455. package/dist/taro-components/p-fb983850.entry.js +0 -1
  456. /package/dist/cjs/{index-e751dfe3.js → index-e1b469cd.js} +0 -0
  457. /package/dist/esm/{index-980f930f.js → index-c948674f.js} +0 -0
  458. /package/dist/esm-es5/{index-980f930f.js → index-c948674f.js} +0 -0
  459. /package/dist/taro-components/{p-7e6b54cb.system.js → p-1a0e1932.system.js} +0 -0
  460. /package/dist/taro-components/{p-9137dcab.js → p-78e3ebb9.js} +0 -0
@@ -0,0 +1,365 @@
1
+ import{g as t,a as i,b as n}from"./p-76724e58.js";var r=i((function(t){var i;"undefined"!=typeof window&&(i=function(){return function(t){var i={};function n(r){if(i[r])return i[r].exports;var e=i[r]={i:r,l:!1,exports:{}};return t[r].call(e.exports,e,e.exports,n),e.l=!0,e.exports}return n.m=t,n.c=i,n.d=function(t,i,r){n.o(t,i)||Object.defineProperty(t,i,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,i){if(1&i&&(t=n(t)),8&i)return t;if(4&i&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&i&&"string"!=typeof t)for(var e in t)n.d(r,e,function(i){return t[i]}.bind(null,e));return r},n.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(i,"a",i),i},n.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},n.p="/dist/",n(n.s="./src/hls.ts")}({"./node_modules/eventemitter3/index.js":
2
+ /*!*********************************************!*\
3
+ !*** ./node_modules/eventemitter3/index.js ***!
4
+ \*********************************************/
5
+ /*! no static exports found */function(t){var i=Object.prototype.hasOwnProperty,n="~";function r(){}function e(t,i,n){this.fn=t,this.context=i,this.once=n||!1}function s(t,i,r,s,a){if("function"!=typeof r)throw new TypeError("The listener must be a function");var o=new e(r,s||t,a),h=n?n+i:i;return t._events[h]?t._events[h].fn?t._events[h]=[t._events[h],o]:t._events[h].push(o):(t._events[h]=o,t._eventsCount++),t}function a(t,i){0==--t._eventsCount?t._events=new r:delete t._events[i]}function o(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),o.prototype.eventNames=function(){var t,r,e=[];if(0===this._eventsCount)return e;for(r in t=this._events)i.call(t,r)&&e.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?e.concat(Object.getOwnPropertySymbols(t)):e},o.prototype.listeners=function(t){var i=this._events[n?n+t:t];if(!i)return[];if(i.fn)return[i.fn];for(var r=0,e=i.length,s=new Array(e);r<e;r++)s[r]=i[r].fn;return s},o.prototype.listenerCount=function(t){var i=this._events[n?n+t:t];return i?i.fn?1:i.length:0},o.prototype.emit=function(t,i,r,e,s,a){var o=n?n+t:t;if(!this._events[o])return!1;var h,u,c=this._events[o],f=arguments.length;if(c.fn){switch(c.once&&this.removeListener(t,c.fn,void 0,!0),f){case 1:return c.fn.call(c.context),!0;case 2:return c.fn.call(c.context,i),!0;case 3:return c.fn.call(c.context,i,r),!0;case 4:return c.fn.call(c.context,i,r,e),!0;case 5:return c.fn.call(c.context,i,r,e,s),!0;case 6:return c.fn.call(c.context,i,r,e,s,a),!0}for(u=1,h=new Array(f-1);u<f;u++)h[u-1]=arguments[u];c.fn.apply(c.context,h)}else{var l,v=c.length;for(u=0;u<v;u++)switch(c[u].once&&this.removeListener(t,c[u].fn,void 0,!0),f){case 1:c[u].fn.call(c[u].context);break;case 2:c[u].fn.call(c[u].context,i);break;case 3:c[u].fn.call(c[u].context,i,r);break;case 4:c[u].fn.call(c[u].context,i,r,e);break;default:if(!h)for(l=1,h=new Array(f-1);l<f;l++)h[l-1]=arguments[l];c[u].fn.apply(c[u].context,h)}}return!0},o.prototype.on=function(t,i,n){return s(this,t,i,n,!1)},o.prototype.once=function(t,i,n){return s(this,t,i,n,!0)},o.prototype.removeListener=function(t,i,r,e){var s=n?n+t:t;if(!this._events[s])return this;if(!i)return a(this,s),this;var o=this._events[s];if(o.fn)o.fn!==i||e&&!o.once||r&&o.context!==r||a(this,s);else{for(var h=0,u=[],c=o.length;h<c;h++)(o[h].fn!==i||e&&!o[h].once||r&&o[h].context!==r)&&u.push(o[h]);u.length?this._events[s]=1===u.length?u[0]:u:a(this,s)}return this},o.prototype.removeAllListeners=function(t){var i;return t?this._events[i=n?n+t:t]&&a(this,i):(this._events=new r,this._eventsCount=0),this},o.prototype.off=o.prototype.removeListener,o.prototype.addListener=o.prototype.on,o.prefixed=n,o.EventEmitter=o,t.exports=o},"./node_modules/url-toolkit/src/url-toolkit.js":
6
+ /*!*****************************************************!*\
7
+ !*** ./node_modules/url-toolkit/src/url-toolkit.js ***!
8
+ \*****************************************************/
9
+ /*! no static exports found */function(t){var i,n,r,e,s;i=/^((?:[a-zA-Z0-9+\-.]+:)?)(\/\/[^\/?#]*)?((?:[^\/?#]*\/)*[^;?#]*)?(;[^?#]*)?(\?[^#]*)?(#[^]*)?$/,n=/^([^\/?#]*)([^]*)$/,r=/(?:\/|^)\.(?=\/)/g,e=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,t.exports=s={buildAbsoluteURL:function(t,i,r){if(r=r||{},t=t.trim(),!(i=i.trim())){if(!r.alwaysNormalize)return t;var e=s.parseURL(t);if(!e)throw new Error("Error trying to parse base URL.");return e.path=s.normalizePath(e.path),s.buildURLFromParts(e)}var a=s.parseURL(i);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):i;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var h=n.exec(o.path);o.netLoc=h[1],o.path=h[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var c=o.path,f=c.substring(0,c.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(f)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var n=i.exec(t);return n?{scheme:n[1]||"",netLoc:n[2]||"",path:n[3]||"",params:n[4]||"",query:n[5]||"",fragment:n[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(r,"");t.length!==(t=t.replace(e,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}}},"./node_modules/webworkify-webpack/index.js":
10
+ /*!**************************************************!*\
11
+ !*** ./node_modules/webworkify-webpack/index.js ***!
12
+ \**************************************************/
13
+ /*! no static exports found */function(t,i,n){function r(t){var i={};function n(r){if(i[r])return i[r].exports;var e=i[r]={i:r,l:!1,exports:{}};return t[r].call(e.exports,e,e.exports,n),e.l=!0,e.exports}n.m=t,n.c=i,n.i=function(t){return t},n.d=function(t,i,r){n.o(t,i)||Object.defineProperty(t,i,{configurable:!1,enumerable:!0,get:r})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var i=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(i,"a",i),i},n.o=function(t,i){return Object.prototype.hasOwnProperty.call(t,i)},n.p="/",n.oe=function(t){throw console.error(t),t};var r=n(n.s=ENTRY_MODULE);return r.default||r}var e="[\\.|\\-|\\+|\\w|/|@]+",s="\\(\\s*(/\\*.*?\\*/)?\\s*.*?("+e+").*?\\)";function a(t){return(t+"").replace(/[.?*+^$[\]\\(){}|-]/g,"\\$&")}function o(t,i,r){var o={};o[r]=[];var h=i.toString(),u=h.match(/^function\s?\w*\(\w+,\s*\w+,\s*(\w+)\)/);if(!u)return o;for(var c,f=u[1],l=new RegExp("(\\\\n|\\W)"+a(f)+s,"g");c=l.exec(h);)"dll-reference"!==c[3]&&o[r].push(c[3]);for(l=new RegExp("\\("+a(f)+'\\("(dll-reference\\s('+e+'))"\\)\\)'+s,"g");c=l.exec(h);)t[c[2]]||(o[r].push(c[1]),t[c[2]]=n(c[1]).m),o[c[2]]=o[c[2]]||[],o[c[2]].push(c[4]);for(var v=Object.keys(o),d=0;d<v.length;d++)for(var m=0;m<o[v[d]].length;m++)isNaN(1*o[v[d]][m])||(o[v[d]][m]=1*o[v[d]][m]);return o}function h(t){return Object.keys(t).reduce((function(i,n){return i||t[n].length>0}),!1)}t.exports=function(t,i){var e={main:n.m},s=(i=i||{}).all?{main:Object.keys(e.main)}:function(t,i){for(var n={main:[i]},r={main:[]},e={main:{}};h(n);)for(var s=Object.keys(n),a=0;a<s.length;a++){var u=s[a],c=n[u].pop();if(e[u]=e[u]||{},!e[u][c]&&t[u][c]){e[u][c]=!0,r[u]=r[u]||[],r[u].push(c);for(var f=o(t,t[u][c],u),l=Object.keys(f),v=0;v<l.length;v++)n[l[v]]=n[l[v]]||[],n[l[v]]=n[l[v]].concat(f[l[v]])}}return r}(e,t),a="";Object.keys(s).filter((function(t){return"main"!==t})).forEach((function(t){for(var i=0;s[t][i];)i++;s[t].push(i),e[t][i]="(function(module, exports, __webpack_require__) { module.exports = __webpack_require__; })",a=a+"var "+t+" = ("+r.toString().replace("ENTRY_MODULE",JSON.stringify(i))+")({"+s[t].map((function(i){return JSON.stringify(i)+": "+e[t][i].toString()})).join(",")+"});\n"})),a=a+"new (("+r.toString().replace("ENTRY_MODULE",JSON.stringify(t))+")({"+s.main.map((function(t){return JSON.stringify(t)+": "+e.main[t].toString()})).join(",")+"}))(self);";var u=new window.Blob([a],{type:"text/javascript"});if(i.bare)return u;var c=(window.URL||window.webkitURL||window.mozURL||window.msURL).createObjectURL(u),f=new window.Worker(c);return f.objectURL=c,f}},"./src/config.ts":
14
+ /*!***********************!*\
15
+ !*** ./src/config.ts ***!
16
+ \***********************/
17
+ /*! exports provided: hlsDefaultConfig, mergeConfig, enableStreamingMode */function(t,i,n){n.r(i),n.d(i,"hlsDefaultConfig",(function(){return O})),n.d(i,"mergeConfig",(function(){return S})),n.d(i,"enableStreamingMode",(function(){return E}));var r=n(/*! ./controller/abr-controller */"./src/controller/abr-controller.ts"),e=n(/*! ./controller/audio-stream-controller */"./src/controller/audio-stream-controller.ts"),s=n(/*! ./controller/audio-track-controller */"./src/controller/audio-track-controller.ts"),a=n(/*! ./controller/subtitle-stream-controller */"./src/controller/subtitle-stream-controller.ts"),o=n(/*! ./controller/subtitle-track-controller */"./src/controller/subtitle-track-controller.ts"),h=n(/*! ./controller/buffer-controller */"./src/controller/buffer-controller.ts"),u=n(/*! ./controller/timeline-controller */"./src/controller/timeline-controller.ts"),c=n(/*! ./controller/cap-level-controller */"./src/controller/cap-level-controller.ts"),f=n(/*! ./controller/fps-controller */"./src/controller/fps-controller.ts"),l=n(/*! ./controller/eme-controller */"./src/controller/eme-controller.ts"),v=n(/*! ./controller/cmcd-controller */"./src/controller/cmcd-controller.ts"),d=n(/*! ./utils/xhr-loader */"./src/utils/xhr-loader.ts"),m=n(/*! ./utils/fetch-loader */"./src/utils/fetch-loader.ts"),p=n(/*! ./utils/cues */"./src/utils/cues.ts"),g=n(/*! ./utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts"),b=n(/*! ./utils/logger */"./src/utils/logger.ts");function y(){return y=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},y.apply(this,arguments)}function w(t,i){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);i&&(r=r.filter((function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable}))),n.push.apply(n,r)}return n}function k(t){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?w(Object(n),!0).forEach((function(i){T(t,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(n,i))}))}return t}function T(t,i,n){return i in t?Object.defineProperty(t,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[i]=n,t}var O=k(k({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,maxBufferSize:6e7,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,enableSoftwareAES:!0,manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,startLevel:void 0,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:d.default,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:r.default,bufferController:h.default,capLevelController:c.default,fpsController:f.default,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystemOptions:{},requestMediaKeySystemAccessFunc:g.requestMediaKeySystemAccess,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0},{cueHandler:p.default,enableCEA708Captions:!0,enableWebVTT:!0,enableIMSC1:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:a.SubtitleStreamController,subtitleTrackController:o.default,timelineController:u.TimelineController,audioStreamController:e.default,audioTrackController:s.default,emeController:l.default,cmcdController:v.default});function S(t,i){if((i.liveSyncDurationCount||i.liveMaxLatencyDurationCount)&&(i.liveSyncDuration||i.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==i.liveMaxLatencyDurationCount&&(void 0===i.liveSyncDurationCount||i.liveMaxLatencyDurationCount<=i.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==i.liveMaxLatencyDuration&&(void 0===i.liveSyncDuration||i.liveMaxLatencyDuration<=i.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');return y({},t,i)}function E(t){var i=t.loader;i!==m.default&&i!==d.default?(b.logger.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):Object(m.fetchSupported)()&&(t.loader=m.default,t.progressive=!0,t.enableSoftwareAES=!0,b.logger.log("[config]: Progressive streaming enabled, using FetchLoader"))}},"./src/controller/abr-controller.ts":
18
+ /*!******************************************!*\
19
+ !*** ./src/controller/abr-controller.ts ***!
20
+ \******************************************/
21
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/ewma-bandwidth-estimator */"./src/utils/ewma-bandwidth-estimator.ts"),s=n(/*! ../events */"./src/events.ts"),a=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=n(/*! ../types/loader */"./src/types/loader.ts"),u=n(/*! ../utils/logger */"./src/utils/logger.ts");function c(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var f=function(){function t(t){this.hls=void 0,this.lastLoadedFragLevel=0,this._nextAutoLevel=-1,this.timer=void 0,this.onCheck=this._abandonRulesCheck.bind(this),this.fragCurrent=null,this.partCurrent=null,this.bitrateTestDelay=0,this.bwEstimator=void 0,this.hls=t;var i=t.config;this.bwEstimator=new e.default(i.abrEwmaSlowVoD,i.abrEwmaFastVoD,i.abrEwmaDefaultEstimate),this.registerListeners()}var i,n,f=t.prototype;return f.registerListeners=function(){var t=this.hls;t.on(s.Events.FRAG_LOADING,this.onFragLoading,this),t.on(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(s.Events.FRAG_LOADING,this.onFragLoading,this),t.off(s.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this.onCheck=null,this.fragCurrent=this.partCurrent=null},f.onFragLoading=function(t,i){var n,r=i.frag;r.type===h.PlaylistLevelType.MAIN&&(this.timer||(this.fragCurrent=r,this.partCurrent=null!=(n=i.part)?n:null,this.timer=self.setInterval(this.onCheck,100)))},f.onLevelLoaded=function(t,i){var n=this.hls.config;i.details.live?this.bwEstimator.update(n.abrEwmaSlowLive,n.abrEwmaFastLive):this.bwEstimator.update(n.abrEwmaSlowVoD,n.abrEwmaFastVoD)},f._abandonRulesCheck=function(){var t=this.fragCurrent,i=this.partCurrent,n=this.hls,e=n.autoLevelEnabled,o=n.config,h=n.media;if(t&&h){var c=i?i.stats:t.stats,f=i?i.duration:t.duration;if(c.aborted)return u.logger.warn("frag loader destroy or aborted, disarm abandonRules"),this.clearTimer(),void(this._nextAutoLevel=-1);if(e&&!h.paused&&h.playbackRate&&h.readyState){var l=performance.now()-c.loading.start,v=Math.abs(h.playbackRate);if(!(l<=500*f/v)){var d=n.levels,m=n.minAutoLevel,p=c.total||Math.max(c.loaded,Math.round(f*d[t.level].maxBitrate/8)),g=Math.max(1,c.bwEstimate?c.bwEstimate/8:1e3*c.loaded/l),b=(p-c.loaded)/g,y=h.currentTime,w=(a.BufferHelper.bufferInfo(h,y,o.maxBufferHole).end-y)/v;if(!(w>=2*f/v||b<=w)){var k,T=Number.POSITIVE_INFINITY;for(k=t.level-1;k>m&&!((T=f*d[k].maxBitrate/(6.4*g))<w);k--);if(!(T>=b)){var O=this.bwEstimator.getEstimate();u.logger.warn("Fragment "+t.sn+(i?" part "+i.index:"")+" of level "+t.level+" is loading too slowly and will cause an underbuffer; aborting and switching to level "+k+"\n Current BW estimate: "+(Object(r.isFiniteNumber)(O)?(O/1024).toFixed(3):"Unknown")+" Kb/s\n Estimated load time for current fragment: "+b.toFixed(3)+" s\n Estimated load time for the next fragment: "+T.toFixed(3)+" s\n Time to underbuffer: "+w.toFixed(3)+" s"),n.nextLoadLevel=k,this.bwEstimator.sample(l,c.loaded),this.clearTimer(),t.loader&&(this.fragCurrent=this.partCurrent=null,t.loader.abort()),n.trigger(s.Events.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:i,stats:c})}}}}}},f.onFragLoaded=function(t,i){var n=i.frag,e=i.part;if(n.type===h.PlaylistLevelType.MAIN&&Object(r.isFiniteNumber)(n.sn)){var a=e?e.stats:n.stats,o=e?e.duration:n.duration;if(this.clearTimer(),this.lastLoadedFragLevel=n.level,this._nextAutoLevel=-1,this.hls.config.abrMaxWithRealBitrate){var u=this.hls.levels[n.level],c=(u.loaded?u.loaded.bytes:0)+a.loaded,f=(u.loaded?u.loaded.duration:0)+o;u.loaded={bytes:c,duration:f},u.realBitrate=Math.round(8*c/f)}n.bitrateTest&&(this.onFragBuffered(s.Events.FRAG_BUFFERED,{stats:a,frag:n,part:e,id:n.type}),n.bitrateTest=!1)}},f.onFragBuffered=function(t,i){var n=i.frag,r=i.part,e=r?r.stats:n.stats;if(!e.aborted&&n.type===h.PlaylistLevelType.MAIN&&"initSegment"!==n.sn){var s=e.parsing.end-e.loading.start;this.bwEstimator.sample(s,e.loaded),e.bwEstimate=this.bwEstimator.getEstimate(),this.bitrateTestDelay=n.bitrateTest?s/1e3:0}},f.onError=function(t,i){switch(i.details){case o.ErrorDetails.FRAG_LOAD_ERROR:case o.ErrorDetails.FRAG_LOAD_TIMEOUT:this.clearTimer()}},f.clearTimer=function(){self.clearInterval(this.timer),this.timer=void 0},f.getNextABRAutoLevel=function(){var t=this.fragCurrent,i=this.partCurrent,n=this.hls,r=n.maxAutoLevel,e=n.config,s=n.minAutoLevel,o=n.media,h=i?i.duration:t?t.duration:0,c=o?o.currentTime:0,f=o&&0!==o.playbackRate?Math.abs(o.playbackRate):1,l=this.bwEstimator?this.bwEstimator.getEstimate():e.abrEwmaDefaultEstimate,v=(a.BufferHelper.bufferInfo(o,c,e.maxBufferHole).end-c)/f,d=this.findBestLevel(l,s,r,v,e.abrBandWidthFactor,e.abrBandWidthUpFactor);if(d>=0)return d;u.logger.trace((v?"rebuffering expected":"buffer is empty")+", finding optimal quality level");var m=h?Math.min(h,e.maxStarvationDelay):e.maxStarvationDelay,p=e.abrBandWidthFactor,g=e.abrBandWidthUpFactor;if(!v){var b=this.bitrateTestDelay;b&&(m=(h?Math.min(h,e.maxLoadingDelay):e.maxLoadingDelay)-b,u.logger.trace("bitrate test took "+Math.round(1e3*b)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*m)+" ms"),p=g=1)}return d=this.findBestLevel(l,s,r,v+m,p,g),Math.max(d,0)},f.findBestLevel=function(t,i,n,r,e,s){for(var a,o=this.fragCurrent,h=this.partCurrent,c=this.lastLoadedFragLevel,f=this.hls.levels,l=f[c],v=!(null==l||null===(a=l.details)||void 0===a||!a.live),d=null==l?void 0:l.codecSet,m=h?h.duration:o?o.duration:0,p=n;p>=i;p--){var g=f[p];if(g&&(!d||g.codecSet===d)){var b,y=g.details,w=(h?null==y?void 0:y.partTarget:null==y?void 0:y.averagetargetduration)||m,k=f[p].maxBitrate,T=k*w/(b=p<=c?e*t:s*t);if(u.logger.trace("level/adjustedbw/bitrate/avgDuration/maxFetchDuration/fetchDuration: "+p+"/"+Math.round(b)+"/"+k+"/"+w+"/"+r+"/"+T),b>k&&(!T||v&&!this.bitrateTestDelay||T<r))return p}}return-1},i=t,(n=[{key:"nextAutoLevel",get:function(){var t=this._nextAutoLevel,i=this.bwEstimator;if(!(-1===t||i&&i.canEstimate()))return t;var n=this.getNextABRAutoLevel();return-1!==t&&(n=Math.min(t,n)),n},set:function(t){this._nextAutoLevel=t}}])&&c(i.prototype,n),t}();i.default=f},"./src/controller/audio-stream-controller.ts":
22
+ /*!***************************************************!*\
23
+ !*** ./src/controller/audio-stream-controller.ts ***!
24
+ \***************************************************/
25
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=n(/*! ../events */"./src/events.ts"),a=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),h=n(/*! ../types/level */"./src/types/level.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),f=n(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts"),l=n(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),v=n(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),d=n(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),m=n(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),p=n(/*! ../errors */"./src/errors.ts"),g=n(/*! ../utils/logger */"./src/utils/logger.ts");function b(){return b=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},b.apply(this,arguments)}function y(t,i){return y=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},y(t,i)}var w=function(t){var i,n;function w(i,n){var r;return(r=t.call(this,i,n,"[audio-stream-controller]")||this).videoBuffer=null,r.videoTrackCC=-1,r.waitingVideoCC=-1,r.audioSwitch=!1,r.trackId=-1,r.waitingData=null,r.mainDetails=null,r.bufferFlushed=!1,r._registerListeners(),r}n=t,(i=w).prototype=Object.create(n.prototype),i.prototype.constructor=i,y(i,n);var k=w.prototype;return k.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},k._registerListeners=function(){var t=this.hls;t.on(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.on(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(s.Events.ERROR,this.onError,this),t.on(s.Events.BUFFER_RESET,this.onBufferReset,this),t.on(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k._unregisterListeners=function(){var t=this.hls;t.off(s.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(s.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(s.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(s.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(s.Events.AUDIO_TRACKS_UPDATED,this.onAudioTracksUpdated,this),t.off(s.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(s.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(s.Events.ERROR,this.onError,this),t.off(s.Events.BUFFER_RESET,this.onBufferReset,this),t.off(s.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(s.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(s.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(s.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k.onInitPtsFound=function(t,i){var n=i.frag,r=i.initPTS;if("main"===i.id){var s=n.cc;this.initPTS[n.cc]=r,this.log("InitPTS for cc: "+s+" found from main: "+r),this.videoTrackCC=s,this.state===e.State.WAITING_INIT_PTS&&this.tick()}},k.startLoad=function(t){if(!this.levels)return this.startPosition=t,void(this.state=e.State.STOPPED);var i=this.lastCurrentTime;this.stopLoad(),this.setInterval(100),this.fragLoadError=0,i>0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),this.state=e.State.IDLE):(this.loadedmetadata=!1,this.state=e.State.WAITING_TRACK),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},k.doTick=function(){switch(this.state){case e.State.IDLE:this.doTickIdle();break;case e.State.WAITING_TRACK:var i,n=this.levels,r=null==n||null===(i=n[this.trackId])||void 0===i?void 0:i.details;if(r){if(this.waitForCdnTuneIn(r))break;this.state=e.State.WAITING_INIT_PTS}break;case e.State.FRAG_LOADING_WAITING_RETRY:var s,o=performance.now(),h=this.retryDate;(!h||o>=h||null!==(s=this.media)&&void 0!==s&&s.seeking)&&(this.log("RetryDate reached, switch back to IDLE state"),this.state=e.State.IDLE);break;case e.State.WAITING_INIT_PTS:var u=this.waitingData;if(u){var c=u.frag,f=u.part,l=u.cache,v=u.complete;if(void 0!==this.initPTS[c.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=e.State.FRAG_LOADING;var m={frag:c,part:f,payload:l.flush(),networkDetails:null};this._handleFragmentLoadProgress(m),v&&t.prototype._handleFragmentLoadComplete.call(this,m)}else if(this.videoTrackCC!==this.waitingVideoCC)g.logger.log("Waiting fragment cc ("+c.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var p=this.getLoadPosition(),b=a.BufferHelper.bufferInfo(this.mediaBuffer,p,this.config.maxBufferHole);Object(d.fragmentWithinToleranceTest)(b.end,this.config.maxFragLookUpTolerance,c)<0&&(g.logger.log("Waiting fragment cc ("+c.cc+") @ "+c.start+" cancelled because another fragment at "+b.end+" is needed"),this.clearWaitingFragment())}}else this.state=e.State.IDLE}this.onTickEnd()},k.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=e.State.IDLE)},k.onTickEnd=function(){var t=this.media;t&&t.readyState&&(!this.loadedmetadata&&(this.mediaBuffer?this.mediaBuffer:t).buffered.length&&(this.loadedmetadata=!0),this.lastCurrentTime=t.currentTime)},k.doTickIdle=function(){var t,i,n=this.hls,r=this.levels,a=this.media,o=this.trackId;if(r&&r[o]&&(a||!this.startFragRequested&&n.config.startFragPrefetch)){var h=r[o].details;if(!h||h.live&&this.levelLastLoaded!==o||this.waitForCdnTuneIn(h))this.state=e.State.WAITING_TRACK;else{this.bufferFlushed&&(this.bufferFlushed=!1,this.afterBufferFlushed(this.mediaBuffer?this.mediaBuffer:this.media,c.ElementaryStreamTypes.AUDIO,u.PlaylistLevelType.AUDIO));var f=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,u.PlaylistLevelType.AUDIO);if(null!==f){var l=f.len,v=this.getMaxBufferLength(),d=this.audioSwitch;if(!(l>=v)||d){if(!d&&this._streamEnded(f,h))return n.trigger(s.Events.BUFFER_EOS,{type:"audio"}),void(this.state=e.State.ENDED);var m=h.fragments[0].start,p=f.end;if(d){var g=this.getLoadPosition();p=g,h.PTSKnown&&g<m&&(f.end>m||f.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),a.currentTime=m+.05)}var b=this.getNextFragment(p,h);b?"identity"!==(null===(t=b.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(i=b.decryptdata)&&void 0!==i&&i.key?this.loadFragment(b,h,p):this.loadKey(b,h):this.bufferFlushed=!0}}}}},k.getMaxBufferLength=function(){var i=t.prototype.getMaxBufferLength.call(this),n=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,u.PlaylistLevelType.MAIN);return null===n?i:Math.max(i,n.len)},k.onMediaDetaching=function(){this.videoBuffer=null,t.prototype.onMediaDetaching.call(this)},k.onAudioTracksUpdated=function(t,i){var n=i.audioTracks;this.resetTransmuxer(),this.levels=n.map((function(t){return new h.Level(t)}))},k.onAudioTrackSwitching=function(t,i){var n=!!i.url;this.trackId=i.id;var r=this.fragCurrent;null!=r&&r.loader&&r.loader.abort(),this.fragCurrent=null,this.clearWaitingFragment(),n?this.setInterval(100):this.resetTransmuxer(),n?(this.audioSwitch=!0,this.state=e.State.IDLE):this.state=e.State.STOPPED,this.tick()},k.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments(),this.startPosition=this.lastCurrentTime=0,this.bufferFlushed=!1},k.onLevelLoaded=function(t,i){this.mainDetails=i.details},k.onAudioTrackLoaded=function(t,i){var n,r=this.levels,s=i.details,a=i.id;if(r){this.log("Track "+a+" loaded ["+s.startSN+","+s.endSN+"],duration:"+s.totalduration);var o=r[a],h=0;if(s.live||null!==(n=o.details)&&void 0!==n&&n.live){var u=this.mainDetails;if(s.fragments[0]||(s.deltaUpdateFailed=!0),s.deltaUpdateFailed||!u)return;!o.details&&s.hasProgramDateTime&&u.hasProgramDateTime?(Object(m.alignMediaPlaylistByPDT)(s,u),h=s.fragments[0].start):h=this.alignPlaylists(s,o.details)}o.details=s,this.levelLastLoaded=a,this.startFragRequested||!this.mainDetails&&s.live||this.setStartPosition(o.details,h),this.state!==e.State.WAITING_TRACK||this.waitForCdnTuneIn(s)||(this.state=e.State.IDLE),this.tick()}else this.warn("Audio tracks were reset while loading level "+a)},k._handleFragmentLoadProgress=function(t){var i,n=t.frag,r=t.part,s=t.payload,a=this.config,o=this.trackId,h=this.levels;if(h){var c=h[o];console.assert(c,"Audio track is defined on fragment load progress");var d=c.details;console.assert(d,"Audio track details are defined on fragment load progress");var m=a.defaultAudioCodec||c.audioCodec||"mp4a.40.2",p=this.transmuxer;p||(p=this.transmuxer=new l.default(this.hls,u.PlaylistLevelType.AUDIO,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)));var b=this.initPTS[n.cc],y=null===(i=n.initSegment)||void 0===i?void 0:i.data;if(void 0!==b){var w=r?r.index:-1,k=new v.ChunkMetadata(n.level,n.sn,n.stats.chunkCount,s.byteLength,w,-1!==w);p.push(s,y,m,"",n,r,d.totalduration,!1,k,b)}else g.logger.log("Unknown video PTS for cc "+n.cc+", waiting for video PTS before demuxing audio frag "+n.sn+" of ["+d.startSN+" ,"+d.endSN+"],track "+o),(this.waitingData=this.waitingData||{frag:n,part:r,cache:new f.default,complete:!1}).cache.push(new Uint8Array(s)),this.waitingVideoCC=this.videoTrackCC,this.state=e.State.WAITING_INIT_PTS}else this.warn("Audio tracks were reset while fragment load was in progress. Fragment "+n.sn+" of level "+n.level+" will not be buffered")},k._handleFragmentLoadComplete=function(i){this.waitingData?this.waitingData.complete=!0:t.prototype._handleFragmentLoadComplete.call(this,i)},k.onBufferReset=function(){this.mediaBuffer=this.videoBuffer=null,this.loadedmetadata=!1},k.onBufferCreated=function(t,i){var n=i.tracks.audio;n&&(this.mediaBuffer=n.buffer),i.tracks.video&&(this.videoBuffer=i.tracks.video.buffer)},k.onFragBuffered=function(t,i){var n=i.frag,r=i.part;n.type===u.PlaylistLevelType.AUDIO&&(this.fragContextChanged(n)?this.warn("Fragment "+n.sn+(r?" p: "+r.index:"")+" of level "+n.level+" finished buffering, but was aborted. state: "+this.state+", audioSwitch: "+this.audioSwitch):("initSegment"!==n.sn&&(this.fragPrevious=n,this.audioSwitch&&(this.audioSwitch=!1,this.hls.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:this.trackId}))),this.fragBufferedComplete(n,r)))},k.onError=function(i,n){switch(n.details){case p.ErrorDetails.FRAG_LOAD_ERROR:case p.ErrorDetails.FRAG_LOAD_TIMEOUT:case p.ErrorDetails.KEY_LOAD_ERROR:case p.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.AUDIO,n);break;case p.ErrorDetails.AUDIO_TRACK_LOAD_ERROR:case p.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:this.state!==e.State.ERROR&&this.state!==e.State.STOPPED&&(this.state=n.fatal?e.State.ERROR:e.State.IDLE,this.warn(n.details+" while loading frag, switching to "+this.state+" state"));break;case p.ErrorDetails.BUFFER_FULL_ERROR:if("audio"===n.parent&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var r=!0,s=this.getFwdBufferInfo(this.mediaBuffer,u.PlaylistLevelType.AUDIO);s&&s.len>.5&&(r=!this.reduceMaxBufferLength(s.len)),r&&(this.warn("Buffer full error also media.currentTime is not buffered, flush audio buffer"),this.fragCurrent=null,t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.resetLoadingState()}}},k.onBufferFlushed=function(t,i){i.type===c.ElementaryStreamTypes.AUDIO&&(this.bufferFlushed=!0)},k._handleTransmuxComplete=function(t){var i,n="audio",r=this.hls,a=t.remuxResult,o=t.chunkMeta,h=this.getCurrentContext(o);if(!h)return this.warn("The loading context changed while buffering fragment "+o.sn+" of level "+o.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(o.level);var u=h.frag,f=h.part,l=a.audio,v=a.text,d=a.id3,m=a.initSegment;if(!this.fragContextChanged(u)){if(this.state=e.State.PARSING,this.audioSwitch&&l&&this.completeAudioSwitch(),null!=m&&m.tracks&&(this._bufferInitSegment(m.tracks,u,o),r.trigger(s.Events.FRAG_PARSING_INIT_SEGMENT,{frag:u,id:n,tracks:m.tracks})),l){var p=l.startPTS,g=l.endPTS,y=l.startDTS,w=l.endDTS;f&&(f.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:p,endPTS:g,startDTS:y,endDTS:w}),u.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,p,g,y,w),this.bufferFragmentData(l,u,f,o)}if(null!=d&&null!==(i=d.samples)&&void 0!==i&&i.length){var k=b({frag:u,id:n},d);r.trigger(s.Events.FRAG_PARSING_METADATA,k)}if(v){var T=b({frag:u,id:n},v);r.trigger(s.Events.FRAG_PARSING_USERDATA,T)}}},k._bufferInitSegment=function(t,i,n){if(this.state===e.State.PARSING){t.video&&delete t.video;var r=t.audio;if(r){r.levelCodec=r.codec,r.id="audio",this.log("Init audio buffer, container:"+r.container+", codecs[parsed]=["+r.codec+"]"),this.hls.trigger(s.Events.BUFFER_CODECS,t);var a=r.initSegment;null!=a&&a.byteLength&&this.hls.trigger(s.Events.BUFFER_APPENDING,{type:"audio",frag:i,part:null,chunkMeta:n,parent:i.type,data:a}),this.tick()}}},k.loadFragment=function(i,n,s){var a=this.fragmentTracker.getState(i);this.fragCurrent=i,(this.audioSwitch||a===o.FragmentState.NOT_LOADED||a===o.FragmentState.PARTIAL)&&("initSegment"===i.sn?this._loadInitSegment(i):n.live&&!Object(r.isFiniteNumber)(this.initPTS[i.cc])?(this.log("Waiting for video PTS in continuity counter "+i.cc+" of live stream before loading audio fragment "+i.sn+" of level "+this.trackId),this.state=e.State.WAITING_INIT_PTS):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,n,s)))},k.completeAudioSwitch=function(){var i=this.hls,n=this.trackId;this.media&&(this.log("Switching audio track : flushing all audio"),t.prototype.flushMainBuffer.call(this,0,Number.POSITIVE_INFINITY,"audio")),this.audioSwitch=!1,i.trigger(s.Events.AUDIO_TRACK_SWITCHED,{id:n})},w}(e.default);i.default=w},"./src/controller/audio-track-controller.ts":
26
+ /*!**************************************************!*\
27
+ !*** ./src/controller/audio-track-controller.ts ***!
28
+ \**************************************************/
29
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=n(/*! ../types/loader */"./src/types/loader.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,i){return h=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},h(t,i)}var u=function(t){var i,n;function s(i){var n;return(n=t.call(this,i,"[audio-track-controller]")||this).tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.trackName="",n.selectDefaultTrack=!0,n.registerListeners(),n}n=t,(i=s).prototype=Object.create(n.prototype),i.prototype.constructor=i,h(i,n);var u,c,f=s.prototype;return f.registerListeners=function(){var t=this.hls;t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(r.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.on(r.Events.ERROR,this.onError,this)},f.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(r.Events.AUDIO_TRACK_LOADED,this.onAudioTrackLoaded,this),t.off(r.Events.ERROR,this.onError,this)},f.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,t.prototype.destroy.call(this)},f.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.trackName="",this.selectDefaultTrack=!0},f.onManifestParsed=function(t,i){this.tracks=i.audioTracks||[]},f.onAudioTrackLoaded=function(t,i){var n=i.id,r=i.details,e=this.tracksInGroup[n];if(e){var s=e.details;e.details=i.details,this.log("audioTrack "+n+" loaded ["+r.startSN+"-"+r.endSN+"]"),n===this.trackId&&(this.retryCount=0,this.playlistLoaded(n,i,s))}else this.warn("Invalid audio track id "+n)},f.onLevelLoading=function(t,i){this.switchLevel(i.level)},f.onLevelSwitching=function(t,i){this.switchLevel(i.level)},f.switchLevel=function(t){var i=this.hls.levels[t];if(null!=i&&i.audioGroupIds){var n=i.audioGroupIds[i.urlId];if(this.groupId!==n){this.groupId=n;var e=this.tracks.filter((function(t){return!n||t.groupId===n}));this.selectDefaultTrack&&!e.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),this.tracksInGroup=e;var s={audioTracks:e};this.log("Updating audio tracks, "+e.length+' track(s) found in "'+n+'" group-id'),this.hls.trigger(r.Events.AUDIO_TRACKS_UPDATED,s),this.selectInitialTrack()}}},f.onError=function(i,n){t.prototype.onError.call(this,i,n),!n.fatal&&n.context&&n.context.type===a.PlaylistContextType.AUDIO_TRACK&&n.context.id===this.trackId&&n.context.groupId===this.groupId&&this.retryLoadingOrFail(n)},f.setAudioTrack=function(t){var i=this.tracksInGroup;if(t<0||t>=i.length)this.warn("Invalid id passed to audio-track controller");else{this.clearTimer();var n=i[this.trackId];this.log("Now switching to audio-track index "+t);var e=i[t],s=e.id,a=e.groupId,o=void 0===a?"":a,h=e.name,u=e.type,c=e.url;if(this.trackId=t,this.trackName=h,this.selectDefaultTrack=!1,this.hls.trigger(r.Events.AUDIO_TRACK_SWITCHING,{id:s,groupId:o,name:h,type:u,url:c}),!e.details||e.details.live){var f=this.switchParams(e.url,null==n?void 0:n.details);this.loadPlaylist(f)}}},f.selectInitialTrack=function(){console.assert(this.tracksInGroup.length,"Initial audio track should be selected when tracks are known");var t=this.findTrackId(this.trackName)||this.findTrackId();-1!==t?this.setAudioTrack(t):(this.warn("No track found for running audio group-ID: "+this.groupId),this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,fatal:!0}))},f.findTrackId=function(t){for(var i=this.tracksInGroup,n=0;n<i.length;n++){var r=i[n];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1},f.loadPlaylist=function(t){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var n=i.id,e=i.groupId,s=i.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("loading audio-track playlist for id: "+n),this.clearTimer(),this.hls.trigger(r.Events.AUDIO_TRACK_LOADING,{url:s,id:n,groupId:e,deliveryDirectives:t||null})}},u=s,(c=[{key:"audioTracks",get:function(){return this.tracksInGroup}},{key:"audioTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setAudioTrack(t)}}])&&o(u.prototype,c),s}(s.default);i.default=u},"./src/controller/base-playlist-controller.ts":
30
+ /*!****************************************************!*\
31
+ !*** ./src/controller/base-playlist-controller.ts ***!
32
+ \****************************************************/
33
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return h}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../types/level */"./src/types/level.ts"),s=n(/*! ./level-helper */"./src/controller/level-helper.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=function(){function t(t,i){this.hls=void 0,this.timer=-1,this.canLoad=!1,this.retryCount=0,this.log=void 0,this.warn=void 0,this.log=a.logger.log.bind(a.logger,i+":"),this.warn=a.logger.warn.bind(a.logger,i+":"),this.hls=t}var i=t.prototype;return i.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},i.onError=function(t,i){i.fatal&&i.type===o.ErrorTypes.NETWORK_ERROR&&this.clearTimer()},i.clearTimer=function(){clearTimeout(this.timer),this.timer=-1},i.startLoad=function(){this.canLoad=!0,this.retryCount=0,this.loadPlaylist()},i.stopLoad=function(){this.canLoad=!1,this.clearTimer()},i.switchParams=function(t,i){var n=null==i?void 0:i.renditionReports;if(n)for(var s=0;s<n.length;s++){var a=n[s],o=""+a.URI;if(o===t.substr(-o.length)){var h=parseInt(a["LAST-MSN"]),u=parseInt(a["LAST-PART"]);if(i&&this.hls.config.lowLatencyMode){var c=Math.min(i.age-i.partTarget,i.targetduration);void 0!==u&&c>i.partTarget&&(u+=1)}if(Object(r.isFiniteNumber)(h))return new e.HlsUrlParameters(h,Object(r.isFiniteNumber)(u)?u:void 0,e.HlsSkip.No)}}},i.loadPlaylist=function(){},i.shouldLoadTrack=function(t){return this.canLoad&&t&&!!t.url&&(!t.details||t.details.live)},i.playlistLoaded=function(t,i,n){var r=this,e=i.details,a=i.stats,o=a.loading.end?Math.max(0,self.performance.now()-a.loading.end):0;if(e.advancedDateTime=Date.now()-o,e.live||null!=n&&n.live){if(e.reloaded(n),n&&this.log("live playlist "+t+" "+(e.advanced?"REFRESHED "+e.lastPartSn+"-"+e.lastPartIndex:"MISSED")),n&&e.fragments.length>0&&Object(s.mergeDetails)(n,e),!this.canLoad||!e.live)return;var h,u=void 0,c=void 0;if(e.canBlockReload&&e.endSN&&e.advanced){var f=this.hls.config.lowLatencyMode,l=e.lastPartSn,v=e.endSN,d=e.lastPartIndex,m=l===v;-1!==d?(u=m?v+1:l,c=m?f?0:d:d+1):u=v+1;var p=e.age,g=Math.min(p+e.ageHeader-e.partTarget,1.5*e.targetduration);if(g>0){if(n&&g>n.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+n.tuneInGoal+" to: "+g+" with playlist age: "+e.age),g=0;else{var b=Math.floor(g/e.targetduration);u+=b,void 0!==c&&(c+=Math.round(g%e.targetduration/e.partTarget)),this.log("CDN Tune-in age: "+e.ageHeader+"s last advanced "+p.toFixed(2)+"s goal: "+g+" skip sn "+b+" to part "+c)}e.tuneInGoal=g}if(h=this.getDeliveryDirectives(e,i.deliveryDirectives,u,c),f||!m)return void this.loadPlaylist(h)}else h=this.getDeliveryDirectives(e,i.deliveryDirectives,u,c);var y=Object(s.computeReloadInterval)(e,a);void 0!==u&&e.canBlockReload&&(y-=e.partTarget||1),this.log("reload live playlist "+t+" in "+Math.round(y)+" ms"),this.timer=self.setTimeout((function(){return r.loadPlaylist(h)}),y)}else this.clearTimer()},i.getDeliveryDirectives=function(t,i,n,r){var s=Object(e.getSkipValue)(t,n);return null!=i&&i.skip&&t.deltaUpdateFailed&&(n=i.msn,r=i.part,s=e.HlsSkip.No),new e.HlsUrlParameters(n,r,s)},i.retryLoadingOrFail=function(t){var i,n=this,r=this.hls.config,e=this.retryCount<r.levelLoadingMaxRetry;if(e)if(this.retryCount++,t.details.indexOf("LoadTimeOut")>-1&&null!==(i=t.context)&&void 0!==i&&i.deliveryDirectives)this.warn("retry playlist loading #"+this.retryCount+' after "'+t.details+'"'),this.loadPlaylist();else{var s=Math.min(Math.pow(2,this.retryCount)*r.levelLoadingRetryDelay,r.levelLoadingMaxRetryTimeout);this.timer=self.setTimeout((function(){return n.loadPlaylist()}),s),this.warn("retry playlist loading #"+this.retryCount+" in "+s+' ms after "'+t.details+'"')}else this.warn('cannot recover from error "'+t.details+'"'),this.clearTimer(),t.fatal=!0;return e},t}()},"./src/controller/base-stream-controller.ts":
34
+ /*!**************************************************!*\
35
+ !*** ./src/controller/base-stream-controller.ts ***!
36
+ \**************************************************/
37
+ /*! exports provided: State, default */function(t,i,n){n.r(i),n.d(i,"State",(function(){return k})),n.d(i,"default",(function(){return T}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../task-loop */"./src/task-loop.ts"),s=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),a=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),o=n(/*! ../utils/logger */"./src/utils/logger.ts"),h=n(/*! ../events */"./src/events.ts"),u=n(/*! ../errors */"./src/errors.ts"),c=n(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),f=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),l=n(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),v=n(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),d=n(/*! ./level-helper */"./src/controller/level-helper.ts"),m=n(/*! ../loader/fragment-loader */"./src/loader/fragment-loader.ts"),p=n(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),g=n(/*! ../utils/time-ranges */"./src/utils/time-ranges.ts"),b=n(/*! ../types/loader */"./src/types/loader.ts");function y(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function w(t,i){return w=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},w(t,i)}var k={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",BACKTRACKING:"BACKTRACKING",ENDED:"ENDED",ERROR:"ERROR",WAITING_INIT_PTS:"WAITING_INIT_PTS",WAITING_LEVEL:"WAITING_LEVEL"},T=function(t){var i,n;function e(i,n,r){var e;return(e=t.call(this)||this).hls=void 0,e.fragPrevious=null,e.fragCurrent=null,e.fragmentTracker=void 0,e.transmuxer=null,e._state=k.STOPPED,e.media=void 0,e.mediaBuffer=void 0,e.config=void 0,e.bitrateTest=!1,e.lastCurrentTime=0,e.nextLoadPosition=0,e.startPosition=0,e.loadedmetadata=!1,e.fragLoadError=0,e.retryDate=0,e.levels=null,e.fragmentLoader=void 0,e.levelLastLoaded=null,e.startFragRequested=!1,e.decrypter=void 0,e.initPTS=[],e.onvseeking=null,e.onvended=null,e.logPrefix="",e.log=void 0,e.warn=void 0,e.logPrefix=r,e.log=o.logger.log.bind(o.logger,r+":"),e.warn=o.logger.warn.bind(o.logger,r+":"),e.hls=i,e.fragmentLoader=new m.default(i.config),e.fragmentTracker=n,e.config=i.config,e.decrypter=new p.default(i,i.config),i.on(h.Events.KEY_LOADED,e.onKeyLoaded,function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(e)),e}n=t,(i=e).prototype=Object.create(n.prototype),i.prototype.constructor=i,w(i,n);var T,O,S=e.prototype;return S.doTick=function(){this.onTickEnd()},S.onTickEnd=function(){},S.startLoad=function(){},S.stopLoad=function(){this.fragmentLoader.abort();var t=this.fragCurrent;t&&this.fragmentTracker.removeFragment(t),this.resetTransmuxer(),this.fragCurrent=null,this.fragPrevious=null,this.clearInterval(),this.clearNextTick(),this.state=k.STOPPED},S._streamEnded=function(t,i){var n=this.fragCurrent,r=this.fragmentTracker;if(!i.live&&n&&n.sn>=i.endSN&&!t.nextStart){var e=i.partList;if(null!=e&&e.length){var o=e[e.length-1];return a.BufferHelper.isBuffered(this.media,o.start+o.duration/2)}var h=r.getState(n);return h===s.FragmentState.PARTIAL||h===s.FragmentState.OK}return!1},S.onMediaAttached=function(t,i){var n=this.media=this.mediaBuffer=i.media;this.onvseeking=this.onMediaSeeking.bind(this),this.onvended=this.onMediaEnded.bind(this),n.addEventListener("seeking",this.onvseeking),n.addEventListener("ended",this.onvended);var r=this.config;this.levels&&r.autoStartLoad&&this.state===k.STOPPED&&this.startLoad(r.startPosition)},S.onMediaDetaching=function(){var t=this.media;null!=t&&t.ended&&(this.log("MSE detaching and video ended, reset startPosition"),this.startPosition=this.lastCurrentTime=0),t&&(t.removeEventListener("seeking",this.onvseeking),t.removeEventListener("ended",this.onvended),this.onvseeking=this.onvended=null),this.media=this.mediaBuffer=null,this.loadedmetadata=!1,this.fragmentTracker.removeAllFragments(),this.stopLoad()},S.onMediaSeeking=function(){var t=this.config,i=this.fragCurrent,n=this.media,e=this.state,s=n?n.currentTime:0,o=a.BufferHelper.bufferInfo(this.mediaBuffer||n,s,t.maxBufferHole);if(this.log("media seeking to "+(Object(r.isFiniteNumber)(s)?s.toFixed(3):s)+", state: "+e),e===k.ENDED)this.resetLoadingState();else if(i&&!o.len){var h=t.maxFragLookUpTolerance,u=s>i.start+i.duration+h;(s<i.start-h||u)&&(u&&i.loader&&(this.log("seeking outside of buffer while fragment load in progress, cancel fragment load"),i.loader.abort()),this.resetLoadingState())}n&&(this.lastCurrentTime=s),this.loadedmetadata||o.len||(this.nextLoadPosition=this.startPosition=s),this.tickImmediate()},S.onMediaEnded=function(){this.startPosition=this.lastCurrentTime=0},S.onKeyLoaded=function(t,i){if(this.state===k.KEY_LOADING&&i.frag===this.fragCurrent&&this.levels){this.state=k.IDLE;var n=this.levels[i.frag.level].details;n&&this.loadFragment(i.frag,n,i.frag.start)}},S.onHandlerDestroying=function(){this.stopLoad(),t.prototype.onHandlerDestroying.call(this)},S.onHandlerDestroyed=function(){this.state=k.STOPPED,this.hls.off(h.Events.KEY_LOADED,this.onKeyLoaded,this),this.fragmentLoader&&this.fragmentLoader.destroy(),this.decrypter&&this.decrypter.destroy(),this.hls=this.log=this.warn=this.decrypter=this.fragmentLoader=this.fragmentTracker=null,t.prototype.onHandlerDestroyed.call(this)},S.loadKey=function(t,i){this.log("Loading key for "+t.sn+" of ["+i.startSN+"-"+i.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=k.KEY_LOADING,this.fragCurrent=t,this.hls.trigger(h.Events.KEY_LOADING,{frag:t})},S.loadFragment=function(t,i,n){this._loadFragForPlayback(t,i,n)},S._loadFragForPlayback=function(t,i,n){var r=this;this._doFragLoad(t,i,n,(function(i){if(r.fragContextChanged(t))return r.warn("Fragment "+t.sn+(i.part?" p: "+i.part.index:"")+" of level "+t.level+" was dropped during download."),void r.fragmentTracker.removeFragment(t);t.stats.chunkCount++,r._handleFragmentLoadProgress(i)})).then((function(i){if(i){r.fragLoadError=0;var n=r.state;if(!r.fragContextChanged(t))return"payload"in i&&(r.log("Loaded fragment "+t.sn+" of level "+t.level),r.hls.trigger(h.Events.FRAG_LOADED,i),r.state===k.BACKTRACKING)?(r.fragmentTracker.backtrack(t,i),void r.resetFragmentLoading(t)):void r._handleFragmentLoadComplete(i);(n===k.FRAG_LOADING||n===k.BACKTRACKING||!r.fragCurrent&&n===k.PARSING)&&(r.fragmentTracker.removeFragment(t),r.state=k.IDLE)}})).catch((function(i){r.warn(i),r.resetFragmentLoading(t)}))},S.flushMainBuffer=function(t,i,n){if(void 0===n&&(n=null),t-i){var r={startOffset:t,endOffset:i,type:n};this.fragLoadError=0,this.hls.trigger(h.Events.BUFFER_FLUSHING,r)}},S._loadInitSegment=function(t){var i=this;this._doFragLoad(t).then((function(n){if(!n||i.fragContextChanged(t)||!i.levels)throw new Error("init load aborted");return n})).then((function(n){var r=i.hls,e=n.payload,s=t.decryptdata;if(e&&e.byteLength>0&&s&&s.key&&s.iv&&"AES-128"===s.method){var a=self.performance.now();return i.decrypter.webCryptoDecrypt(new Uint8Array(e),s.key.buffer,s.iv.buffer).then((function(i){var e=self.performance.now();return r.trigger(h.Events.FRAG_DECRYPTED,{frag:t,payload:i,stats:{tstart:a,tdecrypt:e}}),n.payload=i,n}))}return n})).then((function(n){var r=i.fragCurrent,e=i.hls,s=i.levels;if(!s)throw new Error("init load aborted, missing levels");console.assert(s[t.level].details,"Level details are defined when init segment is loaded");var a=t.stats;i.state=k.IDLE,i.fragLoadError=0,t.data=new Uint8Array(n.payload),a.parsing.start=a.buffering.start=self.performance.now(),a.parsing.end=a.buffering.end=self.performance.now(),n.frag===r&&e.trigger(h.Events.FRAG_BUFFERED,{stats:a,frag:r,part:null,id:t.type}),i.tick()})).catch((function(n){i.warn(n),i.resetFragmentLoading(t)}))},S.fragContextChanged=function(t){var i=this.fragCurrent;return!t||!i||t.level!==i.level||t.sn!==i.sn||t.urlId!==i.urlId},S.fragBufferedComplete=function(t,i){this.log("Buffered "+t.type+" sn: "+t.sn+(i?" part: "+i.index:"")+" of "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level+" "+g.default.toString(a.BufferHelper.getBuffered(this.mediaBuffer?this.mediaBuffer:this.media))),this.state=k.IDLE,this.tick()},S._handleFragmentLoadComplete=function(t){var i=this.transmuxer;if(i){var n=t.frag,r=t.part,e=t.partsLoaded,s=!e||0===e.length||e.some((function(t){return!t})),a=new c.ChunkMetadata(n.level,n.sn,n.stats.chunkCount+1,0,r?r.index:-1,!s);i.flush(a)}},S._handleFragmentLoadProgress=function(){},S._doFragLoad=function(t,i,n,e){var s=this;if(void 0===n&&(n=null),!this.levels)throw new Error("frag load aborted, missing levels");if(n=Math.max(t.start,n||0),this.config.lowLatencyMode&&i){var a=i.partList;if(a&&e){n>t.end&&i.fragmentHint&&(t=i.fragmentHint);var o=this.getNextPart(a,t,n);if(o>-1){var u=a[o];return this.log("Loading part sn: "+t.sn+" p: "+u.index+" cc: "+t.cc+" of playlist ["+i.startSN+"-"+i.endSN+"] parts [0-"+o+"-"+(a.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(n.toFixed(3))),this.nextLoadPosition=u.start+u.duration,this.state=k.FRAG_LOADING,this.hls.trigger(h.Events.FRAG_LOADING,{frag:t,part:a[o],targetBufferTime:n}),this.doFragPartsLoad(t,a,o,e).catch((function(t){return s.handleFragLoadError(t)}))}if(!t.url||this.loadedEndOfParts(a,n))return Promise.resolve(null)}}return this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(i?"of ["+i.startSN+"-"+i.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(n.toFixed(3))),Object(r.isFiniteNumber)(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=k.FRAG_LOADING,this.hls.trigger(h.Events.FRAG_LOADING,{frag:t,targetBufferTime:n}),this.fragmentLoader.load(t,e).catch((function(t){return s.handleFragLoadError(t)}))},S.doFragPartsLoad=function(t,i,n,r){var e=this;return new Promise((function(s,a){var o=[];!function n(u){var c=i[u];e.fragmentLoader.loadPart(t,c,r).then((function(r){o[c.index]=r;var a=r.part;e.hls.trigger(h.Events.FRAG_LOADED,r);var f=i[u+1];if(!f||f.fragment!==t)return s({frag:t,part:a,partsLoaded:o});n(u+1)})).catch(a)}(n)}))},S.handleFragLoadError=function(t){var i=t.data;return i&&i.details===u.ErrorDetails.INTERNAL_ABORTED?this.handleFragLoadAborted(i.frag,i.part):this.hls.trigger(h.Events.ERROR,i),null},S._handleTransmuxerFlush=function(t){var i=this.getCurrentContext(t);if(i&&this.state===k.PARSING){var n=i.frag,r=i.part,e=i.level,s=self.performance.now();n.stats.parsing.end=s,r&&(r.stats.parsing.end=s),this.updateLevelTiming(n,r,e,t.partial)}else this.fragCurrent||(this.state=k.IDLE)},S.getCurrentContext=function(t){var i=this.levels,n=t.level,r=t.sn,e=t.part;if(!i||!i[n])return this.warn("Levels object was unset while buffering fragment "+r+" of level "+n+". The current chunk will not be buffered."),null;var s=i[n],a=e>-1?Object(d.getPartWith)(s,r,e):null,o=a?a.fragment:Object(d.getFragmentWithSN)(s,r,this.fragCurrent);return o?{frag:o,part:a,level:s}:null},S.bufferFragmentData=function(t,i,n,r){if(t&&this.state===k.PARSING){var e=t.data1,s=t.data2,a=e;e&&s&&(a=Object(f.appendUint8Array)(e,s)),a&&a.length&&(this.hls.trigger(h.Events.BUFFER_APPENDING,{type:t.type,frag:i,part:n,chunkMeta:r,parent:i.type,data:a}),t.dropped&&t.independent&&!n&&this.flushBufferGap(i))}},S.flushBufferGap=function(t){var i=this.media;if(i)if(a.BufferHelper.isBuffered(i,i.currentTime)){var n=i.currentTime,r=a.BufferHelper.bufferInfo(i,n,0),e=Math.min(2*this.config.maxFragLookUpTolerance,.25*t.duration),s=Math.max(Math.min(t.start-e,r.end-e),n+e);t.start-s>e&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},S.getFwdBufferInfo=function(t,i){var n=this.config,e=this.getLoadPosition();if(!Object(r.isFiniteNumber)(e))return null;var s=a.BufferHelper.bufferInfo(t,e,n.maxBufferHole);if(0===s.len&&void 0!==s.nextStart){var o=this.fragmentTracker.getBufferedFrag(e,i);if(o&&s.nextStart<o.end)return a.BufferHelper.bufferInfo(t,e,Math.max(s.nextStart,n.maxBufferHole))}return s},S.getMaxBufferLength=function(t){var i,n=this.config;return i=t?Math.max(8*n.maxBufferSize/t,n.maxBufferLength):n.maxBufferLength,Math.min(i,n.maxMaxBufferLength)},S.reduceMaxBufferLength=function(t){var i=this.config;return i.maxMaxBufferLength>=(t||i.maxBufferLength)&&(i.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+i.maxMaxBufferLength+"s"),!0)},S.getNextFragment=function(t,i){var n,r,e=i.fragments,s=e.length;if(!s)return null;var a,o=this.config,h=e[0].start;if(i.live){var u=o.initialLiveManifestSize;if(s<u)return this.warn("Not enough fragments to start playback (have: "+s+", need: "+u+")"),null;i.PTSKnown||this.startFragRequested||-1!==this.startPosition||(a=this.getInitialLiveFragment(i,e),this.startPosition=a?this.hls.liveSyncPosition||a.start:t)}else t<=h&&(a=e[0]);return a||(a=this.getFragmentAtPosition(t,o.lowLatencyMode?i.partEnd:i.fragmentEnd,i)),null===(n=a)||void 0===n||!n.initSegment||null!==(r=a)&&void 0!==r&&r.initSegment.data||this.bitrateTest||(a=a.initSegment),a},S.getNextPart=function(t,i,n){for(var r=-1,e=!1,s=!0,a=0,o=t.length;a<o;a++){var h=t[a];if(s=s&&!h.independent,r>-1&&n<h.start)break;var u=h.loaded;!u&&(e||h.independent||s)&&h.fragment===i&&(r=a),e=u}return r},S.loadedEndOfParts=function(t,i){var n=t[t.length-1];return n&&i>n.start&&n.loaded},S.getInitialLiveFragment=function(t,i){var n=this.fragPrevious,r=null;if(n){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+n.programDateTime),r=Object(v.findFragmentByPDT)(i,n.endProgramDateTime,this.config.maxFragLookUpTolerance)),!r){var e=n.sn+1;if(e>=t.startSN&&e<=t.endSN){var s=i[e-t.startSN];n.cc===s.cc&&this.log("Live playlist, switching playlist, load frag with next SN: "+(r=s).sn)}r||(r=Object(v.findFragWithCC)(i,n.cc))&&this.log("Live playlist, switching playlist, load frag with same CC: "+r.sn)}}else{var a=this.hls.liveSyncPosition;null!==a&&(r=this.getFragmentAtPosition(a,this.bitrateTest?t.fragmentEnd:t.edge,t))}return r},S.getFragmentAtPosition=function(t,i,n){var r,e=this.config,a=this.fragPrevious,o=n.fragments,h=n.endSN,u=n.fragmentHint,c=e.maxFragLookUpTolerance,f=!!(e.lowLatencyMode&&n.partList&&u);if(f&&u&&!this.bitrateTest&&(o=o.concat(u),h=u.sn),t<i){var l=t>i-c?0:c;r=Object(v.findFragmentByPTS)(a,o,t,l)}else r=o[o.length-1];if(r){var d=r.sn-n.startSN,m=a&&r.level===a.level,p=o[d+1];if(this.fragmentTracker.getState(r)===s.FragmentState.BACKTRACKED){r=null;for(var g=d;o[g]&&this.fragmentTracker.getState(o[g])===s.FragmentState.BACKTRACKED;)r=a?o[g--]:o[--g];r||(r=p)}else a&&r.sn===a.sn&&!f&&m&&(r.sn<h&&this.fragmentTracker.getState(p)!==s.FragmentState.OK?(this.log("SN "+r.sn+" just loaded, load next one: "+p.sn),r=p):r=null)}return r},S.synchronizeToLiveEdge=function(t){var i=this.config,n=this.media;if(n){var r=this.hls.liveSyncPosition,e=n.currentTime,s=t.edge,a=e>=t.fragments[0].start-i.maxFragLookUpTolerance&&e<=s;null!==r&&n.duration>r&&(e<r||!a)&&(!a&&n.readyState<4||e<s-(void 0!==i.liveMaxLatencyDuration?i.liveMaxLatencyDuration:i.liveMaxLatencyDurationCount*t.targetduration))&&(this.loadedmetadata||(this.nextLoadPosition=r),n.readyState&&(this.warn("Playback: "+e.toFixed(3)+" is located too far from the end of live sliding playlist: "+s+", reset currentTime to : "+r.toFixed(3)),n.currentTime=r))}},S.alignPlaylists=function(t,i){var n=this.levelLastLoaded,e=this.fragPrevious,s=null!==n?this.levels[n]:null,a=t.fragments.length;if(!a)return this.warn("No fragments in live playlist"),0;var o=t.fragments[0].start,h=!i,u=t.alignedSliding&&Object(r.isFiniteNumber)(o);if(h||!u&&!o){Object(l.alignStream)(e,s,t);var c=t.fragments[0].start;return this.log("Live playlist sliding: "+c.toFixed(2)+" start-sn: "+(i?i.startSN:"na")+"->"+t.startSN+" prev-sn: "+(e?e.sn:"na")+" fragments: "+a),c}return o},S.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},S.setStartPosition=function(t,i){var n=this.startPosition;if(n<i&&(n=-1),-1===n||-1===this.lastCurrentTime){var e=t.startTimeOffset;Object(r.isFiniteNumber)(e)?(n=i+e,e<0&&(n+=t.totalduration),n=Math.min(Math.max(i,n),i+t.totalduration),this.log("Start time offset "+e+" found in playlist, adjust startPosition to "+n),this.startPosition=n):t.live?n=this.hls.liveSyncPosition||i:this.startPosition=n=0,this.lastCurrentTime=n}this.nextLoadPosition=n},S.getLoadPosition=function(){var t=this.media,i=0;return this.loadedmetadata&&t?i=t.currentTime:this.nextLoadPosition&&(i=this.nextLoadPosition),i},S.handleFragLoadAborted=function(t,i){this.transmuxer&&"initSegment"!==t.sn&&t.stats.aborted&&(this.warn("Fragment "+t.sn+(i?" part"+i.index:"")+" of level "+t.level+" was aborted"),this.resetFragmentLoading(t))},S.resetFragmentLoading=function(t){this.fragCurrent&&this.fragContextChanged(t)||(this.state=k.IDLE)},S.onFragmentOrKeyLoadError=function(t,i){if(!i.fatal){var n=i.frag;if(n&&n.type===t){var r=this.fragCurrent;console.assert(r&&n.sn===r.sn&&n.level===r.level&&n.urlId===r.urlId,"Frag load error must match current frag to retry");var e=this.config;if(this.fragLoadError+1<=e.fragLoadingMaxRetry){if(this.resetLiveStartWhenNotLoaded(n.level))return;var s=Math.min(Math.pow(2,this.fragLoadError)*e.fragLoadingRetryDelay,e.fragLoadingMaxRetryTimeout);this.warn("Fragment "+n.sn+" of "+t+" "+n.level+" failed to load, retrying in "+s+"ms"),this.retryDate=self.performance.now()+s,this.fragLoadError++,this.state=k.FRAG_LOADING_WAITING_RETRY}else i.levelRetry?(t===b.PlaylistLevelType.AUDIO&&(this.fragCurrent=null),this.fragLoadError=0,this.state=k.IDLE):(o.logger.error(i.details+" reaches max retry, redispatch as fatal ..."),i.fatal=!0,this.hls.stopLoad(),this.state=k.ERROR)}}},S.afterBufferFlushed=function(t,i,n){if(t){var r=a.BufferHelper.getBuffered(t);this.fragmentTracker.detectEvictedFragments(i,r,n),this.state===k.ENDED&&this.resetLoadingState()}},S.resetLoadingState=function(){this.fragCurrent=null,this.fragPrevious=null,this.state=k.IDLE},S.resetLiveStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var i=this.levels?this.levels[t].details:null;if(null!=i&&i.live)return this.startPosition=-1,this.setStartPosition(i,0),this.resetLoadingState(),!0;this.nextLoadPosition=this.startPosition}return!1},S.updateLevelTiming=function(t,i,n,r){var e=this,s=n.details;console.assert(!!s,"level.details must be defined"),Object.keys(t.elementaryStreams).reduce((function(i,a){var o=t.elementaryStreams[a];if(o){var u=o.endPTS-o.startPTS;if(u<=0)return e.warn("Could not parse fragment "+t.sn+" "+a+" duration reliably ("+u+") resetting transmuxer to fallback to playlist timing"),e.resetTransmuxer(),i||!1;var c=r?0:Object(d.updateFragPTSDTS)(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return e.hls.trigger(h.Events.LEVEL_PTS_UPDATED,{details:s,level:n,drift:c,type:a,frag:t,start:o.startPTS,end:o.endPTS}),!0}return i}),!1)?(this.state=k.PARSED,this.hls.trigger(h.Events.FRAG_PARSED,{frag:t,part:i})):this.resetLoadingState()},S.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},T=e,(O=[{key:"state",get:function(){return this._state},set:function(t){var i=this._state;i!==t&&(this._state=t,this.log(i+"->"+t))}}])&&y(T.prototype,O),e}(e.default)},"./src/controller/buffer-controller.ts":
38
+ /*!*********************************************!*\
39
+ !*** ./src/controller/buffer-controller.ts ***!
40
+ \*********************************************/
41
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return v}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ../errors */"./src/errors.ts"),o=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),h=n(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),c=n(/*! ./buffer-operation-queue */"./src/controller/buffer-operation-queue.ts"),f=Object(h.getMediaSource)(),l=/([ha]vc.)(?:\.[^.,]+)+/,v=function(){function t(t){var i=this;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.appendError=0,this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this._onMediaSourceOpen=function(){var t=i.hls,n=i.media,r=i.mediaSource;s.logger.log("[buffer-controller]: Media source opened"),n&&(i.updateMediaElementDuration(),t.trigger(e.Events.MEDIA_ATTACHED,{media:n})),r&&r.removeEventListener("sourceopen",i._onMediaSourceOpen),i.checkPendingTracks()},this._onMediaSourceClose=function(){s.logger.log("[buffer-controller]: Media source closed")},this._onMediaSourceEnded=function(){s.logger.log("[buffer-controller]: Media source ended")},this.hls=t,this._initSourceBuffer(),this.registerListeners()}var i=t.prototype;return i.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},i.destroy=function(){this.unregisterListeners(),this.details=null},i.registerListeners=function(){var t=this.hls;t.on(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(e.Events.BUFFER_RESET,this.onBufferReset,this),t.on(e.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.on(e.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(e.Events.BUFFER_EOS,this.onBufferEos,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(e.Events.FRAG_PARSED,this.onFragParsed,this),t.on(e.Events.FRAG_CHANGED,this.onFragChanged,this)},i.unregisterListeners=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(e.Events.BUFFER_RESET,this.onBufferReset,this),t.off(e.Events.BUFFER_APPENDING,this.onBufferAppending,this),t.off(e.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(e.Events.BUFFER_EOS,this.onBufferEos,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(e.Events.FRAG_PARSED,this.onFragParsed,this),t.off(e.Events.FRAG_CHANGED,this.onFragChanged,this)},i._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new c.default(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]}},i.onManifestParsed=function(t,i){var n=2;(i.audio&&!i.video||!i.altAudio)&&(n=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=n,this.details=null,s.logger.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},i.onMediaAttaching=function(t,i){var n=this.media=i.media;if(n&&f){var r=this.mediaSource=new f;r.addEventListener("sourceopen",this._onMediaSourceOpen),r.addEventListener("sourceended",this._onMediaSourceEnded),r.addEventListener("sourceclose",this._onMediaSourceClose),n.src=self.URL.createObjectURL(r),this._objectUrl=n.src}},i.onMediaDetaching=function(){var t=this.media,i=this.mediaSource,n=this._objectUrl;if(i){if(s.logger.log("[buffer-controller]: media source detaching"),"open"===i.readyState)try{i.endOfStream()}catch(t){s.logger.warn("[buffer-controller]: onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),i.removeEventListener("sourceopen",this._onMediaSourceOpen),i.removeEventListener("sourceended",this._onMediaSourceEnded),i.removeEventListener("sourceclose",this._onMediaSourceClose),t&&(n&&self.URL.revokeObjectURL(n),t.src===n?(t.removeAttribute("src"),t.load()):s.logger.warn("[buffer-controller]: media.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.Events.MEDIA_DETACHED,void 0)},i.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(i){var n=t.sourceBuffer[i];try{n&&(t.removeBufferListeners(i),t.mediaSource&&t.mediaSource.removeSourceBuffer(n),t.sourceBuffer[i]=void 0)}catch(t){s.logger.warn("[buffer-controller]: Failed to reset the "+i+" buffer",t)}})),this._initSourceBuffer()},i.onBufferCodecs=function(t,i){var n=this,r=this.getSourceBufferTypes().length;Object.keys(i).forEach((function(t){if(r){var e=n.tracks[t];if(e&&"function"==typeof e.buffer.changeType){var s=i[t],a=s.codec,o=s.levelCodec,h=s.container;(e.levelCodec||e.codec).replace(l,"$1")!==(o||a).replace(l,"$1")&&n.appendChangeType(t,h+";codecs="+(o||a))}}else n.pendingTracks[t]=i[t]})),r||(this.bufferCodecEventsExpected=Math.max(this.bufferCodecEventsExpected-1,0),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks())},i.appendChangeType=function(t,i){var n=this,r=this.operationQueue,e={execute:function(){var e=n.sourceBuffer[t];e&&(s.logger.log("[buffer-controller]: changing "+t+" sourceBuffer type to "+i),e.changeType(i)),r.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(i){s.logger.warn("[buffer-controller]: Failed to change "+t+" SourceBuffer type",i)}};r.append(e,t)},i.onBufferAppending=function(t,i){var n=this,r=this.hls,h=this.operationQueue,u=this.tracks,c=i.data,f=i.type,l=i.frag,v=i.part,d=i.chunkMeta,m=d.buffering[f],p=self.performance.now();m.start=p;var g=l.stats.buffering,b=v?v.stats.buffering:null;0===g.start&&(g.start=p),b&&0===b.start&&(b.start=p);var y=u.audio,w="audio"===f&&1===d.id&&"audio/mpeg"===(null==y?void 0:y.container),k={execute:function(){if(m.executeStart=self.performance.now(),w){var t=n.sourceBuffer[f];if(t){var i=l.start-t.timestampOffset;Math.abs(i)>=.1&&(s.logger.log("[buffer-controller]: Updating audio SourceBuffer timestampOffset to "+l.start+" (delta: "+i+") sn: "+l.sn+")"),t.timestampOffset=l.start)}}n.appendExecutor(c,f)},onStart:function(){},onComplete:function(){var t=self.performance.now();m.executeEnd=m.end=t,0===g.first&&(g.first=t),b&&0===b.first&&(b.first=t);var i=n.sourceBuffer,r={};for(var s in i)r[s]=o.BufferHelper.getBuffered(i[s]);n.appendError=0,n.hls.trigger(e.Events.BUFFER_APPENDED,{type:f,frag:l,part:v,chunkMeta:d,parent:l.type,timeRanges:r})},onError:function(t){s.logger.error("[buffer-controller]: Error encountered while trying to append to the "+f+" SourceBuffer",t);var i={type:a.ErrorTypes.MEDIA_ERROR,parent:l.type,details:a.ErrorDetails.BUFFER_APPEND_ERROR,err:t,fatal:!1};t.code===DOMException.QUOTA_EXCEEDED_ERR?i.details=a.ErrorDetails.BUFFER_FULL_ERROR:(n.appendError++,i.details=a.ErrorDetails.BUFFER_APPEND_ERROR,n.appendError>r.config.appendErrorMaxRetry&&(s.logger.error("[buffer-controller]: Failed "+r.config.appendErrorMaxRetry+" times to append segment in sourceBuffer"),i.fatal=!0)),r.trigger(e.Events.ERROR,i)}};h.append(k,f)},i.onBufferFlushing=function(t,i){var n=this,r=this.operationQueue,a=function(t){return{execute:n.removeExecutor.bind(n,t,i.startOffset,i.endOffset),onStart:function(){},onComplete:function(){n.hls.trigger(e.Events.BUFFER_FLUSHED,{type:t})},onError:function(i){s.logger.warn("[buffer-controller]: Failed to remove from "+t+" SourceBuffer",i)}}};i.type?r.append(a(i.type),i.type):this.getSourceBufferTypes().forEach((function(t){r.append(a(t),t)}))},i.onFragParsed=function(t,i){var n=this,r=i.frag,a=i.part,o=[],h=a?a.elementaryStreams:r.elementaryStreams;h[u.ElementaryStreamTypes.AUDIOVIDEO]?o.push("audiovideo"):(h[u.ElementaryStreamTypes.AUDIO]&&o.push("audio"),h[u.ElementaryStreamTypes.VIDEO]&&o.push("video")),0===o.length&&s.logger.warn("Fragments must have at least one ElementaryStreamType set. type: "+r.type+" level: "+r.level+" sn: "+r.sn),this.blockBuffers((function(){var t=self.performance.now();r.stats.buffering.end=t,a&&(a.stats.buffering.end=t),n.hls.trigger(e.Events.FRAG_BUFFERED,{frag:r,part:a,stats:a?a.stats:r.stats,id:r.type})}),o)},i.onFragChanged=function(){this.flushBackBuffer()},i.onBufferEos=function(t,i){var n=this;this.getSourceBufferTypes().reduce((function(t,r){var e=n.sourceBuffer[r];return i.type&&i.type!==r||e&&!e.ended&&(e.ended=!0,s.logger.log("[buffer-controller]: "+r+" sourceBuffer now EOS")),t&&!(e&&!e.ended)}),!0)&&this.blockBuffers((function(){var t=n.mediaSource;t&&"open"===t.readyState&&t.endOfStream()}))},i.onLevelUpdated=function(t,i){var n=i.details;n.fragments.length&&(this.details=n,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},i.flushBackBuffer=function(){var t=this.hls,i=this.details,n=this.media,s=this.sourceBuffer;if(n&&null!==i){var a=this.getSourceBufferTypes();if(a.length){var h=i.live&&null!==t.config.liveBackBufferLength?t.config.liveBackBufferLength:t.config.backBufferLength;if(Object(r.isFiniteNumber)(h)&&!(h<0)){var u=n.currentTime,c=i.levelTargetDuration,f=Math.max(h,c),l=Math.floor(u/c)*c-f;a.forEach((function(n){var r=s[n];if(r){var a=o.BufferHelper.getBuffered(r);a.length>0&&l>a.start(0)&&(t.trigger(e.Events.BACK_BUFFER_REACHED,{bufferEnd:l}),i.live&&t.trigger(e.Events.LIVE_BACK_BUFFER_REACHED,{bufferEnd:l}),t.trigger(e.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:l,type:n}))}}))}}}},i.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,i=this.hls,n=this.mediaSource,e=t.fragments[0].start+t.totalduration,a=this.media.duration,o=Object(r.isFiniteNumber)(n.duration)?n.duration:0;t.live&&i.config.liveDurationInfinity?(s.logger.log("[buffer-controller]: Media Source duration is set to Infinity"),n.duration=1/0,this.updateSeekableRange(t)):(e>o&&e>a||!Object(r.isFiniteNumber)(a))&&(s.logger.log("[buffer-controller]: Updating Media Source duration to "+e.toFixed(3)),n.duration=e)}},i.updateSeekableRange=function(t){var i=this.mediaSource,n=t.fragments;if(n.length&&t.live&&null!=i&&i.setLiveSeekableRange){var r=Math.max(0,n[0].start),e=Math.max(r,r+t.totalduration);i.setLiveSeekableRange(r,e)}},i.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,i=this.operationQueue,n=this.pendingTracks,r=Object.keys(n).length;if(r&&!t||2===r){this.createSourceBuffers(n),this.pendingTracks={};var s=this.getSourceBufferTypes();if(0===s.length)return void this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,reason:"could not create source buffer for media codec(s)"});s.forEach((function(t){i.executeNext(t)}))}},i.createSourceBuffers=function(t){var i=this.sourceBuffer,n=this.mediaSource;if(!n)throw Error("createSourceBuffers called when mediaSource was null");var r=0;for(var o in t)if(!i[o]){var h=t[o];if(!h)throw Error("source buffer exists for track "+o+", however track does not");var u=h.levelCodec||h.codec,c=h.container+";codecs="+u;s.logger.log("[buffer-controller]: creating sourceBuffer("+c+")");try{var f=i[o]=n.addSourceBuffer(c),l=o;this.addBufferListener(l,"updatestart",this._onSBUpdateStart),this.addBufferListener(l,"updateend",this._onSBUpdateEnd),this.addBufferListener(l,"error",this._onSBUpdateError),this.tracks[o]={buffer:f,codec:u,container:h.container,levelCodec:h.levelCodec,id:h.id},r++}catch(t){s.logger.error("[buffer-controller]: error while trying to add sourceBuffer: "+t.message),this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,mimeType:c})}}r&&this.hls.trigger(e.Events.BUFFER_CREATED,{tracks:this.tracks})},i._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},i._onSBUpdateEnd=function(t){var i=this.operationQueue;i.current(t).onComplete(),i.shiftAndExecuteNext(t)},i._onSBUpdateError=function(t,i){s.logger.error("[buffer-controller]: "+t+" SourceBuffer error",i),this.hls.trigger(e.Events.ERROR,{type:a.ErrorTypes.MEDIA_ERROR,details:a.ErrorDetails.BUFFER_APPENDING_ERROR,fatal:!1});var n=this.operationQueue.current(t);n&&n.onError(i)},i.removeExecutor=function(t,i,n){var e=this.media,a=this.mediaSource,o=this.operationQueue,h=this.sourceBuffer[t];if(!e||!a||!h)return s.logger.warn("[buffer-controller]: Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void o.shiftAndExecuteNext(t);var u=Object(r.isFiniteNumber)(e.duration)?e.duration:1/0,c=Object(r.isFiniteNumber)(a.duration)?a.duration:1/0,f=Math.max(0,i),l=Math.min(n,u,c);l>f?(s.logger.log("[buffer-controller]: Removing ["+f+","+l+"] from the "+t+" SourceBuffer"),console.assert(!h.updating,t+" sourceBuffer must not be updating"),h.remove(f,l)):o.shiftAndExecuteNext(t)},i.appendExecutor=function(t,i){var n=this.operationQueue,r=this.sourceBuffer[i];if(!r)return s.logger.warn("[buffer-controller]: Attempting to append to the "+i+" SourceBuffer, but it does not exist"),void n.shiftAndExecuteNext(i);r.ended=!1,console.assert(!r.updating,i+" sourceBuffer must not be updating"),r.appendBuffer(t)},i.blockBuffers=function(t,i){var n=this;if(void 0===i&&(i=this.getSourceBufferTypes()),i.length){var r=this.operationQueue,e=i.map((function(t){return r.appendBlocker(t)}));Promise.all(e).then((function(){t(),i.forEach((function(t){var i=n.sourceBuffer[t];i&&i.updating||r.shiftAndExecuteNext(t)}))}))}else s.logger.log("[buffer-controller]: Blocking operation requested, but no SourceBuffers exist")},i.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},i.addBufferListener=function(t,i,n){var r=this.sourceBuffer[t];if(r){var e=n.bind(this,t);this.listeners[t].push({event:i,listener:e}),r.addEventListener(i,e)}},i.removeBufferListeners=function(t){var i=this.sourceBuffer[t];i&&this.listeners[t].forEach((function(t){i.removeEventListener(t.event,t.listener)}))},t}()},"./src/controller/buffer-operation-queue.ts":
42
+ /*!**************************************************!*\
43
+ !*** ./src/controller/buffer-operation-queue.ts ***!
44
+ \**************************************************/
45
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return e}));var r=n(/*! ../utils/logger */"./src/utils/logger.ts"),e=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var i=t.prototype;return i.append=function(t,i){var n=this.queues[i];n.push(t),1===n.length&&this.buffers[i]&&this.executeNext(i)},i.insertAbort=function(t,i){this.queues[i].unshift(t),this.executeNext(i)},i.appendBlocker=function(t){var i,n=new Promise((function(t){i=t}));return this.append({execute:i,onStart:function(){},onComplete:function(){},onError:function(){}},t),n},i.executeNext=function(t){var i=this.buffers[t],n=this.queues[t];if(n.length){var e=n[0];try{e.execute()}catch(s){r.logger.warn("[buffer-operation-queue]: Unhandled exception executing the current operation"),e.onError(s),i&&i.updating||(n.shift(),this.executeNext(t))}}},i.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},i.current=function(t){return this.queues[t][0]},t}()},"./src/controller/cap-level-controller.ts":
46
+ /*!************************************************!*\
47
+ !*** ./src/controller/cap-level-controller.ts ***!
48
+ \************************************************/
49
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts");function e(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(t){this.autoLevelCapping=void 0,this.firstLevel=void 0,this.media=void 0,this.restrictedLevels=void 0,this.timer=void 0,this.hls=void 0,this.streamController=void 0,this.clientRect=void 0,this.hls=t,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.firstLevel=-1,this.media=null,this.restrictedLevels=[],this.timer=void 0,this.clientRect=null,this.registerListeners()}var i,n,s,a=t.prototype;return a.setStreamController=function(t){this.streamController=t},a.destroy=function(){this.unregisterListener(),this.hls.config.capLevelToPlayerSize&&this.stopCapping(),this.media=null,this.clientRect=null,this.hls=this.streamController=null},a.registerListeners=function(){var t=this.hls;t.on(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.unregisterListener=function(){var t=this.hls;t.off(r.Events.FPS_DROP_LEVEL_CAPPING,this.onFpsDropLevelCapping,this),t.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.BUFFER_CODECS,this.onBufferCodecs,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this)},a.onFpsDropLevelCapping=function(i,n){t.isLevelAllowed(n.droppedLevel,this.restrictedLevels)&&this.restrictedLevels.push(n.droppedLevel)},a.onMediaAttaching=function(t,i){this.media=i.media instanceof HTMLVideoElement?i.media:null},a.onManifestParsed=function(t,i){var n=this.hls;this.restrictedLevels=[],this.firstLevel=i.firstLevel,n.config.capLevelToPlayerSize&&i.video&&this.startCapping()},a.onBufferCodecs=function(t,i){this.hls.config.capLevelToPlayerSize&&i.video&&this.startCapping()},a.onMediaDetaching=function(){this.stopCapping()},a.detectPlayerSize=function(){if(this.media&&this.mediaHeight>0&&this.mediaWidth>0){var t=this.hls.levels;if(t.length){var i=this.hls;i.autoLevelCapping=this.getMaxLevel(t.length-1),i.autoLevelCapping>this.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=i.autoLevelCapping}}},a.getMaxLevel=function(i){var n=this,r=this.hls.levels;if(!r.length)return-1;var e=r.filter((function(r,e){return t.isLevelAllowed(e,n.restrictedLevels)&&e<=i}));return this.clientRect=null,t.getMaxLevelByMediaSize(e,this.mediaWidth,this.mediaHeight)},a.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,this.hls.firstLevel=this.getMaxLevel(this.firstLevel),self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},a.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},a.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,i={width:0,height:0};if(t){var n=t.getBoundingClientRect();i.width=n.width,i.height=n.height,i.width||i.height||(i.width=n.right-n.left||t.width||0,i.height=n.bottom-n.top||t.height||0)}return this.clientRect=i,i},t.isLevelAllowed=function(t,i){return void 0===i&&(i=[]),-1===i.indexOf(t)},t.getMaxLevelByMediaSize=function(t,i,n){if(!t||!t.length)return-1;for(var r,e,s=t.length-1,a=0;a<t.length;a+=1){var o=t[a];if((o.width>=i||o.height>=n)&&(r=o,!(e=t[a+1])||r.width!==e.width||r.height!==e.height)){s=a;break}}return s},i=t,s=[{key:"contentScaleFactor",get:function(){var t=1;try{t=self.devicePixelRatio}catch(t){}return t}}],(n=[{key:"mediaWidth",get:function(){return this.getDimensions().width*t.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*t.contentScaleFactor}}])&&e(i.prototype,n),s&&e(i,s),t}();i.default=s},"./src/controller/cmcd-controller.ts":
50
+ /*!*******************************************!*\
51
+ !*** ./src/controller/cmcd-controller.ts ***!
52
+ \*******************************************/
53
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return l}));var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../types/cmcd */"./src/types/cmcd.ts"),s=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,i,n){return i&&o(t.prototype,i),n&&o(t,n),t}function u(t,i){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(n)return(n=n.call(t)).next.bind(n);if(Array.isArray(t)||(n=function(t,i){if(t){if("string"==typeof t)return c(t,i);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?c(t,i):void 0}}(t))||i&&t&&"number"==typeof t.length){n&&(t=n);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(t,i){(null==i||i>t.length)&&(i=t.length);for(var n=0,r=new Array(i);n<i;n++)r[n]=t[n];return r}function f(){return f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f.apply(this,arguments)}var l=function(){function t(i){var n=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){n.initialized&&(n.starved=!0),n.buffering=!0},this.onPlaying=function(){n.initialized||(n.initialized=!0),n.buffering=!1},this.applyPlaylistData=function(t){try{n.apply(t,{ot:e.CMCDObjectType.MANIFEST,su:!n.initialized})}catch(t){a.logger.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var i=t.frag,r=n.hls.levels[i.level],s=n.getObjectType(i),o={d:1e3*i.duration,ot:s};s!==e.CMCDObjectType.VIDEO&&s!==e.CMCDObjectType.AUDIO&&s!=e.CMCDObjectType.MUXED||(o.br=r.bitrate/1e3,o.tb=n.getTopBandwidth(s)/1e3,o.bl=n.getBufferLength(s)),n.apply(t,o)}catch(t){a.logger.warn("Could not generate segment CMCD data.",t)}},this.hls=i;var r=this.config=i.config,s=r.cmcd;null!=s&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=s.sessionId||t.uuid(),this.cid=s.contentId,this.useHeaders=!0===s.useHeaders,this.registerListeners())}var i=t.prototype;return i.registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.on(r.Events.BUFFER_CREATED,this.onBufferCreated,this)},i.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),t.off(r.Events.BUFFER_CREATED,this.onBufferCreated,this),this.onMediaDetached()},i.destroy=function(){this.unregisterListeners(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null},i.onMediaAttached=function(t,i){this.media=i.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},i.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},i.onBufferCreated=function(t,i){var n,r;this.audioBuffer=null===(n=i.tracks.audio)||void 0===n?void 0:n.buffer,this.videoBuffer=null===(r=i.tracks.video)||void 0===r?void 0:r.buffer},i.createData=function(){var t;return{v:e.CMCDVersion,sf:e.CMCDStreamingFormat.HLS,sid:this.sid,cid:this.cid,pr:null===(t=this.media)||void 0===t?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},i.apply=function(i,n){if(void 0===n&&(n={}),f(n,this.createData()),this.starved&&(n.ot===e.CMCDObjectType.INIT||n.ot===e.CMCDObjectType.VIDEO||n.ot===e.CMCDObjectType.MUXED)&&(n.bs=!0,n.su=!0,this.starved=!1),null==n.su&&(n.su=this.buffering),this.useHeaders){var r=t.toHeaders(n);if(!Object.keys(r).length)return;i.headers||(i.headers={}),f(i.headers,r)}else{var s=t.toQuery(n);if(!s)return;i.url=t.appendQueryToUri(i.url,s)}},i.getObjectType=function(t){var i=t.type;return"subtitle"===i?e.CMCDObjectType.TIMED_TEXT:"initSegment"===t.sn?e.CMCDObjectType.INIT:"audio"===i?e.CMCDObjectType.AUDIO:"main"===i?this.hls.audioTracks.length?e.CMCDObjectType.VIDEO:e.CMCDObjectType.MUXED:void 0},i.getTopBandwidth=function(t){var i,n=0,r=this.hls;if(t===e.CMCDObjectType.AUDIO)i=r.audioTracks;else{var s=r.maxAutoLevel;i=r.levels.slice(0,s>-1?s+1:r.levels.length)}for(var a,o=u(i);!(a=o()).done;){var h=a.value;h.bitrate>n&&(n=h.bitrate)}return n>0?n:NaN},i.getBufferLength=function(t){var i=this.hls.media,n=t===e.CMCDObjectType.AUDIO?this.audioBuffer:this.videoBuffer;return n&&i?1e3*s.BufferHelper.bufferInfo(n,i.currentTime,this.config.maxBufferHole).len:NaN},i.createPlaylistLoader=function(){var t=this.applyPlaylistData,i=this.config.pLoader||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new i(t)}var r=n.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(i,n,r){t(i),this.loader.load(i,n,r)},h(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},i.createFragmentLoader=function(){var t=this.applyFragmentData,i=this.config.fLoader||this.config.loader;return function(){function n(t){this.loader=void 0,this.loader=new i(t)}var r=n.prototype;return r.destroy=function(){this.loader.destroy()},r.abort=function(){this.loader.abort()},r.load=function(i,n,r){t(i),this.loader.load(i,n,r)},h(n,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),n}()},t.uuid=function(){var t=URL.createObjectURL(new Blob),i=t.toString();return URL.revokeObjectURL(t),i.substr(i.lastIndexOf("/")+1)},t.serialize=function(t){for(var i,n=[],r=function(t){return!Number.isNaN(t)&&null!=t&&""!==t&&!1!==t},e=function(t){return Math.round(t)},s=function(t){return 100*e(t/100)},a={br:e,d:e,bl:s,dl:s,mtp:s,nor:function(t){return encodeURIComponent(t)},rtp:s,tb:e},o=u(Object.keys(t||{}).sort());!(i=o()).done;){var h=i.value,c=t[h];if(r(c)&&!("v"===h&&1===c||"pr"==h&&1===c)){var f=a[h];f&&(c=f(c));var l,v=typeof c;l="ot"===h||"sf"===h||"st"===h?h+"="+c:"boolean"===v?h:"number"===v?h+"="+c:h+"="+JSON.stringify(c),n.push(l)}}return n.join(",")},t.toHeaders=function(i){for(var n={},r=["Object","Request","Session","Status"],e=[{},{},{},{}],s={br:0,d:0,ot:0,tb:0,bl:1,dl:1,mtp:1,nor:1,nrr:1,su:1,cid:2,pr:2,sf:2,sid:2,st:2,v:2,bs:3,rtp:3},a=0,o=Object.keys(i);a<o.length;a++){var h=o[a];e[null!=s[h]?s[h]:1][h]=i[h]}for(var u=0;u<e.length;u++){var c=t.serialize(e[u]);c&&(n["CMCD-"+r[u]]=c)}return n},t.toQuery=function(i){return"CMCD="+encodeURIComponent(t.serialize(i))},t.appendQueryToUri=function(t,i){if(!i)return t;var n=t.includes("?")?"&":"?";return""+t+n+i},t}()},"./src/controller/eme-controller.ts":
54
+ /*!******************************************!*\
55
+ !*** ./src/controller/eme-controller.ts ***!
56
+ \******************************************/
57
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ../utils/mediakeys-helper */"./src/utils/mediakeys-helper.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var h=function(){function t(t){this.hls=void 0,this._widevineLicenseUrl=void 0,this._licenseXhrSetup=void 0,this._licenseResponseCallback=void 0,this._emeEnabled=void 0,this._requestMediaKeySystemAccess=void 0,this._drmSystemOptions=void 0,this._config=void 0,this._mediaKeysList=[],this._media=null,this._hasSetMediaKeys=!1,this._requestLicenseFailureCount=0,this.mediaKeysPromise=null,this._onMediaEncrypted=this.onMediaEncrypted.bind(this),this.hls=t,this._config=t.config,this._widevineLicenseUrl=this._config.widevineLicenseUrl,this._licenseXhrSetup=this._config.licenseXhrSetup,this._licenseResponseCallback=this._config.licenseResponseCallback,this._emeEnabled=this._config.emeEnabled,this._requestMediaKeySystemAccess=this._config.requestMediaKeySystemAccessFunc,this._drmSystemOptions=this._config.drmSystemOptions,this._registerListeners()}var i,n,h=t.prototype;return h.destroy=function(){this._unregisterListeners(),this.hls=this._onMediaEncrypted=null,this._requestMediaKeySystemAccess=null},h._registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this)},h._unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(r.Events.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this)},h.getLicenseServerUrl=function(t){switch(t){case a.KeySystems.WIDEVINE:if(!this._widevineLicenseUrl)break;return this._widevineLicenseUrl}throw new Error('no license server URL configured for key-system "'+t+'"')},h._attemptKeySystemAccess=function(t,i,n){var r=this,e=function(t,i,n,r){if(t===a.KeySystems.WIDEVINE)return function(t,i,n){var r={audioCapabilities:[],videoCapabilities:[]};return t.forEach((function(t){r.audioCapabilities.push({contentType:'audio/mp4; codecs="'+t+'"',robustness:n.audioRobustness||""})})),i.forEach((function(t){r.videoCapabilities.push({contentType:'video/mp4; codecs="'+t+'"',robustness:n.videoRobustness||""})})),[r]}(i,n,r);throw new Error("Unknown key-system: "+t)}(t,i,n,this._drmSystemOptions);s.logger.log("Requesting encrypted media key-system access");var o=this.requestMediaKeySystemAccess(t,e);this.mediaKeysPromise=o.then((function(i){return r._onMediaKeySystemAccessObtained(t,i)})),o.catch((function(i){s.logger.error('Failed to obtain key-system "'+t+'" access:',i)}))},h._onMediaKeySystemAccessObtained=function(t,i){var n=this;s.logger.log('Access for key-system "'+t+'" obtained');var r={mediaKeysSessionInitialized:!1,mediaKeySystemAccess:i,mediaKeySystemDomain:t};this._mediaKeysList.push(r);var e=Promise.resolve().then((function(){return i.createMediaKeys()})).then((function(i){return r.mediaKeys=i,s.logger.log('Media-keys created for key-system "'+t+'"'),n._onMediaKeysCreated(),i}));return e.catch((function(t){s.logger.error("Failed to create media-keys:",t)})),e},h._onMediaKeysCreated=function(){var t=this;this._mediaKeysList.forEach((function(i){i.mediaKeysSession||(i.mediaKeysSession=i.mediaKeys.createSession(),t._onNewMediaKeySession(i.mediaKeysSession))}))},h._onNewMediaKeySession=function(t){var i=this;s.logger.log("New key-system session "+t.sessionId),t.addEventListener("message",(function(n){i._onKeySessionMessage(t,n.message)}),!1)},h._onKeySessionMessage=function(t,i){s.logger.log("Got EME message event, creating license request"),this._requestLicense(i,(function(i){s.logger.log("Received license data (length: "+(i?i.byteLength:i)+"), updating key-session"),t.update(i)}))},h.onMediaEncrypted=function(t){var i=this;if(s.logger.log('Media is encrypted using "'+t.initDataType+'" init data type'),!this.mediaKeysPromise)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been requested"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});var n=function(n){i._media&&(i._attemptSetMediaKeys(n),i._generateRequestWithPreferredKeySession(t.initDataType,t.initData))};this.mediaKeysPromise.then(n).catch(n)},h._attemptSetMediaKeys=function(){if(!this._media)throw new Error("Attempted to set mediaKeys without first attaching a media element");if(!this._hasSetMediaKeys){var t=this._mediaKeysList[0];if(!t||!t.mediaKeys)return s.logger.error("Fatal: Media is encrypted but no CDM access or no keys have been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_KEYS,fatal:!0});s.logger.log("Setting keys for encrypted media"),this._media.setMediaKeys(t.mediaKeys),this._hasSetMediaKeys=!0}},h._generateRequestWithPreferredKeySession=function(t,i){var n=this,a=this._mediaKeysList[0];if(!a)return s.logger.error("Fatal: Media is encrypted but not any key-system access has been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});if(a.mediaKeysSessionInitialized)s.logger.warn("Key-Session already initialized but requested again");else{var o=a.mediaKeysSession;if(!o)return s.logger.error("Fatal: Media is encrypted but no key-session existing"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!0});if(!i)return s.logger.warn("Fatal: initData required for generating a key session is null"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_INIT_DATA,fatal:!0});s.logger.log('Generating key-session request for "'+t+'" init data type'),a.mediaKeysSessionInitialized=!0,o.generateRequest(t,i).then((function(){s.logger.debug("Key-session generation succeeded")})).catch((function(t){s.logger.error("Error generating key-session request:",t),n.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_SESSION,fatal:!1})}))}},h._createLicenseXhr=function(t,i,n){var r=new XMLHttpRequest;r.responseType="arraybuffer",r.onreadystatechange=this._onLicenseRequestReadyStageChange.bind(this,r,t,i,n);var e=this._licenseXhrSetup;if(e)try{e.call(this.hls,r,t),e=void 0}catch(t){s.logger.error(t)}try{r.readyState||r.open("POST",t,!0),e&&e.call(this.hls,r,t)}catch(t){throw new Error("issue setting up KeySystem license XHR "+t)}return r},h._onLicenseRequestReadyStageChange=function(t,i,n,a){if(4===t.readyState)if(200===t.status){this._requestLicenseFailureCount=0,s.logger.log("License request succeeded");var o=t.response,h=this._licenseResponseCallback;if(h)try{o=h.call(this.hls,t,i)}catch(t){s.logger.error(t)}a(o)}else{if(s.logger.error("License Request XHR failed ("+i+"). Status: "+t.status+" ("+t.statusText+")"),this._requestLicenseFailureCount++,this._requestLicenseFailureCount>3)return void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0});s.logger.warn("Retrying license request, "+(3-this._requestLicenseFailureCount+1)+" attempts left"),this._requestLicense(n,a)}},h._generateLicenseRequestChallenge=function(t,i){if(t.mediaKeySystemDomain===a.KeySystems.WIDEVINE)return i;throw new Error("unsupported key-system: "+t.mediaKeySystemDomain)},h._requestLicense=function(t,i){s.logger.log("Requesting content license for key-system");var n=this._mediaKeysList[0];if(!n)return s.logger.error("Fatal error: Media is encrypted but no key-system access has been obtained yet"),void this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_NO_ACCESS,fatal:!0});try{var a=this.getLicenseServerUrl(n.mediaKeySystemDomain),o=this._createLicenseXhr(a,t,i);s.logger.log("Sending license request to URL: "+a);var h=this._generateLicenseRequestChallenge(n,t);o.send(h)}catch(t){s.logger.error("Failure requesting DRM license: "+t),this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.KEY_SYSTEM_ERROR,details:e.ErrorDetails.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0})}},h.onMediaAttached=function(t,i){if(this._emeEnabled){var n=i.media;this._media=n,n.addEventListener("encrypted",this._onMediaEncrypted)}},h.onMediaDetached=function(){var t=this._media,i=this._mediaKeysList;t&&(t.removeEventListener("encrypted",this._onMediaEncrypted),this._media=null,this._mediaKeysList=[],Promise.all(i.map((function(t){if(t.mediaKeysSession)return t.mediaKeysSession.close().catch((function(){}))}))).then((function(){return t.setMediaKeys(null)})).catch((function(){})))},h.onManifestParsed=function(t,i){if(this._emeEnabled){var n=i.levels.map((function(t){return t.audioCodec})).filter((function(t){return!!t})),r=i.levels.map((function(t){return t.videoCodec})).filter((function(t){return!!t}));this._attemptKeySystemAccess(a.KeySystems.WIDEVINE,n,r)}},i=t,(n=[{key:"requestMediaKeySystemAccess",get:function(){if(!this._requestMediaKeySystemAccess)throw new Error("No requestMediaKeySystemAccess function configured");return this._requestMediaKeySystemAccess}}])&&o(i.prototype,n),t}();i.default=h},"./src/controller/fps-controller.ts":
58
+ /*!******************************************!*\
59
+ !*** ./src/controller/fps-controller.ts ***!
60
+ \******************************************/
61
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/logger */"./src/utils/logger.ts"),s=function(){function t(t){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=t,this.registerListeners()}var i=t.prototype;return i.setStreamController=function(t){this.streamController=t},i.registerListeners=function(){this.hls.on(r.Events.MEDIA_ATTACHING,this.onMediaAttaching,this)},i.unregisterListeners=function(){this.hls.off(r.Events.MEDIA_ATTACHING,this.onMediaAttaching)},i.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},i.onMediaAttaching=function(t,i){var n=this.hls.config;if(n.capLevelOnFPSDrop){var r=i.media instanceof self.HTMLVideoElement?i.media:null;this.media=r,r&&"function"==typeof r.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),n.fpsDroppedMonitoringPeriod)}},i.checkFPS=function(t,i,n){var s=performance.now();if(i){if(this.lastTime){var a=n-this.lastDroppedFrames,o=i-this.lastDecodedFrames,h=1e3*a/(s-this.lastTime),u=this.hls;if(u.trigger(r.Events.FPS_DROP,{currentDropped:a,currentDecoded:o,totalDroppedFrames:n}),h>0&&a>u.config.fpsDroppedMonitoringThreshold*o){var c=u.currentLevel;e.logger.warn("drop FPS ratio greater than max allowed value for currentLevel: "+c),c>0&&(-1===u.autoLevelCapping||u.autoLevelCapping>=c)&&(u.trigger(r.Events.FPS_DROP_LEVEL_CAPPING,{level:c-=1,droppedLevel:u.currentLevel}),u.autoLevelCapping=c,this.streamController.nextLevelSwitch())}}this.lastTime=s,this.lastDroppedFrames=n,this.lastDecodedFrames=i}},i.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var i=t.getVideoPlaybackQuality();this.checkFPS(t,i.totalVideoFrames,i.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}();i.default=s},"./src/controller/fragment-finders.ts":
62
+ /*!********************************************!*\
63
+ !*** ./src/controller/fragment-finders.ts ***!
64
+ \********************************************/
65
+ /*! exports provided: findFragmentByPDT, findFragmentByPTS, fragmentWithinToleranceTest, pdtWithinToleranceTest, findFragWithCC */function(t,i,n){n.r(i),n.d(i,"findFragmentByPDT",(function(){return s})),n.d(i,"findFragmentByPTS",(function(){return a})),n.d(i,"fragmentWithinToleranceTest",(function(){return o})),n.d(i,"pdtWithinToleranceTest",(function(){return h})),n.d(i,"findFragWithCC",(function(){return u}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/binary-search */"./src/utils/binary-search.ts");function s(t,i,n){if(null===i||!Array.isArray(t)||!t.length||!Object(r.isFiniteNumber)(i))return null;if(i<(t[0].programDateTime||0))return null;if(i>=(t[t.length-1].endProgramDateTime||0))return null;n=n||0;for(var e=0;e<t.length;++e){var s=t[e];if(h(i,n,s))return s}return null}function a(t,i,n,r){void 0===n&&(n=0),void 0===r&&(r=0);var s=null;return t?s=i[t.sn-i[0].sn+1]||null:0===n&&0===i[0].start&&(s=i[0]),s&&0===o(n,r,s)?s:e.default.search(i,o.bind(null,n,r))||s}function o(t,i,n){void 0===t&&(t=0),void 0===i&&(i=0);var r=Math.min(i,n.duration+(n.deltaPTS?n.deltaPTS:0));return n.start+n.duration-r<=t?1:n.start-r>t&&n.start?-1:0}function h(t,i,n){var r=1e3*Math.min(i,n.duration+(n.deltaPTS?n.deltaPTS:0));return(n.endProgramDateTime||0)-r>t}function u(t,i){return e.default.search(t,(function(t){return t.cc<i?1:t.cc>i?-1:0}))}},"./src/controller/fragment-tracker.ts":
66
+ /*!********************************************!*\
67
+ !*** ./src/controller/fragment-tracker.ts ***!
68
+ \********************************************/
69
+ /*! exports provided: FragmentState, FragmentTracker */function(t,i,n){n.r(i),n.d(i,"FragmentState",(function(){return r})),n.d(i,"FragmentTracker",(function(){return a}));var r,e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../types/loader */"./src/types/loader.ts");!function(t){t.NOT_LOADED="NOT_LOADED",t.BACKTRACKED="BACKTRACKED",t.APPENDING="APPENDING",t.PARTIAL="PARTIAL",t.OK="OK"}(r||(r={}));var a=function(){function t(t){this.activeFragment=null,this.activeParts=null,this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hls=t,this._registerListeners()}var i=t.prototype;return i._registerListeners=function(){var t=this.hls;t.on(e.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.on(e.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this)},i._unregisterListeners=function(){var t=this.hls;t.off(e.Events.BUFFER_APPENDED,this.onBufferAppended,this),t.off(e.Events.FRAG_BUFFERED,this.onFragBuffered,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this)},i.destroy=function(){this._unregisterListeners(),this.fragments=this.timeRanges=null},i.getAppendedFrag=function(t,i){if(i===s.PlaylistLevelType.MAIN){var n=this.activeFragment,r=this.activeParts;if(!n)return null;if(r)for(var e=r.length;e--;){var a=r[e],o=a?a.end:n.appendedPTS;if(a.start<=t&&void 0!==o&&t<=o)return e>9&&(this.activeParts=r.slice(e-9)),a}else if(n.start<=t&&void 0!==n.appendedPTS&&t<=n.appendedPTS)return n}return this.getBufferedFrag(t,i)},i.getBufferedFrag=function(t,i){for(var n=this.fragments,r=Object.keys(n),e=r.length;e--;){var s=n[r[e]];if((null==s?void 0:s.body.type)===i&&s.buffered){var a=s.body;if(a.start<=t&&t<=a.end)return a}}return null},i.detectEvictedFragments=function(t,i,n){var r=this;Object.keys(this.fragments).forEach((function(e){var s=r.fragments[e];if(s)if(s.buffered){var a=s.range[t];a&&a.time.some((function(t){var n=!r.isTimeBuffered(t.startPTS,t.endPTS,i);return n&&r.removeFragment(s.body),n}))}else s.body.type===n&&r.removeFragment(s.body)}))},i.detectPartialFragments=function(t){var i=this,n=this.timeRanges,r=t.frag,e=t.part;if(n&&"initSegment"!==r.sn){var s=h(r),a=this.fragments[s];a&&(Object.keys(n).forEach((function(t){var s=r.elementaryStreams[t];s&&(a.range[t]=i.getBufferedTimes(r,e,null!==e||!0===s.partial,n[t]))})),a.backtrack=a.loaded=null,Object.keys(a.range).length?a.buffered=!0:this.removeFragment(a.body))}},i.fragBuffered=function(t){var i=h(t),n=this.fragments[i];n&&(n.backtrack=n.loaded=null,n.buffered=!0)},i.getBufferedTimes=function(t,i,n,r){for(var e={time:[],partial:n},s=i?i.start:t.start,a=i?i.end:t.end,o=t.minEndPTS||a,h=t.maxStartPTS||s,u=0;u<r.length;u++){var c=r.start(u)-this.bufferPadding,f=r.end(u)+this.bufferPadding;if(h>=c&&o<=f){e.time.push({startPTS:Math.max(s,r.start(u)),endPTS:Math.min(a,r.end(u))});break}if(s<f&&a>c)e.partial=!0,e.time.push({startPTS:Math.max(s,r.start(u)),endPTS:Math.min(a,r.end(u))});else if(a<=c)break}return e},i.getPartialFragment=function(t){var i,n,r,e=null,s=0,a=this.bufferPadding,h=this.fragments;return Object.keys(h).forEach((function(u){var c=h[u];c&&o(c)&&(r=c.body.end+a,t>=(n=c.body.start-a)&&t<=r&&(i=Math.min(t-n,r-t),s<=i&&(e=c.body,s=i)))})),e},i.getState=function(t){var i=h(t),n=this.fragments[i];return n?n.buffered?o(n)?r.PARTIAL:r.OK:n.backtrack?r.BACKTRACKED:r.APPENDING:r.NOT_LOADED},i.backtrack=function(t,i){var n=h(t),r=this.fragments[n];if(!r||r.backtrack)return null;var e=r.backtrack=i||r.loaded;return r.loaded=null,e},i.getBacktrackData=function(t){var i=h(t),n=this.fragments[i];if(n){var r,e=n.backtrack;if(null!=e&&null!==(r=e.payload)&&void 0!==r&&r.byteLength)return e;this.removeFragment(t)}return null},i.isTimeBuffered=function(t,i,n){for(var r,e,s=0;s<n.length;s++){if(r=n.start(s)-this.bufferPadding,e=n.end(s)+this.bufferPadding,t>=r&&i<=e)return!0;if(i<=r)return!1}return!1},i.onFragLoaded=function(t,i){var n=i.frag;if("initSegment"!==n.sn&&!n.bitrateTest&&!i.part){var r=h(n);this.fragments[r]={body:n,loaded:i,backtrack:null,buffered:!1,range:Object.create(null)}}},i.onBufferAppended=function(t,i){var n=this,r=i.frag,e=i.part,a=i.timeRanges;if(r.type===s.PlaylistLevelType.MAIN)if(this.activeFragment=r,e){var o=this.activeParts;o||(this.activeParts=o=[]),o.push(e)}else this.activeParts=null;this.timeRanges=a,Object.keys(a).forEach((function(t){var i=a[t];if(n.detectEvictedFragments(t,i),!e)for(var s=0;s<i.length;s++)r.appendedPTS=Math.max(i.end(s),r.appendedPTS||0)}))},i.onFragBuffered=function(t,i){this.detectPartialFragments(i)},i.hasFragment=function(t){var i=h(t);return!!this.fragments[i]},i.removeFragmentsInRange=function(t,i,n){var r=this;Object.keys(this.fragments).forEach((function(e){var s=r.fragments[e];if(s&&s.buffered){var a=s.body;a.type===n&&a.start<i&&a.end>t&&r.removeFragment(a)}}))},i.removeFragment=function(t){var i=h(t);t.stats.loaded=0,t.clearElementaryStreamInfo(),delete this.fragments[i]},i.removeAllFragments=function(){this.fragments=Object.create(null),this.activeFragment=null,this.activeParts=null},t}();function o(t){var i,n;return t.buffered&&((null===(i=t.range.video)||void 0===i?void 0:i.partial)||(null===(n=t.range.audio)||void 0===n?void 0:n.partial))}function h(t){return t.type+"_"+t.level+"_"+t.urlId+"_"+t.sn}},"./src/controller/gap-controller.ts":
70
+ /*!******************************************!*\
71
+ !*** ./src/controller/gap-controller.ts ***!
72
+ \******************************************/
73
+ /*! exports provided: STALL_MINIMUM_DURATION_MS, MAX_START_GAP_JUMP, SKIP_BUFFER_HOLE_STEP_SECONDS, SKIP_BUFFER_RANGE_START, default */function(t,i,n){n.r(i),n.d(i,"STALL_MINIMUM_DURATION_MS",(function(){return o})),n.d(i,"MAX_START_GAP_JUMP",(function(){return h})),n.d(i,"SKIP_BUFFER_HOLE_STEP_SECONDS",(function(){return u})),n.d(i,"SKIP_BUFFER_RANGE_START",(function(){return c})),n.d(i,"default",(function(){return f}));var r=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../events */"./src/events.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=250,h=2,u=.1,c=.05,f=function(){function t(t,i,n,r){this.config=void 0,this.media=void 0,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=t,this.media=i,this.fragmentTracker=n,this.hls=r}var i=t.prototype;return i.destroy=function(){this.hls=this.fragmentTracker=this.media=null},i.poll=function(t){var i=this.config,n=this.media,e=this.stalled,s=n.currentTime,u=n.seeking,c=this.seeking&&!u,f=!this.seeking&&u;if(this.seeking=u,s===t){if((f||c)&&(this.stalled=null),!n.paused&&!n.ended&&0!==n.playbackRate&&r.BufferHelper.getBuffered(n).length){var l=r.BufferHelper.bufferInfo(n,s,0),v=l.nextStart||0;if(l.len>0||v){if(u){var d=l.len>h,m=!v||v-s>h&&!this.fragmentTracker.getPartialFragment(s);if(d||m)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var p,g=Math.max(v,l.start||0)-s,b=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,y=null==b||null===(p=b.details)||void 0===p?void 0:p.live;if(g>0&&g<=(y?2*b.details.targetduration:h))return void this._trySkipBufferHole(null)}var w=self.performance.now();if(null!==e){var k=w-e;!u&&k>=o&&this._reportStall(l.len);var T=r.BufferHelper.bufferInfo(n,s,i.maxBufferHole);this._tryFixBufferStall(T,k)}else this.stalled=w}}}else if(this.moved=!0,null!==e){if(this.stallReported){var O=self.performance.now()-e;a.logger.warn("playback not stuck anymore @"+s+", after "+Math.round(O)+"ms"),this.stallReported=!1}this.stalled=null,this.nudgeRetry=0}},i._tryFixBufferStall=function(t,i){var n=this.config,r=this.fragmentTracker.getPartialFragment(this.media.currentTime);r&&this._trySkipBufferHole(r)||t.len>n.maxBufferHole&&i>1e3*n.highBufferWatchdogPeriod&&(a.logger.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())},i._reportStall=function(t){var i=this.hls,n=this.media;this.stallReported||(this.stallReported=!0,a.logger.warn("Playback stalling at @"+n.currentTime+" due to low buffer (buffer="+t+")"),i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!1,buffer:t}))},i._trySkipBufferHole=function(t){for(var i=this.config,n=this.hls,o=this.media,h=o.currentTime,f=0,l=r.BufferHelper.getBuffered(o),v=0;v<l.length;v++){var d=l.start(v);if(h+i.maxBufferHole>=f&&h<d){var m=Math.max(d+c,o.currentTime+u);return a.logger.warn("skipping hole, adjusting currentTime from "+h+" to "+m),this.moved=!0,this.stalled=null,o.currentTime=m,t&&n.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_SEEK_OVER_HOLE,fatal:!1,reason:"fragment loaded with buffer holes, seeking from "+h+" to "+m,frag:t}),m}f=l.end(v)}return 0},i._tryNudgeBuffer=function(){var t=this.config,i=this.hls,n=this.media,r=n.currentTime,o=(this.nudgeRetry||0)+1;if(this.nudgeRetry=o,o<t.nudgeMaxRetry){var h=r+o*t.nudgeOffset;a.logger.warn("Nudging 'currentTime' from "+r+" to "+h),n.currentTime=h,i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_NUDGE_ON_STALL,fatal:!1})}else a.logger.error("Playhead still not moving while enough data buffered @"+r+" after "+t.nudgeMaxRetry+" nudges"),i.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.BUFFER_STALLED_ERROR,fatal:!0})},t}()},"./src/controller/id3-track-controller.ts":
74
+ /*!************************************************!*\
75
+ !*** ./src/controller/id3-track-controller.ts ***!
76
+ \************************************************/
77
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=n(/*! ../demux/id3 */"./src/demux/id3.ts"),a=function(){function t(t){this.hls=void 0,this.id3Track=null,this.media=null,this.hls=t,this._registerListeners()}var i=t.prototype;return i.destroy=function(){this._unregisterListeners()},i._registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.FRAG_PARSING_METADATA,this.onFragParsingMetadata,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},i.onMediaAttached=function(t,i){this.media=i.media},i.onMediaDetaching=function(){this.id3Track&&(Object(e.clearCurrentCues)(this.id3Track),this.id3Track=null,this.media=null)},i.getID3Track=function(t){if(this.media){for(var i=0;i<t.length;i++){var n=t[i];if("metadata"===n.kind&&"id3"===n.label)return Object(e.sendAddTrackEvent)(n,this.media),n}return this.media.addTextTrack("metadata","id3")}},i.onFragParsingMetadata=function(t,i){if(this.media){var n=i.frag,r=i.samples;this.id3Track||(this.id3Track=this.getID3Track(this.media.textTracks),this.id3Track.mode="hidden");for(var e=self.WebKitDataCue||self.VTTCue||self.TextTrackCue,a=0;a<r.length;a++){var o=s.getID3Frames(r[a].data);if(o){var h=r[a].pts,u=a<r.length-1?r[a+1].pts:n.end;u-h<=0&&(u=h+.25);for(var c=0;c<o.length;c++){var f=o[c];if(!s.isTimeStampFrame(f)){var l=new e(h,u,"");l.value=f,this.id3Track.addCue(l)}}}}}},i.onBufferFlushing=function(t,i){var n=i.startOffset,r=i.endOffset,s=i.type;if(!s||"audio"===s){var a=this.id3Track;a&&Object(e.removeCuesInRange)(a,n,r)}},t}();i.default=a},"./src/controller/latency-controller.ts":
78
+ /*!**********************************************!*\
79
+ !*** ./src/controller/latency-controller.ts ***!
80
+ \**********************************************/
81
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return o}));var r=n(/*! ../errors */"./src/errors.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts");function a(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var o=function(){function t(t){var i=this;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=function(){return i.timeupdate()},this.hls=t,this.config=t.config,this.registerListeners()}var i,n,o=t.prototype;return o.destroy=function(){this.unregisterListeners(),this.onMediaDetaching(),this.levelDetails=null,this.hls=this.timeupdateHandler=null},o.registerListeners=function(){this.hls.on(e.Events.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),this.hls.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(e.Events.LEVEL_UPDATED,this.onLevelUpdated,this),this.hls.on(e.Events.ERROR,this.onError,this)},o.unregisterListeners=function(){this.hls.off(e.Events.MEDIA_ATTACHED,this.onMediaAttached),this.hls.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching),this.hls.off(e.Events.MANIFEST_LOADING,this.onManifestLoading),this.hls.off(e.Events.LEVEL_UPDATED,this.onLevelUpdated),this.hls.off(e.Events.ERROR,this.onError)},o.onMediaAttached=function(t,i){this.media=i.media,this.media.addEventListener("timeupdate",this.timeupdateHandler)},o.onMediaDetaching=function(){this.media&&(this.media.removeEventListener("timeupdate",this.timeupdateHandler),this.media=null)},o.onManifestLoading=function(){this.levelDetails=null,this._latency=null,this.stallCount=0},o.onLevelUpdated=function(t,i){var n=i.details;this.levelDetails=n,n.advanced&&this.timeupdate(),!n.live&&this.media&&this.media.removeEventListener("timeupdate",this.timeupdateHandler)},o.onError=function(t,i){i.details===r.ErrorDetails.BUFFER_STALLED_ERROR&&(this.stallCount++,s.logger.warn("[playback-rate-controller]: Stall detected, adjusting target latency"))},o.timeupdate=function(){var t=this.media,i=this.levelDetails;if(t&&i){this.currentTime=t.currentTime;var n=this.computeLatency();if(null!==n){this._latency=n;var r=this.config,e=r.maxLiveSyncPlaybackRate;if(r.lowLatencyMode&&1!==e){var s=this.targetLatency;if(null!==s){var a=n-s,o=Math.min(this.maxLatency,s+i.targetduration);if(i.live&&a<o&&a>.05&&this.forwardBufferLength>1){var h=Math.min(2,Math.max(1,e)),u=Math.round(2/(1+Math.exp(-.75*a-this.edgeStalled))*20)/20;t.playbackRate=Math.min(h,Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},o.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},o.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},i=t,(n=[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,i=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:i?t.liveMaxLatencyDurationCount*i.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var i=t.targetduration,n=this.config,r=n.liveSyncDuration,e=this.hls.userConfig,s=n.lowLatencyMode&&t.partHoldBack||t.holdBack;return(e.liveSyncDuration||e.liveSyncDurationCount||0===s)&&(s=void 0!==r?r:n.liveSyncDurationCount*i),s+Math.min(1*this.stallCount,i)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),i=this.targetLatency,n=this.levelDetails;if(null===t||null===i||null===n)return null;var r=n.edge,e=r-(this.config.lowLatencyMode&&n.partTarget||n.targetduration);return Math.min(Math.max(r-n.totalduration,t-i-this.edgeStalled),e)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;return null===t?0:Math.max(t.age-3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration),0)}},{key:"forwardBufferLength",get:function(){var t=this.media,i=this.levelDetails;if(!t||!i)return 0;var n=t.buffered.length;return n?t.buffered.end(n-1):i.edge-this.currentTime}}])&&a(i.prototype,n),t}()},"./src/controller/level-controller.ts":
82
+ /*!********************************************!*\
83
+ !*** ./src/controller/level-controller.ts ***!
84
+ \********************************************/
85
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return d}));var r=n(/*! ../types/level */"./src/types/level.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../errors */"./src/errors.ts"),a=n(/*! ../utils/codecs */"./src/utils/codecs.ts"),o=n(/*! ./level-helper */"./src/controller/level-helper.ts"),h=n(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts");function c(){return c=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},c.apply(this,arguments)}function f(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,i){return l=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},l(t,i)}var v=/chrome|firefox/.test(navigator.userAgent.toLowerCase()),d=function(t){var i,n;function h(i){var n;return(n=t.call(this,i,"[level-controller]")||this)._levels=[],n._firstLevel=-1,n._startLevel=void 0,n.currentLevelIndex=-1,n.manualLevelIndex=-1,n.onParsedComplete=void 0,n._registerListeners(),n}n=t,(i=h).prototype=Object.create(n.prototype),i.prototype.constructor=i,l(i,n);var d,m,p=h.prototype;return p._registerListeners=function(){var t=this.hls;t.on(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(e.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(e.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(e.Events.ERROR,this.onError,this)},p._unregisterListeners=function(){var t=this.hls;t.off(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(e.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(e.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(e.Events.ERROR,this.onError,this)},p.destroy=function(){this._unregisterListeners(),this.manualLevelIndex=-1,this._levels.length=0,t.prototype.destroy.call(this)},p.startLoad=function(){this._levels.forEach((function(t){t.loadError=0})),t.prototype.startLoad.call(this)},p.onManifestLoaded=function(t,i){var n,h,u=[],c=[],f=[],l={},d=!1,m=!1,p=!1;if(i.levels.forEach((function(t){var i=t.attrs;d=d||!(!t.width||!t.height),m=m||!!t.videoCodec,p=p||!!t.audioCodec,v&&t.audioCodec&&-1!==t.audioCodec.indexOf("mp4a.40.34")&&(t.audioCodec=void 0);var n=t.bitrate+"-"+t.attrs.RESOLUTION+"-"+t.attrs.CODECS;(h=l[n])?h.url.push(t.url):(h=new r.Level(t),l[n]=h,u.push(h)),i&&(i.AUDIO&&Object(o.addGroupId)(h,"audio",i.AUDIO),i.SUBTITLES&&Object(o.addGroupId)(h,"text",i.SUBTITLES))})),(d||m)&&p&&(u=u.filter((function(t){return!!t.videoCodec||!(!t.width||!t.height)}))),u=u.filter((function(t){var i=t.audioCodec,n=t.videoCodec;return(!i||Object(a.isCodecSupportedInMp4)(i,"audio"))&&(!n||Object(a.isCodecSupportedInMp4)(n,"video"))})),i.audioTracks&&(c=i.audioTracks.filter((function(t){return!t.audioCodec||Object(a.isCodecSupportedInMp4)(t.audioCodec,"audio")})),Object(o.assignTrackIdsByGroup)(c)),i.subtitles&&(f=i.subtitles,Object(o.assignTrackIdsByGroup)(f)),u.length>0){n=u[0].bitrate,u.sort((function(t,i){return t.bitrate-i.bitrate})),this._levels=u;for(var g=0;g<u.length;g++)if(u[g].bitrate===n){this._firstLevel=g,this.log("manifest loaded, "+u.length+" level(s) found, first bitrate: "+n);break}var b={levels:u,audioTracks:c,subtitleTracks:f,firstLevel:this._firstLevel,stats:i.stats,audio:p,video:m,altAudio:!(p&&!m)&&c.some((function(t){return!!t.url}))};this.hls.trigger(e.Events.MANIFEST_PARSED,b),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:i.url,reason:"no level with compatible codecs found in manifest"})},p.onError=function(i,n){if(t.prototype.onError.call(this,i,n),!n.fatal){var r=n.context,e=this._levels[this.currentLevelIndex];if(r&&(r.type===u.PlaylistContextType.AUDIO_TRACK&&e.audioGroupIds&&r.groupId===e.audioGroupIds[e.urlId]||r.type===u.PlaylistContextType.SUBTITLE_TRACK&&e.textGroupIds&&r.groupId===e.textGroupIds[e.urlId]))this.redundantFailover(this.currentLevelIndex);else{var a,o=!1,h=!0;switch(n.details){case s.ErrorDetails.FRAG_LOAD_ERROR:case s.ErrorDetails.FRAG_LOAD_TIMEOUT:case s.ErrorDetails.KEY_LOAD_ERROR:case s.ErrorDetails.KEY_LOAD_TIMEOUT:if(n.frag){var c=this._levels[n.frag.level];c?(c.fragmentError++,c.fragmentError>this.hls.config.fragLoadingMaxRetry&&(a=n.frag.level)):a=n.frag.level}break;case s.ErrorDetails.LEVEL_LOAD_ERROR:case s.ErrorDetails.LEVEL_LOAD_TIMEOUT:r&&(r.deliveryDirectives&&(h=!1),a=r.level),o=!0;break;case s.ErrorDetails.REMUX_ALLOC_ERROR:a=n.level,o=!0}void 0!==a&&this.recoverLevel(n,a,o,h)}}},p.recoverLevel=function(t,i,n,r){var e=t.details,s=this._levels[i];if(s.loadError++,n){if(!this.retryLoadingOrFail(t))return void(this.currentLevelIndex=-1);t.levelRetry=!0}if(r){var a=s.url.length;if(a>1&&s.loadError<a)t.levelRetry=!0,this.redundantFailover(i);else if(-1===this.manualLevelIndex){var o=0===i?this._levels.length-1:i-1;this.currentLevelIndex!==o&&0===this._levels[o].loadError&&(this.warn(e+": switch to "+o),t.levelRetry=!0,this.hls.nextAutoLevel=o)}}},p.redundantFailover=function(t){var i=this._levels[t],n=i.url.length;if(n>1){var r=(i.urlId+1)%n;this.warn("Switching to redundant URL-id "+r),this._levels.forEach((function(t){t.urlId=r})),this.level=t}},p.onFragLoaded=function(t,i){var n=i.frag;if(void 0!==n&&n.type===u.PlaylistLevelType.MAIN){var r=this._levels[n.level];void 0!==r&&(r.fragmentError=0,r.loadError=0)}},p.onLevelLoaded=function(t,i){var n,r,e=i.level,s=i.details,a=this._levels[e];if(!a)return this.warn("Invalid level index "+e),void(null!==(r=i.deliveryDirectives)&&void 0!==r&&r.skip&&(s.deltaUpdateFailed=!0));e===this.currentLevelIndex?(0===a.fragmentError&&(a.loadError=0,this.retryCount=0),this.playlistLoaded(e,i,a.details)):null!==(n=i.deliveryDirectives)&&void 0!==n&&n.skip&&(s.deltaUpdateFailed=!0)},p.onAudioTrackSwitched=function(t,i){var n=this.hls.levels[this.currentLevelIndex];if(n&&n.audioGroupIds){for(var r=-1,e=this.hls.audioTracks[i.id].groupId,s=0;s<n.audioGroupIds.length;s++)if(n.audioGroupIds[s]===e){r=s;break}r!==n.urlId&&(n.urlId=r,this.startLoad())}},p.loadPlaylist=function(t){var i=this.currentLevelIndex,n=this._levels[i];if(this.canLoad&&n&&n.url.length>0){var r=n.urlId,s=n.url[r];if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Attempt loading level index "+i+(t?" at sn "+t.msn+" part "+t.part:"")+" with URL-id "+r+" "+s),this.clearTimer(),this.hls.trigger(e.Events.LEVEL_LOADING,{url:s,level:i,id:r,deliveryDirectives:t||null})}},p.removeLevel=function(t,i){var n=function(t,n){return n!==i},r=this._levels.filter((function(r,e){return e!==t||r.url.length>1&&void 0!==i&&(r.url=r.url.filter(n),r.audioGroupIds&&(r.audioGroupIds=r.audioGroupIds.filter(n)),r.textGroupIds&&(r.textGroupIds=r.textGroupIds.filter(n)),r.urlId=0,!0)})).map((function(t,i){var n=t.details;return null!=n&&n.fragments&&n.fragments.forEach((function(t){t.level=i})),t}));this._levels=r,this.hls.trigger(e.Events.LEVELS_UPDATED,{levels:r})},d=h,(m=[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var i,n=this._levels;if(0!==n.length&&(this.currentLevelIndex!==t||null===(i=n[t])||void 0===i||!i.details)){if(t<0||t>=n.length){var r=t<0;if(this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.OTHER_ERROR,details:s.ErrorDetails.LEVEL_SWITCH_ERROR,level:t,fatal:r,reason:"invalid level idx"}),r)return;t=Math.min(t,n.length-1)}this.clearTimer();var a=this.currentLevelIndex,o=n[a],h=n[t];this.log("switching to level "+t+" from "+a),this.currentLevelIndex=t;var u=c({},h,{level:t,maxBitrate:h.maxBitrate,uri:h.uri,urlId:h.urlId});delete u._urlId,this.hls.trigger(e.Events.LEVEL_SWITCHING,u);var f=h.details;if(!f||f.live){var l=this.switchParams(h.uri,null==o?void 0:o.details);this.loadPlaylist(l)}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this._firstLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}])&&f(d.prototype,m),h}(h.default)},"./src/controller/level-helper.ts":
86
+ /*!****************************************!*\
87
+ !*** ./src/controller/level-helper.ts ***!
88
+ \****************************************/
89
+ /*! exports provided: addGroupId, assignTrackIdsByGroup, updatePTS, updateFragPTSDTS, mergeDetails, mapPartIntersection, mapFragmentIntersection, adjustSliding, addSliding, computeReloadInterval, getFragmentWithSN, getPartWith */function(t,i,n){n.r(i),n.d(i,"addGroupId",(function(){return s})),n.d(i,"assignTrackIdsByGroup",(function(){return a})),n.d(i,"updatePTS",(function(){return o})),n.d(i,"updateFragPTSDTS",(function(){return u})),n.d(i,"mergeDetails",(function(){return c})),n.d(i,"mapPartIntersection",(function(){return f})),n.d(i,"mapFragmentIntersection",(function(){return l})),n.d(i,"adjustSliding",(function(){return v})),n.d(i,"addSliding",(function(){return d})),n.d(i,"computeReloadInterval",(function(){return m})),n.d(i,"getFragmentWithSN",(function(){return p})),n.d(i,"getPartWith",(function(){return g}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/logger */"./src/utils/logger.ts");function s(t,i,n){switch(i){case"audio":t.audioGroupIds||(t.audioGroupIds=[]),t.audioGroupIds.push(n);break;case"text":t.textGroupIds||(t.textGroupIds=[]),t.textGroupIds.push(n)}}function a(t){var i={};t.forEach((function(t){var n=t.groupId||"";t.id=i[n]=i[n]||0,i[n]++}))}function o(t,i,n){h(t[i],t[n])}function h(t,i){var n=i.startPTS;if(Object(r.isFiniteNumber)(n)){var e,s=0;i.sn>t.sn?(s=n-t.start,e=t):(s=t.start-n,e=i),e.duration!==s&&(e.duration=s)}else i.start=i.sn>t.sn?t.cc===i.cc&&t.minEndPTS?t.start+(t.minEndPTS-t.start):t.start+t.duration:Math.max(t.start-i.duration,0)}function u(t,i,n,s,a,o){s-n<=0&&(e.logger.warn("Fragment should have a positive duration",i),s=n+i.duration,o=a+i.duration);var u=n,c=s,f=i.startPTS,l=i.endPTS;if(Object(r.isFiniteNumber)(f)){var v=Math.abs(f-n);i.deltaPTS=Object(r.isFiniteNumber)(i.deltaPTS)?Math.max(v,i.deltaPTS):v,u=Math.max(n,f),n=Math.min(n,f),a=Math.min(a,i.startDTS),c=Math.min(s,l),s=Math.max(s,l),o=Math.max(o,i.endDTS)}i.duration=s-n;var d=n-i.start;i.appendedPTS=s,i.start=i.startPTS=n,i.maxStartPTS=u,i.startDTS=a,i.endPTS=s,i.minEndPTS=c,i.endDTS=o;var m,p=i.sn;if(!t||p<t.startSN||p>t.endSN)return 0;var g=p-t.startSN,b=t.fragments;for(b[g]=i,m=g;m>0;m--)h(b[m],b[m-1]);for(m=g;m<b.length-1;m++)h(b[m],b[m+1]);return t.fragmentHint&&h(b[b.length-1],t.fragmentHint),t.PTSKnown=t.alignedSliding=!0,d}function c(t,i){for(var n=null,s=t.fragments,a=s.length-1;a>=0;a--){var o=s[a].initSegment;if(o){n=o;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var h,c=0;if(l(t,i,(function(t,e){t.relurl&&(c=t.cc-e.cc),Object(r.isFiniteNumber)(t.startPTS)&&Object(r.isFiniteNumber)(t.endPTS)&&(e.start=e.startPTS=t.startPTS,e.startDTS=t.startDTS,e.appendedPTS=t.appendedPTS,e.maxStartPTS=t.maxStartPTS,e.endPTS=t.endPTS,e.endDTS=t.endDTS,e.minEndPTS=t.minEndPTS,e.duration=t.endPTS-t.startPTS,e.duration&&(h=e),i.PTSKnown=i.alignedSliding=!0),e.elementaryStreams=t.elementaryStreams,e.loader=t.loader,e.stats=t.stats,e.urlId=t.urlId,t.initSegment&&(e.initSegment=t.initSegment,n=t.initSegment)})),n&&(i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments).forEach((function(t){var i;t.initSegment&&t.initSegment.relurl!==(null===(i=n)||void 0===i?void 0:i.relurl)||(t.initSegment=n)})),i.skippedSegments&&(i.deltaUpdateFailed=i.fragments.some((function(t){return!t})),i.deltaUpdateFailed)){e.logger.warn("[level-helper] Previous playlist missing segments skipped in delta playlist");for(var d=i.skippedSegments;d--;)i.fragments.shift();i.startSN=i.fragments[0].sn,i.startCC=i.fragments[0].cc}var m=i.fragments;if(c){e.logger.warn("discontinuity sliding from playlist, take drift into account");for(var p=0;p<m.length;p++)m[p].cc+=c}i.skippedSegments&&(i.startCC=i.fragments[0].cc),f(t.partList,i.partList,(function(t,i){i.elementaryStreams=t.elementaryStreams,i.stats=t.stats})),h?u(i,h,h.startPTS,h.endPTS,h.startDTS,h.endDTS):v(t,i),m.length&&(i.totalduration=i.edge-m[0].start),i.driftStartTime=t.driftStartTime,i.driftStart=t.driftStart;var g=i.advancedDateTime;if(i.advanced&&g){var b=i.edge;i.driftStart||(i.driftStartTime=g,i.driftStart=b),i.driftEndTime=g,i.driftEnd=b}else i.driftEndTime=t.driftEndTime,i.driftEnd=t.driftEnd,i.advancedDateTime=t.advancedDateTime}function f(t,i,n){if(t&&i)for(var r=0,e=0,s=t.length;e<=s;e++){var a=t[e],o=i[e+r];a&&o&&a.index===o.index&&a.fragment.sn===o.fragment.sn?n(a,o):r--}}function l(t,i,n){for(var r=i.skippedSegments,e=Math.max(t.startSN,i.startSN)-i.startSN,s=(t.fragmentHint?1:0)+(r?i.endSN:Math.min(t.endSN,i.endSN))-i.startSN,a=i.startSN-t.startSN,o=i.fragmentHint?i.fragments.concat(i.fragmentHint):i.fragments,h=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=e;u<=s;u++){var c=h[a+u],f=o[u];r&&!f&&u<r&&(f=i.fragments[u]=c),c&&f&&n(c,f)}}function v(t,i){var n=i.startSN+i.skippedSegments-t.startSN,r=t.fragments;n<0||n>=r.length||d(i,r[n].start)}function d(t,i){if(i){for(var n=t.fragments,r=t.skippedSegments;r<n.length;r++)n[r].start+=i;t.fragmentHint&&(t.fragmentHint.start+=i)}}function m(t,i){var n,r=1e3*t.levelTargetDuration,e=r/2,s=t.age,a=s>0&&s<3*r,o=i.loading.end-i.loading.start,h=t.availabilityDelay;if(!1===t.updated)if(a){var u=333*t.misses;n=Math.max(Math.min(e,2*o),u),t.availabilityDelay=(t.availabilityDelay||0)+n}else n=e;else a?(h=Math.min(h||r/2,s),t.availabilityDelay=h,n=h+r-s):n=r-o;return Math.round(n)}function p(t,i,n){if(!t||!t.details)return null;var r=t.details,e=r.fragments[i-r.startSN];return e||((e=r.fragmentHint)&&e.sn===i?e:i<r.startSN&&n&&n.sn===i?n:null)}function g(t,i,n){if(!t||!t.details)return null;var r=t.details.partList;if(r)for(var e=r.length;e--;){var s=r[e];if(s.index===n&&s.fragment.sn===i)return s}return null}},"./src/controller/stream-controller.ts":
90
+ /*!*********************************************!*\
91
+ !*** ./src/controller/stream-controller.ts ***!
92
+ \*********************************************/
93
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return b}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),s=n(/*! ../is-supported */"./src/is-supported.ts"),a=n(/*! ../events */"./src/events.ts"),o=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),h=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),f=n(/*! ../demux/transmuxer-interface */"./src/demux/transmuxer-interface.ts"),l=n(/*! ../types/transmuxer */"./src/types/transmuxer.ts"),v=n(/*! ./gap-controller */"./src/controller/gap-controller.ts"),d=n(/*! ../errors */"./src/errors.ts"),m=n(/*! ../utils/logger */"./src/utils/logger.ts");function p(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function g(t,i){return g=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},g(t,i)}var b=function(t){var i,n;function b(i,n){var r;return(r=t.call(this,i,n,"[stream-controller]")||this).audioCodecSwap=!1,r.gapController=null,r.level=-1,r._forceStartLoad=!1,r.altAudio=!1,r.audioOnly=!1,r.fragPlaying=null,r.onvplaying=null,r.onvseeked=null,r.fragLastKbps=0,r.stalled=!1,r.couldBacktrack=!1,r.audioCodecSwitch=!1,r.videoBuffer=null,r._registerListeners(),r}n=t,(i=b).prototype=Object.create(n.prototype),i.prototype.constructor=i,g(i,n);var y,w,k=b.prototype;return k._registerListeners=function(){var t=this.hls;t.on(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(a.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.on(a.Events.ERROR,this.onError,this),t.on(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.on(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.on(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.on(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.on(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k._unregisterListeners=function(){var t=this.hls;t.off(a.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(a.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(a.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(a.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(a.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(a.Events.FRAG_LOAD_EMERGENCY_ABORTED,this.onFragLoadEmergencyAborted,this),t.off(a.Events.ERROR,this.onError,this),t.off(a.Events.AUDIO_TRACK_SWITCHING,this.onAudioTrackSwitching,this),t.off(a.Events.AUDIO_TRACK_SWITCHED,this.onAudioTrackSwitched,this),t.off(a.Events.BUFFER_CREATED,this.onBufferCreated,this),t.off(a.Events.BUFFER_FLUSHED,this.onBufferFlushed,this),t.off(a.Events.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(a.Events.FRAG_BUFFERED,this.onFragBuffered,this)},k.onHandlerDestroying=function(){this._unregisterListeners(),this.onMediaDetaching()},k.startLoad=function(t){if(this.levels){var i=this.lastCurrentTime,n=this.hls;if(this.stopLoad(),this.setInterval(100),this.level=-1,this.fragLoadError=0,!this.startFragRequested){var r=n.startLevel;-1===r&&(n.config.testBandwidth?(r=0,this.bitrateTest=!0):r=n.nextAutoLevel),this.level=n.nextLoadLevel=r,this.loadedmetadata=!1}i>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+i.toFixed(3)),t=i),this.state=e.State.IDLE,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=e.State.STOPPED},k.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},k.doTick=function(){switch(this.state){case e.State.IDLE:this.doTickIdle();break;case e.State.WAITING_LEVEL:var t,i=this.levels,n=null==i||null===(t=i[this.level])||void 0===t?void 0:t.details;if(n&&(!n.live||this.levelLastLoaded===this.level)){if(this.waitForCdnTuneIn(n))break;this.state=e.State.IDLE;break}break;case e.State.FRAG_LOADING_WAITING_RETRY:var r,s=self.performance.now(),a=this.retryDate;(!a||s>=a||null!==(r=this.media)&&void 0!==r&&r.seeking)&&(this.log("retryDate reached, switch back to IDLE state"),this.state=e.State.IDLE)}this.onTickEnd()},k.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},k.doTickIdle=function(){var t,i,n=this.hls,r=this.levels,s=this.media,o=n.nextLoadLevel;if(null!==this.levelLastLoaded&&(s||!this.startFragRequested&&n.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)&&r&&r[o]){var f=r[o];this.level=n.nextLoadLevel=o;var l=f.details;if(!l||this.state===e.State.WAITING_LEVEL||l.live&&this.levelLastLoaded!==o)this.state=e.State.WAITING_LEVEL;else{var v=this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:s,u.PlaylistLevelType.MAIN);if(null!==v&&!(v.len>=this.getMaxBufferLength(f.maxBitrate))){if(this._streamEnded(v,l)){var d={};return this.altAudio&&(d.type="video"),this.hls.trigger(a.Events.BUFFER_EOS,d),void(this.state=e.State.ENDED)}var m=v.end,p=this.getNextFragment(m,l);if(this.couldBacktrack&&!this.fragPrevious&&p&&"initSegment"!==p.sn){var g=p.sn-l.startSN;g>1&&this.fragmentTracker.removeFragment(p=l.fragments[g-1])}p&&this.fragmentTracker.getState(p)===h.FragmentState.OK&&this.nextLoadPosition>m&&(this.afterBufferFlushed(s,this.audioOnly&&!this.altAudio?c.ElementaryStreamTypes.AUDIO:c.ElementaryStreamTypes.VIDEO,u.PlaylistLevelType.MAIN),p=this.getNextFragment(this.nextLoadPosition,l)),p&&(!p.initSegment||p.initSegment.data||this.bitrateTest||(p=p.initSegment),"identity"!==(null===(t=p.decryptdata)||void 0===t?void 0:t.keyFormat)||null!==(i=p.decryptdata)&&void 0!==i&&i.key?this.loadFragment(p,l,m):this.loadKey(p,l))}}}},k.loadFragment=function(i,n,r){var e,s=this.fragmentTracker.getState(i);if(this.fragCurrent=i,s===h.FragmentState.BACKTRACKED){var a=this.fragmentTracker.getBacktrackData(i);if(a)return this._handleFragmentLoadProgress(a),void this._handleFragmentLoadComplete(a);s=h.FragmentState.NOT_LOADED}s===h.FragmentState.NOT_LOADED||s===h.FragmentState.PARTIAL?"initSegment"===i.sn?this._loadInitSegment(i):this.bitrateTest?(i.bitrateTest=!0,this.log("Fragment "+i.sn+" of level "+i.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(i)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,i,n,r)):s===h.FragmentState.APPENDING?this.reduceMaxBufferLength(i.duration)&&this.fragmentTracker.removeFragment(i):0===(null===(e=this.media)||void 0===e?void 0:e.buffered.length)&&this.fragmentTracker.removeAllFragments()},k.getAppendedFrag=function(t){var i=this.fragmentTracker.getAppendedFrag(t,u.PlaylistLevelType.MAIN);return i&&"fragment"in i?i.fragment:i},k.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,u.PlaylistLevelType.MAIN)},k.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},k.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},k.nextLevelSwitch=function(){var t=this.levels,i=this.media;if(null!=i&&i.readyState){var n,r=this.getAppendedFrag(i.currentTime);if(r&&r.start>1&&this.flushMainBuffer(0,r.start-1),!i.paused&&t){var e=this.fragLastKbps;n=e&&this.fragCurrent?this.fragCurrent.duration*t[this.hls.nextLoadLevel].maxBitrate/(1e3*e)+1:0}else n=0;var s=this.getBufferedFrag(i.currentTime+n);if(s){var a=this.followingBufferedFrag(s);if(a){this.abortCurrentFrag();var o=a.duration,h=Math.max(s.end,(a.maxStartPTS?a.maxStartPTS:a.start)+Math.min(Math.max(o-this.config.maxFragLookUpTolerance,.5*o),.75*o));this.flushMainBuffer(h,Number.POSITIVE_INFINITY)}}}},k.abortCurrentFrag=function(){var t=this.fragCurrent;this.fragCurrent=null,null!=t&&t.loader&&t.loader.abort(),this.state===e.State.KEY_LOADING&&(this.state=e.State.IDLE),this.nextLoadPosition=this.getLoadPosition()},k.flushMainBuffer=function(i,n){t.prototype.flushMainBuffer.call(this,i,n,this.altAudio?"video":null)},k.onMediaAttached=function(i,n){t.prototype.onMediaAttached.call(this,i,n);var r=n.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),r.addEventListener("playing",this.onvplaying),r.addEventListener("seeked",this.onvseeked),this.gapController=new v.default(this.config,r,this.fragmentTracker,this.hls)},k.onMediaDetaching=function(){var i=this.media;i&&(i.removeEventListener("playing",this.onvplaying),i.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},k.onMediaPlaying=function(){this.tick()},k.onMediaSeeked=function(){var t=this.media,i=t?t.currentTime:null;Object(r.isFiniteNumber)(i)&&this.log("Media seeked to "+i.toFixed(3)),this.tick()},k.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(a.Events.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=this.stalled=!1,this.startPosition=this.lastCurrentTime=0,this.fragPlaying=null},k.onManifestParsed=function(t,i){var n,r=!1,e=!1;i.levels.forEach((function(t){(n=t.audioCodec)&&(-1!==n.indexOf("mp4a.40.2")&&(r=!0),-1!==n.indexOf("mp4a.40.5")&&(e=!0))})),this.audioCodecSwitch=r&&e&&!Object(s.changeTypeSupported)(),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=i.levels,this.startFragRequested=!1},k.onLevelLoading=function(t,i){var n=this.levels;if(n&&this.state===e.State.IDLE){var r=n[i.level];(!r.details||r.details.live&&this.levelLastLoaded!==i.level||this.waitForCdnTuneIn(r.details))&&(this.state=e.State.WAITING_LEVEL)}},k.onLevelLoaded=function(t,i){var n,r=this.levels,s=i.level,o=i.details;if(r){this.log("Level "+s+" loaded ["+o.startSN+","+o.endSN+"], cc ["+o.startCC+", "+o.endCC+"] duration:"+o.totalduration);var h=this.fragCurrent;!h||this.state!==e.State.FRAG_LOADING&&this.state!==e.State.FRAG_LOADING_WAITING_RETRY||h.level!==i.level&&h.loader&&(this.state=e.State.IDLE,h.loader.abort());var u=r[s],c=0;if(o.live||null!==(n=u.details)&&void 0!==n&&n.live){if(o.fragments[0]||(o.deltaUpdateFailed=!0),o.deltaUpdateFailed)return;c=this.alignPlaylists(o,u.details)}if(u.details=o,this.levelLastLoaded=s,this.hls.trigger(a.Events.LEVEL_UPDATED,{details:o,level:s}),this.state===e.State.WAITING_LEVEL){if(this.waitForCdnTuneIn(o))return;this.state=e.State.IDLE}this.startFragRequested?o.live&&this.synchronizeToLiveEdge(o):this.setStartPosition(o,c),this.tick()}else this.warn("Levels were reset while loading level "+s)},k._handleFragmentLoadProgress=function(t){var i,n=t.frag,r=t.part,e=t.payload,s=this.levels;if(s){var a=s[n.level],o=a.details;if(o){var h=a.videoCodec,c=o.PTSKnown||!o.live,v=null===(i=n.initSegment)||void 0===i?void 0:i.data,d=this._getAudioCodec(a),m=this.transmuxer=this.transmuxer||new f.default(this.hls,u.PlaylistLevelType.MAIN,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),p=r?r.index:-1,g=new l.ChunkMetadata(n.level,n.sn,n.stats.chunkCount,e.byteLength,p,-1!==p);m.push(e,v,d,h,n,r,o.totalduration,c,g,this.initPTS[n.cc])}else this.warn("Dropping fragment "+n.sn+" of level "+n.level+" after level details were reset")}else this.warn("Levels were reset while fragment load was in progress. Fragment "+n.sn+" of level "+n.level+" will not be buffered")},k.onAudioTrackSwitching=function(t,i){var n=this.altAudio,r=i.id;if(!i.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var e=this.fragCurrent;null!=e&&e.loader&&(this.log("Switching to main audio track, cancel main fragment load"),e.loader.abort()),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var s=this.hls;n&&s.trigger(a.Events.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:"audio"}),s.trigger(a.Events.AUDIO_TRACK_SWITCHED,{id:r})}},k.onAudioTrackSwitched=function(t,i){var n=!!this.hls.audioTracks[i.id].url;if(n){var r=this.videoBuffer;r&&this.mediaBuffer!==r&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=r)}this.altAudio=n,this.tick()},k.onBufferCreated=function(t,i){var n,r,e=i.tracks,s=!1;for(var a in e){var o=e[a];if("main"===o.id){if(r=a,n=o,"video"===a){var h=e[a];h&&(this.videoBuffer=h.buffer)}}else s=!0}s&&n?(this.log("Alternate track found, use "+r+".buffered to schedule main fragment loading"),this.mediaBuffer=n.buffer):this.mediaBuffer=this.media},k.onFragBuffered=function(t,i){var n=i.frag,r=i.part;if(!n||n.type===u.PlaylistLevelType.MAIN){if(this.fragContextChanged(n))return this.warn("Fragment "+n.sn+(r?" p: "+r.index:"")+" of level "+n.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===e.State.PARSED&&(this.state=e.State.IDLE));var s=r?r.stats:n.stats;this.fragLastKbps=Math.round(8*s.total/(s.buffering.end-s.loading.first)),"initSegment"!==n.sn&&(this.fragPrevious=n),this.fragBufferedComplete(n,r)}},k.onError=function(t,i){switch(i.details){case d.ErrorDetails.FRAG_LOAD_ERROR:case d.ErrorDetails.FRAG_LOAD_TIMEOUT:case d.ErrorDetails.KEY_LOAD_ERROR:case d.ErrorDetails.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(u.PlaylistLevelType.MAIN,i);break;case d.ErrorDetails.LEVEL_LOAD_ERROR:case d.ErrorDetails.LEVEL_LOAD_TIMEOUT:this.state!==e.State.ERROR&&(i.fatal?(this.warn(""+i.details),this.state=e.State.ERROR):i.levelRetry||this.state!==e.State.WAITING_LEVEL||(this.state=e.State.IDLE));break;case d.ErrorDetails.BUFFER_FULL_ERROR:if("main"===i.parent&&(this.state===e.State.PARSING||this.state===e.State.PARSED)){var n=!0,r=this.getFwdBufferInfo(this.media,u.PlaylistLevelType.MAIN);r&&r.len>.5&&(n=!this.reduceMaxBufferLength(r.len)),n&&(this.warn("buffer full error also media.currentTime is not buffered, flush main"),this.immediateLevelSwitch()),this.resetLoadingState()}}},k.checkBuffer=function(){var t=this.media,i=this.gapController;if(t&&i&&t.readyState){var n=o.BufferHelper.getBuffered(t);!this.loadedmetadata&&n.length?(this.loadedmetadata=!0,this.seekToStartPos()):i.poll(this.lastCurrentTime),this.lastCurrentTime=t.currentTime}},k.onFragLoadEmergencyAborted=function(){this.state=e.State.IDLE,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},k.onBufferFlushed=function(t,i){var n=i.type;(n!==c.ElementaryStreamTypes.AUDIO||this.audioOnly&&!this.altAudio)&&this.afterBufferFlushed((n===c.ElementaryStreamTypes.VIDEO?this.videoBuffer:this.mediaBuffer)||this.media,n,u.PlaylistLevelType.MAIN)},k.onLevelsUpdated=function(t,i){this.levels=i.levels},k.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},k.seekToStartPos=function(){var t=this.media,i=t.currentTime,n=this.startPosition;if(n>=0&&i<n){if(t.seeking)return void m.logger.log("could not seek to "+n+", already seeking at "+i);var r=o.BufferHelper.getBuffered(t),e=(r.length?r.start(0):0)-n;e>0&&(e<this.config.maxBufferHole||e<this.config.maxFragLookUpTolerance)&&(m.logger.log("adjusting start position by "+e+" to match buffer start"),this.startPosition=n+=e),this.log("seek to target start position "+n+" from current time "+i),t.currentTime=n}},k._getAudioCodec=function(t){var i=this.config.defaultAudioCodec||t.audioCodec;return this.audioCodecSwap&&i&&(this.log("Swapping audio codec"),i=-1!==i.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),i},k._loadBitrateTestFrag=function(t){var i=this;this._doFragLoad(t).then((function(n){var r=i.hls;if(n&&!r.nextLoadLevel&&!i.fragContextChanged(t)){i.fragLoadError=0,i.state=e.State.IDLE,i.startFragRequested=!1,i.bitrateTest=!1;var s=t.stats;s.parsing.start=s.parsing.end=s.buffering.start=s.buffering.end=self.performance.now(),r.trigger(a.Events.FRAG_LOADED,n)}}))},k._handleTransmuxComplete=function(t){var i,n="main",s=this.hls,o=t.remuxResult,h=t.chunkMeta,u=this.getCurrentContext(h);if(!u)return this.warn("The loading context changed while buffering fragment "+h.sn+" of level "+h.level+". This chunk will not be buffered."),void this.resetLiveStartWhenNotLoaded(h.level);var f=u.frag,l=u.part,v=u.level,d=o.video,m=o.text,p=o.id3,g=o.initSegment,b=this.altAudio?void 0:o.audio;if(!this.fragContextChanged(f)){if(this.state=e.State.PARSING,g){g.tracks&&(this._bufferInitSegment(v,g.tracks,f,h),s.trigger(a.Events.FRAG_PARSING_INIT_SEGMENT,{frag:f,id:n,tracks:g.tracks}));var y=g.initPTS,w=g.timescale;Object(r.isFiniteNumber)(y)&&(this.initPTS[f.cc]=y,s.trigger(a.Events.INIT_PTS_FOUND,{frag:f,id:n,initPTS:y,timescale:w}))}if(d&&!1!==o.independent){if(v.details){var k=d.startPTS,T=d.endPTS,O=d.startDTS,S=d.endDTS;if(l)l.elementaryStreams[d.type]={startPTS:k,endPTS:T,startDTS:O,endDTS:S};else if(d.firstKeyFrame&&d.independent&&(this.couldBacktrack=!0),d.dropped&&d.independent){if(this.getLoadPosition()+this.config.maxBufferHole<k)return void this.backtrack(f);f.setElementaryStreamInfo(d.type,f.start,T,f.start,S,!0)}f.setElementaryStreamInfo(d.type,k,T,O,S),this.bufferFragmentData(d,f,l,h)}}else if(!1===o.independent)return void this.backtrack(f);if(b){var E=b.startPTS,A=b.endPTS,M=b.startDTS,x=b.endDTS;l&&(l.elementaryStreams[c.ElementaryStreamTypes.AUDIO]={startPTS:E,endPTS:A,startDTS:M,endDTS:x}),f.setElementaryStreamInfo(c.ElementaryStreamTypes.AUDIO,E,A,M,x),this.bufferFragmentData(b,f,l,h)}null!=p&&null!==(i=p.samples)&&void 0!==i&&i.length&&s.trigger(a.Events.FRAG_PARSING_METADATA,{frag:f,id:n,samples:p.samples}),m&&s.trigger(a.Events.FRAG_PARSING_USERDATA,{frag:f,id:n,samples:m.samples})}},k._bufferInitSegment=function(t,i,n,r){var s=this;if(this.state===e.State.PARSING){this.audioOnly=!!i.audio&&!i.video,this.altAudio&&!this.audioOnly&&delete i.audio;var o=i.audio,h=i.video,u=i.audiovideo;if(o){var c=t.audioCodec,f=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(c&&(c=-1!==c.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==o.metadata.channelCount&&-1===f.indexOf("firefox")&&(c="mp4a.40.5")),-1!==f.indexOf("android")&&"audio/mpeg"!==o.container&&this.log("Android: force audio codec to "+(c="mp4a.40.2")),t.audioCodec&&t.audioCodec!==c&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+c+'"'),o.levelCodec=c,o.id="main",this.log("Init audio buffer, container:"+o.container+", codecs[selected/level/parsed]=["+(c||"")+"/"+(t.audioCodec||"")+"/"+o.codec+"]")}h&&(h.levelCodec=t.videoCodec,h.id="main",this.log("Init video buffer, container:"+h.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+h.codec+"]")),u&&this.log("Init audiovideo buffer, container:"+u.container+", codecs[level/parsed]=["+(t.attrs.CODECS||"")+"/"+u.codec+"]"),this.hls.trigger(a.Events.BUFFER_CODECS,i),Object.keys(i).forEach((function(t){var e=i[t].initSegment;null!=e&&e.byteLength&&s.hls.trigger(a.Events.BUFFER_APPENDING,{type:t,data:e,frag:n,part:null,chunkMeta:r,parent:n.type})})),this.tick()}},k.backtrack=function(t){this.couldBacktrack=!0,this.resetTransmuxer(),this.flushBufferGap(t);var i=this.fragmentTracker.backtrack(t);this.fragPrevious=null,this.nextLoadPosition=t.start,i?this.resetFragmentLoading(t):this.state=e.State.BACKTRACKING},k.checkFragmentChanged=function(){var t=this.media,i=null;if(t&&t.readyState>1&&!1===t.seeking){var n=t.currentTime;if(o.BufferHelper.isBuffered(t,n)?i=this.getAppendedFrag(n):o.BufferHelper.isBuffered(t,n+.1)&&(i=this.getAppendedFrag(n+.1)),i){var r=this.fragPlaying,e=i.level;r&&i.sn===r.sn&&r.level===e&&i.urlId===r.urlId||(this.hls.trigger(a.Events.FRAG_CHANGED,{frag:i}),r&&r.level===e||this.hls.trigger(a.Events.LEVEL_SWITCHED,{level:e}),this.fragPlaying=i)}}},y=b,(w=[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentLevel",get:function(){var t=this.media;if(t){var i=this.getAppendedFrag(t.currentTime);if(i)return i.level}return-1}},{key:"nextBufferedFrag",get:function(){var t=this.media;if(t){var i=this.getAppendedFrag(t.currentTime);return this.followingBufferedFrag(i)}return null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}])&&p(y.prototype,w),b}(e.default)},"./src/controller/subtitle-stream-controller.ts":
94
+ /*!******************************************************!*\
95
+ !*** ./src/controller/subtitle-stream-controller.ts ***!
96
+ \******************************************************/
97
+ /*! exports provided: SubtitleStreamController */function(t,i,n){n.r(i),n.d(i,"SubtitleStreamController",(function(){return d}));var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/buffer-helper */"./src/utils/buffer-helper.ts"),s=n(/*! ./fragment-finders */"./src/controller/fragment-finders.ts"),a=n(/*! ../utils/discontinuities */"./src/utils/discontinuities.ts"),o=n(/*! ./level-helper */"./src/controller/level-helper.ts"),h=n(/*! ./fragment-tracker */"./src/controller/fragment-tracker.ts"),u=n(/*! ./base-stream-controller */"./src/controller/base-stream-controller.ts"),c=n(/*! ../types/loader */"./src/types/loader.ts"),f=n(/*! ../types/level */"./src/types/level.ts");function l(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function v(t,i){return v=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},v(t,i)}var d=function(t){var i,n;function d(i,n){var r;return(r=t.call(this,i,n,"[subtitle-stream-controller]")||this).levels=[],r.currentTrackId=-1,r.tracksBuffered=[],r.mainDetails=null,r._registerListeners(),r}n=t,(i=d).prototype=Object.create(n.prototype),i.prototype.constructor=i,v(i,n);var m,p,g=d.prototype;return g.onHandlerDestroying=function(){this._unregisterListeners(),this.mainDetails=null},g._registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.on(r.Events.ERROR,this.onError,this),t.on(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.on(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g._unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.LEVEL_LOADED,this.onLevelLoaded,this),t.off(r.Events.ERROR,this.onError,this),t.off(r.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(r.Events.SUBTITLE_TRACK_SWITCH,this.onSubtitleTrackSwitch,this),t.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(r.Events.SUBTITLE_FRAG_PROCESSED,this.onSubtitleFragProcessed,this),t.off(r.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)},g.startLoad=function(){this.stopLoad(),this.state=u.State.IDLE,this.setInterval(500),this.tick()},g.onManifestLoading=function(){this.mainDetails=null,this.fragmentTracker.removeAllFragments()},g.onLevelLoaded=function(t,i){this.mainDetails=i.details},g.onSubtitleFragProcessed=function(t,i){var n=i.frag,r=i.success;if(this.fragPrevious=n,this.state=u.State.IDLE,r){var e=this.tracksBuffered[this.currentTrackId];if(e){for(var s,a=n.start,o=0;o<e.length;o++)if(a>=e[o].start&&a<=e[o].end){s=e[o];break}var h=n.start+n.duration;s?s.end=h:e.push(s={start:a,end:h}),this.fragmentTracker.fragBuffered(n)}}},g.onBufferFlushing=function(t,i){var n=i.startOffset,r=i.endOffset;if(0===n&&r!==Number.POSITIVE_INFINITY){var e=this.currentTrackId,s=this.levels;if(!s.length||!s[e]||!s[e].details)return;var a=r-s[e].details.targetduration;if(a<=0)return;i.endOffsetSubtitles=Math.max(0,a),this.tracksBuffered.forEach((function(t){for(var i=0;i<t.length;)if(t[i].end<=a)t.shift();else{if(!(t[i].start<a))break;t[i].start=a,i++}})),this.fragmentTracker.removeFragmentsInRange(n,a,c.PlaylistLevelType.SUBTITLE)}},g.onError=function(t,i){var n,r=i.frag;r&&r.type===c.PlaylistLevelType.SUBTITLE&&(null!==(n=this.fragCurrent)&&void 0!==n&&n.loader&&this.fragCurrent.loader.abort(),this.state=u.State.IDLE)},g.onSubtitleTracksUpdated=function(t,i){var n=this,r=i.subtitleTracks;this.tracksBuffered=[],this.levels=r.map((function(t){return new f.Level(t)})),this.fragmentTracker.removeAllFragments(),this.fragPrevious=null,this.levels.forEach((function(t){n.tracksBuffered[t.id]=[]})),this.mediaBuffer=null},g.onSubtitleTrackSwitch=function(t,i){if(this.currentTrackId=i.id,this.levels.length&&-1!==this.currentTrackId){var n=this.levels[this.currentTrackId];this.mediaBuffer=null!=n&&n.details?this.mediaBufferTimeRanges:null,n&&this.setInterval(500)}else this.clearInterval()},g.onSubtitleTrackLoaded=function(t,i){var n,r=i.details,e=i.id,h=this.currentTrackId,c=this.levels;if(c.length){var f=c[h];if(!(e>=c.length||e!==h)&&f){if(this.mediaBuffer=this.mediaBufferTimeRanges,r.live||null!==(n=f.details)&&void 0!==n&&n.live){var l=this.mainDetails;if(r.deltaUpdateFailed||!l)return;var v=l.fragments[0];f.details?0===this.alignPlaylists(r,f.details)&&v&&Object(o.addSliding)(r,v.start):r.hasProgramDateTime&&l.hasProgramDateTime?Object(a.alignMediaPlaylistByPDT)(r,l):v&&Object(o.addSliding)(r,v.start)}f.details=r,this.levelLastLoaded=e,this.tick(),r.live&&!this.fragCurrent&&this.media&&this.state===u.State.IDLE&&(Object(s.findFragmentByPTS)(null,r.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),f.details=void 0))}}},g._handleFragmentLoadComplete=function(t){var i=t.frag,n=t.payload,e=i.decryptdata,s=this.hls;if(!this.fragContextChanged(i)&&n&&n.byteLength>0&&e&&e.key&&e.iv&&"AES-128"===e.method){var a=performance.now();this.decrypter.webCryptoDecrypt(new Uint8Array(n),e.key.buffer,e.iv.buffer).then((function(t){var n=performance.now();s.trigger(r.Events.FRAG_DECRYPTED,{frag:i,payload:t,stats:{tstart:a,tdecrypt:n}})}))}},g.doTick=function(){if(this.media){if(this.state===u.State.IDLE){var t,i=this.currentTrackId,n=this.levels;if(!n.length||!n[i]||!n[i].details)return;var r=n[i].details,a=r.targetduration,o=this.config,c=e.BufferHelper.bufferedInfo(this.mediaBufferTimeRanges,this.media.currentTime-a,o.maxBufferHole),f=c.end;if(c.len>this.getMaxBufferLength()+a)return;console.assert(r,"Subtitle track details are defined on idle subtitle stream controller tick");var l,v=r.fragments,d=v.length,m=this.fragPrevious;if(f<r.edge){var p=o.maxFragLookUpTolerance;!(l=Object(s.findFragmentByPTS)(m,v,f,p))&&m&&m.start<v[0].start&&(l=v[0])}else l=v[d-1];null!==(t=l)&&void 0!==t&&t.encrypted?this.loadKey(l,r):l&&this.fragmentTracker.getState(l)===h.FragmentState.NOT_LOADED&&this.loadFragment(l,r,f)}}else this.state=u.State.IDLE},g.loadFragment=function(i,n,r){this.fragCurrent=i,t.prototype.loadFragment.call(this,i,n,r)},m=d,(p=[{key:"mediaBufferTimeRanges",get:function(){return this.tracksBuffered[this.currentTrackId]||[]}}])&&l(m.prototype,p),d}(u.default)},"./src/controller/subtitle-track-controller.ts":
98
+ /*!*****************************************************!*\
99
+ !*** ./src/controller/subtitle-track-controller.ts ***!
100
+ \*****************************************************/
101
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),s=n(/*! ./base-playlist-controller */"./src/controller/base-playlist-controller.ts"),a=n(/*! ../types/loader */"./src/types/loader.ts");function o(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function h(t,i){return h=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},h(t,i)}var u=function(t){var i,n;function s(i){var n;return(n=t.call(this,i,"[subtitle-track-controller]")||this).media=null,n.tracks=[],n.groupId=null,n.tracksInGroup=[],n.trackId=-1,n.selectDefaultTrack=!0,n.queuedDefaultTrack=-1,n.trackChangeListener=function(){return n.onTextTracksChanged()},n.asyncPollTrackChange=function(){return n.pollTrackChange(0)},n.useTextTrackPolling=!1,n.subtitlePollingInterval=-1,n.subtitleDisplay=!0,n.registerListeners(),n}n=t,(i=s).prototype=Object.create(n.prototype),i.prototype.constructor=i,h(i,n);var u,f,l=s.prototype;return l.destroy=function(){this.unregisterListeners(),this.tracks.length=0,this.tracksInGroup.length=0,this.trackChangeListener=this.asyncPollTrackChange=null,t.prototype.destroy.call(this)},l.registerListeners=function(){var t=this.hls;t.on(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.on(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.on(r.Events.ERROR,this.onError,this)},l.unregisterListeners=function(){var t=this.hls;t.off(r.Events.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(r.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(r.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(r.Events.MANIFEST_PARSED,this.onManifestParsed,this),t.off(r.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(r.Events.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(r.Events.SUBTITLE_TRACK_LOADED,this.onSubtitleTrackLoaded,this),t.off(r.Events.ERROR,this.onError,this)},l.onMediaAttached=function(t,i){this.media=i.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))},l.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.trackChangeListener,t)},l.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),c(this.media.textTracks).forEach((function(t){Object(e.clearCurrentCues)(t)})),this.subtitleTrack=-1,this.media=null)},l.onManifestLoading=function(){this.tracks=[],this.groupId=null,this.tracksInGroup=[],this.trackId=-1,this.selectDefaultTrack=!0},l.onManifestParsed=function(t,i){this.tracks=i.subtitleTracks},l.onSubtitleTrackLoaded=function(t,i){var n=i.id,r=i.details,e=this.tracksInGroup[this.trackId];if(e){var s=e.details;e.details=i.details,this.log("subtitle track "+n+" loaded ["+r.startSN+"-"+r.endSN+"]"),n===this.trackId&&(this.retryCount=0,this.playlistLoaded(n,i,s))}else this.warn("Invalid subtitle track id "+n)},l.onLevelLoading=function(t,i){this.switchLevel(i.level)},l.onLevelSwitching=function(t,i){this.switchLevel(i.level)},l.switchLevel=function(t){var i=this.hls.levels[t];if(null!=i&&i.textGroupIds){var n=i.textGroupIds[i.urlId];if(this.groupId!==n){var e=this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0,s=this.tracks.filter((function(t){return!n||t.groupId===n}));this.tracksInGroup=s;var a=this.findTrackId(null==e?void 0:e.name)||this.findTrackId();this.groupId=n;var o={subtitleTracks:s};this.log("Updating subtitle tracks, "+s.length+' track(s) found in "'+n+'" group-id'),this.hls.trigger(r.Events.SUBTITLE_TRACKS_UPDATED,o),-1!==a&&this.setSubtitleTrack(a,e)}}},l.findTrackId=function(t){for(var i=this.tracksInGroup,n=0;n<i.length;n++){var r=i[n];if((!this.selectDefaultTrack||r.default)&&(!t||t===r.name))return r.id}return-1},l.onError=function(i,n){t.prototype.onError.call(this,i,n),!n.fatal&&n.context&&n.context.type===a.PlaylistContextType.SUBTITLE_TRACK&&n.context.id===this.trackId&&n.context.groupId===this.groupId&&this.retryLoadingOrFail(n)},l.loadPlaylist=function(t){var i=this.tracksInGroup[this.trackId];if(this.shouldLoadTrack(i)){var n=i.id,e=i.groupId,s=i.url;if(t)try{s=t.addDirectives(s)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+n),this.hls.trigger(r.Events.SUBTITLE_TRACK_LOADING,{url:s,id:n,groupId:e,deliveryDirectives:t||null})}},l.toggleTrackModes=function(t){var i=this,n=this.media,r=this.subtitleDisplay,e=this.trackId;if(n){var s=c(n.textTracks),a=s.filter((function(t){return t.groupId===i.groupId}));if(-1===t)[].slice.call(s).forEach((function(t){t.mode="disabled"}));else{var o=a[e];o&&(o.mode="disabled")}var h=a[t];h&&(h.mode=r?"showing":"hidden")}},l.setSubtitleTrack=function(t,i){var n,e=this.tracksInGroup;if(this.media){if(this.trackId!==t&&this.toggleTrackModes(t),!(this.trackId===t&&(-1===t||null!==(n=e[t])&&void 0!==n&&n.details)||t<-1||t>=e.length)){this.clearTimer();var s=e[t];if(this.log("Switching to subtitle track "+t),this.trackId=t,s){var a=s.groupId;this.hls.trigger(r.Events.SUBTITLE_TRACK_SWITCH,{id:s.id,groupId:void 0===a?"":a,name:s.name,type:s.type,url:s.url});var o=this.switchParams(s.url,null==i?void 0:i.details);this.loadPlaylist(o)}else this.hls.trigger(r.Events.SUBTITLE_TRACK_SWITCH,{id:t})}}else this.queuedDefaultTrack=t},l.onTextTracksChanged=function(){if(this.useTextTrackPolling||self.clearInterval(this.subtitlePollingInterval),this.media&&this.hls.config.renderTextTracksNatively){for(var t=-1,i=c(this.media.textTracks),n=0;n<i.length;n++)if("hidden"===i[n].mode)t=n;else if("showing"===i[n].mode){t=n;break}this.subtitleTrack!==t&&(this.subtitleTrack=t)}},u=s,(f=[{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t,this.tracksInGroup?this.tracksInGroup[this.trackId]:void 0)}}])&&o(u.prototype,f),s}(s.default);function c(t){for(var i=[],n=0;n<t.length;n++){var r=t[n];"subtitles"===r.kind&&r.label&&i.push(t[n])}return i}i.default=u},"./src/controller/timeline-controller.ts":
102
+ /*!***********************************************!*\
103
+ !*** ./src/controller/timeline-controller.ts ***!
104
+ \***********************************************/
105
+ /*! exports provided: TimelineController */function(t,i,n){n.r(i),n.d(i,"TimelineController",(function(){return l}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/cea-608-parser */"./src/utils/cea-608-parser.ts"),a=n(/*! ../utils/output-filter */"./src/utils/output-filter.ts"),o=n(/*! ../utils/webvtt-parser */"./src/utils/webvtt-parser.ts"),h=n(/*! ../utils/texttrack-utils */"./src/utils/texttrack-utils.ts"),u=n(/*! ../utils/imsc1-ttml-parser */"./src/utils/imsc1-ttml-parser.ts"),c=n(/*! ../types/loader */"./src/types/loader.ts"),f=n(/*! ../utils/logger */"./src/utils/logger.ts"),l=function(){function t(t){if(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.timescale=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.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}},this.config.enableCEA708Captions){var i=new a.default(this,"textTrack1"),n=new a.default(this,"textTrack2"),r=new a.default(this,"textTrack3"),o=new a.default(this,"textTrack4");this.cea608Parser1=new s.default(1,i,n),this.cea608Parser2=new s.default(3,r,o)}t.on(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(e.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(e.Events.FRAG_LOADING,this.onFragLoading,this),t.on(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.on(e.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(e.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(e.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(e.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this)}var i=t.prototype;return i.destroy=function(){var t=this.hls;t.off(e.Events.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(e.Events.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(e.Events.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(e.Events.FRAG_LOADING,this.onFragLoading,this),t.off(e.Events.FRAG_LOADED,this.onFragLoaded,this),t.off(e.Events.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(e.Events.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(e.Events.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(e.Events.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(e.Events.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=this.cea608Parser1=this.cea608Parser2=null},i.addCues=function(t,i,n,r,s){for(var a,o,h=!1,u=s.length;u--;){var c=s[u],f=(a=c[0],o=i,Math.min(c[1],n)-Math.max(a,o));if(f>=0&&(c[0]=Math.min(c[0],i),c[1]=Math.max(c[1],n),h=!0,f/(n-i)>.5))return}if(h||s.push([i,n]),this.config.renderTextTracksNatively)this.Cues.newCue(this.captionsTracks[t],i,n,r);else{var l=this.Cues.newCue(null,i,n,r);this.hls.trigger(e.Events.CUES_PARSED,{type:"captions",cues:l,track:t})}},i.onInitPtsFound=function(t,i){var n=this,r=i.frag,s=i.timescale,a=this.unparsedVttFrags;"main"===i.id&&(this.initPTS[r.cc]=i.initPTS,this.timescale[r.cc]=s),a.length&&(this.unparsedVttFrags=[],a.forEach((function(t){n.onFragLoaded(e.Events.FRAG_LOADED,t)})))},i.getExistingTrack=function(t){var i=this.media;if(i)for(var n=0;n<i.textTracks.length;n++){var r=i.textTracks[n];if(r[t])return r}return null},i.createCaptionsTrack=function(t){this.config.renderTextTracksNatively?this.createNativeTrack(t):this.createNonNativeTrack(t)},i.createNativeTrack=function(t){if(!this.captionsTracks[t]){var i=this.captionsTracks,n=this.media,r=this.captionsProperties[t],e=r.label,s=r.languageCode,a=this.getExistingTrack(t);if(a)i[t]=a,Object(h.clearCurrentCues)(i[t]),Object(h.sendAddTrackEvent)(i[t],n);else{var o=this.createTextTrack("captions",e,s);o&&(o[t]=!0,i[t]=o)}}},i.createNonNativeTrack=function(t){if(!this.nonNativeCaptionsTracks[t]){var i=this.captionsProperties[t];if(i){var n={_id:t,label:i.label,kind:"captions",default:!!i.media&&!!i.media.default,closedCaptions:i.media};this.nonNativeCaptionsTracks[t]=n,this.hls.trigger(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:[n]})}}},i.createTextTrack=function(t,i,n){var r=this.media;if(r)return r.addTextTrack(t,i,n)},i.onMediaAttaching=function(t,i){this.media=i.media,this._cleanTracks()},i.onMediaDetaching=function(){var t=this.captionsTracks;Object.keys(t).forEach((function(i){Object(h.clearCurrentCues)(t[i]),delete t[i]})),this.nonNativeCaptionsTracks={}},i.onManifestLoading=function(){this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!1}},this._cleanTracks(),this.tracks=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.textTracks=[],this.unparsedVttFrags=this.unparsedVttFrags||[],this.initPTS=[],this.timescale=[],this.cea608Parser1&&this.cea608Parser2&&(this.cea608Parser1.reset(),this.cea608Parser2.reset())},i._cleanTracks=function(){var t=this.media;if(t){var i=t.textTracks;if(i)for(var n=0;n<i.length;n++)Object(h.clearCurrentCues)(i[n])}},i.onSubtitleTracksUpdated=function(t,i){var n=this;this.textTracks=[];var r=i.subtitleTracks||[],s=r.some((function(t){return t.textCodec===u.IMSC1_CODEC}));if(this.config.enableWebVTT||s&&this.config.enableIMSC1){var a=this.tracks&&r&&this.tracks.length===r.length;if(this.tracks=r||[],this.config.renderTextTracksNatively){var o=this.media?this.media.textTracks:[];this.tracks.forEach((function(t,i){var r;if(i<o.length){for(var e=null,s=0;s<o.length;s++)if(v(o[s],t)){e=o[s];break}e&&(r=e)}r?Object(h.clearCurrentCues)(r):(r=n.createTextTrack("subtitles",t.name,t.lang))&&(r.mode="disabled"),r&&(r.groupId=t.groupId,n.textTracks.push(r))}))}else if(!a&&this.tracks&&this.tracks.length){var c=this.tracks.map((function(t){return{label:t.name,kind:t.type.toLowerCase(),default:t.default,subtitleTrack:t}}));this.hls.trigger(e.Events.NON_NATIVE_TEXT_TRACKS_FOUND,{tracks:c})}}},i.onManifestLoaded=function(t,i){var n=this;this.config.enableCEA708Captions&&i.captions&&i.captions.forEach((function(t){var i=/(?:CC|SERVICE)([1-4])/.exec(t.instreamId);if(i){var r=n.captionsProperties["textTrack"+i[1]];r&&(r.label=t.name,t.lang&&(r.languageCode=t.lang),r.media=t)}}))},i.onFragLoading=function(t,i){var n=this.cea608Parser1,r=this.cea608Parser2,e=this.lastSn;if(this.enabled&&n&&r&&i.frag.type===c.PlaylistLevelType.MAIN){var s,a,o=i.frag.sn,h=null!=(s=null==i||null===(a=i.part)||void 0===a?void 0:a.index)?s:-1;o===e+1||o===e&&h===this.lastPartIndex+1||(n.reset(),r.reset()),this.lastSn=o,this.lastPartIndex=h}},i.onFragLoaded=function(t,i){var n=i.frag,s=i.payload,a=this.initPTS,o=this.unparsedVttFrags;if(n.type===c.PlaylistLevelType.SUBTITLE)if(s.byteLength){if(!Object(r.isFiniteNumber)(a[n.cc]))return o.push(i),void(a.length&&this.hls.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Missing initial subtitle PTS")}));var h=n.decryptdata;if(null==h||null==h.key||"AES-128"!==h.method||"stats"in i){var f=this.tracks[n.level],l=this.vttCCs;l[n.cc]||(l[n.cc]={start:n.start,prevCC:this.prevCC,new:!0},this.prevCC=n.cc),f&&f.textCodec===u.IMSC1_CODEC?this._parseIMSC1(n,s):this._parseVTTs(n,s,l)}}else this.hls.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:n,error:new Error("Empty subtitle payload")})},i._parseIMSC1=function(t,i){var n=this,r=this.hls;Object(u.parseIMSC1)(i,this.initPTS[t.cc],this.timescale[t.cc],(function(i){n._appendCues(i,t.level),r.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(i){f.logger.log("Failed to parse IMSC1: "+i),r.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:i})}))},i._parseVTTs=function(t,i,n){var r=this,s=this.hls;Object(o.parseWebVTT)(i,this.initPTS[t.cc],this.timescale[t.cc],n,t.cc,t.start,(function(i){r._appendCues(i,t.level),s.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!0,frag:t})}),(function(n){r._fallbackToIMSC1(t,i),f.logger.log("Failed to parse VTT cue: "+n),s.trigger(e.Events.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:t,error:n})}))},i._fallbackToIMSC1=function(t,i){var n=this,r=this.tracks[t.level];r.textCodec||Object(u.parseIMSC1)(i,this.initPTS[t.cc],this.timescale[t.cc],(function(){r.textCodec=u.IMSC1_CODEC,n._parseIMSC1(t,i)}),(function(){r.textCodec="wvtt"}))},i._appendCues=function(t,i){var n=this.hls;if(this.config.renderTextTracksNatively){var r=this.textTracks[i];if("disabled"===r.mode)return;t.forEach((function(t){return Object(h.addCueToTrack)(r,t)}))}else n.trigger(e.Events.CUES_PARSED,{type:"subtitles",cues:t,track:this.tracks[i].default?"default":"subtitles"+i})},i.onFragDecrypted=function(t,i){var n=i.frag;if(n.type===c.PlaylistLevelType.SUBTITLE){if(!Object(r.isFiniteNumber)(this.initPTS[n.cc]))return void this.unparsedVttFrags.push(i);this.onFragLoaded(e.Events.FRAG_LOADED,i)}},i.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},i.onFragParsingUserdata=function(t,i){var n=this.cea608Parser1,r=this.cea608Parser2;if(this.enabled&&n&&r)for(var e=0;e<i.samples.length;e++){var s=i.samples[e].bytes;if(s){var a=this.extractCea608Data(s);n.addData(i.samples[e].pts,a[0]),r.addData(i.samples[e].pts,a[1])}}},i.onBufferFlushing=function(t,i){var n=i.startOffset,r=i.endOffset,e=i.endOffsetSubtitles,s=i.type,a=this.media;if(a&&!(a.currentTime<r)){if(!s||"video"===s){var o=this.captionsTracks;Object.keys(o).forEach((function(t){return Object(h.removeCuesInRange)(o[t],n,r)}))}if(this.config.renderTextTracksNatively&&0===n&&void 0!==e){var u=this.textTracks;Object.keys(u).forEach((function(t){return Object(h.removeCuesInRange)(u[t],n,e)}))}}},i.extractCea608Data=function(t){for(var i=31&t[0],n=2,r=[[],[]],e=0;e<i;e++){var s=t[n++],a=127&t[n++],o=127&t[n++],h=3&s;0===a&&0===o||0!=(4&s)&&(0!==h&&1!==h||(r[h].push(a),r[h].push(o)))}return r},t}();function v(t,i){return t&&t.label===i.name&&!(t.textTrack1||t.textTrack2)}},"./src/crypt/aes-crypto.ts":
106
+ /*!*********************************!*\
107
+ !*** ./src/crypt/aes-crypto.ts ***!
108
+ \*********************************/
109
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(t,i){this.subtle=void 0,this.aesIV=void 0,this.subtle=t,this.aesIV=i}return t.prototype.decrypt=function(t,i){return this.subtle.decrypt({name:"AES-CBC",iv:this.aesIV},i,t)},t}()},"./src/crypt/aes-decryptor.ts":
110
+ /*!************************************!*\
111
+ !*** ./src/crypt/aes-decryptor.ts ***!
112
+ \************************************/
113
+ /*! exports provided: removePadding, default */function(t,i,n){n.r(i),n.d(i,"removePadding",(function(){return e})),n.d(i,"default",(function(){return s}));var r=n(/*! ../utils/typed-array */"./src/utils/typed-array.ts");function e(t){var i=t.byteLength,n=i&&new DataView(t.buffer).getUint8(i-1);return n?Object(r.sliceUint8)(t,0,i-n):t}var s=function(){function t(){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()}var i=t.prototype;return i.uint8ArrayToUint32Array_=function(t){for(var i=new DataView(t),n=new Uint32Array(4),r=0;r<4;r++)n[r]=i.getUint32(4*r);return n},i.initTable=function(){var t=this.sBox,i=this.invSBox,n=this.subMix,r=n[0],e=n[1],s=n[2],a=n[3],o=this.invSubMix,h=o[0],u=o[1],c=o[2],f=o[3],l=new Uint32Array(256),v=0,d=0,m=0;for(m=0;m<256;m++)l[m]=m<128?m<<1:m<<1^283;for(m=0;m<256;m++){var p=d^d<<1^d<<2^d<<3^d<<4;t[v]=p=p>>>8^255&p^99,i[p]=v;var g=l[v],b=l[g],y=l[b],w=257*l[p]^16843008*p;r[v]=w<<24|w>>>8,e[v]=w<<16|w>>>16,s[v]=w<<8|w>>>24,a[v]=w,h[p]=(w=16843009*y^65537*b^257*g^16843008*v)<<24|w>>>8,u[p]=w<<16|w>>>16,c[p]=w<<8|w>>>24,f[p]=w,v?(v=g^l[l[l[y^g]]],d^=l[l[d]]):v=d=1}},i.expandKey=function(t){for(var i=this.uint8ArrayToUint32Array_(t),n=!0,r=0;r<i.length&&n;)n=i[r]===this.key[r],r++;if(!n){this.key=i;var e=this.keySize=i.length;if(4!==e&&6!==e&&8!==e)throw new Error("Invalid aes key size="+e);var s,a,o,h,u=this.ksRows=4*(e+6+1),c=this.keySchedule=new Uint32Array(u),f=this.invKeySchedule=new Uint32Array(u),l=this.sBox,v=this.rcon,d=this.invSubMix,m=d[0],p=d[1],g=d[2],b=d[3];for(s=0;s<u;s++)s<e?o=c[s]=i[s]:(h=o,s%e==0?(h=l[(h=h<<8|h>>>24)>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[255&h],h^=v[s/e|0]<<24):e>6&&s%e==4&&(h=l[h>>>24]<<24|l[h>>>16&255]<<16|l[h>>>8&255]<<8|l[255&h]),c[s]=o=(c[s-e]^h)>>>0);for(a=0;a<u;a++)s=u-a,h=3&a?c[s]:c[s-4],f[a]=a<4||s<=4?h:m[l[h>>>24]]^p[l[h>>>16&255]]^g[l[h>>>8&255]]^b[l[255&h]],f[a]=f[a]>>>0}},i.networkToHostOrderSwap=function(t){return t<<24|(65280&t)<<8|(16711680&t)>>8|t>>>24},i.decrypt=function(t,i,n){for(var r,e,s,a,o,h,u,c,f,l,v,d,m,p=this.keySize+6,g=this.invKeySchedule,b=this.invSBox,y=this.invSubMix,w=y[0],k=y[1],T=y[2],O=y[3],S=this.uint8ArrayToUint32Array_(n),E=S[0],A=S[1],M=S[2],x=S[3],j=new Int32Array(t),D=new Int32Array(j.length),L=this.networkToHostOrderSwap;i<j.length;){for(c=L(j[i]),f=L(j[i+1]),l=L(j[i+2]),v=L(j[i+3]),a=c^g[0],o=v^g[1],h=l^g[2],u=f^g[3],d=4,m=1;m<p;m++)r=w[o>>>24]^k[h>>16&255]^T[u>>8&255]^O[255&a]^g[d+1],e=w[h>>>24]^k[u>>16&255]^T[a>>8&255]^O[255&o]^g[d+2],s=w[u>>>24]^k[a>>16&255]^T[o>>8&255]^O[255&h]^g[d+3],a=w[a>>>24]^k[o>>16&255]^T[h>>8&255]^O[255&u]^g[d],o=r,h=e,u=s,d+=4;r=b[o>>>24]<<24^b[h>>16&255]<<16^b[u>>8&255]<<8^b[255&a]^g[d+1],e=b[h>>>24]<<24^b[u>>16&255]<<16^b[a>>8&255]<<8^b[255&o]^g[d+2],s=b[u>>>24]<<24^b[a>>16&255]<<16^b[o>>8&255]<<8^b[255&h]^g[d+3],D[i]=L(b[a>>>24]<<24^b[o>>16&255]<<16^b[h>>8&255]<<8^b[255&u]^g[d]^E),D[i+1]=L(s^A),D[i+2]=L(e^M),D[i+3]=L(r^x),E=c,A=f,M=l,x=v,i+=4}return D.buffer},t}()},"./src/crypt/decrypter.ts":
114
+ /*!********************************!*\
115
+ !*** ./src/crypt/decrypter.ts ***!
116
+ \********************************/
117
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return u}));var r=n(/*! ./aes-crypto */"./src/crypt/aes-crypto.ts"),e=n(/*! ./fast-aes-key */"./src/crypt/fast-aes-key.ts"),s=n(/*! ./aes-decryptor */"./src/crypt/aes-decryptor.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=n(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),u=function(){function t(t,i,n){var r=(void 0===n?{}:n).removePKCS7Padding,e=void 0===r||r;if(this.logEnabled=!0,this.observer=void 0,this.config=void 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.observer=t,this.config=i,this.removePKCS7Padding=e,e)try{var s=self.crypto;s&&(this.subtle=s.subtle||s.webkitSubtle)}catch(t){}null===this.subtle&&(this.config.enableSoftwareAES=!0)}var i=t.prototype;return i.destroy=function(){this.observer=null},i.isSync=function(){return this.config.enableSoftwareAES},i.flush=function(){var t=this.currentResult;if(t){var i=new Uint8Array(t);return this.reset(),this.removePKCS7Padding?Object(s.removePadding)(i):i}this.reset()},i.reset=function(){this.currentResult=null,this.currentIV=null,this.remainderData=null,this.softwareDecrypter&&(this.softwareDecrypter=null)},i.decrypt=function(t,i,n,r){if(this.config.enableSoftwareAES){this.softwareDecrypt(new Uint8Array(t),i,n);var e=this.flush();e&&r(e.buffer)}else this.webCryptoDecrypt(new Uint8Array(t),i,n).then(r)},i.softwareDecrypt=function(t,i,n){var r=this.currentIV,e=this.currentResult,a=this.remainderData;this.logOnce("JS AES decrypt"),a&&(t=Object(o.appendUint8Array)(a,t),this.remainderData=null);var u=this.getValidChunk(t);if(!u.length)return null;r&&(n=r);var c=this.softwareDecrypter;c||(c=this.softwareDecrypter=new s.default),c.expandKey(i);var f=e;return this.currentResult=c.decrypt(u.buffer,0,n),this.currentIV=Object(h.sliceUint8)(u,-16).buffer,f||null},i.webCryptoDecrypt=function(t,i,n){var s=this,a=this.subtle;return this.key===i&&this.fastAesKey||(this.key=i,this.fastAesKey=new e.default(a,i)),this.fastAesKey.expandKey().then((function(i){return a?new r.default(a,n).decrypt(t.buffer,i):Promise.reject(new Error("web crypto not initialized"))})).catch((function(r){return s.onWebCryptoError(r,t,i,n)}))},i.onWebCryptoError=function(t,i,n,r){return a.logger.warn("[decrypter.ts]: WebCrypto Error, disable WebCrypto API:",t),this.config.enableSoftwareAES=!0,this.logEnabled=!0,this.softwareDecrypt(i,n,r)},i.getValidChunk=function(t){var i=t,n=t.length-t.length%16;return n!==t.length&&(i=Object(h.sliceUint8)(t,0,n),this.remainderData=Object(h.sliceUint8)(t,n)),i},i.logOnce=function(t){this.logEnabled&&(a.logger.log("[decrypter.ts]: "+t),this.logEnabled=!1)},t}()},"./src/crypt/fast-aes-key.ts":
118
+ /*!***********************************!*\
119
+ !*** ./src/crypt/fast-aes-key.ts ***!
120
+ \***********************************/
121
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(t,i){this.subtle=void 0,this.key=void 0,this.subtle=t,this.key=i}return t.prototype.expandKey=function(){return this.subtle.importKey("raw",this.key,{name:"AES-CBC"},!1,["encrypt","decrypt"])},t}()},"./src/demux/aacdemuxer.ts":
122
+ /*!*********************************!*\
123
+ !*** ./src/demux/aacdemuxer.ts ***!
124
+ \*********************************/
125
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),e=n(/*! ./adts */"./src/demux/adts.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ../demux/id3 */"./src/demux/id3.ts");function o(t,i){return o=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},o(t,i)}var h=function(t){var i,n;function r(i,n){var r;return(r=t.call(this)||this).observer=void 0,r.config=void 0,r.observer=i,r.config=n,r}n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,o(i,n);var h=r.prototype;return h.resetInitSegment=function(i,n,r){t.prototype.resetInitSegment.call(this,i,n,r),this._audioTrack={container:"audio/adts",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!0,samples:[],manifestCodec:i,duration:r,inputTimeScale:9e4,dropped:0}},r.probe=function(t){if(!t)return!1;for(var i=(a.getID3Data(t,0)||[]).length,n=t.length;i<n;i++)if(e.probe(t,i))return s.logger.log("ADTS sync word found !"),!0;return!1},h.canParse=function(t,i){return e.canParse(t,i)},h.appendFrame=function(t,i,n){e.initTrackConfig(t,this.observer,i,n,t.manifestCodec);var r=e.appendFrame(t,i,n,this.initPTS,this.frameIndex);if(r&&0===r.missing)return r},r}(r.default);h.minProbeByteLength=9,i.default=h},"./src/demux/adts.ts":
126
+ /*!***************************!*\
127
+ !*** ./src/demux/adts.ts ***!
128
+ \***************************/
129
+ /*! exports provided: getAudioConfig, isHeaderPattern, getHeaderLength, getFullFrameLength, canGetFrameLength, isHeader, canParse, probe, initTrackConfig, getFrameDuration, parseFrameHeader, appendFrame */function(t,i,n){n.r(i),n.d(i,"getAudioConfig",(function(){return a})),n.d(i,"isHeaderPattern",(function(){return o})),n.d(i,"getHeaderLength",(function(){return h})),n.d(i,"getFullFrameLength",(function(){return u})),n.d(i,"canGetFrameLength",(function(){return c})),n.d(i,"isHeader",(function(){return f})),n.d(i,"canParse",(function(){return l})),n.d(i,"probe",(function(){return v})),n.d(i,"initTrackConfig",(function(){return d})),n.d(i,"getFrameDuration",(function(){return m})),n.d(i,"parseFrameHeader",(function(){return p})),n.d(i,"appendFrame",(function(){return g}));var r=n(/*! ../utils/logger */"./src/utils/logger.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../events */"./src/events.ts");function a(t,i,n,a){var o,h,u,c,f=navigator.userAgent.toLowerCase(),l=a,v=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];o=1+((192&i[n+2])>>>6);var d=(60&i[n+2])>>>2;if(!(d>v.length-1))return u=(1&i[n+2])<<2,u|=(192&i[n+3])>>>6,r.logger.log("manifest codec:"+a+", ADTS type:"+o+", samplingIndex:"+d),/firefox/i.test(f)?d>=6?(o=5,c=new Array(4),h=d-3):(o=2,c=new Array(2),h=d):-1!==f.indexOf("android")?(o=2,c=new Array(2),h=d):(o=5,c=new Array(4),a&&(-1!==a.indexOf("mp4a.40.29")||-1!==a.indexOf("mp4a.40.5"))||!a&&d>=6?h=d-3:((a&&-1!==a.indexOf("mp4a.40.2")&&(d>=6&&1===u||/vivaldi/i.test(f))||!a&&1===u)&&(o=2,c=new Array(2)),h=d)),c[0]=o<<3,c[0]|=(14&d)>>1,c[1]|=(1&d)<<7,c[1]|=u<<3,5===o&&(c[1]|=(14&h)>>1,c[2]=(1&h)<<7,c[2]|=8,c[3]=0),{config:c,samplerate:v[d],channelCount:u,codec:"mp4a.40."+o,manifestCodec:l};t.trigger(s.Events.ERROR,{type:e.ErrorTypes.MEDIA_ERROR,details:e.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"invalid ADTS sampling index:"+d})}function o(t,i){return 255===t[i]&&240==(246&t[i+1])}function h(t,i){return 1&t[i+1]?7:9}function u(t,i){return(3&t[i+3])<<11|t[i+4]<<3|(224&t[i+5])>>>5}function c(t,i){return i+5<t.length}function f(t,i){return i+1<t.length&&o(t,i)}function l(t,i){return c(t,i)&&o(t,i)&&u(t,i)<=t.length-i}function v(t,i){if(f(t,i)){var n=h(t,i);if(i+n>=t.length)return!1;var r=u(t,i);if(r<=n)return!1;var e=i+r;return e===t.length||f(t,e)}return!1}function d(t,i,n,e,s){if(!t.samplerate){var o=a(i,n,e,s);if(!o)return;t.config=o.config,t.samplerate=o.samplerate,t.channelCount=o.channelCount,t.codec=o.codec,t.manifestCodec=o.manifestCodec,r.logger.log("parsed codec:"+t.codec+", rate:"+o.samplerate+", channels:"+o.channelCount)}}function m(t){return 9216e4/t}function p(t,i,n,r,e){var s=h(t,i),a=u(t,i);if((a-=s)>0)return{headerLength:s,frameLength:a,stamp:n+r*e}}function g(t,i,n,r,e){var s=p(i,n,r,e,m(t.samplerate));if(s){var a,o=s.headerLength,h=s.stamp,u=o+s.frameLength,c=Math.max(0,n+u-i.length);c?(a=new Uint8Array(u-o)).set(i.subarray(n+o,i.length),0):a=i.subarray(n+o,n+u);var f={unit:a,pts:h};return c||t.samples.push(f),{sample:f,length:u,missing:c}}}},"./src/demux/base-audio-demuxer.ts":
130
+ /*!*****************************************!*\
131
+ !*** ./src/demux/base-audio-demuxer.ts ***!
132
+ \*****************************************/
133
+ /*! exports provided: initPTSFn, default */function(t,i,n){n.r(i),n.d(i,"initPTSFn",(function(){return u}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../demux/id3 */"./src/demux/id3.ts"),s=n(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),a=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),o=n(/*! ../utils/typed-array */"./src/utils/typed-array.ts"),h=function(){function t(){this._audioTrack=void 0,this._id3Track=void 0,this.frameIndex=0,this.cachedData=null,this.initPTS=null}var i=t.prototype;return i.resetInitSegment=function(){this._id3Track={type:"id3",id:3,pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0}},i.resetTimeStamp=function(){},i.resetContiguity=function(){},i.canParse=function(){return!1},i.appendFrame=function(){},i.demux=function(t,i){this.cachedData&&(t=Object(a.appendUint8Array)(this.cachedData,t),this.cachedData=null);var n,r,h=e.getID3Data(t,0),c=h?h.length:0,f=this._audioTrack,l=this._id3Track,v=h?e.getTimeStamp(h):void 0,d=t.length;for(0!==this.frameIndex&&null!==this.initPTS||(this.initPTS=u(v,i)),h&&h.length>0&&l.samples.push({pts:this.initPTS,dts:this.initPTS,data:h}),r=this.initPTS;c<d;){if(this.canParse(t,c)){var m=this.appendFrame(f,t,c);m?(this.frameIndex++,r=m.sample.pts,n=c+=m.length):c=d}else e.canParse(t,c)?(h=e.getID3Data(t,c),l.samples.push({pts:r,dts:r,data:h}),n=c+=h.length):c++;if(c===d&&n!==d){var p=Object(o.sliceUint8)(t,n);this.cachedData=this.cachedData?Object(a.appendUint8Array)(this.cachedData,p):p}}return{audioTrack:f,avcTrack:Object(s.dummyTrack)(),id3Track:l,textTrack:Object(s.dummyTrack)()}},i.demuxSampleAes=function(){return Promise.reject(new Error("["+this+"] This demuxer does not support Sample-AES decryption"))},i.flush=function(){var t=this.cachedData;return t&&(this.cachedData=null,this.demux(t,0)),this.frameIndex=0,{audioTrack:this._audioTrack,avcTrack:Object(s.dummyTrack)(),id3Track:this._id3Track,textTrack:Object(s.dummyTrack)()}},i.destroy=function(){},t}(),u=function(t,i){return Object(r.isFiniteNumber)(t)?90*t:9e4*i};i.default=h},"./src/demux/chunk-cache.ts":
134
+ /*!**********************************!*\
135
+ !*** ./src/demux/chunk-cache.ts ***!
136
+ \**********************************/
137
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(){this.chunks=[],this.dataLength=0}var i=t.prototype;return i.push=function(t){this.chunks.push(t),this.dataLength+=t.length},i.flush=function(){var t,i=this.chunks;return i.length?(t=1===i.length?i[0]:function(t,i){for(var n=new Uint8Array(i),r=0,e=0;e<t.length;e++){var s=t[e];n.set(s,r),r+=s.length}return n}(i,this.dataLength),this.reset(),t):new Uint8Array(0)},i.reset=function(){this.chunks.length=0,this.dataLength=0},t}()},"./src/demux/dummy-demuxed-track.ts":
138
+ /*!******************************************!*\
139
+ !*** ./src/demux/dummy-demuxed-track.ts ***!
140
+ \******************************************/
141
+ /*! exports provided: dummyTrack */function(t,i,n){function r(){return{type:"",id:-1,pid:-1,inputTimeScale:9e4,sequenceNumber:-1,samples:[],dropped:0}}n.r(i),n.d(i,"dummyTrack",(function(){return r}))},"./src/demux/exp-golomb.ts":
142
+ /*!*********************************!*\
143
+ !*** ./src/demux/exp-golomb.ts ***!
144
+ \*********************************/
145
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/logger */"./src/utils/logger.ts");i.default=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var i=t.prototype;return i.loadWord=function(){var t=this.data,i=this.bytesAvailable,n=t.byteLength-i,r=new Uint8Array(4),e=Math.min(4,i);if(0===e)throw new Error("no bytes available");r.set(t.subarray(n,n+e)),this.word=new DataView(r.buffer).getUint32(0),this.bitsAvailable=8*e,this.bytesAvailable-=e},i.skipBits=function(t){var i;this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(i=t>>3)>>3,this.bytesAvailable-=i,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},i.readBits=function(t){var i=Math.min(this.bitsAvailable,t),n=this.word>>>32-i;return t>32&&r.logger.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=i,this.bitsAvailable>0?this.word<<=i:this.bytesAvailable>0&&this.loadWord(),(i=t-i)>0&&this.bitsAvailable?n<<i|this.readBits(i):n},i.skipLZ=function(){var t;for(t=0;t<this.bitsAvailable;++t)if(0!=(this.word&2147483648>>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},i.skipUEG=function(){this.skipBits(1+this.skipLZ())},i.skipEG=function(){this.skipBits(1+this.skipLZ())},i.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},i.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},i.readBoolean=function(){return 1===this.readBits(1)},i.readUByte=function(){return this.readBits(8)},i.readUShort=function(){return this.readBits(16)},i.readUInt=function(){return this.readBits(32)},i.skipScalingList=function(t){for(var i=8,n=8,r=0;r<t;r++)0!==n&&(n=(i+this.readEG()+256)%256),i=0===n?i:n},i.readSPS=function(){var t,i,n,r=0,e=0,s=0,a=0,o=this.readUByte.bind(this),h=this.readBits.bind(this),u=this.readUEG.bind(this),c=this.readBoolean.bind(this),f=this.skipBits.bind(this),l=this.skipEG.bind(this),v=this.skipUEG.bind(this),d=this.skipScalingList.bind(this);o();var m=o();if(h(5),f(3),o(),v(),100===m||110===m||122===m||244===m||44===m||83===m||86===m||118===m||128===m){var p=u();if(3===p&&f(1),v(),v(),f(1),c())for(i=3!==p?8:12,n=0;n<i;n++)c()&&d(n<6?16:64)}v();var g=u();if(0===g)u();else if(1===g)for(f(1),l(),l(),t=u(),n=0;n<t;n++)l();v(),f(1);var b=u(),y=u(),w=h(1);0===w&&f(1),f(1),c()&&(r=u(),e=u(),s=u(),a=u());var k=[1,1];if(c()&&c())switch(o()){case 1:k=[1,1];break;case 2:k=[12,11];break;case 3:k=[10,11];break;case 4:k=[16,11];break;case 5:k=[40,33];break;case 6:k=[24,11];break;case 7:k=[20,11];break;case 8:k=[32,11];break;case 9:k=[80,33];break;case 10:k=[18,11];break;case 11:k=[15,11];break;case 12:k=[64,33];break;case 13:k=[160,99];break;case 14:k=[4,3];break;case 15:k=[3,2];break;case 16:k=[2,1];break;case 255:k=[o()<<8|o(),o()<<8|o()]}return{width:Math.ceil(16*(b+1)-2*r-2*e),height:(2-w)*(y+1)*16-(w?2:4)*(s+a),pixelRatio:k}},i.readSliceType=function(){return this.readUByte(),this.readUEG(),this.readUEG()},t}()},"./src/demux/id3.ts":
146
+ /*!**************************!*\
147
+ !*** ./src/demux/id3.ts ***!
148
+ \**************************/
149
+ /*! exports provided: isHeader, isFooter, getID3Data, canParse, getTimeStamp, isTimeStampFrame, getID3Frames, decodeFrame, utf8ArrayToStr, testables */function(t,i,n){n.r(i),n.d(i,"isHeader",(function(){return e})),n.d(i,"isFooter",(function(){return s})),n.d(i,"getID3Data",(function(){return a})),n.d(i,"canParse",(function(){return h})),n.d(i,"getTimeStamp",(function(){return u})),n.d(i,"isTimeStampFrame",(function(){return c})),n.d(i,"getID3Frames",(function(){return l})),n.d(i,"decodeFrame",(function(){return v})),n.d(i,"utf8ArrayToStr",(function(){return b})),n.d(i,"testables",(function(){return y}));var r,e=function(t,i){return i+10<=t.length&&73===t[i]&&68===t[i+1]&&51===t[i+2]&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},s=function(t,i){return i+10<=t.length&&51===t[i]&&68===t[i+1]&&73===t[i+2]&&t[i+3]<255&&t[i+4]<255&&t[i+6]<128&&t[i+7]<128&&t[i+8]<128&&t[i+9]<128},a=function(t,i){for(var n=i,r=0;e(t,i);)r+=10,r+=o(t,i+6),s(t,i+10)&&(r+=10),i+=r;if(r>0)return t.subarray(n,n+r)},o=function(t,i){var n=0;return n=(127&t[i])<<21,n|=(127&t[i+1])<<14,(n|=(127&t[i+2])<<7)|127&t[i+3]},h=function(t,i){return e(t,i)&&o(t,i+6)+10<=t.length-i},u=function(t){for(var i=l(t),n=0;n<i.length;n++){var r=i[n];if(c(r))return g(r)}},c=function(t){return t&&"PRIV"===t.key&&"com.apple.streaming.transportStreamTimestamp"===t.info},f=function(t){var i=String.fromCharCode(t[0],t[1],t[2],t[3]),n=o(t,4);return{type:i,size:n,data:t.subarray(10,10+n)}},l=function(t){for(var i=0,n=[];e(t,i);){for(var r=o(t,i+6),a=(i+=10)+r;i+8<a;){var h=f(t.subarray(i)),u=v(h);u&&n.push(u),i+=h.size+10}s(t,i)&&(i+=10)}return n},v=function(t){return"PRIV"===t.type?d(t):"W"===t.type[0]?p(t):m(t)},d=function(t){if(!(t.size<2)){var i=b(t.data,!0),n=new Uint8Array(t.data.subarray(i.length+1));return{key:t.type,info:i,data:n.buffer}}},m=function(t){if(!(t.size<2)){if("TXXX"===t.type){var i=1,n=b(t.data.subarray(i),!0),r=b(t.data.subarray(i+=n.length+1));return{key:t.type,info:n,data:r}}var e=b(t.data.subarray(1));return{key:t.type,data:e}}},p=function(t){if("WXXX"===t.type){if(t.size<2)return;var i=1,n=b(t.data.subarray(i),!0),r=b(t.data.subarray(i+=n.length+1));return{key:t.type,info:n,data:r}}var e=b(t.data);return{key:t.type,data:e}},g=function(t){if(8===t.data.byteLength){var i=new Uint8Array(t.data),n=(i[4]<<23)+(i[5]<<15)+(i[6]<<7)+i[7];return n/=45,1&i[3]&&(n+=47721858.84),Math.round(n)}},b=function(t,i){void 0===i&&(i=!1);var n=w();if(n){var r=n.decode(t);if(i){var e=r.indexOf("\0");return-1!==e?r.substring(0,e):r}return r.replace(/\0/g,"")}for(var s,a,o,h=t.length,u="",c=0;c<h;){if(0===(s=t[c++])&&i)return u;if(0!==s&&3!==s)switch(s>>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(s);break;case 12:case 13:a=t[c++],u+=String.fromCharCode((31&s)<<6|63&a);break;case 14:a=t[c++],o=t[c++],u+=String.fromCharCode((15&s)<<12|(63&a)<<6|(63&o)<<0)}}return u},y={decodeTextFrame:m};function w(){return r||void 0===self.TextDecoder||(r=new self.TextDecoder("utf-8")),r}},"./src/demux/mp3demuxer.ts":
150
+ /*!*********************************!*\
151
+ !*** ./src/demux/mp3demuxer.ts ***!
152
+ \*********************************/
153
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./base-audio-demuxer */"./src/demux/base-audio-demuxer.ts"),e=n(/*! ../demux/id3 */"./src/demux/id3.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! ./mpegaudio */"./src/demux/mpegaudio.ts");function o(t,i){return o=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},o(t,i)}var h=function(t){var i,n;function r(){return t.apply(this,arguments)||this}n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,o(i,n);var h=r.prototype;return h.resetInitSegment=function(i,n,r){t.prototype.resetInitSegment.call(this,i,n,r),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,isAAC:!1,samples:[],manifestCodec:i,duration:r,inputTimeScale:9e4,dropped:0}},r.probe=function(t){if(!t)return!1;for(var i=(e.getID3Data(t,0)||[]).length,n=t.length;i<n;i++)if(a.probe(t,i))return s.logger.log("MPEG Audio sync word found !"),!0;return!1},h.canParse=function(t,i){return a.canParse(t,i)},h.appendFrame=function(t,i,n){if(null!==this.initPTS)return a.appendFrame(t,i,n,this.initPTS,this.frameIndex)},r}(r.default);h.minProbeByteLength=4,i.default=h},"./src/demux/mp4demuxer.ts":
154
+ /*!*********************************!*\
155
+ !*** ./src/demux/mp4demuxer.ts ***!
156
+ \*********************************/
157
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),e=n(/*! ./dummy-demuxed-track */"./src/demux/dummy-demuxed-track.ts"),s=function(){function t(t,i){this.remainderData=null,this.config=void 0,this.config=i}var i=t.prototype;return i.resetTimeStamp=function(){},i.resetInitSegment=function(){},i.resetContiguity=function(){},t.probe=function(t){return Object(r.findBox)({data:t,start:0,end:Math.min(t.length,16384)},["moof"]).length>0},i.demux=function(t){var i=t,n=Object(e.dummyTrack)();if(this.config.progressive){this.remainderData&&(i=Object(r.appendUint8Array)(this.remainderData,t));var s=Object(r.segmentValidRange)(i);this.remainderData=s.remainder,n.samples=s.valid||new Uint8Array}else n.samples=i;return{audioTrack:Object(e.dummyTrack)(),avcTrack:n,id3Track:Object(e.dummyTrack)(),textTrack:Object(e.dummyTrack)()}},i.flush=function(){var t=Object(e.dummyTrack)();return t.samples=this.remainderData||new Uint8Array,this.remainderData=null,{audioTrack:Object(e.dummyTrack)(),avcTrack:t,id3Track:Object(e.dummyTrack)(),textTrack:Object(e.dummyTrack)()}},i.demuxSampleAes=function(){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},i.destroy=function(){},t}();s.minProbeByteLength=1024,i.default=s},"./src/demux/mpegaudio.ts":
158
+ /*!********************************!*\
159
+ !*** ./src/demux/mpegaudio.ts ***!
160
+ \********************************/
161
+ /*! exports provided: appendFrame, parseHeader, isHeaderPattern, isHeader, canParse, probe */function(t,i,n){n.r(i),n.d(i,"appendFrame",(function(){return h})),n.d(i,"parseHeader",(function(){return u})),n.d(i,"isHeaderPattern",(function(){return c})),n.d(i,"isHeader",(function(){return f})),n.d(i,"canParse",(function(){return l})),n.d(i,"probe",(function(){return v}));var r=null,e=[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],s=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],a=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],o=[0,1,1,4];function h(t,i,n,r,e){if(!(n+24>i.length)){var s=u(i,n);if(s&&n+s.frameLength<=i.length){var a=r+e*(9e4*s.samplesPerFrame/s.sampleRate),o={unit:i.subarray(n,n+s.frameLength),pts:a,dts:a};return t.config=[],t.channelCount=s.channelCount,t.samplerate=s.sampleRate,t.samples.push(o),{sample:o,length:s.frameLength,missing:0}}}}function u(t,i){var n=t[i+1]>>3&3,h=t[i+1]>>1&3,u=t[i+2]>>4&15,c=t[i+2]>>2&3;if(1!==n&&0!==u&&15!==u&&3!==c){var f=t[i+3]>>6,l=1e3*e[14*(3===n?3-h:3===h?3:4)+u-1],v=s[3*(3===n?0:2===n?1:2)+c],d=3===f?1:2,m=a[n][h],p=o[h],g=8*m*p,b=Math.floor(m*l/v+(t[i+2]>>1&1))*p;if(null===r){var y=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);r=y?parseInt(y[1]):0}return!!r&&r<=87&&2===h&&l>=224e3&&0===f&&(t[i+3]=128|t[i+3]),{sampleRate:v,channelCount:d,frameLength:b,samplesPerFrame:g}}}function c(t,i){return 255===t[i]&&224==(224&t[i+1])&&0!=(6&t[i+1])}function f(t,i){return i+1<t.length&&c(t,i)}function l(t,i){return c(t,i)&&4<=t.length-i}function v(t,i){if(i+1<t.length&&c(t,i)){var n=u(t,i),r=4;null!=n&&n.frameLength&&(r=n.frameLength);var e=i+r;return e===t.length||f(t,e)}return!1}},"./src/demux/sample-aes.ts":
162
+ /*!*********************************!*\
163
+ !*** ./src/demux/sample-aes.ts ***!
164
+ \*********************************/
165
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),e=n(/*! ./tsdemuxer */"./src/demux/tsdemuxer.ts");i.default=function(){function t(t,i,n){this.keyData=void 0,this.decrypter=void 0,this.keyData=n,this.decrypter=new r.default(t,i,{removePKCS7Padding:!1})}var i=t.prototype;return i.decryptBuffer=function(t,i){this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer,i)},i.decryptAacSample=function(t,i,n,r){var e=t[i].unit,s=e.subarray(16,e.length-e.length%16),a=s.buffer.slice(s.byteOffset,s.byteOffset+s.length),o=this;this.decryptBuffer(a,(function(s){var a=new Uint8Array(s);e.set(a,16),r||o.decryptAacSamples(t,i+1,n)}))},i.decryptAacSamples=function(t,i,n){for(;;i++){if(i>=t.length)return void n();if(!(t[i].unit.length<32)){var r=this.decrypter.isSync();if(this.decryptAacSample(t,i,n,r),!r)return}}},i.getAvcEncryptedData=function(t){for(var i=16*Math.floor((t.length-48)/160)+16,n=new Int8Array(i),r=0,e=32;e<t.length-16;e+=160,r+=16)n.set(t.subarray(e,e+16),r);return n},i.getAvcDecryptedUnit=function(t,i){for(var n=new Uint8Array(i),r=0,e=32;e<t.length-16;e+=160,r+=16)t.set(n.subarray(r,r+16),e);return t},i.decryptAvcSample=function(t,i,n,r,s,a){var o=Object(e.discardEPB)(s.data),h=this.getAvcEncryptedData(o),u=this;this.decryptBuffer(h.buffer,(function(e){s.data=u.getAvcDecryptedUnit(o,e),a||u.decryptAvcSamples(t,i,n+1,r)}))},i.decryptAvcSamples=function(t,i,n,r){if(t instanceof Uint8Array)throw new Error("Cannot decrypt samples of type Uint8Array");for(;;i++,n=0){if(i>=t.length)return void r();for(var e=t[i].units;!(n>=e.length);n++){var s=e[n];if(!(s.data.length<=48||1!==s.type&&5!==s.type)){var a=this.decrypter.isSync();if(this.decryptAvcSample(t,i,n,r,s,a),!a)return}}}},t}()},"./src/demux/transmuxer-interface.ts":
166
+ /*!*******************************************!*\
167
+ !*** ./src/demux/transmuxer-interface.ts ***!
168
+ \*******************************************/
169
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return f}));var r=n(/*! webworkify-webpack */"./node_modules/webworkify-webpack/index.js"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=n(/*! ../utils/mediasource-helper */"./src/utils/mediasource-helper.ts"),u=n(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),c=Object(h.getMediaSource)()||{isTypeSupported:function(){return!1}},f=function(){function t(t,i,n,h){var f=this;this.hls=void 0,this.id=void 0,this.observer=void 0,this.frag=null,this.part=null,this.worker=void 0,this.onwmsg=void 0,this.transmuxer=null,this.onTransmuxComplete=void 0,this.onFlush=void 0,this.hls=t,this.id=i,this.onTransmuxComplete=n,this.onFlush=h;var l=t.config,v=function(i,n){(n=n||{}).frag=f.frag,n.id=f.id,t.trigger(i,n)};this.observer=new u.EventEmitter,this.observer.on(e.Events.FRAG_DECRYPTED,v),this.observer.on(e.Events.ERROR,v);var d={mp4:c.isTypeSupported("video/mp4"),mpeg:c.isTypeSupported("audio/mpeg"),mp3:c.isTypeSupported('audio/mp4; codecs="mp3"')},m=navigator.vendor;if(l.enableWorker&&"undefined"!=typeof Worker){var p;a.logger.log("demuxing in webworker");try{p=this.worker=r(/*! ../demux/transmuxer-worker.ts */"./src/demux/transmuxer-worker.ts"),this.onwmsg=this.onWorkerMessage.bind(this),p.addEventListener("message",this.onwmsg),p.onerror=function(i){t.trigger(e.Events.ERROR,{type:o.ErrorTypes.OTHER_ERROR,details:o.ErrorDetails.INTERNAL_EXCEPTION,fatal:!0,event:"demuxerWorker",error:new Error(i.message+" ("+i.filename+":"+i.lineno+")")})},p.postMessage({cmd:"init",typeSupported:d,vendor:m,id:i,config:JSON.stringify(l)})}catch(t){a.logger.warn("Error in worker:",t),a.logger.error("Error while initializing DemuxerWorker, fallback to inline"),p&&self.URL.revokeObjectURL(p.objectURL),this.transmuxer=new s.default(this.observer,d,l,m,i),this.worker=null}}else this.transmuxer=new s.default(this.observer,d,l,m,i)}var i=t.prototype;return i.destroy=function(){var t=this.worker;if(t)t.removeEventListener("message",this.onwmsg),t.terminate(),this.worker=null;else{var i=this.transmuxer;i&&(i.destroy(),this.transmuxer=null)}var n=this.observer;n&&n.removeAllListeners(),this.observer=null},i.push=function(t,i,n,r,e,o,h,u,c,f){var l,v,d=this;c.transmuxing.start=self.performance.now();var m=this.transmuxer,p=this.worker,g=o?o.start:e.start,b=e.decryptdata,y=this.frag,w=!(y&&e.cc===y.cc),k=!(y&&c.level===y.level),T=y?c.sn-y.sn:-1,O=this.part?c.part-this.part.index:1,S=!k&&(1===T||0===T&&1===O),E=self.performance.now();(k||T||0===e.stats.parsing.start)&&(e.stats.parsing.start=E),!o||!O&&S||(o.stats.parsing.start=E);var A=!(y&&(null===(l=e.initSegment)||void 0===l?void 0:l.url)===(null===(v=y.initSegment)||void 0===v?void 0:v.url)),M=new s.TransmuxState(w,S,u,k,g,A);if(!S||w||A){a.logger.log("[transmuxer-interface, "+e.type+"]: Starting new transmux session for sn: "+c.sn+" p: "+c.part+" level: "+c.level+" id: "+c.id+"\n discontinuity: "+w+"\n trackSwitch: "+k+"\n contiguous: "+S+"\n accurateTimeOffset: "+u+"\n timeOffset: "+g+"\n initSegmentChange: "+A);var x=new s.TransmuxConfig(n,r,i,h,f);this.configureTransmuxer(x)}if(this.frag=e,this.part=o,p)p.postMessage({cmd:"demux",data:t,decryptdata:b,chunkMeta:c,state:M},t instanceof ArrayBuffer?[t]:[]);else if(m){var j=m.push(t,b,c,M);Object(s.isPromise)(j)?j.then((function(t){d.handleTransmuxComplete(t)})):this.handleTransmuxComplete(j)}},i.flush=function(t){var i=this;t.transmuxing.start=self.performance.now();var n=this.transmuxer,r=this.worker;if(r)r.postMessage({cmd:"flush",chunkMeta:t});else if(n){var e=n.flush(t);Object(s.isPromise)(e)?e.then((function(n){i.handleFlushResult(n,t)})):this.handleFlushResult(e,t)}},i.handleFlushResult=function(t,i){var n=this;t.forEach((function(t){n.handleTransmuxComplete(t)})),this.onFlush(i)},i.onWorkerMessage=function(t){var i=t.data,n=this.hls;switch(i.event){case"init":self.URL.revokeObjectURL(this.worker.objectURL);break;case"transmuxComplete":this.handleTransmuxComplete(i.data);break;case"flush":this.onFlush(i.data);break;default:i.data=i.data||{},i.data.frag=this.frag,i.data.id=this.id,n.trigger(i.event,i.data)}},i.configureTransmuxer=function(t){var i=this.worker,n=this.transmuxer;i?i.postMessage({cmd:"configure",config:t}):n&&n.configure(t)},i.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},t}()},"./src/demux/transmuxer-worker.ts":
170
+ /*!****************************************!*\
171
+ !*** ./src/demux/transmuxer-worker.ts ***!
172
+ \****************************************/
173
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return o}));var r=n(/*! ../demux/transmuxer */"./src/demux/transmuxer.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=n(/*! eventemitter3 */"./node_modules/eventemitter3/index.js");function o(t){var i=new a.EventEmitter,n=function(i,n){t.postMessage({event:i,data:n})};i.on(e.Events.FRAG_DECRYPTED,n),i.on(e.Events.ERROR,n),t.addEventListener("message",(function(e){var a=e.data;switch(a.cmd){case"init":var o=JSON.parse(a.config);t.transmuxer=new r.default(i,a.typeSupported,o,a.vendor,a.id),Object(s.enableLogs)(o.debug),n("init",null);break;case"configure":t.transmuxer.configure(a.config);break;case"demux":var u=t.transmuxer.push(a.data,a.decryptdata,a.chunkMeta,a.state);Object(r.isPromise)(u)?u.then((function(i){h(t,i)})):h(t,u);break;case"flush":var f=a.chunkMeta,l=t.transmuxer.flush(f);Object(r.isPromise)(l)?l.then((function(i){c(t,i,f)})):c(t,l,f)}}))}function h(t,i){if((n=i.remuxResult).audio||n.video||n.text||n.id3||n.initSegment){var n,r=[],e=i.remuxResult,s=e.audio,a=e.video;s&&u(r,s),a&&u(r,a),t.postMessage({event:"transmuxComplete",data:i},r)}}function u(t,i){i.data1&&t.push(i.data1.buffer),i.data2&&t.push(i.data2.buffer)}function c(t,i,n){i.forEach((function(i){h(t,i)})),t.postMessage({event:"flush",data:n})}},"./src/demux/transmuxer.ts":
174
+ /*!*********************************!*\
175
+ !*** ./src/demux/transmuxer.ts ***!
176
+ \*********************************/
177
+ /*! exports provided: default, isPromise, TransmuxConfig, TransmuxState */function(t,i,n){n.r(i),n.d(i,"default",(function(){return b})),n.d(i,"isPromise",(function(){return w})),n.d(i,"TransmuxConfig",(function(){return k})),n.d(i,"TransmuxState",(function(){return T}));var r,e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../errors */"./src/errors.ts"),a=n(/*! ../crypt/decrypter */"./src/crypt/decrypter.ts"),o=n(/*! ../demux/aacdemuxer */"./src/demux/aacdemuxer.ts"),h=n(/*! ../demux/mp4demuxer */"./src/demux/mp4demuxer.ts"),u=n(/*! ../demux/tsdemuxer */"./src/demux/tsdemuxer.ts"),c=n(/*! ../demux/mp3demuxer */"./src/demux/mp3demuxer.ts"),f=n(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),l=n(/*! ../remux/passthrough-remuxer */"./src/remux/passthrough-remuxer.ts"),v=n(/*! ./chunk-cache */"./src/demux/chunk-cache.ts"),d=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),m=n(/*! ../utils/logger */"./src/utils/logger.ts");try{r=self.performance.now.bind(self.performance)}catch(t){m.logger.debug("Unable to use Performance API on this environment"),r=self.Date.now}var p=[{demux:u.default,remux:f.default},{demux:h.default,remux:l.default},{demux:o.default,remux:f.default},{demux:c.default,remux:f.default}],g=1024;p.forEach((function(t){g=Math.max(g,t.demux.minProbeByteLength)}));var b=function(){function t(t,i,n,r,e){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.cache=new v.default,this.observer=t,this.typeSupported=i,this.config=n,this.vendor=r,this.id=e}var i=t.prototype;return i.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},i.push=function(t,i,n,e){var s=this,a=n.transmuxing;a.executeStart=r();var o=new Uint8Array(t),h=this.cache,u=this.config,c=this.currentTransmuxState,f=this.transmuxConfig;e&&(this.currentTransmuxState=e);var l=function(t,i){var n=null;return t.byteLength>0&&null!=i&&null!=i.key&&null!==i.iv&&null!=i.method&&(n=i),n}(o,i);if(l&&"AES-128"===l.method){var v=this.getDecrypter();if(!u.enableSoftwareAES)return this.decryptionPromise=v.webCryptoDecrypt(o,l.key.buffer,l.iv.buffer).then((function(t){var i=s.push(t,null,n);return s.decryptionPromise=null,i})),this.decryptionPromise;var m=v.softwareDecrypt(o,l.key.buffer,l.iv.buffer);if(!m)return a.executeEnd=r(),y(n);o=new Uint8Array(m)}var p=e||c,g=p.contiguous,b=p.discontinuity,w=p.trackSwitch,k=p.accurateTimeOffset,T=p.timeOffset,O=p.initSegmentChange,S=f.defaultInitPts;if((b||w||O)&&this.resetInitSegment(f.initSegmentData,f.audioCodec,f.videoCodec,f.duration),(b||O)&&this.resetInitialTimestamp(S),g||this.resetContiguity(),this.needsProbing(o,b,w)){if(h.dataLength){var E=h.flush();o=Object(d.appendUint8Array)(E,o)}this.configureTransmuxer(o,f)}var A=this.transmux(o,l,T,k,n),M=this.currentTransmuxState;return M.contiguous=!0,M.discontinuity=!1,M.trackSwitch=!1,a.executeEnd=r(),A},i.flush=function(t){var i=this,n=t.transmuxing;n.executeStart=r();var a=this.decrypter,o=this.cache,h=this.currentTransmuxState,u=this.decryptionPromise;if(u)return u.then((function(){return i.flush(t)}));var c=[],f=h.timeOffset;if(a){var l=a.flush();l&&c.push(this.push(l,null,t))}var v=o.dataLength;o.reset();var d=this.demuxer;if(!d||!this.remuxer)return v>=g&&this.observer.emit(e.Events.ERROR,e.Events.ERROR,{type:s.ErrorTypes.MEDIA_ERROR,details:s.ErrorDetails.FRAG_PARSING_ERROR,fatal:!0,reason:"no demux matching with content found"}),n.executeEnd=r(),[y(t)];var m=d.flush(f);return w(m)?m.then((function(n){return i.flushRemux(c,n,t),c})):(this.flushRemux(c,m,t),c)},i.flushRemux=function(t,i,n){var e=i.audioTrack,s=i.avcTrack,a=i.id3Track,o=i.textTrack,h=this.currentTransmuxState,u=h.accurateTimeOffset,c=h.timeOffset;m.logger.log("[transmuxer.ts]: Flushed fragment "+n.sn+(n.part>-1?" p: "+n.part:"")+" of level "+n.level);var f=this.remuxer.remux(e,s,a,o,c,u,!0,this.id);t.push({remuxResult:f,chunkMeta:n}),n.transmuxing.executeEnd=r()},i.resetInitialTimestamp=function(t){var i=this.demuxer,n=this.remuxer;i&&n&&(i.resetTimeStamp(t),n.resetTimeStamp(t))},i.resetContiguity=function(){var t=this.demuxer,i=this.remuxer;t&&i&&(t.resetContiguity(),i.resetNextTimestamp())},i.resetInitSegment=function(t,i,n,r){var e=this.demuxer,s=this.remuxer;e&&s&&(e.resetInitSegment(i,n,r),s.resetInitSegment(t,i,n))},i.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},i.transmux=function(t,i,n,r,e){return i&&"SAMPLE-AES"===i.method?this.transmuxSampleAes(t,i,n,r,e):this.transmuxUnencrypted(t,n,r,e)},i.transmuxUnencrypted=function(t,i,n,r){var e=this.demuxer.demux(t,i,!1,!this.config.progressive);return{remuxResult:this.remuxer.remux(e.audioTrack,e.avcTrack,e.id3Track,e.textTrack,i,n,!1,this.id),chunkMeta:r}},i.transmuxSampleAes=function(t,i,n,r,e){var s=this;return this.demuxer.demuxSampleAes(t,i,n).then((function(t){return{remuxResult:s.remuxer.remux(t.audioTrack,t.avcTrack,t.id3Track,t.textTrack,n,r,!1,s.id),chunkMeta:e}}))},i.configureTransmuxer=function(t,i){for(var n,r=this.config,e=this.observer,s=this.typeSupported,a=this.vendor,o=i.audioCodec,u=i.defaultInitPts,c=i.duration,f=i.initSegmentData,v=i.videoCodec,d=0,g=p.length;d<g;d++)if(p[d].demux.probe(t)){n=p[d];break}n||(m.logger.warn("Failed to find demuxer by probing frag, treating as mp4 passthrough"),n={demux:h.default,remux:l.default});var b=this.demuxer,y=this.remuxer,w=n.remux,k=n.demux;y&&y instanceof w||(this.remuxer=new w(e,r,s,a)),b&&b instanceof k||(this.demuxer=new k(e,r,s),this.probe=k.probe),this.resetInitSegment(f,o,v,c),this.resetInitialTimestamp(u)},i.needsProbing=function(t,i,n){return!this.demuxer||!this.remuxer||i||n},i.getDecrypter=function(){var t=this.decrypter;return t||(t=this.decrypter=new a.default(this.observer,this.config)),t},t}(),y=function(t){return{remuxResult:{},chunkMeta:t}};function w(t){return"then"in t&&t.then instanceof Function}var k=function(t,i,n,r,e){this.audioCodec=void 0,this.videoCodec=void 0,this.initSegmentData=void 0,this.duration=void 0,this.defaultInitPts=void 0,this.audioCodec=t,this.videoCodec=i,this.initSegmentData=n,this.duration=r,this.defaultInitPts=e},T=function(t,i,n,r,e,s){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=t,this.contiguous=i,this.accurateTimeOffset=n,this.trackSwitch=r,this.timeOffset=e,this.initSegmentChange=s}},"./src/demux/tsdemuxer.ts":
178
+ /*!********************************!*\
179
+ !*** ./src/demux/tsdemuxer.ts ***!
180
+ \********************************/
181
+ /*! exports provided: discardEPB, default */function(t,i,n){n.r(i),n.d(i,"discardEPB",(function(){return w}));var r=n(/*! ./adts */"./src/demux/adts.ts"),e=n(/*! ./mpegaudio */"./src/demux/mpegaudio.ts"),s=n(/*! ./exp-golomb */"./src/demux/exp-golomb.ts"),a=n(/*! ./id3 */"./src/demux/id3.ts"),o=n(/*! ./sample-aes */"./src/demux/sample-aes.ts"),h=n(/*! ../events */"./src/events.ts"),u=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),c=n(/*! ../utils/logger */"./src/utils/logger.ts"),f=n(/*! ../errors */"./src/errors.ts"),l={video:1,audio:2,id3:3,text:4},v=function(){function t(t,i,n){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.aacLastPTS=null,this._initPTS=null,this._initDTS=null,this._pmtId=-1,this._avcTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.avcSample=null,this.remainderData=null,this.observer=t,this.config=i,this.typeSupported=n}t.probe=function(i){var n=t.syncOffset(i);return!(n<0||(n&&c.logger.warn("MPEG2-TS detected but first sync word found @ offset "+n+", junk ahead ?"),0))},t.syncOffset=function(t){for(var i=Math.min(1e3,t.length-564),n=0;n<i;){if(71===t[n]&&71===t[n+188]&&71===t[n+376])return n;n++}return-1},t.createTrack=function(t,i){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:l[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?i:void 0}};var i=t.prototype;return i.resetInitSegment=function(i,n,r){this.pmtParsed=!1,this._pmtId=-1,this._avcTrack=t.createTrack("video",r),this._audioTrack=t.createTrack("audio",r),this._id3Track=t.createTrack("id3",r),this._txtTrack=t.createTrack("text",r),this._audioTrack.isAAC=!0,this.aacOverFlow=null,this.aacLastPTS=null,this.avcSample=null,this.audioCodec=i,this.videoCodec=n,this._duration=r},i.resetTimeStamp=function(){},i.resetContiguity=function(){var t=this._audioTrack,i=this._avcTrack,n=this._id3Track;t&&(t.pesData=null),i&&(i.pesData=null),n&&(n.pesData=null),this.aacOverFlow=null,this.aacLastPTS=null},i.demux=function(i,n,r,e){var s;void 0===r&&(r=!1),void 0===e&&(e=!1),r||(this.sampleAes=null);var a=this._avcTrack,o=this._audioTrack,l=this._id3Track,v=a.pid,d=a.pesData,b=o.pid,y=l.pid,w=o.pesData,k=l.pesData,T=!1,O=this.pmtParsed,S=this._pmtId,E=i.length;if(this.remainderData&&(E=(i=Object(u.appendUint8Array)(this.remainderData,i)).length,this.remainderData=null),E<188&&!e)return this.remainderData=i,{audioTrack:o,avcTrack:a,id3Track:l,textTrack:this._txtTrack};var A=Math.max(0,t.syncOffset(i));(E-=(E+A)%188)<i.byteLength&&!e&&(this.remainderData=new Uint8Array(i.buffer,E,i.buffer.byteLength-E));for(var M=0,x=A;x<E;x+=188)if(71===i[x]){var j=!!(64&i[x+1]),D=((31&i[x+1])<<8)+i[x+2],L=void 0;if((48&i[x+3])>>4>1){if((L=x+5+i[x+4])===x+188)continue}else L=x+4;switch(D){case v:j&&(d&&(s=g(d))&&this.parseAVCPES(s,!1),d={data:[],size:0}),d&&(d.data.push(i.subarray(L,x+188)),d.size+=x+188-L);break;case b:j&&(w&&(s=g(w))&&(o.isAAC?this.parseAACPES(s):this.parseMPEGPES(s)),w={data:[],size:0}),w&&(w.data.push(i.subarray(L,x+188)),w.size+=x+188-L);break;case y:j&&(k&&(s=g(k))&&this.parseID3PES(s),k={data:[],size:0}),k&&(k.data.push(i.subarray(L,x+188)),k.size+=x+188-L);break;case 0:j&&(L+=i[L]+1),S=this._pmtId=m(i,L);break;case S:j&&(L+=i[L]+1);var I=p(i,L,!0===this.typeSupported.mpeg||!0===this.typeSupported.mp3,r);(v=I.avc)>0&&(a.pid=v),(b=I.audio)>0&&(o.pid=b,o.isAAC=I.isAAC),(y=I.id3)>0&&(l.pid=y),T&&!O&&(c.logger.log("reparse from beginning"),T=!1,x=A-188),O=this.pmtParsed=!0;break;case 17:case 8191:break;default:T=!0}}else M++;M>0&&this.observer.emit(h.Events.ERROR,h.Events.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:!1,reason:"Found "+M+" TS packet/s that do not start with 0x47"}),a.pesData=d,o.pesData=w,l.pesData=k;var C={audioTrack:o,avcTrack:a,id3Track:l,textTrack:this._txtTrack};return e&&this.extractRemainingSamples(C),C},i.flush=function(){var t,i=this.remainderData;return this.remainderData=null,t=i?this.demux(i,-1,!1,!0):{audioTrack:this._audioTrack,avcTrack:this._avcTrack,textTrack:this._txtTrack,id3Track:this._id3Track},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},i.extractRemainingSamples=function(t){var i,n=t.audioTrack,r=t.avcTrack,e=t.id3Track,s=r.pesData,a=n.pesData,o=e.pesData;s&&(i=g(s))?(this.parseAVCPES(i,!0),r.pesData=null):r.pesData=s,a&&(i=g(a))?(n.isAAC?this.parseAACPES(i):this.parseMPEGPES(i),n.pesData=null):(null!=a&&a.size&&c.logger.log("last AAC PES packet truncated,might overlap between fragments"),n.pesData=a),o&&(i=g(o))?(this.parseID3PES(i),e.pesData=null):e.pesData=o},i.demuxSampleAes=function(t,i,n){var r=this.demux(t,n,!0,!this.config.progressive),e=this.sampleAes=new o.default(this.observer,this.config,i);return this.decrypt(r,e)},i.decrypt=function(t,i){return new Promise((function(n){var r=t.audioTrack,e=t.avcTrack;r.samples&&r.isAAC?i.decryptAacSamples(r.samples,0,(function(){e.samples?i.decryptAvcSamples(e.samples,0,0,(function(){n(t)})):n(t)})):e.samples&&i.decryptAvcSamples(e.samples,0,0,(function(){n(t)}))}))},i.destroy=function(){this._initPTS=this._initDTS=null,this._duration=0},i.parseAVCPES=function(t,i){var n,r=this,e=this._avcTrack,o=this.parseAVCNALu(t.data),h=this.avcSample,u=!1;t.data=null,h&&o.length&&!e.audFound&&(b(h,e),h=this.avcSample=d(!1,t.pts,t.dts,"")),o.forEach((function(i){switch(i.type){case 1:n=!0,h||(h=r.avcSample=d(!0,t.pts,t.dts,"")),h.frame=!0;var o=i.data;if(u&&o.length>4){var c=new s.default(o).readSliceType();2!==c&&4!==c&&7!==c&&9!==c||(h.key=!0)}break;case 5:n=!0,h||(h=r.avcSample=d(!0,t.pts,t.dts,"")),h.key=!0,h.frame=!0;break;case 6:n=!0;var f=new s.default(w(i.data));f.readUByte();for(var l=0,v=0,m=!1,p=0;!m&&f.bytesAvailable>1;){l=0;do{l+=p=f.readUByte()}while(255===p);v=0;do{v+=p=f.readUByte()}while(255===p);if(4===l&&0!==f.bytesAvailable){if(m=!0,181===f.readUByte()&&49===f.readUShort()&&1195456820===f.readUInt()&&3===f.readUByte()){for(var g=f.readUByte(),k=31&g,T=[g,f.readUByte()],O=0;O<k;O++)T.push(f.readUByte()),T.push(f.readUByte()),T.push(f.readUByte());y(r._txtTrack.samples,{type:3,pts:t.pts,bytes:T})}}else if(5===l&&0!==f.bytesAvailable){if(m=!0,v>16){for(var S=[],E=0;E<16;E++)S.push(f.readUByte().toString(16)),3!==E&&5!==E&&7!==E&&9!==E||S.push("-");for(var A=v-16,M=new Uint8Array(A),x=0;x<A;x++)M[x]=f.readUByte();y(r._txtTrack.samples,{pts:t.pts,payloadType:l,uuid:S.join(""),userData:Object(a.utf8ArrayToStr)(M),userDataBytes:M})}}else if(v<f.bytesAvailable)for(var j=0;j<v;j++)f.readUByte()}break;case 7:if(n=!0,u=!0,!e.sps){var D=new s.default(i.data).readSPS();e.width=D.width,e.height=D.height,e.pixelRatio=D.pixelRatio,e.sps=[i.data],e.duration=r._duration;for(var L=i.data.subarray(1,4),I="avc1.",C=0;C<3;C++){var R=L[C].toString(16);R.length<2&&(R="0"+R),I+=R}e.codec=I}break;case 8:n=!0,e.pps||(e.pps=[i.data]);break;case 9:n=!1,e.audFound=!0,h&&b(h,e),h=r.avcSample=d(!1,t.pts,t.dts,"");break;case 12:n=!1;break;default:n=!1,h&&(h.debug+="unknown NAL "+i.type+" ")}h&&n&&h.units.push(i)})),i&&h&&(b(h,e),this.avcSample=null)},i.getLastNalUnit=function(){var t,i,n=this.avcSample;if(!n||0===n.units.length){var r=this._avcTrack.samples;n=r[r.length-1]}if(null!==(t=n)&&void 0!==t&&t.units){var e=n.units;i=e[e.length-1]}return i},i.parseAVCNALu=function(t){var i,n,r=t.byteLength,e=this._avcTrack,s=e.naluState||0,a=s,o=[],h=0,u=-1,c=0;for(-1===s&&(u=0,c=31&t[0],s=0,h=1);h<r;)if(i=t[h++],s)if(1!==s)if(i)if(1===i){if(u>=0){var f={data:t.subarray(u,h-s-1),type:c};o.push(f)}else{var l=this.getLastNalUnit();if(l&&(a&&h<=4-a&&l.state&&(l.data=l.data.subarray(0,l.data.byteLength-a)),(n=h-s-1)>0)){var v=new Uint8Array(l.data.byteLength+n);v.set(l.data,0),v.set(t.subarray(0,n),l.data.byteLength),l.data=v,l.state=0}}h<r?(u=h,c=31&t[h],s=0):s=-1}else s=0;else s=3;else s=i?0:2;else s=i?0:1;if(u>=0&&s>=0){var d={data:t.subarray(u,r),type:c,state:s};o.push(d)}if(0===o.length){var m=this.getLastNalUnit();if(m){var p=new Uint8Array(m.data.byteLength+t.byteLength);p.set(m.data,0),p.set(t,m.data.byteLength),m.data=p}}return e.naluState=s,o},i.parseAACPES=function(t){var i,n,e,s,a,o=0,u=this._audioTrack,l=this.aacOverFlow,v=t.data;if(l){this.aacOverFlow=null;var d=l.sample.unit.byteLength,m=Math.min(l.missing,d),p=d-m;l.sample.unit.set(v.subarray(0,m),p),u.samples.push(l.sample),o=l.missing}for(i=o,n=v.length;i<n-1&&!r.isHeader(v,i);i++);if(i===o||(i<n-1?(e="AAC PES did not start with ADTS header,offset:"+i,s=!1):(e="no ADTS header found in AAC PES",s=!0),c.logger.warn("parsing error:"+e),this.observer.emit(h.Events.ERROR,h.Events.ERROR,{type:f.ErrorTypes.MEDIA_ERROR,details:f.ErrorDetails.FRAG_PARSING_ERROR,fatal:s,reason:e}),!s)){if(r.initTrackConfig(u,this.observer,v,i,this.audioCodec),void 0!==t.pts)a=t.pts;else{if(!l)return void c.logger.warn("[tsdemuxer]: AAC PES unknown PTS");var g=r.getFrameDuration(u.samplerate);a=l.sample.pts+g}for(var b=0;i<n;){if(r.isHeader(v,i)){if(i+5<n){var y=r.appendFrame(u,v,i,a,b);if(y){if(!y.missing){i+=y.length,b++;continue}this.aacOverFlow=y}}break}i++}}},i.parseMPEGPES=function(t){var i=t.data,n=i.length,r=0,s=0,a=t.pts;if(void 0!==a)for(;s<n;)if(e.isHeader(i,s)){var o=e.appendFrame(this._audioTrack,i,s,a,r);if(!o)break;s+=o.length,r++}else s++;else c.logger.warn("[tsdemuxer]: MPEG PES unknown PTS")},i.parseID3PES=function(t){void 0!==t.pts?this._id3Track.samples.push(t):c.logger.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function d(t,i,n,r){return{key:t,frame:!1,pts:i,dts:n,units:[],debug:r,length:0}}function m(t,i){return(31&t[i+10])<<8|t[i+11]}function p(t,i,n,r){var e={audio:-1,avc:-1,id3:-1,isAAC:!0},s=i+3+((15&t[i+1])<<8|t[i+2])-4;for(i+=12+((15&t[i+10])<<8|t[i+11]);i<s;){var a=(31&t[i+1])<<8|t[i+2];switch(t[i]){case 207:if(!r){c.logger.log("ADTS AAC with AES-128-CBC frame encryption found in unencrypted stream");break}case 15:-1===e.audio&&(e.audio=a);break;case 21:-1===e.id3&&(e.id3=a);break;case 219:if(!r){c.logger.log("H.264 with AES-128-CBC slice encryption found in unencrypted stream");break}case 27:-1===e.avc&&(e.avc=a);break;case 3:case 4:n?-1===e.audio&&(e.audio=a,e.isAAC=!1):c.logger.log("MPEG audio found, not supported in this browser");break;case 36:c.logger.warn("Unsupported HEVC stream type found")}i+=5+((15&t[i+3])<<8|t[i+4])}return e}function g(t){var i,n,r,e,s,a=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;){var h=new Uint8Array(o[0].length+o[1].length);h.set(o[0]),h.set(o[1],o[0].length),o[0]=h,o.splice(1,1)}if(1===((i=o[0])[0]<<16)+(i[1]<<8)+i[2]){if((n=(i[4]<<8)+i[5])&&n>t.size-6)return null;var u=i[7];192&u&&(e=536870912*(14&i[9])+4194304*(255&i[10])+16384*(254&i[11])+128*(255&i[12])+(254&i[13])/2,64&u?e-(s=536870912*(14&i[14])+4194304*(255&i[15])+16384*(254&i[16])+128*(255&i[17])+(254&i[18])/2)>54e5&&(c.logger.warn(Math.round((e-s)/9e4)+"s delta between PTS and DTS, align them"),e=s):s=e);var f=(r=i[8])+9;if(t.size<=f)return null;t.size-=f;for(var l=new Uint8Array(t.size),v=0,d=o.length;v<d;v++){var m=(i=o[v]).byteLength;if(f){if(f>m){f-=m;continue}i=i.subarray(f),m-=f,f=0}l.set(i,a),a+=m}return n&&(n-=r+3),{data:l,pts:e,dts:s,len:n}}return null}function b(t,i){if(t.units.length&&t.frame){if(void 0===t.pts){var n=i.samples,r=n.length;if(!r)return void i.dropped++;var e=n[r-1];t.pts=e.pts,t.dts=e.dts}i.samples.push(t)}t.debug.length&&c.logger.log(t.pts+"/"+t.dts+":"+t.debug)}function y(t,i){var n=t.length;if(n>0){if(i.pts>=t[n-1].pts)t.push(i);else for(var r=n-1;r>=0;r--)if(i.pts<t[r].pts){t.splice(r,0,i);break}}else t.push(i)}function w(t){for(var i=t.byteLength,n=[],r=1;r<i-2;)0===t[r]&&0===t[r+1]&&3===t[r+2]?(n.push(r+2),r+=2):r++;if(0===n.length)return t;var e=i-n.length,s=new Uint8Array(e),a=0;for(r=0;r<e;a++,r++)a===n[0]&&(a++,n.shift()),s[r]=t[a];return s}v.minProbeByteLength=188,i.default=v},"./src/errors.ts":
182
+ /*!***********************!*\
183
+ !*** ./src/errors.ts ***!
184
+ \***********************/
185
+ /*! exports provided: ErrorTypes, ErrorDetails */function(t,i,n){var r,e;n.r(i),n.d(i,"ErrorTypes",(function(){return r})),n.d(i,"ErrorDetails",(function(){return e})),function(t){t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError"}(r||(r={})),function(t){t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_NO_INIT_DATA="keySystemNoInitData",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown"}(e||(e={}))},"./src/events.ts":
186
+ /*!***********************!*\
187
+ !*** ./src/events.ts ***!
188
+ \***********************/
189
+ /*! exports provided: Events */function(t,i,n){var r;n.r(i),n.d(i,"Events",(function(){return r})),function(t){t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached"}(r||(r={}))},"./src/hls.ts":
190
+ /*!********************!*\
191
+ !*** ./src/hls.ts ***!
192
+ \********************/
193
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return b}));var r=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),e=n(/*! ./loader/playlist-loader */"./src/loader/playlist-loader.ts"),s=n(/*! ./loader/key-loader */"./src/loader/key-loader.ts"),a=n(/*! ./controller/id3-track-controller */"./src/controller/id3-track-controller.ts"),o=n(/*! ./controller/latency-controller */"./src/controller/latency-controller.ts"),h=n(/*! ./controller/level-controller */"./src/controller/level-controller.ts"),u=n(/*! ./controller/fragment-tracker */"./src/controller/fragment-tracker.ts"),c=n(/*! ./controller/stream-controller */"./src/controller/stream-controller.ts"),f=n(/*! ./is-supported */"./src/is-supported.ts"),l=n(/*! ./utils/logger */"./src/utils/logger.ts"),v=n(/*! ./config */"./src/config.ts"),d=n(/*! eventemitter3 */"./node_modules/eventemitter3/index.js"),m=n(/*! ./events */"./src/events.ts"),p=n(/*! ./errors */"./src/errors.ts");function g(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var b=function(){function t(i){void 0===i&&(i={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this._emitter=new d.EventEmitter,this._autoLevelCapping=void 0,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;var n=this.config=Object(v.mergeConfig)(t.DefaultConfig,i);this.userConfig=i,Object(l.enableLogs)(n.debug),this._autoLevelCapping=-1,n.progressive&&Object(v.enableStreamingMode)(n);var r=n.bufferController,f=n.capLevelController,m=n.fpsController,p=this.abrController=new(0,n.abrController)(this),g=this.bufferController=new r(this),b=this.capLevelController=new f(this),y=new m(this),w=new e.default(this),k=new s.default(this),T=new a.default(this),O=this.levelController=new h.default(this),S=new u.FragmentTracker(this),E=this.streamController=new c.default(this,S);b.setStreamController(E),y.setStreamController(E);var A=[O,E];this.networkControllers=A;var M=[w,k,p,g,b,y,T,S];this.audioTrackController=this.createController(n.audioTrackController,null,A),this.createController(n.audioStreamController,S,A),this.subtitleTrackController=this.createController(n.subtitleTrackController,null,A),this.createController(n.subtitleStreamController,S,A),this.createController(n.timelineController,null,M),this.emeController=this.createController(n.emeController,null,M),this.cmcdController=this.createController(n.cmcdController,null,M),this.latencyController=this.createController(o.default,null,M),this.coreComponents=M}t.isSupported=function(){return Object(f.isSupported)()};var i,n,b,y=t.prototype;return y.createController=function(t,i,n){if(t){var r=i?new t(this,i):new t(this);return n&&n.push(r),r}return null},y.on=function(t,i,n){void 0===n&&(n=this),this._emitter.on(t,i,n)},y.once=function(t,i,n){void 0===n&&(n=this),this._emitter.once(t,i,n)},y.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},y.off=function(t,i,n,r){void 0===n&&(n=this),this._emitter.off(t,i,n,r)},y.listeners=function(t){return this._emitter.listeners(t)},y.emit=function(t,i,n){return this._emitter.emit(t,i,n)},y.trigger=function(t,i){if(this.config.debug)return this.emit(t,t,i);try{return this.emit(t,t,i)}catch(i){l.logger.error("An internal error happened while handling event "+t+'. Error message: "'+i.message+'". Here is a stacktrace:',i),this.trigger(m.Events.ERROR,{type:p.ErrorTypes.OTHER_ERROR,details:p.ErrorDetails.INTERNAL_EXCEPTION,fatal:!1,event:t,error:i})}return!1},y.listenerCount=function(t){return this._emitter.listenerCount(t)},y.destroy=function(){l.logger.log("destroy"),this.trigger(m.Events.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0},y.attachMedia=function(t){l.logger.log("attachMedia"),this._media=t,this.trigger(m.Events.MEDIA_ATTACHING,{media:t})},y.detachMedia=function(){l.logger.log("detachMedia"),this.trigger(m.Events.MEDIA_DETACHING,void 0),this._media=null},y.loadSource=function(t){this.stopLoad();var i=this.media,n=this.url,e=this.url=r.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});l.logger.log("loadSource:"+e),i&&n&&n!==e&&this.bufferController.hasSourceTypes()&&(this.detachMedia(),this.attachMedia(i)),this.trigger(m.Events.MANIFEST_LOADING,{url:t})},y.startLoad=function(t){void 0===t&&(t=-1),l.logger.log("startLoad("+t+")"),this.networkControllers.forEach((function(i){i.startLoad(t)}))},y.stopLoad=function(){l.logger.log("stopLoad"),this.networkControllers.forEach((function(t){t.stopLoad()}))},y.swapAudioCodec=function(){l.logger.log("swapAudioCodec"),this.streamController.swapAudioCodec()},y.recoverMediaError=function(){l.logger.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},y.removeLevel=function(t,i){void 0===i&&(i=0),this.levelController.removeLevel(t,i)},i=t,b=[{key:"version",get:function(){return"1.1.5"}},{key:"Events",get:function(){return m.Events}},{key:"ErrorTypes",get:function(){return p.ErrorTypes}},{key:"ErrorDetails",get:function(){return p.ErrorDetails}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:v.hlsDefaultConfig},set:function(i){t.defaultConfig=i}}],(n=[{key:"levels",get:function(){return this.levelController.levels||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){l.logger.log("set currentLevel:"+t),this.loadLevel=t,this.abrController.clearTimer(),this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){l.logger.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){l.logger.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){l.logger.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){return this.levelController.startLevel},set:function(t){l.logger.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var i=!!t;i!==this.config.capLevelToPlayerSize&&(i?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=i)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(l.logger.log("set autoLevelCapping:"+t),this._autoLevelCapping=t)}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,i=this.config.minAutoBitrate;if(!t)return 0;for(var n=t.length,r=0;r<n;r++)if(t[r].maxBitrate>i)return r;return 0}},{key:"maxAutoLevel",get:function(){var t=this.levels,i=this.autoLevelCapping;return-1===i&&t&&t.length?t.length-1:i}},{key:"nextAutoLevel",get:function(){return Math.min(Math.max(this.abrController.nextAutoLevel,this.minAutoLevel),this.maxAutoLevel)},set:function(t){this.abrController.nextAutoLevel=Math.max(this.minAutoLevel,t)}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var i=this.audioTrackController;i&&(i.audioTrack=t)}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var i=this.subtitleTrackController;i&&(i.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var i=this.subtitleTrackController;i&&(i.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}])&&g(i.prototype,n),b&&g(i,b),t}();b.defaultConfig=void 0},"./src/is-supported.ts":
194
+ /*!*****************************!*\
195
+ !*** ./src/is-supported.ts ***!
196
+ \*****************************/
197
+ /*! exports provided: isSupported, changeTypeSupported */function(t,i,n){n.r(i),n.d(i,"isSupported",(function(){return s})),n.d(i,"changeTypeSupported",(function(){return a}));var r=n(/*! ./utils/mediasource-helper */"./src/utils/mediasource-helper.ts");function e(){return self.SourceBuffer||self.WebKitSourceBuffer}function s(){var t=Object(r.getMediaSource)();if(!t)return!1;var i=e();return!(!t||"function"!=typeof t.isTypeSupported||!t.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')||i&&(!i.prototype||"function"!=typeof i.prototype.appendBuffer||"function"!=typeof i.prototype.remove))}function a(){var t,i=e();return"function"==typeof(null==i||null===(t=i.prototype)||void 0===t?void 0:t.changeType)}},"./src/loader/fragment-loader.ts":
198
+ /*!***************************************!*\
199
+ !*** ./src/loader/fragment-loader.ts ***!
200
+ \***************************************/
201
+ /*! exports provided: default, LoadError */function(t,i,n){n.r(i),n.d(i,"default",(function(){return f})),n.d(i,"LoadError",(function(){return v}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../errors */"./src/errors.ts");function s(t){var i="function"==typeof Map?new Map:void 0;return s=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return a(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),h(n,t)},s(t)}function a(t,i,n){return a=o()?Reflect.construct:function(t,i,n){var r=[null];r.push.apply(r,i);var e=new(Function.bind.apply(t,r));return n&&h(e,n.prototype),e},a.apply(null,arguments)}function o(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,i){return h=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},h(t,i)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}var c=Math.pow(2,17),f=function(){function t(t){this.config=void 0,this.loader=null,this.partLoadTimeout=-1,this.config=t}var i=t.prototype;return i.destroy=function(){this.loader&&(this.loader.destroy(),this.loader=null)},i.abort=function(){this.loader&&this.loader.abort()},i.load=function(t,i){var n=this,r=t.url;if(!r)return Promise.reject(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,networkDetails:null},"Fragment does not have a "+(r?"part list":"url")));this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(r,h){n.loader&&n.loader.destroy();var u=n.loader=t.loader=a?new a(s):new o(s),f=l(t),d={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:c};t.stats=u.stats,u.load(f,d,{onSuccess:function(i,e,s,a){n.resetLoader(t,u),r({frag:t,part:null,payload:i.data,networkDetails:a})},onError:function(i,r,s){n.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,response:i,networkDetails:s}))},onAbort:function(i,r,s){n.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,networkDetails:s}))},onTimeout:function(i,r,s){n.resetLoader(t,u),h(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,networkDetails:s}))},onProgress:function(n,r,e,s){i&&i({frag:t,part:null,payload:e,networkDetails:s})}})}))},i.loadPart=function(t,i,n){var r=this;this.abort();var s=this.config,a=s.fLoader,o=s.loader;return new Promise((function(h,u){r.loader&&r.loader.destroy();var f=r.loader=t.loader=a?new a(s):new o(s),d=l(t,i),m={timeout:s.fragLoadingTimeOut,maxRetry:0,retryDelay:0,maxRetryDelay:s.fragLoadingMaxRetryTimeout,highWaterMark:c};i.stats=f.stats,f.load(d,m,{onSuccess:function(e,s,a,o){r.resetLoader(t,f),r.updateStatsFromPart(t,i);var u={frag:t,part:i,payload:e.data,networkDetails:o};n(u),h(u)},onError:function(n,s,a){r.resetLoader(t,f),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_ERROR,fatal:!1,frag:t,part:i,response:n,networkDetails:a}))},onAbort:function(n,s,a){t.stats.aborted=i.stats.aborted,r.resetLoader(t,f),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.INTERNAL_ABORTED,fatal:!1,frag:t,part:i,networkDetails:a}))},onTimeout:function(n,s,a){r.resetLoader(t,f),u(new v({type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.FRAG_LOAD_TIMEOUT,fatal:!1,frag:t,part:i,networkDetails:a}))}})}))},i.updateStatsFromPart=function(t,i){var n=t.stats,r=i.stats,e=r.total;if(n.loaded+=r.loaded,e){var s=Math.round(t.duration/i.duration),a=Math.min(Math.round(n.loaded/e),s),o=(s-a)*Math.round(n.loaded/a);n.total=n.loaded+o}else n.total=Math.max(n.loaded,n.total);var h=n.loading,u=r.loading;h.start?h.first+=u.first-u.start:(h.start=u.start,h.first=u.first),h.end=u.end},i.resetLoader=function(t,i){t.loader=null,this.loader===i&&(self.clearTimeout(this.partLoadTimeout),this.loader=null),i.destroy()},t}();function l(t,i){void 0===i&&(i=null);var n=i||t,e={frag:t,part:i,responseType:"arraybuffer",url:n.url,headers:{},rangeStart:0,rangeEnd:0},s=n.byteRangeStartOffset,a=n.byteRangeEndOffset;return Object(r.isFiniteNumber)(s)&&Object(r.isFiniteNumber)(a)&&(e.rangeStart=s,e.rangeEnd=a),e}var v=function(t){var i,n;function r(i){for(var n,r=arguments.length,e=new Array(r>1?r-1:0),s=1;s<r;s++)e[s-1]=arguments[s];return(n=t.call.apply(t,[this].concat(e))||this).data=void 0,n.data=i,n}return n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,h(i,n),r}(s(Error))},"./src/loader/fragment.ts":
202
+ /*!********************************!*\
203
+ !*** ./src/loader/fragment.ts ***!
204
+ \********************************/
205
+ /*! exports provided: ElementaryStreamTypes, BaseSegment, Fragment, Part */function(t,i,n){n.r(i),n.d(i,"ElementaryStreamTypes",(function(){return r})),n.d(i,"BaseSegment",(function(){return v})),n.d(i,"Fragment",(function(){return d})),n.d(i,"Part",(function(){return m}));var r,e=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),s=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ./level-key */"./src/loader/level-key.ts"),h=n(/*! ./load-stats */"./src/loader/load-stats.ts");function u(t,i){t.prototype=Object.create(i.prototype),t.prototype.constructor=t,c(t,i)}function c(t,i){return c=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},c(t,i)}function f(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function l(t,i,n){return i&&f(t.prototype,i),n&&f(t,n),t}!function(t){t.AUDIO="audio",t.VIDEO="video",t.AUDIOVIDEO="audiovideo"}(r||(r={}));var v=function(){function t(t){var i;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((i={})[r.AUDIO]=null,i[r.VIDEO]=null,i[r.AUDIOVIDEO]=null,i),this.baseurl=t}return t.prototype.setByteRange=function(t,i){var n=t.split("@",2),r=[];r[0]=1===n.length?i?i.byteRangeEndOffset:0:parseInt(n[1]),r[1]=parseInt(n[0])+r[0],this._byteRange=r},l(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=Object(s.buildAbsoluteURL)(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),d=function(t){function i(i,n){var r;return(r=t.call(this,n)||this)._decryptdata=null,r.rawProgramDateTime=null,r.programDateTime=null,r.tagList=[],r.duration=0,r.sn=0,r.levelkey=void 0,r.type=void 0,r.loader=null,r.level=-1,r.cc=0,r.startPTS=void 0,r.endPTS=void 0,r.appendedPTS=void 0,r.startDTS=void 0,r.endDTS=void 0,r.start=0,r.deltaPTS=void 0,r.maxStartPTS=void 0,r.minEndPTS=void 0,r.stats=new h.LoadStats,r.urlId=0,r.data=void 0,r.bitrateTest=!1,r.title=null,r.initSegment=null,r.type=i,r}u(i,t);var n=i.prototype;return n.createInitializationVector=function(t){for(var i=new Uint8Array(16),n=12;n<16;n++)i[n]=t>>8*(15-n)&255;return i},n.setDecryptDataFromLevelKey=function(t,i){var n=t;return"AES-128"===(null==t?void 0:t.method)&&t.uri&&!t.iv&&((n=o.LevelKey.fromURI(t.uri)).method=t.method,n.iv=this.createInitializationVector(i),n.keyFormat="identity"),n},n.setElementaryStreamInfo=function(t,i,n,r,e,s){void 0===s&&(s=!1);var a=this.elementaryStreams,o=a[t];o?(o.startPTS=Math.min(o.startPTS,i),o.endPTS=Math.max(o.endPTS,n),o.startDTS=Math.min(o.startDTS,r),o.endDTS=Math.max(o.endDTS,e)):a[t]={startPTS:i,endPTS:n,startDTS:r,endDTS:e,partial:s}},n.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[r.AUDIO]=null,t[r.VIDEO]=null,t[r.AUDIOVIDEO]=null},l(i,[{key:"decryptdata",get:function(){if(!this.levelkey&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkey){var t=this.sn;"number"!=typeof t&&(this.levelkey&&"AES-128"===this.levelkey.method&&!this.levelkey.iv&&a.logger.warn('missing IV for initialization segment with method="'+this.levelkey.method+'" - compliance issue'),t=0),this._decryptdata=this.setDecryptDataFromLevelKey(this.levelkey,t)}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!Object(e.isFiniteNumber)(this.programDateTime))return null;var t=Object(e.isFiniteNumber)(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;return!(null===(t=this.decryptdata)||void 0===t||!t.keyFormat||!this.decryptdata.uri)}}]),i}(v),m=function(t){function i(i,n,r,e,s){var a;(a=t.call(this,r)||this).fragOffset=0,a.duration=0,a.gap=!1,a.independent=!1,a.relurl=void 0,a.fragment=void 0,a.index=void 0,a.stats=new h.LoadStats,a.duration=i.decimalFloatingPoint("DURATION"),a.gap=i.bool("GAP"),a.independent=i.bool("INDEPENDENT"),a.relurl=i.enumeratedString("URI"),a.fragment=n,a.index=e;var o=i.enumeratedString("BYTERANGE");return o&&a.setByteRange(o,s),s&&(a.fragOffset=s.fragOffset+s.duration),a}return u(i,t),l(i,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),i}(v)},"./src/loader/key-loader.ts":
206
+ /*!**********************************!*\
207
+ !*** ./src/loader/key-loader.ts ***!
208
+ \**********************************/
209
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return a}));var r=n(/*! ../events */"./src/events.ts"),e=n(/*! ../errors */"./src/errors.ts"),s=n(/*! ../utils/logger */"./src/utils/logger.ts"),a=function(){function t(t){this.hls=void 0,this.loaders={},this.decryptkey=null,this.decrypturl=null,this.hls=t,this._registerListeners()}var i=t.prototype;return i._registerListeners=function(){this.hls.on(r.Events.KEY_LOADING,this.onKeyLoading,this)},i._unregisterListeners=function(){this.hls.off(r.Events.KEY_LOADING,this.onKeyLoading)},i.destroy=function(){for(var t in this._unregisterListeners(),this.loaders){var i=this.loaders[t];i&&i.destroy()}this.loaders={}},i.onKeyLoading=function(t,i){var n=i.frag,e=n.type,a=this.loaders[e];if(n.decryptdata){var o=n.decryptdata.uri;if(o!==this.decrypturl||null===this.decryptkey){var h=this.hls.config;if(a&&(s.logger.warn("abort previous key loader for type:"+e),a.abort()),!o)return void s.logger.warn("key uri is falsy");var u=n.loader=this.loaders[e]=new(0,h.loader)(h);this.decrypturl=o,this.decryptkey=null;var c={url:o,frag:n,responseType:"arraybuffer"},f={timeout:h.fragLoadingTimeOut,maxRetry:0,retryDelay:h.fragLoadingRetryDelay,maxRetryDelay:h.fragLoadingMaxRetryTimeout,highWaterMark:0},l={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};u.load(c,f,l)}else this.decryptkey&&(n.decryptdata.key=this.decryptkey,this.hls.trigger(r.Events.KEY_LOADED,{frag:n}))}else s.logger.warn("Missing decryption data on fragment in onKeyLoading")},i.loadsuccess=function(t,i,n){var e=n.frag;e.decryptdata?(this.decryptkey=e.decryptdata.key=new Uint8Array(t.data),e.loader=null,delete this.loaders[e.type],this.hls.trigger(r.Events.KEY_LOADED,{frag:e})):s.logger.error("after key load, decryptdata unset")},i.loaderror=function(t,i){var n=i.frag,s=n.loader;s&&s.abort(),delete this.loaders[n.type],this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.KEY_LOAD_ERROR,fatal:!1,frag:n,response:t})},i.loadtimeout=function(t,i){var n=i.frag,s=n.loader;s&&s.abort(),delete this.loaders[n.type],this.hls.trigger(r.Events.ERROR,{type:e.ErrorTypes.NETWORK_ERROR,details:e.ErrorDetails.KEY_LOAD_TIMEOUT,fatal:!1,frag:n})},t}()},"./src/loader/level-details.ts":
210
+ /*!*************************************!*\
211
+ !*** ./src/loader/level-details.ts ***!
212
+ \*************************************/
213
+ /*! exports provided: LevelDetails */function(t,i,n){n.r(i),n.d(i,"LevelDetails",(function(){return s}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts");function e(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(t){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.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.needSidxRanges=!1,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.fragments=[],this.url=t}var i,n;return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var i=this.lastPartSn-t.lastPartSn,n=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!n||!!i,this.advanced=this.endSN>t.endSN||i>0||0===i&&n>0,this.misses=this.updated||this.advanced?Math.floor(.6*t.misses):t.misses+1,this.availabilityDelay=t.availabilityDelay},i=t,(n=[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&Object(r.isFiniteNumber)(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!==(t=this.fragments)&&void 0!==t&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!==(t=this.partList)&&void 0!==t&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}])&&e(i.prototype,n),t}()},"./src/loader/level-key.ts":
214
+ /*!*********************************!*\
215
+ !*** ./src/loader/level-key.ts ***!
216
+ \*********************************/
217
+ /*! exports provided: LevelKey */function(t,i,n){n.r(i),n.d(i,"LevelKey",(function(){return s}));var r=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js");function e(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var s=function(){function t(t,i){this._uri=null,this.method=null,this.keyFormat=null,this.keyFormatVersions=null,this.keyID=null,this.key=null,this.iv=null,this._uri=i?Object(r.buildAbsoluteURL)(t,i,{alwaysNormalize:!0}):t}var i,n;return t.fromURL=function(i,n){return new t(i,n)},t.fromURI=function(i){return new t(i)},i=t,(n=[{key:"uri",get:function(){return this._uri}}])&&e(i.prototype,n),t}()},"./src/loader/load-stats.ts":
218
+ /*!**********************************!*\
219
+ !*** ./src/loader/load-stats.ts ***!
220
+ \**********************************/
221
+ /*! exports provided: LoadStats */function(t,i,n){n.r(i),n.d(i,"LoadStats",(function(){return r}));var r=function(){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}}},"./src/loader/m3u8-parser.ts":
222
+ /*!***********************************!*\
223
+ !*** ./src/loader/m3u8-parser.ts ***!
224
+ \***********************************/
225
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return p}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! url-toolkit */"./node_modules/url-toolkit/src/url-toolkit.js"),s=n(/*! ./fragment */"./src/loader/fragment.ts"),a=n(/*! ./level-details */"./src/loader/level-details.ts"),o=n(/*! ./level-key */"./src/loader/level-key.ts"),h=n(/*! ../utils/attr-list */"./src/utils/attr-list.ts"),u=n(/*! ../utils/logger */"./src/utils/logger.ts"),c=n(/*! ../utils/codecs */"./src/utils/codecs.ts"),f=/#EXT-X-STREAM-INF:([^\r\n]*)(?:[\r\n](?:#[^\r\n]*)?)*([^\r\n]+)|#EXT-X-SESSION-DATA:([^\r\n]*)[\r\n]+/g,l=/#EXT-X-MEDIA:(.*)/g,v=new RegExp([/#EXTINF:\s*(\d*(?:\.\d+)?)(?:,(.*)\s+)?/.source,/(?!#) *(\S[\S ]*)/.source,/#EXT-X-BYTERANGE:*(.+)/.source,/#EXT-X-PROGRAM-DATE-TIME:(.+)/.source,/#.*/.source].join("|"),"g"),d=new RegExp([/#(EXTM3U)/.source,/#EXT-X-(PLAYLIST-TYPE):(.+)/.source,/#EXT-X-(MEDIA-SEQUENCE): *(\d+)/.source,/#EXT-X-(SKIP):(.+)/.source,/#EXT-X-(TARGETDURATION): *(\d+)/.source,/#EXT-X-(KEY):(.+)/.source,/#EXT-X-(START):(.+)/.source,/#EXT-X-(ENDLIST)/.source,/#EXT-X-(DISCONTINUITY-SEQ)UENCE: *(\d+)/.source,/#EXT-X-(DIS)CONTINUITY/.source,/#EXT-X-(VERSION):(\d+)/.source,/#EXT-X-(MAP):(.+)/.source,/#EXT-X-(SERVER-CONTROL):(.+)/.source,/#EXT-X-(PART-INF):(.+)/.source,/#EXT-X-(GAP)/.source,/#EXT-X-(BITRATE):\s*(\d+)/.source,/#EXT-X-(PART):(.+)/.source,/#EXT-X-(PRELOAD-HINT):(.+)/.source,/#EXT-X-(RENDITION-REPORT):(.+)/.source,/(#)([^:]*):(.*)/.source,/(#)(.*)(?:.*)\r?\n?/.source].join("|")),m=/\.(mp4|m4s|m4v|m4a)$/i,p=function(){function t(){}return t.findGroup=function(t,i){for(var n=0;n<t.length;n++){var r=t[n];if(r.id===i)return r}},t.convertAVC1ToAVCOTI=function(t){var i=t.split(".");if(i.length>2){var n=i.shift()+".";return(n+=parseInt(i.shift()).toString(16))+("000"+parseInt(i.shift()).toString(16)).substr(-4)}return t},t.resolve=function(t,i){return e.buildAbsoluteURL(i,t,{alwaysNormalize:!0})},t.parseMasterPlaylist=function(i,n){var r,e=[],s={},a=!1;for(f.lastIndex=0;null!=(r=f.exec(i));)if(r[1]){var o=new h.AttrList(r[1]),u={attrs:o,bitrate:o.decimalInteger("AVERAGE-BANDWIDTH")||o.decimalInteger("BANDWIDTH"),name:o.NAME,url:t.resolve(r[2],n)},c=o.decimalResolution("RESOLUTION");c&&(u.width=c.width,u.height=c.height),g((o.CODECS||"").split(/[ ,]+/).filter((function(t){return t})),u),u.videoCodec&&-1!==u.videoCodec.indexOf("avc1")&&(u.videoCodec=t.convertAVC1ToAVCOTI(u.videoCodec)),e.push(u)}else if(r[3]){var l=new h.AttrList(r[3]);l["DATA-ID"]&&(a=!0,s[l["DATA-ID"]]=l)}return{levels:e,sessionData:a?s:null}},t.parseMasterPlaylistMedia=function(i,n,r,e){var s;void 0===e&&(e=[]);var a=[],o=0;for(l.lastIndex=0;null!==(s=l.exec(i));){var u=new h.AttrList(s[1]);if(u.TYPE===r){var c={attrs:u,bitrate:0,id:o++,groupId:u["GROUP-ID"],instreamId:u["INSTREAM-ID"],name:u.NAME||u.LANGUAGE||"",type:r,default:u.bool("DEFAULT"),autoselect:u.bool("AUTOSELECT"),forced:u.bool("FORCED"),lang:u.LANGUAGE,url:u.URI?t.resolve(u.URI,n):""};if(e.length){var f=t.findGroup(e,c.groupId)||e[0];b(c,f,"audioCodec"),b(c,f,"textCodec")}a.push(c)}}return a},t.parseLevelPlaylist=function(t,i,n,c,f){var l,p,g,b=new a.LevelDetails(i),w=b.fragments,k=null,T=0,O=0,S=0,E=0,A=null,M=new s.Fragment(c,i),x=-1,j=!1;for(v.lastIndex=0,b.m3u8=t;null!==(l=v.exec(t));){j&&(j=!1,(M=new s.Fragment(c,i)).start=S,M.sn=T,M.cc=E,M.level=n,k&&(M.initSegment=k,M.rawProgramDateTime=k.rawProgramDateTime));var D=l[1];if(D){M.duration=parseFloat(D);var L=(" "+l[2]).slice(1);M.title=L||null,M.tagList.push(L?["INF",D,L]:["INF",D])}else if(l[3])Object(r.isFiniteNumber)(M.duration)&&(M.start=S,g&&(M.levelkey=g),M.sn=T,M.level=n,M.cc=E,M.urlId=f,w.push(M),M.relurl=(" "+l[3]).slice(1),y(M,A),A=M,S+=M.duration,T++,O=0,j=!0);else if(l[4]){var I=(" "+l[4]).slice(1);A?M.setByteRange(I,A):M.setByteRange(I)}else if(l[5])M.rawProgramDateTime=(" "+l[5]).slice(1),M.tagList.push(["PROGRAM-DATE-TIME",M.rawProgramDateTime]),-1===x&&(x=w.length);else{if(!(l=l[0].match(d))){u.logger.warn("No matches on slow regex match for level playlist!");continue}for(p=1;p<l.length&&void 0===l[p];p++);var C=(" "+l[p]).slice(1),R=(" "+l[p+1]).slice(1),P=l[p+2]?(" "+l[p+2]).slice(1):"";switch(C){case"PLAYLIST-TYPE":b.type=R.toUpperCase();break;case"MEDIA-SEQUENCE":T=b.startSN=parseInt(R);break;case"SKIP":var U=new h.AttrList(R),N=U.decimalInteger("SKIPPED-SEGMENTS");if(Object(r.isFiniteNumber)(N)){b.skippedSegments=N;for(var F=N;F--;)w.unshift(null);T+=N}var B=U.enumeratedString("RECENTLY-REMOVED-DATERANGES");B&&(b.recentlyRemovedDateranges=B.split("\t"));break;case"TARGETDURATION":b.targetduration=parseFloat(R);break;case"VERSION":b.version=parseInt(R);break;case"EXTM3U":break;case"ENDLIST":b.live=!1;break;case"#":(R||P)&&M.tagList.push(P?[R,P]:[R]);break;case"DIS":E++;case"GAP":M.tagList.push([C]);break;case"BITRATE":M.tagList.push([C,R]);break;case"DISCONTINUITY-SEQ":E=parseInt(R);break;case"KEY":var _,X=new h.AttrList(R),G=X.enumeratedString("METHOD"),W=X.URI,K=X.hexadecimalInteger("IV"),H=X.enumeratedString("KEYFORMATVERSIONS"),V=X.enumeratedString("KEYID"),q=null!=(_=X.enumeratedString("KEYFORMAT"))?_:"identity";if(["com.apple.streamingkeydelivery","com.microsoft.playready","urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed","com.widevine"].indexOf(q)>-1){u.logger.warn("Keyformat "+q+" is not supported from the manifest");continue}if("identity"!==q)continue;G&&(g=o.LevelKey.fromURL(i,W),W&&["AES-128","SAMPLE-AES","SAMPLE-AES-CENC"].indexOf(G)>=0&&(g.method=G,g.keyFormat=q,V&&(g.keyID=V),H&&(g.keyFormatVersions=H),g.iv=K));break;case"START":var z=new h.AttrList(R).decimalFloatingPoint("TIME-OFFSET");Object(r.isFiniteNumber)(z)&&(b.startTimeOffset=z);break;case"MAP":var Y=new h.AttrList(R);M.relurl=Y.URI,Y.BYTERANGE&&M.setByteRange(Y.BYTERANGE),M.level=n,M.sn="initSegment",g&&(M.levelkey=g),M.initSegment=null,k=M,j=!0;break;case"SERVER-CONTROL":var $=new h.AttrList(R);b.canBlockReload=$.bool("CAN-BLOCK-RELOAD"),b.canSkipUntil=$.optionalFloat("CAN-SKIP-UNTIL",0),b.canSkipDateRanges=b.canSkipUntil>0&&$.bool("CAN-SKIP-DATERANGES"),b.partHoldBack=$.optionalFloat("PART-HOLD-BACK",0),b.holdBack=$.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var J=new h.AttrList(R);b.partTarget=J.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=b.partList;Q||(Q=b.partList=[]);var Z=O>0?Q[Q.length-1]:void 0,tt=O++,it=new s.Part(new h.AttrList(R),M,i,tt,Z);Q.push(it),M.duration+=it.duration;break;case"PRELOAD-HINT":var nt=new h.AttrList(R);b.preloadHint=nt;break;case"RENDITION-REPORT":var rt=new h.AttrList(R);b.renditionReports=b.renditionReports||[],b.renditionReports.push(rt);break;default:u.logger.warn("line parsed but not handled: "+l)}}}A&&!A.relurl?(w.pop(),S-=A.duration,b.partList&&(b.fragmentHint=A)):b.partList&&(y(M,A),M.cc=E,b.fragmentHint=M);var et=w.length,st=w[0],at=w[et-1];if((S+=b.skippedSegments*b.targetduration)>0&&et&&at){b.averagetargetduration=S/et;var ot=at.sn;b.endSN="initSegment"!==ot?ot:0,st&&(b.startCC=st.cc,st.initSegment||b.fragments.every((function(t){return t.relurl&&m.test(null!=(i=null===(n=e.parseURL(t.relurl))||void 0===n?void 0:n.path)?i:"");var i,n}))&&(u.logger.warn("MP4 fragments found but no init segment (probably no MAP, incomplete M3U8), trying to fetch SIDX"),(M=new s.Fragment(c,i)).relurl=at.relurl,M.level=n,M.sn="initSegment",st.initSegment=M,b.needSidxRanges=!0))}else b.endSN=0,b.startCC=0;return b.fragmentHint&&(S+=b.fragmentHint.duration),b.totalduration=S,b.endCC=E,x>0&&function(t,i){for(var n=t[i],r=i;r--;){var e=t[r];if(!e)return;e.programDateTime=n.programDateTime-1e3*e.duration,n=e}}(w,x),b},t}();function g(t,i){["video","audio","text"].forEach((function(n){var r=t.filter((function(t){return Object(c.isCodecType)(t,n)}));if(r.length){var e=r.filter((function(t){return 0===t.lastIndexOf("avc1",0)||0===t.lastIndexOf("mp4a",0)}));i[n+"Codec"]=e.length>0?e[0]:r[0],t=t.filter((function(t){return-1===r.indexOf(t)}))}})),i.unknownCodecs=t}function b(t,i,n){var r=i[n];r&&(t[n]=r)}function y(t,i){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=i&&i.programDateTime&&(t.programDateTime=i.endProgramDateTime),Object(r.isFiniteNumber)(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}},"./src/loader/playlist-loader.ts":
226
+ /*!***************************************!*\
227
+ !*** ./src/loader/playlist-loader.ts ***!
228
+ \***************************************/
229
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../events */"./src/events.ts"),s=n(/*! ../errors */"./src/errors.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),h=n(/*! ./m3u8-parser */"./src/loader/m3u8-parser.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../utils/attr-list */"./src/utils/attr-list.ts");function f(t,i){var n=t.url;return void 0!==n&&0!==n.indexOf("data:")||(n=i.url),n}var l=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.hls=t,this.registerListeners()}var i=t.prototype;return i.registerListeners=function(){var t=this.hls;t.on(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.on(e.Events.LEVEL_LOADING,this.onLevelLoading,this),t.on(e.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(e.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},i.unregisterListeners=function(){var t=this.hls;t.off(e.Events.MANIFEST_LOADING,this.onManifestLoading,this),t.off(e.Events.LEVEL_LOADING,this.onLevelLoading,this),t.off(e.Events.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(e.Events.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},i.createInternalLoader=function(t){var i=this.hls.config,n=new(i.pLoader||i.loader)(i);return t.loader=n,this.loaders[t.type]=n,n},i.getInternalLoader=function(t){return this.loaders[t.type]},i.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},i.destroyInternalLoaders=function(){for(var t in this.loaders){var i=this.loaders[t];i&&i.destroy(),this.resetInternalLoader(t)}},i.destroy=function(){this.unregisterListeners(),this.destroyInternalLoaders()},i.onManifestLoading=function(t,i){this.load({id:null,groupId:null,level:0,responseType:"text",type:u.PlaylistContextType.MANIFEST,url:i.url,deliveryDirectives:null})},i.onLevelLoading=function(t,i){this.load({id:i.id,groupId:null,level:i.level,responseType:"text",type:u.PlaylistContextType.LEVEL,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.onAudioTrackLoading=function(t,i){this.load({id:i.id,groupId:i.groupId,level:null,responseType:"text",type:u.PlaylistContextType.AUDIO_TRACK,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.onSubtitleTrackLoading=function(t,i){this.load({id:i.id,groupId:i.groupId,level:null,responseType:"text",type:u.PlaylistContextType.SUBTITLE_TRACK,url:i.url,deliveryDirectives:i.deliveryDirectives})},i.load=function(t){var i,n,r,e,s,o,h=this.hls.config,c=this.getInternalLoader(t);if(c){var f=c.context;if(f&&f.url===t.url)return void a.logger.trace("[playlist-loader]: playlist request ongoing");a.logger.log("[playlist-loader]: aborting previous loader for type: "+t.type),c.abort()}switch(t.type){case u.PlaylistContextType.MANIFEST:n=h.manifestLoadingMaxRetry,r=h.manifestLoadingTimeOut,e=h.manifestLoadingRetryDelay,s=h.manifestLoadingMaxRetryTimeout;break;case u.PlaylistContextType.LEVEL:case u.PlaylistContextType.AUDIO_TRACK:case u.PlaylistContextType.SUBTITLE_TRACK:n=0,r=h.levelLoadingTimeOut;break;default:n=h.levelLoadingMaxRetry,r=h.levelLoadingTimeOut,e=h.levelLoadingRetryDelay,s=h.levelLoadingMaxRetryTimeout}if(c=this.createInternalLoader(t),null!==(i=t.deliveryDirectives)&&void 0!==i&&i.part&&(t.type===u.PlaylistContextType.LEVEL&&null!==t.level?o=this.hls.levels[t.level].details:t.type===u.PlaylistContextType.AUDIO_TRACK&&null!==t.id?o=this.hls.audioTracks[t.id].details:t.type===u.PlaylistContextType.SUBTITLE_TRACK&&null!==t.id&&(o=this.hls.subtitleTracks[t.id].details),o)){var l=o.partTarget,v=o.targetduration;l&&v&&(r=Math.min(1e3*Math.max(3*l,.8*v),r))}var d={timeout:r,maxRetry:n,retryDelay:e,maxRetryDelay:s,highWaterMark:0},m={onSuccess:this.loadsuccess.bind(this),onError:this.loaderror.bind(this),onTimeout:this.loadtimeout.bind(this)};c.load(t,d,m)},i.loadsuccess=function(t,i,n,r){if(void 0===r&&(r=null),n.isSidxRequest)return this.handleSidxRequest(t,n),void this.handlePlaylistLoaded(t,i,n,r);this.resetInternalLoader(n.type);var e=t.data;0===e.indexOf("#EXTM3U")?(i.parsing.start=performance.now(),e.indexOf("#EXTINF:")>0||e.indexOf("#EXT-X-TARGETDURATION:")>0?this.handleTrackOrLevelPlaylist(t,i,n,r):this.handleMasterPlaylist(t,i,n,r)):this.handleManifestParsingError(t,n,"no EXTM3U delimiter",r)},i.loaderror=function(t,i,n){void 0===n&&(n=null),this.handleNetworkError(i,n,!1,t)},i.loadtimeout=function(t,i,n){void 0===n&&(n=null),this.handleNetworkError(i,n,!0)},i.handleMasterPlaylist=function(t,i,n,r){var s=this.hls,o=t.data,u=f(t,n),l=h.default.parseMasterPlaylist(o,u),v=l.levels,d=l.sessionData;if(v.length){var m=v.map((function(t){return{id:t.attrs.AUDIO,audioCodec:t.audioCodec}})),p=v.map((function(t){return{id:t.attrs.SUBTITLES,textCodec:t.textCodec}})),g=h.default.parseMasterPlaylistMedia(o,u,"AUDIO",m),b=h.default.parseMasterPlaylistMedia(o,u,"SUBTITLES",p),y=h.default.parseMasterPlaylistMedia(o,u,"CLOSED-CAPTIONS");g.length&&(g.some((function(t){return!t.url}))||!v[0].audioCodec||v[0].attrs.AUDIO||(a.logger.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),g.unshift({type:"main",name:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new c.AttrList({}),bitrate:0,url:""}))),s.trigger(e.Events.MANIFEST_LOADED,{levels:v,audioTracks:g,subtitles:b,captions:y,url:u,stats:i,networkDetails:r,sessionData:d})}else this.handleManifestParsingError(t,n,"no level found in manifest",r)},i.handleTrackOrLevelPlaylist=function(t,i,n,a){var o=this.hls,l=n.id,v=n.level,d=n.type,m=f(t,n),p=Object(r.isFiniteNumber)(l)?l:0,g=Object(r.isFiniteNumber)(v)?v:p,b=function(t){switch(t.type){case u.PlaylistContextType.AUDIO_TRACK:return u.PlaylistLevelType.AUDIO;case u.PlaylistContextType.SUBTITLE_TRACK:return u.PlaylistLevelType.SUBTITLE;default:return u.PlaylistLevelType.MAIN}}(n),y=h.default.parseLevelPlaylist(t.data,m,g,b,p);if(y.fragments.length){if(d===u.PlaylistContextType.MANIFEST){var w={attrs:new c.AttrList({}),bitrate:0,details:y,name:"",url:m};o.trigger(e.Events.MANIFEST_LOADED,{levels:[w],audioTracks:[],url:m,stats:i,networkDetails:a,sessionData:null})}if(i.parsing.end=performance.now(),y.needSidxRanges){var k,T=null===(k=y.fragments[0].initSegment)||void 0===k?void 0:k.url;this.load({url:T,isSidxRequest:!0,type:d,level:v,levelDetails:y,id:l,groupId:null,rangeStart:0,rangeEnd:2048,responseType:"arraybuffer",deliveryDirectives:null})}else n.levelDetails=y,this.handlePlaylistLoaded(t,i,n,a)}else o.trigger(e.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.LEVEL_EMPTY_ERROR,fatal:!1,url:m,reason:"no fragments found in level",level:"number"==typeof n.level?n.level:void 0})},i.handleSidxRequest=function(t,i){var n=Object(o.parseSegmentIndex)(new Uint8Array(t.data));if(n){var r=i.levelDetails;n.references.forEach((function(t,i){var e=t.info,s=r.fragments[i];0===s.byteRange.length&&s.setByteRange(String(1+e.end-e.start)+"@"+String(e.start)),s.initSegment&&s.initSegment.setByteRange(String(n.moovEndOffset)+"@0")}))}},i.handleManifestParsingError=function(t,i,n,r){this.hls.trigger(e.Events.ERROR,{type:s.ErrorTypes.NETWORK_ERROR,details:s.ErrorDetails.MANIFEST_PARSING_ERROR,fatal:i.type===u.PlaylistContextType.MANIFEST,url:t.url,reason:n,response:t,context:i,networkDetails:r})},i.handleNetworkError=function(t,i,n,r){void 0===n&&(n=!1),a.logger.warn("[playlist-loader]: A network "+(n?"timeout":"error")+" occurred while loading "+t.type+" level: "+t.level+" id: "+t.id+' group-id: "'+t.groupId+'"');var o=s.ErrorDetails.UNKNOWN,h=!1,c=this.getInternalLoader(t);switch(t.type){case u.PlaylistContextType.MANIFEST:o=n?s.ErrorDetails.MANIFEST_LOAD_TIMEOUT:s.ErrorDetails.MANIFEST_LOAD_ERROR,h=!0;break;case u.PlaylistContextType.LEVEL:o=n?s.ErrorDetails.LEVEL_LOAD_TIMEOUT:s.ErrorDetails.LEVEL_LOAD_ERROR,h=!1;break;case u.PlaylistContextType.AUDIO_TRACK:o=n?s.ErrorDetails.AUDIO_TRACK_LOAD_TIMEOUT:s.ErrorDetails.AUDIO_TRACK_LOAD_ERROR,h=!1;break;case u.PlaylistContextType.SUBTITLE_TRACK:o=n?s.ErrorDetails.SUBTITLE_TRACK_LOAD_TIMEOUT:s.ErrorDetails.SUBTITLE_LOAD_ERROR,h=!1}c&&this.resetInternalLoader(t.type);var f={type:s.ErrorTypes.NETWORK_ERROR,details:o,fatal:h,url:t.url,loader:c,context:t,networkDetails:i};r&&(f.response=r),this.hls.trigger(e.Events.ERROR,f)},i.handlePlaylistLoaded=function(t,i,n,r){var s=n.type,a=n.level,o=n.id,h=n.groupId,c=n.loader,f=n.levelDetails,l=n.deliveryDirectives;if(null!=f&&f.targetduration){if(c)switch(f.live&&(c.getCacheAge&&(f.ageHeader=c.getCacheAge()||0),c.getCacheAge&&!isNaN(f.ageHeader)||(f.ageHeader=0)),s){case u.PlaylistContextType.MANIFEST:case u.PlaylistContextType.LEVEL:this.hls.trigger(e.Events.LEVEL_LOADED,{details:f,level:a||0,id:o||0,stats:i,networkDetails:r,deliveryDirectives:l});break;case u.PlaylistContextType.AUDIO_TRACK:this.hls.trigger(e.Events.AUDIO_TRACK_LOADED,{details:f,id:o||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:l});break;case u.PlaylistContextType.SUBTITLE_TRACK:this.hls.trigger(e.Events.SUBTITLE_TRACK_LOADED,{details:f,id:o||0,groupId:h||"",stats:i,networkDetails:r,deliveryDirectives:l})}}else this.handleManifestParsingError(t,n,"invalid target duration",r)},t}();i.default=l},"./src/polyfills/number.ts":
230
+ /*!*********************************!*\
231
+ !*** ./src/polyfills/number.ts ***!
232
+ \*********************************/
233
+ /*! exports provided: isFiniteNumber, MAX_SAFE_INTEGER */function(t,i,n){n.r(i),n.d(i,"isFiniteNumber",(function(){return r})),n.d(i,"MAX_SAFE_INTEGER",(function(){return e}));var r=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},e=Number.MAX_SAFE_INTEGER||9007199254740991},"./src/remux/aac-helper.ts":
234
+ /*!*********************************!*\
235
+ !*** ./src/remux/aac-helper.ts ***!
236
+ \*********************************/
237
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default=function(){function t(){}return t.getSilentFrame=function(t,i){if("mp4a.40.2"===t){if(1===i)return new Uint8Array([0,200,0,128,35,128]);if(2===i)return new Uint8Array([33,0,73,144,2,25,0,35,128]);if(3===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,142]);if(4===i)return new Uint8Array([0,200,0,128,32,132,1,38,64,8,100,0,128,44,128,8,2,56]);if(5===i)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(6===i)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])}else{if(1===i)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(2===i)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(3===i)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])}},t}()},"./src/remux/mp4-generator.ts":
238
+ /*!************************************!*\
239
+ !*** ./src/remux/mp4-generator.ts ***!
240
+ \************************************/
241
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=Math.pow(2,32)-1,e=function(){function t(){}return t.init=function(){var i;for(i in t.types={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],".mp3":[],mvex:[],mvhd:[],pasp:[],sdtp:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[],smhd:[]})t.types.hasOwnProperty(i)&&(t.types[i]=[i.charCodeAt(0),i.charCodeAt(1),i.charCodeAt(2),i.charCodeAt(3)]);var n=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]),r=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]);t.HDLR_TYPES={video:n,audio:r};var e=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),s=new Uint8Array([0,0,0,0,0,0,0,0]);t.STTS=t.STSC=t.STCO=s,t.STSZ=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),t.VMHD=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0]),t.SMHD=new Uint8Array([0,0,0,0,0,0,0,0]),t.STSD=new Uint8Array([0,0,0,0,0,0,0,1]);var a=new Uint8Array([105,115,111,109]),o=new Uint8Array([97,118,99,49]),h=new Uint8Array([0,0,0,1]);t.FTYP=t.box(t.types.ftyp,a,h,a,o),t.DINF=t.box(t.types.dinf,t.box(t.types.dref,e))},t.box=function(t){for(var i=8,n=arguments.length,r=new Array(n>1?n-1:0),e=1;e<n;e++)r[e-1]=arguments[e];for(var s=r.length,a=s;s--;)i+=r[s].byteLength;var o=new Uint8Array(i);for(o[0]=i>>24&255,o[1]=i>>16&255,o[2]=i>>8&255,o[3]=255&i,o.set(t,4),s=0,i=8;s<a;s++)o.set(r[s],i),i+=r[s].byteLength;return o},t.hdlr=function(i){return t.box(t.types.hdlr,t.HDLR_TYPES[i])},t.mdat=function(i){return t.box(t.types.mdat,i)},t.mdhd=function(i,n){n*=i;var e=Math.floor(n/(r+1)),s=Math.floor(n%(r+1));return t.box(t.types.mdhd,new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e,s>>24,s>>16&255,s>>8&255,255&s,85,196,0,0]))},t.mdia=function(i){return t.box(t.types.mdia,t.mdhd(i.timescale,i.duration),t.hdlr(i.type),t.minf(i))},t.mfhd=function(i){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,i>>24,i>>16&255,i>>8&255,255&i]))},t.minf=function(i){return t.box(t.types.minf,"audio"===i.type?t.box(t.types.smhd,t.SMHD):t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(i))},t.moof=function(i,n,r){return t.box(t.types.moof,t.mfhd(i),t.traf(r,n))},t.moov=function(i){for(var n=i.length,r=[];n--;)r[n]=t.trak(i[n]);return t.box.apply(null,[t.types.moov,t.mvhd(i[0].timescale,i[0].duration)].concat(r).concat(t.mvex(i)))},t.mvex=function(i){for(var n=i.length,r=[];n--;)r[n]=t.trex(i[n]);return t.box.apply(null,[t.types.mvex].concat(r))},t.mvhd=function(i,n){n*=i;var e=Math.floor(n/(r+1)),s=Math.floor(n%(r+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,i>>24&255,i>>16&255,i>>8&255,255&i,e>>24,e>>16&255,e>>8&255,255&e,s>>24,s>>16&255,s>>8&255,255&s,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 t.box(t.types.mvhd,a)},t.sdtp=function(i){var n,r,e=i.samples||[],s=new Uint8Array(4+e.length);for(n=0;n<e.length;n++)s[n+4]=(r=e[n].flags).dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return t.box(t.types.sdtp,s)},t.stbl=function(i){return t.box(t.types.stbl,t.stsd(i),t.box(t.types.stts,t.STTS),t.box(t.types.stsc,t.STSC),t.box(t.types.stsz,t.STSZ),t.box(t.types.stco,t.STCO))},t.avc1=function(i){var n,r,e,s=[],a=[];for(n=0;n<i.sps.length;n++)s.push((e=(r=i.sps[n]).byteLength)>>>8&255),s.push(255&e),s=s.concat(Array.prototype.slice.call(r));for(n=0;n<i.pps.length;n++)a.push((e=(r=i.pps[n]).byteLength)>>>8&255),a.push(255&e),a=a.concat(Array.prototype.slice.call(r));var o=t.box(t.types.avcC,new Uint8Array([1,s[3],s[4],s[5],255,224|i.sps.length].concat(s).concat([i.pps.length]).concat(a))),h=i.width,u=i.height,c=i.pixelRatio[0],f=i.pixelRatio[1];return t.box(t.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,h>>8&255,255&h,u>>8&255,255&u,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,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([c>>24,c>>16&255,c>>8&255,255&c,f>>24,f>>16&255,f>>8&255,255&f])))},t.esds=function(t){var i=t.config.length;return new Uint8Array([0,0,0,0,3,23+i,0,1,0,4,15+i,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([i]).concat(t.config).concat([6,1,2]))},t.mp4a=function(i){var n=i.samplerate;return t.box(t.types.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,n>>8&255,255&n,0,0]),t.box(t.types.esds,t.esds(i)))},t.mp3=function(i){var n=i.samplerate;return t.box(t.types[".mp3"],new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,i.channelCount,0,16,0,0,0,0,n>>8&255,255&n,0,0]))},t.stsd=function(i){return t.box(t.types.stsd,t.STSD,"audio"===i.type?i.isAAC||"mp3"!==i.codec?t.mp4a(i):t.mp3(i):t.avc1(i))},t.tkhd=function(i){var n=i.id,e=i.duration*i.timescale,s=i.width,a=i.height,o=Math.floor(e/(r+1)),h=Math.floor(e%(r+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,n>>24&255,n>>16&255,n>>8&255,255&n,0,0,0,0,o>>24,o>>16&255,o>>8&255,255&o,h>>24,h>>16&255,h>>8&255,255&h,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,s>>8&255,255&s,0,0,a>>8&255,255&a,0,0]))},t.traf=function(i,n){var e=t.sdtp(i),s=i.id,a=Math.floor(n/(r+1)),o=Math.floor(n%(r+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,o>>24,o>>16&255,o>>8&255,255&o])),t.trun(i,e.length+16+20+8+16+8+8),e)},t.trak=function(i){return i.duration=i.duration||4294967295,t.box(t.types.trak,t.tkhd(i),t.mdia(i))},t.trex=function(i){var n=i.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(i,n){var r,e,s,a,o,h,u=i.samples||[],c=u.length,f=12+16*c,l=new Uint8Array(f);for(l.set([0,0,15,1,c>>>24&255,c>>>16&255,c>>>8&255,255&c,(n+=8+f)>>>24&255,n>>>16&255,n>>>8&255,255&n],0),r=0;r<c;r++)l.set([(s=(e=u[r]).duration)>>>24&255,s>>>16&255,s>>>8&255,255&s,(a=e.size)>>>24&255,a>>>16&255,a>>>8&255,255&a,(o=e.flags).isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,(h=e.cts)>>>24&255,h>>>16&255,h>>>8&255,255&h],12+16*r);return t.box(t.types.trun,l)},t.initSegment=function(i){t.types||t.init();var n=t.moov(i),r=new Uint8Array(t.FTYP.byteLength+n.byteLength);return r.set(t.FTYP),r.set(n,t.FTYP.byteLength),r},t}();e.types=void 0,e.HDLR_TYPES=void 0,e.STTS=void 0,e.STSC=void 0,e.STCO=void 0,e.STSZ=void 0,e.VMHD=void 0,e.SMHD=void 0,e.STSD=void 0,e.FTYP=void 0,e.DINF=void 0,i.default=e},"./src/remux/mp4-remuxer.ts":
242
+ /*!**********************************!*\
243
+ !*** ./src/remux/mp4-remuxer.ts ***!
244
+ \**********************************/
245
+ /*! exports provided: default, normalizePts */function(t,i,n){n.r(i),n.d(i,"default",(function(){return m})),n.d(i,"normalizePts",(function(){return p}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./aac-helper */"./src/remux/aac-helper.ts"),s=n(/*! ./mp4-generator */"./src/remux/mp4-generator.ts"),a=n(/*! ../events */"./src/events.ts"),o=n(/*! ../errors */"./src/errors.ts"),h=n(/*! ../utils/logger */"./src/utils/logger.ts"),u=n(/*! ../types/loader */"./src/types/loader.ts"),c=n(/*! ../utils/timescale-conversion */"./src/utils/timescale-conversion.ts");function f(){return f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f.apply(this,arguments)}var l=null,v=null,d=!1,m=function(){function t(t,i,n){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=void 0,this._initDTS=void 0,this.nextAvcDts=null,this.nextAudioPts=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.observer=t,this.config=i,this.typeSupported=n,this.ISGenerated=!1,null===l){var r=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);l=r?parseInt(r[1]):0}if(null===v){var e=navigator.userAgent.match(/Safari\/(\d+)/i);v=e?parseInt(e[1]):0}d=!!l&&l<75||!!v&&v<600}var i=t.prototype;return i.destroy=function(){},i.resetTimeStamp=function(t){h.logger.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},i.resetNextTimestamp=function(){h.logger.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},i.resetInitSegment=function(){h.logger.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1},i.getVideoStartPts=function(t){var i=!1,n=t.reduce((function(t,n){var r=n.pts-t;return r<-4294967296?(i=!0,p(t,n.pts)):r>0?t:n.pts}),t[0].pts);return i&&h.logger.debug("PTS rollover detected"),n},i.remux=function(t,i,n,r,e,s,a,o){var c,f,l,v,d,m,g=e,b=e,y=i.pid>-1,w=i.samples.length,k=t.samples.length>0,T=w>1;if((!(t.pid>-1)||k)&&(!y||T)||this.ISGenerated||a){this.ISGenerated||(l=this.generateIS(t,i,e));var O=this.isVideoContiguous,S=-1;if(T&&(S=function(t){for(var i=0;i<t.length;i++)if(t[i].key)return i;return-1}(i.samples),!O&&this.config.forceKeyFrameOnDiscontinuity))if(m=!0,S>0){h.logger.warn("[mp4-remuxer]: Dropped "+S+" out of "+w+" video samples due to a missing keyframe");var E=this.getVideoStartPts(i.samples);i.samples=i.samples.slice(S),i.dropped+=S,b+=(i.samples[0].pts-E)/(i.timescale||9e4)}else-1===S&&(h.logger.warn("[mp4-remuxer]: No keyframe found out of "+w+" video samples"),m=!1);if(this.ISGenerated){if(k&&T){var A=this.getVideoStartPts(i.samples),M=(p(t.samples[0].pts,A)-A)/i.inputTimeScale;g+=Math.max(0,M),b+=Math.max(0,-M)}if(k){if(t.samplerate||(h.logger.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),l=this.generateIS(t,i,e)),f=this.remuxAudio(t,g,this.isAudioContiguous,s,y||T||o===u.PlaylistLevelType.AUDIO?b:void 0),T){var x=f?f.endPTS-f.startPTS:0;i.inputTimeScale||(h.logger.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),l=this.generateIS(t,i,e)),c=this.remuxVideo(i,b,O,x)}}else T&&(c=this.remuxVideo(i,b,O,0));c&&(c.firstKeyFrame=S,c.independent=-1!==S)}}return this.ISGenerated&&(n.samples.length&&(d=this.remuxID3(n,e)),r.samples.length&&(v=this.remuxText(r,e))),{audio:f,video:c,initSegment:l,independent:m,text:v,id3:d}},i.generateIS=function(t,i,n){var e,a,o,h=t.samples,u=i.samples,c=this.typeSupported,f={},l=!Object(r.isFiniteNumber)(this._initPTS),v="audio/mp4";if(l&&(e=a=1/0),t.config&&h.length&&(t.timescale=t.samplerate,t.isAAC||(c.mpeg?(v="audio/mpeg",t.codec=""):c.mp3&&(t.codec="mp3")),f.audio={id:"audio",container:v,codec:t.codec,initSegment:!t.isAAC&&c.mpeg?new Uint8Array(0):s.default.initSegment([t]),metadata:{channelCount:t.channelCount}},l&&(o=t.inputTimeScale,e=a=h[0].pts-Math.round(o*n))),i.sps&&i.pps&&u.length&&(i.timescale=i.inputTimeScale,f.video={id:"main",container:"video/mp4",codec:i.codec,initSegment:s.default.initSegment([i]),metadata:{width:i.width,height:i.height}},l)){o=i.inputTimeScale;var d=this.getVideoStartPts(u),m=Math.round(o*n);a=Math.min(a,p(u[0].dts,d)-m),e=Math.min(e,d-m)}if(Object.keys(f).length)return this.ISGenerated=!0,l&&(this._initPTS=e,this._initDTS=a),{tracks:f,initPTS:e,timescale:o}},i.remuxVideo=function(t,i,n,r){var e,u,v,m=t.inputTimeScale,b=t.samples,y=[],w=b.length,k=this._initPTS,T=this.nextAvcDts,O=8,S=Number.POSITIVE_INFINITY,E=Number.NEGATIVE_INFINITY,A=0,M=!1;n&&null!==T||(T=i*m-(b[0].pts-p(b[0].dts,b[0].pts)));for(var x=0;x<w;x++){var j=b[x];j.pts=p(j.pts-k,T),j.dts=p(j.dts-k,T),j.dts>j.pts&&(A=Math.max(Math.min(A,j.pts-j.dts),-18e3)),j.dts<b[x>0?x-1:x].dts&&(M=!0)}M&&b.sort((function(t,i){return t.dts-i.dts||t.pts-i.pts})),u=b[0].dts,v=b[b.length-1].dts;var D=Math.round((v-u)/(w-1));if(A<0){if(A<-2*D){h.logger.warn("PTS < DTS detected in video samples, offsetting DTS from PTS by "+Object(c.toMsFromMpegTsClock)(-D,!0)+" ms");for(var L=A,I=0;I<w;I++)b[I].dts=L=Math.max(L,b[I].pts-D),b[I].pts=Math.max(L,b[I].pts)}else{h.logger.warn("PTS < DTS detected in video samples, shifting DTS by "+Object(c.toMsFromMpegTsClock)(A,!0)+" ms to overcome this issue");for(var C=0;C<w;C++)b[C].dts=b[C].dts+A}u=b[0].dts}if(n){var R=u-T,P=R>D;if(P||R<-1){h.logger.warn(P?"AVC: "+Object(c.toMsFromMpegTsClock)(R,!0)+" ms ("+R+"dts) hole between fragments detected, filling it":"AVC: "+Object(c.toMsFromMpegTsClock)(-R,!0)+" ms ("+R+"dts) overlapping between fragments detected");var U=b[0].pts-R;b[0].dts=u=T,b[0].pts=U,h.logger.log("Video: First PTS/DTS adjusted: "+Object(c.toMsFromMpegTsClock)(U,!0)+"/"+Object(c.toMsFromMpegTsClock)(u,!0)+", delta: "+Object(c.toMsFromMpegTsClock)(R,!0)+" ms")}}d&&(u=Math.max(0,u));for(var N=0,F=0,B=0;B<w;B++){for(var _=b[B],X=_.units,G=X.length,W=0,K=0;K<G;K++)W+=X[K].data.length;F+=W,N+=G,_.length=W,_.dts=Math.max(_.dts,u),_.pts=Math.max(_.pts,_.dts,0),S=Math.min(_.pts,S),E=Math.max(_.pts,E)}v=b[w-1].dts;var H,V=F+4*N+8;try{H=new Uint8Array(V)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:V,reason:"fail allocating video mdat "+V})}var q=new DataView(H.buffer);q.setUint32(0,V),H.set(s.default.types.mdat,4);for(var z=0;z<w;z++){for(var Y=b[z],$=Y.units,J=0,Q=0,Z=$.length;Q<Z;Q++){var tt=$[Q],it=tt.data,nt=tt.data.byteLength;q.setUint32(O,nt),H.set(it,O+=4),O+=nt,J+=4+nt}if(z<w-1)e=b[z+1].dts-Y.dts;else{var rt=this.config,et=Y.dts-b[z>0?z-1:z].dts;if(rt.stretchShortVideoTrack&&null!==this.nextAudioPts){var st=Math.floor(rt.maxBufferHole*m),at=(r?S+r*m:this.nextAudioPts)-Y.pts;at>st?((e=at-et)<0&&(e=et),h.logger.log("[mp4-remuxer]: It is approximately "+at/90+" ms to the next segment; using duration "+e/90+" ms for the last video frame.")):e=et}else e=et}var ot=Math.round(Y.pts-Y.dts);y.push(new g(Y.key,e,J,ot))}if(y.length&&l&&l<70){var ht=y[0].flags;ht.dependsOn=2,ht.isNonSync=0}console.assert(void 0!==e,"mp4SampleDuration must be computed"),this.nextAvcDts=T=v+e,this.isVideoContiguous=!0;var ut={data1:s.default.moof(t.sequenceNumber++,u,f({},t,{samples:y})),data2:H,startPTS:S/m,endPTS:(E+e)/m,startDTS:u/m,endDTS:T/m,type:"video",hasAudio:!1,hasVideo:!0,nb:y.length,dropped:t.dropped};return t.samples=[],t.dropped=0,console.assert(H.length,"MDAT length must not be zero"),ut},i.remuxAudio=function(t,i,n,r,u){var c=t.inputTimeScale,l=c/(t.samplerate?t.samplerate:c),v=t.isAAC?1024:1152,d=v*l,m=this._initPTS,b=!t.isAAC&&this.typeSupported.mpeg,y=[],w=t.samples,k=b?0:8,T=this.nextAudioPts||-1,O=i*c;if(this.isAudioContiguous=n=n||w.length&&T>0&&(r&&Math.abs(O-T)<9e3||Math.abs(p(w[0].pts-m,O)-T)<20*d),w.forEach((function(t){t.pts=p(t.pts-m,O)})),!n||T<0){if(w=w.filter((function(t){return t.pts>=0})),!w.length)return;T=0===u?0:r?Math.max(0,O):w[0].pts}if(t.isAAC)for(var S=void 0!==u,E=this.config.maxAudioFramesDrift,A=0,M=T;A<w.length;A++){var x=w[A],j=x.pts,D=j-M,L=Math.abs(1e3*D/c);if(D<=-E*d&&S)0===A&&(h.logger.warn("Audio frame @ "+(j/c).toFixed(3)+"s overlaps nextAudioPts by "+Math.round(1e3*D/c)+" ms."),this.nextAudioPts=T=M=j);else if(D>=E*d&&L<1e4&&S){var I=Math.round(D/d);(M=j-I*d)<0&&(I--,M+=d),0===A&&(this.nextAudioPts=T=M),h.logger.warn("[mp4-remuxer]: Injecting "+I+" audio frame @ "+(M/c).toFixed(3)+"s due to "+Math.round(1e3*D/c)+" ms gap.");for(var C=0;C<I;C++){var R=Math.max(M,0),P=e.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);P||(h.logger.log("[mp4-remuxer]: Unable to get silent frame for given audio codec; duplicating last frame instead."),P=x.unit.subarray()),w.splice(A,0,{unit:P,pts:R}),M+=d,A++}}x.pts=M,M+=d}for(var U,N=null,F=null,B=0,_=w.length;_--;)B+=w[_].unit.byteLength;for(var X=0,G=w.length;X<G;X++){var W=w[X],K=W.unit,H=W.pts;if(null!==F)y[X-1].duration=Math.round((H-F)/l);else{if(n&&t.isAAC&&(H=T),N=H,!(B>0))return;B+=k;try{U=new Uint8Array(B)}catch(t){return void this.observer.emit(a.Events.ERROR,a.Events.ERROR,{type:o.ErrorTypes.MUX_ERROR,details:o.ErrorDetails.REMUX_ALLOC_ERROR,fatal:!1,bytes:B,reason:"fail allocating audio mdat "+B})}b||(new DataView(U.buffer).setUint32(0,B),U.set(s.default.types.mdat,4))}U.set(K,k);var V=K.byteLength;k+=V,y.push(new g(!0,v,V,0)),F=H}var q=y.length;if(q){this.nextAudioPts=T=F+l*y[y.length-1].duration;var z=b?new Uint8Array(0):s.default.moof(t.sequenceNumber++,N/l,f({},t,{samples:y}));t.samples=[];var Y=N/c,$=T/c,J={data1:z,data2:U,startPTS:Y,endPTS:$,startDTS:Y,endDTS:$,type:"audio",hasAudio:!0,hasVideo:!1,nb:q};return this.isAudioContiguous=!0,console.assert(U.length,"MDAT length must not be zero"),J}},i.remuxEmptyAudio=function(t,i,n,r){var s=t.inputTimeScale,a=this.nextAudioPts,o=(null!==a?a:r.startDTS*s)+this._initDTS,u=s/(t.samplerate?t.samplerate:s)*1024,c=Math.ceil((r.endDTS*s+this._initDTS-o)/u),f=e.default.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(h.logger.warn("[mp4-remuxer]: remux empty Audio"),f){for(var l=[],v=0;v<c;v++){var d=o+v*u;l.push({unit:f,pts:d,dts:d})}return t.samples=l,this.remuxAudio(t,i,n,!1)}h.logger.trace("[mp4-remuxer]: Unable to remuxEmptyAudio since we were unable to get a silent frame for given audio codec")},i.remuxID3=function(t,i){var n=t.samples.length;if(n){for(var r=t.inputTimeScale,e=this._initPTS,s=this._initDTS,a=0;a<n;a++){var o=t.samples[a];o.pts=p(o.pts-e,i*r)/r,o.dts=p(o.dts-s,i*r)/r}var h=t.samples;return t.samples=[],{samples:h}}},i.remuxText=function(t,i){var n=t.samples.length;if(n){for(var r=t.inputTimeScale,e=this._initPTS,s=0;s<n;s++){var a=t.samples[s];a.pts=p(a.pts-e,i*r)/r}t.samples.sort((function(t,i){return t.pts-i.pts}));var o=t.samples;return t.samples=[],{samples:o}}},t}();function p(t,i){var n;if(null===i)return t;for(n=i<t?-8589934592:8589934592;Math.abs(t-i)>4294967296;)t+=n;return t}var g=function(t,i,n,r){this.size=void 0,this.duration=void 0,this.cts=void 0,this.flags=void 0,this.duration=i,this.size=n,this.cts=r,this.flags=new b(t)},b=function(t){this.isLeading=0,this.isDependedOn=0,this.hasRedundancy=0,this.degradPrio=0,this.dependsOn=1,this.isNonSync=1,this.dependsOn=t?2:1,this.isNonSync=t?0:1}},"./src/remux/passthrough-remuxer.ts":
246
+ /*!******************************************!*\
247
+ !*** ./src/remux/passthrough-remuxer.ts ***!
248
+ \******************************************/
249
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../utils/mp4-tools */"./src/utils/mp4-tools.ts"),s=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),a=n(/*! ../utils/logger */"./src/utils/logger.ts"),o=function(){function t(){this.emitInitSegment=!1,this.audioCodec=void 0,this.videoCodec=void 0,this.initData=void 0,this.initPTS=void 0,this.initTracks=void 0,this.lastEndDTS=null}var i=t.prototype;return i.destroy=function(){},i.resetTimeStamp=function(t){this.initPTS=t,this.lastEndDTS=null},i.resetNextTimestamp=function(){this.lastEndDTS=null},i.resetInitSegment=function(t,i,n){this.audioCodec=i,this.videoCodec=n,this.generateInitSegment(t),this.emitInitSegment=!0},i.generateInitSegment=function(t){var i=this.audioCodec,n=this.videoCodec;if(!t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var r=this.initData=Object(e.parseInitSegment)(t);i||(i=u(r.audio,s.ElementaryStreamTypes.AUDIO)),n||(n=u(r.video,s.ElementaryStreamTypes.VIDEO));var o={};r.audio&&r.video?o.audiovideo={container:"video/mp4",codec:i+","+n,initSegment:t,id:"main"}:r.audio?o.audio={container:"audio/mp4",codec:i,initSegment:t,id:"audio"}:r.video?o.video={container:"video/mp4",codec:n,initSegment:t,id:"main"}:a.logger.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=o},i.remux=function(t,i,n,s,o){var u=this.initPTS,c=this.lastEndDTS,f={audio:void 0,video:void 0,text:s,id3:n,initSegment:void 0};Object(r.isFiniteNumber)(c)||(c=this.lastEndDTS=o||0);var l=i.samples;if(!l||!l.length)return f;var v={initPTS:void 0,timescale:1},d=this.initData;if(d&&d.length||(this.generateInitSegment(l),d=this.initData),!d||!d.length)return a.logger.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),f;this.emitInitSegment&&(v.tracks=this.initTracks,this.emitInitSegment=!1),Object(r.isFiniteNumber)(u)||(this.initPTS=v.initPTS=u=h(d,l,c));var m=Object(e.getDuration)(l,d),p=c,g=m+p;Object(e.offsetStartDTS)(d,l,u),m>0?this.lastEndDTS=g:(a.logger.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var b=!!d.audio,y=!!d.video,w="";b&&(w+="audio"),y&&(w+="video");var k={data1:l,startPTS:p,startDTS:p,endPTS:g,endDTS:g,type:w,hasAudio:b,hasVideo:y,nb:1,dropped:0};return f.audio="audio"===k.type?k:void 0,f.video="audio"!==k.type?k:void 0,f.text=s,f.id3=n,f.initSegment=v,f},t}(),h=function(t,i,n){return Object(e.getStartDTS)(t,i)-n};function u(t,i){var n=null==t?void 0:t.codec;return n&&n.length>4?n:"hvc1"===n?"hvc1.1.c.L120.90":"av01"===n?"av01.0.04M.08":"avc1"===n||i===s.ElementaryStreamTypes.VIDEO?"avc1.42e01e":"mp4a.40.5"}i.default=o},"./src/task-loop.ts":
250
+ /*!**************************!*\
251
+ !*** ./src/task-loop.ts ***!
252
+ \**************************/
253
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var i=t.prototype;return i.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},i.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},i.onHandlerDestroyed=function(){},i.hasInterval=function(){return!!this._tickInterval},i.hasNextTick=function(){return!!this._tickTimer},i.setInterval=function(t){return!this._tickInterval&&(this._tickInterval=self.setInterval(this._boundTick,t),!0)},i.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},i.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},i.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},i.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},i.doTick=function(){},t}()},"./src/types/cmcd.ts":
254
+ /*!***************************!*\
255
+ !*** ./src/types/cmcd.ts ***!
256
+ \***************************/
257
+ /*! exports provided: CMCDVersion, CMCDObjectType, CMCDStreamingFormat, CMCDStreamType */function(t,i,n){n.r(i),n.d(i,"CMCDVersion",(function(){return a})),n.d(i,"CMCDObjectType",(function(){return r})),n.d(i,"CMCDStreamingFormat",(function(){return e})),n.d(i,"CMCDStreamType",(function(){return s}));var r,e,s,a=1;!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}(r||(r={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(e||(e={})),function(t){t.VOD="v",t.LIVE="l"}(s||(s={}))},"./src/types/level.ts":
258
+ /*!****************************!*\
259
+ !*** ./src/types/level.ts ***!
260
+ \****************************/
261
+ /*! exports provided: HlsSkip, getSkipValue, HlsUrlParameters, Level */function(t,i,n){function r(t,i){for(var n=0;n<i.length;n++){var r=i[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var e;function s(t,i){var n=t.canSkipUntil;return n&&(void 0!==i?i-t.endSN:0)<n?t.canSkipDateRanges?e.v2:e.Yes:e.No}n.r(i),n.d(i,"HlsSkip",(function(){return e})),n.d(i,"getSkipValue",(function(){return s})),n.d(i,"HlsUrlParameters",(function(){return a})),n.d(i,"Level",(function(){return o})),function(t){t.No="",t.Yes="YES",t.v2="v2"}(e||(e={}));var a=function(){function t(t,i,n){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=i,this.skip=n}return t.prototype.addDirectives=function(t){var i=new self.URL(t);return void 0!==this.msn&&i.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&i.searchParams.set("_HLS_part",this.part.toString()),this.skip&&i.searchParams.set("_HLS_skip",this.skip),i.toString()},t}(),o=function(){function t(t){this.attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.unknownCodecs=void 0,this.audioGroupIds=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.textGroupIds=void 0,this.url=void 0,this._urlId=0,this.url=[t.url],this.attrs=t.attrs,this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.unknownCodecs=t.unknownCodecs,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return t})).join(",").replace(/\.[^.,]+/g,"")}var i,n;return i=t,(n=[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"uri",get:function(){return this.url[this._urlId]||""}},{key:"urlId",get:function(){return this._urlId},set:function(t){var i=t%this.url.length;this._urlId!==i&&(this.details=void 0,this._urlId=i)}}])&&r(i.prototype,n),t}()},"./src/types/loader.ts":
262
+ /*!*****************************!*\
263
+ !*** ./src/types/loader.ts ***!
264
+ \*****************************/
265
+ /*! exports provided: PlaylistContextType, PlaylistLevelType */function(t,i,n){var r,e;n.r(i),n.d(i,"PlaylistContextType",(function(){return r})),n.d(i,"PlaylistLevelType",(function(){return e})),function(t){t.MANIFEST="manifest",t.LEVEL="level",t.AUDIO_TRACK="audioTrack",t.SUBTITLE_TRACK="subtitleTrack"}(r||(r={})),function(t){t.MAIN="main",t.AUDIO="audio",t.SUBTITLE="subtitle"}(e||(e={}))},"./src/types/transmuxer.ts":
266
+ /*!*********************************!*\
267
+ !*** ./src/types/transmuxer.ts ***!
268
+ \*********************************/
269
+ /*! exports provided: ChunkMetadata */function(t,i,n){n.r(i),n.d(i,"ChunkMetadata",(function(){return r}));var r=function(t,i,n,r,e,s){void 0===r&&(r=0),void 0===e&&(e=-1),void 0===s&&(s=!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={start:0,executeStart:0,executeEnd:0,end:0},this.buffering={audio:{start:0,executeStart:0,executeEnd:0,end:0},video:{start:0,executeStart:0,executeEnd:0,end:0},audiovideo:{start:0,executeStart:0,executeEnd:0,end:0}},this.level=t,this.sn=i,this.id=n,this.size=r,this.part=e,this.partial=s}},"./src/utils/attr-list.ts":
270
+ /*!********************************!*\
271
+ !*** ./src/utils/attr-list.ts ***!
272
+ \********************************/
273
+ /*! exports provided: AttrList */function(t,i,n){n.r(i),n.d(i,"AttrList",(function(){return s}));var r=/^(\d+)x(\d+)$/,e=/\s*(.+?)\s*=((?:\".*?\")|.*?)(?:,|$)/g,s=function(){function t(i){for(var n in"string"==typeof i&&(i=t.parseAttrList(i)),i)i.hasOwnProperty(n)&&(this[n]=i[n])}var i=t.prototype;return i.decimalInteger=function(t){var i=parseInt(this[t],10);return i>Number.MAX_SAFE_INTEGER?1/0:i},i.hexadecimalInteger=function(t){if(this[t]){var i=(this[t]||"0x").slice(2);i=(1&i.length?"0":"")+i;for(var n=new Uint8Array(i.length/2),r=0;r<i.length/2;r++)n[r]=parseInt(i.slice(2*r,2*r+2),16);return n}return null},i.hexadecimalIntegerAsNumber=function(t){var i=parseInt(this[t],16);return i>Number.MAX_SAFE_INTEGER?1/0:i},i.decimalFloatingPoint=function(t){return parseFloat(this[t])},i.optionalFloat=function(t,i){var n=this[t];return n?parseFloat(n):i},i.enumeratedString=function(t){return this[t]},i.bool=function(t){return"YES"===this[t]},i.decimalResolution=function(t){var i=r.exec(this[t]);if(null!==i)return{width:parseInt(i[1],10),height:parseInt(i[2],10)}},t.parseAttrList=function(t){var i,n={};for(e.lastIndex=0;null!==(i=e.exec(t));){var r=i[2];0===r.indexOf('"')&&r.lastIndexOf('"')===r.length-1&&(r=r.slice(1,-1)),n[i[1]]=r}return n},t}()},"./src/utils/binary-search.ts":
274
+ /*!************************************!*\
275
+ !*** ./src/utils/binary-search.ts ***!
276
+ \************************************/
277
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default={search:function(t,i){for(var n=0,r=t.length-1,e=null,s=null;n<=r;){var a=i(s=t[e=(n+r)/2|0]);if(a>0)n=e+1;else{if(!(a<0))return s;r=e-1}}return null}}},"./src/utils/buffer-helper.ts":
278
+ /*!************************************!*\
279
+ !*** ./src/utils/buffer-helper.ts ***!
280
+ \************************************/
281
+ /*! exports provided: BufferHelper */function(t,i,n){n.r(i),n.d(i,"BufferHelper",(function(){return s}));var r=n(/*! ./logger */"./src/utils/logger.ts"),e={length:0,start:function(){return 0},end:function(){return 0}},s=function(){function t(){}return t.isBuffered=function(i,n){try{if(i)for(var r=t.getBuffered(i),e=0;e<r.length;e++)if(n>=r.start(e)&&n<=r.end(e))return!0}catch(t){}return!1},t.bufferInfo=function(i,n,r){try{if(i){var e,s=t.getBuffered(i),a=[];for(e=0;e<s.length;e++)a.push({start:s.start(e),end:s.end(e)});return this.bufferedInfo(a,n,r)}}catch(t){}return{len:0,start:n,end:n,nextStart:void 0}},t.bufferedInfo=function(t,i,n){i=Math.max(0,i),t.sort((function(t,i){return t.start-i.start||i.end-t.end}));var r=[];if(n)for(var e=0;e<t.length;e++){var s=r.length;if(s){var a=r[s-1].end;t[e].start-a<n?t[e].end>a&&(r[s-1].end=t[e].end):r.push(t[e])}else r.push(t[e])}else r=t;for(var o,h=0,u=i,c=i,f=0;f<r.length;f++){var l=r[f].start,v=r[f].end;if(i+n>=l&&i<v)u=l,h=(c=v)-i;else if(i+n<l){o=l;break}}return{len:h,start:u||0,end:c||0,nextStart:o}},t.getBuffered=function(t){try{return t.buffered}catch(t){return r.logger.log("failed to get media.buffered",t),e}},t}()},"./src/utils/cea-608-parser.ts":
282
+ /*!*************************************!*\
283
+ !*** ./src/utils/cea-608-parser.ts ***!
284
+ \*************************************/
285
+ /*! exports provided: Row, CaptionScreen, default */function(t,i,n){n.r(i),n.d(i,"Row",(function(){return b})),n.d(i,"CaptionScreen",(function(){return y}));var r,e=n(/*! ../utils/logger */"./src/utils/logger.ts"),s={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},a=function(t){var i=t;return s.hasOwnProperty(t)&&(i=s[t]),String.fromCharCode(i)},o=15,h=100,u={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},c={17:2,18:4,21:6,22:8,23:10,19:13,20:15},f={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},l={25:2,26:4,29:6,30:8,31:10,27:13,28:15},v=["white","green","blue","cyan","red","yellow","magenta","black","transparent"];!function(t){t[t.ERROR=0]="ERROR",t[t.TEXT=1]="TEXT",t[t.WARNING=2]="WARNING",t[t.INFO=2]="INFO",t[t.DEBUG=3]="DEBUG",t[t.DATA=3]="DATA"}(r||(r={}));var d=function(){function t(){this.time=null,this.verboseLevel=r.ERROR}return t.prototype.log=function(t,i){this.verboseLevel>=t&&e.logger.log(this.time+" ["+t+"] "+i)},t}(),m=function(t){for(var i=[],n=0;n<t.length;n++)i.push(t[n].toString(16));return i},p=function(){function t(t,i,n,r,e){this.foreground=void 0,this.underline=void 0,this.italics=void 0,this.background=void 0,this.flash=void 0,this.foreground=t||"white",this.underline=i||!1,this.italics=n||!1,this.background=r||"black",this.flash=e||!1}var i=t.prototype;return i.reset=function(){this.foreground="white",this.underline=!1,this.italics=!1,this.background="black",this.flash=!1},i.setStyles=function(t){for(var i=["foreground","underline","italics","background","flash"],n=0;n<i.length;n++){var r=i[n];t.hasOwnProperty(r)&&(this[r]=t[r])}},i.isDefault=function(){return"white"===this.foreground&&!this.underline&&!this.italics&&"black"===this.background&&!this.flash},i.equals=function(t){return this.foreground===t.foreground&&this.underline===t.underline&&this.italics===t.italics&&this.background===t.background&&this.flash===t.flash},i.copy=function(t){this.foreground=t.foreground,this.underline=t.underline,this.italics=t.italics,this.background=t.background,this.flash=t.flash},i.toString=function(){return"color="+this.foreground+", underline="+this.underline+", italics="+this.italics+", background="+this.background+", flash="+this.flash},t}(),g=function(){function t(t,i,n,r,e,s){this.uchar=void 0,this.penState=void 0,this.uchar=t||" ",this.penState=new p(i,n,r,e,s)}var i=t.prototype;return i.reset=function(){this.uchar=" ",this.penState.reset()},i.setChar=function(t,i){this.uchar=t,this.penState.copy(i)},i.setPenState=function(t){this.penState.copy(t)},i.equals=function(t){return this.uchar===t.uchar&&this.penState.equals(t.penState)},i.copy=function(t){this.uchar=t.uchar,this.penState.copy(t.penState)},i.isEmpty=function(){return" "===this.uchar&&this.penState.isDefault()},t}(),b=function(){function t(t){this.chars=void 0,this.pos=void 0,this.currPenState=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chars=[];for(var i=0;i<h;i++)this.chars.push(new g);this.logger=t,this.pos=0,this.currPenState=new p}var i=t.prototype;return i.equals=function(t){for(var i=!0,n=0;n<h;n++)if(!this.chars[n].equals(t.chars[n])){i=!1;break}return i},i.copy=function(t){for(var i=0;i<h;i++)this.chars[i].copy(t.chars[i])},i.isEmpty=function(){for(var t=!0,i=0;i<h;i++)if(!this.chars[i].isEmpty()){t=!1;break}return t},i.setCursor=function(t){this.pos!==t&&(this.pos=t),this.pos<0?(this.logger.log(r.DEBUG,"Negative cursor position "+this.pos),this.pos=0):this.pos>h&&(this.logger.log(r.DEBUG,"Too large cursor position "+this.pos),this.pos=h)},i.moveCursor=function(t){var i=this.pos+t;if(t>1)for(var n=this.pos+1;n<i+1;n++)this.chars[n].setPenState(this.currPenState);this.setCursor(i)},i.backSpace=function(){this.moveCursor(-1),this.chars[this.pos].setChar(" ",this.currPenState)},i.insertChar=function(t){t>=144&&this.backSpace();var i=a(t);this.pos>=h?this.logger.log(r.ERROR,"Cannot insert "+t.toString(16)+" ("+i+") at position "+this.pos+". Skipping it!"):(this.chars[this.pos].setChar(i,this.currPenState),this.moveCursor(1))},i.clearFromPos=function(t){var i;for(i=t;i<h;i++)this.chars[i].reset()},i.clear=function(){this.clearFromPos(0),this.pos=0,this.currPenState.reset()},i.clearToEndOfRow=function(){this.clearFromPos(this.pos)},i.getTextString=function(){for(var t=[],i=!0,n=0;n<h;n++){var r=this.chars[n].uchar;" "!==r&&(i=!1),t.push(r)}return i?"":t.join("")},i.setPenStyles=function(t){this.currPenState.setStyles(t),this.chars[this.pos].setPenState(this.currPenState)},t}(),y=function(){function t(t){this.rows=void 0,this.currRow=void 0,this.nrRollUpRows=void 0,this.lastOutputScreen=void 0,this.logger=void 0,this.rows=[];for(var i=0;i<o;i++)this.rows.push(new b(t));this.logger=t,this.currRow=14,this.nrRollUpRows=null,this.lastOutputScreen=null,this.reset()}var i=t.prototype;return i.reset=function(){for(var t=0;t<o;t++)this.rows[t].clear();this.currRow=14},i.equals=function(t){for(var i=!0,n=0;n<o;n++)if(!this.rows[n].equals(t.rows[n])){i=!1;break}return i},i.copy=function(t){for(var i=0;i<o;i++)this.rows[i].copy(t.rows[i])},i.isEmpty=function(){for(var t=!0,i=0;i<o;i++)if(!this.rows[i].isEmpty()){t=!1;break}return t},i.backSpace=function(){this.rows[this.currRow].backSpace()},i.clearToEndOfRow=function(){this.rows[this.currRow].clearToEndOfRow()},i.insertChar=function(t){this.rows[this.currRow].insertChar(t)},i.setPen=function(t){this.rows[this.currRow].setPenStyles(t)},i.moveCursor=function(t){this.rows[this.currRow].moveCursor(t)},i.setCursor=function(t){this.logger.log(r.INFO,"setCursor: "+t),this.rows[this.currRow].setCursor(t)},i.setPAC=function(t){this.logger.log(r.INFO,"pacData = "+JSON.stringify(t));var i=t.row-1;if(this.nrRollUpRows&&i<this.nrRollUpRows-1&&(i=this.nrRollUpRows-1),this.nrRollUpRows&&this.currRow!==i){for(var n=0;n<o;n++)this.rows[n].clear();var e=this.currRow+1-this.nrRollUpRows,s=this.lastOutputScreen;if(s){var a=s.rows[e].cueStartTime,h=this.logger.time;if(a&&null!==h&&a<h)for(var u=0;u<this.nrRollUpRows;u++)this.rows[i-this.nrRollUpRows+u+1].copy(s.rows[e+u])}}this.currRow=i;var c=this.rows[this.currRow];if(null!==t.indent){var f=Math.max(t.indent-1,0);c.setCursor(t.indent),t.color=c.chars[f].penState.foreground}this.setPen({foreground:t.color,underline:t.underline,italics:t.italics,background:"black",flash:!1})},i.setBkgData=function(t){this.logger.log(r.INFO,"bkgData = "+JSON.stringify(t)),this.backSpace(),this.setPen(t),this.insertChar(32)},i.setRollUpRows=function(t){this.nrRollUpRows=t},i.rollUp=function(){if(null!==this.nrRollUpRows){this.logger.log(r.TEXT,this.getDisplayText());var t=this.rows.splice(this.currRow+1-this.nrRollUpRows,1)[0];t.clear(),this.rows.splice(this.currRow,0,t),this.logger.log(r.INFO,"Rolling up")}else this.logger.log(r.DEBUG,"roll_up but nrRollUpRows not set yet")},i.getDisplayText=function(t){t=t||!1;for(var i=[],n="",r=0;r<o;r++){var e=this.rows[r].getTextString();e&&i.push(t?"Row "+(r+1)+": '"+e+"'":e.trim())}return i.length>0&&(n=t?"["+i.join(" | ")+"]":i.join("\n")),n},i.getTextAndFormat=function(){return this.rows},t}(),w=function(){function t(t,i,n){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=t,this.outputFilter=i,this.mode=null,this.verbose=0,this.displayedMemory=new y(n),this.nonDisplayedMemory=new y(n),this.lastOutputScreen=new y(n),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=n}var i=t.prototype;return i.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},i.getHandler=function(){return this.outputFilter},i.setHandler=function(t){this.outputFilter=t},i.setPAC=function(t){this.writeScreen.setPAC(t)},i.setBkgData=function(t){this.writeScreen.setBkgData(t)},i.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(r.INFO,"MODE="+t),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},i.insertChars=function(t){for(var i=0;i<t.length;i++)this.writeScreen.insertChar(t[i]);this.logger.log(r.INFO,(this.writeScreen===this.displayedMemory?"DISP":"NON_DISP")+": "+this.writeScreen.getDisplayText(!0)),"MODE_PAINT-ON"!==this.mode&&"MODE_ROLL-UP"!==this.mode||(this.logger.log(r.TEXT,"DISPLAYED: "+this.displayedMemory.getDisplayText(!0)),this.outputDataUpdate())},i.ccRCL=function(){this.logger.log(r.INFO,"RCL - Resume Caption Loading"),this.setMode("MODE_POP-ON")},i.ccBS=function(){this.logger.log(r.INFO,"BS - BackSpace"),"MODE_TEXT"!==this.mode&&(this.writeScreen.backSpace(),this.writeScreen===this.displayedMemory&&this.outputDataUpdate())},i.ccAOF=function(){},i.ccAON=function(){},i.ccDER=function(){this.logger.log(r.INFO,"DER- Delete to End of Row"),this.writeScreen.clearToEndOfRow(),this.outputDataUpdate()},i.ccRU=function(t){this.logger.log(r.INFO,"RU("+t+") - Roll Up"),this.writeScreen=this.displayedMemory,this.setMode("MODE_ROLL-UP"),this.writeScreen.setRollUpRows(t)},i.ccFON=function(){this.logger.log(r.INFO,"FON - Flash On"),this.writeScreen.setPen({flash:!0})},i.ccRDC=function(){this.logger.log(r.INFO,"RDC - Resume Direct Captioning"),this.setMode("MODE_PAINT-ON")},i.ccTR=function(){this.logger.log(r.INFO,"TR"),this.setMode("MODE_TEXT")},i.ccRTD=function(){this.logger.log(r.INFO,"RTD"),this.setMode("MODE_TEXT")},i.ccEDM=function(){this.logger.log(r.INFO,"EDM - Erase Displayed Memory"),this.displayedMemory.reset(),this.outputDataUpdate(!0)},i.ccCR=function(){this.logger.log(r.INFO,"CR - Carriage Return"),this.writeScreen.rollUp(),this.outputDataUpdate(!0)},i.ccENM=function(){this.logger.log(r.INFO,"ENM - Erase Non-displayed Memory"),this.nonDisplayedMemory.reset()},i.ccEOC=function(){if(this.logger.log(r.INFO,"EOC - End Of Caption"),"MODE_POP-ON"===this.mode){var t=this.displayedMemory;this.displayedMemory=this.nonDisplayedMemory,this.nonDisplayedMemory=t,this.writeScreen=this.nonDisplayedMemory,this.logger.log(r.TEXT,"DISP: "+this.displayedMemory.getDisplayText())}this.outputDataUpdate(!0)},i.ccTO=function(t){this.logger.log(r.INFO,"TO("+t+") - Tab Offset"),this.writeScreen.moveCursor(t)},i.ccMIDROW=function(t){var i={flash:!1};if(i.underline=t%2==1,i.italics=t>=46,i.italics)i.foreground="white";else{var n=Math.floor(t/2)-16;i.foreground=["white","green","blue","cyan","red","yellow","magenta"][n]}this.logger.log(r.INFO,"MIDROW: "+JSON.stringify(i)),this.writeScreen.setPen(i)},i.outputDataUpdate=function(t){void 0===t&&(t=!1);var i=this.logger.time;null!==i&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,i,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:i):this.cueStartTime=i,this.lastOutputScreen.copy(this.displayedMemory))},i.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}();function k(t,i,n){n.a=t,n.b=i}function T(t,i,n){return n.a===t&&n.b===i}i.default=function(){function t(t,i,n){this.channels=void 0,this.currentChannel=0,this.cmdHistory=void 0,this.logger=void 0;var r=new d;this.channels=[null,new w(t,i,r),new w(t+1,n,r)],this.cmdHistory={a:null,b:null},this.logger=r}var i=t.prototype;return i.getHandler=function(t){return this.channels[t].getHandler()},i.setHandler=function(t,i){this.channels[t].setHandler(i)},i.addData=function(t,i){var n,e,s,a=!1;this.logger.time=t;for(var o=0;o<i.length;o+=2)if(s=127&i[o+1],0!=(e=127&i[o])||0!==s){if(this.logger.log(r.DATA,"["+m([i[o],i[o+1]])+"] -> ("+m([e,s])+")"),(n=this.parseCmd(e,s))||(n=this.parseMidrow(e,s)),n||(n=this.parsePAC(e,s)),n||(n=this.parseBackgroundAttributes(e,s)),!n&&(a=this.parseChars(e,s))){var h=this.currentChannel;h&&h>0?this.channels[h].insertChars(a):this.logger.log(r.WARNING,"No channel found yet. TEXT-MODE?")}n||a||this.logger.log(r.WARNING,"Couldn't parse cleaned data "+m([e,s])+" orig: "+m([i[o],i[o+1]]))}},i.parseCmd=function(t,i){var n=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&i>=32&&i<=47||(23===t||31===t)&&i>=33&&i<=35))return!1;if(T(t,i,n))return k(null,null,n),this.logger.log(r.DEBUG,"Repeated command ("+m([t,i])+") is dropped"),!0;var e=20===t||21===t||23===t?1:2,s=this.channels[e];return 20===t||21===t||28===t||29===t?32===i?s.ccRCL():33===i?s.ccBS():34===i?s.ccAOF():35===i?s.ccAON():36===i?s.ccDER():37===i?s.ccRU(2):38===i?s.ccRU(3):39===i?s.ccRU(4):40===i?s.ccFON():41===i?s.ccRDC():42===i?s.ccTR():43===i?s.ccRTD():44===i?s.ccEDM():45===i?s.ccCR():46===i?s.ccENM():47===i&&s.ccEOC():s.ccTO(i-32),k(t,i,n),this.currentChannel=e,!0},i.parseMidrow=function(t,i){var n=0;if((17===t||25===t)&&i>=32&&i<=47){if((n=17===t?1:2)!==this.currentChannel)return this.logger.log(r.ERROR,"Mismatch channel in midrow parsing"),!1;var e=this.channels[n];return!!e&&(e.ccMIDROW(i),this.logger.log(r.DEBUG,"MIDROW ("+m([t,i])+")"),!0)}return!1},i.parsePAC=function(t,i){var n=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&i>=64&&i<=127||(16===t||24===t)&&i>=64&&i<=95))return!1;if(T(t,i,n))return k(null,null,n),!0;var r=t<=23?1:2,e=this.channels[r];return!!e&&(e.setPAC(this.interpretPAC(i>=64&&i<=95?1===r?u[t]:f[t]:1===r?c[t]:l[t],i)),k(t,i,n),this.currentChannel=r,!0)},i.interpretPAC=function(t,i){var n,r={color:null,italics:!1,indent:null,underline:!1,row:t};return r.underline=1==(1&(n=i>95?i-96:i-64)),n<=13?r.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(n/2)]:n<=15?(r.italics=!0,r.color="white"):r.indent=4*Math.floor((n-16)/2),r},i.parseChars=function(t,i){var n,e,s=null,o=null;if(t>=25?(n=2,o=t-8):(n=1,o=t),o>=17&&o<=19?(this.logger.log(r.INFO,"Special char '"+a(e=17===o?i+80:18===o?i+112:i+144)+"' in channel "+n),s=[e]):t>=32&&t<=127&&(s=0===i?[t]:[t,i]),s){var h=m(s);this.logger.log(r.DEBUG,"Char codes = "+h.join(",")),k(t,i,this.cmdHistory)}return s},i.parseBackgroundAttributes=function(t,i){var n;if(!((16===t||24===t)&&i>=32&&i<=47||(23===t||31===t)&&i>=45&&i<=47))return!1;var r={};return 16===t||24===t?(n=Math.floor((i-32)/2),r.background=v[n],i%2==1&&(r.background=r.background+"_semi")):45===i?r.background="transparent":(r.foreground="black",47===i&&(r.underline=!0)),this.channels[t<=23?1:2].setBkgData(r),k(t,i,this.cmdHistory),!0},i.reset=function(){for(var t=0;t<Object.keys(this.channels).length;t++){var i=this.channels[t];i&&i.reset()}this.cmdHistory={a:null,b:null}},i.cueSplitAtTime=function(t){for(var i=0;i<this.channels.length;i++){var n=this.channels[i];n&&n.cueSplitAtTime(t)}},t}()},"./src/utils/codecs.ts":
286
+ /*!*****************************!*\
287
+ !*** ./src/utils/codecs.ts ***!
288
+ \*****************************/
289
+ /*! exports provided: isCodecType, isCodecSupportedInMp4 */function(t,i,n){n.r(i),n.d(i,"isCodecType",(function(){return e})),n.d(i,"isCodecSupportedInMp4",(function(){return s}));var r={audio:{a3ds:!0,"ac-3":!0,"ac-4":!0,alac:!0,alaw:!0,dra1:!0,"dts+":!0,"dts-":!0,dtsc:!0,dtse:!0,dtsh:!0,"ec-3":!0,enca:!0,g719:!0,g726:!0,m4ae:!0,mha1:!0,mha2:!0,mhm1:!0,mhm2:!0,mlpa:!0,mp4a:!0,"raw ":!0,Opus:!0,samr:!0,sawb:!0,sawp:!0,sevc:!0,sqcp:!0,ssmv:!0,twos:!0,ulaw:!0},video:{avc1:!0,avc2:!0,avc3:!0,avc4:!0,avcp:!0,av01:!0,drac:!0,dvav:!0,dvhe:!0,encv:!0,hev1:!0,hvc1:!0,mjp2:!0,mp4v:!0,mvc1:!0,mvc2:!0,mvc3:!0,mvc4:!0,resv:!0,rv60:!0,s263:!0,svc1:!0,svc2:!0,"vc-1":!0,vp08:!0,vp09:!0},text:{stpp:!0,wvtt:!0}};function e(t,i){var n=r[i];return!!n&&!0===n[t.slice(0,4)]}function s(t,i){return MediaSource.isTypeSupported((i||"video")+'/mp4;codecs="'+t+'"')}},"./src/utils/cues.ts":
290
+ /*!***************************!*\
291
+ !*** ./src/utils/cues.ts ***!
292
+ \***************************/
293
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ./vttparser */"./src/utils/vttparser.ts"),e=n(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts"),s=n(/*! ./texttrack-utils */"./src/utils/texttrack-utils.ts"),a=/\s/;i.default={newCue:function(t,i,n,o){for(var h,u,c,f,l,v=[],d=self.VTTCue||self.TextTrackCue,m=0;m<o.rows.length;m++)if(c=!0,f=0,l="",!(h=o.rows[m]).isEmpty()){for(var p=0;p<h.chars.length;p++)a.test(h.chars[p].uchar)&&c?f++:(l+=h.chars[p].uchar,c=!1);h.cueStartTime=i,i===n&&(n+=1e-4),f>=16?f--:f++;var g=Object(r.fixLineBreaks)(l.trim()),b=Object(e.generateCueId)(i,n,g);t&&t.cues&&t.cues.getCueById(b)||((u=new d(i,n,g)).id=b,u.line=m+1,u.align="left",u.position=10+Math.min(80,10*Math.floor(8*f/32)),v.push(u))}return t&&v.length&&(v.sort((function(t,i){return"auto"===t.line||"auto"===i.line?0:t.line>8&&i.line>8?i.line-t.line:t.line-i.line})),v.forEach((function(i){return Object(s.addCueToTrack)(t,i)}))),v}}},"./src/utils/discontinuities.ts":
294
+ /*!**************************************!*\
295
+ !*** ./src/utils/discontinuities.ts ***!
296
+ \**************************************/
297
+ /*! exports provided: findFirstFragWithCC, shouldAlignOnDiscontinuities, findDiscontinuousReferenceFrag, adjustSlidingStart, alignStream, alignPDT, alignFragmentByPDTDelta, alignMediaPlaylistByPDT */function(t,i,n){n.r(i),n.d(i,"findFirstFragWithCC",(function(){return a})),n.d(i,"shouldAlignOnDiscontinuities",(function(){return o})),n.d(i,"findDiscontinuousReferenceFrag",(function(){return h})),n.d(i,"adjustSlidingStart",(function(){return c})),n.d(i,"alignStream",(function(){return f})),n.d(i,"alignPDT",(function(){return l})),n.d(i,"alignFragmentByPDTDelta",(function(){return v})),n.d(i,"alignMediaPlaylistByPDT",(function(){return d}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./logger */"./src/utils/logger.ts"),s=n(/*! ../controller/level-helper */"./src/controller/level-helper.ts");function a(t,i){for(var n=null,r=0,e=t.length;r<e;r++){var s=t[r];if(s&&s.cc===i){n=s;break}}return n}function o(t,i,n){return!(!i.details||!(n.endCC>n.startCC||t&&t.cc<n.startCC))}function h(t,i){var n=t.fragments,r=i.fragments;if(r.length&&n.length){var s=a(n,r[0].cc);if(s&&(!s||s.startPTS))return s;e.logger.log("No frag in previous level to align on")}else e.logger.log("No fragments to align")}function u(t,i){if(t){var n=t.start+i;t.start=t.startPTS=n,t.endPTS=n+t.duration}}function c(t,i){for(var n=i.fragments,r=0,e=n.length;r<e;r++)u(n[r],t);i.fragmentHint&&u(i.fragmentHint,t),i.alignedSliding=!0}function f(t,i,n){i&&(function(t,i,n){if(o(t,n,i)){var s=h(n.details,i);s&&Object(r.isFiniteNumber)(s.start)&&(e.logger.log("Adjusting PTS using last level due to CC increase within current level "+i.url),c(s.start,i))}}(t,n,i),!n.alignedSliding&&i.details&&l(n,i.details),n.alignedSliding||!i.details||n.skippedSegments||Object(s.adjustSliding)(i.details,n))}function l(t,i){if(i.fragments.length&&t.hasProgramDateTime&&i.hasProgramDateTime){var n=i.fragments[0].programDateTime,s=t.fragments[0].programDateTime,a=(s-n)/1e3+i.fragments[0].start;a&&Object(r.isFiniteNumber)(a)&&(e.logger.log("Adjusting PTS using programDateTime delta "+(s-n)+"ms, sliding:"+a.toFixed(3)+" "+t.url+" "),c(a,t))}}function v(t,i){var n=t.programDateTime;if(n){var r=(n-i)/1e3;t.start=t.startPTS=r,t.endPTS=r+t.duration}}function d(t,i){if(i.fragments.length&&t.hasProgramDateTime&&i.hasProgramDateTime){var n=i.fragments[0].programDateTime-1e3*i.fragments[0].start;t.fragments.forEach((function(t){v(t,n)})),t.fragmentHint&&v(t.fragmentHint,n),t.alignedSliding=!0}}},"./src/utils/ewma-bandwidth-estimator.ts":
298
+ /*!***********************************************!*\
299
+ !*** ./src/utils/ewma-bandwidth-estimator.ts ***!
300
+ \***********************************************/
301
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/ewma */"./src/utils/ewma.ts");i.default=function(){function t(t,i,n){this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultEstimate_=n,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new r.default(t),this.fast_=new r.default(i)}var i=t.prototype;return i.update=function(t,i){var n=this.slow_,e=this.fast_;this.slow_.halfLife!==t&&(this.slow_=new r.default(t,n.getEstimate(),n.getTotalWeight())),this.fast_.halfLife!==i&&(this.fast_=new r.default(i,e.getEstimate(),e.getTotalWeight()))},i.sample=function(t,i){var n=(t=Math.max(t,this.minDelayMs_))/1e3,r=8*i/n;this.fast_.sample(n,r),this.slow_.sample(n,r)},i.canEstimate=function(){var t=this.fast_;return t&&t.getTotalWeight()>=this.minWeight_},i.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},i.destroy=function(){},t}()},"./src/utils/ewma.ts":
302
+ /*!***************************!*\
303
+ !*** ./src/utils/ewma.ts ***!
304
+ \***************************/
305
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default=function(){function t(t,i,n){void 0===i&&(i=0),void 0===n&&(n=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=i,this.totalWeight_=n}var i=t.prototype;return i.sample=function(t,i){var n=Math.pow(this.alpha_,t);this.estimate_=i*(1-n)+n*this.estimate_,this.totalWeight_+=t},i.getTotalWeight=function(){return this.totalWeight_},i.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}()},"./src/utils/fetch-loader.ts":
306
+ /*!***********************************!*\
307
+ !*** ./src/utils/fetch-loader.ts ***!
308
+ \***********************************/
309
+ /*! exports provided: fetchSupported, default */function(t,i,n){n.r(i),n.d(i,"fetchSupported",(function(){return l}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=n(/*! ../demux/chunk-cache */"./src/demux/chunk-cache.ts");function a(t){var i="function"==typeof Map?new Map:void 0;return a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==i){if(i.has(t))return i.get(t);i.set(t,n)}function n(){return o(t,arguments,c(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),u(n,t)},a(t)}function o(t,i,n){return o=h()?Reflect.construct:function(t,i,n){var r=[null];r.push.apply(r,i);var e=new(Function.bind.apply(t,r));return n&&u(e,n.prototype),e},o.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function u(t,i){return u=Object.setPrototypeOf||function(t,i){return t.__proto__=i,t},u(t,i)}function c(t){return c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},c(t)}function f(){return f=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},f.apply(this,arguments)}function l(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}var v=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=void 0,this.response=void 0,this.controller=void 0,this.context=void 0,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||d,this.controller=new self.AbortController,this.stats=new e.LoadStats}var i=t.prototype;return i.destroy=function(){this.loader=this.callbacks=null,this.abortInternal()},i.abortInternal=function(){var t=this.response;t&&t.ok||(this.stats.aborted=!0,this.controller.abort())},i.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},i.load=function(t,i,n){var e=this,s=this.stats;if(s.loading.start)throw new Error("Loader can only be used once.");s.loading.start=self.performance.now();var a=function(t,i){var n={method:"GET",mode:"cors",credentials:"same-origin",signal:i,headers:new self.Headers(f({},t.headers))};return t.rangeEnd&&n.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),n}(t,this.controller.signal),o=n.onProgress,h="arraybuffer"===t.responseType,u=h?"byteLength":"length";this.context=t,this.config=i,this.callbacks=n,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout((function(){e.abortInternal(),n.onTimeout(s,t,e.response)}),i.timeout),self.fetch(this.request).then((function(n){if(e.response=e.loader=n,!n.ok)throw new m(n.statusText||"fetch, bad network response",n.status,n);return s.loading.first=Math.max(self.performance.now(),s.loading.start),s.total=parseInt(n.headers.get("Content-Length")||"0"),o&&Object(r.isFiniteNumber)(i.highWaterMark)?e.loadProgressively(n,s,t,i.highWaterMark,o):h?n.arrayBuffer():n.text()})).then((function(a){var h=e.response;self.clearTimeout(e.requestTimeout),s.loading.end=Math.max(self.performance.now(),s.loading.first),s.loaded=s.total=a[u];var c={url:h.url,data:a};o&&!Object(r.isFiniteNumber)(i.highWaterMark)&&o(s,t,a,h),n.onSuccess(c,s,t,h)})).catch((function(i){self.clearTimeout(e.requestTimeout),s.aborted||n.onError({code:i.code||0,text:i.message},t,i.details)}))},i.getCacheAge=function(){var t=null;if(this.response){var i=this.response.headers.get("age");t=i?parseFloat(i):null}return t},i.loadProgressively=function(t,i,n,r,e){void 0===r&&(r=0);var a=new s.default,o=t.body.getReader();return function s(){return o.read().then((function(o){if(o.done)return a.dataLength&&e(i,n,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var h=o.value,u=h.length;return i.loaded+=u,u<r||a.dataLength?(a.push(h),a.dataLength>=r&&e(i,n,a.flush(),t)):e(i,n,h,t),s()})).catch((function(){return Promise.reject()}))}()},t}();function d(t,i){return new self.Request(t.url,i)}var m=function(t){var i,n;function r(i,n,r){var e;return(e=t.call(this,i)||this).code=void 0,e.details=void 0,e.code=n,e.details=r,e}return n=t,(i=r).prototype=Object.create(n.prototype),i.prototype.constructor=i,u(i,n),r}(a(Error));i.default=v},"./src/utils/imsc1-ttml-parser.ts":
310
+ /*!****************************************!*\
311
+ !*** ./src/utils/imsc1-ttml-parser.ts ***!
312
+ \****************************************/
313
+ /*! exports provided: IMSC1_CODEC, parseIMSC1 */function(t,i,n){n.r(i),n.d(i,"IMSC1_CODEC",(function(){return c})),n.d(i,"parseIMSC1",(function(){return d}));var r=n(/*! ./mp4-tools */"./src/utils/mp4-tools.ts"),e=n(/*! ./vttparser */"./src/utils/vttparser.ts"),s=n(/*! ./vttcue */"./src/utils/vttcue.ts"),a=n(/*! ../demux/id3 */"./src/demux/id3.ts"),o=n(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),h=n(/*! ./webvtt-parser */"./src/utils/webvtt-parser.ts");function u(){return u=Object.assign||function(t){for(var i=1;i<arguments.length;i++){var n=arguments[i];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},u.apply(this,arguments)}var c="stpp.ttml.im1t",f=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,l=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,v={left:"start",center:"center",right:"end",start:"start",end:"end"};function d(t,i,n,e,c){var f=Object(r.findBox)(new Uint8Array(t),["mdat"]);if(0!==f.length){var l=f[0],d=Object(a.utf8ArrayToStr)(new Uint8Array(t,l.start,l.end-l.start)),k=Object(o.toTimescaleFromScale)(i,1,n);try{e(function(t,i){var n=(new DOMParser).parseFromString(t,"text/xml").getElementsByTagName("tt")[0];if(!n)throw new Error("Invalid ttml");var r={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},e=Object.keys(r).reduce((function(t,i){return t[i]=n.getAttribute("ttp:"+i)||r[i],t}),{}),a="preserve"!==n.getAttribute("xml:space"),o=p(m(n,"styling","style")),c=p(m(n,"layout","region")),f=m(n,"body","[begin]");return[].map.call(f,(function(t){var n=g(t,a);if(!n||!t.hasAttribute("begin"))return null;var r=w(t.getAttribute("begin"),e),f=w(t.getAttribute("dur"),e),l=w(t.getAttribute("end"),e);if(null===r)throw y(t);if(null===l){if(null===f)throw y(t);l=r+f}var d=new s.default(r-i,l-i,n);d.id=Object(h.generateCueId)(d.startTime,d.endTime,d.text);var m=c[t.getAttribute("region")],p=o[t.getAttribute("style")];d.position=10,d.size=80;var k=function(t,i){var n="http://www.w3.org/ns/ttml#styling";return["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"].reduce((function(r,e){var s=b(i,n,e)||b(t,n,e);return s&&(r[e]=s),r}),{})}(m,p),T=k.textAlign;if(T){var O=v[T];O&&(d.lineAlign=O),d.align=T}return u(d,k),d})).filter((function(t){return null!==t}))}(d,k))}catch(t){c(t)}}else c(new Error("Could not parse IMSC1 mdat"))}function m(t,i,n){var r=t.getElementsByTagName(i)[0];return r?[].slice.call(r.querySelectorAll(n)):[]}function p(t){return t.reduce((function(t,i){var n=i.getAttribute("xml:id");return n&&(t[n]=i),t}),{})}function g(t,i){return[].slice.call(t.childNodes).reduce((function(t,n,r){var e;return"br"===n.nodeName&&r?t+"\n":null!==(e=n.childNodes)&&void 0!==e&&e.length?g(n,i):i?t+n.textContent.trim().replace(/\s+/g," "):t+n.textContent}),"")}function b(t,i,n){return t.hasAttributeNS(i,n)?t.getAttributeNS(i,n):null}function y(t){return new Error("Could not parse ttml timestamp "+t)}function w(t,i){if(!t)return null;var n=Object(e.parseTimeStamp)(t);return null===n&&(f.test(t)?n=function(t,i){var n=f.exec(t);return 3600*(0|n[1])+60*(0|n[2])+(0|n[3])+((0|n[4])+(0|n[5])/i.subFrameRate)/i.frameRate}(t,i):l.test(t)&&(n=function(t,i){var n=l.exec(t),r=Number(n[1]);switch(n[2]){case"h":return 3600*r;case"m":return 60*r;case"ms":return 1e3*r;case"f":return r/i.frameRate;case"t":return r/i.tickRate}return r}(t,i))),n}},"./src/utils/logger.ts":
314
+ /*!*****************************!*\
315
+ !*** ./src/utils/logger.ts ***!
316
+ \*****************************/
317
+ /*! exports provided: enableLogs, logger */function(t,i,n){n.r(i),n.d(i,"enableLogs",(function(){return o})),n.d(i,"logger",(function(){return h}));var r=function(){},e={trace:r,debug:r,log:r,warn:r,info:r,error:r},s=e;function a(t){var i=self.console[t];return i?i.bind(self.console,"["+t+"] >"):r}function o(t){if(self.console&&!0===t||"object"==typeof t){!function(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];n.forEach((function(i){s[i]=t[i]?t[i].bind(t):a(i)}))}(t,"debug","log","info","warn","error");try{s.log()}catch(t){s=e}}else s=e}var h=e},"./src/utils/mediakeys-helper.ts":
318
+ /*!***************************************!*\
319
+ !*** ./src/utils/mediakeys-helper.ts ***!
320
+ \***************************************/
321
+ /*! exports provided: KeySystems, requestMediaKeySystemAccess */function(t,i,n){var r;n.r(i),n.d(i,"KeySystems",(function(){return r})),n.d(i,"requestMediaKeySystemAccess",(function(){return e})),function(t){t.WIDEVINE="com.widevine.alpha",t.PLAYREADY="com.microsoft.playready"}(r||(r={}));var e="undefined"!=typeof self&&self.navigator&&self.navigator.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null},"./src/utils/mediasource-helper.ts":
322
+ /*!*****************************************!*\
323
+ !*** ./src/utils/mediasource-helper.ts ***!
324
+ \*****************************************/
325
+ /*! exports provided: getMediaSource */function(t,i,n){function r(){return self.MediaSource||self.WebKitMediaSource}n.r(i),n.d(i,"getMediaSource",(function(){return r}))},"./src/utils/mp4-tools.ts":
326
+ /*!********************************!*\
327
+ !*** ./src/utils/mp4-tools.ts ***!
328
+ \********************************/
329
+ /*! exports provided: bin2str, readUint16, readUint32, writeUint32, findBox, parseSegmentIndex, parseInitSegment, getStartDTS, getDuration, computeRawDurationFromSamples, offsetStartDTS, segmentValidRange, appendUint8Array */function(t,i,n){n.r(i),n.d(i,"bin2str",(function(){return o})),n.d(i,"readUint16",(function(){return h})),n.d(i,"readUint32",(function(){return u})),n.d(i,"writeUint32",(function(){return c})),n.d(i,"findBox",(function(){return f})),n.d(i,"parseSegmentIndex",(function(){return l})),n.d(i,"parseInitSegment",(function(){return v})),n.d(i,"getStartDTS",(function(){return d})),n.d(i,"getDuration",(function(){return m})),n.d(i,"computeRawDurationFromSamples",(function(){return p})),n.d(i,"offsetStartDTS",(function(){return g})),n.d(i,"segmentValidRange",(function(){return b})),n.d(i,"appendUint8Array",(function(){return y}));var r=n(/*! ./typed-array */"./src/utils/typed-array.ts"),e=n(/*! ../loader/fragment */"./src/loader/fragment.ts"),s=Math.pow(2,32)-1,a=[].push;function o(t){return String.fromCharCode.apply(null,t)}function h(t,i){"data"in t&&(i+=t.start,t=t.data);var n=t[i]<<8|t[i+1];return n<0?65536+n:n}function u(t,i){"data"in t&&(i+=t.start,t=t.data);var n=t[i]<<24|t[i+1]<<16|t[i+2]<<8|t[i+3];return n<0?4294967296+n:n}function c(t,i,n){"data"in t&&(i+=t.start,t=t.data),t[i]=n>>24,t[i+1]=n>>16&255,t[i+2]=n>>8&255,t[i+3]=255&n}function f(t,i){var n,r,e,s=[];if(!i.length)return s;"data"in t?(n=t.data,r=t.start,e=t.end):(r=0,e=(n=t).byteLength);for(var h=r;h<e;){var c=u(n,h),l=c>1?h+c:e;if(o(n.subarray(h+4,h+8))===i[0])if(1===i.length)s.push({data:n,start:h+8,end:l});else{var v=f({data:n,start:h+8,end:l},i.slice(1));v.length&&a.apply(s,v)}h=l}return s}function l(t){var i=f(t,["moov"])[0],n=i?i.end:null,r=f(t,["sidx"]);if(!r||!r[0])return null;var e=[],s=r[0],a=s.data[0],o=0===a?8:16,c=u(s,o);o+=4,o+=0===a?8:16;var l=s.end+0,v=h(s,o+=2);o+=2;for(var d=0;d<v;d++){var m=o,p=u(s,m);m+=4;var g=2147483647&p;if(1==(2147483648&p)>>>31)return console.warn("SIDX has hierarchical references (not supported)"),null;var b=u(s,m);m+=4,e.push({referenceSize:g,subsegmentDuration:b,info:{duration:b/c,start:l,end:l+g-1}}),l+=g,o=m+=4}return{earliestPresentationTime:0,timescale:c,version:a,referencesCount:v,references:e,moovEndOffset:n}}function v(t){for(var i=[],n=f(t,["moov","trak"]),r=0;r<n.length;r++){var s=n[r],a=f(s,["tkhd"])[0];if(a){var h=a.data[a.start],c=0===h?12:20,l=u(a,c),v=f(s,["mdia","mdhd"])[0];if(v){var d=u(v,c=0===(h=v.data[v.start])?12:20),m=f(s,["mdia","hdlr"])[0];if(m){var p=o(m.data.subarray(m.start+8,m.start+12)),g={soun:e.ElementaryStreamTypes.AUDIO,vide:e.ElementaryStreamTypes.VIDEO}[p];if(g){var b=f(s,["mdia","minf","stbl","stsd"])[0],y=void 0;b&&(y=o(b.data.subarray(b.start+12,b.start+16))),i[l]={timescale:d,type:g},i[g]={timescale:d,id:l,codec:y}}}}}}return f(t,["moov","mvex","trex"]).forEach((function(t){var n=u(t,4),r=i[n];r&&(r.default={duration:u(t,12),flags:u(t,20)})})),i}function d(t,i){return f(i,["moof","traf"]).reduce((function(i,n){var r=f(n,["tfdt"])[0],e=r.data[r.start],s=f(n,["tfhd"]).reduce((function(i,n){var s=u(n,4),a=t[s];if(a){var o=u(r,4);1===e&&(o*=Math.pow(2,32),o+=u(r,8));var h=o/(a.timescale||9e4);if(isFinite(h)&&(null===i||h<i))return h}return i}),null);return null!==s&&isFinite(s)&&(null===i||s<i)?s:i}),null)||0}function m(t,i){for(var n=0,r=0,s=0,a=f(t,["moof","traf"]),o=0;o<a.length;o++){var h=a[o],c=f(h,["tfhd"])[0],v=i[u(c,4)];if(v){var d=v.default,m=u(c,0)|(null==d?void 0:d.flags),g=null==d?void 0:d.duration;8&m&&(g=u(c,2&m?12:8));for(var b=v.timescale||9e4,y=f(h,["trun"]),w=0;w<y.length;w++)!(n=p(y[w]))&&g&&(n=g*u(y[w],4)),v.type===e.ElementaryStreamTypes.VIDEO?r+=n/b:v.type===e.ElementaryStreamTypes.AUDIO&&(s+=n/b)}}if(0===r&&0===s){var k=l(t);if(null!=k&&k.references)return k.references.reduce((function(t,i){return t+i.info.duration||0}),0)}return r||s}function p(t){var i=u(t,0),n=8;1&i&&(n+=4),4&i&&(n+=4);for(var r=0,e=u(t,4),s=0;s<e;s++)256&i&&(r+=u(t,n),n+=4),512&i&&(n+=4),1024&i&&(n+=4),2048&i&&(n+=4);return r}function g(t,i,n){f(i,["moof","traf"]).forEach((function(i){f(i,["tfhd"]).forEach((function(r){var e=u(r,4),a=t[e];if(a){var o=a.timescale||9e4;f(i,["tfdt"]).forEach((function(t){var i=t.data[t.start],r=u(t,4);if(0===i)c(t,4,r-n*o);else{r*=Math.pow(2,32),r+=u(t,8),r-=n*o,r=Math.max(r,0);var e=Math.floor(r/(s+1)),a=Math.floor(r%(s+1));c(t,4,e),c(t,8,a)}}))}}))}))}function b(t){var i={valid:null,remainder:null},n=f(t,["moof"]);if(!n)return i;if(n.length<2)return i.remainder=t,i;var e=n[n.length-1];return i.valid=Object(r.sliceUint8)(t,0,e.start-8),i.remainder=Object(r.sliceUint8)(t,e.start-8),i}function y(t,i){var n=new Uint8Array(t.length+i.length);return n.set(t),n.set(i,t.length),n}},"./src/utils/output-filter.ts":
330
+ /*!************************************!*\
331
+ !*** ./src/utils/output-filter.ts ***!
332
+ \************************************/
333
+ /*! exports provided: default */function(t,i,n){n.r(i),n.d(i,"default",(function(){return r}));var r=function(){function t(t,i){this.timelineController=void 0,this.cueRanges=[],this.trackName=void 0,this.startTime=null,this.endTime=null,this.screen=null,this.timelineController=t,this.trackName=i}var i=t.prototype;return i.dispatchCue=function(){null!==this.startTime&&(this.timelineController.addCues(this.trackName,this.startTime,this.endTime,this.screen,this.cueRanges),this.startTime=null)},i.newCue=function(t,i,n){(null===this.startTime||this.startTime>t)&&(this.startTime=t),this.endTime=i,this.screen=n,this.timelineController.createCaptionsTrack(this.trackName)},i.reset=function(){this.cueRanges=[],this.startTime=null},t}()},"./src/utils/texttrack-utils.ts":
334
+ /*!**************************************!*\
335
+ !*** ./src/utils/texttrack-utils.ts ***!
336
+ \**************************************/
337
+ /*! exports provided: sendAddTrackEvent, addCueToTrack, clearCurrentCues, removeCuesInRange, getCuesInRange */function(t,i,n){n.r(i),n.d(i,"sendAddTrackEvent",(function(){return e})),n.d(i,"addCueToTrack",(function(){return s})),n.d(i,"clearCurrentCues",(function(){return a})),n.d(i,"removeCuesInRange",(function(){return o})),n.d(i,"getCuesInRange",(function(){return h}));var r=n(/*! ./logger */"./src/utils/logger.ts");function e(t,i){var n;try{n=new Event("addtrack")}catch(t){(n=document.createEvent("Event")).initEvent("addtrack",!1,!1)}n.track=t,i.dispatchEvent(n)}function s(t,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(i.id))try{if(t.addCue(i),!t.cues.getCueById(i.id))throw new Error("addCue is failed for: "+i)}catch(n){r.logger.debug("[texttrack-utils]: "+n);var e=new self.TextTrackCue(i.startTime,i.endTime,i.text);e.id=i.id,t.addCue(e)}"disabled"===n&&(t.mode=n)}function a(t){var i=t.mode;if("disabled"===i&&(t.mode="hidden"),t.cues)for(var n=t.cues.length;n--;)t.removeCue(t.cues[n]);"disabled"===i&&(t.mode=i)}function o(t,i,n){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var e=h(t.cues,i,n),s=0;s<e.length;s++)t.removeCue(e[s]);"disabled"===r&&(t.mode=r)}function h(t,i,n){var r=[],e=function(t,i){if(i<t[0].startTime)return 0;var n=t.length-1;if(i>t[n].endTime)return-1;for(var r=0,e=n;r<=e;){var s=Math.floor((e+r)/2);if(i<t[s].startTime)e=s-1;else{if(!(i>t[s].startTime&&r<n))return s;r=s+1}}return t[r].startTime-i<i-t[e].startTime?r:e}(t,i);if(e>-1)for(var s=e,a=t.length;s<a;s++){var o=t[s];if(o.startTime>=i&&o.endTime<=n)r.push(o);else if(o.startTime>n)return r}return r}},"./src/utils/time-ranges.ts":
338
+ /*!**********************************!*\
339
+ !*** ./src/utils/time-ranges.ts ***!
340
+ \**********************************/
341
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default={toString:function(t){for(var i="",n=t.length,r=0;r<n;r++)i+="["+t.start(r).toFixed(3)+","+t.end(r).toFixed(3)+"]";return i}}},"./src/utils/timescale-conversion.ts":
342
+ /*!*******************************************!*\
343
+ !*** ./src/utils/timescale-conversion.ts ***!
344
+ \*******************************************/
345
+ /*! exports provided: toTimescaleFromBase, toTimescaleFromScale, toMsFromMpegTsClock, toMpegTsClockFromTimescale */function(t,i,n){function r(t,i,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);var e=t*i*n;return r?Math.round(e):e}function e(t,i,n,e){return void 0===n&&(n=1),void 0===e&&(e=!1),r(t,i,1/n,e)}function s(t,i){return void 0===i&&(i=!1),r(t,1e3,1/9e4,i)}function a(t,i){return void 0===i&&(i=1),r(t,9e4,1/i)}n.r(i),n.d(i,"toTimescaleFromBase",(function(){return r})),n.d(i,"toTimescaleFromScale",(function(){return e})),n.d(i,"toMsFromMpegTsClock",(function(){return s})),n.d(i,"toMpegTsClockFromTimescale",(function(){return a}))},"./src/utils/typed-array.ts":
346
+ /*!**********************************!*\
347
+ !*** ./src/utils/typed-array.ts ***!
348
+ \**********************************/
349
+ /*! exports provided: sliceUint8 */function(t,i,n){function r(t,i,n){return Uint8Array.prototype.slice?t.slice(i,n):new Uint8Array(Array.prototype.slice.call(t,i,n))}n.r(i),n.d(i,"sliceUint8",(function(){return r}))},"./src/utils/vttcue.ts":
350
+ /*!*****************************!*\
351
+ !*** ./src/utils/vttcue.ts ***!
352
+ \*****************************/
353
+ /*! exports provided: default */function(t,i,n){n.r(i),i.default=function(){if("undefined"!=typeof self&&self.VTTCue)return self.VTTCue;var t=["","lr","rl"],i=["start","middle","end","left","right"];function n(t,i){if("string"!=typeof i)return!1;if(!Array.isArray(t))return!1;var n=i.toLowerCase();return!!~t.indexOf(n)&&n}function r(t){return n(i,t)}function e(t){for(var i=arguments.length,n=new Array(i>1?i-1:0),r=1;r<i;r++)n[r-1]=arguments[r];for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var a in s)t[a]=s[a]}return t}function s(i,s,a){var o=this,h={enumerable:!0};o.hasBeenReset=!1;var u="",c=!1,f=i,l=s,v=a,d=null,m="",p=!0,g="auto",b="start",y=50,w="middle",k=50,T="middle";Object.defineProperty(o,"id",e({},h,{get:function(){return u},set:function(t){u=""+t}})),Object.defineProperty(o,"pauseOnExit",e({},h,{get:function(){return c},set:function(t){c=!!t}})),Object.defineProperty(o,"startTime",e({},h,{get:function(){return f},set:function(t){if("number"!=typeof t)throw new TypeError("Start time must be set to a number.");f=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"endTime",e({},h,{get:function(){return l},set:function(t){if("number"!=typeof t)throw new TypeError("End time must be set to a number.");l=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"text",e({},h,{get:function(){return v},set:function(t){v=""+t,this.hasBeenReset=!0}})),Object.defineProperty(o,"region",e({},h,{get:function(){return d},set:function(t){d=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"vertical",e({},h,{get:function(){return m},set:function(i){var r=function(i){return n(t,i)}(i);if(!1===r)throw new SyntaxError("An invalid or illegal string was specified.");m=r,this.hasBeenReset=!0}})),Object.defineProperty(o,"snapToLines",e({},h,{get:function(){return p},set:function(t){p=!!t,this.hasBeenReset=!0}})),Object.defineProperty(o,"line",e({},h,{get:function(){return g},set:function(t){if("number"!=typeof t&&"auto"!==t)throw new SyntaxError("An invalid number or illegal string was specified.");g=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"lineAlign",e({},h,{get:function(){return b},set:function(t){var i=r(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");b=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"position",e({},h,{get:function(){return y},set:function(t){if(t<0||t>100)throw new Error("Position must be between 0 and 100.");y=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",e({},h,{get:function(){return w},set:function(t){var i=r(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");w=i,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",e({},h,{get:function(){return k},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");k=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",e({},h,{get:function(){return T},set:function(t){var i=r(t);if(!i)throw new SyntaxError("An invalid or illegal string was specified.");T=i,this.hasBeenReset=!0}})),o.displayState=void 0}return s.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},s}()},"./src/utils/vttparser.ts":
354
+ /*!********************************!*\
355
+ !*** ./src/utils/vttparser.ts ***!
356
+ \********************************/
357
+ /*! exports provided: parseTimeStamp, fixLineBreaks, VTTParser */function(t,i,n){n.r(i),n.d(i,"parseTimeStamp",(function(){return s})),n.d(i,"fixLineBreaks",(function(){return f})),n.d(i,"VTTParser",(function(){return l}));var r=n(/*! ./vttcue */"./src/utils/vttcue.ts"),e=function(){function t(){}return t.prototype.decode=function(t){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function s(t){function i(t,i,n,r){return 3600*(0|t)+60*(0|i)+(0|n)+parseFloat(r||0)}var n=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return n?parseFloat(n[2])>59?i(n[2],n[3],0,n[4]):i(n[1],n[2],n[3],n[4]):null}var a=function(){function t(){this.values=Object.create(null)}var i=t.prototype;return i.set=function(t,i){this.get(t)||""===i||(this.values[t]=i)},i.get=function(t,i,n){return n?this.has(t)?this.values[t]:i[n]:this.has(t)?this.values[t]:i},i.has=function(t){return t in this.values},i.alt=function(t,i,n){for(var r=0;r<n.length;++r)if(i===n[r]){this.set(t,i);break}},i.integer=function(t,i){/^-?\d+$/.test(i)&&this.set(t,parseInt(i,10))},i.percent=function(t,i){if(/^([\d]{1,3})(\.[\d]*)?%$/.test(i)){var n=parseFloat(i);if(n>=0&&n<=100)return this.set(t,n),!0}return!1},t}();function o(t,i,n,r){var e=r?t.split(r):[t];for(var s in e)if("string"==typeof e[s]){var a=e[s].split(n);2===a.length&&i(a[0],a[1])}}var h=new r.default(0,0,""),u="middle"===h.align?"middle":"center";function c(t,i,n){var r=t;function e(){var i=s(t);if(null===i)throw new Error("Malformed timestamp: "+r);return t=t.replace(/^[^\sa-zA-Z-]+/,""),i}function c(){t=t.replace(/^\s+/,"")}if(c(),i.startTime=e(),c(),"--\x3e"!==t.substr(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+r);t=t.substr(3),c(),i.endTime=e(),c(),function(t,i){var r=new a;o(t,(function(t,i){var e;switch(t){case"region":for(var s=n.length-1;s>=0;s--)if(n[s].id===i){r.set(t,n[s].region);break}break;case"vertical":r.alt(t,i,["rl","lr"]);break;case"line":e=i.split(","),r.integer(t,e[0]),r.percent(t,e[0])&&r.set("snapToLines",!1),r.alt(t,e[0],["auto"]),2===e.length&&r.alt("lineAlign",e[1],["start",u,"end"]);break;case"position":e=i.split(","),r.percent(t,e[0]),2===e.length&&r.alt("positionAlign",e[1],["start",u,"end","line-left","line-right","auto"]);break;case"size":r.percent(t,i);break;case"align":r.alt(t,i,["start",u,"end","left","right"])}}),/:/,/\s/),i.region=r.get("region",null),i.vertical=r.get("vertical","");var e=r.get("line","auto");"auto"===e&&-1===h.line&&(e=-1),i.line=e,i.lineAlign=r.get("lineAlign","start"),i.snapToLines=r.get("snapToLines",!0),i.size=r.get("size",100),i.align=r.get("align",u);var s=r.get("position","auto");"auto"===s&&50===h.position&&(s="start"===i.align||"left"===i.align?0:"end"===i.align||"right"===i.align?100:50),i.position=s}(t,i)}function f(t){return t.replace(/<br(?: \/)?>/gi,"\n")}var l=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new e,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var i=t.prototype;return i.parse=function(t){var i=this;function n(){var t=i.buffer,n=0;for(t=f(t);n<t.length&&"\r"!==t[n]&&"\n"!==t[n];)++n;var r=t.substr(0,n);return"\r"===t[n]&&++n,"\n"===t[n]&&++n,i.buffer=t.substr(n),r}t&&(i.buffer+=i.decoder.decode(t,{stream:!0}));try{var e="";if("INITIAL"===i.state){if(!/\r\n|\n/.test(i.buffer))return this;var s=(e=n()).match(/^()?WEBVTT([ \t].*)?$/);if(!s||!s[0])throw new Error("Malformed WebVTT signature.");i.state="HEADER"}for(var a=!1;i.buffer;){if(!/\r\n|\n/.test(i.buffer))return this;switch(a?a=!1:e=n(),i.state){case"HEADER":/:/.test(e)?o(e,(function(){}),/:/):e||(i.state="ID");continue;case"NOTE":e||(i.state="ID");continue;case"ID":if(/^NOTE($|[ \t])/.test(e)){i.state="NOTE";break}if(!e)continue;if(i.cue=new r.default(0,0,""),i.state="CUE",-1===e.indexOf("--\x3e")){i.cue.id=e;continue}case"CUE":if(!i.cue){i.state="BADCUE";continue}try{c(e,i.cue,i.regionList)}catch(t){i.cue=null,i.state="BADCUE";continue}i.state="CUETEXT";continue;case"CUETEXT":var h=-1!==e.indexOf("--\x3e");if(!e||h&&(a=!0)){i.oncue&&i.cue&&i.oncue(i.cue),i.cue=null,i.state="ID";continue}if(null===i.cue)continue;i.cue.text&&(i.cue.text+="\n"),i.cue.text+=e;continue;case"BADCUE":e||(i.state="ID")}}}catch(t){"CUETEXT"===i.state&&i.cue&&i.oncue&&i.oncue(i.cue),i.cue=null,i.state="INITIAL"===i.state?"BADWEBVTT":"BADCUE"}return this},i.flush=function(){var t=this;try{if((t.cue||"HEADER"===t.state)&&(t.buffer+="\n\n",t.parse()),"INITIAL"===t.state||"BADWEBVTT"===t.state)throw new Error("Malformed WebVTT signature.")}catch(i){t.onparsingerror&&t.onparsingerror(i)}return t.onflush&&t.onflush(),this},t}()},"./src/utils/webvtt-parser.ts":
358
+ /*!************************************!*\
359
+ !*** ./src/utils/webvtt-parser.ts ***!
360
+ \************************************/
361
+ /*! exports provided: generateCueId, parseWebVTT */function(t,i,n){n.r(i),n.d(i,"generateCueId",(function(){return f})),n.d(i,"parseWebVTT",(function(){return l}));var r=n(/*! ./src/polyfills/number */"./src/polyfills/number.ts"),e=n(/*! ./vttparser */"./src/utils/vttparser.ts"),s=n(/*! ../demux/id3 */"./src/demux/id3.ts"),a=n(/*! ./timescale-conversion */"./src/utils/timescale-conversion.ts"),o=n(/*! ../remux/mp4-remuxer */"./src/remux/mp4-remuxer.ts"),h=/\r\n|\n\r|\n|\r/g,u=function(t,i,n){return void 0===n&&(n=0),t.substr(n,i.length)===i},c=function(t){for(var i=5381,n=t.length;n;)i=33*i^t.charCodeAt(--n);return(i>>>0).toString()};function f(t,i,n){return c(t.toString())+c(i.toString())+c(n)}function l(t,i,n,c,l,v,d,m){var p,g=new e.VTTParser,b=Object(s.utf8ArrayToStr)(new Uint8Array(t)).trim().replace(h,"\n").split("\n"),y=[],w=Object(a.toMpegTsClockFromTimescale)(i,n),k="00:00.000",T=0,O=0,S=!0,E=!1;g.oncue=function(t){var i=c[l],n=c.ccOffset,r=(T-w)/9e4;if(null!=i&&i.new&&(void 0!==O?n=c.ccOffset=i.start:function(t,i,n){var r=t[i],e=t[r.prevCC];if(!e||!e.new&&r.new)return t.ccOffset=t.presentationOffset=r.start,void(r.new=!1);for(;null!==(s=e)&&void 0!==s&&s.new;){var s;t.ccOffset+=r.start-e.start,r.new=!1,e=t[(r=e).prevCC]}t.presentationOffset=n}(c,l,r)),r&&(n=r-c.presentationOffset),E){var e=t.endTime-t.startTime,s=Object(o.normalizePts)(9e4*(t.startTime+n-O),9e4*v)/9e4;t.startTime=s,t.endTime=s+e}var a=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(a)),t.id||(t.id=f(t.startTime,t.endTime,a)),t.endTime>0&&y.push(t)},g.onparsingerror=function(t){p=t},g.onflush=function(){p?m(p):d(y)},b.forEach((function(t){if(S){if(u(t,"X-TIMESTAMP-MAP=")){S=!1,E=!0,t.substr(16).split(",").forEach((function(t){u(t,"LOCAL:")?k=t.substr(6):u(t,"MPEGTS:")&&(T=parseInt(t.substr(7)))}));try{O=function(t){var i=parseInt(t.substr(-3)),n=parseInt(t.substr(-6,2)),e=parseInt(t.substr(-9,2)),s=t.length>9?parseInt(t.substr(0,t.indexOf(":"))):0;if(!(Object(r.isFiniteNumber)(i)&&Object(r.isFiniteNumber)(n)&&Object(r.isFiniteNumber)(e)&&Object(r.isFiniteNumber)(s)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return i+=1e3*n,(i+=6e4*e)+36e5*s}(k)/1e3}catch(t){E=!1,p=t}return}""===t&&(S=!1)}g.parse(t+"\n")})),g.flush()}},"./src/utils/xhr-loader.ts":
362
+ /*!*********************************!*\
363
+ !*** ./src/utils/xhr-loader.ts ***!
364
+ \*********************************/
365
+ /*! exports provided: default */function(t,i,n){n.r(i);var r=n(/*! ../utils/logger */"./src/utils/logger.ts"),e=n(/*! ../loader/load-stats */"./src/loader/load-stats.ts"),s=/^age:\s*[\d.]+\s*$/m;i.default=function(){function t(t){this.xhrSetup=void 0,this.requestTimeout=void 0,this.retryTimeout=void 0,this.retryDelay=void 0,this.config=null,this.callbacks=null,this.context=void 0,this.loader=null,this.stats=void 0,this.xhrSetup=t?t.xhrSetup:null,this.stats=new e.LoadStats,this.retryDelay=0}var i=t.prototype;return i.destroy=function(){this.callbacks=null,this.abortInternal(),this.loader=null,this.config=null},i.abortInternal=function(){var t=this.loader;self.clearTimeout(this.requestTimeout),self.clearTimeout(this.retryTimeout),t&&(t.onreadystatechange=null,t.onprogress=null,4!==t.readyState&&(this.stats.aborted=!0,t.abort()))},i.abort=function(){var t;this.abortInternal(),null!==(t=this.callbacks)&&void 0!==t&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.loader)},i.load=function(t,i,n){if(this.stats.loading.start)throw new Error("Loader can only be used once.");this.stats.loading.start=self.performance.now(),this.context=t,this.config=i,this.callbacks=n,this.retryDelay=i.retryDelay,this.loadInternal()},i.loadInternal=function(){var t=this.config,i=this.context;if(t){var n=this.loader=new self.XMLHttpRequest,r=this.stats;r.loading.first=0,r.loaded=0;var e=this.xhrSetup;try{if(e)try{e(n,i.url)}catch(t){n.open("GET",i.url,!0),e(n,i.url)}n.readyState||n.open("GET",i.url,!0);var s=this.context.headers;if(s)for(var a in s)n.setRequestHeader(a,s[a])}catch(t){return void this.callbacks.onError({code:n.status,text:t.message},i,n)}i.rangeEnd&&n.setRequestHeader("Range","bytes="+i.rangeStart+"-"+(i.rangeEnd-1)),n.onreadystatechange=this.readystatechange.bind(this),n.onprogress=this.loadprogress.bind(this),n.responseType=i.responseType,self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),t.timeout),n.send()}},i.readystatechange=function(){var t=this.context,i=this.loader,n=this.stats;if(t&&i){var e=i.readyState,s=this.config;if(!n.aborted&&e>=2)if(self.clearTimeout(this.requestTimeout),0===n.loading.first&&(n.loading.first=Math.max(self.performance.now(),n.loading.start)),4===e){i.onreadystatechange=null,i.onprogress=null;var a=i.status;if(a>=200&&a<300){var o,h;if(n.loading.end=Math.max(self.performance.now(),n.loading.first),h="arraybuffer"===t.responseType?(o=i.response).byteLength:(o=i.responseText).length,n.loaded=n.total=h,!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(n,t,o,i),!this.callbacks)return;this.callbacks.onSuccess({url:i.responseURL,data:o},n,t,i)}else n.retry>=s.maxRetry||a>=400&&a<499?(r.logger.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:i.statusText},t,i)):(r.logger.warn(a+" while loading "+t.url+", retrying in "+this.retryDelay+"..."),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay),this.retryDelay=Math.min(2*this.retryDelay,s.maxRetryDelay),n.retry++)}else self.clearTimeout(this.requestTimeout),this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),s.timeout)}},i.loadtimeout=function(){r.logger.warn("timeout while loading "+this.context.url);var t=this.callbacks;t&&(this.abortInternal(),t.onTimeout(this.stats,this.context,this.loader))},i.loadprogress=function(t){var i=this.stats;i.loaded=t.loaded,t.lengthComputable&&(i.total=t.total)},i.getCacheAge=function(){var t=null;if(this.loader&&s.test(this.loader.getAllResponseHeaders())){var i=this.loader.getResponseHeader("age");t=i?parseFloat(i):null}return t},t}()}}).default},t.exports=i())}));const e=t(r),s=Object.freeze(Object.assign(Object.create(null),r,{default:e}));export{s as h}