rx-player 4.1.0 → 4.2.0-dev.2024080600

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 (1030) hide show
  1. package/CHANGELOG.md +5 -10
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  5. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  6. package/dist/commonjs/compat/add_class_name.js +1 -1
  7. package/dist/commonjs/compat/add_text_track.d.ts +2 -2
  8. package/dist/commonjs/compat/add_text_track.d.ts.map +1 -1
  9. package/dist/commonjs/compat/add_text_track.js +1 -1
  10. package/dist/commonjs/compat/browser_compatibility_types.d.ts +196 -13
  11. package/dist/commonjs/compat/browser_compatibility_types.d.ts.map +1 -1
  12. package/dist/commonjs/compat/browser_compatibility_types.js +29 -0
  13. package/dist/commonjs/compat/browser_version.js +1 -2
  14. package/dist/commonjs/compat/can_patch_isobmff.js +1 -1
  15. package/dist/commonjs/compat/can_rely_on_request_media_key_system_access.js +1 -2
  16. package/dist/commonjs/compat/can_rely_on_video_visibility_and_size.js +1 -1
  17. package/dist/commonjs/compat/can_reuse_media_keys.js +1 -1
  18. package/dist/commonjs/compat/change_source_buffer_type.js +1 -1
  19. package/dist/commonjs/compat/clear_element_src.d.ts +2 -1
  20. package/dist/commonjs/compat/clear_element_src.d.ts.map +1 -1
  21. package/dist/commonjs/compat/clear_element_src.js +1 -1
  22. package/dist/commonjs/compat/eme/close_session.js +1 -1
  23. package/dist/commonjs/compat/eme/custom_media_keys/ie11_media_keys.d.ts +3 -2
  24. package/dist/commonjs/compat/eme/custom_media_keys/ie11_media_keys.d.ts.map +1 -1
  25. package/dist/commonjs/compat/eme/custom_media_keys/ie11_media_keys.js +1 -1
  26. package/dist/commonjs/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts +2 -1
  27. package/dist/commonjs/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts.map +1 -1
  28. package/dist/commonjs/compat/eme/custom_media_keys/moz_media_keys_constructor.js +2 -3
  29. package/dist/commonjs/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts +3 -2
  30. package/dist/commonjs/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts.map +1 -1
  31. package/dist/commonjs/compat/eme/custom_media_keys/old_webkit_media_keys.js +2 -3
  32. package/dist/commonjs/compat/eme/custom_media_keys/types.d.ts +5 -1
  33. package/dist/commonjs/compat/eme/custom_media_keys/types.d.ts.map +1 -1
  34. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.d.ts +4 -3
  35. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.d.ts.map +1 -1
  36. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys.js +3 -4
  37. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys_constructor.d.ts.map +1 -1
  38. package/dist/commonjs/compat/eme/custom_media_keys/webkit_media_keys_constructor.js +1 -2
  39. package/dist/commonjs/compat/eme/eme-api-implementation.d.ts +4 -3
  40. package/dist/commonjs/compat/eme/eme-api-implementation.d.ts.map +1 -1
  41. package/dist/commonjs/compat/eme/eme-api-implementation.js +19 -5
  42. package/dist/commonjs/compat/eme/generate_key_request.js +2 -3
  43. package/dist/commonjs/compat/eme/get_init_data.d.ts +3 -1
  44. package/dist/commonjs/compat/eme/get_init_data.d.ts.map +1 -1
  45. package/dist/commonjs/compat/eme/get_init_data.js +3 -3
  46. package/dist/commonjs/compat/eme/get_uuid_kid_from_keystatus_kid.js +1 -1
  47. package/dist/commonjs/compat/eme/get_webkit_fairplay_initdata.js +1 -1
  48. package/dist/commonjs/compat/eme/load_session.js +1 -1
  49. package/dist/commonjs/compat/eme/set_media_keys.d.ts +2 -1
  50. package/dist/commonjs/compat/eme/set_media_keys.d.ts.map +1 -1
  51. package/dist/commonjs/compat/eme/set_media_keys.js +1 -2
  52. package/dist/commonjs/compat/enable_audio_track.js +1 -1
  53. package/dist/commonjs/compat/event_listeners.d.ts +26 -24
  54. package/dist/commonjs/compat/event_listeners.d.ts.map +1 -1
  55. package/dist/commonjs/compat/event_listeners.js +9 -21
  56. package/dist/commonjs/compat/generate_init_data.js +2 -2
  57. package/dist/commonjs/compat/get_start_date.d.ts +2 -1
  58. package/dist/commonjs/compat/get_start_date.d.ts.map +1 -1
  59. package/dist/commonjs/compat/get_start_date.js +1 -1
  60. package/dist/commonjs/compat/has_issues_with_high_media_source_duration.js +1 -1
  61. package/dist/commonjs/compat/has_worker_api.js +1 -1
  62. package/dist/commonjs/compat/is_codec_supported.js +1 -1
  63. package/dist/commonjs/compat/is_debug_mode_enabled.js +1 -1
  64. package/dist/commonjs/compat/is_vtt_cue.js +1 -1
  65. package/dist/commonjs/compat/make_vtt_cue.js +1 -1
  66. package/dist/commonjs/compat/on_height_width_change.js +1 -1
  67. package/dist/commonjs/compat/patch_webkit_source_buffer.js +1 -1
  68. package/dist/commonjs/compat/remove_cue.js +1 -1
  69. package/dist/commonjs/compat/should_await_set_media_keys.js +1 -1
  70. package/dist/commonjs/compat/should_favour_custom_safari_EME.js +1 -1
  71. package/dist/commonjs/compat/should_reload_media_source_on_decipherability_update.js +1 -1
  72. package/dist/commonjs/compat/should_renew_media_key_system_access.js +1 -1
  73. package/dist/commonjs/compat/should_unset_media_keys.js +1 -1
  74. package/dist/commonjs/compat/should_validate_metadata.js +1 -1
  75. package/dist/commonjs/compat/should_wait_for_data_before_loaded.js +1 -1
  76. package/dist/commonjs/compat/should_wait_for_have_enough_data.js +1 -1
  77. package/dist/commonjs/config.d.ts +1 -1
  78. package/dist/commonjs/core/adaptive/adaptive_representation_selector.js +1 -1
  79. package/dist/commonjs/core/adaptive/network_analyzer.js +1 -2
  80. package/dist/commonjs/core/adaptive/utils/filter_by_bitrate.js +1 -1
  81. package/dist/commonjs/core/adaptive/utils/filter_by_resolution.js +1 -1
  82. package/dist/commonjs/core/adaptive/utils/get_buffer_levels.js +1 -1
  83. package/dist/commonjs/core/adaptive/utils/select_optimal_representation.js +1 -1
  84. package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts +121 -0
  85. package/dist/commonjs/core/cmcd/cmcd_data_builder.d.ts.map +1 -0
  86. package/dist/commonjs/core/cmcd/cmcd_data_builder.js +341 -0
  87. package/dist/commonjs/core/cmcd/index.d.ts +4 -0
  88. package/dist/commonjs/core/cmcd/index.d.ts.map +1 -0
  89. package/dist/commonjs/core/cmcd/index.js +4 -0
  90. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts +8 -0
  91. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.d.ts.map +1 -1
  92. package/dist/commonjs/core/fetchers/manifest/manifest_fetcher.js +14 -11
  93. package/dist/commonjs/core/fetchers/segment/prioritized_segment_fetcher.js +1 -1
  94. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts +43 -23
  95. package/dist/commonjs/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  96. package/dist/commonjs/core/fetchers/segment/segment_fetcher.js +25 -37
  97. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts +5 -3
  98. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.d.ts.map +1 -1
  99. package/dist/commonjs/core/fetchers/segment/segment_fetcher_creator.js +13 -5
  100. package/dist/commonjs/core/fetchers/utils/error_selector.js +1 -1
  101. package/dist/commonjs/core/fetchers/utils/schedule_request.js +2 -3
  102. package/dist/commonjs/core/main/common/create_content_time_boundaries_observer.js +1 -1
  103. package/dist/commonjs/core/main/common/get_buffered_data_per_media_buffer.js +1 -1
  104. package/dist/commonjs/core/main/worker/content_preparer.d.ts +7 -0
  105. package/dist/commonjs/core/main/worker/content_preparer.d.ts.map +1 -1
  106. package/dist/commonjs/core/main/worker/content_preparer.js +5 -2
  107. package/dist/commonjs/core/main/worker/send_message.js +2 -3
  108. package/dist/commonjs/core/main/worker/worker_main.d.ts.map +1 -1
  109. package/dist/commonjs/core/main/worker/worker_main.js +28 -38
  110. package/dist/commonjs/core/segment_sinks/garbage_collector.js +1 -1
  111. package/dist/commonjs/core/segment_sinks/inventory/utils.js +2 -3
  112. package/dist/commonjs/core/stream/adaptation/adaptation_stream.js +1 -1
  113. package/dist/commonjs/core/stream/adaptation/get_representations_switch_strategy.js +1 -1
  114. package/dist/commonjs/core/stream/orchestrator/get_time_ranges_for_content.js +1 -1
  115. package/dist/commonjs/core/stream/orchestrator/stream_orchestrator.js +1 -1
  116. package/dist/commonjs/core/stream/period/period_stream.js +1 -1
  117. package/dist/commonjs/core/stream/period/utils/get_adaptation_switch_strategy.js +1 -1
  118. package/dist/commonjs/core/stream/representation/representation_stream.js +1 -1
  119. package/dist/commonjs/core/stream/representation/utils/append_segment_to_buffer.js +1 -1
  120. package/dist/commonjs/core/stream/representation/utils/check_for_discontinuity.js +1 -1
  121. package/dist/commonjs/core/stream/representation/utils/get_buffer_status.js +1 -1
  122. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  123. package/dist/commonjs/core/stream/representation/utils/get_segment_priority.js +1 -1
  124. package/dist/commonjs/core/stream/representation/utils/push_init_segment.js +7 -7
  125. package/dist/commonjs/core/stream/representation/utils/push_media_segment.js +10 -10
  126. package/dist/commonjs/default_config.d.ts +1 -1
  127. package/dist/commonjs/default_config.d.ts.map +1 -1
  128. package/dist/commonjs/default_config.js +1 -0
  129. package/dist/commonjs/errors/error_message.js +1 -1
  130. package/dist/commonjs/errors/format_error.js +1 -1
  131. package/dist/commonjs/errors/is_known_error.js +1 -1
  132. package/dist/commonjs/experimental/features/local.d.ts.map +1 -1
  133. package/dist/commonjs/experimental/features/local.js +1 -4
  134. package/dist/commonjs/experimental/features/metaplaylist.d.ts.map +1 -1
  135. package/dist/commonjs/experimental/features/metaplaylist.js +1 -4
  136. package/dist/commonjs/experimental/features/multi_thread.js +1 -2
  137. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/features/dash.js +1 -1
  138. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/features/metaplaylist.js +1 -1
  139. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +1 -1
  140. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts +2 -1
  141. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  142. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.js +1 -1
  143. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts +2 -1
  144. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts.map +1 -1
  145. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.js +1 -1
  146. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts.map +1 -1
  147. package/dist/commonjs/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +14 -8
  148. package/dist/commonjs/experimental/tools/createMetaplaylist/get_duration_from_manifest.js +1 -1
  149. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/index.d.ts.map +1 -1
  150. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
  151. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/capabilities.js +1 -1
  152. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/DRMInfos.js +1 -1
  153. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/HDCPPolicy.js +1 -1
  154. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/decodingInfo.js +1 -1
  155. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  156. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +3 -3
  157. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentType.js +1 -1
  158. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/format.js +1 -1
  159. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaContentTypeWithFeatures/index.js +1 -1
  160. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/probers/mediaDisplayInfos.js +1 -1
  161. package/dist/commonjs/experimental/tools/mediaCapabilitiesProber/utils.js +2 -3
  162. package/dist/commonjs/features/add_features.js +1 -1
  163. package/dist/commonjs/features/features_object.d.ts.map +1 -1
  164. package/dist/commonjs/features/features_object.js +0 -1
  165. package/dist/commonjs/features/list/dash.d.ts.map +1 -1
  166. package/dist/commonjs/features/list/dash.js +1 -4
  167. package/dist/commonjs/features/list/dash_wasm.d.ts.map +1 -1
  168. package/dist/commonjs/features/list/dash_wasm.js +0 -2
  169. package/dist/commonjs/features/list/debug_element.js +1 -2
  170. package/dist/commonjs/features/list/directfile.js +1 -2
  171. package/dist/commonjs/features/list/eme.js +1 -2
  172. package/dist/commonjs/features/list/html_sami_parser.js +1 -2
  173. package/dist/commonjs/features/list/html_srt_parser.js +1 -2
  174. package/dist/commonjs/features/list/html_text_buffer.js +1 -2
  175. package/dist/commonjs/features/list/html_ttml_parser.js +1 -2
  176. package/dist/commonjs/features/list/html_vtt_parser.js +1 -2
  177. package/dist/commonjs/features/list/media_source_main.js +1 -2
  178. package/dist/commonjs/features/list/native_sami_parser.js +1 -2
  179. package/dist/commonjs/features/list/native_srt_parser.js +1 -2
  180. package/dist/commonjs/features/list/native_text_buffer.js +1 -2
  181. package/dist/commonjs/features/list/native_ttml_parser.js +1 -2
  182. package/dist/commonjs/features/list/native_vtt_parser.js +1 -2
  183. package/dist/commonjs/features/list/smooth.d.ts.map +1 -1
  184. package/dist/commonjs/features/list/smooth.js +1 -4
  185. package/dist/commonjs/features/types.d.ts +3 -11
  186. package/dist/commonjs/features/types.d.ts.map +1 -1
  187. package/dist/commonjs/index.js +2 -2
  188. package/dist/commonjs/main_thread/api/debug/modules/general_info.js +1 -1
  189. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_content.js +1 -1
  190. package/dist/commonjs/main_thread/api/debug/modules/segment_buffer_size.js +1 -1
  191. package/dist/commonjs/main_thread/api/debug/render.js +1 -1
  192. package/dist/commonjs/main_thread/api/debug/utils.js +5 -6
  193. package/dist/commonjs/main_thread/api/option_utils.d.ts +9 -2
  194. package/dist/commonjs/main_thread/api/option_utils.d.ts.map +1 -1
  195. package/dist/commonjs/main_thread/api/option_utils.js +7 -9
  196. package/dist/commonjs/main_thread/api/public_api.d.ts +23 -2
  197. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  198. package/dist/commonjs/main_thread/api/public_api.js +50 -12
  199. package/dist/commonjs/main_thread/api/utils.d.ts +5 -4
  200. package/dist/commonjs/main_thread/api/utils.d.ts.map +1 -1
  201. package/dist/commonjs/main_thread/api/utils.js +5 -6
  202. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts +3 -2
  203. package/dist/commonjs/main_thread/decrypt/attach_media_keys.d.ts.map +1 -1
  204. package/dist/commonjs/main_thread/decrypt/attach_media_keys.js +8 -9
  205. package/dist/commonjs/main_thread/decrypt/clear_on_stop.d.ts +2 -1
  206. package/dist/commonjs/main_thread/decrypt/clear_on_stop.d.ts.map +1 -1
  207. package/dist/commonjs/main_thread/decrypt/clear_on_stop.js +1 -1
  208. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts +26 -1
  209. package/dist/commonjs/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  210. package/dist/commonjs/main_thread/decrypt/content_decryptor.js +86 -13
  211. package/dist/commonjs/main_thread/decrypt/create_or_load_session.js +1 -1
  212. package/dist/commonjs/main_thread/decrypt/create_session.js +1 -1
  213. package/dist/commonjs/main_thread/decrypt/dispose_decryption_resources.d.ts +2 -1
  214. package/dist/commonjs/main_thread/decrypt/dispose_decryption_resources.d.ts.map +1 -1
  215. package/dist/commonjs/main_thread/decrypt/dispose_decryption_resources.js +1 -1
  216. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts +17 -2
  217. package/dist/commonjs/main_thread/decrypt/find_key_system.d.ts.map +1 -1
  218. package/dist/commonjs/main_thread/decrypt/find_key_system.js +73 -3
  219. package/dist/commonjs/main_thread/decrypt/get_key_system_configuration.d.ts +2 -1
  220. package/dist/commonjs/main_thread/decrypt/get_key_system_configuration.d.ts.map +1 -1
  221. package/dist/commonjs/main_thread/decrypt/get_key_system_configuration.js +1 -1
  222. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts +5 -1
  223. package/dist/commonjs/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  224. package/dist/commonjs/main_thread/decrypt/get_media_keys.js +5 -3
  225. package/dist/commonjs/main_thread/decrypt/init_media_keys.d.ts +2 -1
  226. package/dist/commonjs/main_thread/decrypt/init_media_keys.d.ts.map +1 -1
  227. package/dist/commonjs/main_thread/decrypt/init_media_keys.js +1 -1
  228. package/dist/commonjs/main_thread/decrypt/session_events_listener.js +1 -1
  229. package/dist/commonjs/main_thread/decrypt/set_server_certificate.js +5 -4
  230. package/dist/commonjs/main_thread/decrypt/types.d.ts +1 -0
  231. package/dist/commonjs/main_thread/decrypt/types.d.ts.map +1 -1
  232. package/dist/commonjs/main_thread/decrypt/utils/are_init_values_compatible.js +1 -1
  233. package/dist/commonjs/main_thread/decrypt/utils/check_key_statuses.js +1 -1
  234. package/dist/commonjs/main_thread/decrypt/utils/clean_old_loaded_sessions.js +1 -1
  235. package/dist/commonjs/main_thread/decrypt/utils/clean_old_stored_persistent_info.js +1 -1
  236. package/dist/commonjs/main_thread/decrypt/utils/get_drm_system_id.js +1 -1
  237. package/dist/commonjs/main_thread/decrypt/utils/is_compatible_codec_supported.d.ts +14 -0
  238. package/dist/commonjs/main_thread/decrypt/utils/is_compatible_codec_supported.d.ts.map +1 -0
  239. package/dist/commonjs/main_thread/decrypt/utils/is_compatible_codec_supported.js +53 -0
  240. package/dist/commonjs/main_thread/decrypt/utils/is_session_usable.js +1 -1
  241. package/dist/commonjs/main_thread/decrypt/utils/key_id_comparison.js +2 -3
  242. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts +4 -3
  243. package/dist/commonjs/main_thread/decrypt/utils/media_keys_infos_store.d.ts.map +1 -1
  244. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts +6 -1
  245. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  246. package/dist/commonjs/main_thread/init/directfile_content_initializer.js +2 -13
  247. package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts +62 -4
  248. package/dist/commonjs/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
  249. package/dist/commonjs/main_thread/init/media_source_content_initializer.js +163 -28
  250. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts +46 -4
  251. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
  252. package/dist/commonjs/main_thread/init/multi_thread_content_initializer.js +78 -140
  253. package/dist/commonjs/main_thread/init/send_message.js +1 -1
  254. package/dist/commonjs/main_thread/init/types.d.ts +6 -1
  255. package/dist/commonjs/main_thread/init/types.d.ts.map +1 -1
  256. package/dist/commonjs/main_thread/init/utils/create_core_playback_observer.js +3 -4
  257. package/dist/commonjs/main_thread/init/utils/create_media_source.d.ts +3 -2
  258. package/dist/commonjs/main_thread/init/utils/create_media_source.d.ts.map +1 -1
  259. package/dist/commonjs/main_thread/init/utils/create_media_source.js +2 -3
  260. package/dist/commonjs/main_thread/init/utils/get_initial_time.js +1 -1
  261. package/dist/commonjs/main_thread/init/utils/get_loaded_reference.d.ts +2 -1
  262. package/dist/commonjs/main_thread/init/utils/get_loaded_reference.d.ts.map +1 -1
  263. package/dist/commonjs/main_thread/init/utils/get_loaded_reference.js +1 -1
  264. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts +2 -1
  265. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  266. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +1 -1
  267. package/dist/commonjs/main_thread/init/utils/initialize_content_decryption.d.ts +17 -6
  268. package/dist/commonjs/main_thread/init/utils/initialize_content_decryption.d.ts.map +1 -1
  269. package/dist/commonjs/main_thread/init/utils/initialize_content_decryption.js +17 -22
  270. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts +2 -1
  271. package/dist/commonjs/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts.map +1 -1
  272. package/dist/commonjs/main_thread/init/utils/throw_on_media_error.d.ts +2 -1
  273. package/dist/commonjs/main_thread/init/utils/throw_on_media_error.d.ts.map +1 -1
  274. package/dist/commonjs/main_thread/init/utils/throw_on_media_error.js +1 -1
  275. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts +33 -0
  276. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -0
  277. package/dist/commonjs/main_thread/init/utils/update_manifest_codec_support.js +224 -0
  278. package/dist/commonjs/main_thread/text_displayer/html/html_parsers.js +1 -1
  279. package/dist/commonjs/main_thread/text_displayer/html/html_text_displayer.d.ts +2 -1
  280. package/dist/commonjs/main_thread/text_displayer/html/html_text_displayer.d.ts.map +1 -1
  281. package/dist/commonjs/main_thread/text_displayer/html/update_proportional_elements.js +1 -1
  282. package/dist/commonjs/main_thread/text_displayer/html/utils.js +5 -6
  283. package/dist/commonjs/main_thread/text_displayer/native/native_parsers.js +1 -1
  284. package/dist/commonjs/main_thread/text_displayer/native/native_text_displayer.d.ts +2 -1
  285. package/dist/commonjs/main_thread/text_displayer/native/native_text_displayer.d.ts.map +1 -1
  286. package/dist/commonjs/main_thread/tracks_store/media_element_tracks_store.d.ts +6 -1
  287. package/dist/commonjs/main_thread/tracks_store/media_element_tracks_store.d.ts.map +1 -1
  288. package/dist/commonjs/main_thread/tracks_store/track_dispatcher.d.ts +5 -2
  289. package/dist/commonjs/main_thread/tracks_store/track_dispatcher.d.ts.map +1 -1
  290. package/dist/commonjs/main_thread/tracks_store/track_dispatcher.js +7 -26
  291. package/dist/commonjs/main_thread/tracks_store/tracks_store.d.ts +49 -25
  292. package/dist/commonjs/main_thread/tracks_store/tracks_store.d.ts.map +1 -1
  293. package/dist/commonjs/main_thread/tracks_store/tracks_store.js +263 -103
  294. package/dist/commonjs/manifest/classes/adaptation.d.ts +9 -9
  295. package/dist/commonjs/manifest/classes/adaptation.d.ts.map +1 -1
  296. package/dist/commonjs/manifest/classes/adaptation.js +50 -24
  297. package/dist/commonjs/manifest/classes/codec_support_cache.d.ts +45 -0
  298. package/dist/commonjs/manifest/classes/codec_support_cache.d.ts.map +1 -0
  299. package/dist/commonjs/manifest/classes/codec_support_cache.js +84 -0
  300. package/dist/commonjs/manifest/classes/index.d.ts +2 -2
  301. package/dist/commonjs/manifest/classes/index.d.ts.map +1 -1
  302. package/dist/commonjs/manifest/classes/manifest.d.ts +28 -6
  303. package/dist/commonjs/manifest/classes/manifest.d.ts.map +1 -1
  304. package/dist/commonjs/manifest/classes/manifest.js +46 -7
  305. package/dist/commonjs/manifest/classes/period.d.ts +6 -7
  306. package/dist/commonjs/manifest/classes/period.d.ts.map +1 -1
  307. package/dist/commonjs/manifest/classes/period.js +23 -14
  308. package/dist/commonjs/manifest/classes/representation.d.ts +10 -11
  309. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  310. package/dist/commonjs/manifest/classes/representation.js +64 -68
  311. package/dist/commonjs/manifest/classes/update_period_in_place.js +1 -1
  312. package/dist/commonjs/manifest/classes/update_periods.js +2 -3
  313. package/dist/commonjs/manifest/classes/utils.js +2 -3
  314. package/dist/commonjs/manifest/index.d.ts +2 -2
  315. package/dist/commonjs/manifest/types.d.ts +32 -5
  316. package/dist/commonjs/manifest/types.d.ts.map +1 -1
  317. package/dist/commonjs/manifest/utils.d.ts +1 -1
  318. package/dist/commonjs/manifest/utils.d.ts.map +1 -1
  319. package/dist/commonjs/manifest/utils.js +36 -20
  320. package/dist/commonjs/minimal.d.ts.map +1 -1
  321. package/dist/commonjs/minimal.js +2 -8
  322. package/dist/commonjs/mse/index.d.ts +1 -1
  323. package/dist/commonjs/mse/index.d.ts.map +1 -1
  324. package/dist/commonjs/mse/main_media_source_interface.d.ts +2 -1
  325. package/dist/commonjs/mse/main_media_source_interface.d.ts.map +1 -1
  326. package/dist/commonjs/mse/main_media_source_interface.js +5 -4
  327. package/dist/commonjs/mse/types.d.ts +0 -29
  328. package/dist/commonjs/mse/types.d.ts.map +1 -1
  329. package/dist/commonjs/mse/utils/end_of_stream.d.ts +3 -2
  330. package/dist/commonjs/mse/utils/end_of_stream.d.ts.map +1 -1
  331. package/dist/commonjs/mse/utils/end_of_stream.js +2 -3
  332. package/dist/commonjs/mse/utils/media_source_duration_updater.d.ts +2 -1
  333. package/dist/commonjs/mse/utils/media_source_duration_updater.d.ts.map +1 -1
  334. package/dist/commonjs/multithread_types.d.ts +26 -14
  335. package/dist/commonjs/multithread_types.d.ts.map +1 -1
  336. package/dist/commonjs/parsers/containers/isobmff/create_box.js +2 -3
  337. package/dist/commonjs/parsers/containers/isobmff/drm/playready.js +1 -2
  338. package/dist/commonjs/parsers/containers/isobmff/extract_complete_chunks.js +1 -1
  339. package/dist/commonjs/parsers/containers/isobmff/find_complete_box.js +1 -1
  340. package/dist/commonjs/parsers/containers/isobmff/get_box.js +7 -8
  341. package/dist/commonjs/parsers/containers/isobmff/read.js +5 -6
  342. package/dist/commonjs/parsers/containers/isobmff/take_pssh_out.js +2 -3
  343. package/dist/commonjs/parsers/containers/isobmff/utils.js +9 -9
  344. package/dist/commonjs/parsers/containers/matroska/utils.js +2 -3
  345. package/dist/commonjs/parsers/manifest/dash/common/convert_supplemental_codecs.js +1 -2
  346. package/dist/commonjs/parsers/manifest/dash/common/flatten_overlapping_periods.js +1 -1
  347. package/dist/commonjs/parsers/manifest/dash/common/get_clock_offset.js +1 -1
  348. package/dist/commonjs/parsers/manifest/dash/common/get_hdr_information.js +1 -2
  349. package/dist/commonjs/parsers/manifest/dash/common/get_http_utc-timing_url.js +1 -1
  350. package/dist/commonjs/parsers/manifest/dash/common/get_minimum_and_maximum_positions.js +1 -1
  351. package/dist/commonjs/parsers/manifest/dash/common/get_periods_time_infos.js +1 -1
  352. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_init_segment.js +1 -1
  353. package/dist/commonjs/parsers/manifest/dash/common/indexes/get_segments_from_timeline.js +1 -1
  354. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.d.ts.map +1 -1
  355. package/dist/commonjs/parsers/manifest/dash/common/indexes/template.js +1 -1
  356. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_elements.js +1 -1
  357. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/construct_timeline_from_previous_timeline.js +1 -1
  358. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/convert_element_to_index_segment.js +1 -1
  359. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/find_first_common_start_time.js +1 -1
  360. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/parse_s_element.js +2 -3
  361. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts.map +1 -1
  362. package/dist/commonjs/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +4 -4
  363. package/dist/commonjs/parsers/manifest/dash/common/indexes/tokens.js +3 -4
  364. package/dist/commonjs/parsers/manifest/dash/common/indexes/utils.js +1 -2
  365. package/dist/commonjs/parsers/manifest/dash/common/infer_adaptation_type.js +1 -1
  366. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +6 -2
  367. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts.map +1 -1
  368. package/dist/commonjs/parsers/manifest/dash/common/manifest_bounds_calculator.js +7 -3
  369. package/dist/commonjs/parsers/manifest/dash/common/parse_adaptation_sets.js +1 -1
  370. package/dist/commonjs/parsers/manifest/dash/common/parse_availability_start_time.js +1 -1
  371. package/dist/commonjs/parsers/manifest/dash/common/parse_mpd.js +16 -2
  372. package/dist/commonjs/parsers/manifest/dash/common/parse_periods.js +1 -1
  373. package/dist/commonjs/parsers/manifest/dash/common/parse_representation_index.js +1 -1
  374. package/dist/commonjs/parsers/manifest/dash/common/parse_representations.js +1 -1
  375. package/dist/commonjs/parsers/manifest/dash/common/resolve_base_urls.js +1 -1
  376. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/AdaptationSet.js +1 -2
  377. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/BaseURL.js +1 -1
  378. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentComponent.js +1 -1
  379. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/ContentProtection.js +1 -1
  380. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/EventStream.js +1 -2
  381. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Initialization.js +1 -1
  382. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/MPD.js +1 -2
  383. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Period.js +1 -2
  384. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/Representation.js +1 -2
  385. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentBase.js +1 -1
  386. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentList.js +1 -1
  387. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTemplate.js +1 -1
  388. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentTimeline.js +1 -1
  389. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/SegmentURL.js +1 -1
  390. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts.map +1 -1
  391. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/node_parsers/utils.js +13 -13
  392. package/dist/commonjs/parsers/manifest/dash/fast-js-parser/parse_from_xml_string.js +1 -1
  393. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/AdaptationSet.js +1 -2
  394. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/BaseURL.js +1 -1
  395. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/ContentComponent.js +1 -1
  396. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/ContentProtection.js +1 -1
  397. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/EventStream.js +1 -1
  398. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Initialization.js +1 -1
  399. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/MPD.js +1 -2
  400. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Period.js +1 -2
  401. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/Representation.js +1 -2
  402. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentBase.js +1 -1
  403. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentList.js +1 -1
  404. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentTemplate.js +1 -1
  405. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentTimeline.js +1 -1
  406. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/SegmentURL.js +1 -1
  407. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts.map +1 -1
  408. package/dist/commonjs/parsers/manifest/dash/native-parser/node_parsers/utils.js +12 -12
  409. package/dist/commonjs/parsers/manifest/dash/native-parser/parse_from_document.js +1 -1
  410. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/AdaptationSet.js +2 -3
  411. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/BaseURL.js +1 -2
  412. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/ContentComponent.js +1 -2
  413. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/ContentProtection.js +1 -2
  414. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/EventStream.js +2 -3
  415. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/MPD.js +2 -3
  416. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Period.js +2 -3
  417. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Representation.js +2 -3
  418. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/Scheme.js +1 -2
  419. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentBase.js +1 -2
  420. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentList.js +1 -2
  421. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentTemplate.js +1 -2
  422. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/SegmentUrl.js +1 -2
  423. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/XLink.js +1 -2
  424. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/generators/root.js +1 -2
  425. package/dist/commonjs/parsers/manifest/dash/wasm-parser/ts/utils.js +2 -3
  426. package/dist/commonjs/parsers/manifest/local/parse_local_manifest.js +1 -1
  427. package/dist/commonjs/parsers/manifest/metaplaylist/metaplaylist_parser.js +1 -1
  428. package/dist/commonjs/parsers/manifest/smooth/get_codecs.js +2 -3
  429. package/dist/commonjs/parsers/manifest/smooth/parse_C_nodes.js +1 -1
  430. package/dist/commonjs/parsers/manifest/smooth/parse_protection_node.js +1 -1
  431. package/dist/commonjs/parsers/manifest/smooth/utils/add_segment_infos.js +1 -1
  432. package/dist/commonjs/parsers/manifest/smooth/utils/parseBoolean.js +1 -1
  433. package/dist/commonjs/parsers/manifest/smooth/utils/reduceChildren.js +1 -1
  434. package/dist/commonjs/parsers/manifest/smooth/utils/tokens.js +2 -3
  435. package/dist/commonjs/parsers/manifest/utils/check_manifest_ids.js +1 -1
  436. package/dist/commonjs/parsers/manifest/utils/clear_timeline_from_position.js +1 -1
  437. package/dist/commonjs/parsers/manifest/utils/get_first_time_from_adaptation.js +1 -1
  438. package/dist/commonjs/parsers/manifest/utils/get_last_time_from_adaptation.js +1 -1
  439. package/dist/commonjs/parsers/manifest/utils/get_maximum_positions.js +1 -1
  440. package/dist/commonjs/parsers/manifest/utils/get_minimum_position.js +1 -1
  441. package/dist/commonjs/parsers/manifest/utils/index_helpers.js +6 -7
  442. package/dist/commonjs/parsers/manifest/utils/update_segment_timeline.js +1 -1
  443. package/dist/commonjs/parsers/texttracks/srt/find_end_of_cue_block.js +1 -1
  444. package/dist/commonjs/parsers/texttracks/srt/get_cue_blocks.js +1 -1
  445. package/dist/commonjs/parsers/texttracks/srt/html.js +1 -1
  446. package/dist/commonjs/parsers/texttracks/srt/native.js +1 -1
  447. package/dist/commonjs/parsers/texttracks/srt/parse_cue.js +1 -1
  448. package/dist/commonjs/parsers/texttracks/srt/parse_timestamp.js +1 -1
  449. package/dist/commonjs/parsers/texttracks/ttml/get_parameters.js +1 -1
  450. package/dist/commonjs/parsers/texttracks/ttml/get_styling.js +2 -3
  451. package/dist/commonjs/parsers/texttracks/ttml/get_time_delimiters.js +1 -1
  452. package/dist/commonjs/parsers/texttracks/ttml/html/apply_default_ttml_paragraph_style.js +2 -3
  453. package/dist/commonjs/parsers/texttracks/ttml/html/apply_extent.js +1 -1
  454. package/dist/commonjs/parsers/texttracks/ttml/html/apply_font_size.js +1 -1
  455. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +1 -1
  456. package/dist/commonjs/parsers/texttracks/ttml/html/apply_origin.js +1 -1
  457. package/dist/commonjs/parsers/texttracks/ttml/html/apply_padding.js +1 -1
  458. package/dist/commonjs/parsers/texttracks/ttml/html/create_element.js +1 -1
  459. package/dist/commonjs/parsers/texttracks/ttml/html/generate_css_test_outline.js +1 -1
  460. package/dist/commonjs/parsers/texttracks/ttml/html/parse_cue.js +1 -1
  461. package/dist/commonjs/parsers/texttracks/ttml/html/parse_ttml_to_div.js +1 -1
  462. package/dist/commonjs/parsers/texttracks/ttml/html/ttml_color_to_css_color.js +1 -1
  463. package/dist/commonjs/parsers/texttracks/ttml/native/parse_cue.js +1 -1
  464. package/dist/commonjs/parsers/texttracks/ttml/native/parse_ttml_to_vtt.js +1 -1
  465. package/dist/commonjs/parsers/texttracks/ttml/parse_ttml.js +1 -1
  466. package/dist/commonjs/parsers/texttracks/ttml/resolve_styles_inheritance.js +1 -1
  467. package/dist/commonjs/parsers/texttracks/ttml/xml_utils.js +9 -10
  468. package/dist/commonjs/parsers/texttracks/webvtt/get_cue_blocks.js +1 -1
  469. package/dist/commonjs/parsers/texttracks/webvtt/get_style_blocks.js +1 -1
  470. package/dist/commonjs/parsers/texttracks/webvtt/html/convert_payload_to_html.js +1 -1
  471. package/dist/commonjs/parsers/texttracks/webvtt/html/create_default_style_elements.js +1 -1
  472. package/dist/commonjs/parsers/texttracks/webvtt/html/create_style_attribute.js +1 -1
  473. package/dist/commonjs/parsers/texttracks/webvtt/html/create_styled_element.js +1 -1
  474. package/dist/commonjs/parsers/texttracks/webvtt/html/parse_style_block.js +1 -1
  475. package/dist/commonjs/parsers/texttracks/webvtt/html/parse_webvtt_to_div.js +1 -1
  476. package/dist/commonjs/parsers/texttracks/webvtt/html/to_html.js +1 -1
  477. package/dist/commonjs/parsers/texttracks/webvtt/native/parse_vtt_to_cues.js +1 -1
  478. package/dist/commonjs/parsers/texttracks/webvtt/native/set_settings_on_cue.js +1 -1
  479. package/dist/commonjs/parsers/texttracks/webvtt/native/to_native_cue.js +1 -1
  480. package/dist/commonjs/parsers/texttracks/webvtt/parse_cue_block.js +1 -1
  481. package/dist/commonjs/parsers/texttracks/webvtt/parse_timestamp.js +1 -1
  482. package/dist/commonjs/parsers/texttracks/webvtt/utils.js +6 -7
  483. package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts +2 -1
  484. package/dist/commonjs/playback_observer/media_element_playback_observer.d.ts.map +1 -1
  485. package/dist/commonjs/playback_observer/media_element_playback_observer.js +3 -5
  486. package/dist/commonjs/playback_observer/utils/generate_read_only_observer.js +1 -1
  487. package/dist/commonjs/public_types.d.ts +77 -0
  488. package/dist/commonjs/public_types.d.ts.map +1 -1
  489. package/dist/commonjs/tools/TextTrackRenderer/text_track_renderer.d.ts.map +1 -1
  490. package/dist/commonjs/tools/parseBIFThumbnails/index.js +1 -1
  491. package/dist/commonjs/transports/dash/construct_segment_url.js +1 -1
  492. package/dist/commonjs/transports/dash/get_events_out_of_emsgs.js +1 -1
  493. package/dist/commonjs/transports/dash/init_segment_loader.d.ts +2 -2
  494. package/dist/commonjs/transports/dash/init_segment_loader.d.ts.map +1 -1
  495. package/dist/commonjs/transports/dash/init_segment_loader.js +26 -7
  496. package/dist/commonjs/transports/dash/integrity_checks.d.ts +18 -0
  497. package/dist/commonjs/transports/dash/integrity_checks.d.ts.map +1 -0
  498. package/dist/commonjs/transports/dash/integrity_checks.js +209 -0
  499. package/dist/commonjs/transports/dash/{low_latency_segment_loader.d.ts → load_chunked_segment_data.d.ts} +14 -5
  500. package/dist/commonjs/transports/dash/load_chunked_segment_data.d.ts.map +1 -0
  501. package/dist/commonjs/transports/dash/load_chunked_segment_data.js +126 -0
  502. package/dist/commonjs/transports/dash/manifest_parser.js +1 -1
  503. package/dist/commonjs/transports/dash/pipelines.d.ts.map +1 -1
  504. package/dist/commonjs/transports/dash/pipelines.js +4 -2
  505. package/dist/commonjs/transports/dash/segment_loader.d.ts +2 -2
  506. package/dist/commonjs/transports/dash/segment_loader.d.ts.map +1 -1
  507. package/dist/commonjs/transports/dash/segment_loader.js +105 -31
  508. package/dist/commonjs/transports/dash/segment_parser.js +1 -1
  509. package/dist/commonjs/transports/dash/text_loader.d.ts.map +1 -1
  510. package/dist/commonjs/transports/dash/text_loader.js +122 -46
  511. package/dist/commonjs/transports/dash/text_parser.js +1 -1
  512. package/dist/commonjs/transports/local/pipelines.d.ts.map +1 -1
  513. package/dist/commonjs/transports/local/pipelines.js +2 -1
  514. package/dist/commonjs/transports/local/segment_loader.js +1 -1
  515. package/dist/commonjs/transports/local/segment_parser.js +1 -1
  516. package/dist/commonjs/transports/local/text_parser.js +1 -1
  517. package/dist/commonjs/transports/metaplaylist/manifest_loader.d.ts.map +1 -1
  518. package/dist/commonjs/transports/metaplaylist/manifest_loader.js +12 -4
  519. package/dist/commonjs/transports/metaplaylist/pipelines.d.ts.map +1 -1
  520. package/dist/commonjs/transports/metaplaylist/pipelines.js +3 -1
  521. package/dist/commonjs/transports/smooth/extract_timings_infos.js +1 -1
  522. package/dist/commonjs/transports/smooth/is_mp4_embedded_track.js +1 -1
  523. package/dist/commonjs/transports/smooth/isobmff/create_audio_init_segment.js +1 -1
  524. package/dist/commonjs/transports/smooth/isobmff/create_boxes.js +23 -24
  525. package/dist/commonjs/transports/smooth/isobmff/create_init_segment.js +1 -1
  526. package/dist/commonjs/transports/smooth/isobmff/create_traf_box.js +1 -1
  527. package/dist/commonjs/transports/smooth/isobmff/create_video_init_segment.js +1 -1
  528. package/dist/commonjs/transports/smooth/isobmff/get_aaces_header.js +1 -1
  529. package/dist/commonjs/transports/smooth/isobmff/parse_tfrf.js +1 -1
  530. package/dist/commonjs/transports/smooth/isobmff/parse_tfxd.js +1 -1
  531. package/dist/commonjs/transports/smooth/isobmff/patch_segment.js +1 -1
  532. package/dist/commonjs/transports/smooth/pipelines.d.ts.map +1 -1
  533. package/dist/commonjs/transports/smooth/pipelines.js +17 -4
  534. package/dist/commonjs/transports/smooth/segment_loader.d.ts.map +1 -1
  535. package/dist/commonjs/transports/smooth/segment_loader.js +82 -26
  536. package/dist/commonjs/transports/smooth/utils.js +2 -3
  537. package/dist/commonjs/transports/types.d.ts +17 -1
  538. package/dist/commonjs/transports/types.d.ts.map +1 -1
  539. package/dist/commonjs/transports/utils/add_query_string.d.ts +13 -0
  540. package/dist/commonjs/transports/utils/add_query_string.d.ts.map +1 -0
  541. package/dist/commonjs/transports/utils/add_query_string.js +54 -0
  542. package/dist/commonjs/transports/utils/byte_range.js +1 -1
  543. package/dist/commonjs/transports/utils/call_custom_manifest_loader.js +3 -3
  544. package/dist/commonjs/transports/utils/check_isobmff_integrity.js +1 -1
  545. package/dist/commonjs/transports/utils/generate_manifest_loader.d.ts +4 -4
  546. package/dist/commonjs/transports/utils/generate_manifest_loader.d.ts.map +1 -1
  547. package/dist/commonjs/transports/utils/generate_manifest_loader.js +20 -8
  548. package/dist/commonjs/transports/utils/get_isobmff_timing_infos.js +1 -1
  549. package/dist/commonjs/transports/utils/infer_segment_container.js +1 -1
  550. package/dist/commonjs/transports/utils/parse_text_track.js +5 -6
  551. package/dist/commonjs/utils/are_arrays_of_numbers_equal.js +1 -1
  552. package/dist/commonjs/utils/are_codecs_compatible.d.ts +4 -0
  553. package/dist/commonjs/utils/are_codecs_compatible.d.ts.map +1 -1
  554. package/dist/commonjs/utils/are_codecs_compatible.js +18 -8
  555. package/dist/commonjs/utils/array_find.js +1 -1
  556. package/dist/commonjs/utils/array_find_index.js +1 -1
  557. package/dist/commonjs/utils/array_includes.js +1 -1
  558. package/dist/commonjs/utils/assert.js +4 -4
  559. package/dist/commonjs/utils/base64.js +2 -3
  560. package/dist/commonjs/utils/byte_parsing.js +15 -16
  561. package/dist/commonjs/utils/cancellable_sleep.js +1 -1
  562. package/dist/commonjs/utils/create_cancellable_promise.js +1 -1
  563. package/dist/commonjs/utils/create_uuid.d.ts +9 -0
  564. package/dist/commonjs/utils/create_uuid.d.ts.map +1 -0
  565. package/dist/commonjs/utils/create_uuid.js +32 -0
  566. package/dist/commonjs/utils/deep_merge.js +1 -1
  567. package/dist/commonjs/utils/flat_map.js +1 -1
  568. package/dist/commonjs/utils/get_fuzzed_delay.js +1 -1
  569. package/dist/commonjs/utils/hash_buffer.js +1 -1
  570. package/dist/commonjs/utils/id_generator.js +1 -1
  571. package/dist/commonjs/utils/is_non_empty_string.js +1 -1
  572. package/dist/commonjs/utils/is_null_or_undefined.js +1 -1
  573. package/dist/commonjs/utils/languages/normalize.js +2 -3
  574. package/dist/commonjs/utils/logger.d.ts +21 -4
  575. package/dist/commonjs/utils/logger.d.ts.map +1 -1
  576. package/dist/commonjs/utils/logger.js +106 -36
  577. package/dist/commonjs/utils/monotonic_timestamp.js +1 -2
  578. package/dist/commonjs/utils/noop.js +1 -1
  579. package/dist/commonjs/utils/object_values.js +1 -2
  580. package/dist/commonjs/utils/ranges.js +22 -23
  581. package/dist/commonjs/utils/reference.js +1 -2
  582. package/dist/commonjs/utils/request/fetch.d.ts +2 -4
  583. package/dist/commonjs/utils/request/fetch.d.ts.map +1 -1
  584. package/dist/commonjs/utils/request/fetch.js +2 -3
  585. package/dist/commonjs/utils/request/xhr.d.ts +1 -3
  586. package/dist/commonjs/utils/request/xhr.d.ts.map +1 -1
  587. package/dist/commonjs/utils/request/xhr.js +1 -1
  588. package/dist/commonjs/utils/resolve_url.js +2 -3
  589. package/dist/commonjs/utils/retry_promise_with_backoff.js +2 -3
  590. package/dist/commonjs/utils/sleep.js +1 -1
  591. package/dist/commonjs/utils/starts_with.js +1 -1
  592. package/dist/commonjs/utils/string_parsing.js +10 -11
  593. package/dist/commonjs/utils/sync_or_async.d.ts +1 -1
  594. package/dist/commonjs/utils/sync_or_async.d.ts.map +1 -1
  595. package/dist/commonjs/utils/warn_once.js +1 -1
  596. package/dist/commonjs/utils/weak_map_memory.js +1 -1
  597. package/dist/commonjs/utils/wrapInPromise.js +1 -1
  598. package/dist/commonjs/utils/xml-parser.js +5 -6
  599. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  600. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  601. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  602. package/dist/es2017/compat/add_text_track.d.ts +2 -2
  603. package/dist/es2017/compat/add_text_track.d.ts.map +1 -1
  604. package/dist/es2017/compat/browser_compatibility_types.d.ts +196 -13
  605. package/dist/es2017/compat/browser_compatibility_types.d.ts.map +1 -1
  606. package/dist/es2017/compat/browser_compatibility_types.js +29 -0
  607. package/dist/es2017/compat/clear_element_src.d.ts +2 -1
  608. package/dist/es2017/compat/clear_element_src.d.ts.map +1 -1
  609. package/dist/es2017/compat/eme/custom_media_keys/ie11_media_keys.d.ts +3 -2
  610. package/dist/es2017/compat/eme/custom_media_keys/ie11_media_keys.d.ts.map +1 -1
  611. package/dist/es2017/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts +2 -1
  612. package/dist/es2017/compat/eme/custom_media_keys/moz_media_keys_constructor.d.ts.map +1 -1
  613. package/dist/es2017/compat/eme/custom_media_keys/moz_media_keys_constructor.js +1 -2
  614. package/dist/es2017/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts +3 -2
  615. package/dist/es2017/compat/eme/custom_media_keys/old_webkit_media_keys.d.ts.map +1 -1
  616. package/dist/es2017/compat/eme/custom_media_keys/types.d.ts +5 -1
  617. package/dist/es2017/compat/eme/custom_media_keys/types.d.ts.map +1 -1
  618. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.d.ts +4 -3
  619. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.d.ts.map +1 -1
  620. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys.js +2 -3
  621. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys_constructor.d.ts.map +1 -1
  622. package/dist/es2017/compat/eme/custom_media_keys/webkit_media_keys_constructor.js +1 -2
  623. package/dist/es2017/compat/eme/eme-api-implementation.d.ts +4 -3
  624. package/dist/es2017/compat/eme/eme-api-implementation.d.ts.map +1 -1
  625. package/dist/es2017/compat/eme/eme-api-implementation.js +19 -5
  626. package/dist/es2017/compat/eme/get_init_data.d.ts +3 -1
  627. package/dist/es2017/compat/eme/get_init_data.d.ts.map +1 -1
  628. package/dist/es2017/compat/eme/get_init_data.js +2 -2
  629. package/dist/es2017/compat/eme/set_media_keys.d.ts +2 -1
  630. package/dist/es2017/compat/eme/set_media_keys.d.ts.map +1 -1
  631. package/dist/es2017/compat/event_listeners.d.ts +26 -24
  632. package/dist/es2017/compat/event_listeners.d.ts.map +1 -1
  633. package/dist/es2017/compat/event_listeners.js +2 -14
  634. package/dist/es2017/compat/get_start_date.d.ts +2 -1
  635. package/dist/es2017/compat/get_start_date.d.ts.map +1 -1
  636. package/dist/es2017/config.d.ts +1 -1
  637. package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts +121 -0
  638. package/dist/es2017/core/cmcd/cmcd_data_builder.d.ts.map +1 -0
  639. package/dist/es2017/core/cmcd/cmcd_data_builder.js +313 -0
  640. package/dist/es2017/core/cmcd/index.d.ts +4 -0
  641. package/dist/es2017/core/cmcd/index.d.ts.map +1 -0
  642. package/dist/es2017/core/cmcd/index.js +2 -0
  643. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts +8 -0
  644. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.d.ts.map +1 -1
  645. package/dist/es2017/core/fetchers/manifest/manifest_fetcher.js +7 -2
  646. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts +43 -23
  647. package/dist/es2017/core/fetchers/segment/segment_fetcher.d.ts.map +1 -1
  648. package/dist/es2017/core/fetchers/segment/segment_fetcher.js +21 -33
  649. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts +5 -3
  650. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.d.ts.map +1 -1
  651. package/dist/es2017/core/fetchers/segment/segment_fetcher_creator.js +14 -6
  652. package/dist/es2017/core/main/worker/content_preparer.d.ts +7 -0
  653. package/dist/es2017/core/main/worker/content_preparer.d.ts.map +1 -1
  654. package/dist/es2017/core/main/worker/content_preparer.js +5 -2
  655. package/dist/es2017/core/main/worker/worker_main.d.ts.map +1 -1
  656. package/dist/es2017/core/main/worker/worker_main.js +19 -18
  657. package/dist/es2017/default_config.d.ts +1 -1
  658. package/dist/es2017/default_config.d.ts.map +1 -1
  659. package/dist/es2017/default_config.js +1 -0
  660. package/dist/es2017/experimental/features/local.d.ts.map +1 -1
  661. package/dist/es2017/experimental/features/local.js +0 -2
  662. package/dist/es2017/experimental/features/metaplaylist.d.ts.map +1 -1
  663. package/dist/es2017/experimental/features/metaplaylist.js +0 -2
  664. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts +2 -1
  665. package/dist/es2017/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.d.ts.map +1 -1
  666. package/dist/es2017/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts +2 -1
  667. package/dist/es2017/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.d.ts.map +1 -1
  668. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.d.ts.map +1 -1
  669. package/dist/es2017/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +14 -8
  670. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/index.d.ts.map +1 -1
  671. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/api/index.js +1 -1
  672. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.d.ts.map +1 -1
  673. package/dist/es2017/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.js +1 -0
  674. package/dist/es2017/features/features_object.d.ts.map +1 -1
  675. package/dist/es2017/features/features_object.js +0 -1
  676. package/dist/es2017/features/list/dash.d.ts.map +1 -1
  677. package/dist/es2017/features/list/dash.js +0 -2
  678. package/dist/es2017/features/list/dash_wasm.d.ts.map +1 -1
  679. package/dist/es2017/features/list/dash_wasm.js +0 -2
  680. package/dist/es2017/features/list/smooth.d.ts.map +1 -1
  681. package/dist/es2017/features/list/smooth.js +0 -2
  682. package/dist/es2017/features/types.d.ts +3 -11
  683. package/dist/es2017/features/types.d.ts.map +1 -1
  684. package/dist/es2017/index.js +2 -2
  685. package/dist/es2017/main_thread/api/option_utils.d.ts +9 -2
  686. package/dist/es2017/main_thread/api/option_utils.d.ts.map +1 -1
  687. package/dist/es2017/main_thread/api/option_utils.js +4 -5
  688. package/dist/es2017/main_thread/api/public_api.d.ts +23 -2
  689. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  690. package/dist/es2017/main_thread/api/public_api.js +43 -11
  691. package/dist/es2017/main_thread/api/utils.d.ts +5 -4
  692. package/dist/es2017/main_thread/api/utils.d.ts.map +1 -1
  693. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts +3 -2
  694. package/dist/es2017/main_thread/decrypt/attach_media_keys.d.ts.map +1 -1
  695. package/dist/es2017/main_thread/decrypt/clear_on_stop.d.ts +2 -1
  696. package/dist/es2017/main_thread/decrypt/clear_on_stop.d.ts.map +1 -1
  697. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts +26 -1
  698. package/dist/es2017/main_thread/decrypt/content_decryptor.d.ts.map +1 -1
  699. package/dist/es2017/main_thread/decrypt/content_decryptor.js +70 -0
  700. package/dist/es2017/main_thread/decrypt/dispose_decryption_resources.d.ts +2 -1
  701. package/dist/es2017/main_thread/decrypt/dispose_decryption_resources.d.ts.map +1 -1
  702. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts +17 -2
  703. package/dist/es2017/main_thread/decrypt/find_key_system.d.ts.map +1 -1
  704. package/dist/es2017/main_thread/decrypt/find_key_system.js +48 -0
  705. package/dist/es2017/main_thread/decrypt/get_key_system_configuration.d.ts +2 -1
  706. package/dist/es2017/main_thread/decrypt/get_key_system_configuration.d.ts.map +1 -1
  707. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts +5 -1
  708. package/dist/es2017/main_thread/decrypt/get_media_keys.d.ts.map +1 -1
  709. package/dist/es2017/main_thread/decrypt/get_media_keys.js +3 -1
  710. package/dist/es2017/main_thread/decrypt/init_media_keys.d.ts +2 -1
  711. package/dist/es2017/main_thread/decrypt/init_media_keys.d.ts.map +1 -1
  712. package/dist/es2017/main_thread/decrypt/types.d.ts +1 -0
  713. package/dist/es2017/main_thread/decrypt/types.d.ts.map +1 -1
  714. package/dist/es2017/main_thread/decrypt/utils/is_compatible_codec_supported.d.ts +14 -0
  715. package/dist/es2017/main_thread/decrypt/utils/is_compatible_codec_supported.d.ts.map +1 -0
  716. package/dist/es2017/main_thread/decrypt/utils/is_compatible_codec_supported.js +28 -0
  717. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts +4 -3
  718. package/dist/es2017/main_thread/decrypt/utils/media_keys_infos_store.d.ts.map +1 -1
  719. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts +6 -1
  720. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  721. package/dist/es2017/main_thread/init/directfile_content_initializer.js +1 -12
  722. package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts +62 -4
  723. package/dist/es2017/main_thread/init/media_source_content_initializer.d.ts.map +1 -1
  724. package/dist/es2017/main_thread/init/media_source_content_initializer.js +142 -19
  725. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts +46 -4
  726. package/dist/es2017/main_thread/init/multi_thread_content_initializer.d.ts.map +1 -1
  727. package/dist/es2017/main_thread/init/multi_thread_content_initializer.js +67 -133
  728. package/dist/es2017/main_thread/init/types.d.ts +6 -1
  729. package/dist/es2017/main_thread/init/types.d.ts.map +1 -1
  730. package/dist/es2017/main_thread/init/utils/create_media_source.d.ts +3 -2
  731. package/dist/es2017/main_thread/init/utils/create_media_source.d.ts.map +1 -1
  732. package/dist/es2017/main_thread/init/utils/get_loaded_reference.d.ts +2 -1
  733. package/dist/es2017/main_thread/init/utils/get_loaded_reference.d.ts.map +1 -1
  734. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts +2 -1
  735. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  736. package/dist/es2017/main_thread/init/utils/initialize_content_decryption.d.ts +17 -6
  737. package/dist/es2017/main_thread/init/utils/initialize_content_decryption.d.ts.map +1 -1
  738. package/dist/es2017/main_thread/init/utils/initialize_content_decryption.js +16 -21
  739. package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts +2 -1
  740. package/dist/es2017/main_thread/init/utils/stream_events_emitter/stream_events_emitter.d.ts.map +1 -1
  741. package/dist/es2017/main_thread/init/utils/throw_on_media_error.d.ts +2 -1
  742. package/dist/es2017/main_thread/init/utils/throw_on_media_error.d.ts.map +1 -1
  743. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts +33 -0
  744. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.d.ts.map +1 -0
  745. package/dist/es2017/main_thread/init/utils/update_manifest_codec_support.js +149 -0
  746. package/dist/es2017/main_thread/text_displayer/html/html_text_displayer.d.ts +2 -1
  747. package/dist/es2017/main_thread/text_displayer/html/html_text_displayer.d.ts.map +1 -1
  748. package/dist/es2017/main_thread/text_displayer/native/native_text_displayer.d.ts +2 -1
  749. package/dist/es2017/main_thread/text_displayer/native/native_text_displayer.d.ts.map +1 -1
  750. package/dist/es2017/main_thread/tracks_store/media_element_tracks_store.d.ts +6 -1
  751. package/dist/es2017/main_thread/tracks_store/media_element_tracks_store.d.ts.map +1 -1
  752. package/dist/es2017/main_thread/tracks_store/track_dispatcher.d.ts +5 -2
  753. package/dist/es2017/main_thread/tracks_store/track_dispatcher.d.ts.map +1 -1
  754. package/dist/es2017/main_thread/tracks_store/track_dispatcher.js +7 -26
  755. package/dist/es2017/main_thread/tracks_store/tracks_store.d.ts +49 -25
  756. package/dist/es2017/main_thread/tracks_store/tracks_store.d.ts.map +1 -1
  757. package/dist/es2017/main_thread/tracks_store/tracks_store.js +221 -98
  758. package/dist/es2017/manifest/classes/adaptation.d.ts +9 -9
  759. package/dist/es2017/manifest/classes/adaptation.d.ts.map +1 -1
  760. package/dist/es2017/manifest/classes/adaptation.js +50 -24
  761. package/dist/es2017/manifest/classes/codec_support_cache.d.ts +45 -0
  762. package/dist/es2017/manifest/classes/codec_support_cache.d.ts.map +1 -0
  763. package/dist/es2017/manifest/classes/codec_support_cache.js +58 -0
  764. package/dist/es2017/manifest/classes/index.d.ts +2 -2
  765. package/dist/es2017/manifest/classes/index.d.ts.map +1 -1
  766. package/dist/es2017/manifest/classes/manifest.d.ts +28 -6
  767. package/dist/es2017/manifest/classes/manifest.d.ts.map +1 -1
  768. package/dist/es2017/manifest/classes/manifest.js +45 -7
  769. package/dist/es2017/manifest/classes/period.d.ts +6 -7
  770. package/dist/es2017/manifest/classes/period.d.ts.map +1 -1
  771. package/dist/es2017/manifest/classes/period.js +23 -14
  772. package/dist/es2017/manifest/classes/representation.d.ts +10 -11
  773. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  774. package/dist/es2017/manifest/classes/representation.js +56 -60
  775. package/dist/es2017/manifest/index.d.ts +2 -2
  776. package/dist/es2017/manifest/types.d.ts +32 -5
  777. package/dist/es2017/manifest/types.d.ts.map +1 -1
  778. package/dist/es2017/manifest/utils.d.ts +1 -1
  779. package/dist/es2017/manifest/utils.d.ts.map +1 -1
  780. package/dist/es2017/manifest/utils.js +19 -3
  781. package/dist/es2017/minimal.d.ts.map +1 -1
  782. package/dist/es2017/minimal.js +2 -8
  783. package/dist/es2017/mse/index.d.ts +1 -1
  784. package/dist/es2017/mse/index.d.ts.map +1 -1
  785. package/dist/es2017/mse/main_media_source_interface.d.ts +2 -1
  786. package/dist/es2017/mse/main_media_source_interface.d.ts.map +1 -1
  787. package/dist/es2017/mse/main_media_source_interface.js +5 -4
  788. package/dist/es2017/mse/types.d.ts +0 -29
  789. package/dist/es2017/mse/types.d.ts.map +1 -1
  790. package/dist/es2017/mse/utils/end_of_stream.d.ts +3 -2
  791. package/dist/es2017/mse/utils/end_of_stream.d.ts.map +1 -1
  792. package/dist/es2017/mse/utils/media_source_duration_updater.d.ts +2 -1
  793. package/dist/es2017/mse/utils/media_source_duration_updater.d.ts.map +1 -1
  794. package/dist/es2017/multithread_types.d.ts +26 -14
  795. package/dist/es2017/multithread_types.d.ts.map +1 -1
  796. package/dist/es2017/parsers/manifest/dash/common/indexes/template.d.ts.map +1 -1
  797. package/dist/es2017/parsers/manifest/dash/common/indexes/template.js +1 -1
  798. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.d.ts.map +1 -1
  799. package/dist/es2017/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.js +2 -1
  800. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts +6 -2
  801. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.d.ts.map +1 -1
  802. package/dist/es2017/parsers/manifest/dash/common/manifest_bounds_calculator.js +7 -3
  803. package/dist/es2017/parsers/manifest/dash/common/parse_mpd.js +15 -1
  804. package/dist/es2017/parsers/manifest/dash/fast-js-parser/node_parsers/utils.d.ts.map +1 -1
  805. package/dist/es2017/parsers/manifest/dash/native-parser/node_parsers/utils.d.ts.map +1 -1
  806. package/dist/es2017/playback_observer/media_element_playback_observer.d.ts +2 -1
  807. package/dist/es2017/playback_observer/media_element_playback_observer.d.ts.map +1 -1
  808. package/dist/es2017/playback_observer/media_element_playback_observer.js +3 -5
  809. package/dist/es2017/public_types.d.ts +77 -0
  810. package/dist/es2017/public_types.d.ts.map +1 -1
  811. package/dist/es2017/tools/TextTrackRenderer/text_track_renderer.d.ts.map +1 -1
  812. package/dist/es2017/transports/dash/init_segment_loader.d.ts +2 -2
  813. package/dist/es2017/transports/dash/init_segment_loader.d.ts.map +1 -1
  814. package/dist/es2017/transports/dash/init_segment_loader.js +14 -6
  815. package/dist/es2017/transports/dash/integrity_checks.d.ts +18 -0
  816. package/dist/es2017/transports/dash/integrity_checks.d.ts.map +1 -0
  817. package/dist/es2017/transports/dash/integrity_checks.js +150 -0
  818. package/dist/es2017/transports/dash/{low_latency_segment_loader.d.ts → load_chunked_segment_data.d.ts} +14 -5
  819. package/dist/es2017/transports/dash/load_chunked_segment_data.d.ts.map +1 -0
  820. package/dist/es2017/transports/dash/{low_latency_segment_loader.js → load_chunked_segment_data.js} +15 -12
  821. package/dist/es2017/transports/dash/pipelines.d.ts.map +1 -1
  822. package/dist/es2017/transports/dash/pipelines.js +3 -1
  823. package/dist/es2017/transports/dash/segment_loader.d.ts +2 -2
  824. package/dist/es2017/transports/dash/segment_loader.d.ts.map +1 -1
  825. package/dist/es2017/transports/dash/segment_loader.js +29 -10
  826. package/dist/es2017/transports/dash/text_loader.d.ts.map +1 -1
  827. package/dist/es2017/transports/dash/text_loader.js +40 -20
  828. package/dist/es2017/transports/local/pipelines.d.ts.map +1 -1
  829. package/dist/es2017/transports/local/pipelines.js +1 -0
  830. package/dist/es2017/transports/metaplaylist/manifest_loader.d.ts.map +1 -1
  831. package/dist/es2017/transports/metaplaylist/manifest_loader.js +11 -3
  832. package/dist/es2017/transports/metaplaylist/pipelines.d.ts.map +1 -1
  833. package/dist/es2017/transports/metaplaylist/pipelines.js +2 -0
  834. package/dist/es2017/transports/smooth/pipelines.d.ts.map +1 -1
  835. package/dist/es2017/transports/smooth/pipelines.js +16 -3
  836. package/dist/es2017/transports/smooth/segment_loader.d.ts.map +1 -1
  837. package/dist/es2017/transports/smooth/segment_loader.js +27 -16
  838. package/dist/es2017/transports/types.d.ts +17 -1
  839. package/dist/es2017/transports/types.d.ts.map +1 -1
  840. package/dist/es2017/transports/utils/add_query_string.d.ts +13 -0
  841. package/dist/es2017/transports/utils/add_query_string.d.ts.map +1 -0
  842. package/dist/es2017/transports/utils/add_query_string.js +51 -0
  843. package/dist/es2017/transports/utils/call_custom_manifest_loader.js +2 -2
  844. package/dist/es2017/transports/utils/generate_manifest_loader.d.ts +4 -4
  845. package/dist/es2017/transports/utils/generate_manifest_loader.d.ts.map +1 -1
  846. package/dist/es2017/transports/utils/generate_manifest_loader.js +19 -7
  847. package/dist/es2017/utils/are_codecs_compatible.d.ts +4 -0
  848. package/dist/es2017/utils/are_codecs_compatible.d.ts.map +1 -1
  849. package/dist/es2017/utils/are_codecs_compatible.js +17 -8
  850. package/dist/es2017/utils/create_uuid.d.ts +9 -0
  851. package/dist/es2017/utils/create_uuid.d.ts.map +1 -0
  852. package/dist/es2017/utils/create_uuid.js +29 -0
  853. package/dist/es2017/utils/logger.d.ts +21 -4
  854. package/dist/es2017/utils/logger.d.ts.map +1 -1
  855. package/dist/es2017/utils/logger.js +73 -13
  856. package/dist/es2017/utils/request/fetch.d.ts +2 -4
  857. package/dist/es2017/utils/request/fetch.d.ts.map +1 -1
  858. package/dist/es2017/utils/request/xhr.d.ts +1 -3
  859. package/dist/es2017/utils/request/xhr.d.ts.map +1 -1
  860. package/dist/es2017/utils/sync_or_async.d.ts +1 -1
  861. package/dist/es2017/utils/sync_or_async.d.ts.map +1 -1
  862. package/dist/es2017/utils/weak_map_memory.js +1 -1
  863. package/dist/mpd-parser.wasm +0 -0
  864. package/dist/rx-player.js +18 -17
  865. package/dist/worker.js +6 -5
  866. package/package.json +31 -35
  867. package/src/README.md +23 -20
  868. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  869. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  870. package/src/compat/__tests__/add_text_track.test.ts +4 -3
  871. package/src/compat/__tests__/change_source_buffer_type.test.ts +4 -3
  872. package/src/compat/add_text_track.ts +2 -2
  873. package/src/compat/browser_compatibility_types.ts +247 -13
  874. package/src/compat/clear_element_src.ts +2 -1
  875. package/src/compat/eme/custom_media_keys/ie11_media_keys.ts +6 -6
  876. package/src/compat/eme/custom_media_keys/moz_media_keys_constructor.ts +3 -4
  877. package/src/compat/eme/custom_media_keys/old_webkit_media_keys.ts +4 -5
  878. package/src/compat/eme/custom_media_keys/types.ts +6 -1
  879. package/src/compat/eme/custom_media_keys/webkit_media_keys.ts +11 -15
  880. package/src/compat/eme/custom_media_keys/webkit_media_keys_constructor.ts +2 -3
  881. package/src/compat/eme/eme-api-implementation.ts +40 -9
  882. package/src/compat/eme/get_init_data.ts +5 -3
  883. package/src/compat/eme/set_media_keys.ts +2 -1
  884. package/src/compat/event_listeners.ts +37 -12
  885. package/src/compat/get_start_date.ts +4 -2
  886. package/src/core/README.md +5 -0
  887. package/src/core/cmcd/cmcd_data_builder.ts +597 -0
  888. package/src/core/cmcd/index.ts +7 -0
  889. package/src/core/fetchers/manifest/manifest_fetcher.ts +18 -9
  890. package/src/core/fetchers/segment/segment_fetcher.ts +76 -42
  891. package/src/core/fetchers/segment/segment_fetcher_creator.ts +16 -10
  892. package/src/core/main/README.md +2 -2
  893. package/src/core/main/worker/content_preparer.ts +16 -1
  894. package/src/core/main/worker/worker_main.ts +34 -18
  895. package/src/core/segment_sinks/README.md +1 -1
  896. package/src/core/segment_sinks/inventory/segment_inventory.ts +1 -1
  897. package/src/default_config.ts +1 -0
  898. package/src/experimental/features/__tests__/local.test.ts +0 -3
  899. package/src/experimental/features/__tests__/metaplaylist.test.ts +0 -3
  900. package/src/experimental/features/local.ts +0 -2
  901. package/src/experimental/features/metaplaylist.ts +0 -2
  902. package/src/experimental/tools/VideoThumbnailLoader/prepare_source_buffer.ts +2 -1
  903. package/src/experimental/tools/VideoThumbnailLoader/remove_buffer_around_time.ts +2 -1
  904. package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +9 -8
  905. package/src/experimental/tools/mediaCapabilitiesProber/__tests__/probers/defaultCodecFinder.test.ts +1 -1
  906. package/src/experimental/tools/mediaCapabilitiesProber/api/index.ts +1 -1
  907. package/src/experimental/tools/mediaCapabilitiesProber/probers/defaultCodecsFinder.ts +1 -0
  908. package/src/features/features_object.ts +0 -1
  909. package/src/features/list/__tests__/dash.test.ts +0 -3
  910. package/src/features/list/__tests__/smooth.test.ts +0 -3
  911. package/src/features/list/dash.ts +0 -2
  912. package/src/features/list/dash_wasm.ts +0 -2
  913. package/src/features/list/smooth.ts +0 -2
  914. package/src/features/types.ts +3 -11
  915. package/src/index.ts +2 -2
  916. package/src/main_thread/README.md +1 -1
  917. package/src/main_thread/api/__tests__/option_utils.test.ts +1 -0
  918. package/src/main_thread/api/__tests__/utils.test.ts +12 -11
  919. package/src/main_thread/api/option_utils.ts +12 -3
  920. package/src/main_thread/api/public_api.ts +55 -13
  921. package/src/main_thread/api/utils.ts +5 -4
  922. package/src/main_thread/decrypt/__tests__/__global__/utils.ts +10 -5
  923. package/src/main_thread/decrypt/attach_media_keys.ts +3 -2
  924. package/src/main_thread/decrypt/clear_on_stop.ts +2 -1
  925. package/src/main_thread/decrypt/content_decryptor.ts +98 -5
  926. package/src/main_thread/decrypt/dispose_decryption_resources.ts +2 -1
  927. package/src/main_thread/decrypt/find_key_system.ts +85 -2
  928. package/src/main_thread/decrypt/get_key_system_configuration.ts +2 -1
  929. package/src/main_thread/decrypt/get_media_keys.ts +8 -2
  930. package/src/main_thread/decrypt/init_media_keys.ts +2 -1
  931. package/src/main_thread/decrypt/types.ts +2 -0
  932. package/src/main_thread/decrypt/utils/__tests__/is_compatible_codec_supported.test.ts +38 -0
  933. package/src/main_thread/decrypt/utils/is_compatible_codec_supported.ts +39 -0
  934. package/src/main_thread/decrypt/utils/media_keys_infos_store.ts +5 -7
  935. package/src/main_thread/init/directfile_content_initializer.ts +5 -13
  936. package/src/main_thread/init/media_source_content_initializer.ts +221 -42
  937. package/src/main_thread/init/multi_thread_content_initializer.ts +144 -151
  938. package/src/main_thread/init/types.ts +6 -1
  939. package/src/main_thread/init/utils/create_media_source.ts +4 -3
  940. package/src/main_thread/init/utils/get_loaded_reference.ts +2 -1
  941. package/src/main_thread/init/utils/initial_seek_and_play.ts +2 -1
  942. package/src/main_thread/init/utils/initialize_content_decryption.ts +40 -33
  943. package/src/main_thread/init/utils/stream_events_emitter/stream_events_emitter.ts +3 -2
  944. package/src/main_thread/init/utils/throw_on_media_error.ts +2 -2
  945. package/src/main_thread/init/utils/update_manifest_codec_support.ts +193 -0
  946. package/src/main_thread/text_displayer/html/html_text_displayer.ts +3 -2
  947. package/src/main_thread/text_displayer/native/native_text_displayer.ts +6 -3
  948. package/src/main_thread/tracks_store/media_element_tracks_store.ts +4 -4
  949. package/src/main_thread/tracks_store/track_dispatcher.ts +7 -26
  950. package/src/main_thread/tracks_store/tracks_store.ts +314 -184
  951. package/src/manifest/classes/__tests__/adaptation.test.ts +50 -19
  952. package/src/manifest/classes/__tests__/manifest.test.ts +37 -6
  953. package/src/manifest/classes/__tests__/period.test.ts +212 -99
  954. package/src/manifest/classes/__tests__/representation.test.ts +96 -103
  955. package/src/manifest/classes/__tests__/update_period_in_place.test.ts +20 -20
  956. package/src/manifest/classes/adaptation.ts +61 -28
  957. package/src/manifest/classes/codec_support_cache.ts +82 -0
  958. package/src/manifest/classes/index.ts +2 -2
  959. package/src/manifest/classes/manifest.ts +61 -7
  960. package/src/manifest/classes/period.ts +30 -14
  961. package/src/manifest/classes/representation.ts +73 -70
  962. package/src/manifest/index.ts +2 -2
  963. package/src/manifest/types.ts +33 -5
  964. package/src/manifest/utils.ts +25 -4
  965. package/src/minimal.ts +2 -9
  966. package/src/mse/index.ts +0 -1
  967. package/src/mse/main_media_source_interface.ts +11 -8
  968. package/src/mse/types.ts +1 -30
  969. package/src/mse/utils/end_of_stream.ts +9 -4
  970. package/src/mse/utils/media_source_duration_updater.ts +10 -6
  971. package/src/multithread_types.ts +27 -14
  972. package/src/parsers/manifest/dash/common/__tests__/manifest_bounds_calculator.test.ts +29 -17
  973. package/src/parsers/manifest/dash/common/indexes/template.ts +3 -1
  974. package/src/parsers/manifest/dash/common/indexes/timeline/timeline_representation_index.ts +3 -1
  975. package/src/parsers/manifest/dash/common/manifest_bounds_calculator.ts +7 -3
  976. package/src/parsers/manifest/dash/common/parse_mpd.ts +15 -1
  977. package/src/parsers/manifest/utils/__tests__/update_segment_timeline.test.ts +1 -1
  978. package/src/parsers/texttracks/ttml/html/__tests__/__global__/html_ttml_parser.test.ts +6 -2
  979. package/src/playback_observer/media_element_playback_observer.ts +11 -11
  980. package/src/public_types.ts +86 -0
  981. package/src/tools/TextTrackRenderer/text_track_renderer.ts +1 -0
  982. package/src/transports/dash/init_segment_loader.ts +26 -6
  983. package/src/transports/dash/integrity_checks.ts +170 -0
  984. package/src/transports/dash/{low_latency_segment_loader.ts → load_chunked_segment_data.ts} +20 -17
  985. package/src/transports/dash/pipelines.ts +3 -0
  986. package/src/transports/dash/segment_loader.ts +47 -12
  987. package/src/transports/dash/text_loader.ts +50 -21
  988. package/src/transports/local/pipelines.ts +1 -0
  989. package/src/transports/metaplaylist/manifest_loader.ts +14 -3
  990. package/src/transports/metaplaylist/pipelines.ts +2 -0
  991. package/src/transports/smooth/pipelines.ts +19 -3
  992. package/src/transports/smooth/segment_loader.ts +33 -17
  993. package/src/transports/types.ts +19 -0
  994. package/src/transports/utils/__tests__/add_query_string.test.ts +108 -0
  995. package/src/transports/utils/add_query_string.ts +54 -0
  996. package/src/transports/utils/call_custom_manifest_loader.ts +2 -2
  997. package/src/transports/utils/generate_manifest_loader.ts +34 -13
  998. package/src/utils/__tests__/array_find.test.ts +3 -3
  999. package/src/utils/__tests__/array_find_index.test.ts +3 -3
  1000. package/src/utils/__tests__/logger.test.ts +174 -17
  1001. package/src/utils/are_codecs_compatible.ts +19 -11
  1002. package/src/utils/create_uuid.ts +28 -0
  1003. package/src/utils/logger.ts +83 -13
  1004. package/src/utils/request/fetch.ts +3 -3
  1005. package/src/utils/request/xhr.ts +2 -2
  1006. package/src/utils/weak_map_memory.ts +1 -1
  1007. package/dist/commonjs/mse/main_codec_support_prober.d.ts +0 -27
  1008. package/dist/commonjs/mse/main_codec_support_prober.d.ts.map +0 -1
  1009. package/dist/commonjs/mse/main_codec_support_prober.js +0 -44
  1010. package/dist/commonjs/mse/worker_codec_support_prober.d.ts +0 -43
  1011. package/dist/commonjs/mse/worker_codec_support_prober.d.ts.map +0 -1
  1012. package/dist/commonjs/mse/worker_codec_support_prober.js +0 -61
  1013. package/dist/commonjs/transports/dash/add_segment_integrity_checks_to_loader.d.ts +0 -25
  1014. package/dist/commonjs/transports/dash/add_segment_integrity_checks_to_loader.d.ts.map +0 -1
  1015. package/dist/commonjs/transports/dash/add_segment_integrity_checks_to_loader.js +0 -95
  1016. package/dist/commonjs/transports/dash/low_latency_segment_loader.d.ts.map +0 -1
  1017. package/dist/commonjs/transports/dash/low_latency_segment_loader.js +0 -77
  1018. package/dist/es2017/mse/main_codec_support_prober.d.ts +0 -27
  1019. package/dist/es2017/mse/main_codec_support_prober.d.ts.map +0 -1
  1020. package/dist/es2017/mse/main_codec_support_prober.js +0 -41
  1021. package/dist/es2017/mse/worker_codec_support_prober.d.ts +0 -43
  1022. package/dist/es2017/mse/worker_codec_support_prober.d.ts.map +0 -1
  1023. package/dist/es2017/mse/worker_codec_support_prober.js +0 -58
  1024. package/dist/es2017/transports/dash/add_segment_integrity_checks_to_loader.d.ts +0 -25
  1025. package/dist/es2017/transports/dash/add_segment_integrity_checks_to_loader.d.ts.map +0 -1
  1026. package/dist/es2017/transports/dash/add_segment_integrity_checks_to_loader.js +0 -81
  1027. package/dist/es2017/transports/dash/low_latency_segment_loader.d.ts.map +0 -1
  1028. package/src/mse/main_codec_support_prober.ts +0 -52
  1029. package/src/mse/worker_codec_support_prober.ts +0 -75
  1030. package/src/transports/dash/add_segment_integrity_checks_to_loader.ts +0 -97
@@ -1,3 +1,3 @@
1
- const blob = new Blob(["(function(){" + "\"use strict\";(()=>{var $s=Object.defineProperty,Xs=Object.defineProperties;var Zs=Object.getOwnPropertyDescriptors;var Ga=Object.getOwnPropertySymbols;var Js=Object.prototype.hasOwnProperty,eu=Object.prototype.propertyIsEnumerable;var Ka=(n,e,t)=>e in n?$s(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ge=(n,e)=>{for(var t in e||(e={}))Js.call(e,t)&&Ka(n,t,e[t]);if(Ga)for(var t of Ga(e))eu.call(e,t)&&Ka(n,t,e[t]);return n},Me=(n,e)=>Xs(n,Zs(e));var b={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var nu={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:\"native\",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:\"continue\",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:\"none\",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.001,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs=\"avc1.4d401e\"','video/mp4;codecs=\"avc1.42e01e\"','video/webm;codecs=\"vp8\"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs=\"mp4a.40.2\"',\"audio/webm;codecs=opus\"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:[\"HW_SECURE_ALL\",\"HW_SECURE_DECODE\",\"HW_SECURE_CRYPTO\",\"SW_SECURE_DECODE\",\"SW_SECURE_CRYPTO\"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:[\"3000\",\"2000\"],EME_KEY_SYSTEMS:{clearkey:[\"webkit-org.w3.clearkey\",\"org.w3.clearkey\"],widevine:[\"com.widevine.alpha\"],playready:[\"com.microsoft.playready.recommendation\",\"com.microsoft.playready\",\"com.chromecast.playready\",\"com.youtube.playready\"],fairplay:[\"com.apple.fps.1_0\"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:\"reload\",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:\"seamless\"},ja=nu;function ru(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r=0;r<e.length;r++){let i=e[r];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t}var H=typeof Object.assign==\"function\"?Object.assign:ru;function Gr(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function Qt(n,...e){if(e.length===0)return n;let t=e.shift();if(Gr(n)&&Gr(t))for(let r in t)if(Gr(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),Qt(i,t[r])}else H(n,{[r]:t[r]});return Qt(n,...e)}var Kr=class{constructor(){this._config=ja}update(e){let t=Qt(this._config,e);this._config=t}getCurrent(){return this._config}},iu=new Kr,U=iu;var Ke=class n extends Error{constructor(e,t,r){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"CustomLoaderError\",this.canRetry=t,this.xhr=r}};function v(n){return n==null}var oe=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],r!==void 0&&r.register(()=>{this.removeEventListener(e,t)})}removeEventListener(e,t){if(v(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(v(t)){delete this._listeners[e];return}let i=r.indexOf(t);i!==-1&&r.splice(i,1),r.length===0&&delete this._listeners[e]}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i(t)}catch(a){if(b.CURRENT_ENV===b.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};function D(){}var au=\"NONE\",$t=class extends oe{constructor(){super(),this.error=D,this.warn=D,this.info=D,this.debug=D,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentLevel=au}setLevel(e,t){let r,i=this._levels[e];typeof i==\"number\"?(r=i,this._currentLevel=e):(r=0,this._currentLevel=\"NONE\"),t===void 0?(this.error=r>=this._levels.ERROR?console.error.bind(console):D,this.warn=r>=this._levels.WARNING?console.warn.bind(console):D,this.info=r>=this._levels.INFO?console.info.bind(console):D,this.debug=r>=this._levels.DEBUG?console.log.bind(console):D):(this.error=r>=this._levels.ERROR?(...a)=>t(\"ERROR\",a):D,this.warn=r>=this._levels.WARNING?(...a)=>t(\"WARNING\",a):D,this.info=r>=this._levels.INFO?(...a)=>t(\"INFO\",a):D,this.debug=r>=this._levels.DEBUG?(...a)=>t(\"DEBUG\",a):D),this.trigger(\"onLogLevelChange\",this._currentLevel)}getLevel(){return this._currentLevel}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};var ou=new $t,c=ou;var st=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var su=typeof window==\"undefined\"&&!st,nr=su;var rr;st?rr=self:nr?rr=global:rr=window;var Ee=rr;function ne(n,e,t){if(typeof Array.prototype.findIndex==\"function\")return n.findIndex(e,t);let r=n.length>>>0;for(let i=0;i<r;i++)if(e.call(t,n[i],i,n))return i;return-1}var ir=class{constructor(e,t){this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],t!==void 0&&(this._deregisterCancellation=t.register(()=>this.finish()))}getValue(){return this._value}setValue(e){if(this._isFinished){b.CURRENT_ENV===b.DEV&&console.error(\"Finished shared references cannot be updated\");return}if(this._value=e,this._listeners.length===0)return;let t=this._listeners.slice();for(let r of t)try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(i){}}setValueIfChanged(e){e!==this._value&&this.setValue(e)}onUpdate(e,t){let r=()=>{if((t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let a=this._listeners.indexOf(i);a>=0&&this._listeners.splice(a,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),(t==null?void 0:t.emitCurrentValue)===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}(t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return D;let r=()=>{let o=ne(this._onFinishCbs,s=>s.trigger===i);o>=0&&(this._onFinishCbs[o].hasBeenCleared=!0,this._onFinishCbs.splice(o,1))},i=()=>{r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a}finish(){this._deregisterCancellation!==void 0&&this._deregisterCancellation(),this._isFinished=!0;let e=this._listeners.slice();for(let t of e)try{t.hasBeenCleared||(t.complete(),t.hasBeenCleared=!0)}catch(r){}if(this._listeners.length=0,this._onFinishCbs.length>0){let t=this._onFinishCbs.slice();for(let r of t)try{r.hasBeenCleared||(r.trigger(),r.hasBeenCleared=!0)}catch(i){}this._onFinishCbs.length=0}}};function Xt(n,e,t){let r=new ir(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var j=ir;var jr=new j(0);function Ya({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;jr.setValueIfChanged(r-t)}var uu=typeof performance!=\"undefined\"?()=>performance.now()+jr.getValue():()=>Date.now()+jr.getValue(),L=uu;var re=class n extends Error{constructor(e,t,r){let i;switch(r){case\"TIMEOUT\":i=\"The request timed out\";break;case\"ERROR_EVENT\":i=\"An error prevented the request to be performed successfully\";break;case\"PARSE_ERROR\":i=\"An error happened while formatting the response data\";break;case\"ERROR_HTTP_CODE\":i=\"An HTTP status code indicating failure was received: \"+String(t);break}super(i),Object.setPrototypeOf(this,n.prototype),this.name=\"RequestError\",this.url=e,this.status=t,this.type=r}serialize(){return{url:this.url,status:this.status,type:this.type}}},ye={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var Yr=typeof Headers==\"function\"?Headers:null,Qr=typeof AbortController==\"function\"?AbortController:null;function ar(n){var m,p;let e;if(!v(n.headers))if(v(Yr))e=n.headers;else{e=new Yr;let g=Object.keys(n.headers);for(let h=0;h<g.length;h++){let I=g[h];e.append(I,n.headers[I])}}c.debug(\"Fetch: Called with URL\",n.url);let t=null,r=!1,i=!1,a=L(),o=v(Qr)?null:new Qr;function s(){if(v(o)){c.warn(\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,f!==void 0&&clearTimeout(f),s()},n.timeout));let f;n.connectionTimeout!==void 0&&(f=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let d=n.cancelSignal.register(function(h){t=h,s()}),l={method:\"GET\"};if(e!==void 0&&(l.headers=e),l.signal=v(o)?null:o.signal,c.hasLevel(\"DEBUG\")){let g=\"FETCH: Sending GET \"+n.url;n.timeout!==void 0&&(g+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(g+=\" cto=\"+String(n.connectionTimeout/1e3)),((m=n.headers)==null?void 0:m.Range)!==void 0&&(g+=\" Range=\"+((p=n.headers)==null?void 0:p.Range)),c.debug(g)}return fetch(n.url,l).then(g=>{if(f!==void 0&&clearTimeout(f),g.status>=300)throw c.warn(\"Fetch: Request HTTP Error\",g.status,g.url),new re(g.url,g.status,ye.ERROR_HTTP_CODE);if(v(g.body))throw new re(g.url,g.status,ye.PARSE_ERROR);let h=g.headers.get(\"Content-Length\"),I=!v(h)&&!isNaN(+h)?+h:void 0,y=g.body.getReader(),T=0;return P();async function P(){let E=await y.read();if(!E.done&&!v(E.value)){T+=E.value.byteLength;let C=L(),R={url:g.url,currentTime:C,duration:C-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:I};return n.onData(R),P()}else if(E.done){u!==void 0&&clearTimeout(u),d();let C=L();return{requestDuration:C-a,receivedTime:C,sendingTime:a,size:T,status:g.status,url:g.url}}return P()}}).catch(g=>{throw t!==null?t:(d(),r?(c.warn(\"Fetch: Request timed out.\"),new re(n.url,0,ye.TIMEOUT)):i?(c.warn(\"Fetch: Request connection timed out.\"),new re(n.url,0,ye.TIMEOUT)):g instanceof re?g:(c.warn(\"Fetch: Request Error\",g instanceof Error?g.toString():\"\"),new re(n.url,0,ye.ERROR_EVENT)))})}function Zt(){return typeof Ee.fetch==\"function\"&&!v(Qr)&&!v(Yr)}function J(n){return typeof n==\"string\"&&n.length>0}var du=\"json\";function $r(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?du:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:u,timeout:f,connectionTimeout:d}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let m;f!==void 0&&(l.timeout=f,m=setTimeout(()=>{I(),r(new re(o,l.status,ye.TIMEOUT))},f+3e3));let p;if(d!==void 0&&(p=setTimeout(()=>{I(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new re(o,l.status,ye.TIMEOUT))},d)),l.responseType=u,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let T in y)y.hasOwnProperty(T)&&l.setRequestHeader(T,y[T])}let g=L(),h=null;if(a!==void 0&&(h=a.register(function(T){I(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){I(),r(new re(o,l.status,ye.ERROR_EVENT))},l.ontimeout=function(){I(),r(new re(o,l.status,ye.TIMEOUT))},d!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(l.onprogress=function(T){let P=L();i({url:o,duration:P-g,sendingTime:g,currentTime:P,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(I(),l.status>=200&&l.status<300){let P=L(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,C=l.status,R=l.responseType,k=J(l.responseURL)?l.responseURL:o,_;if(R===\"json\"?_=typeof l.response==\"object\"?l.response:lu(l.responseText):_=l.response,v(_)){r(new re(o,l.status,ye.PARSE_ERROR));return}t({status:C,url:k,responseType:R,sendingTime:g,receivedTime:P,requestDuration:P-g,size:E,responseData:_})}else r(new re(o,l.status,ye.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let y=\"XHR: Sending GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),f!==void 0&&(y+=\" to=\"+String(f/1e3)),d!==void 0&&(y+=\" cto=\"+String(d/1e3)),(s==null?void 0:s.Range)!==void 0&&(y+=\" Range=\"+(s==null?void 0:s.Range)),c.debug(y)}l.send();function I(){m!==void 0&&clearTimeout(m),p!==void 0&&clearTimeout(p),h!==null&&h()}})}function lu(n){try{return JSON.parse(n)}catch(e){return null}}var le=$r;var St=ye,ze={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function $e(n,e){return`${n}: ${e}`}var Jt=class n extends Error{constructor(e,t,r){super($e(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=ze.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,typeof(r==null?void 0:r.keyStatuses)==\"string\"&&(this.keyStatuses=r.keyStatuses)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}}};var Q=class n extends Error{constructor(e,t,r){super($e(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=ze.MEDIA_ERROR,this._originalMessage=t,this.code=e,this.fatal=!1,(r==null?void 0:r.tracks)!==void 0&&(r==null?void 0:r.tracks.length)>0&&(this.tracksInfo=r.tracks)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var je=class n extends Error{constructor(e,t){super($e(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=ze.NETWORK_ERROR,this.url=t.url,this.status=t.status,this.errorType=t.type,this._baseError=t,this.code=e,this.fatal=!1}isHttpError(e){return this.errorType===St.ERROR_HTTP_CODE&&this.status===e}serialize(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Re=class n extends Error{constructor(e,t){super($e(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=ze.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage}}};function wt(n){return(n instanceof Jt||n instanceof Q||n instanceof Re||n instanceof je)&&Object.keys(ze).indexOf(n.type)>=0}function he(n,{defaultCode:e,defaultReason:t}){if(wt(n))return n;let r=n instanceof Error?n.toString():t;return new Re(e,r)}var Ce=class n extends Error{constructor(e,t,r){super(t),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var fu={dashParsers:{wasm:null,native:null,fastJs:null},codecSupportProber:null,createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},Qa=fu;var ae=Qa;function K(n,e,t){if(typeof Array.prototype.find==\"function\")return n.find(e,t);let r=n.length>>>0;for(let i=0;i<r;i++){let a=n[i];if(e.call(t,a,i,n))return a}}var mu={aa:\"aar\",ab:\"abk\",ae:\"ave\",af:\"afr\",ak:\"aka\",am:\"amh\",an:\"arg\",ar:\"ara\",as:\"asm\",av:\"ava\",ay:\"aym\",az:\"aze\",ba:\"bak\",be:\"bel\",bg:\"bul\",bi:\"bis\",bm:\"bam\",bn:\"ben\",bo:\"bod\",br:\"bre\",bs:\"bos\",ca:\"cat\",ce:\"che\",ch:\"cha\",co:\"cos\",cr:\"cre\",cs:\"ces\",cu:\"chu\",cv:\"chv\",cy:\"cym\",da:\"dan\",de:\"deu\",dv:\"div\",dz:\"dzo\",ee:\"ewe\",el:\"ell\",en:\"eng\",eo:\"epo\",es:\"spa\",et:\"est\",eu:\"eus\",fa:\"fas\",ff:\"ful\",fi:\"fin\",fj:\"fij\",fo:\"fao\",fr:\"fra\",fy:\"fry\",ga:\"gle\",gd:\"gla\",gl:\"glg\",gn:\"grn\",gu:\"guj\",gv:\"glv\",ha:\"hau\",he:\"heb\",hi:\"hin\",ho:\"hmo\",hr:\"hrv\",ht:\"hat\",hu:\"hun\",hy:\"hye\",hz:\"her\",ia:\"ina\",id:\"ind\",ie:\"ile\",ig:\"ibo\",ii:\"iii\",ik:\"ipk\",io:\"ido\",is:\"isl\",it:\"ita\",iu:\"iku\",ja:\"jpn\",jv:\"jav\",ka:\"kat\",kg:\"kon\",ki:\"kik\",kj:\"kua\",kk:\"kaz\",kl:\"kal\",km:\"khm\",kn:\"kan\",ko:\"kor\",kr:\"kau\",ks:\"kas\",ku:\"kur\",kv:\"kom\",kw:\"cor\",ky:\"kir\",la:\"lat\",lb:\"ltz\",lg:\"lug\",li:\"lim\",ln:\"lin\",lo:\"lao\",lt:\"lit\",lu:\"lub\",lv:\"lav\",mg:\"mlg\",mh:\"mah\",mi:\"mri\",mk:\"mkd\",ml:\"mal\",mn:\"mon\",mr:\"mar\",ms:\"msa\",mt:\"mlt\",my:\"mya\",na:\"nau\",nb:\"nob\",nd:\"nde\",ne:\"nep\",ng:\"ndo\",nl:\"nld\",nn:\"nno\",no:\"nor\",nr:\"nbl\",nv:\"nav\",ny:\"nya\",oc:\"oci\",oj:\"oji\",om:\"orm\",or:\"ori\",os:\"oss\",pa:\"pan\",pi:\"pli\",pl:\"pol\",ps:\"pus\",pt:\"por\",qu:\"que\",rm:\"roh\",rn:\"run\",ro:\"ron\",ru:\"rus\",rw:\"kin\",sa:\"san\",sc:\"srd\",sd:\"snd\",se:\"sme\",sg:\"sag\",si:\"sin\",sk:\"slk\",sl:\"slv\",sm:\"smo\",sn:\"sna\",so:\"som\",sq:\"sqi\",sr:\"srp\",ss:\"ssw\",st:\"sot\",su:\"sun\",sv:\"swe\",sw:\"swa\",ta:\"tam\",te:\"tel\",tg:\"tgk\",th:\"tha\",ti:\"tir\",tk:\"tuk\",tl:\"tgl\",tn:\"tsn\",to:\"ton\",tr:\"tur\",ts:\"tso\",tt:\"tat\",tw:\"twi\",ty:\"tah\",ug:\"uig\",uk:\"ukr\",ur:\"urd\",uz:\"uzb\",ve:\"ven\",vi:\"vie\",vo:\"vol\",wa:\"wln\",wo:\"wol\",xh:\"xho\",yi:\"yid\",yo:\"yor\",za:\"zha\",zh:\"zho\",zu:\"zul\"},$a=mu;var cu={alb:\"sqi\",arm:\"hye\",baq:\"eus\",bur:\"mya\",chi:\"zho\",cze:\"ces\",dut:\"nld\",fre:\"fra\",geo:\"kat\",ger:\"deu\",gre:\"ell\",ice:\"isl\",mac:\"mkd\",mao:\"mri\",may:\"msa\",per:\"fas\",slo:\"slk\",rum:\"ron\",tib:\"bod\",wel:\"cym\"},Xa=cu;function pu(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=gu(t);return J(r)?r:n}function gu(n){let e;switch(n.length){case 2:e=$a[n];break;case 3:e=Xa[n];break}return e}var Za=pu;var Ja=Za;function or(n,e){if(n.length!==e.length)return!1;if(n===e)return!0;for(let t=n.length-1;t>=0;t--)if(n[t]!==e[t])return!1;return!0}function Ae(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var hu=Ae(),Xr=class{constructor(e,t){var r,i,a,o,s;if(this.id=e.id,this.uniqueId=hu(),this.bitrate=e.bitrate,this.codecs=[],e.isSpatialAudio!==void 0&&(this.isSpatialAudio=e.isSpatialAudio),e.height!==void 0&&(this.height=e.height),e.width!==void 0&&(this.width=e.width),e.mimeType!==void 0&&(this.mimeType=e.mimeType),e.contentProtections!==void 0&&(this.contentProtections=e.contentProtections),e.frameRate!==void 0&&(this.frameRate=e.frameRate),e.hdrInfo!==void 0&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index,t===\"audio\"||t===\"video\")if(ae.codecSupportProber!==null){if(e.supplementalCodecs!==void 0){let u=ae.codecSupportProber.isSupported((r=this.mimeType)!=null?r:\"\",(i=e.supplementalCodecs)!=null?i:\"\");u!==!1&&(this.codecs=[e.supplementalCodecs],u===!0&&(this.isSupported=!0))}this.isSupported!==!0&&(this.codecs.length>0?this.codecs.push((a=e.codecs)!=null?a:\"\"):(this.codecs=e.codecs===void 0?[]:[e.codecs],this.isSupported=ae.codecSupportProber.isSupported((o=this.mimeType)!=null?o:\"\",(s=e.codecs)!=null?s:\"\")))}else e.supplementalCodecs!==void 0&&this.codecs.push(e.supplementalCodecs),e.codecs!==void 0&&this.codecs.push(e.codecs);else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var i;let t=(i=this.mimeType)!=null?i:\"\",r=this.codecs;r.length===0&&(r=[\"\"]);for(let a=0;a<r.length;a++)for(let o of e){let s=r[a];if(o.codec===s&&o.mimeType===t){if(o.result){this.isSupported=!0,this.codecs=[s];return}else if(a===r.length){this.isSupported=!1,this.codecs=[s];return}}}}getMimeTypeString(){var e,t,r;return`${(e=this.mimeType)!=null?e:\"\"};codecs=\"${(r=(t=this.codecs)==null?void 0:t[0])!=null?r:\"\"}\"`}getEncryptionData(e){var i,a;let t=this.getAllEncryptionData(),r=[];for(let o=0;o<t.length;o++){let s=!1,u=t[o];for(let f=0;f<u.values.length;f++)if(u.values[f].systemId.toLowerCase()===e.toLowerCase())if(s)r[r.length-1].values.push(u.values[f]);else{let d=(a=(i=this.contentProtections)==null?void 0:i.keyIds)==null?void 0:a.map(l=>l.keyId);r.push({type:u.type,keyIds:d,values:[u.values[f]]}),s=!0}}return r}getAllEncryptionData(){var t,r;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(r=(t=this.contentProtections)==null?void 0:t.keyIds)==null?void 0:r.map(i=>i.keyId);return this.contentProtections.initData.map(i=>({type:i.type,keyIds:e,values:i.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[{keyId:t}]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[{keyId:t}];else{let s=!1;for(let u of o)or(u.keyId,t)&&(s=!0);s||(c.warn(\"Manifest: found unanounced key id.\"),o.push({keyId:t}))}}let a=this.contentProtections.initData;for(let o=0;o<a.length;o++)if(a[o].type===e){let s=a[o].values;for(let u=0;u<r.length;u++){let f=r[u],d;for(d=0;d<s.length;d++)if(f.systemId===s[d].systemId){if(or(f.data,s[d].data))break;c.warn(\"Manifest: different init data for the same system ID\")}d===s.length&&(s.push(f),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}getMetadataSnapshot(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}}},en=Xr;var ut=class n{constructor(e,t={}){let{trickModeTracks:r}=e,{representationFilter:i,isManuallyAdded:a}=t;this.id=e.id,this.type=e.type,e.isTrickModeTrack!==void 0&&(this.isTrickModeTrack=e.isTrickModeTrack),e.language!==void 0&&(this.language=e.language,this.normalizedLanguage=Ja(e.language)),e.closedCaption!==void 0&&(this.isClosedCaption=e.closedCaption),e.audioDescription!==void 0&&(this.isAudioDescription=e.audioDescription),e.isDub!==void 0&&(this.isDub=e.isDub),e.forcedSubtitles!==void 0&&(this.isForcedSubtitles=e.forcedSubtitles),e.isSignInterpreted!==void 0&&(this.isSignInterpreted=e.isSignInterpreted),e.label!==void 0&&(this.label=e.label),r!==void 0&&r.length>0&&(this.trickModeTracks=r.map(f=>new n(f)));let o=e.representations,s=[],u;for(let f=0;f<o.length;f++){let d=new en(o[f],this.type),l=!0;if(!v(i)){let m={id:d.id,bitrate:d.bitrate,codecs:d.codecs,height:d.height,width:d.width,frameRate:d.frameRate,hdrInfo:d.hdrInfo};if(d.contentProtections!==void 0&&(m.contentProtections={},d.contentProtections.keyIds!==void 0)){let p=d.contentProtections.keyIds.map(({keyId:g})=>g);m.contentProtections.keyIds=p}l=i(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}l?(s.push(d),u===void 0&&(d.isSupported===!0?u=!0:d.isSupported===!1&&(u=!1))):c.debug(\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${d.id}`,`(${d.bitrate})`)}s.sort((f,d)=>f.bitrate-d.bitrate),this.representations=s,this.isSupported=u,this.manuallyAdded=a===!0}refreshCodecSupport(e){for(let t of this.representations)t.isSupported===void 0&&(t.refreshCodecSupport(e),this.isSupported!==!0&&t.isSupported===!0?this.isSupported=!0:this.isSupported===void 0&&t.isSupported===!1&&(this.isSupported=!1))}getRepresentation(e){return K(this.representations,({id:t})=>e===t)}getMetadataSnapshot(){let e=[],t=this.representations;for(let r of t)e.push(r.getMetadataSnapshot());return{id:this.id,type:this.type,isSupported:this.isSupported,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:e,label:this.label,isDub:this.isDub}}};function se(n,e,t){if(typeof Array.prototype.includes==\"function\")return n.includes(e,t);let r=n.length>>>0;if(r===0)return!1;let i=t|0,a=i>=0?Math.min(i,r-1):Math.max(r+i,0),o=(s,u)=>s===u||typeof s==\"number\"&&typeof u==\"number\"&&isNaN(s)&&isNaN(u);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}var eo=[];function Xe(n){se(eo,n)||(console.warn(n),eo.push(n))}function Zr(n){return Object.keys(n).map(e=>n[e])}var sr=typeof Object.values==\"function\"?Object.values:Zr;var Dt=[\"audio\",\"video\",\"text\"];function no(n){var a,o;let e=n.timeBounds;if(e.timeshiftDepth===null)return(a=e.minimumSafePosition)!=null?a:0;let{maximumTimeData:t}=e,r;if(!e.maximumTimeData.isLinear)r=t.maximumSafePosition;else{let s=L()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function ro(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=L()-e.time;return e.livePosition+t/1e3}function io(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=L()-e.time;return e.maximumSafePosition+t/1e3}function ao(n,e){if(e===void 0)return ei(n).filter(r=>r.isSupported===!0);let t=n.adaptations[e];return t===void 0?[]:t.filter(r=>r.isSupported===!0)}function oo(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(Jr(i,e,t))return i;t=i}}function so(n,e){let t=e.end;if(t===void 0)return null;let r=K(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function Jr(n,e,t){return e>=n.start&&(n.end===void 0||e<n.end)?!0:e===n.end&&(t===null||t.start>n.end)}function ei(n){let e=n.adaptations;return Zr(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function Iu(n,e){var r,i;let t={language:(r=n.language)!=null?r:\"\",normalized:(i=n.normalizedLanguage)!=null?i:\"\",audioDescription:n.isAudioDescription===!0,id:n.id,representations:(e?n.representations.filter(a=>a.isSupported===!0&&a.decipherable!==!1):n.representations).map(yu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function bu(n){var e,t;return{language:(e=n.language)!=null?e:\"\",normalized:(t=n.normalizedLanguage)!=null?t:\"\",closedCaption:n.isClosedCaption===!0,id:n.id,label:n.label,forced:n.isForcedSubtitles}}function Su(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>s.isSupported===!0&&s.decipherable!==!1):i.representations).map(to),o={id:i.id,representations:a,isTrickModeTrack:!0};return i.isSignInterpreted===!0&&(o.signInterpreted=!0),o}):void 0,r={id:n.id,representations:(e?n.representations.filter(i=>i.isSupported===!0&&i.decipherable!==!1):n.representations).map(to),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function yu(n){let{id:e,bitrate:t,codecs:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r==null?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function to(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:f}}function dt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Iu(n,!1)};case\"video\":return{type:\"video\",track:Su(n,!1)};case\"text\":return{type:\"text\",track:bu(n)}}}function uo(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var lt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((i,a)=>{let o=e.adaptations[a];if(v(o))return i;let s=o.map(u=>{let f=new ut(u,{representationFilter:r});return f.representations.length>0&&f.isSupported===!1&&t.push(f),f}).filter(u=>u.representations.length>0);if(s.every(u=>u.isSupported===!1)&&o.length>0&&(a===\"video\"||a===\"audio\"))throw new Q(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+a+\" adaptations\",{tracks:void 0});return s.length>0&&(i[a]=s),i},{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new Q(\"MANIFEST_PARSE_ERROR\",\"No supported audio and video tracks.\");this.duration=e.duration,this.start=e.start,!v(this.duration)&&!v(this.start)&&(this.end=this.start+this.duration),this.streamEvents=e.streamEvents===void 0?[]:e.streamEvents}refreshCodecSupport(e,t){Object.keys(this.adaptations).forEach(r=>{let i=this.adaptations[r];if(i===void 0)return;let a=!1;for(let o of i){let s=o.isSupported;o.refreshCodecSupport(e),s!==!1&&o.isSupported===!1&&t.push(o),a===!1?a=o.isSupported:a===void 0&&o.isSupported===!0&&(a=!0)}if((r===\"video\"||r===\"audio\")&&a===!1)throw new Q(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+r+\" adaptations\",{tracks:void 0})},{})}getAdaptations(){return ei(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return K(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return ao(this,e)}containsTime(e,t){return Jr(this,e,t)}getMetadataSnapshot(){let e={},t=this.getAdaptations();for(let r of t){let i=e[r.type];i===void 0&&(i=[],e[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:e}}};function tn(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.getAdaptations(),a=e.getAdaptations();for(let o=0;o<i.length;o++){let s=i[o],u=ne(a,f=>f.id===s.id);if(u===-1){c.warn('Manifest: Adaptation \"'+i[o].id+'\" not found when merging.');let[f]=i.splice(o,1);o--,r.removedAdaptations.push({id:f.id,trackType:f.type})}else{let[f]=a.splice(u,1),d=[],l=[],m=[];r.updatedAdaptations.push({adaptation:s.id,trackType:s.type,updatedRepresentations:d,addedRepresentations:l,removedRepresentations:m});let p=s.representations,g=f.representations.slice();for(let h=0;h<p.length;h++){let I=p[h],y=ne(g,T=>T.id===I.id);if(y===-1){c.warn(`Manifest: Representation \"${p[h].id}\" not found when merging.`);let[T]=p.splice(h,1);h--,m.push(T.id)}else{let[T]=g.splice(y,1);d.push(I.getMetadataSnapshot()),I.cdnMetadata=T.cdnMetadata,t===0?I.index._replace(T.index):I.index._update(T.index)}}g.length>0&&(c.warn(`Manifest: ${g.length} new Representations found when merging.`),s.representations.push(...g),l.push(...g.map(h=>h.getMetadataSnapshot())))}}if(a.length>0){c.warn(`Manifest: ${a.length} new Adaptations found when merging.`);for(let o of a){let s=n.adaptations[o.type];s===void 0?n.adaptations[o.type]=[o]:s.push(o),r.addedAdaptations.push(o.getMetadataSnapshot())}}return r}function lo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,u=n[s];for(;u!==void 0&&u.id!==o.id;)s++,u=n[s];if(u!==void 0){let f=tn(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:f});let d=e.slice(r,a),l=s-r,m=n.splice(r,l,...d);t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end}))),t.addedPeriods.push(...d.map(p=>p.getMetadataSnapshot())),r=a+1}}if(r>n.length)return c.error(\"Manifest: error when updating Periods\"),t;if(r<n.length){let a=n.splice(r,n.length-r);t.removedPeriods.push(...a.map(o=>({id:o.id,start:o.start,end:o.end})))}let i=e.slice(r,e.length);return i.length>0&&(n.push(...i),t.addedPeriods.push(...i.map(a=>a.getMetadataSnapshot()))),t}function fo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(n.length===0)return n.splice(0,0,...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t;if(e.length===0)return t;let r=n[n.length-1];if(r.start<e[0].start){if(r.end!==e[0].start)throw new Q(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");return n.push(...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t}let i=ne(n,({id:s})=>s===e[0].id);if(i<0)throw new Q(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=tn(n[i],e[0],1);t.updatedPeriods.push({period:H(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],f=-1;for(let d=o;d<n.length;d++)if(u.id===n[d].id){f=d;break}if(f<0){let d=-1;for(let p=o;p<n.length;p++)if(u.start<n[p].start){d=p;break}let l=d-o,m=n.splice(o,l,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end})))}else{if(f>o){c.warn(\"Manifest: old Periods not found in new when updating, removing\");let l=n.splice(o,f-o);t.removedPeriods.push(...l.map(m=>({id:m.id,start:m.start,end:m.end}))),f=o}let d=tn(n[f],u,0);t.updatedPeriods.push({period:H(n[f].getMetadataSnapshot(),{adaptations:void 0}),result:d})}o++}if(o<n.length){c.warn(\"Manifest: Ending Periods not found in new when updating, removing\");let s=n.splice(o,n.length-o);t.removedPeriods.push(...s.map(u=>({id:u.id,start:u.start,end:u.end})))}return t}var _u=Ae(),nn=class extends oe{constructor(e,t,r){var s;super();let{representationFilter:i,manifestUpdateUrl:a}=t;this.manifestFormat=0,this.id=_u(),this.expired=(s=e.expired)!=null?s:null,this.transport=e.transportType,this.clockOffset=e.clockOffset;let o=[];if(this.periods=e.periods.map(u=>new lt(u,o,i)).sort((u,f)=>u.start-f.start),o.length>0){let u=new Q(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:o.map(dt)});r.push(u)}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.timeBounds=e.timeBounds,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.uris=e.uris===void 0?[]:e.uris,this.updateUrl=a,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.availabilityStartTime=e.availabilityStartTime,this.publishTime=e.publishTime}refreshCodecSupport(e){let t=[];for(let r of this.periods)r.refreshCodecSupport(e,t);return t.length>0?new Q(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(dt)}):null}getPeriod(e){return K(this.periods,t=>e===t.id)}getPeriodForTime(e){return oo(this,e)}getNextPeriod(e){return K(this.periods,t=>t.start>e)}getPeriodAfter(e){return so(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return no(this)}getLivePosition(){return ro(this)}getMaximumSafePosition(){return io(this)}updateRepresentationsDeciperability(e){let t=Tu(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}getAdaptations(){Xe(\"manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead\");let e=this.periods[0];if(e===void 0)return[];let t=e.adaptations,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){Xe(\"manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead\");let t=this.periods[0];if(t===void 0)return[];let r=t.adaptations[e];return r===void 0?[]:r}getAdaptation(e){return Xe(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),K(this.getAdaptations(),({id:t})=>e===t)}getMetadataSnapshot(){let e=[];for(let t of this.periods)e.push(t.getMetadataSnapshot());return{manifestFormat:1,id:this.id,periods:e,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}}_performUpdate(e,t){this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=lo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=fo(this.periods,e.periods);let i=this.getMinimumSafePosition();for(;this.periods.length>0;){let a=this.periods[0];if(a.end===void 0||a.end>i)break;this.periods.shift()}}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.trigger(\"manifestUpdate\",r)}};function Tu(n,e){let t=[];for(let r of n.periods)for(let i of r.getAdaptations())for(let a of i.representations){let o={manifest:n,period:r,adaptation:i,representation:a},s=e(o);s!==a.decipherable&&(t.push(o),a.decipherable=s,c.debug(`Decipherability changed for \"${a.id}\"`,`(${a.bitrate})`,String(a.decipherable)))}return t}function Ze(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function yt(n){if(v(n))return\"\";let{period:e,adaptation:t,representation:r,segment:i}=n,a;return i.isInit?a=\"init\":i.complete?a=`${i.time}-${i.duration}`:a=`${i.time}`,`${t.type} P: ${e.id} A: ${t.id} R: ${r.id} S: ${a}`}var Nt=nn;var ft=Ee,_t=ft===void 0?void 0:v(ft.MediaSource)?v(ft.MozMediaSource)?v(ft.WebKitMediaSource)?ft.MSMediaSource:ft.WebKitMediaSource:ft.MozMediaSource:ft.MediaSource;var Eu=200,ur=new Map;function ti(n){if(v(_t))return st&&c.error(\"Compat: Cannot request codec support in a worker without MSE.\"),!1;if(typeof _t.isTypeSupported==\"function\"){let e=ur.get(n);if(e!==void 0)return e;{let t=_t.isTypeSupported(n);return ur.size>=Eu&&ur.clear(),ur.set(n,t),t}}return!0}var Ru=50,ni=class{constructor(){this._cachedCodecSupport=new Map}isSupported(e,t){let r=`${e!=null?e:\"\"};codecs=\"${t!=null?t:\"\"}\"`,i=this._cachedCodecSupport.get(r);if(i!==void 0)return i;this._cachedCodecSupport.size>=Ru&&this._cachedCodecSupport.clear();let a=ti(r);return this._cachedCodecSupport.set(r,a),a}},Pu=new ni,mo=Pu;var ri=class{constructor(){this._currentCacheSize=0,this._cachedCodecSupport=new Map}isSupported(e,t){var i;let r=(i=this._cachedCodecSupport.get(e))==null?void 0:i.get(t);if(r!==void 0)return r}updateCache(e,t,r){this._currentCacheSize>=50&&(this._cachedCodecSupport.clear(),this._currentCacheSize=0);let i=this._cachedCodecSupport.get(e);if(i!==void 0)i.set(t,r);else{let a=new Map;a.set(t,r),this._cachedCodecSupport.set(e,a)}}},co=new ri;var dr=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function Ie(n,e){if(b.DEV===b.CURRENT_ENV&&!n)throw new dr(e===void 0?\"invalid assertion\":e)}function We(n){throw new dr(\"Unreachable path taken\")}var vu=\"<\";var po=\">\";var Cu=`\\r\n\t>/= `;function ii(n,e={}){var m,p;let t=(m=e.pos)!=null?m:0,r=e.keepComments===!0,i=e.keepWhitespace===!0,a;if(e.attrValue!==void 0)for(e.attrName=(p=e.attrName)!=null?p:\"id\",a=[];(t=l())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(f()),n=n.substring(t),t=0;else a=o(\"\");return e.filter&&(a=go(a,e.filter)),a;function o(g){let h=[];for(;n[t];)if(n.charCodeAt(t)===60){if(n.charCodeAt(t+1)===47){let y=t+2;if(t=n.indexOf(po,t),n.substring(y,t).indexOf(g)===-1){let P=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(P.length-1)+`\nColumn: `+(P[P.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),h}else if(n.charCodeAt(t+1)===33){if(n.charCodeAt(t+2)===45){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===62&&n.charCodeAt(t-1)===45&&n.charCodeAt(t-2)===45);)t=n.indexOf(po,t+1);t===-1&&(t=n.length),r&&h.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===91&&n.charCodeAt(t+8)===91&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(h.push(n.substring(t+9)),t=n.length):(h.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==62||T)&&n[t];)n.charCodeAt(t)===91?T=!0:T&&n.charCodeAt(t)===93&&(T=!1),t++;h.push(n.substring(y,t))}t++;continue}let I=f();h.push(I),I.tagName[0]===\"?\"&&(h.push(...I.children),I.children=[])}else{let I=s();if(i)I.length>0&&h.push(I);else{let y=I.trim();y.length>0&&h.push(y)}t++}return h}function s(){let g=t;return t=n.indexOf(vu,t)-1,t===-2&&(t=n.length),n.slice(g,t+1)}function u(){let g=t;for(;Cu.indexOf(n[t])===-1&&n[t];)t++;return n.slice(g,t)}function f(){let g=t;t++;let h=u(),I={},y=[];for(;n.charCodeAt(t)!==62&&n[t];){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let P=u(),E=n.charCodeAt(t);for(;E&&E!==39&&E!==34&&!(E>64&&E<91||E>96&&E<123)&&E!==62;)t++,E=n.charCodeAt(t);let C;E===39||E===34?C=d():(C=null,t--),I[P]=C===null?null:ho(C)}t++}return n.charCodeAt(t-1)!==47?(t++,y=o(h)):t++,{tagName:h,attributes:I,children:y,posStart:g,posEnd:t}}function d(){let g=n[t],h=t+1;return t=n.indexOf(g,h),n.slice(h,t)}function l(){let g=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return g?g.index:-1}}function go(n,e,t=0,r=\"\"){let i=[];return n.forEach(function(a,o){if(typeof a==\"object\"&&(e(a,o,t,r)&&i.push(a),a.children.length>0)){let s=go(a.children,e,t+1,(r?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function lr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+lr(t),e=e.trim()}),e}else return typeof n==\"object\"?lr(n.children):\" \"+ho(n)}function ho(n){return n.indexOf(\"&\")<0?n:n.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&apos;/g,\"'\").replace(/&#x([A-Fa-f0-9]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&amp;/g,\"&\")}function ai(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return v(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function Ne(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ai(n,e,t);return r+(a+1)*i}function Pe(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function Ye(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function Io(n,e,t){return[n*t,(n+e)*t]}function Au(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i].start<=e?t=i+1:r=i}return t-1}function bo(n,e,t){let{timeline:r}=n,i=Pe(e,n);if(i<0)return null;let a=Au(r,i);if(a<0||a>=r.length-1)return null;let o=r[a];if(o.duration<=0)return null;let s=r[a+1];if(s===void 0)return null;let u=s.start,f=Ne(o,s,t);return i>=f&&i<u?Ye(u,n):null}function Je(n,e){var i;let{initialization:t}=n,r={};return e!==void 0&&(r.isEMSGWhitelisted=e),{id:\"init\",isInit:!0,time:0,end:0,duration:0,timescale:1,range:v(t)?void 0:t.range,indexRange:n.indexRange,url:(i=t==null?void 0:t.url)!=null?i:null,complete:!0,privateInfos:r,timestampOffset:-(n.indexTimeOffset/n.timescale)}}function ku(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function oi(n){return(e,t,r)=>{let i=J(r)?parseInt(r,10):1;return ku(String(n),i)}}function Be(n,e,t){return xu(n,e,t)}function xu(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(\\%0(\\d+)d)?\\$/g,oi(t===void 0?0:t))}function fr(n,e){return function(r){return r.indexOf(\"$\")===-1?r:r.replace(/\\$\\$/g,\"$\").replace(/\\$Number(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(e===void 0)throw new Error(\"Segment number not defined in a $Number$ scheme\");return oi(e)(i,a,o)}).replace(/\\$Time(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(n===void 0)throw new Error(\"Segment time not defined in a $Time$ scheme\");return oi(n)(i,a,o)})}}function Mu(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function rn(n,e,t,r,i,a){var T;let o=r.getEstimatedMaximumPosition((T=n.availabilityTimeOffset)!=null?T:0),s=Math.min(e+t,o!=null?o:1/0),u=Pe(e,n),f=Pe(s,n),{timeline:d,timescale:l,segmentUrlTemplate:m,startNumber:p,endNumber:g}=n,h=p!=null?p:1,I=[],y=d.length;for(let P=0;P<y;P++){let E=d[P],{duration:C,start:R,range:k}=E,_;o===void 0?_=i:_=Math.min(o*l,i!=null?i:1/0);let A=ai(E,d[P+1],_),x=n.availabilityTimeComplete!==!1||P!==y-1&&A!==0,M=Mu(R,C,u),N=R+M*C;for(;N<f&&M<=A;){let w=h+M;if(g!==void 0&&w>g)break;let O=m===null?null:fr(N,w)(m),B=N-n.indexTimeOffset,V=C;B<0&&(V=C+B,B=0);let q={id:String(N),time:B/l,end:(B+V)/l,duration:V/l,isInit:!1,range:k,timescale:1,url:O,number:w,timestampOffset:-(n.indexTimeOffset/l),complete:x,privateInfos:{isEMSGWhitelisted:a}};I.push(q),M++,N=R+M*C}if(N>=f||(h+=A+1,g!==void 0&&h>g))return I}return I}function Ou(n,e){if(e.timescale!==n.timescale){let{timescale:t}=n;n.timeline.push({start:e.time/e.timescale*t,duration:e.duration/e.timescale*t,repeatCount:e.count===void 0?0:e.count,range:e.range})}else n.timeline.push({start:e.time,duration:e.duration,repeatCount:e.count===void 0?0:e.count,range:e.range});return!0}var Tt=class{constructor(e,t){var g,h,I,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(g=e.timescale)!=null?g:1,d=((h=e.presentationTimeOffset)!=null?h:0)-r*u,l=((I=e.initialization)==null?void 0:I.media)===void 0?null:Be(e.initialization.media,a,o),m=e.media===void 0?null:Be(e.media,a,o),p;e.initialization!==void 0?p=e.initialization.range:e.indexRange!==void 0&&(p=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:d,initialization:{url:l,range:p},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Pe(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Pe(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return rn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:Ye(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)}getLastAvailablePosition(){var i;let{timeline:e}=this._index;if(e.length===0)return null;let t=e[e.length-1],r=Math.min(Ne(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return Ye(r,this._index)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return this._isInitialized}initialize(e){if(!this._isInitialized){for(let t=0;t<e.length;t++)Ou(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){c.error(\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Et=class{constructor(e,t){var p,g,h;if(e.duration===void 0)throw new Error(\"Invalid SegmentList: no duration\");let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t;this._isEMSGWhitelisted=s,this._periodStart=r,this._periodEnd=i;let u=(p=e.presentationTimeOffset)!=null?p:0,f=(g=e.timescale)!=null?g:1,d=u-r*f,l=((h=e.initialization)==null?void 0:h.media)===void 0?null:Be(e.initialization.media,a,o),m=e.list.map(I=>({url:I.media===void 0?null:Be(I.media,a,o),mediaRange:I.mediaRange}));this._index={list:m,timescale:f,duration:e.duration,indexTimeOffset:d,indexRange:e.indexRange,initialization:v(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=Je(this._index);return e.privateInfos===void 0&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e}getSegments(e,t){let r=this._index,{duration:i,list:a,timescale:o}=r,s=i/o,u=e-this._periodStart,[f,d]=Io(u,t,o),l=Math.min(a.length-1,Math.floor(d/i)),m=[],p=Math.floor(f/i);for(;p<=l;){let g=a[p].mediaRange,h=a[p].url,I=p*s+this._periodStart,y={id:String(p),time:I,isInit:!1,range:g,duration:s,timescale:1,end:I+s,url:h,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(y),p++}return m}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){c.error(\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `ListRepresentationIndex`\")}_replace(e){this._index=e._index}_update(){c.error(\"A `ListRepresentationIndex` cannot be updated\")}};function Bt(n){return U.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var Rt=class{constructor(e,t){var y,T,P;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:f,isEMSGWhitelisted:d}=t,l=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(T=e.presentationTimeOffset)!=null?T:0,p=s*l,g=m-p;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let h=((P=e.initialization)==null?void 0:P.media)===void 0?null:Be(e.initialization.media,u,f),I=e.media===void 0?null:Be(e.media,u,f);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:g,initialization:v(e.initialization)?void 0:{url:h,range:e.initialization.range},url:I,presentationTimeOffset:m,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*l,this._isEMSGWhitelisted=d}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,f=this._periodStart*s,d=this._scaledRelativePeriodEnd,l=e*s-f,m=(e+t)*s-f,p=this._getFirstSegmentStart(),g=this._getLastSegmentStart();if(v(p)||v(g))return[];let h=Math.max(p,l),I=Math.min(g,m);if(I+i<=h)return[];let y=[],T=a!=null?a:1,P=Math.floor(h/i);for(let E=P*i;E<=I;E+=i){let C=P+T;if(o!==void 0&&C>o)return y;let R=!v(d)&&E+i>d?d-E:i,k=E+f,_=E+this._index.presentationTimeOffset,A=u===null?null:fr(_,C)(u),x={id:String(C),number:C,time:k/s,end:(k+R)/s,duration:R/s,timescale:1,isInit:!1,scaledDuration:R/s,url:A,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(x),P++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return v(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(v(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(Ie(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Bt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(v(u)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let f=u+this._index.duration,d=this._estimateRelativeScaledEnd();return d===void 0?s>f-i:s>f-i&&o<d-i}shouldRefresh(){return!1}checkDiscontinuity(){return null}isSegmentStillAvailable(e){if(e.isInit)return!0;let t=this.getSegments(e.time,.1);return t.length===0?!1:t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){if(!this._isDynamic)return!1;let e=this._estimateRelativeScaledEnd();if(e===void 0)return!0;let{timescale:t}=this._index,r=this._getLastSegmentStart();if(v(r))return!0;let i=r+this._index.duration,a=Bt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}_replace(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator}_update(e){this._replace(e)}_getFirstSegmentStart(){var o;if(!this._isDynamic)return 0;if(this._scaledRelativePeriodEnd===0||this._scaledRelativePeriodEnd===void 0){let s=this._manifestBoundsCalculator.getEstimatedMaximumPosition((o=this._availabilityTimeOffset)!=null?o:0);if(s!==void 0&&s<this._periodStart)return null}let{duration:e,timescale:t}=this._index,r=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(r===void 0)return;let i=r>this._periodStart?(r-this._periodStart)*t:0;return Math.floor(i/e)*e}_getLastSegmentStart(){var a,o;let{duration:e,timescale:t,endNumber:r,startNumber:i=1}=this._index;if(this._isDynamic){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&this._scaledRelativePeriodEnd!==void 0&&this._scaledRelativePeriodEnd<s-this._periodStart*this._index.timescale){let l=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<l&&(l=r-i+1),(l-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let f=(u-this._periodStart)*t;if(f<0)return null;let d=Math.floor(f/e);return r!==void 0&&r-i+1<d&&(d=r-i+1),d<=0?null:(d-1)*e}else{let s=(o=this._scaledRelativePeriodEnd)!=null?o:0,u=Math.ceil(s/e);r!==void 0&&r-i+1<u&&(u=r-i+1);let f=(u-1)*e,d=U.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-f>d||u<2?f:(u-2)*e}}_estimateRelativeScaledEnd(){var e,t;if(this._index.endNumber!==void 0){let r=this._index.endNumber-((e=this._index.startNumber)!=null?e:1)+1;return Math.max(Math.min(r*this._index.duration,(t=this._scaledRelativePeriodEnd)!=null?t:1/0),0)}if(this._scaledRelativePeriodEnd!==void 0)return Math.max(this._scaledRelativePeriodEnd,0)}};function si(n,e){let t=0;for(;n.length>0;){let r=n[0];if(r.start>=e||r.repeatCount===-1)return t;if(r.repeatCount===0)n.shift(),t+=1;else{let i=n[1];if(i!==void 0&&i.start<=e)n.shift(),t+=1;else{if(r.duration<=0)return t;let a=r.start+r.duration,o=1;for(;a<e&&o<=r.repeatCount;)a+=r.duration,o++;if(o>r.repeatCount)n.shift(),t=r.repeatCount+1;else{let s=r.repeatCount-o;return r.start=a,r.repeatCount=s,t+=o,t}}}}return t}function ui(n,e){if(n.length===0)return n.push(...e),!0;if(e.length===0)return!1;let t=n.length,r=e[0].start,i=n[t-1];if(Ne(i,e[0])<r)throw new Q(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");for(let d=t-1;d>=0;d--){let l=n[d].start;if(l===r){let m=t-d;return n.splice(d,m,...e),!1}else if(l<r){let m=n[d];if(m.start+m.duration>r)return c.warn(\"RepresentationIndex: Manifest update removed all previous segments\"),n.splice(0,t,...e),!0;if(m.repeatCount===void 0||m.repeatCount<=0)return m.repeatCount<0&&(m.repeatCount=Math.floor((r-m.start)/m.duration)-1),n.splice(d+1,t-(d+1),...e),!1;if(m.start+m.duration*(m.repeatCount+1)<=r)return n.splice(d+1,t-(d+1),...e),!1;let g=(r-m.start)/m.duration-1;if(g%1===0&&m.duration===e[0].duration){let h=e[0].repeatCount<0?-1:e[0].repeatCount+g+1;return n.splice(d,t-d,...e),n[d].start=m.start,n[d].repeatCount=h,!1}return c.warn(\"RepresentationIndex: Manifest update removed previous segments\"),n[d].repeatCount=Math.floor(g),n.splice(d+1,t-(d+1),...e),!1}}let o=n[n.length-1],s=e[e.length-1];if(o.repeatCount!==void 0&&o.repeatCount<0)return o.start>s.start?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),f=s.start+s.duration*(s.repeatCount+1);return u>=f?(c.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(c.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function an(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:v(e.duration)||(r=e.start+e.duration*(e.repeatCount+1))),(i===void 0||isNaN(i))&&t!==null&&t.start!==void 0&&!isNaN(t.start)&&r!==void 0&&!isNaN(r)&&(i=t.start-r),r!==void 0&&!isNaN(r)&&i!==void 0&&!isNaN(i)&&(a===void 0||!isNaN(a))?{start:r,duration:i,repeatCount:a===void 0?0:a}:(c.warn('DASH: A \"S\" Element could not have been parsed.'),null)}function on(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"t\":let i=parseInt(r,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r}\")`):e.start=i;break;case\"d\":let a=parseInt(r,10);isNaN(a)?c.warn(`DASH: invalid d (\"${r}\")`):e.duration=a;break;case\"r\":let o=parseInt(r,10);isNaN(o)?c.warn(`DASH: invalid r (\"${r}\")`):e.repeatCount=o;break}}return e}function sn(n){let e={};for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];switch(r.name){case\"t\":let i=parseInt(r.value,10);isNaN(i)?c.warn(`DASH: invalid t (\"${r.value}\")`):e.start=i;break;case\"d\":let a=parseInt(r.value,10);isNaN(a)?c.warn(`DASH: invalid d (\"${r.value}\")`):e.duration=a;break;case\"r\":let o=parseInt(r.value,10);isNaN(o)?c.warn(`DASH: invalid r (\"${r.value}\")`):e.repeatCount=o;break}}return e}function mt(n){let e=[];if(Array.isArray(n))for(let r=0;r<n.length;r++)e.push(on(n[r]));else for(let r=0;r<n.length;r++)e.push(sn(n[r]));let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[t.length-1]===void 0?null:t[t.length-1],o=e[r+1]===void 0?null:e[r+1],s=an(i,a,o);s!==null&&t.push(s)}return t}function di(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=Array.isArray(e)?e[0].attributes.t:e[0].getAttribute(\"t\"),i=v(r)?null:parseInt(r,10);if(i===null||Number.isNaN(i))return null;if(t===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(t<i){let a=n[0],o=0;for(;;){if(a.repeatCount>0){let s=i-a.start;if(s%a.duration===0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(o++,o>=n.length)return null;if(a=n[o],a.start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}}else{let a=0,o=Array.isArray(e)?e[0]:null,s=Array.isArray(e)?null:e[0],u=i;for(;;){let f=o!==null?o.attributes.d:s==null?void 0:s.getAttribute(\"d\"),d=v(f)?null:parseInt(f,10);if(d===null||Number.isNaN(d))return null;let l=o!==null?o.attributes.r:s==null?void 0:s.getAttribute(\"r\"),m=v(l)?null:parseInt(l,10);if(m!==null){if(Number.isNaN(m)||m<0)return null;if(m>0){let h=t-u;if(h%d===0&&h/d<=m)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/d,prevSegmentsIdx:0,newElementsIdx:a}}u+=d*(m+1)}else u+=d;if(a++,a>=e.length)return null;Array.isArray(e)?o=e[a]:s=e[a];let p=o!==null?o.attributes.t:s==null?void 0:s.getAttribute(\"t\"),g=v(p)?null:parseInt(p,10);if(g!==null){if(Number.isNaN(g))return null;u=g}if(u===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(u>i)return null}}}function li(n,e){var h;let t=di(e,n);if(t===null)return c.warn('DASH: Cannot perform \"based\" update. Common segment not found.'),mt(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,u=e.length-r+i-1;if(u>=n.length)return c.info('DASH: Cannot perform \"based\" update. New timeline too short'),mt(n);let f=e.slice(r);if(a>0){let I=f[0];I.start+=I.duration*a,f[0].repeatCount-=a}if(o>0&&i!==0)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form.'),mt(n);let d=f[f.length-1],l=Array.isArray(n)?on(n[u]):sn(n[u]),m=((h=l.repeatCount)!=null?h:0)-o;if(l.duration!==d.duration||d.repeatCount>m)return c.info('DASH: Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),mt(n);l.repeatCount!==void 0&&l.repeatCount>d.repeatCount&&(d.repeatCount=l.repeatCount);let p=[],g=[];if(Array.isArray(n))for(let I=u+1;I<n.length;I++)g.push(on(n[I]));else for(let I=u+1;I<n.length;I++)g.push(sn(n[I]));for(let I=0;I<g.length;I++){let y=g[I],T=p[p.length-1]===void 0?d:p[p.length-1],P=g[I+1]===void 0?null:g[I+1],E=an(y,T,P);E!==null&&p.push(E)}return f.concat(p)}var un=class n{constructor(e,t){var E,C,R,k,_;if(!n.isTimelineIndexArgument(e))throw new Error(\"The given index is not compatible with a TimelineRepresentationIndex.\");let{availabilityTimeComplete:r,availabilityTimeOffset:i,manifestBoundsCalculator:a,isDynamic:o,isLastPeriod:s,representationId:u,representationBitrate:f,periodStart:d,periodEnd:l,isEMSGWhitelisted:m}=t,p=(E=e.timescale)!=null?E:1,g=(C=e.presentationTimeOffset)!=null?C:0,h=d*p,I=g-h;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(R=t.receivedTime)!=null?R:L(),this._unsafelyBaseOnPreviousIndex=null,t.unsafelyBaseOnPreviousRepresentation!==null&&t.unsafelyBaseOnPreviousRepresentation.index instanceof n&&(t.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=t.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=o,this._parseTimeline=(k=e.timelineParser)!=null?k:null;let y=((_=e.initialization)==null?void 0:_.media)===void 0?null:Be(e.initialization.media,u,f),T=e.media===void 0?null:Be(e.media,u,f),P;i===void 0&&r===void 0?P=1/0:P=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:P,indexRange:e.indexRange,indexTimeOffset:I,initialization:v(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:T,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:fi(e.timeline,e.startNumber,e.endNumber),timescale:p},this._scaledPeriodStart=Pe(d,this._index),this._scaledPeriodEnd=l===void 0?void 0:Pe(l,this._index)}getInitSegment(){return Je(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),rn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=this._index.timeline;return e.length===0?null:Ye(Math.max(this._scaledPeriodStart,e[0].start),this._index)}getLastAvailablePosition(){var r;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=mr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(e===null)return null;let t=Math.min(e.end,(r=this._scaledPeriodEnd)!=null?r:1/0);return Ye(t,this._index)}getEnd(){var r;if(this._isDynamic&&!this._isLastPeriod)return;if(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;let e=this._index.timeline[this._index.timeline.length-1],t=Math.min(Ne(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return Ye(t,this._index)}awaitSegmentBetween(e,t){var f,d;if(Ie(e<=t),!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timescale:r,timeline:i}=this._index,a=Bt(r),o=Pe(t,this._index),s=mr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(f=this._scaledPeriodEnd)!=null?f:1/0)+a>=Math.min(o,(d=this._scaledPeriodEnd)!=null?d:1/0))return!1;let u=Pe(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],p=Ne(l,null,this._scaledPeriodEnd)+a;if(u<p+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:u-a<this._scaledPeriodEnd&&o+a>this._scaledPeriodStart:!1}isSegmentStillAvailable(e){return e.isInit?!0:(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),wu(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))}checkDiscontinuity(e){this._refreshTimeline();let t=this._index.timeline;return t===null&&(t=this._getTimeline(),this._index.timeline=t),bo({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof je&&e.isHttpError(404):!1}_replace(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod}_update(e){this._index.timeline===null&&(this._index.timeline=this._getTimeline()),e._index.timeline===null&&(e._index.timeline=e._getTimeline()),ui(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod}isStillAwaitingFutureSegments(){var o;if(!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timeline:e}=this._index;if(e.length===0){if(this._scaledPeriodEnd!==void 0){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&Pe(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Bt(this._index.timescale),r=mr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(r!==null&&!r.isLastOfTimeline){let s=Math.min(r.end,(o=this._scaledPeriodEnd)!=null?o:1/0);return!(this._scaledPeriodEnd!==void 0&&s+t>=this._scaledPeriodEnd)}if(!this._isLastPeriod)return!1;if(this._scaledPeriodEnd===void 0)return!0;let i=e[e.length-1];return Ne(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}static isTimelineIndexArgument(e){return typeof e.timelineParser==\"function\"||Array.isArray(e.timeline)}_refreshTimeline(){if(this._index.timeline===null&&(this._index.timeline=this._getTimeline()),!this._isDynamic)return;let e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime();if(v(e))return;let t=Pe(e,this._index),r=si(this._index.timeline,t);this._index.startNumber!==void 0?this._index.startNumber+=r:this._index.endNumber!==void 0&&(this._index.startNumber=r+1)}_getTimeline(){if(this._parseTimeline===null)return this._index.timeline!==null?this._index.timeline:(c.error(\"DASH: Timeline already lazily parsed.\"),[]);let e=this._parseTimeline();this._parseTimeline=null;let{MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:t}=U.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return fi(mt(e),this._index.startNumber,this._index.endNumber);let r;return this._unsafelyBaseOnPreviousIndex._index.timeline===null?(r=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=r):r=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,fi(li(e,r),this._index.startNumber,this._index.endNumber)}};function fi(n,e,t){if(t===void 0)return n;let r=e!=null?e:1;for(let i=0;i<n.length;i++){let a=n[i];if(r+=a.repeatCount+1,r>t){if(r===t+1)return n.slice(0,i+1);{let o=n.slice(0,i),s=ge({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function wu(n,e,t,r){let i=mr(e,t,r);if(i===null)return!1;for(let a=0;a<e.timeline.length;a++){if(i.timelineIdx<a)return!1;let o=e.timeline[a],s=(o.start-e.indexTimeOffset)/e.timescale;if(s>n.time)return!1;if(s===n.time)return o.range===void 0?n.range===void 0:!v(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let f=(s-o.start)/o.duration-1;return f%1===0&&f<=i.newRepeatCount}}return!1}function mr(n,e,t){if(n.timeline.length<=0)return null;if(n.availabilityTimeOffset===1/0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Ne(a,null,t)}}let r=e.getEstimatedMaximumPosition(n.availabilityTimeOffset);if(r===void 0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Ne(a,null,t)}}for(let i=n.timeline.length-1;i>=n.timeline.length;i--){let a=n.timeline[i],o=a.start+a.duration;if(Ye(o,n)<=r){let s=Ne(a,n.timeline[i+1],t);if(Ye(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let f=Pe(r,n)-a.start,d=Math.floor(f/a.duration);return Ie(d>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:d-1,end:a.start+d*a.duration}}}}return null}var cr=un;function Ue(n,e,t){if(typeof String.prototype.startsWith==\"function\")return n.startsWith(e,t);let r=typeof t==\"number\"?Math.max(t,0):0;return n.substring(r,r+e.length)===e}var Du=/^(?:[a-z]+:)?\\/\\//i,Nu=/^(?:([^:\\/?#]+):)?(?:\\/\\/([^\\/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function pi(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(Du.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?pi(n.substring(0,t)):e+1}function Bu(n,e){let t=So(n),r=So(e);if(r.scheme)return mi(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return r.authority?(i.authority=r.authority,i.path=ci(r.path),mi(i)):(r.path===\"\"?(i.path=t.path,r.query||(i.query=t.query)):Ue(r.path,\"/\")?i.path=ci(r.path):i.path=ci(Lu(t,r.path)),mi(i))}var dn=new Map,Uu=200;function So(n){var r,i,a,o,s;if(dn.has(n))return dn.get(n);let e=n.match(Nu),t;return e===null?t={scheme:\"\",authority:\"\",path:\"\",query:\"\",fragment:\"\"}:t={scheme:(r=e[1])!=null?r:\"\",authority:(i=e[2])!=null?i:\"\",path:(a=e[3])!=null?a:\"\",query:(o=e[4])!=null?o:\"\",fragment:(s=e[5])!=null?s:\"\"},dn.size>=Uu&&dn.clear(),dn.set(n,t),t}function mi(n){let e=\"\";return n.scheme&&(e+=n.scheme+\":\"),n.authority&&(e+=\"//\"+n.authority),e+=n.path,n.query&&(e+=\"?\"+n.query),n.fragment&&(e+=\"#\"+n.fragment),e}function ci(n){let e=n.split(/(?=\\/)/),t=[];for(let r=0;r<e.length;r++){let i=e[r];if(!(i===\"..\"||i===\".\"||i===\"\")){if(i===\"/..\"){t.pop(),r===e.length-1&&t.push(\"/\");continue}if(i===\"/.\"){r===e.length-1&&t.push(\"/\");continue}t.push(i)}}return t.join(\"\")}function Lu(n,e){if(n.authority&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function yo(...n){var r,i,a;let e=n.filter(o=>o!==\"\"),t=e.length;if(t===0)return\"\";if(t===1)return(r=e[0])!=null?r:\"\";{let o=(i=e[0])!=null?i:\"\",s=(a=e[1])!=null?a:\"\",u=Bu(o,s),f=e.slice(2);return yo(u,...f)}}var pr=yo;var ln=class{constructor(){this._refs=new Map,this._stored=[]}addReferences(e){for(let t of e)t.attributes.refId!==void 0&&this._refs.set(t.attributes.refId,t)}add(e,t){this._tryParsing(e,t,!1)||this._stored.push([e,t]),t.attributes.refId!==void 0&&(this._refs.set(t.attributes.refId,t),this._resolveStoredRefs(!1))}finalize(){this._resolveStoredRefs(!0)}_resolveStoredRefs(e){for(let t=this._stored.length-1;t>=0;t--){let[r,i]=this._stored[t];(this._tryParsing(r,i,e)||e)&&this._stored.splice(t,1)}return this._stored.length===0}_tryParsing(e,t,r){if(t.attributes.ref===void 0)return gi(e,t),!0;let i=this._getReferenced(t.attributes.ref);return i===void 0?(r&&(c.warn(\"DASH: forcing the parsing of a referencing ContentProtection\"),gi(e,t)),!1):(t.children.cencPssh.push(...i.children.cencPssh),t.attributes.keyId===void 0&&i.attributes.keyId!==void 0&&(t.attributes.keyId=i.attributes.keyId),t.attributes.schemeIdUri===void 0&&i.attributes.schemeIdUri!==void 0&&(t.attributes.schemeIdUri=i.attributes.schemeIdUri),t.attributes.value===void 0&&i.attributes.value!==void 0&&(t.attributes.value=i.attributes.value),gi(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function gi(n,e){let t;if(e.attributes.schemeIdUri!==void 0&&e.attributes.schemeIdUri.substring(0,9)===\"urn:uuid:\"&&(t=e.attributes.schemeIdUri.substring(9).replace(/-/g,\"\").toLowerCase()),e.attributes.keyId!==void 0&&e.attributes.keyId.length>0){let o={keyId:e.attributes.keyId,systemId:t};n.contentProtections===void 0?n.contentProtections={keyIds:[o],initData:[]}:n.contentProtections.keyIds===void 0?n.contentProtections.keyIds=[o]:n.contentProtections.keyIds.push(o)}if(t===void 0)return;let{cencPssh:r}=e.children,i=[];for(let o of r)i.push({systemId:t,data:o});if(i.length===0)return;if(n.contentProtections===void 0){n.contentProtections={keyIds:[],initData:[{type:\"cenc\",values:i}]};return}let a=K(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function gr(n){let e=Date.parse(n)-L();if(isNaN(e)){c.warn(\"DASH Parser: Invalid clock received: \",n);return}return e}function hi(n){let e=n.children.utcTimings.filter(t=>(t.schemeIdUri===\"urn:mpeg:dash:utc:http-iso:2014\"||t.schemeIdUri===\"urn:mpeg:dash:utc:http-xsdate:2014\")&&t.value!==void 0);return e.length>0?e[0].value:void 0}function hr(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function Ii(n){for(let e=n.length-1;e>=0;e--){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=hr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=hr(i);if(s===void 0)return{safe:void 0,unsafe:void 0};o=s}if(r!==void 0&&a===null||i!==void 0&&o===null)return c.info(\"Parser utils: found Period with no segment. \",\"Going to previous one to calculate last position\"),{safe:void 0,unsafe:void 0};if(o!==null)return a!==null?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(a!==null)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}function Ir(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function bi(n){for(let e=0;e<=n.length-1;e++){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=Ir(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Ir(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"Parser utils: found Period with no segment. \",\"Going to next one to calculate first position\");return}if(o!==null)return a!==null?Math.max(a,o):o;if(a!==null)return a}}}function Si(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=bi(n),t=Ii(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var fn=class{constructor(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=!e.isDynamic||e.timeShiftBufferDepth===void 0?null:e.timeShiftBufferDepth,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}setLastPosition(e,t){this._lastPosition=e,this._positionTime=t}lastPositionIsKnown(){return this._isDynamic?this._positionTime!==void 0&&this._lastPosition!==void 0:this._lastPosition!==void 0}getEstimatedMinimumSegmentTime(){var r;if(!this._isDynamic||this._timeShiftBufferDepth===null)return 0;let e=(r=this.getEstimatedLiveEdge())!=null?r:this.getEstimatedMaximumPosition(0);return e===void 0?void 0:e-this._timeShiftBufferDepth}getEstimatedLiveEdge(){if(!(!this._isDynamic||this._serverTimestampOffset===void 0))return(L()+this._serverTimestampOffset)/1e3-this._availabilityStartTime}getEstimatedMaximumPosition(e){if(!this._isDynamic)return this._lastPosition;let t=this.getEstimatedLiveEdge();return t!==void 0&&e!==1/0?t+e:this._positionTime!==void 0&&this._lastPosition!==void 0?Math.max(this._lastPosition-this._positionTime+L()/1e3,0):this._lastPosition}};function yi(n,e){return n.type!==\"dynamic\"?0:v(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function _i(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}var Fu=typeof Ee==\"object\"&&typeof Ee.TextDecoder==\"function\",zu=typeof Ee==\"object\"&&typeof Ee.TextEncoder==\"function\";function mn(n){if(zu)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation\",a)}let e,t=encodeURIComponent(n);if(typeof unescape==\"function\")e=unescape(t);else{let i=/[0-9a-fA-F]/,a=t.length;e=\"\";for(let o=0;o<t.length;o++){let s=!1;if(t[o]===\"%\"){if(o<=a-6&&t[o+1]===\"u\"&&i.test(t[o+2])&&i.test(t[o+3])&&i.test(t[o+4])&&i.test(t[o+5])){let u=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let u=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(u),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function Wu(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function _o(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Le(n){if(Fu)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"\";c.warn(\"Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation\",a)}let e=n;e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let t=Wu(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_\\+-\\.\\/]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+_o(o,4):\"%\"+_o(o,2)}}return decodeURIComponent(r)}function cn(n){let e=n.length,t=new Uint8Array(e/2);for(let r=0,i=0;r<e;r+=2,i++)t[i]=parseInt(n.substring(r,r+2),16)&255;return t}function To(n,e=\"\"){let t=\"\";for(let r=0;r<n.byteLength;r++)t+=(n[r]>>>4).toString(16),t+=(n[r]&15).toString(16),e.length>0&&r<n.byteLength-1&&(t+=e);return t}function Ti(n,e){let t=e;for(;t<n.length&&n[t]!==0;)t+=1;let r=n.subarray(e,t);return{end:t+1,string:Le(r)}}function Ei(n){if(n.length===0)return[];let e=[n[0]];for(let t=1;t<n.length;t++){let r=n[t],i=e[e.length-1];for(;(i.duration===void 0||i.start+i.duration>r.start)&&(c.warn(\"DASH: Updating overlapping Periods.\",i==null?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));){if(e.pop(),e.length===0)break;i=e[e.length-1]}e.push(r)}return e}function Ri(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!v(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||v(e.availabilityStartTime)?0:e.availabilityStartTime;else{let f=t[t.length-1];if(!v(f)&&!v(f.periodEnd))a=f.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];v(r.attributes.duration)?i===n.length-1?o=e.duration:v(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function Vu(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Dt){let s=n[o];if(s!==void 0)for(let u of s)u.id===a&&(u.trickModeTracks===void 0&&(u.trickModeTracks=[]),u.trickModeTracks.push(r))}}}var Eo=Vu;var qu=[\"subtitle\",\"caption\"];function Pi(n,e,t,r){function i(o,s){let u=o.split(\"/\")[0];if(se(Dt,u))return u;if(o===\"application/ttml+xml\")return\"text\";if(o===\"application/mp4\")return s!==null&&K(s,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&se(qu,f.value))!==void 0?\"text\":void 0}function a(o){switch(o.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(o.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(e!==null){let o=i(e,r);if(o!==void 0)return o}if(t!==null){let o=a(t);if(o!==void 0)return o}for(let o=0;o<n.length;o++){let s=n[o],{mimeType:u,codecs:f}=s.attributes;if(u!==void 0){let d=i(u,r);if(d!==void 0)return d}if(f!==void 0){let d=a(f);if(d!==void 0)return d}}}var Hu=/[, ]+/g;function Ro(n){return J(n)?n.trim().replace(Hu,\", \"):\"\"}function Po(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let f,d,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(f=parseInt(i,10)),s!==void 0&&(s===\"16\"?d=\"pq\":s===\"18\"&&(d=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(l=\"rec2020\"),!(f===void 0||d===void 0))return{colorDepth:f,eotf:d,colorSpace:l}}function vi(n,e){var g,h,I;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:f,isLastPeriod:d}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:y=>f===void 0?!1:f.some(({schemeIdUri:T})=>T===y.schemeIdUri),isLastPeriod:d,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},p;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;p=new Tt(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;p=new Et(y,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),T=n.children.segmentTemplate;T!==void 0&&y.push(T);let P=H({},...y);(P.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((g=P.availabilityTimeOffset)!=null?g:0)+((h=e.availabilityTimeOffset)!=null?h:0)),(P.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(I=P.availabilityTimeComplete)!=null?I:e.availabilityTimeComplete),p=cr.isTimelineIndexArgument(P)?new cr(P,m):new Rt(P,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:T}=y;p=new Tt(T,m)}else if(y.segmentList!==void 0){let{segmentList:T}=y;p=new Et(T,m)}else p=new Rt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return p}function et(n,e){var i;if(e.length===0)return n;let t=e.map(a=>({url:a.value}));if(n.length===0)return t;let r=[];for(let a=0;a<n.length;a++){let o=n[a];for(let s=0;s<t.length;s++){let u=t[s],f=pr(o.url,u.url);r.push({url:f,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Gu(n,e){let t=[];if(n.children.inbandEventStreams!==void 0&&t.push(...n.children.inbandEventStreams),e.children.inbandEventStreams!==void 0&&t.push(...e.children.inbandEventStreams),t.length!==0)return t}function Ku({adaptationProfiles:n,essentialProperties:e,supplementalProperties:t,manifestProfiles:r,codecs:i}){if(((n!=null?n:\"\")+(r!=null?r:\"\")).indexOf(\"http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10\")!==-1&&(i===\"hvc1.2.4.L153.B0\"||i===\"hev1.2.4.L153.B0\"))return{colorDepth:10,eotf:\"pq\",colorSpace:\"rec2020\"};let o=K([...e!=null?e:[],...t!=null?t:[]],s=>s.schemeIdUri===\"urn:mpeg:mpegB:cicp:TransferCharacteristics\");if(o!==void 0)switch(o.value){case\"15\":return;case\"16\":return{eotf:\"pq\"};case\"18\":return{eotf:\"hlg\"}}if(i!==void 0&&/^vp(08|09|10)/.exec(i))return Po(i)}function Ci(n,e,t){var i,a,o,s,u,f,d;let r=[];for(let l of n){let m=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(A=>A.id===m);)m+=\"-dup\";let p=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,g=Gu(l,e),h=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,I;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(I=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let y=H({},t,{availabilityTimeOffset:I,availabilityTimeComplete:h,unsafelyBaseOnPreviousRepresentation:p,adaptation:e,inbandEventStreams:g}),T=vi(l,y),P;l.attributes.bitrate===void 0?(c.warn(\"DASH: No usable bitrate found in the Representation.\"),P=0):P=l.attributes.bitrate;let E=et(t.baseURLs,l.children.baseURLs),C=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(A=>({baseUrl:A.url,id:A.serviceLocation})),R={bitrate:P,cdnMetadata:C,index:T,id:m};l.children.supplementalProperties!==void 0&&K(l.children.supplementalProperties,A=>A.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&A.value===\"JOC\")&&(R.isSpatialAudio=!0);let k;l.attributes.codecs!==void 0?k=l.attributes.codecs:e.attributes.codecs!==void 0&&(k=e.attributes.codecs),k!==void 0&&(k=k===\"mp4a.40.02\"?\"mp4a.40.2\":k,R.codecs=k);let _;l.attributes.supplementalCodecs!==void 0?_=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(_=e.attributes.supplementalCodecs),_!==void 0&&(R.supplementalCodecs=Ro(_)),l.attributes.frameRate!==void 0?R.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(R.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?R.height=l.attributes.height:e.attributes.height!==void 0&&(R.height=e.attributes.height),l.attributes.mimeType!==void 0?R.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(R.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?R.width=l.attributes.width:e.attributes.width!==void 0&&(R.width=e.attributes.width);{let A=[...(f=e.children.contentProtections)!=null?f:[],...(d=l.children.contentProtections)!=null?d:[]];for(let x of A)t.contentProtectionParser.add(R,x)}R.hdrInfo=Ku({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:k}),r.push(R)}return r}function ju(n){if(n===void 0)return!1;let e=n.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&n.value===\"1\",t=n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"description\";return e||t}function Yu(n,e){return!!(n!==void 0&&n.some(r=>r.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&r.value===\"2\")||e!==void 0&&e.some(r=>r.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&r.value===\"caption\"))}function Qu(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function $u(n,e){if(J(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return J(n.attributes.language)&&(u+=`-${n.attributes.language}`),t===!0&&(u+=\"-cc\"),r===!0&&(u+=\"-cc\"),i===!0&&(u+=\"-ad\"),a===!0&&(u+=\"-si\"),o&&(u+=\"-trickMode\"),J(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),J(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),J(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function Xu(n){if(!v(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!v(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>r)}return[]}function Ai(n,e){var s,u,f,d,l,m,p;let t={video:[],audio:[],text:[]},r=[],i={},a=[];for(let g=0;g<n.length;g++){let h=n[g],I=h.children,{essentialProperties:y,roles:T,label:P}=I,E=Array.isArray(T)&&T.some(Se=>Se.value===\"main\")&&T.some(Se=>Se.schemeIdUri===\"urn:mpeg:dash:role:2011\"),C=h.children.representations,R=(s=h.attributes.availabilityTimeComplete)!=null?s:e.availabilityTimeComplete,k;(h.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(k=((u=h.attributes.availabilityTimeOffset)!=null?u:0)+((f=e.availabilityTimeOffset)!=null?f:0));let _=h.attributes.mimeType,A=h.attributes.codecs,x=Pi(C,J(_)?_:null,J(A)?A:null,v(I.roles)?null:I.roles);if(x===void 0)continue;let M=(d=h.attributes.selectionPriority)!=null?d:1,N=h.attributes.id,w=Xu(h),O=[];e.segmentTemplate!==void 0&&O.push(e.segmentTemplate),h.children.segmentTemplate!==void 0&&O.push(h.children.segmentTemplate);let B={availabilityTimeComplete:R,availabilityTimeOffset:k,baseURLs:et(e.baseURLs,I.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:O,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},V=Array.isArray(y)?K(y,Se=>Se.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,q=(l=V==null?void 0:V.value)==null?void 0:l.split(\" \"),Y=q!==void 0,{accessibilities:G}=I,z;T!==void 0&&T.some(Se=>Se.value===\"dub\")&&(z=!0);let X;x!==\"text\"?X=!1:X=Yu(G,T);let Z;x===\"text\"&&T!==void 0&&T.some(Se=>Se.value===\"forced-subtitle\"||Se.value===\"forced_subtitle\")&&(Z=!0);let me;x!==\"audio\"?me=!1:G!==void 0&&(me=G.some(ju));let ce;x!==\"video\"?ce=!1:G!==void 0&&(ce=G.some(Qu));let de=$u(h,{isAudioDescription:me,isForcedSubtitle:Z,isClosedCaption:X,isSignInterpreted:ce,isTrickModeTrack:Y,type:x});for(;se(a,de);)de+=\"-dup\";let be=de;a.push(de),B.unsafelyBaseOnPreviousAdaptation=(p=(m=e.unsafelyBaseOnPreviousPeriod)==null?void 0:m.getAdaptation(de))!=null?p:null;let tr=Ci(C,h,B),pe={id:de,representations:tr,type:x,isTrickModeTrack:Y};if(v(h.attributes.language)||(pe.language=h.attributes.language),v(X)||(pe.closedCaption=X),v(me)||(pe.audioDescription=me),z===!0&&(pe.isDub=!0),Z!==void 0&&(pe.forcedSubtitles=Z),ce===!0&&(pe.isSignInterpreted=!0),P!==void 0&&(pe.label=P),q!==void 0)r.push({adaptation:pe,trickModeAttachedAdaptationIds:q});else{let Se=-1;for(let Yt of w){let Ge=i[Yt];if(Ge!==void 0&&Ge.newID!==be&&se(Ge.adaptationSetSwitchingIDs,N)){Se=ne(t[x],Ot=>Ot[0].id===Yt);let xe=t[x][Se];if(xe!==void 0&&xe[0].audioDescription===pe.audioDescription&&xe[0].closedCaption===pe.closedCaption&&xe[0].language===pe.language){c.info('DASH Parser: merging \"switchable\" AdaptationSets',N,Yt),xe[0].representations.push(...pe.representations),xe[1]={priority:Math.max(M,xe[1].priority),isMainAdaptation:E||xe[1].isMainAdaptation,indexInMpd:Math.min(g,xe[1].indexInMpd)};break}}}Se<0&&t[x].push([pe,{priority:M,isMainAdaptation:E,indexInMpd:g}])}!v(N)&&v(i[N])&&(i[N]={newID:be,adaptationSetSwitchingIDs:w})}let o=Dt.reduce((g,h)=>{let I=t[h];return I.length>0&&(I.sort(vo),g[h]=I.map(([y])=>y)),g},{});return t.video.sort(vo),Eo(o,r),o}function vo(n,e){let t=e[1].priority-n[1].priority;return t!==0?t:n[1].isMainAdaptation!==e[1].isMainAdaptation?n[1].isMainAdaptation?-1:1:n[1].indexInMpd-e[1].indexInMpd}var Zu=Ae();function ki(n,e){var o,s,u,f,d;let t=[],r=Ri(n,e);if(r.length!==n.length)throw new Error(\"MPD parsing error: the time information are incoherent.\");let{isDynamic:i,manifestBoundsCalculator:a}=e;!i&&!v(e.duration)&&a.setLastPosition(e.duration);for(let l=n.length-1;l>=0;l--){let m=l===n.length-1,p=n[l],g=e.xlinkInfos.get(p),h=et(e.baseURLs,p.children.baseURLs),{periodStart:I,periodDuration:y,periodEnd:T}=r[l],P;for(v(p.attributes.id)?(c.warn(\"DASH: No usable id found in the Period. Generating one.\"),P=\"gen-dash-period-\"+Zu()):P=p.attributes.id;t.some(V=>V.id===P);)P+=\"-dup\";let E=g!==void 0?g.receivedTime:e.receivedTime,C=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(P))!=null?s:null,R=p.attributes.availabilityTimeComplete,k=p.attributes.availabilityTimeOffset,{manifestProfiles:_,contentProtectionParser:A}=e,{segmentTemplate:x}=p.children;A.addReferences((u=p.children.contentProtections)!=null?u:[]);let M={availabilityTimeComplete:R,availabilityTimeOffset:k,baseURLs:h,contentProtectionParser:A,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:m,manifestProfiles:_,receivedTime:E,segmentTemplate:x,start:I,unsafelyBaseOnPreviousPeriod:C},N=Ai(p.children.adaptations,M),w=((f=e.xmlNamespaces)!=null?f:[]).concat((d=p.attributes.namespaces)!=null?d:[]),O=ed(p.children.eventStreams,I,w),B={id:P,start:I,end:T,duration:y,adaptations:N,streamEvents:O};if(t.unshift(B),!a.lastPositionIsKnown()){let V=Ju(N);if(!i)typeof V==\"number\"&&a.setLastPosition(V);else if(typeof V==\"number\"){let q=L()/1e3;a.setLastPosition(V,q)}else{let q=Co(e,I);if(q!==void 0){let[Y,G]=q;a.setLastPosition(Y,G)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=Co(e,0);if(l!==void 0){let[m,p]=l;a.setLastPosition(m,p)}}return Ei(t)}function Co(n,e){if(v(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"DASH Parser: no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=L()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=L()/1e3,i=r+t;if(i>=e)return[i,r]}}function Ju(n){let e=null,t=!0,r=sr(n).filter(a=>!v(a)),i=_i(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let u=s.index.getLastAvailablePosition();u!==null&&(t=!1,typeof u==\"number\"&&(e=v(e)?u:Math.max(e,u)))}}if(v(e)){if(t)return null}else return e}function ed(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,f=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let d of o.children.events)if(d.eventStreamData!==void 0){let l=((a=d.presentationTime)!=null?a:0)/u+e,m=d.duration===void 0?void 0:l+d.duration/u,p,g;if(!st&&d.eventStreamData instanceof Element)p=d.eventStreamData;else try{g={namespaces:f,data:typeof d.eventStreamData==\"string\"?d.eventStreamData:Le(new Uint8Array(d.eventStreamData))}}catch(h){c.error(\"DASH: Error while parsing event-stream:\",h instanceof Error?h.message:\"Unknown error\")}r.push({start:l,end:m,id:d.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:p,xmlData:g}}})}}return r}function Ut(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let u=o.type===\"dynamic\",f=K(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(m.value)),d=!v(f)&&!v(f.value)?gr(f.value):void 0,l=!v(d)&&!isNaN(d)?d:void 0;if(!v(l)&&r!==!0)e.externalClockOffset=l;else if(u&&r!==!0){let m=hi(n);if(!v(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(g){return g.success?(e.externalClockOffset=gr(g.data),Ut(n,e,t,!0)):(t.push(g.error),c.warn(\"DASH Parser: Error on fetching the clock ressource\",g.error),Ut(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:f,xlinkActuate:d}=a.periods[u].attributes;!v(f)&&d===\"onLoad\"&&s.push({index:u,ressource:f})}return s.length===0?td(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(f){if(f.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let d=f.length-1;d>=0;d--){let l=s[d].index,{parsed:m,warnings:p,receivedTime:g,sendingTime:h,url:I}=f[d];p.length>0&&t.push(...p);for(let y of m)i.set(y,{receivedTime:g,sendingTime:h,url:I});a.periods.splice(l,1,...m)}return Ut(n,e,t,r,i)}}}}function td(n,e,t,r){var w,O,B,V,q;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,pi(e.url))}]:[],u=et(s,i.baseURLs),f=yi(a,e.referenceDateTime),d=a.timeShiftBufferDepth,{externalClockOffset:l,unsafelyBaseOnPreviousManifest:m}=e,{externalClockOffset:p}=e,g=new fn({availabilityStartTime:f,isDynamic:o,timeShiftBufferDepth:d,serverTimestampOffset:p}),h=new ln;h.addReferences((w=i.contentProtections)!=null?w:[]);let I={availabilityStartTime:f,baseURLs:u,clockOffset:l,contentProtectionParser:h,duration:a.duration,isDynamic:o,manifestBoundsCalculator:g,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,timeShiftBufferDepth:d,unsafelyBaseOnPreviousManifest:m,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},y=ki(i.periods,I);h.finalize();let T=a.duration,P,E,C=null,R;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(P=a.minimumUpdatePeriod===0?U.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:k,maximumSafePosition:_,maximumUnsafePosition:A}=Si(y),x=L();if(o){let Y;_!==void 0?Y=_:p===void 0?(c.warn(\"DASH Parser: use system clock to define maximum position\"),Y=Date.now()/1e3-f):Y=(L()+p)/1e3-f;let G=g.getEstimatedLiveEdge();G===void 0&&(A!==void 0?G=A:G=Y),R={isLinear:!0,maximumSafePosition:Y,livePosition:G,time:x},E=k,C=d!=null?d:null,C!==null&&E!==void 0&&G-E>C&&(C=G-E)}else{E=k,E===void 0&&(E=(B=(O=y[0])==null?void 0:O.start)!=null?B:0);let Y=T!=null?T:1/0;if(y[y.length-1]!==void 0){let G=y[y.length-1],z=(V=G.end)!=null?V:G.duration!==void 0?G.start+G.duration:void 0;z!==void 0&&z<Y&&(Y=z)}_!==void 0&&_<Y&&(Y=_),R={isLinear:!1,maximumSafePosition:Y,livePosition:void 0,time:x}}let M=!o||n.attributes.minimumUpdatePeriod===void 0&&(((q=y[y.length-1])==null?void 0:q.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:f,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:M,periods:y,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:E,timeshiftDepth:C,maximumTimeData:R},lifetime:P,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var br=Ut;var Ao=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function Sr(n){if(n>=Ao.length)throw new Error(\"Unable to parse base64 string.\");let e=Ao[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function yr(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"base64ToBytes: base64 given miss padding\"),t+=e===3?\"=\":e===2?\"==\":\"===\");let r=t.indexOf(\"=\");if(r!==-1&&r<t.length-2)throw new Error(\"Unable to parse base64 string.\");let i=t.endsWith(\"==\")?2:t.endsWith(\"=\")?1:0,a=t.length,o=new Uint8Array(a/4*3),s;for(let u=0,f=0;u<a;u+=4,f+=3)s=Sr(t.charCodeAt(u))<<18|Sr(t.charCodeAt(u+1))<<12|Sr(t.charCodeAt(u+2))<<6|Sr(t.charCodeAt(u+3)),o[f]=s>>16,o[f+1]=s>>8&255,o[f+2]=s&255;return o.subarray(0,o.length-i)}var nd=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,rd=/([0-9]+)-([0-9]+)/;function ve(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new Oe(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ee(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new Oe(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function ke(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new Oe(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function xi(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new Oe(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function _r(n,e){let t=Date.parse(n);return isNaN(t)?[null,new Oe(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function Ve(n,e){if(!J(n))return[0,new Oe(`\\`${e}\\` property is empty`)];let t=nd.exec(n);return t===null?[null,new Oe(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(J(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(J(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(J(t[6])?t[6]:\"0\")*24*60*60+parseFloat(J(t[8])?t[8]:\"0\")*60*60+parseFloat(J(t[10])?t[10]:\"0\")*60+parseFloat(J(t[12])?t[12]:\"0\"),null]}function Pt(n,e){let t=rd.exec(n);return t===null?[null,new Oe(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function ko(n,e){try{return[yr(n),null]}catch(t){return[null,new Oe(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Lt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:ke(n,e)}function _e(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!v(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function fe(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(s.message),e.push(s)),o!==null&&(n[r]=o)}}var Oe=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function ct(n){return lr(n)}function tt(n){let e=typeof n==\"string\"?n:ct(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function id(n){let e=[],t=[];for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=\"string\"&&i.tagName===\"cenc:pssh\"){let a=ct(i.children);if(a!==null&&a.length>0){let[o,s]=ko(a,\"cenc:pssh\");s!==null&&(c.warn(s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function ad(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=cn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function nt(n){let[e,t]=id(n.children),r=ad(n);return[{children:e,attributes:r},t]}function Mi(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"id\":e.id=r;break;case\"lang\":e.language=r;break;case\"contentType\":e.contentType=r;break;case\"par\":e.par=r;break}}return e}function Oi(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Pt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function rt(n){let e={},t=[],r=fe(e,t),i=n.children;for(let a=0;a<i.length;a++){let o=i[a];if(typeof o!=\"string\"&&o.tagName===\"Initialization\"){let[s,u]=Oi(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!v(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ee,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:ke,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Pt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:ve,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ee,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ee,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ee,dashName:\"endNumber\"});break}}return[e,t]}function wi(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Pt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Pt,dashName:\"mediaRange\"});break}}return[e,t]}function pn(n){let[e,t]=rt(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let u=a[s];if(typeof u!=\"string\"&&u.tagName===\"SegmentURL\"){let[f,d]=wi(u);i.push(f),r=r.concat(d)}}return[H(e,{list:i}),r]}function Di(n){let e=n.children;return function(){for(let t=e.length-1;t>=0;t--){let r=e[t];(typeof r==\"string\"||r.tagName!==\"S\")&&e.splice(t,1)}return e}}function vt(n){let[e,t]=rt(n),r=t,i;for(let s=0;s<n.children.length;s++){let u=n.children[s];typeof u!=\"string\"&&u.tagName===\"SegmentTimeline\"&&(i=Di(u))}let a=H({},e,{duration:e.duration,timelineParser:i}),o=fe(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!v(u))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function od(n){let e={baseURLs:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"BaseURL\":let[o,s]=tt(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(_e(a));break;case\"SegmentBase\":let[u,f]=rt(a);e.segmentBase=u,f.length>0&&(r=r.concat(f));break;case\"SegmentList\":let[d,l]=pn(a);r=r.concat(l),e.segmentList=d;break;case\"SegmentTemplate\":let[m,p]=vt(a);r=r.concat(p),e.segmentTemplate=m;break;case\"ContentProtection\":let[g,h]=nt(a);h.length>0&&(r=r.concat(h)),g!==void 0&&t.push(g);break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[_e(a)]:e.supplementalProperties.push(_e(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function sd(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ee,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Lt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ee,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ee,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ee,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new Oe(\"No bitrate found on a Representation\")),[e,t]}function xo(n){let[e,t]=od(n.children),[r,i]=sd(n),a=t.concat(i);return[{children:e,attributes:r},a]}function ud(n){let e={baseURLs:[],representations:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"Accessibility\":e.accessibilities===void 0?e.accessibilities=[_e(a)]:e.accessibilities.push(_e(a));break;case\"BaseURL\":let[o,s]=tt(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break;case\"ContentComponent\":e.contentComponent=Mi(a);break;case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[_e(a)]:e.essentialProperties.push(_e(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(_e(a));break;case\"Label\":let u=ct(a.children);u!=null&&(e.label=u);break;case\"Representation\":let[f,d]=xo(a);e.representations.push(f),d.length>0&&(r=r.concat(d));break;case\"Role\":v(e.roles)?e.roles=[_e(a)]:e.roles.push(_e(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[_e(a)]:e.supplementalProperties.push(_e(a));break;case\"SegmentBase\":let[l,m]=rt(a);e.segmentBase=l,m.length>0&&(r=r.concat(m));break;case\"SegmentList\":let[p,g]=pn(a);e.segmentList=p,g.length>0&&(r=r.concat(g));break;case\"SegmentTemplate\":let[h,I]=vt(a);e.segmentTemplate=h,I.length>0&&(r=r.concat(I));break;case\"ContentProtection\":let[y,T]=nt(a);T.length>0&&(r=r.concat(T)),y!==void 0&&t.push(y);break}}return t.length>0&&(e.contentProtections=t),[e,r]}function dd(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ee,dashName:\"group\"});break;case\"lang\":e.language=a;break;case\"contentType\":e.contentType=a;break;case\"par\":e.par=a;break;case\"minBandwidth\":r(a,{asKey:\"minBitrate\",parser:ee,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ee,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ee,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ee,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ee,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ee,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Lt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Lt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ee,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:xi,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:xi,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"codecs\":e.codecs=a;break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:ve,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Lt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ee,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:ke,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:ke,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ee,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:ke,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:ve,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function Mo(n){let e=n.children,[t,r]=ud(e),[i,a]=dd(n),o=r.concat(a);return[{children:t,attributes:i},o]}function ld(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ee,dashName:\"timescale\"});break;default:Ue(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Oo(n,e){let[t,r]=ld(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(v(a.attributes.id)||(o.id=a.attributes.id),!v(a.attributes.presentationTime)){let[s,u]=ee(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,u]=ee(a.attributes.duration,\"duration\");u!==null&&r.push(u),s!==null&&(o.duration=s)}if(a.posStart<a.posEnd){let s=e.substring(a.posStart,a.posEnd);o.eventStreamData=s}i.push(o)}return[{children:{events:i},attributes:t},r]}function fd(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let u=0;u<n.length;u++){let f=n[u];if(typeof f!=\"string\")switch(f.tagName){case\"BaseURL\":let[d,l]=tt(f);d!==void 0&&t.push(d),o=o.concat(l);break;case\"AdaptationSet\":let[m,p]=Mo(f);r.push(m),o=o.concat(p);break;case\"EventStream\":let[g,h]=Oo(f,e);s.push(g),o=o.concat(h);break;case\"SegmentTemplate\":let[I,y]=vt(f);i=I,y.length>0&&(o=o.concat(y));break;case\"ContentProtection\":let[T,P]=nt(f);P.length>0&&(o=o.concat(P)),T!==void 0&&a.push(T);break}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function md(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:Ve,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:Ve,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:ve,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Ue(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Tr(n,e){let[t,r]=fd(n.children,e),[i,a]=md(n),o=r.concat(a);return[{children:t,attributes:i},o]}function cd(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let u=0;u<n.length;u++){let f=n[u];if(typeof f!=\"string\")switch(f.tagName){case\"BaseURL\":let[d,l]=tt(f);d!==void 0&&t.push(d),s=s.concat(l);break;case\"Location\":r.push(ct(f.children));break;case\"Period\":let[m,p]=Tr(f,e);i.push(m),s=s.concat(p);break;case\"UTCTiming\":let g=_e(f);a.push(g);break;case\"ContentProtection\":let[h,I]=nt(f);I.length>0&&(s=s.concat(I)),h!==void 0&&o.push(h);break}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function pd(n){let e={},t=[],r=fe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:_r,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:_r,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:_r,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:Ve,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:Ve,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:Ve,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:Ve,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:Ve,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:Ve,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:Ve,dashName:\"maxSubsegmentDuration\"});break;default:Ue(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function wo(n,e){let[t,r]=cd(n.children,e),[i,a]=pd(n),o=r.concat(a);return[{children:t,attributes:i},o]}function Ni(n,e){let t=ii(n),r=t[t.length-1];if(r===void 0||typeof r==\"string\"||r.tagName!==\"MPD\")throw new Error(\"DASH Parser: document root should be MPD\");let[i,a]=wo(r,n),o=br(i,e,a);return s(o);function s(u){if(u.type===\"done\")return u;if(u.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[u.value.url],format:\"string\",continue(f){if(f.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let d=u.value.continue(f[0].responseData);return s(d)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(f){let d=[];for(let m=0;m<f.length;m++){let{responseData:p,receivedTime:g,sendingTime:h,url:I}=f[m];if(!p.success)throw p.error;let y=\"<root>\"+p.data+\"</root>\",T=ii(y),P=T[T.length-1];if(P===void 0||typeof P==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=P.children,C=[],R=[];for(let k=0;k<E.length;k++){let _=E[k];if(typeof _==\"string\"||_.tagName!==\"Period\")continue;let[A,x]=Tr(_,y);R.push(...x),C.push(A)}d.push({url:I,receivedTime:g,sendingTime:h,parsed:C,warnings:R})}let l=u.value.continue(d);return s(l)}}};We(u)}}var Do=Ni;var gd=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",No=gd;function F(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Bi(n){return n===1/0?!0:n===-1/0?!1:n}function pt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=F(t,e.buffer,a,o))}}function gt(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=F(i,e.buffer,s,u);break;case 13:t.value=F(i,e.buffer,s,u);break;case 14:let f=F(i,e.buffer,s,u);t.keyId=cn(f.replace(/-/g,\"\"));break;case 15:try{let d=F(i,e.buffer,s,u);r.cencPssh.push(yr(d))}catch(d){}break;case 78:t.ref=F(i,e.buffer,s,u);break;case 79:t.refId=F(i,e.buffer,s,u);break}}}function Bo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break}}}function qe(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break}}}function Ft(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 29:{let s=new DataView(e.buffer);n.initialization===void 0&&(n.initialization={}),n.initialization.range=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 67:n.initialization===void 0&&(n.initialization={}),n.initialization.media=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Uo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=F(t,e.buffer,a,o);break;case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 30:n.media=F(t,e.buffer,a,o);break;case 18:{let s=new DataView(e.buffer);n.mediaRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}}}}function Er(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=Uo(a,e);t.pushParsers(i,D,o);break}default:t.pushParsers(i,D,D);break}}}function zt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let u=a;for(let f=0;f<o/24;f++)n.timeline.push({start:s.getFloat64(u,!0),duration:s.getFloat64(u+8,!0),repeatCount:s.getFloat64(u+16,!0)}),u+=24;break}case 67:n.initialization={media:F(t,e.buffer,a,o)};break;case 28:n.index=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 30:n.media=F(t,e.buffer,a,o);break;case 32:{n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Lo(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,D,pt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=gt(a,e);t.pushParsers(i,D,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,D,qe(a,e));break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 17:{let a={};n.segmentBase=a;let o=Ft(a,e);t.pushParsers(i,D,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Er(a,e,t),s=Ft(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,D,zt(a,e));break}default:t.pushParsers(i,D,D);break}}}function Fo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 5:n.codingDependency=new DataView(e.buffer).getUint8(0)===0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function zo(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=pt(a,e);t.pushParsers(i,D,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,D,Bo(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=gt(a,e);t.pushParsers(i,D,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=D,s=qe(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=D,s=qe(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=Lo(a.children,e,t),s=Fo(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(a,e);t.pushParsers(i,D,o);break}case 17:{let a={};n.segmentBase=a;let o=Ft(a,e);t.pushParsers(i,D,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Er(a,e,t),s=Ft(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,D,zt(a,e));break}default:t.pushParsers(i,D,D);break}}}function Wo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break;case 53:n.minBitrate=s.getFloat64(a,!0);break;case 49:n.maxBitrate=s.getFloat64(a,!0);break;case 56:n.minWidth=s.getFloat64(a,!0);break;case 52:n.maxWidth=s.getFloat64(a,!0);break;case 55:n.minHeight=s.getFloat64(a,!0);break;case 51:n.maxHeight=s.getFloat64(a,!0);break;case 54:n.minFrameRate=s.getFloat64(a,!0);break;case 50:n.maxFrameRate=s.getFloat64(a,!0);break;case 57:n.selectionPriority=s.getFloat64(a,!0);break;case 58:n.segmentAlignment=Bi(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Bi(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 5:n.codingDependency=s.getFloat64(a,!0)!==0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break;case 71:let u=F(t,e.buffer,a,o);n.label=u;break}}}function Vo(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=hd(o,e,r);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function qo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:let u={key:\"\",value:\"\"},f=a,d=s.getUint32(f);f+=4,u.key=F(t,e.buffer,f,d),f+=d;let l=s.getUint32(f);f+=4,u.value=F(t,e.buffer,f,l),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}function hd(n,e,t){let r=new TextDecoder;return function(a,o,s){let u=new DataView(e.buffer);switch(a){case 25:n.presentationTime=u.getFloat64(o,!0);break;case 1:n.duration=u.getFloat64(o,!0);break;case 0:n.id=F(r,e.buffer,o,s);break;case 69:let f=u.getFloat64(o,!0),d=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(f,d);break}}}function Rr(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=zo(o.children,e,t),u=Wo(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=D,u=pt(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=Vo(o.children,e,t,r),u=qo(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,D,zt(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=gt(o,e);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function Pr(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 45:n.start=new DataView(e.buffer).getFloat64(a,!0);break;case 1:n.duration=new DataView(e.buffer).getFloat64(a,!0);break;case 32:n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break;case 46:n.xlinkHref=F(t,e.buffer,a,o);break;case 47:n.xlinkActuate=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=new DataView(e.buffer).getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break;case 70:let s={key:\"\",value:\"\"},u=new DataView(e.buffer),f=a,d=u.getUint32(f);f+=4,s.key=F(t,e.buffer,f,d),f+=d;let l=u.getUint32(f);f+=4,s.value=F(t,e.buffer,f,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}function Ho(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=D,u=pt(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Rr(o.children,e,t,r),u=Pr(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=D,u=qe(o,e);t.pushParsers(a,s,u);break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=gt(o,e);t.pushParsers(a,D,s);break}default:t.pushParsers(a,D,D);break}}}function Go(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=F(i,t.buffer,s,u);break;case 2:e.profiles=F(i,t.buffer,s,u);break;case 33:e.type=F(i,t.buffer,s,u);break;case 34:let f=F(i,t.buffer,s,u);e.availabilityStartTime=new Date(f).getTime()/1e3;break;case 35:let d=F(i,t.buffer,s,u);e.availabilityEndTime=new Date(d).getTime()/1e3;break;case 36:let l=F(i,t.buffer,s,u);e.publishTime=new Date(l).getTime()/1e3;break;case 68:r=new DataView(t.buffer),e.duration=r.getFloat64(s,!0);break;case 37:r=new DataView(t.buffer),e.minimumUpdatePeriod=r.getFloat64(s,!0);break;case 38:r=new DataView(t.buffer),e.minBufferTime=r.getFloat64(s,!0);break;case 39:r=new DataView(t.buffer),e.timeShiftBufferDepth=r.getFloat64(s,!0);break;case 40:r=new DataView(t.buffer),e.suggestedPresentationDelay=r.getFloat64(s,!0);break;case 41:r=new DataView(t.buffer),e.maxSegmentDuration=r.getFloat64(s,!0);break;case 42:r=new DataView(t.buffer),e.maxSubsegmentDuration=r.getFloat64(s,!0);break;case 66:let m=F(i,t.buffer,s,u);n.locations.push(m);break;case 70:let p={key:\"\",value:\"\"};r=new DataView(t.buffer);let g=s,h=r.getUint32(g);g+=4,p.key=F(i,t.buffer,g,h),g+=h;let I=r.getUint32(g);g+=4,p.value=F(i,t.buffer,g,I),e.namespaces===void 0?e.namespaces=[p]:e.namespaces.push(p);break}}}function Ui(n,e,t,r){return function(a){switch(a){case 1:n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=Ho(n.mpd.children,e,t,r),s=Go(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break;default:t.pushParsers(a,D,D);break}}}function Ko(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Rr(o.children,e,t,r),u=Pr(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,D,D);break}}}var gn=class{constructor(){this._currentNodeId=null,this.childrenParser=D,this.attributeParser=D,this._stack=[{nodeId:null,children:D,attribute:D}]}pushParsers(e,t,r){this._currentNodeId=e,this.childrenParser=t,this.attributeParser=r,this._stack.push({nodeId:e,attribute:r,children:t})}popIfCurrent(e){if(this._currentNodeId!==e)return;this._stack.pop();let{nodeId:t,children:r,attribute:i}=this._stack[this._stack.length-1];this._currentNodeId=t,this.attributeParser=i,this.childrenParser=r}reset(){this.childrenParser=D,this.attributeParser=D,this._stack=[{nodeId:null,children:D,attribute:D}]}};var Id=15e3,hn=class{constructor(){this._parsersStack=new gn,this._instance=null,this._mpdData=null,this._linearMemory=null,this.status=\"uninitialized\",this._initProm=null,this._warnings=[],this._isParsing=!1}waitForInitialization(){var e;return(e=this._initProm)!=null?e:Promise.reject(\"No initialization performed yet.\")}async initialize(e){if(this.status!==\"uninitialized\")return Promise.reject(new Error(\"DashWasmParser already initialized.\"));if(!this.isCompatible())return this.status=\"failure\",Promise.reject(new Error(\"Target not compatible with WebAssembly.\"));this.status=\"initializing\";let t=this._parsersStack,r=new TextDecoder,i=this,a={env:{memoryBase:0,tableBase:0,memory:new WebAssembly.Memory({initial:10}),table:new WebAssembly.Table({initial:1,element:\"anyfunc\"}),onTagOpen:f,onCustomEvent:m,onAttribute:l,readNext:p,onTagClose:d}},o=null,s;typeof e.wasmUrl==\"string\"?s=fetch(e.wasmUrl):(o=URL.createObjectURL(new Blob([e.wasmUrl],{type:\"application/wasm\"})),s=fetch(o));let u=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=u.catch(async g=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"Unable to call `instantiateStreaming` on WASM\",g instanceof Error?g:\"\");let h=await s;if(h.status<200||h.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(h.status));let I=await h.arrayBuffer();return WebAssembly.instantiate(I,a)}).then(g=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=g,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(g=>{let h=g instanceof Error?g.toString():\"Unknown error\";throw c.warn(\"DW: Could not create DASH-WASM parser:\",h),this.status=\"failure\",g}),this._initProm;function f(g){return t.childrenParser(g)}function d(g){return t.popIfCurrent(g)}function l(g,h,I){return t.attributeParser(g,h,I)}function m(g,h,I){let y=i._linearMemory,T=new Uint8Array(y.buffer,h,I);if(g===1){let P=r.decode(T);c.warn(\"WASM Error Event:\",P),i._warnings.push(new Error(P))}else if(g===0){let P=r.decode(T);c.warn(\"WASM Log Event:\",P)}}function p(g,h){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let I=i._linearMemory,{mpd:y,cursor:T}=i._mpdData,P=Math.min(h,Id,y.byteLength-T);return new Uint8Array(I.buffer,g,P).set(new Uint8Array(y,T,P)),i._mpdData.cursor+=P,P}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=br(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return No&&typeof Ee.TextDecoder==\"function\"}_parseMpd(e){var s;if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={},r=this._linearMemory,i=Ui(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,D),this._warnings=[];try{this._instance.instance.exports.parse()}catch(u){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,u}let a=(s=t.mpd)!=null?s:null,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_parseXlink(e){if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={periods:[]},r=this._linearMemory,i=Ko(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,D),this._warnings=[];try{this._instance.instance.exports.parse()}catch(s){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,s}let{periods:a}=t,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_processParserReturnValue(e){if(e.type===\"done\")return e;if(e.type===\"needs-clock\"){let t=r=>{if(r.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let i=e.value.continue(r[0].responseData);return this._processParserReturnValue(i)};return{type:\"needs-resources\",value:{urls:[e.value.url],format:\"string\",continue:t}}}else if(e.type===\"needs-xlinks\"){let t=r=>{let i=[];for(let o=0;o<r.length;o++){let{responseData:s,receivedTime:u,sendingTime:f,url:d}=r[o];if(!s.success)throw s.error;let[l,m]=this._parseXlink(s.data);i.push({url:d,receivedTime:u,sendingTime:f,parsed:l,warnings:m})}let a=e.value.continue(i);return this._processParserReturnValue(a)};return{type:\"needs-resources\",value:{urls:e.value.xlinksUrls,format:\"arraybuffer\",continue:t}}}else We(e)}};var jo=hn;var Ct=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function vr(n,e,t){let r=e(n.getReference(),t);return{getCurrentTime(){return n.getCurrentTime()},getReadyState(){return n.getReadyState()},getPlaybackRate(){return n.getPlaybackRate()},getIsPaused(){return n.getIsPaused()},getReference(){return r},listen(i,a){var o;t.isCancelled()||((o=a==null?void 0:a.clearSignal)==null?void 0:o.isCancelled())===!0||r.onUpdate(i,{clearSignal:a==null?void 0:a.clearSignal,emitCurrentValue:a==null?void 0:a.includeLastObservation})},deriveReadOnlyObserver(i){return vr(this,i,t)}}}var In=class{constructor(e,t,r,i){this._src=e,this._contentId=t,this._messageSender=r,this._cancelSignal=i}getCurrentTime(){}getReadyState(){}getIsPaused(){}getReference(){return this._src}setPlaybackRate(e){this._messageSender({type:\"update-playback-rate\",contentId:this._contentId,value:e})}getPlaybackRate(){}listen(e,t){var r;this._cancelSignal.isCancelled()||((r=t==null?void 0:t.clearSignal)==null?void 0:r.isCancelled())===!0||this._src.onUpdate(e,{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:t==null?void 0:t.includeLastObservation})}deriveReadOnlyObserver(e){return vr(this,e,this._cancelSignal)}};function Li(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-L(),u=!1,m={reject:h=>{var P,E;if(u||i.isCancelled())return;u=!0,i.deregister(g);let I=h,y=(P=I==null?void 0:I.message)!=null?P:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new Ke(y,(E=I==null?void 0:I.canRetry)!=null?E:!1,I==null?void 0:I.xhr);o(T)},resolve:h=>{if(u||i.isCancelled())return;u=!0,i.deregister(g);let I=h.receivingTime!==void 0?h.receivingTime-s:void 0,y=h.sendingTime!==void 0?h.sendingTime-s:void 0;a({responseData:h.data,size:h.size,requestDuration:h.duration,url:h.url,receivedTime:I,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(g),e(t,r,i).then(a,o))}},p=n({url:t,timeout:r.timeout},m);i.register(g);function g(h){u||(u=!0,typeof p==\"function\"&&p(),o(h))}})}function bd(n){return function(t,r,i){if(t===void 0)throw new Error(\"Cannot perform HTTP(s) request. URL not known\");switch(n){case\"arraybuffer\":return le({url:t,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return le({url:t,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return le({url:t,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:We(n)}}}function Fi({customManifestLoader:n},e){let t=bd(e);return typeof n!=\"function\"?t:Li(n,t)}function zi(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,u){var T;let{responseData:f}=i,d=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,m=t!=null?t:d,g={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},h=ae.dashParsers;if(h.wasm===null||h.wasm.status===\"uninitialized\"||h.wasm.status===\"failure\")return c.debug(\"DASH: WASM MPD Parser not initialized. Running JS one.\"),I();{let P=Ed(f);if(!Rd(P))return c.info(\"DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),I();if(h.wasm.status===\"initialized\"){c.debug(\"DASH: Running WASM MPD Parser.\");let E=h.wasm.runWasmParser(P,g);return y(E)}else return c.debug(\"DASH: Awaiting WASM initialization before parsing the MPD.\"),h.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(h.wasm===null||h.wasm.status!==\"initialized\")return c.warn(\"DASH: WASM MPD parser initialization failed. Running JS parser instead\"),I();c.debug(\"DASH: Running WASM MPD Parser.\");let C=h.wasm.runWasmParser(P,g);return y(C)})}function I(){if(h.fastJs!==null){let P=_d(f),E=h.fastJs(P,g);return y(E)}else if(h.native!==null){let P=Td(f),E=h.native(P,g);return y(E)}else throw new Error(\"No MPD parser is imported\")}function y(P){if(P.type===\"done\"){if(P.value.warnings.length>0&&o(P.value.warnings),s.isCancelled())return Promise.reject(s.cancellationError);let R=[];return{manifest:new Nt(P.value.parsed,n,R),url:l,warnings:R}}let{value:E}=P,C=E.urls.map(R=>u(()=>{let k=U.getCurrent().DEFAULT_REQUEST_TIMEOUT,_=U.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?le({url:R,responseType:\"text\",timeout:k,connectionTimeout:_,cancelSignal:s}):le({url:R,responseType:\"arraybuffer\",timeout:k,connectionTimeout:_,cancelSignal:s})}).then(k=>{if(E.format===\"string\"){if(typeof k.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return H(k,{responseData:{success:!0,data:k.responseData}})}else{if(!(k.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return H(k,{responseData:{success:!0,data:k.responseData}})}},k=>{let _=he(k,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return H({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:_}})}));return Promise.all(C).then(R=>E.format===\"string\"?(Sd(R),y(E.continue(R))):(yd(R),y(E.continue(R))))}}}function Sd(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&typeof t.data==\"string\")&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function yd(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&t.data instanceof ArrayBuffer)&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function _d(n){if(n instanceof ArrayBuffer)return Le(new Uint8Array(n));if(typeof n==\"string\")return n;if(n instanceof Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Td(n){if(n instanceof ArrayBuffer)return new DOMParser().parseFromString(Le(new Uint8Array(n)),\"text/xml\");if(typeof n==\"string\")return new DOMParser().parseFromString(n,\"text/xml\");if(n instanceof Document)return n;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Ed(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return mn(n).buffer;if(n instanceof Document)return mn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Rd(n){let e=new DataView(n);return e.getUint16(0)===61371&&e.getUint8(2)===191?!0:!(e.getUint16(0)===65279||e.getUint16(0)===65534)}function we([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function He(n,e){if(n===\"audio\"||n===\"video\")return e===\"video/mp4\"||e===\"audio/mp4\"?\"mp4\":e===\"video/webm\"||e===\"audio/webm\"?\"webm\":void 0;if(n===\"text\")return e===\"application/mp4\"?\"mp4\":void 0}var W=class{constructor(){let[e,t]=Pd();this._isUsed=!1,this._trigger=e,this.signal=new Wi(t)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(()=>{this.cancel()});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=e!=null?e:new ie;this._trigger(t)}static isCancellationError(e){return e instanceof ie}},Wi=class{constructor(e){this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e(t=>{for(this.cancellationError=t,this._isCancelled=!0;this._listeners.length>0;)try{let r=this._listeners.pop();r==null||r(t)}catch(r){c.error(\"Error while calling clean up listener\",r instanceof Error?r.toString():\"Unknown error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(Ie(this.cancellationError!==null),e(this.cancellationError),D):(this._listeners.push(e),()=>this.deregister(e))}deregister(e){for(let t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)}},ie=class n extends Error{constructor(){let e=\"This task was cancelled.\";super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\"}};function Pd(){let n=D;return[function(t){n(t)},function(t){n=t}]}function At(...n){let e=n.length,t=-1,r=0,i;for(;++t<e;)i=n[t],r+=typeof i==\"number\"?i:i.length;let a=new Uint8Array(r),o=0;for(t=-1;++t<e;)i=n[t],typeof i==\"number\"?o+=i:i.length>0&&(a.set(i,o),o+=i.length);return a}function Yo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function Vi(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function te(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function ht(n,e){return(n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3])*4294967296+n[e+4]*16777216+n[e+5]*65536+n[e+6]*256+n[e+7]}function Qe(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=te(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=ht(n,r+8)}if(isNaN(i)||i<=0)return-1;if(te(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function Cr(n){let e=0,t=[],r=null;for(;e<=n.length;){if(e===n.length){r=null;break}r=n.subarray(e,1/0);let i=Qe(r,1836019558);if(i<0)break;let a=te(n,i+e),o=e+i+a;if(o>n.length)break;let s=Qe(r,1835295092);if(s<0)break;let u=te(n,s+e),f=e+s+u;if(f>n.length)break;let d=Math.max(o,f),l=n.subarray(e,d);t.push(l),e=d}return t.length===0?[null,r]:[t,r]}function vd(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function Cd(n,e,t){return n.slice(e,t)}var qi=typeof Uint8Array.prototype.slice==\"function\"?Cd:vd;function Hi(n,e){let t=n;for(let r of e){let i=ue(t,r);if(i===null)return null;t=i}return t}function ue(n,e){let t=Wt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function Qo(n,e){let t=[],r=n;for(;;){let i=Wt(r,e);if(i===null)return t;Ie(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function Wt(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=te(n,o),o+=4,i=te(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=ht(n,o),o+=8}if(a<0)throw new Error(\"ISOBMFF: Size out of range\");if(i===e)return e===1970628964&&(o+=16),[r,o,r+a];r+=a}return null}function Ar(n){let e=0,t=ue(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Wt(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return c.warn(\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=qi(t,i[0],i[2]),o=$o(a,i[1]-i[0]);o!==void 0&&r.push({systemId:o,data:a}),t[i[0]+4]=102,t[i[0]+5]=114,t[i[0]+6]=101,t[i[0]+7]=101,e=i[2]}return r}function $o(n,e){if(n[e]>1){c.warn(\"ISOBMFF: un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=qi(n,t,t+16);return To(r)}function Gi(n){let e=ue(n,1836019558);return e===null?null:ue(e,1953653094)}function Xo(n){return Qo(n,1836019558).reduce((t,r)=>{let i=ue(r,1953653094);return i!==null&&t.push(i),t},[])}function Ki(n){return ue(n,1835295092)}function ji(n){let e=ue(n,1836019574);if(e===null)return null;let t=ue(e,1953653099);return t===null?null:ue(t,1835297121)}function Zo(n,e=0){return ue(n.subarray(e),1701671783)}function bn(n,e){let t=Wt(n,1936286840);if(t===null)return null;let r=e,i=t[2]-t[0],a=t[1],o=n[a];a+=8;let s=te(n,a);a+=4;let u;if(o===0)u=te(n,a),a+=4,r+=te(n,a)+i,a+=4;else if(o===1)u=ht(n,a),a+=8,r+=ht(n,a)+i,a+=8;else return null;let f=[];a+=2;let d=Yo(n,a);for(a+=2;--d>=0;){let l=te(n,a);a+=4;let m=(l&2147483648)>>>31,p=l&2147483647;if(m===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let g=te(n,a);a+=4,a+=4,f.push({time:u,duration:g,timescale:s,range:[r,r+p-1]}),u+=g,r+=p}return f}function Yi(n){let e=Gi(n);if(e===null)return;let t=ue(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return ht(t,4);if(r===0)return te(t,4)}function Ad(n){let e=ue(n,1952868452);if(e===null)return;let t=1,r=Vi(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),te(e,t)):void 0}function Qi(n){let e=Xo(n);if(e.length===0)return;let t=0;for(let r of e){let i=ue(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=Vi(i,a);a+=3;let u=(s&256)>0,f=0;if(!u&&(f=Ad(r),f===void 0))return;let d=(s&1)>0,l=(s&4)>0,m=(s&512)>0,p=(s&1024)>0,g=(s&2048)>0,h=te(i,a);a+=4,d&&(a+=4),l&&(a+=4);let I=h,y=0;for(;I-- >0;)u?(y+=te(i,a),a+=4):y+=f,m&&(a+=4),p&&(a+=4),g&&(a+=4);t+=y}return t}function Sn(n){let e=ji(n);if(e===null)return;let t=ue(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return te(t,r+16);if(i===0)return te(t,r+8)}function Jo(n){let e=[],t=0;for(;t<n.length;){let r=Zo(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)c.warn(\"ISOBMFF: EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=Ti(r,o);o=s;let{end:f,string:d}=Ti(r,o);o=f;let l=te(r,o);o+=4;let m=te(r,o);o+=4;let p=te(r,o);o+=4;let g=te(r,o);o+=4;let h=r.subarray(o,i),I={schemeIdUri:u,value:d,timescale:l,presentationTimeDelta:m,eventDuration:p,id:g,messageData:h};e.push(I)}}if(e.length!==0)return e}function es(n){let e=Hi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=ue(t,1701733238),i=0;if(r===null?(i=28,r=ue(t,1701733217)):i=78,r===null)return null;let a=Hi(r.subarray(i),[1936289382,1935894633,1952804451]);if(a===null||a.byteLength<24)return null;let o=a.subarray(8,24);return o.every(s=>s===0)?null:o}function $i(n,e){if(e){if(Qe(n,1718909296)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Qe(n,1836019574)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Qe(n,1836019558)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Qe(n,1835295092)<0)throw new Re(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function yn(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let f=new W,d=f.linkToSignal(i);f.signal.register(u),n(e,t,r,f.signal,Me(ge({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(p){l(),f.cancel(),u(p)}}})).then(m=>{if(l(),!f.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(p){u(p);return}s(m)}},m=>{l(),u(m)});function l(){f.signal.deregister(u),d()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||He(t.type,t.mimeType)!==\"mp4\"||$i(new Uint8Array(s),t.segment.isInit)}}}function _n(n,e){return n===null?null:e.url===null?n.baseUrl:pr(n.baseUrl,e.url)}function Tn(n,e,t,r,i){if(e.range===void 0)return le({url:n,responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));if(e.indexRange===void 0)return le({url:n,headers:{Range:we(e.range)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));if(e.range[1]+1===e.indexRange[0])return le({url:n,headers:{Range:we([e.range[0],e.indexRange[1]])},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(s=>({resultType:\"segment-loaded\",resultData:s}));let a=le({url:n,headers:{Range:we(e.range)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),o=le({url:n,headers:{Range:we(e.indexRange)},responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([a,o]).then(([s,u])=>{let f=At(new Uint8Array(s.responseData),new Uint8Array(u.responseData)),d=Math.min(s.sendingTime,u.sendingTime),l=Math.max(s.receivedTime,u.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:n,responseData:f,size:s.size+u.size,requestDuration:l-d,sendingTime:d,receivedTime:l}}})}function En(n,e,t,r,i){let{segment:a}=e,o=a.range!==void 0?{Range:we(a.range)}:void 0,s=null;function u(f){let d=new Uint8Array(f.chunk),l=s!==null?At(s,d):d,m=Cr(l),p=m[0];s=m[1],!(p!==null&&(p.forEach(g=>{r.onNewChunk(g)}),i.isCancelled()))&&(r.onProgress({duration:f.duration,size:f.size,totalSize:f.totalSize}),i.isCancelled())}return ar({url:n,headers:o,onData:u,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:i}).then(f=>({resultType:\"chunk-complete\",resultData:f}))}function ts(n,e,t,r,i,a){if(e.segment.isInit)return Tn(n,e.segment,r,a,i);let o=He(e.type,e.mimeType);if(t&&(o===\"mp4\"||o===void 0)){if(Zt())return En(n,e,r,i,a);Xe(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let{segment:s}=e;return le({url:n,responseType:\"arraybuffer\",headers:s.range!==void 0?{Range:we(s.range)}:void 0,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress}).then(u=>({resultType:\"segment-loaded\",resultData:u}))}function Xi({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:yn(r);function r(i,a,o,s,u){let f=_n(i,a.segment);return f===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?ts(f,a,n,o,u,s):new Promise((d,l)=>{let m=!1,y={reject:R=>{var x,M;if(m||s.isCancelled())return;m=!0,s.deregister(C);let k=R,_=(x=k==null?void 0:k.message)!=null?x:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",A=new Ke(_,(M=k==null?void 0:k.canRetry)!=null?M:!1,k==null?void 0:k.xhr);l(A)},resolve:R=>{m||s.isCancelled()||(m=!0,s.deregister(C),d({resultType:\"segment-loaded\",resultData:{responseData:R.data,size:R.size,requestDuration:R.duration}}))},progress:R=>{m||s.isCancelled()||u.onProgress({duration:R.duration,size:R.size,totalSize:R.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(C),ts(f,a,n,o,u,s).then(d,l))}},T;a.segment.range!==void 0&&(T=[a.segment.range],a.segment.indexRange!==void 0&&T.push(a.segment.indexRange));let P={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:f},E=e(P,y);s.register(C);function C(R){m||(m=!0,typeof E==\"function\"&&E(),l(R))}})}}var Ji=408125543,ns=357149030,kd=2807729,xd=17545,Md=475249515,Od=187,wd=179,Dd=183,Nd=241;function It(n,e,t,[r,i]){let a=r;for(;a<i;){let o=Ud(t,a);if(o===null)return null;let{value:s,length:u}=o,f=a+u,d=Ld(t,f);if(d===null)return null;let{length:l,value:m}=d,p=f+l,g=p+m;if(s===n)return[p,g];if(e.length>0){for(let h=0;h<e.length;h++)if(s===e[h]){let I=e.slice(h+1,e.length);return It(n,I,t,[p,g])}}a=g}return null}function kr(n,e){let t=It(kd,[Ji,ns],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/Zi(n,t[0],r)}function Bd(n,e){let t=It(xd,[Ji,ns],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Fd(n,t[0]):r===8?zd(n,t[0]):null}function ea(n,e){let t=It(Ji,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=kr(n,r);if(a===null)return null;let o=Bd(n,r);if(o===null)return null;let s=It(Md,[],n,[r,i]);if(s===null)return null;let u=[],f=s[0];for(;f<s[1];){let l=It(Od,[],n,[f,s[1]]);if(l===null)break;let m=It(wd,[],n,[l[0],l[1]]);if(m===null)return null;let p=Zi(n,m[0],m[1]-m[0]),g=It(Nd,[Dd],n,[l[0],l[1]]);if(g===null)return null;let h=Zi(n,g[0],g[1]-g[0])+r;u.push({time:p,rangeStart:h}),f=l[1]}let d=[];for(let l=0;l<u.length;l++){let m=u[l];l===u.length-1?d.push({time:m.time,timescale:a,duration:l===0?o:o-m.time,range:[m.rangeStart,1/0]}):d.push({time:m.time,timescale:a,duration:u[l+1].time-m.time,range:[m.rangeStart,u[l+1].rangeStart-1]})}return d}function rs(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function Ud(n,e){let t=rs(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function Ld(n,e){let t=rs(n,e);if(t===void 0)return c.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm: impossible length\"),null;let r=(n[e]&(1<<8-t)-1)*Math.pow(2,(t-1)*8);for(let i=1;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function Fd(n,e){return new DataView(n.buffer).getFloat32(e)}function zd(n,e){return new DataView(n.buffer).getFloat64(e)}function Zi(n,e,t){let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return r}function Rn(n,e,t,r){let i=Yi(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Qi(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&c.warn(\"DASH: Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,u=t.duration*r,f=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=f&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function Wd(n,e){if(n.length<=0)return!1;let t=n.length;for(let r=0;r<t;r++){let i=n[r],a=e,{messageData:o}=i,s=Le(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function ta(n,e){if(n.length===0)return;let{manifestRefreshEventsFromEMSGs:t,EMSGs:r}=n.reduce((o,s)=>(s.schemeIdUri===\"urn:mpeg:dash:event:2012\"&&s.value===\"1\"?(o.manifestRefreshEventsFromEMSGs===void 0&&(o.manifestRefreshEventsFromEMSGs=[]),o.manifestRefreshEventsFromEMSGs.push(s)):(o.EMSGs===void 0&&(o.EMSGs=[]),o.EMSGs.push(s)),o),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),i=r==null?void 0:r.map(o=>({type:\"emsg\",value:o})),a=e===void 0||t===void 0?!1:Wd(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function na({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var P,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:f}=t,d=[o,s];if(u===null)return a.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:d};let l=u instanceof Uint8Array?u:new Uint8Array(u),m=He(r.type,r.mimeType),p=m===\"mp4\"||m===void 0,g=[];if(p){let C=Ar(l),R;a.isInit&&(R=(P=es(l))!=null?P:void 0),(C.length>0||R!==void 0)&&g.push({initDataType:\"cenc\",keyId:R,initData:C})}if(!a.isInit){let C=p?Rn(l,f,a,i):null,R=(E=a.timestampOffset)!=null?E:0;if(p){let k=Jo(l);if(k!==void 0){let _=k.filter(x=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(x)),A=ta(_,r.manifestPublishTime);if(A!==void 0){let{needsManifestRefresh:x,inbandEvents:M}=A;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:R,appendWindow:d,inbandEvents:M,protectionData:g,needsManifestRefresh:x}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:R,protectionData:g,appendWindow:d}}let{indexRange:h}=a,I;if(m===\"webm\")I=ea(l,0);else if(p&&(I=bn(l,Array.isArray(h)?h[0]:0),n===!0&&I!==null&&I.length>0)){let C=I[I.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;p?y=Sn(l):m===\"webm\"&&(y=kr(l,0));let T=v(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:g,initTimescale:T,segmentList:I!=null?I:void 0}}}function ra({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:yn(t);function t(r,i,a,o,s){let{segment:u}=i,{range:f}=u,d=_n(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return Tn(d,u,a,o,s);let l=He(i.type,i.mimeType),m=l===\"mp4\"||l===void 0;if(n&&m){if(Zt())return En(d,i,a,s,o);Xe(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}return m?le({url:d,responseType:\"arraybuffer\",headers:Array.isArray(f)?{Range:we(f)}:null,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}).then(p=>({resultType:\"segment-loaded\",resultData:p})):le({url:d,responseType:\"text\",headers:Array.isArray(f)?{Range:we(f)}:null,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}).then(p=>({resultType:\"segment-loaded\",resultData:p}))}}function Vd(n){let e=Ki(n);return e===null?\"\":Le(e)}function qd(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml.im1t\":return\"ttml\";case\"wvtt\":return\"vtt\"}throw new Error(`The codec used for the subtitles \"${n}\" is not managed yet.`)}function Hd(n,e){switch(e){case\"application/ttml+xml\":return\"ttml\";case\"application/x-sami\":case\"application/smil\":return\"sami\";case\"text/vtt\":return\"vtt\"}if(n!==void 0&&n.toLowerCase()===\"srt\")return\"srt\";throw new Error(`could not find a text-track parser for the type ${e!=null?e:\"\"}`)}function is({segment:n,language:e,codecs:t},r,i,a){if(n.isInit)return null;let o,s;i===null?a?(o=n.time,s=n.end):c.warn(\"Transport: Unavailable time data for current text track.\"):(o=i.time,i.duration!==void 0?s=o+i.duration:!a&&n.complete&&(s=o+n.duration));let u=qd(t);return{data:Vd(r),type:u,language:e,start:o,end:s}}function as(n,e,t){let{segment:r}=n;if(r.isInit)return null;let i,a;t?c.warn(\"Transport: Unavailable time data for current text track.\"):(i=r.time,r.complete&&(a=r.time+r.duration));let o=Hd(n.codecs,n.mimeType);return{data:e,type:o,language:n.language,start:i,end:a}}function Gd(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,u;if(typeof n==\"string\"?u=mn(n):n instanceof Uint8Array?u=n:u=new Uint8Array(n),o){let p=bn(u,Array.isArray(s)?s[0]:0);if(i===!0&&p!==null&&p.length>0){let h=p[p.length-1];Array.isArray(h.range)&&(h.range[1]=1/0)}let g=Sn(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:g,segmentList:p!=null?p:void 0}}let f=Rn(u,e,a,r),d=is(t,u,f,e),l=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:d,chunkSize:u.length,chunkInfos:f,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Kd(n,e,t){let{periodStart:r,periodEnd:i,segment:a}=t,{timestampOffset:o=0}=a;if(a.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let s,u;if(typeof n!=\"string\"){let d=n instanceof Uint8Array?n:new Uint8Array(n);s=Le(d),u=d.length}else s=n;return{segmentType:\"media\",chunkData:as(t,s,e),chunkSize:u,chunkInfos:null,chunkOffset:o,protectionData:[],appendWindow:[r,i]}}function ia({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:f}=t;if(u===null)return s.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:(l=s.timestampOffset)!=null?l:0,protectionData:[],appendWindow:[a,o]};let d=He(r.type,r.mimeType);if(d===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return d===\"mp4\"?Gd(u,f,r,i,n):Kd(u,f,r)}}function os(n){let e=Fi({customManifestLoader:n.manifestLoader},jd()?\"text\":\"arraybuffer\"),t=zi(n),r=Xi(n),i=na(n),a=ra(n),o=ia(n);return{manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o}}}function jd(){return ae.dashParsers.wasm!==null&&(ae.dashParsers.wasm.status===\"initialized\"||ae.dashParsers.wasm.status===\"initializing\")}var ss=os;var kt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var xt=class{constructor(e){this._array=[],this._sortingFn=e}add(...e){e.sort(this._sortingFn);let t=0;for(let r=0;r<e.length;r++){let i=e[r],a=!1;for(;!a&&t<this._array.length;)this._sortingFn(i,this._array[t])<0?(this._array.splice(t,0,i),a=!0):t++;a||this._array.push(i)}}length(){return this._array.length}get(e){if(e<0||e>=this._array.length)throw new Error(\"Invalid index.\");return this._array[e]}toArray(){return this._array.slice()}findFirst(e){return K(this._array,e)}has(e){return se(this._array,e)}removeElement(e){let t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t}head(){return this._array[0]}last(){return this._array[this._array.length-1]}shift(){return this._array.shift()}pop(){return this._array.pop()}};var Pn=class{constructor(e){this._weakMap=new WeakMap,this._fn=e}get(e){let t=this._weakMap.get(e);if(t===void 0){let r=this._fn(e);return this._weakMap.set(e,r),r}else return t}destroy(e){this._weakMap.delete(e)}};var Yd=.016666666666666666;function us(n,e){return Math.abs(n-e)<Yd}function ls(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function Qd(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function $d(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(ms(t,r)){let i=ls(t,r);n.splice(--e,2,i)}}return n}function aa(n,e){return n.end<=e.start}function ds({start:n,end:e},t){return n<=t&&t<e}function fs(n,e){return ds(n,e.start)||n.start<e.end&&e.end<n.end||ds(e,n.start)}function ms(n,e){return us(e.start,n.end)||us(e.end,n.start)}function oa(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function Xd(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t].start;if(e>=r){let i=n[t].end;if(e<i)return n[t]}}return null}function cs(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let a=n[i].start,o=n[i].end;e<a||e>=o?r.push({start:a,end:o}):t={start:a,end:o}}return{outerRanges:r,innerRange:t}}function xr(n,e){let t=Xd(n,e);return t!==null?t.end-e:1/0}function Vt(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=fs(t,i),o=ms(t,i);if(a||o)t=ls(t,i),n.splice(r--,1);else if(r===0){if(aa(t,n[0]))break}else if(aa(n[r-1],t)&&aa(t,i))break}return n.splice(r,0,t),$d(Qd(n))}function Zd(n,e){let t=[];for(let r=0;r<e.length;r++)fs(n,e[r])&&t.push(e[r]);return t}function Mr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=Zd(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let u=0;u<a.length;u++)a[u].start>s&&t.push({start:s,end:a[u].start}),s=a[u].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function Or({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(u=>{a=u.position.getWanted(),o=u.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&Jd(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{let f=u instanceof Error?u.message:\"Unknown error\";c.error(\"Could not run BufferGarbageCollector:\",f)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function Jd(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=cs(t,e),f=()=>{if(isFinite(r)){for(let l of u)e-r>=l.end?o.push(l):e>=l.end&&e-r>l.start&&e-r<l.end&&o.push({start:l.start,end:e-r});v(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},d=()=>{if(isFinite(i)){for(let l of u)e+i<=l.start?o.push(l):e<=l.start&&e+i<l.end&&e+i>l.start&&o.push({start:e+i,end:l.end});v(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};f(),d();for(let l of o)if(l.start<l.end){if(c.debug(\"GC: cleaning range from SegmentSink\",l.start,l.end),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var vn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=L();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>Ze(t.context,e))}_cleanHistory(e){let t=e-this._lifetime,r=0;for(let i of this._history)if(i.date<t)r++;else break;if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){let i=this._history.length-this._maxHistoryLength;this._history=this._history.splice(i)}}};var Cn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=U.getCurrent();this._inventory=[],this._bufferedHistory=new vn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,f,d,l,m,p,g;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=U.getCurrent(),o=i==null?void 0:i.infos.adaptation.type;if(c.hasLevel(\"DEBUG\")){let h=e.map(I=>`${I.start}-${I.end}`).join(\",\");c.debug(`SI: synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,h)}let s=e.length;for(let h=0;h<s;h++){if(i===void 0)return;let I=e[h].start,y=e[h].end;if(y-I<a){c.warn(\"SI: skipped range when synchronizing because it was too small\",o,I,y);continue}let T=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-I<a;)i=t[++r];let P=null,E=r-T;if(E>0){let R=t[T+E-1];P={end:(f=R.bufferedEnd)!=null?f:R.end,precizeEnd:R.precizeEnd},c.debug(`SI: ${E} segments GCed.`,o);let k=t.splice(T,E);for(let _ of k)_.bufferedStart===void 0&&_.bufferedEnd===void 0&&_.status!==2&&this._bufferedHistory.addBufferedSegment(_.infos,null);r=T}if(i===void 0)return;if(y-((d=i.bufferedStart)!=null?d:i.start)>=a){if(el(i,I,P,o),r===t.length-1){gs(i,y,o);return}i=t[++r];let R=(l=i.bufferedStart)!=null?l:i.start,k=(m=i.bufferedEnd)!=null?m:i.end,_=h<s-1?e[h+1].start:void 0;for(;i!==void 0&&!(y<R||y-R<a&&k-y>=a||_!==void 0&&y-R<k-_);){let A=t[r-1];A.bufferedEnd===void 0&&(i.precizeStart?A.bufferedEnd=i.start:A.infos.segment.complete?A.bufferedEnd=A.end:A.bufferedEnd=i.start,c.debug(\"SI: calculating buffered end of contiguous segment\",o,A.bufferedEnd,A.end)),i.bufferedStart=A.bufferedEnd,i=t[++r],i!==void 0&&(R=(p=i.bufferedStart)!=null?p:i.start,k=(g=i.bufferedEnd)!=null?g:i.end)}}let C=t[r-1];C!==void 0&&gs(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:h}=U.getCurrent(),I=L();for(let y=r;y<t.length;y++){let T=t[y];I-T.insertionTs>=h&&(c.debug(\"SI: A segment at the end has been completely GCed\",o,`${T.start}-${T.end}`),T.bufferedStart===void 0&&T.bufferedEnd===void 0&&T.status!==2&&this._bufferedHistory.addBufferedSegment(T.infos,null),t.splice(y,1),y--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(`SI: current ${o} inventory timeline:\n`+tl(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,f){if(i.isInit)return;let d=t.type;if(o>=s){c.warn(\"SI: Invalid chunked inserted: starts before it ends\",d,o,s);return}let l=this._inventory,m={status:u?0:2,insertionTs:f,chunkSize:a,splitted:!1,start:o,end:s,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:i,period:e,adaptation:t,representation:r}};for(let g=l.length-1;g>=0;g--){let h=l[g];if(h.start<=o)if(h.end<=o){for(c.debug(\"SI: Pushing segment strictly after previous one.\",d,o,h.end),this._inventory.splice(g+1,0,m),g+=2;g<l.length&&l[g].start<m.end;){if(l[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,l[g].start),l[g].start=m.end,l[g].bufferedStart=void 0,l[g].precizeStart=l[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,l[g].start,l[g].end),l.splice(g,1)}return}else if(h.start===o)if(h.end<=s){for(c.debug(\"SI: Segment pushed replace another one\",d,o,s,h.end),this._inventory.splice(g,1,m),g+=1;g<l.length&&l[g].start<m.end;){if(l[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,l[g].start),l[g].start=m.end,l[g].bufferedStart=void 0,l[g].precizeStart=l[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,l[g].start,l[g].end),l.splice(g,1)}return}else{c.debug(\"SI: Segment pushed ends before another with the same start\",d,o,s,h.end),l.splice(g,0,m),h.start=m.end,h.bufferedStart=void 0,h.precizeStart=h.precizeStart&&m.precizeEnd;return}else if(h.end<=m.end){for(c.debug(\"SI: Segment pushed updates end of previous one\",d,o,s,h.start,h.end),this._inventory.splice(g+1,0,m),h.end=m.start,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&m.precizeStart,g+=2;g<l.length&&l[g].start<m.end;){if(l[g].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,l[g].start),l[g].start=m.end,l[g].bufferedStart=void 0,l[g].precizeStart=l[g].precizeStart&&m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,l[g].start,l[g].end),l.splice(g,1)}return}else{c.warn(\"SI: Segment pushed is contained in a previous one\",d,o,s,h.start,h.end);let I={status:h.status,insertionTs:h.insertionTs,chunkSize:h.chunkSize,splitted:!0,start:m.end,end:h.end,precizeStart:h.precizeStart&&h.precizeEnd&&m.precizeEnd,precizeEnd:h.precizeEnd,bufferedStart:void 0,bufferedEnd:h.end,infos:h.infos};h.end=m.start,h.splitted=!0,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&m.precizeStart,l.splice(g+1,0,m),l.splice(g+2,0,I);return}}let p=this._inventory[0];if(p===void 0){c.debug(\"SI: first segment pushed\",d,o,s),this._inventory.push(m);return}if(p.start>=s)c.debug(\"SI: Segment pushed comes before all previous ones\",d,o,s,p.start),this._inventory.splice(0,0,m);else if(p.end<=s){for(c.debug(\"SI: Segment pushed starts before and completely recovers the previous first one\",d,o,s,p.start,p.end),this._inventory.splice(0,1,m);l.length>1&&l[1].start<m.end;){if(l[1].end>m.end){c.debug(\"SI: Segment pushed updates the start of the next one\",d,m.end,l[1].start),l[1].start=m.end,l[1].bufferedStart=void 0,l[1].precizeStart=m.precizeEnd;return}c.debug(\"SI: Segment pushed removes the next one\",d,o,s,l[1].start,l[1].end),l.splice(1,1)}return}else{c.debug(\"SI: Segment pushed start of the next one\",d,o,s,p.start,p.end),p.start=s,p.bufferedStart=void 0,p.precizeStart=m.precizeEnd,this._inventory.splice(0,0,m);return}}completeSegment(e){if(e.segment.isInit)return;let t=this._inventory,r=[];for(let i=0;i<t.length;i++)if(Ze(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI: Completed Segment is splitted.\",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&Ze(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let u=i-1,f=u-o,d=t[u].end,l=t[u].bufferedEnd;f>0&&(this._inventory.splice(o+1,f),i-=f),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=d,this._inventory[o].bufferedEnd=l,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)c.warn(\"SI: Completed Segment not found\",e.segment.id,e.segment.time);else for(let i of r)i.bufferedStart!==void 0&&i.bufferedEnd!==void 0?i.status!==2&&this._bufferedHistory.addBufferedSegment(i.infos,{start:i.bufferedStart,end:i.bufferedEnd}):c.debug(\"SI: buffered range not known after sync. Skipping history.\",i.start,i.end)}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function sa(n){if(n.bufferedStart===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(e-n.bufferedStart)<=i&&(n.bufferedEnd===void 0||n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3))}function ps(n){if(n.bufferedEnd===void 0||!n.infos.segment.complete||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=U.getCurrent();return Math.abs(t-n.bufferedEnd)<=i&&n.bufferedStart!==void 0&&n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3)}function el(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=U.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(c.debug(\"SI: Segment partially GCed at the start\",r,n.bufferedStart,e),n.bufferedStart=e),!n.precizeStart&&sa(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI: buffered start is precize start\",r,n.start),n.bufferedStart=n.start;else if(t!==null&&t.end>e&&(t.precizeEnd||n.start-t.end<=i))c.debug(\"SI: buffered start is end of previous segment\",r,e,n.start,t.end),n.bufferedStart=t.end,sa(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: found true buffered start\",r,e,n.start),n.bufferedStart=e,sa(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI: range start too far from expected start\",r,e,n.start),n.bufferedStart=n.start;else{let s=L();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the start\",r,e,n.start),n.bufferedStart=e}}function gs(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=U.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(c.debug(\"SI: Segment partially GCed at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&ps(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI: buffered end is precize end\",t,n.end),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: found true buffered end\",t,e,n.end),n.bufferedEnd=e,ps(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI: range end too far from expected end\",t,e,n.end),n.bufferedEnd=n.end;else{let o=L();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}c.debug(\"SI: Segment appears immediately garbage collected at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e}}function tl(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let f=String.fromCharCode(r.length+65);return r.push({letter:f,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),f}let s=\"\";for(let u=0;u<n.length;u++){let f=n[u];if(f.bufferedStart!==void 0&&f.bufferedEnd!==void 0){let d=f.infos.period.id,l=f.infos.representation.id,m=t[d],p;m===void 0?(p=o(f.infos),t[d]={[l]:p}):m[l]===void 0?(p=o(f.infos),m[l]=p):p=m[l],i===null?s+=`${f.bufferedStart.toFixed(2)}|${p}|`:a===p?i.bufferedEnd+e<f.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${f.bufferedStart.toFixed(2)}|${p}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${f.bufferedStart.toFixed(2)}|${p}|`,i=f,a=p}}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(u=>{var f;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(f=u.bitrate)!=null?f:\"unknown bitrate\"})`}),s}function qt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>=e.start)return t>0?n[t-1]:null;return n.length>0?n[n.length-1]:null}function Ht(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var hs=Cn;var Gt=class{constructor(){this._segmentInventory=new hs}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var An=class extends Gt{constructor(e,t,r){super(),c.info(\"AVSB: calling `mediaSource.addSourceBuffer`\",t);let i=r.addSourceBuffer(e,t);this.bufferType=e,this._sourceBuffer=i,this._lastInitSegmentUniqueId=null,this.codec=t,this._initSegmentsMap=new Map,this._pendingOperations=[]}declareInitSegment(e,t){Is(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Is(e.data.chunk),c.debug(\"AVSB: receiving order to push data to the SourceBuffer\",this.bufferType,yt(e.inventoryInfos));let t=this._getActualDataToPush(e.data);t.length===0&&t.push(new Uint8Array);let r=Promise.all(t.map(o=>{let{codec:s,timestampOffset:u,appendWindow:f}=e.data;return c.debug(\"AVSB: pushing segment\",this.bufferType,yt(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:f})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,L()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"AVSB: receiving order to remove data from the SourceBuffer\",this.bufferType,e,t);let r=this._sourceBuffer.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){try{c.debug(\"AVSB: Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){c.debug(`AVSB: Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"\")}}_getActualDataToPush(e){let t=[];if(e.initSegmentUniqueId!==null&&!this._isLastInitSegment(e.initSegmentUniqueId)){let r=this._initSegmentsMap.get(e.initSegmentUniqueId);if(r===void 0)throw new Error(\"Invalid initialization segment uniqueId\");let i=new ArrayBuffer(r.byteLength),a=new Uint8Array(i);a.set(r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer)),r=a,t.push(r),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return e.chunk!==null&&t.push(e.chunk),t}_isLastInitSegment(e){return this._lastInitSegmentUniqueId===null?!1:this._lastInitSegmentUniqueId===e}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function Is(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Dr=An;function Mt(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(u){n.deregister(o),a=!0,r(u)},function(u){n.deregister(o),a=!0,i(u)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}var kn=class extends Gt{constructor(e){c.debug(\"HTSB: Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"HTSB: Declaring initialization segment for Text SegmentSink\",e)}freeInitSegment(e){c.warn(\"HTSB: Freeing initialization segment for Text SegmentSink\",e)}async pushChunk(e){let{data:t}=e;rl(t.chunk);let r=this._sender.pushTextData(Me(ge({},t),{chunk:t.chunk}));this._addToOperationQueue(r,{type:0,value:e});let i=await r;return e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,L()),this._segmentInventory.synchronizeBuffered(i),i}async removeBuffer(e,t){let r=this._sender.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){c.debug(\"HTSB: Disposing TextSegmentSink\"),this._sender.reset()}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function rl(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n===null||typeof n.data!=\"string\"||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\"))throw new Error(\"Invalid format given to a TextSegmentSink\")}b.CURRENT_ENV===b.DEV&&(il=function(e){function t(r){}});var il;var bs=kn;var al=[\"audio\",\"video\",\"text\"],xn=class n{static isNative(e){return Ss(e)}constructor(e,t,r){this._mediaSource=e,this._textInterface=r,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}getBufferTypes(){let e=this.getNativeBufferTypes();return this._textInterface!==null&&e.push(\"text\"),e}getNativeBufferTypes(){return this._hasVideo?[\"video\",\"audio\"]:[\"audio\"]}getStatus(e){let t=this._initializedSegmentSinks[e];return t===void 0?{type:\"uninitialized\"}:t===null?{type:\"disabled\"}:{type:\"initialized\",value:t}}waitForUsableBuffers(e){return this._areNativeBuffersUsable()?Promise.resolve():Mt(e,t=>{let r,i=()=>{let a=this._onNativeBufferAddedOrDisabled.indexOf(r);a>=0&&this._onNativeBufferAddedOrDisabled.splice(a,1)};return r=()=>{this._areNativeBuffersUsable()&&(i(),t())},this._onNativeBufferAddedOrDisabled.push(r),i})}disableSegmentSink(e){let t=this._initializedSegmentSinks[e];if(t===null){c.warn(`SBS: The ${e} SegmentSink was already disabled.`);return}if(t!==void 0)throw new Error(\"Cannot disable an active SegmentSink.\");this._initializedSegmentSinks[e]=null,n.isNative(e)&&this._onNativeBufferAddedOrDisabled.forEach(r=>r())}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(Ss(e)){if(!v(r))return r instanceof Dr&&r.codec!==t?c.warn(\"SB: Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"SB: Reusing native SegmentSink with codec\",t),r;c.info(\"SB: Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Dr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.forEach(s=>s()),o}if(!v(r))return c.info(\"SB: Reusing a previous custom SegmentSink for the type\",e),r;let i;if(e===\"text\"){if(c.info(\"SB: Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new bs(this._textInterface),this._initializedSegmentSinks.text=i,i}throw c.error(\"SB: Unknown buffer type:\",e),new Q(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e){let t=this._initializedSegmentSinks[e];if(v(t)){c.warn(\"SB: Trying to dispose a SegmentSink that does not exist\");return}c.info(\"SB: Aborting SegmentSink\",e),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){al.forEach(e=>{this.getStatus(e).type===\"initialized\"&&this.disposeSegmentSink(e)})}_areNativeBuffersUsable(){let e=this.getNativeBufferTypes();return!(e.some(i=>this._initializedSegmentSinks[i]===void 0)||e.every(i=>this._initializedSegmentSinks[i]===null))}createSegmentSinkMetricsForType(e){var t,r;return{bufferType:e,codec:(t=this._initializedSegmentSinks[e])==null?void 0:t.codec,segmentInventory:(r=this._initializedSegmentSinks[e])==null?void 0:r.getLastKnownInventory().map(i=>Me(ge({},i),{infos:ol(i.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function Ss(n){return n===\"audio\"||n===\"video\"}function ol(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=xn;function Mn(n,e){return Mt(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var On=class extends oe{constructor(e,t,r,i){super(),this._content=e,this._currentCanceller=null,this._downloadQueue=t,this._initSegmentRequest=null,this._mediaSegmentRequest=null,this._segmentFetcher=r,this._initSegmentInfoRef=new j(void 0),this._mediaSegmentAwaitingInitMetadata=null,i||this._initSegmentInfoRef.setValue(null)}getRequestedInitSegment(){return this._initSegmentRequest===null?null:this._initSegmentRequest.segment}getRequestedMediaSegment(){return this._mediaSegmentRequest===null?null:this._mediaSegmentRequest.segment}start(){this._currentCanceller===null&&(this._currentCanceller=new W,this._downloadQueue.onUpdate(e=>{let{segmentQueue:t}=e;if(t.length>0&&t[0].segment.id===this._mediaSegmentAwaitingInitMetadata)return;let r=this._mediaSegmentRequest;if(t.length===0){if(r===null)return;c.debug(\"Stream: no more media segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}else if(r===null){c.debug(\"Stream: Media segments now need to be requested. Starting queue.\",this._content.adaptation.type,t.length),this._restartMediaSegmentDownloadingQueue();return}else{let i=t[0];if(r.segment.id!==i.segment.id){c.debug(\"Stream: Next media segment changed, cancelling previous\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}r.priority!==i.priority&&(c.debug(\"Stream: Priority of next media segment changed, updating\",this._content.adaptation.type,r.priority,i.priority),this._segmentFetcher.updatePriority(r.request,i.priority));return}},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate(e=>{var r;let t=this._initSegmentRequest;if(e.initSegment!==null&&t!==null){e.initSegment.priority!==t.priority&&this._segmentFetcher.updatePriority(t.request,e.initSegment.priority);return}else if(((r=e.initSegment)==null?void 0:r.segment.id)===(t==null?void 0:t.segment.id))return;e.initSegment===null&&c.debug(\"Stream: no more init segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartInitSegmentDownloadingQueue(e.initSegment)},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))}stop(){var e;(e=this._currentCanceller)==null||e.cancel(),this._currentCanceller=null}_restartMediaSegmentDownloadingQueue(){this._mediaSegmentRequest!==null&&this._mediaSegmentRequest.canceller.cancel();let{segmentQueue:e}=this._downloadQueue.getValue(),t=e[0],r=i=>{if(this._currentCanceller!==null&&this._currentCanceller.isUsed()){this._mediaSegmentRequest=null;return}if(i===void 0){this._mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let a=new W,o=this._currentCanceller===null?D:a.linkToSignal(this._currentCanceller.signal),{segment:s,priority:u}=i,f=H({segment:s},this._content),d=!1,l=!1;a.signal.register(()=>{this._mediaSegmentRequest=null,!d&&(this._mediaSegmentAwaitingInitMetadata===s.id&&(this._mediaSegmentAwaitingInitMetadata=null),d=!0,l=!1)});let m=h=>{Ie(h.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",H({},h,{segment:s}))},p=()=>{let h=this._downloadQueue.getValue().segmentQueue;if(h.length===0){d=!0,this.trigger(\"emptyQueue\",null);return}else h[0].segment.id===s.id&&h.shift();d=!0,r(h[0])},g=this._segmentFetcher.createRequest(f,u,{onRetry:h=>{this.trigger(\"requestRetry\",{segment:s,error:h})},beforeInterrupted(){c.info(\"Stream: segment request interrupted temporarly.\",s.id,s.time)},onChunk:h=>{let I=this._initSegmentInfoRef.getValue();I!==void 0?m(h(I!=null?I:void 0)):(l=!0,this._initSegmentInfoRef.waitUntilDefined(y=>{m(h(y!=null?y:void 0))},{clearSignal:a.signal}))},onAllChunksReceived:()=>{l?(this._mediaSegmentAwaitingInitMetadata=s.id,this._initSegmentInfoRef.waitUntilDefined(()=>{this._mediaSegmentAwaitingInitMetadata=null,l=!1,this.trigger(\"fullyLoadedSegment\",s)},{clearSignal:a.signal})):this.trigger(\"fullyLoadedSegment\",s)},beforeEnded:()=>{o(),this._mediaSegmentRequest=null,l?this._initSegmentInfoRef.waitUntilDefined(p,{clearSignal:a.signal}):p()}},a.signal);g.catch(h=>{o(),d||(d=!0,this.stop(),this.trigger(\"error\",h))}),this._mediaSegmentRequest={segment:s,priority:u,request:g,canceller:a}};r(t)}_restartInitSegmentDownloadingQueue(e){if(this._currentCanceller!==null&&this._currentCanceller.isUsed()||(this._initSegmentRequest!==null&&this._initSegmentRequest.canceller.cancel(),e===null))return;let t=new W,r=this._currentCanceller===null?D:t.linkToSignal(this._currentCanceller.signal),{segment:i,priority:a}=e,o=H({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:f=>{this.trigger(\"requestRetry\",{segment:i,error:f})},beforeInterrupted:()=>{c.info(\"Stream: init segment request interrupted temporarly.\",i.id)},beforeEnded:()=>{r(),this._initSegmentRequest=null,s=!0},onChunk:f=>{var l;let d=f(void 0);Ie(d.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",H({},d,{segment:i})),d.segmentType===\"init\"&&this._initSegmentInfoRef.setValue((l=d.initTimescale)!=null?l:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",i)}},t.signal);u.catch(f=>{r(),s||(s=!0,this.stop(),this.trigger(\"error\",f))}),t.signal.register(()=>{this._initSegmentRequest=null,!s&&(s=!0)}),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:t}}};function ua(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=sl(i,e);if(u===null){if(t===null){if(r&&a.end!==void 0&&e.end>=a.end)return{start:void 0,end:null};let l=s.index.checkDiscontinuity(e.start);if(l!==null)return{start:void 0,end:l}}return null}let f=i[u];if(f.bufferedStart!==void 0&&f.bufferedStart>e.start&&(t===null||f.infos.segment.end<=t)){let l=f.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(c.debug(\"RS: current discontinuity encountered\",o.type,f.bufferedStart),{start:void 0,end:l})}let d=ul(i,e,u+1);if(d!==null){let l=i[d-1],m=i[d];if(t===null||m.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(l.infos.segment.end,m.infos.segment.time)!==!1)return null;let p=l.bufferedEnd,g=m.bufferedStart;return c.debug(\"RS: future discontinuity encountered\",o.type,p,g),{start:p,end:g}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=dl(i,a.end);if(l!==null){let m=i[l];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"RS: discontinuity encountered at the end of the current period\",o.type,m.bufferedEnd,a.end),{start:m.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let l=i.length-1;l>=0;l--){let m=i[l];if(m.bufferedStart===void 0)break;if(m.bufferedStart<e.end){if(m.bufferedEnd!==void 0&&m.bufferedEnd<e.end){let p=s.index.checkDiscontinuity(e.end);if(p!==null)return{start:m.bufferedEnd,end:p}}return null}}}return null}function sl(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.bufferedStart===void 0||r.bufferedEnd===void 0||r.bufferedStart>=e.end)return null;if(r.bufferedEnd>e.start)return t}return null}function ul(n,e,t){if(t<=0)return c.error(\"RS: Asked to check a discontinuity before the first chunk.\"),null;for(let r=t;r<n.length;r++){let i=n[r],a=n[r-1];if(i.bufferedStart===void 0||a.bufferedEnd===void 0||i.bufferedStart>=e.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}function dl(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t];if(r.bufferedStart===void 0)return null;if(r.bufferedStart<e)return t}return null}function da({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:f}=e,d=ll(n,o,s),l=f.index.getSegments(a.start,a.end-a.start),m=n.filter(C=>!ys(C.infos,e,t,r)),p=Il(m,a,i),{MINIMUM_SEGMENT_SIZE:g,MIN_BUFFER_AHEAD:h}=U.getCurrent(),I=!1,y=Math.min(1/60,g),T=!1,P=[];return{segmentsToLoad:l.filter(C=>{let R=H({segment:C},e);if(o.length>0&&o.some(w=>Ze(R,w)))return!1;let{duration:k,time:_,end:A}=C;if(C.isInit)return!0;if(I)return P.push(C),!1;if(C.complete&&k<g||o.length>0&&o.some(w=>{if(w.period.id!==e.period.id||w.adaptation.id!==e.adaptation.id)return!1;let{segment:O}=w;if(O.time-y>_)return!1;if(O.complete){if(O.end+y<A)return!1}else if(Math.abs(_-O.time)>_)return!1;return!ys(w,R,t,r)}))return!1;for(let N=0;N<p.length;N++){let w=p[N],O=w.infos.period.id===e.period.id;if(w.status===1&&O){let B=w.infos.segment;if(_-B.time>-y){if(B.complete){if(B.end-A>-y)return!1}else if(Math.abs(_-B.time)<y)return!1}}}let x=k*e.representation.bitrate;if(d-x<0&&(T=!0,_>a.start+h))return I=!0,P.push(C),!1;let M=i(R);if(M.length>1){let N=M[M.length-1],w=M[M.length-2];if(N.buffered===null&&w.buffered===null)return c.warn(\"Stream: Segment GCed multiple times in a row, ignoring it.\",\"If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering.\"+u.type,f.id,C.time),!1}for(let N=0;N<p.length;N++){let w=p[N];if(w.end+y>_){let O=w.start>_+y||fl(p,N).end<A-y;return O&&(d-=x),O}}return d-=x,!0}),segmentsOnHold:P,isBufferFull:T}}function ll(n,e,t){let r=t*8e3;return r-=e.reduce((i,a)=>{let{bitrate:o}=a.representation,{duration:s}=a.segment;return i+o*s},0),n.reduce((i,a)=>a.chunkSize!==void 0?i-a.chunkSize*8:i,r)}function fl(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=U.getCurrent(),i=Math.min(1/60,r);for(;t<n.length-1&&n[t-1].end+i>n[t].start;)t++;return t--,n[t]}function ys(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=U.getCurrent();if(n.period.id!==e.period.id)return!1;let{segment:a}=n;return a.time<t+i?!1:n.adaptation.id!==e.adaptation.id?!0:ml(n.representation,e.representation,r)}function ml(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=U.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function cl(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedStart===void 0||e!==null&&e.bufferedEnd!==void 0&&n.bufferedStart-e.bufferedEnd<.1?!1:t<n.bufferedStart&&n.bufferedStart-n.start>r?(c.info(\"Stream: The start of the wanted segment has been garbage collected\",n.start,n.bufferedStart),!0):!1}function pl(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=U.getCurrent();return n.bufferedEnd===void 0||e!==null&&e.bufferedStart!==void 0&&e.bufferedStart-n.bufferedEnd<.1?!1:t>n.bufferedEnd&&n.end-n.bufferedEnd>r?(c.info(\"Stream: The end of the wanted segment has been garbage collected\",n.end,n.bufferedEnd),!0):!1}function gl(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.start;if(e!==void 0&&r!==void 0&&e-r>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.start;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function hl(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.end;if(e!==void 0&&r!==void 0&&r-e>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.end;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function Il(n,e,t){return n.filter((r,i,a)=>{let o=i===0?null:a[i-1],s=i>=a.length-1?null:a[i+1],u=null;if(cl(r,o,e.start)){if(u=t(r.infos),gl(u,r.bufferedStart))return!1;c.debug(\"Stream: skipping segment gc-ed at the start\",r.start,r.bufferedStart)}if(pl(r,s,e.end)){if(u=u!=null?u:t(r.infos),hl(u,r.bufferedEnd))return!1;c.debug(\"Stream: skipping segment gc-ed at the end\",r.end,r.bufferedEnd)}return!0})}function wn(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=U.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function la(n,e,t,r,i,a,o){var _,A,x;let{representation:s}=n,u=(A=(_=t.getIsPaused())!=null?_:t.getReference().getValue().paused.pending)!=null?A:t.getReference().getValue().paused.last,f=(x=t.getPlaybackRate())!=null?x:t.getReference().getValue().speed,d=e;(u===void 0||f===void 0||u||f<=0)&&(d-=.1);let l=bl(n,d,i),m=s.index.shouldRefresh(l.start,l.end),p=o.getPendingOperations().filter(M=>M.type===2).map(M=>M.value),g=o.getLastKnownInventory(),h=t.getCurrentTime();h===void 0&&(h=t.getReference().getValue().position.getWanted());let I=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:T,isBufferFull:P}=da({content:n,bufferedSegments:g,currentPlaybackTime:h,fastSwitchThreshold:r,getBufferedHistory:I,neededRange:l,segmentsBeingPushed:p,maxBufferSize:a}),E=y.map(M=>({priority:wn(M.time,d),segment:M})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,R=null;return p.length>0&&(R=Math.min(...p.map(M=>M.segment.time))),T.length>0&&(R=R!==null?Math.min(R,T[0].time):T[0].time),E.length>0&&(R=R!==null?Math.min(R,E[0].segment.time):E[0].segment.time),{imminentDiscontinuity:ua(n,l,R,C,g),hasFinishedLoading:C,neededSegments:E,isBufferFull:P,shouldRefreshManifest:m}}function bl(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!v(s)&&bt.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&Sl(i,a,e)?r=s-1:r=e-.1;let f=r+t,d;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?d=!1:s===void 0?d=f>=a.end:s===null?d=!0:d=f>=s,{start:Math.max(r,a.start),end:Math.min(f,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:d}}function Sl(n,e,t){var i;let r=n.getPeriodAfter(e);return e.containsTime(t,r)&&n.isLastPeriodKnown&&e.id===((i=n.periods[n.periods.length-1])==null?void 0:i.id)}function fa(n){return new Promise(e=>{setTimeout(e,n)})}async function Dn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof ie)throw a;if(!(a instanceof Ce)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Q(\"BUFFER_APPEND_ERROR\",u,{tracks:[dt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream: Running garbage collector\");let u=Math.max(s-5,0),f=s+r.getValue()+12;if(await e.removeBuffer(0,u),await e.removeBuffer(f,Number.MAX_VALUE),await fa(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(u){if(u instanceof ie)throw u;let f=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new Q(\"BUFFER_FULL_ERROR\",f,{tracks:[dt(t.inventoryInfos.adaptation)]})}}}async function ma({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){if(o.cancellationError!==null)throw o.cancellationError;let s=e.representation.getMimeTypeString(),u={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},f=H({segment:r,chunkSize:void 0,start:0,end:0},e),d=await Dn(n,i,{data:u,inventoryInfos:f},a,o);return{content:e,segment:r,buffered:d}}async function ca({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var R,k;if(i.chunkData===null)return null;if(s.cancellationError!==null)throw s.cancellationError;let{chunkData:u,chunkInfos:f,chunkOffset:d,chunkSize:l,appendWindow:m}=i,p=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:g}=U.getCurrent(),h=[m[0]!==void 0?Math.max(0,m[0]-g.START):void 0,m[1]!==void 0?m[1]+g.END:void 0],I={initSegmentUniqueId:r,chunk:u,timestampOffset:d,appendWindow:h,codec:p},y=(R=f==null?void 0:f.time)!=null?R:a.time,T=(k=f==null?void 0:f.duration)!=null?k:a.duration,P=y+T;h[0]!==void 0&&(y=Math.max(y,h[0])),h[1]!==void 0&&(P=Math.min(P,h[1]));let E=H({segment:a,chunkSize:l,start:y,end:P},t),C=await Dn(n,o,{data:I,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:C}}function pa({content:n,options:e,playbackObserver:t,segmentSink:r,segmentFetcher:i,terminate:a},o,s){let{period:u,adaptation:f,representation:d}=n,{bufferGoal:l,maxBufferSize:m,drmSystemId:p,fastSwitchThreshold:g}=e,h=f.type,I=new W;I.linkToSignal(s);let y=new W;y.linkToSignal(I.signal);let T={segment:d.index.getInitSegment(),uniqueId:null,isLoaded:!1};I.signal.register(()=>{T.uniqueId!==null&&r.freeInitSegment(T.uniqueId)});let P=new j({initSegment:null,segmentQueue:[]},y.signal),E=T.segment!==null;E||(T.isLoaded=!0);let C=!1;if(p!==void 0){let x=d.getEncryptionData(p);if(x.length>0&&x.every(M=>M.keyIds!==void 0)&&(C=!0,o.encryptionDataEncountered(x.map(M=>H({content:n},M))),I.isUsed()))return}let R=new On(n,P,i,E);R.addEventListener(\"error\",x=>{y.signal.isCancelled()||(I.cancel(),o.error(x))}),R.addEventListener(\"parsedInitSegment\",_),R.addEventListener(\"parsedMediaSegment\",_),R.addEventListener(\"emptyQueue\",k),R.addEventListener(\"requestRetry\",x=>{if(o.warning(x.error),y.signal.isCancelled())return;let M=x.segment,{index:N}=d;N.isSegmentStillAvailable(M)===!1?k():N.canBeOutOfSyncError(x.error,M)&&o.manifestMightBeOufOfSync()}),R.addEventListener(\"fullyLoadedSegment\",x=>{r.signalSegmentComplete(H({segment:x},n)).catch(A)}),R.start(),y.signal.register(()=>{R.removeEventListener(),R.stop()}),t.listen(k,{includeLastObservation:!1,clearSignal:y.signal}),n.manifest.addEventListener(\"manifestUpdate\",k,y.signal),l.onUpdate(k,{emitCurrentValue:!1,clearSignal:y.signal}),m.onUpdate(k,{emitCurrentValue:!1,clearSignal:y.signal}),a.onUpdate(k,{emitCurrentValue:!1,clearSignal:y.signal}),k();return;function k(){if(y.isUsed())return;let x=t.getReference().getValue(),M=x.position.getWanted(),N=la(n,M,t,g.getValue(),l.getValue(),m.getValue(),r),{neededSegments:w}=N,O=null;if(d.index.isInitialized()){if(w.length>0&&!T.isLoaded&&T.segment!==null){let q=w[0].priority;O={segment:T.segment,priority:q}}}else if(T.segment===null)c.warn(\"Stream: Uninitialized index without an initialization segment\");else if(T.isLoaded)c.warn(\"Stream: Uninitialized index with an already loaded initialization segment\");else{let q=x.position.getWanted();O={segment:T.segment,priority:wn(u.start,q)}}let B=a.getValue();if(B===null)P.setValue({initSegment:O,segmentQueue:w});else if(B.urgent){c.debug(\"Stream: Urgent switch, terminate now.\",h),P.setValue({initSegment:null,segmentQueue:[]}),P.finish(),y.cancel(),o.terminating();return}else{let q=w[0],Y=R.getRequestedInitSegment(),G=R.getRequestedMediaSegment(),z=G===null||q===void 0||G.id!==q.segment.id?[]:[q],X=Y===null?null:O;if(P.setValue({initSegment:X,segmentQueue:z}),z.length===0&&X===null){c.debug(\"Stream: No request left, terminate\",h),P.finish(),y.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:x.position.getWanted(),bufferType:h,imminentDiscontinuity:N.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:N.hasFinishedLoading,neededSegments:N.neededSegments}),y.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:V}=U.getCurrent();if(N.isBufferFull){let q=Math.max(0,M-V);q>0&&r.removeBuffer(0,q).catch(A)}N.shouldRefreshManifest&&o.needsManifestRefresh()}function _(x){if(!I.isUsed()){for(let M of x.protectionData)d.addProtectionData(M.initDataType,M.keyId,M.initData);if(!C){let M=d.getAllEncryptionData();if(M.length>0&&(o.encryptionDataEncountered(M.map(N=>H({content:n},N))),C=!0,I.isUsed()))return}if(x.segmentType===\"init\"){if(!d.index.isInitialized()&&x.segmentList!==void 0&&d.index.initialize(x.segmentList),T.isLoaded=!0,x.initializationData!==null){let M=d.uniqueId;T.uniqueId=M,r.declareInitSegment(M,x.initializationData),ma({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:M,segment:x.segment,segmentData:x.initializationData,segmentSink:r},I.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(A)}k();return}else{let{inbandEvents:M,predictedSegments:N,needsManifestRefresh:w}=x;if(N!==void 0&&d.index.addPredictedSegments(N,x.segment),w===!0&&(o.needsManifestRefresh(),I.isUsed())||M!==void 0&&M.length>0&&(o.inbandEvent(M),I.isUsed()))return;let O=T.uniqueId;ca({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:O,parsedSegment:x,segment:x.segment,segmentSink:r},I.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(A)}}}function A(x){I.isUsed()&&x instanceof ie||(I.cancel(),o.error(x))}}var _s=pa;function ga(n,e,t,r,i){var m,p,g,h;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let I of a)I.infos.period.id===n.id&&(I.infos.adaptation.id!==e.id||!se(t.representationIds,I.infos.representation.id))&&Vt(o,{start:(m=I.bufferedStart)!=null?m:I.start,end:(p=I.bufferedEnd)!=null?p:I.end});let s=r.getPendingOperations();for(let I of s)if(I.type===0){let y=I.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!se(t.representationIds,y.representation.id))){let T=y.segment.time,P=T+y.segment.duration;Vt(o,{start:T,end:P})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let I=i.getReadyState();if(I===void 0||I>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",f=[],d=qt(a,n);if(d!==null&&(d.bufferedEnd===void 0||n.start-d.bufferedEnd<1)&&f.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:I}=U.getCurrent(),y=e.type,T=(g=I[y].before)!=null?g:0,P=(h=I[y].after)!=null?h:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),f.push({start:E-T,end:E+P})}if(n.end!==void 0){let I=Ht(a,n);I!==null&&(I.bufferedStart===void 0||I.bufferedStart-n.end<1)&&f.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Mr(o,f);return l.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function ha({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentFetcherCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,f){let{manifest:d,period:l,adaptation:m}=e,p=new W;p.linkToSignal(f);let g=new Map,h=new j(null,p.signal),I,y=e.representations.getValue().representationIds,T=e.adaptation.representations.filter(w=>se(y,w.id)&&w.decipherable!==!1&&w.isSupported!==!1),P=new j(T,p.signal),{estimates:E,callbacks:C}=r({manifest:d,period:l,adaptation:m},h,P,n,p.signal),R=a.createSegmentFetcher(m.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics}),k=new j(0);E.onUpdate(({bitrate:w,knownStableBitrate:O})=>{t.enableFastSwitching&&k.setValueIfChanged(O),!(w===void 0||w===I)&&(I=w,c.debug(`Stream: new ${m.type} bitrate estimate`,w),u.bitrateEstimateChange({type:m.type,bitrate:w}))},{emitCurrentValue:!0,clearSignal:p.signal});let _;e.representations.onUpdate(w=>{_!==void 0&&_.cancel();let O=e.representations.getValue().representationIds,B=e.adaptation.representations.filter(V=>se(O,V.id));P.setValueIfChanged(B),_=new W,_.linkToSignal(p.signal),A(w,_.signal).catch(V=>{(_==null?void 0:_.isUsed())===!0&&W.isCancellationError(V)||(p.cancel(),u.error(V))})},{clearSignal:p.signal,emitCurrentValue:!0});return;async function A(w,O){let B=ga(l,m,w,i,n);switch(B.type){case\"continue\":break;case\"needs-reload\":return kt(()=>{n.listen(()=>{if(O.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:V}=U.getCurrent(),q=V.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:q,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:O})});case\"flush-buffer\":case\"clean-buffer\":for(let V of B.value)if(await i.removeBuffer(V.start,V.end),O.isCancelled())return;if(B.type===\"flush-buffer\"&&(u.needsBufferFlush(),O.isCancelled()))return;break;default:We(B)}x(O)}function x(w){let O=new W;O.linkToSignal(w);let{representation:B}=E.getValue();if(B===null)return;let V=new j(null,O.signal);E.onUpdate(G=>{if(!(G.representation===null||G.representation.id===B.id))return G.urgent?(c.info(\"Stream: urgent Representation switch\",m.type),V.setValue({urgent:!0})):(c.info(\"Stream: slow Representation switch\",m.type),V.setValue({urgent:!1}))},{clearSignal:O.signal,emitCurrentValue:!0});let q={type:m.type,adaptation:m,period:l,representation:B};if(h.setValue(B),p.isUsed()||(u.representationChange(q),p.isUsed()))return;let Y={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error(G){p.cancel(),u.error(G)},addedSegment(G){C.addedSegment(G)},terminating(){if(!O.isUsed())return O.cancel(),x(w)}};M(B,V,Y,w)}function M(w,O,B,V){let q=new W;q.linkToSignal(V);let Y=Xt(o,X=>X*N(w),q.signal),G=m.type===\"video\"?s:new j(1/0);c.info(\"Stream: changing representation\",m.type,w.id,w.bitrate);let z=H({},B,{error(X){var me;let Z=he(X,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(Z.code!==\"BUFFER_FULL_ERROR\")B.error(X);else{let ce=o.getValue(),be=((me=g.get(w.id))!=null?me:1)*.7;if(be<=.05||ce*be<=2)throw Z;g.set(w.id,be),Mn(4e3,p.signal).then(()=>M(w,O,B,V)).catch(D)}},terminating(){q.cancel(),B.terminating()}});_s({playbackObserver:n,content:{representation:w,adaptation:m,period:l,manifest:d},segmentSink:i,segmentFetcher:R,terminate:O,options:{bufferGoal:Y,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:k}},z,V),d.addEventListener(\"manifestUpdate\",X=>{for(let Z of X.updatedPeriods)if(Z.period.id===l.id){for(let me of Z.result.updatedAdaptations)if(me.adaptation===m.id){for(let ce of me.removedRepresentations)if(ce===w.id)return V.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(Z.period.start>l.start)break},V)}function N(w){let O=g.get(w.id),B=O!==void 0?O:1;return O===void 0&&g.set(w.id,B),B}}var Ts=ha;function yl(n,e){let[t,...r]=n.split(\";\"),[i,...a]=e.split(\";\");if(t!==i)return!1;let o=K(r,d=>Ue(d,\"codecs=\")),s=K(a,d=>Ue(d,\"codecs=\"));if(o===void 0||s===void 0)return!1;let u=o.substring(7),f=s.substring(7);return u.split(\".\")[0]===f.split(\".\")[0]}var Es=yl;function Ia(n,e,t,r,i,a){var p,g,h,I;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!_l(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let y of o)y.infos.period.id===e.id&&y.infos.adaptation.id!==t.id&&Vt(s,{start:(p=y.bufferedStart)!=null?p:y.start,end:(g=y.bufferedEnd)!=null?g:y.end});let u=n.getPendingOperations();for(let y of u)if(y.type===0){let T=y.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let P=T.segment.time,E=P+T.segment.duration;Vt(s,{start:P,end:E})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let f=r===\"direct\",d=[],l=qt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&d.push({start:0,end:e.start+1}),!f){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=U.getCurrent(),P=(h=T[y].before)!=null?h:0,E=(I=T[y].after)!=null?I:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),d.push({start:C-P,end:C+E})}if(e.end!==void 0){let y=Ht(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&d.push({start:e.end-1,end:Number.MAX_VALUE})}let m=Mr(s,d);return m.length===0?{type:\"continue\",value:void 0}:f&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function _l(n,e){return n.representations.some(t=>t.isSupported===!0&&t.decipherable!==!1&&Es(t.getMimeTypeString(),e))}function ba({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentFetcherCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:f},d,l){let{manifest:m,period:p}=e,g=new j(void 0,l);if(d.periodStreamReady({type:n,manifest:m,period:p,adaptationRef:g}),l.isCancelled())return;let h,I=!0;g.onUpdate(P=>{(async()=>{var w;if(P===void 0)return;let E=new W;if(E.linkToSignal(l),h==null||h.cancel(),h=E,P===null){c.info(`Stream: Set no ${n} Adaptation. P:`,p.start);let O=o.getStatus(n);if(O.type===\"initialized\"){if(c.info(`Stream: Clearing previous ${n} SegmentSink`),bt.isNative(n))return T(0,!0,E.signal);{let B=(w=p.end)!=null?w:1/0;if(p.start>B)c.warn(\"Stream: Can't free buffer: period's start is after its end\");else if(await O.value.removeBuffer(p.start,B),E.isUsed())return}}else if(O.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return d.adaptationChange({type:n,adaptation:null,period:p}),E.isUsed()?void 0:Rs(r,u,n,{period:p},d,E.signal)}let C=p.adaptations[n],R=K(C!=null?C:[],O=>O.id===P.adaptationId);if(R===void 0){h.cancel(),c.warn(\"Stream: Unfound chosen Adaptation choice\",P.adaptationId);return}let{DELTA_POSITION_AFTER_RELOAD:k}=U.getCurrent(),_=!1,A;if(I)A=0;else if(P.relativeResumingPosition!==void 0)A=P.relativeResumingPosition;else switch(_=!0,n){case\"audio\":A=k.trackSwitch.audio;break;case\"video\":A=k.trackSwitch.video;break;default:A=k.trackSwitch.other;break}if(I=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(A,!0,E.signal);m.addEventListener(\"manifestUpdate\",O=>{for(let B of O.updatedPeriods)if(B.period.id===p.id){for(let V of B.result.removedAdaptations)if(V.id===R.id)return T(A,!0,E.signal)}else if(B.period.start>p.start)break},h.signal);let{representations:x}=P;if(c.info(`Stream: Updating ${n} adaptation`,`A: ${R.id}`,`P: ${p.start}`),d.adaptationChange({type:n,adaptation:R,period:p}),E.isUsed())return;let M=Tl(o,n,R),N=Ia(M,p,R,P.switchingMode,r,s);if(N.type===\"needs-reload\")return T(A,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(N.type===\"flush-buffer\"||N.type===\"clean-buffer\"){for(let{start:O,end:B}of N.value)if(await M.removeBuffer(O,B),E.isUsed())return;if(N.type===\"flush-buffer\"&&(d.needsBufferFlush({relativeResumingPosition:A,relativePosHasBeenDefaulted:_}),E.isUsed()))return}t.get(M)(E.signal),y(R,x,M,E.signal)}})().catch(E=>{E instanceof ie||(h==null||h.cancel(),d.error(E))})},{clearSignal:l,emitCurrentValue:!0});function y(P,E,C,R){let k=Rl(r,P.type);Ts({content:{manifest:m,period:p,adaptation:P,representations:E},options:s,playbackObserver:k,representationEstimator:i,segmentSink:C,segmentFetcherCreator:a,wantedBufferAhead:u,maxVideoBufferSize:f},Me(ge({},d),{error:_}),R);function _(A){if(!bt.isNative(n)){c.error(`Stream: ${n} Stream crashed. Aborting it.`,A instanceof Error?A:\"\"),o.disposeSegmentSink(n);let x=he(A,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return d.warning(x),R.isCancelled()?void 0:Rs(r,u,n,{period:p},d,R)}c.error(`Stream: ${n} Stream crashed. Stopping playback.`,A instanceof Error?A:\"\"),d.error(A)}}function T(P,E,C){kt(()=>{r.listen(()=>{C.isCancelled()||d.waitingMediaSourceReload({bufferType:n,period:p,timeOffset:P,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:C})})}}function Tl(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream: Reusing a previous SegmentSink for the type\",e),r.value;let i=El(t);return n.createSegmentSink(e,i)}function El(n){let e=n.representations.filter(t=>t.isSupported===!0&&t.decipherable!==!1);if(e.length===0)throw new Q(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[dt(n)]});return e[0].getMimeTypeString()}function Rl(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new j(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),f=u.buffered[e],d=f!==null?xr(f,u.position.getWanted()):0;return H({},u,{bufferGap:d,buffered:f})}function s(){a.setValue(o())}})}function Rs(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),n.listen(u,{includeLastObservation:!1,clearSignal:a}),u();function u(){let f=n.getReference().getValue(),d=e.getValue(),l=f.position.getWanted();o.end!==void 0&&l+d>=o.end&&(c.debug('Stream: full \"empty\" AdaptationStream',t),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var Ps=ba;function Nr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory();for(let i=0;i<r.length;i++){let a=r[i];if(e.some(s=>a.infos.period.id===s.period.id&&a.infos.adaptation.id===s.adaptation.id&&a.infos.representation.id===s.representation.id)){let{bufferedStart:s,bufferedEnd:u}=a;if(s===void 0||u===void 0)return c.warn(\"SO: No buffered start or end found from a segment.\"),[{start:0,end:Number.MAX_VALUE}];let f=t[t.length-1];f!==void 0&&f.end===s?f.end=u:t.push({start:s,end:u})}}return t}function Sa(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:f}=n,{maxBufferAhead:d,maxBufferBehind:l,wantedBufferAhead:m,maxVideoBufferSize:p}=a,{MINIMUM_MAX_BUFFER_AHEAD:g,MAXIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_BEHIND:I}=U.getCurrent(),y=new Pn(E=>{var _,A;let{bufferType:C}=E,R=(_=I[C])!=null?_:1/0,k=(A=h[C])!=null?A:1/0;return x=>{Or({segmentSink:E,playbackObserver:e,maxBufferBehind:Xt(l,M=>Math.min(M,R),x),maxBufferAhead:Xt(d,M=>{var w;let N=Math.max(M,(w=g[C])!=null?w:0);return Math.min(N,k)},x)},x)}});for(let E of r.getBufferTypes())T(E,f);function T(E,C){let R=new xt((N,w)=>N.start-w.start),k=!1,_=new W;return _.linkToSignal(s),e.listen(({position:N})=>{var B;let w=N.getWanted();if(!k||!x(w))return;for(c.info(\"Stream: Destroying all PeriodStreams due to out of bounds situation\",E,w),k=!1;R.length()>0;){let V=R.get(R.length()-1);R.removeElement(V),o.periodStreamCleared({type:E,manifest:u,period:V})}_.cancel(),_=new W,_.linkToSignal(s);let O=(B=u.getPeriodForTime(w))!=null?B:u.getNextPeriod(w);if(O===void 0){c.warn(\"Stream: The wanted position is not found in the Manifest.\"),k=!0;return}A(O)},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",N=>{s.isCancelled()||M(N).catch(w=>{s.isCancelled()||(_.cancel(),o.error(w))})},s),A(C);function A(N){let w=Me(ge({},o),{waitingMediaSourceReload(O){let B=R.head();B===void 0||B.id!==O.period.id?o.lockedStream({bufferType:O.bufferType,period:O.period}):o.needsMediaSourceReload({timeOffset:O.timeOffset,minimumPosition:O.stayInPeriod?O.period.start:void 0,maximumPosition:O.stayInPeriod?O.period.end:void 0})},periodStreamReady(O){k=!0,R.add(O.period),o.periodStreamReady(O)},periodStreamCleared(O){R.removeElement(O.period),o.periodStreamCleared(O)},error(O){_.cancel(),o.error(O)}});P(E,N,w,_.signal)}function x(N){let w=R.head(),O=R.last();return w===void 0||O===void 0?!0:w.start>N||(v(O.end)?1/0:O.end)<N}async function M(N){let w=r.getStatus(E),O=N.filter(z=>z.adaptation.type===E);if(O.length===0||w.type!==\"initialized\"||O.every(z=>z.representation.decipherable===!0))return;let B=w.value,V=O.filter(z=>z.representation.decipherable===void 0),q=O.filter(z=>z.representation.decipherable===!1),Y=Nr(B,q),G=Nr(B,V);for(k=!1,c.info(\"Stream: Destroying all PeriodStreams for decipherability matters\",E);R.length()>0;){let z=R.get(R.length()-1);R.removeElement(z),o.periodStreamCleared({type:E,manifest:u,period:z})}_.cancel(),_=new W,_.linkToSignal(s);for(let{start:z,end:X}of[...Y,...G]){if(s.isCancelled())return;if(z<X){if(s.isCancelled())return;await B.removeBuffer(z,X)}}kt(()=>{if(s.isCancelled())return;let z=e.getReference().getValue();if(vs(z,Y)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(vs(z,G)&&(o.needsBufferFlush(),s.isCancelled()))return;let X=z.position.getWanted(),Z=u.getPeriodForTime(X);if(Z===void 0){o.error(new Q(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}A(Z)})}}function P(E,C,R,k){c.info(\"Stream: Creating new Stream for\",E,C.start);let _=null,A=new W;A.linkToSignal(k),e.listen(({position:O},B)=>{if(C.end!==void 0&&O.getWanted()>=C.end){let V=u.getPeriodAfter(C);if(C.containsTime(O.getWanted(),V))return;c.info(\"Stream: Destroying PeriodStream as the current playhead moved above it\",E,C.start,O.getWanted(),C.end),B(),R.periodStreamCleared({type:E,manifest:u,period:C}),A.cancel()}},{clearSignal:k,includeLastObservation:!0});let x={bufferType:E,content:{manifest:u,period:C},garbageCollectors:y,maxVideoBufferSize:p,segmentFetcherCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},M=Me(ge({},R),{streamStatusUpdate(O){if(O.hasFinishedLoading){let B=u.getPeriodAfter(C);B!==null&&N(B)}else _!==null&&(c.info(\"Stream: Destroying next PeriodStream due to current one being active\",E,_.period.start),R.periodStreamCleared({type:E,manifest:u,period:_.period}),_.canceller.cancel(),_=null);R.streamStatusUpdate(O)},error(O){_!==null&&(_.canceller.cancel(),_=null),A.cancel(),R.error(O)}});Ps(x,M,A.signal),w(A.signal);function N(O){if(_!==null){if(_.period.id===O.id)return;c.warn(\"Stream: Creating next `PeriodStream` while one was already created.\",E,O.id,_.period.id),R.periodStreamCleared({type:E,manifest:u,period:_.period}),_.canceller.cancel()}let B=new W;B.linkToSignal(k),_={canceller:B,period:O},P(E,O,R,_.canceller.signal)}function w(O){u.addEventListener(\"manifestUpdate\",B=>{for(let V of B.removedPeriods)if(V.id===C.id){if(u.periods.length>0&&u.periods[0].start<=V.start)return kt(()=>{if(!O.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(V.start>C.start)break;if(B.addedPeriods.length>0&&_!==null){let V=u.getPeriodAfter(C);(V===null||_.period.id!==V.id)&&(c.warn(\"Stream: Destroying next PeriodStream due to new one being added\",E,_.period.start),R.periodStreamCleared({type:E,manifest:u,period:_.period}),_.canceller.cancel(),_=null)}},O)}}}function vs(n,e){if(e.length===0)return!1;let t=n.position.getPolled();return n.speed>=0?e[e.length-1].end>=t-5:e[0].start<=t+5}var Cs=Sa;var As=Cs;var Nn=class extends oe{constructor(e,t,r){super(),this._canceller=new W,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ya(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let u=new Q(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",u)}else if(s>i.getMaximumAvailablePosition()){let u=new Q(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",u)}},{includeLastObservation:!0,clearSignal:a}),e.addEventListener(\"manifestUpdate\",()=>{this.trigger(\"endingPositionChange\",this._getManifestEndTime()),!a.isCancelled()&&this._checkEndOfStream()},a)}getCurrentEndingTime(){return this._getManifestEndTime()}onAdaptationChange(e,t,r){if(this._manifest.isLastPeriodKnown){let i=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(i==null?void 0:i.id)&&(e===\"audio\"||e===\"video\")){e===\"audio\"?this._maximumPositionCalculator.updateLastAudioAdaptation(r):this._maximumPositionCalculator.updateLastVideoAdaptation(r);let a=this._maximumPositionCalculator.getEndingPosition(),o=a!==void 0?{isEnd:!0,endingPosition:a}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger(\"endingPositionChange\",o)}}this._canceller.isUsed()||r===null&&this._addActivelyLoadedPeriod(t,e)}onRepresentationChange(e,t){this._addActivelyLoadedPeriod(t,e)}onPeriodCleared(e,t){this._removeActivelyLoadedPeriod(t,e)}onLastSegmentFinishedLoading(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())}onLastSegmentLoadingResume(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())}dispose(){this.removeEventListener(),this._canceller.cancel()}_addActivelyLoadedPeriod(e,t){let r=this._lazilyCreateActiveStreamInfo(t);r.activePeriods.has(e)||(r.activePeriods.add(e),this._checkCurrentPeriod())}_removeActivelyLoadedPeriod(e,t){let r=this._activeStreams.get(t);r!==void 0&&r.activePeriods.has(e)&&(r.activePeriods.removeElement(e),this._checkCurrentPeriod())}_checkCurrentPeriod(){if(this._allBufferTypes.length===0)return;let e=this._activeStreams.get(this._allBufferTypes[0]);if(e!==void 0)for(let t of e.activePeriods.toArray()){let r=!0;for(let i of this._allBufferTypes){let a=this._activeStreams.get(i);if(a===void 0)return;if(!a.activePeriods.toArray().some(u=>u.id===t.id)){r=!1;break}}if(r){this._lastCurrentPeriodId!==t.id&&(this._lastCurrentPeriodId=t.id,this.trigger(\"periodChange\",t));return}}}_getManifestEndTime(){let e=this._maximumPositionCalculator.getEndingPosition();return e!==void 0?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}}_lazilyCreateActiveStreamInfo(e){let t=this._activeStreams.get(e);return t===void 0&&(t={activePeriods:new xt((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},ya=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Br(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Br(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Br(this._lastAudioAdaptation),t=Br(this._lastVideoAdaptation);return typeof e!=\"number\"||typeof t!=\"number\"?this._manifest.getMaximumSafePosition():Math.min(e,t)}}getEndingPosition(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(!(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)){if(this._lastAudioAdaptation===null)return this._lastVideoAdaptation===null?void 0:(e=Ur(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Ur(this._lastAudioAdaptation))!=null?t:void 0;{let r=Ur(this._lastAudioAdaptation),i=Ur(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Br(n){let{representations:e}=n,t=null,r;for(let i of e)if(i.index!==r){r=i.index;let a=i.index.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function Ur(n){let{representations:e}=n,t=null,r;for(let i=0;i<e.length;i++)if(e[i].index!==r){r=e[i].index;let a=e[i].index.getEnd();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function _a(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new Nn(n,t,r.getBufferTypes());a.register(()=>{o.dispose()}),o.addEventListener(\"warning\",u=>i.onWarning(u)),o.addEventListener(\"periodChange\",u=>i.onPeriodChanged(u)),o.addEventListener(\"endingPositionChange\",u=>{e.setDuration(u.endingPosition,u.isEnd)}),o.addEventListener(\"endOfStream\",()=>{c.debug(\"Init: end-of-stream order received.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function Ta(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=K(n.sourceBuffers,s=>s.type===\"audio\"),i=K(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}function Ea(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}var Pl=[\"\",\"webkit\",\"moz\",\"ms\"];function vl(n,e){let t=document.createElement(n.tagName),r=\"on\"+e;return r in t?!0:(t.setAttribute(r,\"return;\"),typeof t[r]==\"function\")}function Cl(n,e){return e.filter(t=>vl(n,t))[0]}function Al(n,e){return n.reduce((t,r)=>t.concat((e===void 0?Pl:e).map(i=>i+r)),[])}function Te(n,e){let t,r=Al(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=Cl(i,r)),J(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{b.CURRENT_ENV===b.DEV&&c.warn(`compat: element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let u=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(u=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),u&&delete i[\"on\"+s]})})}}}var oD=Te([\"loadedmetadata\"]),sD=Te([\"timeupdate\"]),uD=Te([\"addtrack\"]),dD=Te([\"removetrack\"]),Kt=Te([\"sourceopen\",\"webkitsourceopen\"]),Lr=Te([\"sourceclose\",\"webkitsourceclose\"]),Fr=Te([\"sourceended\",\"webkitsourceended\"]),ks=Te([\"update\"]),xs=Te([\"removesourcebuffer\"]),lD=Te([\"keymessage\",\"message\"]),fD=Te([\"keyadded\",\"ready\"]),mD=Te([\"keyerror\",\"error\"]),cD=Te([\"keystatuseschange\"]),pD=Te([\"seeking\"]),gD=Te([\"seeked\"]),hD=Te([\"ended\"]);function kl(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Bn(n,e){if(c.debug(\"Init: Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"Init: MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=kl(t);if(r.length===0){c.info(\"Init: Triggering end of stream\");try{n.endOfStream()}catch(a){c.error(\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}c.debug(\"Init: Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new W;i.linkToSignal(e);for(let a of r)ks(a,()=>{i.cancel(),Bn(n,e)},i.signal);xs(t,()=>{i.cancel(),Bn(n,e)},i.signal)}function Ms(n,e){let t=new W;t.linkToSignal(e),Kt(n,()=>{c.debug(\"Init: MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new W,t.linkToSignal(e),Bn(n,t.signal)},e),Bn(n,t.signal)}var xl=!1,Ml=!1,Os=!1,Ol=!1,wl=!1,Dl=!1,Nl=!1,Bl=!1,Ul=!1,Ll=!1,Fl=!1,zl=!1,Wl=!1,Ra=!1,Vl=!1;(function(){var e,t,r;nr||(typeof Ee.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?(Ml=!0,Os=!0):navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?Os=!0:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?xl=!0:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Ol=!0:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Dl=!0:(Object.prototype.toString.call(Ee.HTMLElement).indexOf(\"Constructor\")>=0||((t=(e=Ee.safari)==null?void 0:e.pushNotification)==null?void 0:t.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((r=navigator.vendor)==null?void 0:r.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(wl=!0),/SamsungBrowser/.test(navigator.userAgent)&&(Nl=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?Wl=!0:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?Ra=!0:/Tizen/.test(navigator.userAgent)?Bl=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(Ul=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?Fl=!0:(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent))&&(Ll=!0)):/[Pp]anasonic/.test(navigator.userAgent)?zl=!0:navigator.userAgent.indexOf(\"Xbox\")!==-1&&(Vl=!0))})();function Pa(){return Ra}var ql=365*24*3600,Un=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new W;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Kl(r,i),o=new W;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new W,o.linkToSignal(i);let u=Gl(r.sourceBuffers,o.signal),f=new W;return f.linkToSignal(o.signal),u.onUpdate(d=>{f.cancel(),f=new W,f.linkToSignal(o.signal),!d&&Ds(r,e,t,f.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function Hl(n,e,t){let r=e;t||(r=Pa()?1/0:ws(e));let i=0;for(let a=0;a<n.sourceBuffers.length;a++){let o=n.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"Init: Updating duration to what is currently buffered\",i),n.duration=i}catch(a){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"Init: Updating duration\",r),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=ws(e);c.info(\"Init: calling `mediaSource.setLiveSeekableRange`\",s),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"Duration Updater: Can't update duration on the MediaSource.\",s instanceof Error?s:\"\"),\"failed\"}let o=Math.abs(n.duration-r);if(o>=.1){let s=Math.abs(n.duration-a);return o<s?\"partial\":\"failed\"}return\"success\"}}function Gl(n,e){if(n.length===0){let i=new j(!1);return i.finish(),i}let t=new j(!1,e);r();for(let i=0;i<n.length;i++){let a=n[i];a.addEventListener(\"updatestart\",r),a.addEventListener(\"update\",r),e.register(()=>{a.removeEventListener(\"updatestart\",r),a.removeEventListener(\"update\",r)})}return t;function r(){for(let i=0;i<n.length;i++)if(n[i].updating){t.setValueIfChanged(!0);return}t.setValueIfChanged(!1)}}function Kl(n,e){let t=new j(n.readyState===\"open\",e);return Kt(n,()=>{c.debug(\"Init: Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Fr(n,()=>{c.debug(\"Init: Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Lr(n,()=>{c.debug(\"Init: Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function Ds(n,e,t,r){if(Hl(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),Ds(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function ws(n){return Math.max(Math.pow(2,32),n+ql)}var Ln=class extends oe{constructor(e){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,v(_t))throw new Q(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"Init: Creating MediaSource\");let t=new _t;this.readyState=t.readyState;let r=t.handle;this.handle=v(r)?{type:\"media-source\",value:t}:{type:\"handle\",value:r},this._mediaSource=t,this._durationUpdater=new Un(t),this._endOfStreamCanceller=null,Kt(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Fr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Lr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal)}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new va(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(){this._durationUpdater.stopUpdating()}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new W,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"Init: end-of-stream order received.\"),Ms(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"Init: resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),jl(this._mediaSource)}},va=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new W,this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=o=>{let s;o instanceof Error?s=o:o.error instanceof Error?s=o.error:s=new Error(\"Unknown SourceBuffer Error\");let u=this._currentOperations;if(this._currentOperations=[],u.length===0)c.error(\"SBI: error for an unknown operation\",s);else{let f=new Ce(s.name,s.message,s.name===\"QuotaExceededError\");for(let d of u)d.reject(f)}},a=()=>{let o=this._currentOperations;this._currentOperations=[];try{for(let s of o)s.resolve(oa(this._sourceBuffer.buffered))}catch(s){for(let u of o)s instanceof Error&&s.name===\"InvalidStateError\"?u.resolve([]):u.reject(s)}this._performNextOperation()};r.addEventListener(\"error\",i),r.addEventListener(\"updateend\",a),this._canceller.signal.register(()=>{r.removeEventListener(\"error\",i),r.removeEventListener(\"updateend\",a)})}appendBuffer(...e){return c.debug(\"SBI: receiving order to push data to the SourceBuffer\",this.type),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"SBI: receiving order to remove data from the SourceBuffer\",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return oa(this._sourceBuffer.buffered)}catch(e){return c.error(\"Failed to get buffered time range of SourceBuffer\",this.type,e instanceof Error?e:null),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){c.debug(\"Init: Failed to abort SourceBuffer:\",e instanceof Error?e:null)}this._emptyCurrentQueue()}dispose(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()}_emptyCurrentQueue(){let e=new ie;this._currentOperations.length>0&&(this._currentOperations.forEach(t=>{t.reject(e)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(t=>{t.reject(e)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=H({resolve:t,reject:r},e);this._operationQueue.push(a),i&&this._performNextOperation()})}_performNextOperation(){var t,r,i,a,o;if(this._currentOperations.length!==0||this._sourceBuffer.updating)return;let e=this._operationQueue.shift();if(e!==void 0)if(e.operationName===0){this._currentOperations=[{operationName:0,resolve:e.resolve,reject:e.reject}];let s=e.params[0],u=e.params[1],f=s;if(this._operationQueue.length>0&&this._operationQueue[0].operationName===0){let d;s instanceof ArrayBuffer?d=new Uint8Array(s):s instanceof Uint8Array?d=s:d=new Uint8Array(s.buffer);let l=[d];for(;((t=this._operationQueue[0])==null?void 0:t.operationName)===0;){let m=this._operationQueue[0],p=(r=u.appendWindow)!=null?r:[void 0,void 0],g=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],h=(a=u.timestampOffset)!=null?a:0,I=(o=m.params[1].timestampOffset)!=null?o:0;if(p[0]===g[0]&&p[1]===g[1]&&u.codec===m.params[1].codec&&h===I){let y=m.params[0],T;y instanceof ArrayBuffer?T=new Uint8Array(y):y instanceof Uint8Array?T=y:T=new Uint8Array(y.buffer),l.push(T),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:m.resolve,reject:m.reject})}else break}l.length>1&&(c.info(`MMSI: Merging ${l.length} segments together for perf`,this.type),f=At(...l))}try{this._appendBufferNow(f,u)}catch(d){let l=d instanceof Error?new Ce(d.name,d.message,d.name===\"QuotaExceededError\"):new Ce(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(l)}),this._currentOperations=[]}}else{this._currentOperations=[e];let[s,u]=e.params;c.debug(\"SBI: removing data from SourceBuffer\",this.type,s,u);try{this._sourceBuffer.remove(s,u)}catch(f){let d=f instanceof Error?new Ce(f.name,f.message,!1):new Ce(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(d),this._currentOperations=[]}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"SBI: updating codec\",i),Ea(r,i)?this.codec=i:c.debug(\"SBI: could not update codec\",i,this.codec)),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"SBI: updating timestampOffset\",i,r.timestampOffset,s),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"SBI: re-setting `appendWindowStart` to `0`\"),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"SBI: pre-updating `appendWindowEnd`\",s),r.appendWindowEnd=s}c.debug(\"SBI: setting `appendWindowStart`\",o[0]),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"SBI: re-setting `appendWindowEnd` to `Infinity`\"),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"SBI: setting `appendWindowEnd`\",o[1]),r.appendWindowEnd=o[1]),c.debug(\"SBI: pushing segment\",this.type),r.appendBuffer(e)}};function jl(n){if(n.readyState!==\"closed\"){let{readyState:e,sourceBuffers:t}=n;for(let r=t.length-1;r>=0;r--){let i=t[r];try{if(e===\"open\"){c.info(\"Init: Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"Init: Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"Init: Not all SourceBuffers could have been removed.\")}}var Yl=Ae(),zr=Ae(),Ns=1/0,Fn=class extends oe{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new W,this.readyState=\"closed\",this._messageSender=r;let i=Yl();this._messageSender({type:\"create-media-source\",contentId:t,mediaSourceId:i})}onMediaSourceReadyStateChanged(e){switch(e){case\"closed\":this.readyState=\"closed\",this.trigger(\"mediaSourceClose\",null);break;case\"open\":this.readyState=\"open\",this.trigger(\"mediaSourceOpen\",null);break;case\"ended\":this.readyState=\"ended\",this.trigger(\"mediaSourceEnded\",null);break}}addSourceBuffer(e,t){this._messageSender({type:\"add-source-buffer\",mediaSourceId:this.id,value:{sourceBufferType:e,codec:t}});let r=new Ca(e,t,this.id,this._messageSender);return this.sourceBuffers.push(r),r}setDuration(e,t){this._messageSender({type:\"update-media-source-duration\",mediaSourceId:this.id,value:{duration:e,isRealEndKnown:t}})}interruptDurationSetting(){this._messageSender({type:\"stop-media-source-duration\",mediaSourceId:this.id,value:null})}maintainEndOfStream(){this._messageSender({type:\"end-of-stream\",mediaSourceId:this.id,value:null})}stopEndOfStream(){this._messageSender({type:\"stop-end-of-stream\",mediaSourceId:this.id,value:null})}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Ca=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new W,this._mediaSourceId=r,this._queuedOperations=[],this._pendingOperations=new Map,this._messageSender=i}onOperationSuccess(e,t){let r=this._pendingOperations.get(e);r===void 0?c.warn(\"SBI: unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new ie:new Ce(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"SBI: unknown SourceBuffer operation failed\",r):(this._pendingOperations.delete(e),i.reject(r));let a=new ie;for(let o of this._queuedOperations)o.reject(a);this._queuedOperations=[]}appendBuffer(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=Ns){this._queuedOperations.push({operationName:0,params:[e,t],resolve:r,reject:i});return}try{let a;e instanceof ArrayBuffer?a=e:e.byteLength===e.buffer.byteLength?a=e.buffer:a=e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset);let o=zr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:o,value:{data:a,params:t}},[a]),this._addOperationToQueue(o,r,i)}catch(a){i(a)}})}remove(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=Ns){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=zr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{start:e,end:t}}),this._addOperationToQueue(a,r,i)}catch(a){i(a)}})}abort(){this._messageSender({type:\"abort-source-buffer\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,value:null})}dispose(){this.abort(),this._canceller.cancel()}getBuffered(){}_addOperationToQueue(e,t,r){this._pendingOperations.set(e,{resolve:a,reject:o});let i=this._canceller.signal.register(s=>{this._pendingOperations.delete(e),r(s)});function a(s){i(),t(s)}function o(s){i(),r(s)}}_performNextQueuedOperationIfItExists(){let e=this._queuedOperations.shift();if(e!==void 0)try{if(e.operationName===0){let[t,r]=e.params,i;t instanceof ArrayBuffer?i=t:t.byteLength===t.buffer.byteLength?i=t.buffer:i=t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset);let a=zr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{data:i,params:r}},[i]),this._addOperationToQueue(a,e.resolve,e.reject)}else{let[t,r]=e.params,i=zr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:i,value:{start:t,end:r}}),this._addOperationToQueue(i,e.resolve,e.reject)}}catch(t){e.reject(t)}}};function Aa(n){let e=n.map(o=>Math.log(o/n[0])),t=e.map(o=>o-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((o,s)=>a(s));function a(o){if(o===0)return 0;let s=Math.min(Math.max(1,o),n.length-1);return n[s]===n[s-1]?a(o-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var Fe=class{constructor(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}addSample(e,t){let r=Math.pow(this._alpha,e),i=t*(1-r)+r*this._lastEstimate;isNaN(i)||(this._lastEstimate=i,this._totalWeight+=e)}getEstimate(){let e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e}};var zn=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,a=this._currentRepresentationData,o;a!==null&&a.representation.id===e.id?(o=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=r,a.loadedSegments++):(o=new Fe(5),o.addSample(t,i),this._currentRepresentationData={representation:e,ewma:o,loadedDuration:r,loadedSegments:0}),o.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(c.debug(\"ABR: New last stable representation\",e.bitrate),this._lastRepresentationWithGoodScore=e)}getEstimate(e){if(this._currentRepresentationData===null||this._currentRepresentationData.representation.id!==e.id)return;let{ewma:t,loadedSegments:r,loadedDuration:i}=this._currentRepresentationData,a=t.getEstimate(),o=r>=5&&i>=10?1:0;return{score:a,confidenceLevel:o}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var Bs=6e3,Ql=15e3,$l=3e3,Xl=1e3,Zl=9e3,Wn=class{constructor(e){this._levelsMap=Aa(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=Bs,c.debug(\"ABR: Steps for buffer based chooser.\",this._levelsMap.map((t,r)=>`bufferLevel: ${t}, bitrate: ${e[r]}`).join(\" ,\"))}onAddedSegment(e){let t=this._levelsMap,r=this._bitrates,{bufferGap:i,currentBitrate:a,currentScore:o,speed:s}=e;if(v(a)){this._currentEstimate=r[0];return}let u=-1;for(let g=0;g<r.length;g++){let h=r[g];if(h===a)u=g;else if(h>a)break}if(u<0||r.length!==t.length){c.info(\"ABR: Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let f;o!==void 0&&(f=s===0?o.score:o.score/s);let d=isFinite(i)?i:0,l=L();if(d<t[u]||f!==void 0&&f<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Zl){let I=this._blockRaiseDelay+$l;this._blockRaiseDelay=Math.min(I,Ql),c.debug(\"ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality\",this._blockRaiseDelay)}else{let I=this._blockRaiseDelay-Xl;this._blockRaiseDelay=Math.max(Bs,I),c.debug(\"ABR: Lowering quality in BufferBasedChooser\",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=l;let h=ne(r,I=>I===a);for(let I=h-1;I>=0;I--)if(d>=t[I]){this._currentEstimate=r[I];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||f===void 0||f<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[u],p=(()=>{for(let g=u+1;g<t.length;g++)if(t[g]>m)return g})();if(p!==void 0){let g=t[p];if(i>=g){c.debug(\"ABR: Raising quality in BufferBasedChooser\",r[p]),this._currentEstimate=r[p];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Jl(n,e){let t=-1;for(let o=0;o<n.length;o++){let{segment:s}=n[o].content;if(s.duration<=0)continue;let u=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(u>e&&e-s.time>-1.2){t=o;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,a=[r];for(let o=t+1;o<n.length&&n[o].content.segment.time===i;o++)a.push(n[o]);return a}function Wr(n){if(n.progress.length<5)return;let e=new Fe(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,a=t[r].timestamp-t[r-1].timestamp,o=i*8/(a/1e3);e.addSample(a/1e3,o)}return e.getEstimate()}function Us(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function ef(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,f=s.getWanted()+u,d=Jl(n,f);if(d.length!==1)return;let l=d[0],m=L(),p=l.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),m-l.requestTimestamp<p)return;let g=l.progress.length>0?l.progress[l.progress.length-1]:void 0,h=Wr(l);if(g!==void 0&&h!==void 0){let C=Us(g,h);if((m-g.timestamp)/1e3<=C&&C-u/o>2500)return h}if(!l.content.segment.complete)return;let I=l.content.segment.duration,y=(m-l.requestTimestamp)/1e3,T=y<=(I*1.5+2)/o;if(v(t)||T)return;let P=I/y,E=t.bitrate*Math.min(.7,P);if(i===void 0||E<i)return E}function tf(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=K(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=L(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=Wr(a);if(s===void 0||u===void 0)return!0;let f=Us(s,u);return(o-s.timestamp)/1e3>f*1.2?!0:f-r/n.speed>-1.5}var Vn=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=U.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}getBandwidthEstimate(e,t,r,i,a){let o,s,u=this._config,{bufferGap:f,position:d,duration:l}=e,m=isFinite(f)?f:0,{ABR_STARVATION_DURATION_DELTA:p}=U.getCurrent();return isNaN(l)||m+d.getWanted()<l-p?!this._inStarvationMode&&m<=u.starvationGap?(c.info(\"ABR: enter starvation mode.\"),this._inStarvationMode=!0):this._inStarvationMode&&m>=u.outOfStarvationGap&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1),this._inStarvationMode&&(s=ef(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR: starvation mode emergency estimate:\",s),t.reset(),o=v(r)?s:Math.min(s,r.bitrate))),v(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):o=this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:tf(i,r,this._lowLatencyMode)}};var qn=class{constructor(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}update(e,t,r){this.representation=e,this.bandwidth=t,this.algorithmType=r}};var Hn=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,a){let{bufferGap:o,speed:s}=t,u=this._lastAbrEstimate.representation;if(u===null)return null;if(i>u.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let f=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(f===void 0)return null;if(this._canGuessHigher(o,s,f)){let l=Ls(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(u,i,f)&&(c.debug(\"ABR: Guessed Representation validated\",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,f,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=L()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),nf(e,r);if(f===void 0)return r;if(this._canGuessHigher(o,s,f)){let l=Ls(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&L()>this._blockGuessesUntil&&i===1&&r/t>1.01}_shouldStopGuess(e,t,r,i){if(t!==void 0&&t.score<1.01)return!0;if((t===void 0||t.score<1.2)&&r<.6)return!0;let a=i.filter(s=>s.content.representation.id===e.id),o=L();for(let s of a){let u=o-s.requestTimestamp;if(s.content.segment.isInit){if(u>1e3)return!0}else{if(u>s.content.segment.duration*1e3+200)return!0;{let f=Wr(s);if(f!==void 0&&f<e.bitrate*.8)return!0}}}return!1}_isLastGuessValidated(e,t,r){return r!==void 0&&r.confidenceLevel===1&&r.score>1.5?!0:t>=e.bitrate&&(this._lastMaintanableBitrate===null||this._lastMaintanableBitrate<e.bitrate)}};function Ls(n,e){let t=n.length,r=ne(n,({id:i})=>i===e.id);if(r<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function nf(n,e){let t=ne(n,({id:r})=>r===e.id);if(t<0)return c.error(\"ABR: Current Representation not found.\"),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var Gn=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new Fe(e),this._slowEWMA=new Fe(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=U.getCurrent();if(t<r)return;let i=t*8e3/e,a=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(a,i),this._slowEWMA.addSample(a,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=U.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=U.getCurrent();this._fastEWMA=new Fe(e),this._slowEWMA=new Fe(t),this._bytesSampled=0}};function ka(n,e){if(n.length===0)return[];n.sort((a,o)=>a.bitrate-o.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=ne(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function xa(n,e){if(e.width===void 0||e.height===void 0)return n;let t=e.width*e.pixelRatio,r=e.height*e.pixelRatio,i=n.slice().sort((s,u)=>{var f,d;return((f=s.width)!=null?f:0)-((d=u.width)!=null?d:0)}),a=K(i,s=>typeof s.width==\"number\"&&s.width>=t&&typeof s.height==\"number\"&&s.height>=r);if(a===void 0)return n;let o=typeof a.width==\"number\"?a.width:0;return n.filter(s=>typeof s.width==\"number\"?s.width<=o:!0)}var Kn=class{constructor(){this._currentRequests={}}add(e){let{id:t,requestTimestamp:r,content:i}=e;this._currentRequests[t]={requestTimestamp:r,progress:[],content:i}}addProgress(e){let t=this._currentRequests[e.id];if(v(t)){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR: progress for a request not added\");return}t.progress.push(e)}remove(e){if(v(this._currentRequests[e])){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR: can't remove unknown request\")}delete this._currentRequests[e]}getRequests(){return sr(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Vr(n,e){let t=ne(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var Fs=new j(void 0);Fs.finish();var zs=new j(1/0);zs.finish();function Ma(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,f,d,l){var I,y,T;let{type:m}=s.adaptation,p=a(m),g=(I=t[m])!=null?I:0,h={limitResolution:(y=r.limitResolution[m])!=null?y:Fs,throttleBitrate:(T=r.throttleBitrate[m])!=null?T:zs};return rf({bandwidthEstimator:p,context:s,currentRepresentation:u,filters:h,initialBitrate:g,playbackObserver:d,representations:f,lowLatencyMode:i},l)};function a(o){let s=e[o];if(v(s)){c.debug(\"ABR: Creating new BandwidthEstimator for \",o);let u=new Gn;return e[o]=u,u}return s}}function rf({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let f=new zn,d=new Vn(i!=null?i:0,a),l=new Kn,m=D,p={metrics:T,requestBegin:P,requestProgress:E,requestEnd:C,addedSegment(R){m(R)}},g=new W;g.linkToSignal(u);let h=I(s.getValue(),g.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:h,callbacks:p};function I(R,k){if(R.length<=1)return new j({bitrate:void 0,representation:R[0],urgent:!0,knownStableBitrate:void 0});let _=!1,A=R.sort((q,Y)=>q.bitrate-Y.bitrate),x=new Wn(A.map(q=>q.bitrate)),M=new qn,N=new Hn(f,M),w=o.getReference().getValue(),O=new j(V());return o.listen(q=>{w=q,B()},{includeLastObservation:!1,clearSignal:k}),m=function(q){if(w===null)return;let{position:Y,speed:G}=w,z=q.buffered,X=xr(z,Y.getWanted()),{representation:Z}=q.content,me=f.getEstimate(Z),ce=Z.bitrate,de={bufferGap:X,currentBitrate:ce,currentScore:me,speed:G};x.onAddedSegment(de),B()},k.register(()=>{m=D}),r.throttleBitrate.onUpdate(B,{clearSignal:k}),r.limitResolution.onUpdate(B,{clearSignal:k}),O;function B(){O.setValue(V())}function V(){let{bufferGap:q,position:Y,maximumPosition:G}=w,z=r.limitResolution.getValue(),X=r.throttleBitrate.getValue(),Z=t.getValue(),me=af(A,z,X),ce=l.getRequests(),{bandwidthEstimate:de,bitrateChosen:be}=d.getBandwidthEstimate(w,n,Z,ce,M.bandwidth),tr=f.getLastStableRepresentation(),pe=tr===null?void 0:tr.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Se,ABR_EXIT_BUFFER_BASED_ALGO:Yt}=U.getCurrent();_&&q<=Yt?_=!1:!_&&isFinite(q)&&q>=Se&&(_=!0);let Ge=Vr(me,be),xe=x.getLastEstimate(),Ot=Ge.bitrate,at=null;_&&xe!==void 0&&xe>Ot&&(at=Vr(me,xe),Ot=at.bitrate);let ot=null;return a&&Z!==null&&e.manifest.isDynamic&&G-Y.getWanted()<40&&(ot=N.getGuess(A,w,Z,Ot,ce)),ot!==null&&ot.bitrate>Ot?(c.debug(\"ABR: Choosing representation with guess-based estimation.\",ot.bitrate,ot.id),M.update(ot,de,2),{bitrate:de,representation:ot,urgent:Z===null||ot.bitrate<Z.bitrate,knownStableBitrate:pe}):at!==null?(c.debug(\"ABR: Choosing representation with buffer-based estimation.\",at.bitrate,at.id),M.update(at,de,0),{bitrate:de,representation:at,urgent:d.isUrgent(at.bitrate,Z,ce,w),knownStableBitrate:pe}):(c.debug(\"ABR: Choosing representation with bandwidth estimation.\",Ge.bitrate,Ge.id),M.update(Ge,de,1),{bitrate:de,representation:Ge,urgent:d.isUrgent(Ge.bitrate,Z,ce,w),knownStableBitrate:pe})}}function y(){let R=s.getValue();g.cancel(),g=new W,g.linkToSignal(u),I(R,g.signal).onUpdate(function(A){h.setValue(A)},{clearSignal:g.signal,emitCurrentValue:!0})}function T(R){let{requestDuration:k,segmentDuration:_,size:A,content:x}=R;if(n.addSample(k,A),!x.segment.isInit){let{segment:M,representation:N}=x;if(_===void 0&&!M.complete)return;let w=_!=null?_:M.duration;f.addSample(N,k/1e3,w)}}function P(R){l.add(R)}function E(R){l.addProgress(R)}function C(R){l.remove(R.id)}}function af(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=ka(r,t)),e!==void 0&&(r=xa(r,e)),r}var Ws=Ma;function it(n){return n instanceof re?new je(\"PIPELINE_LOAD_ERROR\",n):he(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function Oa(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function of(n){return n instanceof re?n.type===St.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===St.TIMEOUT||n.type===St.ERROR_EVENT:n instanceof Ke?typeof n.canRetry==\"boolean\"?n.canRetry:n.xhr!==void 0?n.xhr.status>=500||n.xhr.status===404||n.xhr.status===415||n.xhr.status===412:!1:wt(n)&&n.code===\"INTEGRITY_ERROR\"}async function wa(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:u}=r;n!==null&&n.length===0&&c.warn(\"Fetchers: no CDN given to `scheduleRequestWithCdns`.\");let f=new Map,d=l();if(d===void 0)throw new Error(\"No CDN to request\");return m(d);function l(){if(n===null){let I=f.get(null);return I!==void 0&&I.isBlacklisted?void 0:null}else{if(e===null)return h(n);{let I=e.getCdnPreferenceForResource(n);return h(I)}}}async function m(I){try{return await t(I,i)}catch(y){if(W.isCancellationError(y))throw y;I!==null&&e!==null&&e.downgradeCdn(I);let T=f.get(I);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},f.set(I,T)):T.errorCounter++,!of(y))return T.blockedUntil=void 0,T.isBlacklisted=!0,p(y);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let P=T.errorCounter,E=Math.min(a*Math.pow(2,P-1),o),C=Oa(E);T.blockedUntil=L()+C}return p(y)}}async function p(I){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw I;if(u(I),i.isCancelled())throw i.cancellationError;return g(y,I)}function g(I,y){let T=f.get(I);if(T===void 0||T.blockedUntil===void 0)return m(I);let P=L(),E=T.blockedUntil-P;if(E<=0)return m(I);let C=new W,R=C.linkToSignal(i);return new Promise((k,_)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let M=l();if(i.isCancelled())throw i.cancellationError;if(M===void 0)return x(y);M!==I&&(C.cancel(),g(M,y).then(A,x))},C.signal),Mn(E,C.signal).then(()=>m(I).then(A,x),D);function A(M){R(),k(M)}function x(M){R(),_(M)}})}function h(I){var T;if(f.size===0)return I[0];let y=L();return(T=I.filter(P=>{var E;return((E=f.get(P))==null?void 0:E.isBlacklisted)!==!0}).reduce((P,E)=>{var R;let C=(R=f.get(E))==null?void 0:R.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),P===void 0?[E,C]:P[1]===void 0?P:C===void 0?[E,void 0]:C<P[1]?[E,C]:P},void 0))==null?void 0:T[0]}}function Da(n,e,t){return wa(null,null,n,e,t)}var jn=class extends oe{constructor(e,t,r){super(),this.scheduleManualRefresh=D,this._manifestUrls=e,this._pipelines=t.manifest,this._settings=r,this._canceller=new W,this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(){this._canceller.cancel(),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof Nt?e=Promise.resolve({manifest:t}):t!==void 0?e=this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):e=this._fetchManifest(void 0).then(r=>r.parse({previousManifest:null,unsafeMode:!1})),e.then(r=>{this.trigger(\"manifestReady\",r.manifest),this._canceller.isUsed()||this._recursivelyRefreshManifest(r.manifest,r)}).catch(r=>this._onFatalError(r))}updateContentUrls(e,t){var r;this._prioritizedContentUrl=(r=e==null?void 0:e[0])!=null?r:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})}async _fetchManifest(e){var u;let t=this._canceller.signal,r=this._settings,i=this._pipelines,a=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],o=this._getBackoffSetting(f=>{this.trigger(\"warning\",it(f))});try{let f=await s(a);return{parse:d=>this._parseLoadedManifest(f,d,a)}}catch(f){throw it(f)}function s(f){let{loadManifest:d}=i,l=r.requestTimeout===void 0?U.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,m=r.connectionTimeout===void 0?U.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;return l<0&&(l=void 0),m<0&&(m=void 0),Da(()=>d(f,{timeout:l,connectionTimeout:m},t),o,t)}}parse(e,t,r){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,r)}async _parseLoadedManifest(e,t,r){var h;let i=L(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,f=this._getBackoffSetting(I=>{this.trigger(\"warning\",it(I))}),d=r!=null?r:(h=this._manifestUrls)==null?void 0:h[0],l={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:d};try{let I=this._pipelines.parseManifest(e,l,p,a,m);if(sf(I)){let{manifest:y,warnings:T}=await I;return g(y,T)}else return g(I.manifest,I.warnings)}catch(I){throw he(I,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(I){try{return await Da(I,f,a)}catch(y){throw it(y)}}function p(I){for(let y of I){if(a.isCancelled())return;let T=he(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function g(I,y){p(y);let T=L()-i;return c.info(`MF: Manifest parsed in ${T}ms`),{manifest:I,sendingTime:s,receivedTime:u,parsingTime:T}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=U.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,f=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:f}}_recursivelyRefreshManifest(e,{sendingTime:t,parsingTime:r,updatingTime:i}){let{MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:a,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:o}=U.getCurrent(),s=r!==void 0?r+(i!=null?i:0):void 0,u=!1;this._consecutiveUnsafeMode>0?u=this._consecutiveUnsafeMode<a:s!==void 0&&(u=s>=o);let f=t===void 0?0:L()-t,d=Math.max(this._settings.minimumManifestUpdateInterval-f,0),l=new W;if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:p,delay:g,canUseUnsafeMode:h}=m,I=h&&u,y=t===void 0?0:L()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),P=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:p,unsafeMode:I})},Math.max((g!=null?g:0)-y,T));l.signal.register(()=>{clearTimeout(P)})},e.expired!==null){let m=setTimeout(()=>{var p;(p=e.expired)==null||p.then(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},D)},d);l.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-f,p;s===void 0?p=m:e.lifetime<3&&s>=100?(p=Math.min(Math.max(3e3-f,Math.max(m,0)+s),m*6),c.info(\"MUS: Manifest update rythm is too frequent. Postponing next request.\",m,p)):s>=e.lifetime*1e3/10?(p=Math.min(Math.max(m,0)+s,m*6),c.info(\"MUS: Manifest took too long to parse. Postponing next request\",p,p)):p=m;let g=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(p,d));l.signal.register(()=>{clearTimeout(g)})}}_triggerNextManifestRefresh(e,{enablePartialRefresh:t,unsafeMode:r}){let i=e.updateUrl,a,o;this._prioritizedContentUrl!==null?(a=!0,o=this._prioritizedContentUrl,this._prioritizedContentUrl=null):(a=!t||i===void 0,o=a?e.getUrls()[0]:i);let s=e.clockOffset;r?(this._consecutiveUnsafeMode+=1,c.info('Init: Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info('Init: Not parsing the Manifest in \"unsafeMode\" anymore after '+String(this._consecutiveUnsafeMode)+\" consecutive times.\"),this._consecutiveUnsafeMode=0),!this._isRefreshPending&&(this._isRefreshPending=!0,this._fetchManifest(o).then(u=>u.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(u=>{this._isRefreshPending=!1;let{manifest:f,sendingTime:d,parsingTime:l}=u,m=L();if(a)e.replace(f);else try{e.update(f)}catch(g){let h=g instanceof Error?g.message:\"unknown error\";c.warn(`MUS: Attempt to update Manifest failed: ${h}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:I}=U.getCurrent(),y=d===void 0?0:L()-d,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),P=D,E=setTimeout(()=>{P(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(I-y,T));P=this._canceller.signal.register(()=>{clearTimeout(E)});return}let p=L()-m;this._recursivelyRefreshManifest(e,{sendingTime:d,parsingTime:l,updatingTime:p})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function sf(n){return n instanceof Promise}var Na=jn;var Yn=class extends oe{constructor(e){super(),this._downgradedCdnList={metadata:[],timeouts:[]},e.register(()=>{for(let t of this._downgradedCdnList.timeouts)clearTimeout(t);this._downgradedCdnList={metadata:[],timeouts:[]}})}getCdnPreferenceForResource(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)}downgradeCdn(e){let t=Vs(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=U.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=Vs(this._downgradedCdnList.metadata,e);o>=0&&this._removeIndexFromDowngradeList(o),this.trigger(\"priorityChange\",null)},i);this._downgradedCdnList.timeouts.push(a),this.trigger(\"priorityChange\",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,a)=>(this._downgradedCdnList.metadata.some(o=>o.id===a.id&&o.baseUrl===a.baseUrl)?i[1].push(a):i[0].push(a),i),[[],[]]);return t.concat(r)}_removeIndexFromDowngradeList(e){this._downgradedCdnList.metadata.splice(e,1);let t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])}};function Vs(n,e){return n.length===0?-1:e.id!==void 0?ne(n,t=>t.id===e.id):ne(n,t=>t.baseUrl===e.baseUrl)}function Ba(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=f=>e(r,a,f),u=n.create(s,i,a,o);return t.set(u,s),u},updatePriority(r,i){let a=t.get(r);if(a===void 0){c.warn(\"Fetchers: Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Ua=class{constructor(){this._cache=new WeakMap}add({representation:e,segment:t},r){t.isInit&&this._cache.set(e,r)}get({representation:e,segment:t}){if(t.isInit){let r=this._cache.get(e);if(r!==void 0)return r}return null}},qs=Ua;var uf=Ae();function La(n,e,t,r,i){let a;i.connectionTimeout===void 0||i.connectionTimeout<0?a=void 0:a=i.connectionTimeout;let o={timeout:i.requestTimeout<0?void 0:i.requestTimeout,connectionTimeout:a},s=se([\"audio\",\"video\"],n)?new qs:void 0,{loadSegment:u,parseSegment:f}=e;return async function(l,m,p){var q,Y,G;let{segment:g,adaptation:h,representation:I,manifest:y,period:T}=l,P=yt(l),E=uf(),C,R=[],k=0,_=!1,A={segment:g,type:h.type,language:h.language,isLive:y.isLive,periodStart:T.start,periodEnd:T.end,mimeType:I.mimeType,codecs:I.codecs[0],manifestPublishTime:y.publishTime},x={onProgress(z){var X;C===void 0&&z.totalSize!==void 0&&z.size<z.totalSize&&((X=r.onProgress)==null||X.call(r,{duration:z.duration,size:z.size,totalSize:z.totalSize,timestamp:L(),id:E}))},onNewChunk(z){m.onChunk(O(z,!0))}},M=s!==void 0?s.get(l):null;if(M!==null)return c.debug(\"SF: Found wanted segment in cache\",P),m.onChunk(O(M,!1)),Promise.resolve();c.debug(\"SF: Beginning request\",P),(q=r.onRequestBegin)==null||q.call(r,{requestTimestamp:L(),id:E,content:l}),p.register(N);try{let z=await wa(l.representation.cdnMetadata,t,w,H({onRetry:B},i),p);if(z.resultType===\"segment-loaded\"){let X=z.resultData.responseData;s!==void 0&&s.add(l,z.resultData.responseData),m.onChunk(O(X,!1))}else z.resultType===\"segment-created\"&&m.onChunk(O(z.resultData,!1));c.debug(\"SF: Segment request ended with success\",P),m.onAllChunksReceived(),z.resultType!==\"segment-created\"?(C=z.resultData,V()):C=null,p.isCancelled()||(Y=r.onRequestEnd)==null||Y.call(r,{id:E}),p.deregister(N)}catch(z){throw p.deregister(N),C=null,z instanceof ie?(c.debug(\"SF: Segment request aborted\",P),z):(c.debug(\"SF: Segment request failed\",P),(G=r.onRequestEnd)==null||G.call(r,{id:E}),it(z))}function N(){var z;C===void 0&&(c.debug(\"SF: Segment request cancelled\",P),C=null,(z=r.onRequestEnd)==null||z.call(r,{id:E}))}function w(z){return u(z,A,o,p,x)}function O(z,X){R.push(!1);let Z=R.length-1;return function(ce){let de={data:z,isChunked:X};try{let be=f(de,A,ce);return R[Z]||(k=k!==void 0&&be.segmentType===\"media\"&&be.chunkInfos!==null&&be.chunkInfos.duration!==void 0?k+be.chunkInfos.duration:void 0,R[Z]=!0,V()),be}catch(be){throw he(be,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function B(z){m.onRetry(it(z))}function V(){var z;_||!v(C)&&C.size!==void 0&&C.requestDuration!==void 0&&R.length>0&&R.every(X=>X)&&(_=!0,(z=r.onMetrics)==null||z.call(r,{size:C.size,requestDuration:C.requestDuration,content:l,segmentDuration:k}))}}}function Hs({maxRetry:n,lowLatencyMode:e,requestTimeout:t,connectionTimeout:r}){let{DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:i,DEFAULT_REQUEST_TIMEOUT:a,DEFAULT_CONNECTION_TIMEOUT:o,INITIAL_BACKOFF_DELAY_BASE:s,MAX_BACKOFF_DELAY_BASE:u}=U.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?u.LOW_LATENCY:u.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var $n=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"TP: the max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return Mt(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let f=()=>{p(),this._endTask(a)},d=g=>{r.beforeEnded(),f(),o(g)},l=g=>{f(),s(g)},m=new W,p=m.linkToSignal(i);a.interrupter=m,m.signal.register(()=>{a.interrupter=null,i.isCancelled()||r.beforeInterrupted()}),this._minPendingPriority=this._minPendingPriority===null?a.priority:Math.min(this._minPendingPriority,a.priority),this._pendingTasks.push(a),a.taskFn(m.signal).then(d).catch(g=>{!i.isCancelled()&&m.isUsed()&&g instanceof ie||l(g)})},taskFn:e,interrupter:null},this._canBeStartedNow(a)?(a.trigger(),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()):this._waitingQueue.push(a),()=>this._endTask(a)))}_endTask(e){e.hasEnded=!0;let t=Qn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Qn(e.taskFn,this._pendingTasks);if(r<0)return;this._pendingTasks.splice(r,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}}updatePriority(e,t){let r=Qn(e,this._waitingQueue);if(r>=0){let s=this._waitingQueue[r];if(s.priority===t||(s.priority=t,!this._canBeStartedNow(s)))return;this._findAndRunWaitingQueueTask(r),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks();return}let i=Qn(e,this._pendingTasks);if(i<0){c.warn(\"TP: request to update the priority of a non-existent task\");return}let a=this._pendingTasks[i];if(a.priority===t)return;let o=a.priority;a.priority=t,this._minPendingPriority===null||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(this._pendingTasks.length===1?this._minPendingPriority=t:this._minPendingPriority=Math.min(...this._pendingTasks.map(s=>s.priority)),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}_loopThroughWaitingQueue(){let e=this._waitingQueue.reduce((t,r)=>t===null||t>r.priority?r.priority:t,null);if(!(e===null||this._minPendingPriority!==null&&this._minPendingPriority<e))for(let t=0;t<this._waitingQueue.length;t++){let r=this._minPendingPriority===null?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=r&&(this._findAndRunWaitingQueueTask(t),t--)}}_interruptCancellableTasks(){for(let e=0;e<this._pendingTasks.length;e++){let t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(c.warn(\"TP : Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=Qn(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"TP: Interrupting a non-existent pending task. Aborting...\");return}this._pendingTasks.splice(t,1),this._waitingQueue.push(e),this._pendingTasks.length===0?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))),(r=e.interrupter)==null||r.cancel()}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Qn(n,e){return ne(e,t=>t.taskFn===n)}var Xn=class{constructor(e,t,r){let i=new Yn(r),{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=U.getCurrent();this._transport=e,this._prioritizer=new $n({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=i,this._backoffOptions=t}createSegmentFetcher(e,t){let r=Hs(this._backoffOptions),i=this._transport[e],a=La(e,i,this._cdnPrioritizer,t,r);return Ba(this._prioritizer,a)}};var Fa=Xn;var Zn=class{constructor(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}needToReload(e){let{readyState:t,rebuffering:r,freezing:i}=e;if((e.bufferGap!==void 0&&isFinite(e.bufferGap)?e.bufferGap:0)<6||r===null&&i===null||t>1)return this._currentFreezeTimestamp=null,!1;let o=L();this._currentFreezeTimestamp===null&&(this._currentFreezeTimestamp=o);let s=r!==null&&o-r.timestamp>4e3,u=i!==null&&o-i.timestamp>4e3;if((s||u)&&L()-this._currentFreezeTimestamp>4e3){let f=this._segmentSinksStore.getStatus(\"audio\"),d=this._segmentSinksStore.getStatus(\"video\"),l=!0,m=!0;for(let p of[f,d])if(p.type===\"initialized\")for(let g of p.value.getLastKnownInventory()){let{representation:h}=g.infos;if(h.decipherable===!1)return c.warn(\"Init: we have undecipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0;h.contentProtections!==void 0&&(m=!1,h.decipherable!==!0&&(l=!1))}if(!m&&l)return c.warn(\"Init: we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0}return!1}};var{DEFAULT_WANTED_BUFFER_AHEAD:df,DEFAULT_MAX_VIDEO_BUFFER_SIZE:lf,DEFAULT_MAX_BUFFER_AHEAD:ff,DEFAULT_MAX_BUFFER_BEHIND:mf}=U.getCurrent(),za=new j(df),Wa=new j(lf),Va=new j(ff),qa=new j(mf),qr=new j({height:void 0,width:void 0,pixelRatio:1}),Hr=new j(1/0);function $(n,e){c.debug(\"<--- Sending to Main:\",n.type),e===void 0?postMessage(n):postMessage(n,e)}function De(n){return he(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var Jn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,f,d,l,m;for(let p of this._refs.keys())(t=(e=this._refs.get(p))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(p))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(p))==null?void 0:a.video)==null||o.trackReference.finish(),(u=(s=this._refs.get(p))==null?void 0:s.video)==null||u.representations.finish(),(d=(f=this._refs.get(p))==null?void 0:f.text)==null||d.trackReference.finish(),(m=(l=this._refs.get(p))==null?void 0:l.text)==null||m.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,u;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(c.warn(\"WP: Track for periodId already declared\",e,t),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;v(a)?o=new j({representationIds:[],switchingMode:\"lazy\"}):(o=new j(a.representations.getValue()),r.setValue(H({},a,{representations:o}))),i[t]={trackReference:r,representations:o}}setTrack(e,t,r){var a;let i=(a=this._refs.get(e))==null?void 0:a[t];return i===void 0?(c.debug(\"WP: Setting track for inexistent periodId\",e,t),!1):(v(r)?(i.representations=new j({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new j(r.initialRepresentations),i.trackReference.setValue({adaptationId:r.adaptationId,switchingMode:r.switchingMode,representations:i.representations,relativeResumingPosition:r.relativeResumingPosition})),!0)}updateRepresentations(e,t,r,i){var s;let a=(s=this._refs.get(e))==null?void 0:s[r];if(a===void 0)return c.debug(\"WP: Setting track for inexistent periodId\",e,r),!1;let o=a.trackReference.getValue();return v(o)||o.adaptationId!==t?(c.debug(\"WP: Desynchronized Adaptation id\",o==null?void 0:o.adaptationId,t),!1):(a.representations.setValue(i),!0)}removeTrackSetter(e,t){let r=this._refs.get(e),i=r==null?void 0:r[t];return r===void 0||i===void 0?(c.debug(\"WP: Removing track setter for inexistent periodId\",e,t),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var er=class{constructor(e,t){this._contentId=e,this._messageSender=t,this._queues={pushTextData:[],remove:[]}}pushTextData(e){return new Promise((t,r)=>{this._messageSender({type:\"push-text-data\",contentId:this._contentId,value:e}),this._queues.pushTextData.push({resolve:t,reject:r})})}remove(e,t){return new Promise((r,i)=>{this._messageSender({type:\"remove-text-data\",contentId:this._contentId,value:{start:e,end:t}}),this._queues.remove.push({resolve:r,reject:i})})}reset(){this._messageSender({type:\"reset-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}stop(){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}_resetCurrentQueue(){let e=new ie;this._queues.pushTextData.forEach(t=>{t.reject(e)}),this._queues.remove.forEach(t=>{t.reject(e)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"WMS: remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}};var Gs=Ae(),jt=class{constructor({hasMseInWorker:e,hasVideo:t}){this._currentContent=null,this._currentMediaSourceCanceller=new W,this._hasVideo=t,this._hasMseInWorker=e;let r=new W;this._contentCanceller=r}initializeNewContent(e){return new Promise((t,r)=>{var k,_;this.disposeCurrentContent();let i=this._contentCanceller,a=new W;this._currentMediaSourceCanceller=a,a.linkToSignal(i.signal);let{contentId:o,url:s,hasText:u,transportOptions:f}=e,d=null;Ie(ae.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let l=typeof f.representationFilter==\"string\"?uo(f.representationFilter):void 0,m=ae.transports.dash(Me(ge({},f),{representationFilter:l})),p=new Na(s===void 0?void 0:[s],m,e.manifestRetryOptions),g=Ws({initialBitrates:{audio:(k=e.initialAudioBitrate)!=null?k:0,video:(_=e.initialVideoBitrate)!=null?_:0},lowLatencyMode:f.lowLatencyMode,throttlers:{limitResolution:{video:qr},throttleBitrate:{video:Hr}}}),h=a.signal.register(A=>{r(A)}),I=new Fa(m,e.segmentRetryOptions,i.signal),y=new Jn,[T,P,E]=Ks(o,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:u},a.signal),C=new Zn(P);this._currentContent={contentId:o,decipherabilityFreezeDetector:C,mediaSource:T,manifest:null,manifestFetcher:p,representationEstimator:g,segmentSinksStore:P,segmentFetcherCreator:I,workerTextSender:E,trackChoiceSetter:y},T.addEventListener(\"mediaSourceOpen\",function(){R()},a.signal),i.signal.register(()=>{p.dispose()}),p.addEventListener(\"warning\",A=>{$({type:\"warning\",contentId:o,value:De(A)})},i.signal),p.addEventListener(\"manifestReady\",A=>{if(d!==null){c.warn(\"WP: Multiple `manifestReady` events, ignoring\");return}d=A,this._currentContent!==null&&(this._currentContent.manifest=d),R()},a.signal),p.addEventListener(\"error\",A=>{r(A)},i.signal),p.start();function R(){if(d===null||T.readyState===\"closed\"||a.isUsed())return;let A=d.getMetadataSnapshot();d.addEventListener(\"manifestUpdate\",x=>{if(d===null)return;let M=H(d.getMetadataSnapshot(),{periods:[]});$({type:\"manifest-update\",contentId:o,value:{manifest:M,updates:x}})},i.signal),h(),t(A)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new W,$({type:\"reloading-media-source\",contentId:this._currentContent.contentId,value:e},[]);let[t,r,i]=Ks(this._currentContent.contentId,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.workerTextSender=i,new Promise((a,o)=>{t.addEventListener(\"mediaSourceOpen\",function(){a()},this._currentMediaSourceCanceller.signal),t.addEventListener(\"mediaSourceClose\",function(){o(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(s=>{o(s)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new W}};function Ks(n,e,t){let r;if(e.hasMseInWorker){let s=new Ln(Gs());r=s;let u,f=s.handle;if(f.type===\"handle\")u={type:\"handle\",value:f.value};else{let d=URL.createObjectURL(f.value);u={type:\"url\",value:d},t.register(()=>{URL.revokeObjectURL(d)})}$({type:\"attach-media-source\",contentId:n,value:u,mediaSourceId:r.id},[f.value])}else r=new Fn(Gs(),n,$);let i=e.hasText?new er(n,$):null,{hasVideo:a}=e,o=new bt(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Ha(){let n=!1,e=new jt({hasMseInWorker:!1,hasVideo:!0}),t=null,r=new jo;ae.dashParsers.wasm=r,ae.dashParsers.fastJs=Do,ae.transports.dash=ss;let i=null;onmessage=function(a){var s,u,f;c.debug(\"Worker: received message\",a.data.type);let o=a.data;switch(o.type){case\"init\":Ie(!n),n=!0,Ya(o.value),js(o.value.logLevel,o.value.sendBackLogs),o.value.dashWasmUrl!==void 0&&r.isCompatible()&&r.initialize({wasmUrl:o.value.dashWasmUrl}).catch(d=>{let l=d instanceof Error?d.toString():\"Unknown Error\";c.error(\"Worker: Could not initialize DASH_WASM parser\",l)}),(!o.value.hasVideo||o.value.hasMseInWorker)&&(e.disposeCurrentContent(),e=new jt({hasMseInWorker:o.value.hasMseInWorker,hasVideo:o.value.hasVideo})),ae.codecSupportProber=o.value.hasMseInWorker?mo:co,$({type:\"init-success\",value:null});break;case\"log-level-update\":js(o.value.logLevel,o.value.sendBackLogs);break;case\"prepare\":cf(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t!==null&&(t.cancel(),t=null);let l=new W,m=new j(H(o.value.initialObservation,{position:new Ct(...o.value.initialObservation.position)}));i=m,t=l,t.signal.register(()=>{m.finish()}),Ys(o.value,e,m,l.signal);break}case\"observation\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;let l=o.value,{buffered:m}=l,p=Ta(d.mediaSource,null);p.audio!==null&&(m.audio=p.audio),p.video!==null&&(m.video=p.video),i==null||i.setValue(H(l,{position:new Ct(...o.value.position)}));break}case\"ref-update\":pf(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t!==null&&(t.cancel(),t=null);break;case\"sb-success\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:l}=d.mediaSource,m=K(l,p=>p.type===o.sourceBufferType);if(m===void 0){c.info(\"WP: Success for an unknown SourceBuffer\",o.sourceBufferType);return}if(m.onOperationSuccess===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}m.onOperationSuccess(o.operationId,o.value.buffered);break}case\"sb-error\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:l}=d.mediaSource,m=K(l,p=>p.type===o.sourceBufferType);if(m===void 0){c.info(\"WP: Error for an unknown SourceBuffer\",o.sourceBufferType);return}if(m.onOperationFailure===void 0){c.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}m.onOperationFailure(o.operationId,o.value);break}case\"media-source-ready-state-change\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;if(d.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"WP: A MediaSourceInterface with MSE performed a cross-thread operation\");return}d.mediaSource.onMediaSourceReadyStateChanged(o.value);break}case\"decipherability-update\":{if(o.contentId!==((u=e.getCurrentContent())==null?void 0:u.contentId))return;let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let l=o.value;d.manifest.updateRepresentationsDeciperability(m=>{for(let p of l)if(m.representation.uniqueId===p.representationUniqueId)return p.decipherable;return m.representation.decipherable});break}case\"codec-support-update\":{let d=e.getCurrentContent();if(d===null||d.manifest===null)return;if(typeof((f=ae.codecSupportProber)==null?void 0:f.updateCache)==\"function\")for(let{mimeType:l,codec:m,result:p}of o.value)ae.codecSupportProber.updateCache(l,m,p);try{let l=d.manifest.refreshCodecSupport(o.value);l!==null&&$({type:\"warning\",contentId:d.contentId,value:De(l)})}catch(l){$({type:\"error\",contentId:d.contentId,value:De(l)})}break}case\"urls-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.manifestFetcher.updateContentUrls(o.value.urls,o.value.refreshNow);break}case\"track-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.setTrack(o.value.periodId,o.value.bufferType,o.value.choice);break}case\"rep-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.updateRepresentations(o.value.periodId,o.value.adaptationId,o.value.bufferType,o.value.choice);break}case\"add-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackSuccess(o.value.ranges);break}case\"push-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackError(new Error(o.value.message));break}case\"remove-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveSuccess(o.value.ranges);break}case\"remove-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){c.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveError(new Error(o.value.message));break}case\"pull-segment-sink-store-infos\":{gf(e,o.value.messageId);break}default:We(o)}}}function cf(n,e){n.initializeNewContent(e).then(t=>{$({type:\"manifest-ready\",contentId:e.contentId,value:{manifest:t}})},t=>{$({type:\"error\",contentId:e.contentId,value:De(t)})})}function pf(n){switch(n.value.name){case\"wantedBufferAhead\":za.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":Wa.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":qa.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":Va.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":qr.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":Hr.setValueIfChanged(n.value.newVal);break;default:We(n.value)}}function Ys(n,e,t,r){var k;let i=new W;i.linkToSignal(r);let a=new Map,o=e.getCurrentContent();if(o===null||o.manifest===null){let _=new Re(\"NONE\",\"Loading content when none is prepared\");$({type:\"error\",contentId:void 0,value:De(_)});return}let{contentId:s,manifest:u,mediaSource:f,representationEstimator:d,segmentSinksStore:l,segmentFetcherCreator:m}=o,{drmSystemId:p,enableFastSwitching:g,initialTime:h,onCodecSwitch:I}=n;if(t.onUpdate(_=>{o.decipherabilityFreezeDetector.needToReload(_)&&R({timeOffset:0,minimumPosition:0,maximumPosition:1/0}),[\"video\",\"audio\",\"text\"].forEach(A=>{var M;let x=l.getStatus(A);x.type===\"initialized\"&&x.value.synchronizeInventory((M=_.buffered[A])!=null?M:[])})}),((k=u.getPeriodForTime(h))!=null?k:u.getNextPeriod(h))===void 0){let _=new Q(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");$({type:\"error\",contentId:s,value:De(_)});return}let T=new In(t,s,$,i.signal),P=_a(u,f,T,l,{onWarning:_=>$({type:\"warning\",contentId:s,value:De(_)}),onPeriodChanged:_=>{$({type:\"active-period-changed\",contentId:s,value:{periodId:_.id}})}},i.signal);As({initialPeriod:u.periods[0],manifest:u},T,d,l,m,{wantedBufferAhead:za,maxVideoBufferSize:Wa,maxBufferAhead:Va,maxBufferBehind:qa,drmSystemId:p,enableFastSwitching:g,onCodecSwitch:I},E(),i.signal);function E(){return{needsBufferFlush(_){$({type:\"needs-buffer-flush\",contentId:s,value:_})},streamStatusUpdate(_){C(_),u.isLastPeriodKnown&&_.period.id===u.periods[u.periods.length-1].id&&(_.hasFinishedLoading||_.isEmptyStream?P.onLastSegmentFinishedLoading(_.bufferType):P.onLastSegmentLoadingResume(_.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:_}=U.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:_})},lockedStream(_){$({type:\"locked-stream\",contentId:s,value:{periodId:_.period.id,bufferType:_.bufferType}})},adaptationChange(_){var A,x;P.onAdaptationChange(_.type,_.period,_.adaptation),!i.signal.isCancelled()&&$({type:\"adaptation-changed\",contentId:s,value:{adaptationId:(x=(A=_.adaptation)==null?void 0:A.id)!=null?x:null,periodId:_.period.id,type:_.type}})},representationChange(_){var A,x;P.onRepresentationChange(_.type,_.period),!i.signal.isCancelled()&&$({type:\"representation-changed\",contentId:s,value:{adaptationId:_.adaptation.id,representationId:(x=(A=_.representation)==null?void 0:A.id)!=null?x:null,periodId:_.period.id,type:_.type}})},inbandEvent(_){$({type:\"inband-event\",contentId:s,value:_})},warning(_){$({type:\"warning\",contentId:s,value:De(_)})},periodStreamReady(_){o!==null&&(o.trackChoiceSetter.addTrackSetter(_.period.id,_.type,_.adaptationRef),$({type:\"period-stream-ready\",contentId:s,value:{periodId:_.period.id,bufferType:_.type}}))},periodStreamCleared(_){if(o===null)return;let A=a.get(_.period);A!==void 0&&(A.delete(_.type),A.size===0&&a.delete(_.period)),o.trackChoiceSetter.removeTrackSetter(_.period.id,_.type),$({type:\"period-stream-cleared\",contentId:s,value:{periodId:_.period.id,bufferType:_.type}})},bitrateEstimateChange(_){$({type:\"bitrate-estimate-change\",contentId:s,value:{bitrate:_.bitrate,bufferType:_.type}})},needsMediaSourceReload(_){R(_)},needsDecipherabilityFlush(){$({type:\"needs-decipherability-flush\",contentId:s,value:null})},encryptionDataEncountered(_){for(let A of _){let x=A.content,M=ge({},x);M.manifest instanceof Nt&&(M.manifest=M.manifest.getMetadataSnapshot()),M.period instanceof lt&&(M.period=M.period.getMetadataSnapshot()),M.adaptation instanceof ut&&(M.adaptation=M.adaptation.getMetadataSnapshot()),M.representation instanceof en&&(M.representation=M.representation.getMetadataSnapshot()),$({type:\"encryption-data-encountered\",contentId:s,value:{keyIds:A.keyIds,values:A.values,content:M,type:A.type}})}},error(_){$({type:\"error\",contentId:s,value:De(_)})}}}function C(_){let{imminentDiscontinuity:A}=_,x=a.get(_.period),M=x==null?void 0:x.get(_.bufferType);if(M!==void 0){if(M.discontinuity===null){if(A===null)return}else if(A!==null&&M.discontinuity.start===A.start&&M.discontinuity.end===A.end)return}x===void 0&&(x=new Map,a.set(_.period,x));let N={periodId:_.period.id,bufferType:_.bufferType,discontinuity:_.imminentDiscontinuity,position:_.position};x.set(_.bufferType,N),$({type:\"discontinuity-update\",contentId:s,value:N})}function R(_){let x=t.getValue().position.getWanted();i!==null&&i.cancel(),e.reloadMediaSource(_).then(()=>{Ys({initialTime:x,drmSystemId:n.drmSystemId,enableFastSwitching:n.enableFastSwitching,onCodecSwitch:n.onCodecSwitch},e,t,r)},M=>{$({type:\"error\",contentId:s,value:De(M)})})}}function js(n,e){e?c.setLevel(n,(t,r)=>{let i=r.map(a=>a instanceof Error?De(a):a);postMessage({type:\"log\",value:{logLevel:t,logs:i}})}):c.setLevel(n)}function gf(n,e){let t=n.getCurrentContent();if(t===null)return;let r=t.segmentSinksStore.getSegmentSinksMetrics();$({type:\"segment-sink-store-update\",contentId:t.contentId,value:{segmentSinkMetrics:r,messageId:e}})}var Qs=Ha;Qs();})();\n" + "})()"], { type: "application/javascript" });
1
+ const blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Zs=Object.defineProperty,Js=Object.defineProperties;var eu=Object.getOwnPropertyDescriptors;var Ga=Object.getOwnPropertySymbols;var tu=Object.prototype.hasOwnProperty,nu=Object.prototype.propertyIsEnumerable;var Ka=(n,e,t)=>e in n?Zs(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Z=(n,e)=>{for(var t in e||(e={}))tu.call(e,t)&&Ka(n,t,e[t]);if(Ga)for(var t of Ga(e))nu.call(e,t)&&Ka(n,t,e[t]);return n},ie=(n,e)=>Js(n,eu(e));var b={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var iu={DEFAULT_REQUEST_TIMEOUT:3e4,DEFAULT_CONNECTION_TIMEOUT:15e3,DEFAULT_TEXT_TRACK_MODE:\"native\",DEFAULT_ENABLE_FAST_SWITCHING:!0,DELTA_POSITION_AFTER_RELOAD:{bitrateSwitch:-.1,trackSwitch:{audio:0,video:0,other:0}},DEFAULT_CODEC_SWITCHING_BEHAVIOR:\"continue\",DEFAULT_AUTO_PLAY:!1,DEFAULT_WANTED_BUFFER_AHEAD:30,DEFAULT_MAX_BUFFER_AHEAD:1/0,DEFAULT_MAX_BUFFER_BEHIND:1/0,DEFAULT_MAX_VIDEO_BUFFER_SIZE:1/0,MAXIMUM_MAX_BUFFER_AHEAD:{text:18e3},MINIMUM_MAX_BUFFER_AHEAD:{text:120},MAXIMUM_MAX_BUFFER_BEHIND:{text:18e3},DEFAULT_BASE_BANDWIDTH:0,INACTIVITY_DELAY:6e4,DEFAULT_THROTTLE_VIDEO_BITRATE_WHEN_HIDDEN:!1,DEFAULT_VIDEO_RESOLUTION_LIMIT:\"none\",DEFAULT_LIVE_GAP:{DEFAULT:10,LOW_LATENCY:3.5},BUFFER_DISCONTINUITY_THRESHOLD:.2,BITRATE_REBUFFERING_RATIO:1.5,DEFAULT_MAX_MANIFEST_REQUEST_RETRY:4,DEFAULT_CDN_DOWNGRADE_TIME:60,DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:4,INITIAL_BACKOFF_DELAY_BASE:{REGULAR:200,LOW_LATENCY:50},MAX_BACKOFF_DELAY_BASE:{REGULAR:3e3,LOW_LATENCY:1e3},SAMPLING_INTERVAL_MEDIASOURCE:1e3,SAMPLING_INTERVAL_LOW_LATENCY:500,SAMPLING_INTERVAL_NO_MEDIASOURCE:500,ABR_ENTER_BUFFER_BASED_ALGO:10,ABR_EXIT_BUFFER_BASED_ALGO:5,ABR_MINIMUM_TOTAL_BYTES:15e4,ABR_MINIMUM_CHUNK_SIZE:16e3,ABR_STARVATION_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_REGULAR_FACTOR:{DEFAULT:.72,LOW_LATENCY:.72},ABR_STARVATION_GAP:{DEFAULT:5,LOW_LATENCY:5},OUT_OF_STARVATION_GAP:{DEFAULT:7,LOW_LATENCY:7},ABR_STARVATION_DURATION_DELTA:.1,ABR_FAST_EMA:2,ABR_SLOW_EMA:10,RESUME_GAP_AFTER_SEEKING:{DEFAULT:1.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_NOT_ENOUGH_DATA:{DEFAULT:.5,LOW_LATENCY:.5},RESUME_GAP_AFTER_BUFFERING:{DEFAULT:5,LOW_LATENCY:.5},REBUFFERING_GAP:{DEFAULT:.5,LOW_LATENCY:.2},MINIMUM_BUFFER_AMOUNT_BEFORE_FREEZING:2,UNFREEZING_SEEK_DELAY:6e3,FREEZING_STALLED_DELAY:600,UNFREEZING_DELTA_POSITION:.001,SEGMENT_SYNCHRONIZATION_DELAY:1500,MISSING_DATA_TRIGGER_SYNC_DELAY:.1,MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:.15,MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:.4,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:.3,MINIMUM_SEGMENT_SIZE:.001,APPEND_WINDOW_SECURITIES:{START:.2,END:.1},MAXIMUM_HTML_TEXT_TRACK_UPDATE_INTERVAL:50,TEXT_TRACK_SIZE_CHECKS_INTERVAL:250,BUFFER_PADDING:{audio:1,video:3,other:1},SEGMENT_PRIORITIES_STEPS:[2,4,8,12,18,25],MAX_HIGH_PRIORITY_LEVEL:1,MIN_CANCELABLE_PRIORITY:3,EME_DEFAULT_VIDEO_CODECS:['video/mp4;codecs=\"avc1.4d401e\"','video/mp4;codecs=\"avc1.42e01e\"','video/mp4;codecs=\"hvc1.1.6.L93.B0\"','video/webm;codecs=\"vp8\"'],EME_DEFAULT_AUDIO_CODECS:['audio/mp4;codecs=\"mp4a.40.2\"',\"audio/webm;codecs=opus\"],EME_DEFAULT_WIDEVINE_ROBUSTNESSES:[\"HW_SECURE_ALL\",\"HW_SECURE_DECODE\",\"HW_SECURE_CRYPTO\",\"SW_SECURE_DECODE\",\"SW_SECURE_CRYPTO\"],EME_DEFAULT_PLAYREADY_RECOMMENDATION_ROBUSTNESSES:[\"3000\",\"2000\"],EME_KEY_SYSTEMS:{clearkey:[\"webkit-org.w3.clearkey\",\"org.w3.clearkey\"],widevine:[\"com.widevine.alpha\"],playready:[\"com.microsoft.playready.recommendation\",\"com.microsoft.playready\",\"com.chromecast.playready\",\"com.youtube.playready\"],fairplay:[\"com.apple.fps.1_0\"]},MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:10,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:200,MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:300,OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:3e3,FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:3e3,DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:3,EME_DEFAULT_MAX_SIMULTANEOUS_MEDIA_KEY_SESSIONS:15,EME_MAX_STORED_PERSISTENT_SESSION_INFORMATION:1e3,EME_WAITING_DELAY_LOADED_SESSION_EMPTY_KEYSTATUSES:100,FORCED_ENDED_THRESHOLD:8e-4,ADAP_REP_SWITCH_BUFFER_PADDINGS:{video:{before:5,after:5},audio:{before:2,after:2.5},text:{before:0,after:0}},SOURCE_BUFFER_FLUSHING_INTERVAL:500,CONTENT_REPLACEMENT_PADDING:1.2,CACHE_LOAD_DURATION_THRESHOLDS:{video:50,audio:10},STREAM_EVENT_EMITTER_POLL_INTERVAL:250,DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR:.001,BUFFERED_HISTORY_RETENTION_TIME:6e4,BUFFERED_HISTORY_MAXIMUM_ENTRIES:200,MIN_BUFFER_AHEAD:5,UPTO_CURRENT_POSITION_CLEANUP:5,DEFAULT_VIDEO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_AUDIO_REPRESENTATIONS_SWITCHING_MODE:\"seamless\",DEFAULT_VIDEO_TRACK_SWITCHING_MODE:\"reload\",DEFAULT_AUDIO_TRACK_SWITCHING_MODE:\"seamless\"},ja=iu;function au(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r=0;r<e.length;r++){let i=e[r];for(let a in i)Object.prototype.hasOwnProperty.call(i,a)&&(t[a]=i[a])}return t}var H=typeof Object.assign==\"function\"?Object.assign:au;function jr(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function $t(n,...e){if(e.length===0)return n;let t=e.shift();if(jr(n)&&jr(t))for(let r in t)if(jr(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),$t(i,t[r])}else H(n,{[r]:t[r]});return $t(n,...e)}var Yr=class{constructor(){this._config=ja}update(e){let t=$t(this._config,e);this._config=t}getCurrent(){return this._config}},ou=new Yr,L=ou;var Ke=class n extends Error{constructor(e,t,r){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"CustomLoaderError\",this.canRetry=t,this.xhr=r}};function v(n){return n==null}var de=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=this._listeners[e];Array.isArray(i)?i.push(t):this._listeners[e]=[t],r!==void 0&&r.register(()=>{this.removeEventListener(e,t)})}removeEventListener(e,t){if(v(e)){this._listeners={};return}let r=this._listeners[e];if(!Array.isArray(r))return;if(v(t)){delete this._listeners[e];return}let i=r.indexOf(t);i!==-1&&r.splice(i,1),r.length===0&&delete this._listeners[e]}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i(t)}catch(a){if(b.CURRENT_ENV===b.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};function re(n,e,t){if(typeof Array.prototype.findIndex==\"function\")return n.findIndex(e,t);let r=n.length>>>0;for(let i=0;i<r;i++)if(e.call(t,n[i],i,n))return i;return-1}function B(){}var rr=class{constructor(e,t){this._value=e,this._listeners=[],this._isFinished=!1,this._onFinishCbs=[],t!==void 0&&(this._deregisterCancellation=t.register(()=>this.finish()))}getValue(){return this._value}setValue(e){if(this._isFinished){b.CURRENT_ENV===b.DEV&&console.error(\"Finished shared references cannot be updated\");return}if(this._value=e,this._listeners.length===0)return;let t=this._listeners.slice();for(let r of t)try{r.hasBeenCleared||r.trigger(e,r.complete)}catch(i){}}setValueIfChanged(e){e!==this._value&&this.setValue(e)}onUpdate(e,t){let r=()=>{if((t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.deregister(r),i.hasBeenCleared)return;i.hasBeenCleared=!0;let a=this._listeners.indexOf(i);a>=0&&this._listeners.splice(a,1)},i={trigger:e,complete:r,hasBeenCleared:!1};if(this._listeners.push(i),(t==null?void 0:t.emitCurrentValue)===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}(t==null?void 0:t.clearSignal)!==void 0&&t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return B;let r=()=>{let o=re(this._onFinishCbs,s=>s.trigger===i);o>=0&&(this._onFinishCbs[o].hasBeenCleared=!0,this._onFinishCbs.splice(o,1))},i=()=>{r(),e()},a=t.register(r);return this._onFinishCbs.push({trigger:i,hasBeenCleared:!1}),a}finish(){this._deregisterCancellation!==void 0&&this._deregisterCancellation(),this._isFinished=!0;let e=this._listeners.slice();for(let t of e)try{t.hasBeenCleared||(t.complete(),t.hasBeenCleared=!0)}catch(r){}if(this._listeners.length=0,this._onFinishCbs.length>0){let t=this._onFinishCbs.slice();for(let r of t)try{r.hasBeenCleared||(r.trigger(),r.hasBeenCleared=!0)}catch(i){}this._onFinishCbs.length=0}}};function Xt(n,e,t){let r=new rr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var j=rr;var Qr=new j(0);function Ya({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;Qr.setValueIfChanged(r-t)}var su=typeof performance!=\"undefined\"?()=>performance.now()+Qr.getValue():()=>Date.now()+Qr.getValue(),U=su;var uu=\"NONE\",Zt=class extends de{constructor(){super(),this.error=B,this.warn=B,this.info=B,this.debug=B,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat=\"standard\",this._currentLevel=uu}setLevel(e,t,r){let i,a=this._levels[e];typeof a==\"number\"?(i=a,this._currentLevel=e):(i=0,this._currentLevel=\"NONE\");let o;if(t===\"standard\"||t===\"full\"?o=t:o=\"standard\",o===\"full\"&&o!==this._currentFormat){let u=U();console.log(String(u.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(u,d)=>(...f)=>{let l=U();return d(String(l.toFixed(2)),`[${u}]`,...f)}:(u,d)=>d;if(r===void 0)this.error=i>=this._levels.ERROR?s(\"error\",console.error.bind(console)):B,this.warn=i>=this._levels.WARNING?s(\"warn\",console.warn.bind(console)):B,this.info=i>=this._levels.INFO?s(\"info\",console.info.bind(console)):B,this.debug=i>=this._levels.DEBUG?s(\"log\",console.log.bind(console)):B;else{let u=(d,f)=>i>=this._levels[d]?(...l)=>{let c=U();return r(d,[c,f,...l])}:B;this.error=u(\"ERROR\",\"error\"),this.warn=u(\"WARNING\",\"warn\"),this.info=u(\"INFO\",\"info\"),this.debug=u(\"DEBUG\",\"log\")}this.trigger(\"onLogLevelChange\",{level:this._currentLevel,format:this._currentFormat})}getLevel(){return this._currentLevel}getFormat(){return this._currentFormat}hasLevel(e){return this._levels[e]>=this._levels[this._currentLevel]}};var du=new Zt,m=du;var wt=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var lu=typeof window==\"undefined\"&&!wt,ir=lu;var ar;wt?ar=self:ir?ar=global:ar=window;var se=ar;var ae=class n extends Error{constructor(e,t,r){let i;switch(r){case\"TIMEOUT\":i=\"The request timed out\";break;case\"ERROR_EVENT\":i=\"An error prevented the request to be performed successfully\";break;case\"PARSE_ERROR\":i=\"An error happened while formatting the response data\";break;case\"ERROR_HTTP_CODE\":i=\"An HTTP status code indicating failure was received: \"+String(t);break}super(i),Object.setPrototypeOf(this,n.prototype),this.name=\"RequestError\",this.url=e,this.status=t,this.type=r}serialize(){return{url:this.url,status:this.status,type:this.type}}},Te={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var $r=typeof Headers==\"function\"?Headers:null,Xr=typeof AbortController==\"function\"?AbortController:null;function or(n){var c,g;let e;if(!v(n.headers))if(v($r))e=n.headers;else{e=new $r;let p=Object.keys(n.headers);for(let h=0;h<p.length;h++){let I=p[h];e.append(I,n.headers[I])}}m.debug(\"Fetch: Called with URL\",n.url);let t=null,r=!1,i=!1,a=U(),o=v(Xr)?null:new Xr;function s(){if(v(o)){m.warn(\"Fetch: AbortController API not available.\");return}o.abort()}let u;n.timeout!==void 0&&(u=setTimeout(()=>{r=!0,d!==void 0&&clearTimeout(d),s()},n.timeout));let d;n.connectionTimeout!==void 0&&(d=setTimeout(()=>{i=!0,u!==void 0&&clearTimeout(u),s()},n.connectionTimeout));let f=n.cancelSignal.register(function(h){t=h,s()}),l={method:\"GET\"};if(e!==void 0&&(l.headers=e),l.signal=v(o)?null:o.signal,m.hasLevel(\"DEBUG\")){let p=\"FETCH: Sending GET \"+n.url;n.timeout!==void 0&&(p+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(p+=\" cto=\"+String(n.connectionTimeout/1e3)),((c=n.headers)==null?void 0:c.Range)!==void 0&&(p+=\" Range=\"+((g=n.headers)==null?void 0:g.Range)),m.debug(p)}return fetch(n.url,l).then(p=>{if(d!==void 0&&clearTimeout(d),p.status>=300)throw m.warn(\"Fetch: Request HTTP Error\",p.status,p.url),new ae(p.url,p.status,Te.ERROR_HTTP_CODE);if(v(p.body))throw new ae(p.url,p.status,Te.PARSE_ERROR);let h=p.headers.get(\"Content-Length\"),I=!v(h)&&!isNaN(+h)?+h:void 0,y=p.body.getReader(),T=0;return P();async function P(){let E=await y.read();if(!E.done&&!v(E.value)){T+=E.value.byteLength;let C=U(),_={url:p.url,currentTime:C,duration:C-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:I};return n.onData(_),P()}else if(E.done){u!==void 0&&clearTimeout(u),f();let C=U();return{requestDuration:C-a,receivedTime:C,sendingTime:a,size:T,status:p.status,url:p.url}}return P()}}).catch(p=>{throw t!==null?t:(f(),r?(m.warn(\"Fetch: Request timed out.\"),new ae(n.url,0,Te.TIMEOUT)):i?(m.warn(\"Fetch: Request connection timed out.\"),new ae(n.url,0,Te.TIMEOUT)):p instanceof ae?p:(m.warn(\"Fetch: Request Error\",p instanceof Error?p.toString():\"\"),new ae(n.url,0,Te.ERROR_EVENT)))})}function Jt(){return typeof se.fetch==\"function\"&&!v(Xr)&&!v($r)}function J(n){return typeof n==\"string\"&&n.length>0}var fu=\"json\";function Zr(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?fu:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:u,timeout:d,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let c;d!==void 0&&(l.timeout=d,c=setTimeout(()=>{I(),r(new ae(o,l.status,Te.TIMEOUT))},d+3e3));let g;if(f!==void 0&&(g=setTimeout(()=>{I(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new ae(o,l.status,Te.TIMEOUT))},f)),l.responseType=u,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let T in y)y.hasOwnProperty(T)&&l.setRequestHeader(T,y[T])}let p=U(),h=null;if(a!==void 0&&(h=a.register(function(T){I(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){I(),r(new ae(o,l.status,Te.ERROR_EVENT))},l.ontimeout=function(){I(),r(new ae(o,l.status,Te.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(g)}),i!==void 0&&(l.onprogress=function(T){let P=U();i({url:o,duration:P-p,sendingTime:p,currentTime:P,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(I(),l.status>=200&&l.status<300){let P=U(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,C=l.status,_=l.responseType,x=J(l.responseURL)?l.responseURL:o,A;if(_===\"json\"?A=typeof l.response==\"object\"?l.response:cu(l.responseText):A=l.response,v(A)){r(new ae(o,l.status,Te.PARSE_ERROR));return}t({status:C,url:x,responseType:_,sendingTime:p,receivedTime:P,requestDuration:P-p,size:E,responseData:A})}else r(new ae(o,l.status,Te.ERROR_HTTP_CODE))},m.hasLevel(\"DEBUG\")){let y=\"XHR: Sending GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),d!==void 0&&(y+=\" to=\"+String(d/1e3)),f!==void 0&&(y+=\" cto=\"+String(f/1e3)),(s==null?void 0:s.Range)!==void 0&&(y+=\" Range=\"+(s==null?void 0:s.Range)),m.debug(y)}l.send();function I(){c!==void 0&&clearTimeout(c),g!==void 0&&clearTimeout(g),h!==null&&h()}})}function cu(n){try{return JSON.parse(n)}catch(e){return null}}var me=Zr;var yt=Te,Le={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function Xe(n,e){return`${n}: ${e}`}var en=class n extends Error{constructor(e,t,r){super(Xe(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=Le.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,typeof(r==null?void 0:r.keyStatuses)==\"string\"&&(this.keyStatuses=r.keyStatuses)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses}}};var $=class n extends Error{constructor(e,t,r){super(Xe(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=Le.MEDIA_ERROR,this._originalMessage=t,this.code=e,this.fatal=!1,(r==null?void 0:r.tracks)!==void 0&&(r==null?void 0:r.tracks.length)>0&&(this.tracksInfo=r.tracks)}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var je=class n extends Error{constructor(e,t){super(Xe(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=Le.NETWORK_ERROR,this.url=t.url,this.status=t.status,this.errorType=t.type,this._baseError=t,this.code=e,this.fatal=!1}isHttpError(e){return this.errorType===yt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var he=class n extends Error{constructor(e,t){super(Xe(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Le.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{name:this.name,code:this.code,reason:this._originalMessage}}};function Dt(n){return(n instanceof en||n instanceof $||n instanceof he||n instanceof je)&&Object.keys(Le).indexOf(n.type)>=0}function Ie(n,{defaultCode:e,defaultReason:t}){if(Dt(n))return n;let r=n instanceof Error?n.toString():t;return new he(e,r)}var ve=class n extends Error{constructor(e,t,r){super(t),Object.setPrototypeOf(this,n.prototype),this.name=\"SourceBufferError\",this.errorName=e,this.isBufferFull=r}serialize(){return{errorName:this.name,message:this.message,isBufferFull:this.isBufferFull}}toString(){return`${this.errorName}: ${this.message}`}};var mu={dashParsers:{wasm:null,native:null,fastJs:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},mainThreadMediaSourceInit:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},Qa=mu;var xe=Qa;function Y(n,e,t){if(typeof Array.prototype.find==\"function\")return n.find(e,t);let r=n.length>>>0;for(let i=0;i<r;i++){let a=n[i];if(e.call(t,a,i,n))return a}}var pu={aa:\"aar\",ab:\"abk\",ae:\"ave\",af:\"afr\",ak:\"aka\",am:\"amh\",an:\"arg\",ar:\"ara\",as:\"asm\",av:\"ava\",ay:\"aym\",az:\"aze\",ba:\"bak\",be:\"bel\",bg:\"bul\",bi:\"bis\",bm:\"bam\",bn:\"ben\",bo:\"bod\",br:\"bre\",bs:\"bos\",ca:\"cat\",ce:\"che\",ch:\"cha\",co:\"cos\",cr:\"cre\",cs:\"ces\",cu:\"chu\",cv:\"chv\",cy:\"cym\",da:\"dan\",de:\"deu\",dv:\"div\",dz:\"dzo\",ee:\"ewe\",el:\"ell\",en:\"eng\",eo:\"epo\",es:\"spa\",et:\"est\",eu:\"eus\",fa:\"fas\",ff:\"ful\",fi:\"fin\",fj:\"fij\",fo:\"fao\",fr:\"fra\",fy:\"fry\",ga:\"gle\",gd:\"gla\",gl:\"glg\",gn:\"grn\",gu:\"guj\",gv:\"glv\",ha:\"hau\",he:\"heb\",hi:\"hin\",ho:\"hmo\",hr:\"hrv\",ht:\"hat\",hu:\"hun\",hy:\"hye\",hz:\"her\",ia:\"ina\",id:\"ind\",ie:\"ile\",ig:\"ibo\",ii:\"iii\",ik:\"ipk\",io:\"ido\",is:\"isl\",it:\"ita\",iu:\"iku\",ja:\"jpn\",jv:\"jav\",ka:\"kat\",kg:\"kon\",ki:\"kik\",kj:\"kua\",kk:\"kaz\",kl:\"kal\",km:\"khm\",kn:\"kan\",ko:\"kor\",kr:\"kau\",ks:\"kas\",ku:\"kur\",kv:\"kom\",kw:\"cor\",ky:\"kir\",la:\"lat\",lb:\"ltz\",lg:\"lug\",li:\"lim\",ln:\"lin\",lo:\"lao\",lt:\"lit\",lu:\"lub\",lv:\"lav\",mg:\"mlg\",mh:\"mah\",mi:\"mri\",mk:\"mkd\",ml:\"mal\",mn:\"mon\",mr:\"mar\",ms:\"msa\",mt:\"mlt\",my:\"mya\",na:\"nau\",nb:\"nob\",nd:\"nde\",ne:\"nep\",ng:\"ndo\",nl:\"nld\",nn:\"nno\",no:\"nor\",nr:\"nbl\",nv:\"nav\",ny:\"nya\",oc:\"oci\",oj:\"oji\",om:\"orm\",or:\"ori\",os:\"oss\",pa:\"pan\",pi:\"pli\",pl:\"pol\",ps:\"pus\",pt:\"por\",qu:\"que\",rm:\"roh\",rn:\"run\",ro:\"ron\",ru:\"rus\",rw:\"kin\",sa:\"san\",sc:\"srd\",sd:\"snd\",se:\"sme\",sg:\"sag\",si:\"sin\",sk:\"slk\",sl:\"slv\",sm:\"smo\",sn:\"sna\",so:\"som\",sq:\"sqi\",sr:\"srp\",ss:\"ssw\",st:\"sot\",su:\"sun\",sv:\"swe\",sw:\"swa\",ta:\"tam\",te:\"tel\",tg:\"tgk\",th:\"tha\",ti:\"tir\",tk:\"tuk\",tl:\"tgl\",tn:\"tsn\",to:\"ton\",tr:\"tur\",ts:\"tso\",tt:\"tat\",tw:\"twi\",ty:\"tah\",ug:\"uig\",uk:\"ukr\",ur:\"urd\",uz:\"uzb\",ve:\"ven\",vi:\"vie\",vo:\"vol\",wa:\"wln\",wo:\"wol\",xh:\"xho\",yi:\"yid\",yo:\"yor\",za:\"zha\",zh:\"zho\",zu:\"zul\"},$a=pu;var gu={alb:\"sqi\",arm:\"hye\",baq:\"eus\",bur:\"mya\",chi:\"zho\",cze:\"ces\",dut:\"nld\",fre:\"fra\",geo:\"kat\",ger:\"deu\",gre:\"ell\",ice:\"isl\",mac:\"mkd\",mao:\"mri\",may:\"msa\",per:\"fas\",slo:\"slk\",rum:\"ron\",tib:\"bod\",wel:\"cym\"},Xa=gu;function hu(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Iu(t);return J(r)?r:n}function Iu(n){let e;switch(n.length){case 2:e=$a[n];break;case 3:e=Xa[n];break}return e}var Za=hu;var Ja=Za;function sr(n,e){if(n.length!==e.length)return!1;if(n===e)return!0;for(let t=n.length-1;t>=0;t--)if(n[t]!==e[t])return!1;return!0}function Ce(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var bu=Ce(),Jr=class{constructor(e,t,r){var a,o,s,u,d;this.id=e.id,this.uniqueId=bu(),this.bitrate=e.bitrate,this.codecs=[],this.trackType=t,e.isSpatialAudio!==void 0&&(this.isSpatialAudio=e.isSpatialAudio),e.height!==void 0&&(this.height=e.height),e.width!==void 0&&(this.width=e.width),e.mimeType!==void 0&&(this.mimeType=e.mimeType),e.contentProtections!==void 0&&(this.contentProtections=e.contentProtections),e.frameRate!==void 0&&(this.frameRate=e.frameRate),e.hdrInfo!==void 0&&(this.hdrInfo=e.hdrInfo),this.cdnMetadata=e.cdnMetadata,this.index=e.index;let i=this.contentProtections!==void 0;if(t===\"audio\"||t===\"video\"){if(e.supplementalCodecs!==void 0){let f=r.isSupported((a=this.mimeType)!=null?a:\"\",(o=e.supplementalCodecs)!=null?o:\"\",i);f!==!1&&(this.codecs=[e.supplementalCodecs],this.isSupported=f)}this.isSupported!==!0&&(this.codecs.length>0?this.codecs.push((s=e.codecs)!=null?s:\"\"):(this.codecs=e.codecs===void 0?[]:[e.codecs],this.isSupported=r.isSupported((u=this.mimeType)!=null?u:\"\",(d=e.codecs)!=null?d:\"\",i)))}else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,u;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(u=this.codecs)!=null?u:[];a.length===0&&(a=[\"\"]);let o=!1;for(let d of a){if(r=e.isSupported(i,d,t),r===!0){this.codecs=[d];break}r===void 0&&(o=!0)}r===!0?this.isSupported=!0:o?this.isSupported=void 0:this.isSupported=!1}getMimeTypeString(){var e,t,r;return`${(e=this.mimeType)!=null?e:\"\"};codecs=\"${(r=(t=this.codecs)==null?void 0:t[0])!=null?r:\"\"}\"`}getEncryptionData(e){var i,a;let t=this.getAllEncryptionData(),r=[];for(let o=0;o<t.length;o++){let s=!1,u=t[o];for(let d=0;d<u.values.length;d++)if(u.values[d].systemId.toLowerCase()===e.toLowerCase())if(s)r[r.length-1].values.push(u.values[d]);else{let f=(a=(i=this.contentProtections)==null?void 0:i.keyIds)==null?void 0:a.map(l=>l.keyId);r.push({type:u.type,keyIds:f,values:[u.values[d]]}),s=!0}}return r}getAllEncryptionData(){var t,r;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(r=(t=this.contentProtections)==null?void 0:t.keyIds)==null?void 0:r.map(i=>i.keyId);return this.contentProtections.initData.map(i=>({type:i.type,keyIds:e,values:i.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[{keyId:t}]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[{keyId:t}];else{let s=!1;for(let u of o)sr(u.keyId,t)&&(s=!0);s||(m.warn(\"Manifest: found unanounced key id.\"),o.push({keyId:t}))}}let a=this.contentProtections.initData;for(let o=0;o<a.length;o++)if(a[o].type===e){let s=a[o].values;for(let u=0;u<r.length;u++){let d=r[u],f;for(f=0;f<s.length;f++)if(d.systemId===s[f].systemId){if(sr(d.data,s[f].data))break;m.warn(\"Manifest: different init data for the same system ID\")}f===s.length&&(s.push(d),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}getMetadataSnapshot(){return{id:this.id,uniqueId:this.uniqueId,bitrate:this.bitrate,codecs:this.codecs,mimeType:this.mimeType,width:this.width,height:this.height,frameRate:this.frameRate,isSupported:this.isSupported,hdrInfo:this.hdrInfo,contentProtections:this.contentProtections,decipherable:this.decipherable}}},tn=Jr;var dt=class n{constructor(e,t,r={}){let{trickModeTracks:i}=e,{representationFilter:a,isManuallyAdded:o}=r;this.id=e.id,this.type=e.type,e.isTrickModeTrack!==void 0&&(this.isTrickModeTrack=e.isTrickModeTrack),e.language!==void 0&&(this.language=e.language,this.normalizedLanguage=Ja(e.language)),e.closedCaption!==void 0&&(this.isClosedCaption=e.closedCaption),e.audioDescription!==void 0&&(this.isAudioDescription=e.audioDescription),e.isDub!==void 0&&(this.isDub=e.isDub),e.forcedSubtitles!==void 0&&(this.isForcedSubtitles=e.forcedSubtitles),e.isSignInterpreted!==void 0&&(this.isSignInterpreted=e.isSignInterpreted),e.label!==void 0&&(this.label=e.label),i!==void 0&&i.length>0&&(this.trickModeTracks=i.map(d=>new n(d,t)));let s=e.representations,u=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let d=0;d<s.length;d++){let f=new tn(s[d],this.type,t),l=!0;if(!v(a)){let c={id:f.id,bitrate:f.bitrate,codecs:f.codecs,height:f.height,width:f.width,frameRate:f.frameRate,hdrInfo:f.hdrInfo};if(f.contentProtections!==void 0&&(c.contentProtections={},f.contentProtections.keyIds!==void 0)){let g=f.contentProtections.keyIds.map(({keyId:p})=>p);c.contentProtections.keyIds=g}l=a(c,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}l?(u.push(f),f.isSupported===void 0?(this.supportStatus.hasCodecWithUndefinedSupport=!0,this.supportStatus.hasSupportedCodec===!1&&(this.supportStatus.hasSupportedCodec=void 0)):f.isSupported&&(this.supportStatus.hasSupportedCodec=!0),f.decipherable===void 0?this.supportStatus.isDecipherable===!1&&(this.supportStatus.isDecipherable=void 0):f.decipherable&&(this.supportStatus.isDecipherable=!0)):m.debug(\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${f.id}`,`(${f.bitrate})`)}u.sort((d,f)=>d.bitrate-f.bitrate),this.representations=u,this.manuallyAdded=o===!0}refreshCodecSupport(e){let t=!1,r=!1;for(let i of this.representations)i.refreshCodecSupport(e),i.isSupported===void 0?t=!0:i.isSupported&&(r=!0);r?this.supportStatus.hasSupportedCodec=!0:t?this.supportStatus.hasSupportedCodec=void 0:this.supportStatus.hasSupportedCodec=!1,this.supportStatus.hasCodecWithUndefinedSupport=t}getRepresentation(e){return Y(this.representations,({id:t})=>e===t)}getMetadataSnapshot(){let e=[],t=this.representations;for(let r of t)e.push(r.getMetadataSnapshot());return{id:this.id,type:this.type,supportStatus:this.supportStatus,language:this.language,isForcedSubtitles:this.isForcedSubtitles,isClosedCaption:this.isClosedCaption,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted,normalizedLanguage:this.normalizedLanguage,representations:e,label:this.label,isDub:this.isDub}}};var lt=se,ei=lt===void 0?void 0:v(lt.MediaSource)?v(lt.MozMediaSource)?v(lt.WebKitMediaSource)?lt.MSMediaSource:lt.WebKitMediaSource:lt.MozMediaSource:lt.MediaSource;var Su=!1,yu=!1,eo=!1,Tu=!1,_u=!1,Eu=!1,Ru=!1,Pu=!1,vu=!1,Cu=!1,Au=!1,ku=!1,xu=!1,ti=!1,Mu=!1;(function(){var e,t,r;ir||(typeof se.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?(yu=!0,eo=!0):navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?eo=!0:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Su=!0:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Tu=!0:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Eu=!0:(Object.prototype.toString.call(se.HTMLElement).indexOf(\"Constructor\")>=0||((t=(e=se.safari)==null?void 0:e.pushNotification)==null?void 0:t.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((r=navigator.vendor)==null?void 0:r.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(_u=!0),/SamsungBrowser/.test(navigator.userAgent)&&(Ru=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?xu=!0:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?ti=!0:/Tizen/.test(navigator.userAgent)?Pu=!0:/[Ww]eb[O0]S/.test(navigator.userAgent)?(vu=!0,/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?Au=!0:(/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent))&&(Cu=!0)):/[Pp]anasonic/.test(navigator.userAgent)?ku=!0:navigator.userAgent.indexOf(\"Xbox\")!==-1&&(Mu=!0))})();function ni(n){return new Promise(e=>{setTimeout(e,n)})}function Tt(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(u){n.deregister(o),a=!0,r(u)},function(u){n.deregister(o),a=!0,i(u)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}function nn(n,e){return Tt(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var ur=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function be(n,e){if(b.DEV===b.CURRENT_ENV&&!n)throw new ur(e===void 0?\"invalid assertion\":e)}function Fe(n){throw new ur(\"Unreachable path taken\")}var z=class{constructor(){let[e,t]=Ou();this._isUsed=!1,this._trigger=e,this.signal=new ri(t)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(()=>{this.cancel()});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=e!=null?e:new oe;this._trigger(t)}static isCancellationError(e){return e instanceof oe}},ri=class{constructor(e){this._isCancelled=!1,this.cancellationError=null,this._listeners=[],e(t=>{for(this.cancellationError=t,this._isCancelled=!0;this._listeners.length>0;)try{let r=this._listeners.pop();r==null||r(t)}catch(r){m.error(\"Error while calling clean up listener\",r instanceof Error?r.toString():\"Unknown error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(be(this.cancellationError!==null),e(this.cancellationError),B):(this._listeners.push(e),()=>this.deregister(e))}deregister(e){for(let t=this._listeners.length-1;t>=0;t--)this._listeners[t]===e&&this._listeners.splice(t,1)}},oe=class n extends Error{constructor(){super(\"This task was cancelled.\"),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\"}};function Ou(){let n=B;return[function(t){n(t)},function(t){n=t}]}var wu=[\"\",\"webkit\",\"moz\",\"ms\"];function Du(n,e){let t=document.createElement(n.tagName),r=\"on\"+e;return r in t?!0:(t.setAttribute(r,\"return;\"),typeof t[r]==\"function\")}function Bu(n,e){return e.filter(t=>Du(n,t))[0]}function Nu(n,e){return n.reduce((t,r)=>t.concat((e===void 0?wu:e).map(i=>i+r)),[])}function _e(n,e){let t,r=Nu(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=Bu(i,r)),J(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{b.CURRENT_ENV===b.DEV&&m.warn(`compat: element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let u=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(u=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),u&&delete i[\"on\"+s]})})}}}var xg=_e([\"loadedmetadata\"]),Mg=_e([\"timeupdate\"]),Og=_e([\"addtrack\"]),wg=_e([\"removetrack\"]),Bt=_e([\"sourceopen\",\"webkitsourceopen\"]),dr=_e([\"sourceclose\",\"webkitsourceclose\"]),lr=_e([\"sourceended\",\"webkitsourceended\"]),to=_e([\"update\"]),no=_e([\"removesourcebuffer\"]),Dg=_e([\"keymessage\",\"message\"]),Bg=_e([\"keyadded\",\"ready\"]),Ng=_e([\"keyerror\",\"error\"]),Ug=_e([\"keystatuseschange\"]),Lg=_e([\"seeking\"]),Fg=_e([\"seeked\"]),zg=_e([\"ended\"]);var ro=[255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,62,255,255,255,63,52,53,54,55,56,57,58,59,60,61,255,255,255,0,255,255,255,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,255,255,255,255,255,255,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51];function fr(n){if(n>=ro.length)throw new Error(\"Unable to parse base64 string.\");let e=ro[n];if(e===255)throw new Error(\"Unable to parse base64 string.\");return e}function cr(n){let e=n.length%4,t=n;e!==0&&(m.warn(\"base64ToBytes: base64 given miss padding\"),t+=e===3?\"=\":e===2?\"==\":\"===\");let r=t.indexOf(\"=\");if(r!==-1&&r<t.length-2)throw new Error(\"Unable to parse base64 string.\");let i=t.endsWith(\"==\")?2:t.endsWith(\"=\")?1:0,a=t.length,o=new Uint8Array(a/4*3),s;for(let u=0,d=0;u<a;u+=4,d+=3)s=fr(t.charCodeAt(u))<<18|fr(t.charCodeAt(u+1))<<12|fr(t.charCodeAt(u+2))<<6|fr(t.charCodeAt(u+3)),o[d]=s>>16,o[d+1]=s>>8&255,o[d+2]=s&255;return o.subarray(0,o.length-i)}var Uu=typeof se==\"object\"&&typeof se.TextDecoder==\"function\",Lu=typeof se==\"object\"&&typeof se.TextEncoder==\"function\";function rn(n){if(Lu)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"\";m.warn(\"Utils: could not use TextEncoder to encode string into UTF-8, fallbacking to another implementation\",a)}let e,t=encodeURIComponent(n);if(typeof unescape==\"function\")e=unescape(t);else{let i=/[0-9a-fA-F]/,a=t.length;e=\"\";for(let o=0;o<t.length;o++){let s=!1;if(t[o]===\"%\"){if(o<=a-6&&t[o+1]===\"u\"&&i.test(t[o+2])&&i.test(t[o+3])&&i.test(t[o+4])&&i.test(t[o+5])){let u=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(u),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let u=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(u),s=!0,o+=2}}s||(e+=t[o])}}let r=new Uint8Array(e.length);for(let i=0;i<e.length;i++)r[i]=e.charCodeAt(i)&255;return r}function Fu(n){let t=\"\";for(let r=0;r<n.length;r+=16e3){let i=n.subarray(r,r+16e3);t+=String.fromCharCode.apply(null,i)}return t}function io(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function De(n){if(Uu)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"\";m.warn(\"Utils: could not use TextDecoder to parse UTF-8, fallbacking to another implementation\",a)}let e=n;e[0]===239&&e[1]===187&&e[2]===191&&(e=e.subarray(3));let t=Fu(e),r;if(typeof escape==\"function\")r=escape(t);else{let i=/[A-Za-z0-9*_\\+-\\.\\/]/;r=\"\";for(let a=0;a<t.length;a++)if(i.test(t[a]))r+=t[a];else{let o=t.charCodeAt(a);r+=o>=256?\"%u\"+io(o,4):\"%\"+io(o,2)}}return decodeURIComponent(r)}function an(n){let e=n.length,t=new Uint8Array(e/2);for(let r=0,i=0;r<e;r+=2,i++)t[i]=parseInt(n.substring(r,r+2),16)&255;return t}function ao(n,e=\"\"){let t=\"\";for(let r=0;r<n.byteLength;r++)t+=(n[r]>>>4).toString(16),t+=(n[r]&15).toString(16),e.length>0&&r<n.byteLength-1&&(t+=e);return t}function ii(n,e){let t=e;for(;t<n.length&&n[t]!==0;)t+=1;let r=n.subarray(e,t);return{end:t+1,string:De(r)}}function ze(n,e,t){if(typeof String.prototype.startsWith==\"function\")return n.startsWith(e,t);let r=typeof t==\"number\"?Math.max(t,0):0;return n.substring(r,r+e.length)===e}function _t(...n){let e=n.length,t=-1,r=0,i;for(;++t<e;)i=n[t],r+=typeof i==\"number\"?i:i.length;let a=new Uint8Array(r),o=0;for(t=-1;++t<e;)i=n[t],typeof i==\"number\"?o+=i:i.length>0&&(a.set(i,o),o+=i.length);return a}function oo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function ai(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function te(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function ft(n,e){return(n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3])*4294967296+n[e+4]*16777216+n[e+5]*65536+n[e+6]*256+n[e+7]}function Ye(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=te(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=ft(n,r+8)}if(isNaN(i)||i<=0)return-1;if(te(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function mr(n){let e=0,t=[],r=null;for(;e<=n.length;){if(e===n.length){r=null;break}r=n.subarray(e,1/0);let i=Ye(r,1836019558);if(i<0)break;let a=te(n,i+e),o=e+i+a;if(o>n.length)break;let s=Ye(r,1835295092);if(s<0)break;let u=te(n,s+e),d=e+s+u;if(d>n.length)break;let f=Math.max(o,d),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function zu(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function Wu(n,e,t){return n.slice(e,t)}var oi=typeof Uint8Array.prototype.slice==\"function\"?Wu:zu;function si(n,e){let t=n;for(let r of e){let i=le(t,r);if(i===null)return null;t=i}return t}function le(n,e){let t=Nt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function so(n,e){let t=[],r=n;for(;;){let i=Nt(r,e);if(i===null)return t;be(i[2]!==0&&r.length!==0),t.push(r.subarray(i[1],i[2])),r=r.subarray(i[2])}}function Nt(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=te(n,o),o+=4,i=te(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=ft(n,o),o+=8}if(a<0)throw new Error(\"ISOBMFF: Size out of range\");if(i===e)return e===1970628964&&(o+=16),[r,o,r+a];r+=a}return null}function pr(n){let e=0,t=le(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=Nt(t,1886614376)}catch(s){let u=s instanceof Error?s:\"\";return m.warn(\"Error while removing PSSH from ISOBMFF\",u),r}if(i===null)return r;let a=oi(t,i[0],i[2]),o=uo(a,i[1]-i[0]);o!==void 0&&r.push({systemId:o,data:a}),t[i[0]+4]=102,t[i[0]+5]=114,t[i[0]+6]=101,t[i[0]+7]=101,e=i[2]}return r}function uo(n,e){if(n[e]>1){m.warn(\"ISOBMFF: un-handled PSSH version\");return}let t=e+4;if(t+16>n.length)return;let r=oi(n,t,t+16);return ao(r)}function ui(n){let e=le(n,1836019558);return e===null?null:le(e,1953653094)}function lo(n){return so(n,1836019558).reduce((t,r)=>{let i=le(r,1953653094);return i!==null&&t.push(i),t},[])}function di(n){return le(n,1835295092)}function li(n){let e=le(n,1836019574);if(e===null)return null;let t=le(e,1953653099);return t===null?null:le(t,1835297121)}function fo(n,e=0){return le(n.subarray(e),1701671783)}function on(n,e){let t=Nt(n,1936286840);if(t===null)return null;let r=e,i=t[2]-t[0],a=t[1],o=n[a];a+=8;let s=te(n,a);a+=4;let u;if(o===0)u=te(n,a),a+=4,r+=te(n,a)+i,a+=4;else if(o===1)u=ft(n,a),a+=8,r+=ft(n,a)+i,a+=8;else return null;let d=[];a+=2;let f=oo(n,a);for(a+=2;--f>=0;){let l=te(n,a);a+=4;let c=(l&2147483648)>>>31,g=l&2147483647;if(c===1)throw new Error(\"sidx with reference_type `1` not yet implemented\");let p=te(n,a);a+=4,a+=4,d.push({time:u,duration:p,timescale:s,range:[r,r+g-1]}),u+=p,r+=g}return d}function fi(n){let e=ui(n);if(e===null)return;let t=le(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return ft(t,4);if(r===0)return te(t,4)}function Vu(n){let e=le(n,1952868452);if(e===null)return;let t=1,r=ai(e,t);t+=3;let i=(r&1)>0,a=(r&2)>0;return(r&8)>0?(t+=4,i&&(t+=8),a&&(t+=4),te(e,t)):void 0}function ci(n){let e=lo(n);if(e.length===0)return;let t=0;for(let r of e){let i=le(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=ai(i,a);a+=3;let u=(s&256)>0,d=0;if(!u&&(d=Vu(r),d===void 0))return;let f=(s&1)>0,l=(s&4)>0,c=(s&512)>0,g=(s&1024)>0,p=(s&2048)>0,h=te(i,a);a+=4,f&&(a+=4),l&&(a+=4);let I=h,y=0;for(;I-- >0;)u?(y+=te(i,a),a+=4):y+=d,c&&(a+=4),g&&(a+=4),p&&(a+=4);t+=y}return t}function sn(n){let e=li(n);if(e===null)return;let t=le(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return te(t,r+16);if(i===0)return te(t,r+8)}function co(n){let e=[],t=0;for(;t<n.length;){let r=fo(n,t);if(r===null)break;let i=r.length;t+=i;let a=r[0];if(a!==0)m.warn(\"ISOBMFF: EMSG version \"+a.toString()+\" not supported.\");else{let o=4,{end:s,string:u}=ii(r,o);o=s;let{end:d,string:f}=ii(r,o);o=d;let l=te(r,o);o+=4;let c=te(r,o);o+=4;let g=te(r,o);o+=4;let p=te(r,o);o+=4;let h=r.subarray(o,i),I={schemeIdUri:u,value:f,timescale:l,presentationTimeDelta:c,eventDuration:g,id:p,messageData:h};e.push(I)}}if(e.length!==0)return e}function mo(n){let e=si(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=le(t,1701733238),i=0;if(r===null?(i=28,r=le(t,1701733217)):i=78,r===null)return null;let a=si(r.subarray(i),[1936289382,1935894633,1952804451]);if(a===null||a.byteLength<24)return null;let o=a.subarray(8,24);return o.every(s=>s===0)?null:o}function fe(n,e,t){if(typeof Array.prototype.includes==\"function\")return n.includes(e,t);let r=n.length>>>0;if(r===0)return!1;let i=t|0,a=i>=0?Math.min(i,r-1):Math.max(r+i,0),o=(s,u)=>s===u||typeof s==\"number\"&&typeof u==\"number\"&&isNaN(s)&&isNaN(u);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function mi(n){return Object.keys(n).map(e=>n[e])}var gr=typeof Object.values==\"function\"?Object.values:mi;function qu(n,e){let{mimeType:t,codecs:r}=po(n),{mimeType:i,codecs:a}=po(e);return!(t!==i||r===\"\"||a===\"\"||r.split(\".\")[0]!==a.split(\".\")[0])}var Hu=7;function po(n){var i;let[e,...t]=n.split(\";\"),r=(i=Y(t,a=>ze(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(Hu),r[0]==='\"'&&(r=r.substring(1,r.length-2)),{mimeType:e,codecs:r}}var go=qu;function pi(n,e){return typeof Array.prototype.flatMap==\"function\"?n.flatMap(e):n.reduce((t,r)=>{let i=e(r);return Array.isArray(i)?(t.push(...i),t):(t.push(i),t)},[])}function gi(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function ho(n){var t,r,i,a,o;let e=[];for(let s of n.periods){let u=[...(t=s.adaptations.video)!=null?t:[],...(r=s.adaptations.audio)!=null?r:[]];for(let d of u)if(d.supportStatus.hasCodecWithUndefinedSupport)for(let f of d.representations)f.isSupported===void 0&&e.push({mimeType:(i=f.mimeType)!=null?i:\"\",codec:(o=(a=f.codecs)==null?void 0:a[0])!=null?o:\"\"})}return e}var Io=[];function Ze(n){fe(Io,n)||(console.warn(n),Io.push(n))}var Ut=[\"audio\",\"video\",\"text\"];function So(n){var a,o;let e=n.timeBounds;if(e.timeshiftDepth===null)return(a=e.minimumSafePosition)!=null?a:0;let{maximumTimeData:t}=e,r;if(!e.maximumTimeData.isLinear)r=t.maximumSafePosition;else{let s=U()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function yo(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=U()-e.time;return e.livePosition+t/1e3}function To(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=U()-e.time;return e.maximumSafePosition+t/1e3}function _o(n,e){if(e===void 0)return Ii(n).filter(r=>r.supportStatus.hasSupportedCodec!==!1&&r.supportStatus.isDecipherable!==!1);let t=n.adaptations[e];return t===void 0?[]:t.filter(r=>r.supportStatus.hasSupportedCodec!==!1&&r.supportStatus.isDecipherable!==!1)}function Eo(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(hi(i,e,t))return i;t=i}}function Ro(n,e){let t=e.end;if(t===void 0)return null;let r=Y(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function hi(n,e,t){return e>=n.start&&(n.end===void 0||e<n.end)?!0:e===n.end&&(t===null||t.start>n.end)}function Ii(n){let e=n.adaptations;return mi(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function Gu(n,e){var r,i;let t={language:(r=n.language)!=null?r:\"\",normalized:(i=n.normalizedLanguage)!=null?i:\"\",audioDescription:n.isAudioDescription===!0,id:n.id,representations:(e?n.representations.filter(a=>a.isSupported===!0&&a.decipherable!==!1):n.representations).map(Yu),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function Ku(n){var e,t;return{language:(e=n.language)!=null?e:\"\",normalized:(t=n.normalizedLanguage)!=null?t:\"\",closedCaption:n.isClosedCaption===!0,id:n.id,label:n.label,forced:n.isForcedSubtitles}}function ju(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>s.isSupported===!0&&s.decipherable!==!1):i.representations).map(bo),o={id:i.id,representations:a,isTrickModeTrack:!0};return i.isSignInterpreted===!0&&(o.signInterpreted=!0),o}):void 0,r={id:n.id,representations:(e?n.representations.filter(i=>i.isSupported===!0&&i.decipherable!==!1):n.representations).map(bo),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Yu(n){let{id:e,bitrate:t,codecs:r,isSpatialAudio:i,isSupported:a,decipherable:o}=n;return{id:e,bitrate:t,codec:r==null?void 0:r[0],isSpatialAudio:i,isCodecSupported:a,decipherable:o}}function bo(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:u,decipherable:d}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:u,decipherable:d}}function ct(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Gu(n,!1)};case\"video\":return{type:\"video\",track:ju(n,!1)};case\"text\":return{type:\"text\",track:Ku(n)}}}function Po(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var un=class{constructor(e){this.supportMap=new Map,this.addCodecs(e)}addCodecs(e){for(let t of e){let r=this.supportMap.get(t.mimeType);r===void 0&&(r=new Map,this.supportMap.set(t.mimeType,r)),r.set(t.codec,{supported:t.supported,supportedIfEncrypted:t.supportedIfEncrypted})}}isSupported(e,t,r){let i=this.supportMap.get(e);if(i===void 0)return;let a=i.get(t);if(a!==void 0)return r?a.supportedIfEncrypted:a.supported}};var mt=class{constructor(e,t,r,i){if(this.id=e.id,this.adaptations=Object.keys(e.adaptations).reduce((a,o)=>{let s=e.adaptations[o];if(v(s))return a;let u=s.map(d=>{let f=new dt(d,r,{representationFilter:i});return f.representations.length>0&&f.supportStatus.hasSupportedCodec===!1&&t.push(f),f}).filter(d=>d.representations.length>0);if(u.every(d=>d.supportStatus.hasSupportedCodec===!1)&&s.length>0&&(o===\"video\"||o===\"audio\"))throw new $(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+o+\" adaptations\",{tracks:void 0});return u.length>0&&(a[o]=u),a},{}),!Array.isArray(this.adaptations.video)&&!Array.isArray(this.adaptations.audio))throw new $(\"MANIFEST_PARSE_ERROR\",\"No supported audio and video tracks.\");this.duration=e.duration,this.start=e.start,!v(this.duration)&&!v(this.start)&&(this.end=this.start+this.duration),this.streamEvents=e.streamEvents===void 0?[]:e.streamEvents}refreshCodecSupport(e,t){Object.keys(this.adaptations).forEach(r=>{let i=this.adaptations[r];if(i===void 0)return;let a=!1;for(let o of i){if(!o.supportStatus.hasCodecWithUndefinedSupport){o.supportStatus.hasSupportedCodec===!0&&(a=!0);continue}let s=o.supportStatus.hasSupportedCodec;o.refreshCodecSupport(t),s!==!1&&o.supportStatus.hasSupportedCodec===!1&&e.push(o),a===!1?a=o.supportStatus.hasSupportedCodec:a===void 0&&o.supportStatus.hasSupportedCodec===!0&&(a=!0)}if((r===\"video\"||r===\"audio\")&&a===!1)throw new $(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"No supported \"+r+\" adaptations\",{tracks:void 0})},{})}getAdaptations(){return Ii(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return Y(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return _o(this,e)}containsTime(e,t){return hi(this,e,t)}getMetadataSnapshot(){let e={},t=this.getAdaptations();for(let r of t){let i=e[r.type];i===void 0&&(i=[],e[r.type]=i),i.push(r.getMetadataSnapshot())}return{start:this.start,end:this.end,id:this.id,streamEvents:this.streamEvents,adaptations:e}}};function dn(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.getAdaptations(),a=e.getAdaptations();for(let o=0;o<i.length;o++){let s=i[o],u=re(a,d=>d.id===s.id);if(u===-1){m.warn('Manifest: Adaptation \"'+i[o].id+'\" not found when merging.');let[d]=i.splice(o,1);o--,r.removedAdaptations.push({id:d.id,trackType:d.type})}else{let[d]=a.splice(u,1),f=[],l=[],c=[];r.updatedAdaptations.push({adaptation:s.id,trackType:s.type,updatedRepresentations:f,addedRepresentations:l,removedRepresentations:c});let g=s.representations,p=d.representations.slice();for(let h=0;h<g.length;h++){let I=g[h],y=re(p,T=>T.id===I.id);if(y===-1){m.warn(`Manifest: Representation \"${g[h].id}\" not found when merging.`);let[T]=g.splice(h,1);h--,c.push(T.id)}else{let[T]=p.splice(y,1);f.push(I.getMetadataSnapshot()),I.cdnMetadata=T.cdnMetadata,t===0?I.index._replace(T.index):I.index._update(T.index)}}p.length>0&&(m.warn(`Manifest: ${p.length} new Representations found when merging.`),s.representations.push(...p),l.push(...p.map(h=>h.getMetadataSnapshot())))}}if(a.length>0){m.warn(`Manifest: ${a.length} new Adaptations found when merging.`);for(let o of a){let s=n.adaptations[o.type];s===void 0?n.adaptations[o.type]=[o]:s.push(o),r.addedAdaptations.push(o.getMetadataSnapshot())}}return r}function vo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,u=n[s];for(;u!==void 0&&u.id!==o.id;)s++,u=n[s];if(u!==void 0){let d=dn(u,o,0);t.updatedPeriods.push({period:{id:u.id,start:u.start,end:u.end,duration:u.duration,streamEvents:u.streamEvents},result:d});let f=e.slice(r,a),l=s-r,c=n.splice(r,l,...f);t.removedPeriods.push(...c.map(g=>({id:g.id,start:g.start,end:g.end}))),t.addedPeriods.push(...f.map(g=>g.getMetadataSnapshot())),r=a+1}}if(r>n.length)return m.error(\"Manifest: error when updating Periods\"),t;if(r<n.length){let a=n.splice(r,n.length-r);t.removedPeriods.push(...a.map(o=>({id:o.id,start:o.start,end:o.end})))}let i=e.slice(r,e.length);return i.length>0&&(n.push(...i),t.addedPeriods.push(...i.map(a=>a.getMetadataSnapshot()))),t}function Co(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]};if(n.length===0)return n.splice(0,0,...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t;if(e.length===0)return t;let r=n[n.length-1];if(r.start<e[0].start){if(r.end!==e[0].start)throw new $(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");return n.push(...e),t.addedPeriods.push(...e.map(s=>s.getMetadataSnapshot())),t}let i=re(n,({id:s})=>s===e[0].id);if(i<0)throw new $(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=dn(n[i],e[0],1);t.updatedPeriods.push({period:H(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let u=e[s],d=-1;for(let f=o;f<n.length;f++)if(u.id===n[f].id){d=f;break}if(d<0){let f=-1;for(let g=o;g<n.length;g++)if(u.start<n[g].start){f=g;break}let l=f-o,c=n.splice(o,l,u);t.addedPeriods.push(u.getMetadataSnapshot()),t.removedPeriods.push(...c.map(g=>({id:g.id,start:g.start,end:g.end})))}else{if(d>o){m.warn(\"Manifest: old Periods not found in new when updating, removing\");let l=n.splice(o,d-o);t.removedPeriods.push(...l.map(c=>({id:c.id,start:c.start,end:c.end}))),d=o}let f=dn(n[d],u,0);t.updatedPeriods.push({period:H(n[d].getMetadataSnapshot(),{adaptations:void 0}),result:f})}o++}if(o<n.length){m.warn(\"Manifest: Ending Periods not found in new when updating, removing\");let s=n.splice(o,n.length-o);t.removedPeriods.push(...s.map(u=>({id:u.id,start:u.start,end:u.end})))}return t}var Qu=Ce(),ln=class extends de{constructor(e,t,r){var s;super();let{representationFilter:i,manifestUpdateUrl:a}=t;this.manifestFormat=0,this.id=Qu(),this.expired=(s=e.expired)!=null?s:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new un([]);let o=[];if(this.periods=e.periods.map(u=>new mt(u,o,this._cachedCodecSupport,i)).sort((u,d)=>u.start-d.start),o.length>0){let u=new $(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:o.map(ct)});r.push(u)}this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.timeBounds=e.timeBounds,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.uris=e.uris===void 0?[]:e.uris,this.updateUrl=a,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.availabilityStartTime=e.availabilityStartTime,this.publishTime=e.publishTime}updateCodecSupport(e=[]){if(e.length===0)return null;this._cachedCodecSupport.addCodecs(e);let t=[];for(let r of this.periods)r.refreshCodecSupport(t,this._cachedCodecSupport);return this.trigger(\"supportUpdate\",null),t.length>0?new $(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(ct)}):null}getPeriod(e){return Y(this.periods,t=>e===t.id)}getPeriodForTime(e){return Eo(this,e)}getNextPeriod(e){return Y(this.periods,t=>t.start>e)}getPeriodAfter(e){return Ro(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return So(this)}getLivePosition(){return yo(this)}getMaximumSafePosition(){return To(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=$u(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}getAdaptations(){Ze(\"manifest.getAdaptations() is deprecated. Please use manifest.period[].getAdaptations() instead\");let e=this.periods[0];if(e===void 0)return[];let t=e.adaptations,r=[];for(let i in t)if(t.hasOwnProperty(i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){Ze(\"manifest.getAdaptationsForType(type) is deprecated. Please use manifest.period[].getAdaptationsForType(type) instead\");let t=this.periods[0];if(t===void 0)return[];let r=t.adaptations[e];return r===void 0?[]:r}getAdaptation(e){return Ze(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),Y(this.getAdaptations(),({id:t})=>e===t)}getMetadataSnapshot(){let e=[];for(let t of this.periods)e.push(t.getMetadataSnapshot());return{manifestFormat:1,id:this.id,periods:e,isDynamic:this.isDynamic,isLive:this.isLive,isLastPeriodKnown:this.isLastPeriodKnown,suggestedPresentationDelay:this.suggestedPresentationDelay,clockOffset:this.clockOffset,uris:this.uris,availabilityStartTime:this.availabilityStartTime,timeBounds:this.timeBounds}}getCodecsWithUnknownSupport(){return ho(this)}_performUpdate(e,t){this.availabilityStartTime=e.availabilityStartTime,this.expired=e.expired,this.isDynamic=e.isDynamic,this.isLive=e.isLive,this.isLastPeriodKnown=e.isLastPeriodKnown,this.lifetime=e.lifetime,this.clockOffset=e.clockOffset,this.suggestedPresentationDelay=e.suggestedPresentationDelay,this.transport=e.transport,this.publishTime=e.publishTime;let r;if(t===0)this.timeBounds=e.timeBounds,this.uris=e.uris,r=vo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Co(this.periods,e.periods);let i=this.getMinimumSafePosition();for(;this.periods.length>0;){let a=this.periods[0];if(a.end===void 0||a.end>i)break;this.periods.shift()}}this.updateCodecSupport(),this.adaptations=this.periods[0]===void 0?{}:this.periods[0].adaptations,this.trigger(\"manifestUpdate\",r)}};function $u(n,e){let t=[];for(let r of n.periods)for(let i of r.getAdaptations()){let a=!0;for(let o of i.representations){let s={manifest:n,period:r,adaptation:i,representation:o},u=e(s);u!==!1&&(a=!1),u!==o.decipherable&&(t.push(s),o.decipherable=u,u===!0?i.supportStatus.isDecipherable=!0:u===void 0&&i.supportStatus.isDecipherable===!1&&(i.supportStatus.isDecipherable=void 0),m.debug(`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function Je(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function Et(n){if(v(n))return\"\";let{period:e,adaptation:t,representation:r,segment:i}=n,a;return i.isInit?a=\"init\":i.complete?a=`${i.time}-${i.duration}`:a=`${i.time}`,`${t.type} P: ${e.id} A: ${t.id} R: ${r.id} S: ${a}`}var Lt=ln;var Xu=\"<\";var Ao=\">\";var Zu=`\\r\n\t>/= `;function bi(n,e={}){var c,g;let t=(c=e.pos)!=null?c:0,r=e.keepComments===!0,i=e.keepWhitespace===!0,a;if(e.attrValue!==void 0)for(e.attrName=(g=e.attrName)!=null?g:\"id\",a=[];(t=l())!==-1;)t=n.lastIndexOf(\"<\",t),t!==-1&&a.push(d()),n=n.substring(t),t=0;else a=o(\"\");return e.filter&&(a=ko(a,e.filter)),a;function o(p){let h=[];for(;n[t];)if(n.charCodeAt(t)===60){if(n.charCodeAt(t+1)===47){let y=t+2;if(t=n.indexOf(Ao,t),n.substring(y,t).indexOf(p)===-1){let P=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(P.length-1)+`\nColumn: `+(P[P.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),h}else if(n.charCodeAt(t+1)===33){if(n.charCodeAt(t+2)===45){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===62&&n.charCodeAt(t-1)===45&&n.charCodeAt(t-2)===45);)t=n.indexOf(Ao,t+1);t===-1&&(t=n.length),r&&h.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===91&&n.charCodeAt(t+8)===91&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(h.push(n.substring(t+9)),t=n.length):(h.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==62||T)&&n[t];)n.charCodeAt(t)===91?T=!0:T&&n.charCodeAt(t)===93&&(T=!1),t++;h.push(n.substring(y,t))}t++;continue}let I=d();h.push(I),I.tagName[0]===\"?\"&&(h.push(...I.children),I.children=[])}else{let I=s();if(i)I.length>0&&h.push(I);else{let y=I.trim();y.length>0&&h.push(y)}t++}return h}function s(){let p=t;return t=n.indexOf(Xu,t)-1,t===-2&&(t=n.length),n.slice(p,t+1)}function u(){let p=t;for(;Zu.indexOf(n[t])===-1&&n[t];)t++;return n.slice(p,t)}function d(){let p=t;t++;let h=u(),I={},y=[];for(;n.charCodeAt(t)!==62&&n[t];){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let P=u(),E=n.charCodeAt(t);for(;E&&E!==39&&E!==34&&!(E>64&&E<91||E>96&&E<123)&&E!==62;)t++,E=n.charCodeAt(t);let C;E===39||E===34?C=f():(C=null,t--),I[P]=C===null?null:xo(C)}t++}return n.charCodeAt(t-1)!==47?(t++,y=o(h)):t++,{tagName:h,attributes:I,children:y,posStart:p,posEnd:t}}function f(){let p=n[t],h=t+1;return t=n.indexOf(p,h),n.slice(h,t)}function l(){let p=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return p?p.index:-1}}function ko(n,e,t=0,r=\"\"){let i=[];return n.forEach(function(a,o){if(typeof a==\"object\"&&(e(a,o,t,r)&&i.push(a),a.children.length>0)){let s=ko(a.children,e,t+1,(r?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function hr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+hr(t),e=e.trim()}),e}else return typeof n==\"object\"?hr(n.children):\" \"+xo(n)}function xo(n){return n.indexOf(\"&\")<0?n:n.replace(/&lt;/g,\"<\").replace(/&gt;/g,\">\").replace(/&quot;/g,'\"').replace(/&apos;/g,\"'\").replace(/&#x([A-Fa-f0-9]+);/g,(e,t)=>String.fromCharCode(parseInt(t,16))).replace(/&amp;/g,\"&\")}function Si(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return v(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function Be(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=Si(n,e,t);return r+(a+1)*i}function Re(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function Qe(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function Mo(n,e,t){return[n*t,(n+e)*t]}function Ju(n,e){let t=0,r=n.length;for(;t<r;){let i=t+r>>>1;n[i].start<=e?t=i+1:r=i}return t-1}function Oo(n,e,t){let{timeline:r}=n,i=Re(e,n);if(i<0)return null;let a=Ju(r,i);if(a<0||a>=r.length-1)return null;let o=r[a];if(o.duration<=0)return null;let s=r[a+1];if(s===void 0)return null;let u=s.start,d=Be(o,s,t);return i>=d&&i<u?Qe(u,n):null}function et(n,e){var i;let{initialization:t}=n,r={};return e!==void 0&&(r.isEMSGWhitelisted=e),{id:\"init\",isInit:!0,time:0,end:0,duration:0,timescale:1,range:v(t)?void 0:t.range,indexRange:n.indexRange,url:(i=t==null?void 0:t.url)!=null?i:null,complete:!0,privateInfos:r,timestampOffset:-(n.indexTimeOffset/n.timescale)}}function ed(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function yi(n){return(e,t,r)=>{let i=J(r)?parseInt(r,10):1;return ed(String(n),i)}}function Ne(n,e,t){return td(n,e,t)}function td(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(\\%0(\\d+)d)?\\$/g,yi(t===void 0?0:t))}function Ir(n,e){return function(r){return r.indexOf(\"$\")===-1?r:r.replace(/\\$\\$/g,\"$\").replace(/\\$Number(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(e===void 0)throw new Error(\"Segment number not defined in a $Number$ scheme\");return yi(e)(i,a,o)}).replace(/\\$Time(\\%0(\\d+)d)?\\$/g,(i,a,o)=>{if(n===void 0)throw new Error(\"Segment time not defined in a $Time$ scheme\");return yi(n)(i,a,o)})}}function nd(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function fn(n,e,t,r,i,a){var T;let o=r.getEstimatedMaximumPosition((T=n.availabilityTimeOffset)!=null?T:0),s=Math.min(e+t,o!=null?o:1/0),u=Re(e,n),d=Re(s,n),{timeline:f,timescale:l,segmentUrlTemplate:c,startNumber:g,endNumber:p}=n,h=g!=null?g:1,I=[],y=f.length;for(let P=0;P<y;P++){let E=f[P],{duration:C,start:_,range:x}=E,A;o===void 0?A=i:A=Math.min(o*l,i!=null?i:1/0);let R=Si(E,f[P+1],A),k=n.availabilityTimeComplete!==!1||P!==y-1&&R!==0,M=nd(_,C,u),D=_+M*C;for(;D<d&&M<=R;){let w=h+M;if(p!==void 0&&w>p)break;let O=c===null?null:Ir(D,w)(c),N=D-n.indexTimeOffset,V=C;N<0&&(V=C+N,N=0);let q={id:String(D),time:N/l,end:(N+V)/l,duration:V/l,isInit:!1,range:x,timescale:1,url:O,number:w,timestampOffset:-(n.indexTimeOffset/l),complete:k,privateInfos:{isEMSGWhitelisted:a}};I.push(q),M++,D=_+M*C}if(D>=d||(h+=R+1,p!==void 0&&h>p))return I}return I}function rd(n,e){if(e.timescale!==n.timescale){let{timescale:t}=n;n.timeline.push({start:e.time/e.timescale*t,duration:e.duration/e.timescale*t,repeatCount:e.count===void 0?0:e.count,range:e.range})}else n.timeline.push({start:e.time,duration:e.duration,repeatCount:e.count===void 0?0:e.count,range:e.range});return!0}var Rt=class{constructor(e,t){var p,h,I,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,u=(p=e.timescale)!=null?p:1,f=((h=e.presentationTimeOffset)!=null?h:0)-r*u,l=((I=e.initialization)==null?void 0:I.media)===void 0?null:Ne(e.initialization.media,a,o),c=e.media===void 0?null:Ne(e.media,a,o),g;e.initialization!==void 0?g=e.initialization.range:e.indexRange!==void 0&&(g=[0,e.indexRange[0]-1]),this._index={indexRange:e.indexRange,indexTimeOffset:f,initialization:{url:l,range:g},segmentUrlTemplate:c,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:u},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Re(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Re(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return et(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return fn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:Qe(Math.max(this._scaledPeriodStart,e.timeline[0].start),e)}getLastAvailablePosition(){var i;let{timeline:e}=this._index;if(e.length===0)return null;let t=e[e.length-1],r=Math.min(Be(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return Qe(r,this._index)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return this._isInitialized}initialize(e){if(!this._isInitialized){for(let t=0;t<e.length;t++)rd(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){m.error(\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Pt=class{constructor(e,t){var g,p,h;if(e.duration===void 0)throw new Error(\"Invalid SegmentList: no duration\");let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t;this._isEMSGWhitelisted=s,this._periodStart=r,this._periodEnd=i;let u=(g=e.presentationTimeOffset)!=null?g:0,d=(p=e.timescale)!=null?p:1,f=u-r*d,l=((h=e.initialization)==null?void 0:h.media)===void 0?null:Ne(e.initialization.media,a,o),c=e.list.map(I=>({url:I.media===void 0?null:Ne(I.media,a,o),mediaRange:I.mediaRange}));this._index={list:c,timescale:d,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:v(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=et(this._index);return e.privateInfos===void 0&&(e.privateInfos={}),e.privateInfos.isEMSGWhitelisted=this._isEMSGWhitelisted,e}getSegments(e,t){let r=this._index,{duration:i,list:a,timescale:o}=r,s=i/o,u=e-this._periodStart,[d,f]=Mo(u,t,o),l=Math.min(a.length-1,Math.floor(f/i)),c=[],g=Math.floor(d/i);for(;g<=l;){let p=a[g].mediaRange,h=a[g].url,I=g*s+this._periodStart,y={id:String(g),time:I,isInit:!1,range:p,duration:s,timescale:1,end:I+s,url:h,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};c.push(y),g++}return c}shouldRefresh(e,t){return!1}getFirstAvailablePosition(){return this._periodStart}getLastAvailablePosition(){var i;let e=this._index,{duration:t,list:r}=e;return Math.min(r.length*t/e.timescale+this._periodStart,(i=this._periodEnd)!=null?i:1/0)}getEnd(){return this.getLastAvailablePosition()}awaitSegmentBetween(){return!1}isSegmentStillAvailable(){return!0}checkDiscontinuity(){return null}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){return!1}isInitialized(){return!0}initialize(){m.error(\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `ListRepresentationIndex`\")}_replace(e){this._index=e._index}_update(){m.error(\"A `ListRepresentationIndex` cannot be updated\")}};function Ft(n){return L.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var vt=class{constructor(e,t){var y,T,P;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:u,representationBitrate:d,isEMSGWhitelisted:f}=t,l=(y=e.timescale)!=null?y:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let c=(T=e.presentationTimeOffset)!=null?T:0,g=s*l,p=c-g;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let h=((P=e.initialization)==null?void 0:P.media)===void 0?null:Ne(e.initialization.media,u,d),I=e.media===void 0?null:Ne(e.media,u,d);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:p,initialization:v(e.initialization)?void 0:{url:h,range:e.initialization.range},url:I,presentationTimeOffset:c,startNumber:e.startNumber,endNumber:e.endNumber},this._isDynamic=a,this._periodStart=s,this._scaledRelativePeriodEnd=o===void 0?void 0:(o-s)*l,this._isEMSGWhitelisted=f}getInitSegment(){return et(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:u}=r,d=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-d,c=(e+t)*s-d,g=this._getFirstSegmentStart(),p=this._getLastSegmentStart();if(v(g)||v(p))return[];let h=Math.max(g,l),I=Math.min(p,c);if(I+i<=h)return[];let y=[],T=a!=null?a:1,P=Math.floor(h/i);for(let E=P*i;E<=I;E+=i){let C=P+T;if(o!==void 0&&C>o)return y;let _=!v(f)&&E+i>f?f-E:i,x=E+d,A=E+this._index.presentationTimeOffset,R=u===null?null:Ir(A,C)(u),k={id:String(C),number:C,time:x/s,end:(x+_)/s,duration:_/s,timescale:1,isInit:!1,scaledDuration:_/s,url:R,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(k),P++}return y}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return v(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(v(e))return e;let t=this._estimateRelativeScaledEnd();return Math.min(e+this._index.duration,t!=null?t:1/0)/this._index.timescale+this._periodStart}getEnd(){if(!this._isDynamic)return this.getLastAvailablePosition();let e=this._estimateRelativeScaledEnd();if(e===void 0)return;let{timescale:t}=this._index;return(e+this._periodStart*t)/t}awaitSegmentBetween(e,t){if(be(e<=t),!this._isDynamic)return!1;let{timescale:r}=this._index,i=Ft(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,u=this._getLastSegmentStart();if(v(u)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let d=u+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>d-i:s>d-i&&o<f-i}shouldRefresh(){return!1}checkDiscontinuity(){return null}isSegmentStillAvailable(e){if(e.isInit)return!0;let t=this.getSegments(e.time,.1);return t.length===0?!1:t[0].time===e.time&&t[0].end===e.end&&t[0].number===e.number}canBeOutOfSyncError(){return!1}isStillAwaitingFutureSegments(){if(!this._isDynamic)return!1;let e=this._estimateRelativeScaledEnd();if(e===void 0)return!0;let{timescale:t}=this._index,r=this._getLastSegmentStart();if(v(r))return!0;let i=r+this._index.duration,a=Ft(t);return i+a<e}isInitialized(){return!0}initialize(){m.error(\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}_replace(e){this._index=e._index,this._isDynamic=e._isDynamic,this._periodStart=e._periodStart,this._scaledRelativePeriodEnd=e._scaledRelativePeriodEnd,this._manifestBoundsCalculator=e._manifestBoundsCalculator}_update(e){this._replace(e)}_getFirstSegmentStart(){var o;if(!this._isDynamic)return 0;if(this._scaledRelativePeriodEnd===0||this._scaledRelativePeriodEnd===void 0){let s=this._manifestBoundsCalculator.getEstimatedMaximumPosition((o=this._availabilityTimeOffset)!=null?o:0);if(s!==void 0&&s<this._periodStart)return null}let{duration:e,timescale:t}=this._index,r=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime(e/t);if(r===void 0)return;let i=r>this._periodStart?(r-this._periodStart)*t:0;return Math.floor(i/e)*e}_getLastSegmentStart(){var a,o;let{duration:e,timescale:t,endNumber:r,startNumber:i=1}=this._index;if(this._isDynamic){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&this._scaledRelativePeriodEnd!==void 0&&this._scaledRelativePeriodEnd<s-this._periodStart*this._index.timescale){let l=Math.ceil(this._scaledRelativePeriodEnd/e);return r!==void 0&&r-i+1<l&&(l=r-i+1),(l-1)*e}let u=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(u===void 0)return;let d=(u-this._periodStart)*t;if(d<0)return null;let f=Math.floor(d/e);return r!==void 0&&r-i+1<f&&(f=r-i+1),f<=0?null:(f-1)*e}else{let s=(o=this._scaledRelativePeriodEnd)!=null?o:0,u=Math.ceil(s/e);r!==void 0&&r-i+1<u&&(u=r-i+1);let d=(u-1)*e,f=L.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-d>f||u<2?d:(u-2)*e}}_estimateRelativeScaledEnd(){var e,t;if(this._index.endNumber!==void 0){let r=this._index.endNumber-((e=this._index.startNumber)!=null?e:1)+1;return Math.max(Math.min(r*this._index.duration,(t=this._scaledRelativePeriodEnd)!=null?t:1/0),0)}if(this._scaledRelativePeriodEnd!==void 0)return Math.max(this._scaledRelativePeriodEnd,0)}};function Ti(n,e){let t=0;for(;n.length>0;){let r=n[0];if(r.start>=e||r.repeatCount===-1)return t;if(r.repeatCount===0)n.shift(),t+=1;else{let i=n[1];if(i!==void 0&&i.start<=e)n.shift(),t+=1;else{if(r.duration<=0)return t;let a=r.start+r.duration,o=1;for(;a<e&&o<=r.repeatCount;)a+=r.duration,o++;if(o>r.repeatCount)n.shift(),t=r.repeatCount+1;else{let s=r.repeatCount-o;return r.start=a,r.repeatCount=s,t+=o,t}}}}return t}function _i(n,e){if(n.length===0)return n.push(...e),!0;if(e.length===0)return!1;let t=n.length,r=e[0].start,i=n[t-1];if(Be(i,e[0])<r)throw new $(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: not enough data\");for(let f=t-1;f>=0;f--){let l=n[f].start;if(l===r){let c=t-f;return n.splice(f,c,...e),!1}else if(l<r){let c=n[f];if(c.start+c.duration>r)return m.warn(\"RepresentationIndex: Manifest update removed all previous segments\"),n.splice(0,t,...e),!0;if(c.repeatCount===void 0||c.repeatCount<=0)return c.repeatCount<0&&(c.repeatCount=Math.floor((r-c.start)/c.duration)-1),n.splice(f+1,t-(f+1),...e),!1;if(c.start+c.duration*(c.repeatCount+1)<=r)return n.splice(f+1,t-(f+1),...e),!1;let p=(r-c.start)/c.duration-1;if(p%1===0&&c.duration===e[0].duration){let h=e[0].repeatCount<0?-1:e[0].repeatCount+p+1;return n.splice(f,t-f,...e),n[f].start=c.start,n[f].repeatCount=h,!1}return m.warn(\"RepresentationIndex: Manifest update removed previous segments\"),n[f].repeatCount=Math.floor(p),n.splice(f+1,t-(f+1),...e),!1}}let o=n[n.length-1],s=e[e.length-1];if(o.repeatCount!==void 0&&o.repeatCount<0)return o.start>s.start?(m.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(m.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let u=o.start+o.duration*(o.repeatCount+1),d=s.start+s.duration*(s.repeatCount+1);return u>=d?(m.warn(\"RepresentationIndex: The new index is older than the previous one\"),!1):(m.warn('RepresentationIndex: The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function cn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:v(e.duration)||(r=e.start+e.duration*(e.repeatCount+1))),(i===void 0||isNaN(i))&&t!==null&&t.start!==void 0&&!isNaN(t.start)&&r!==void 0&&!isNaN(r)&&(i=t.start-r),r!==void 0&&!isNaN(r)&&i!==void 0&&!isNaN(i)&&(a===void 0||!isNaN(a))?{start:r,duration:i,repeatCount:a===void 0?0:a}:(m.warn('DASH: A \"S\" Element could not have been parsed.'),null)}function mn(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"t\":let i=parseInt(r,10);isNaN(i)?m.warn(`DASH: invalid t (\"${r}\")`):e.start=i;break;case\"d\":let a=parseInt(r,10);isNaN(a)?m.warn(`DASH: invalid d (\"${r}\")`):e.duration=a;break;case\"r\":let o=parseInt(r,10);isNaN(o)?m.warn(`DASH: invalid r (\"${r}\")`):e.repeatCount=o;break}}return e}function pn(n){let e={};for(let t=0;t<n.attributes.length;t++){let r=n.attributes[t];switch(r.name){case\"t\":let i=parseInt(r.value,10);isNaN(i)?m.warn(`DASH: invalid t (\"${r.value}\")`):e.start=i;break;case\"d\":let a=parseInt(r.value,10);isNaN(a)?m.warn(`DASH: invalid d (\"${r.value}\")`):e.duration=a;break;case\"r\":let o=parseInt(r.value,10);isNaN(o)?m.warn(`DASH: invalid r (\"${r.value}\")`):e.repeatCount=o;break}}return e}function pt(n){let e=[];if(Array.isArray(n))for(let r=0;r<n.length;r++)e.push(mn(n[r]));else for(let r=0;r<n.length;r++)e.push(pn(n[r]));let t=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[t.length-1]===void 0?null:t[t.length-1],o=e[r+1]===void 0?null:e[r+1],s=cn(i,a,o);s!==null&&t.push(s)}return t}function Ei(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=Array.isArray(e)?e[0].attributes.t:e[0].getAttribute(\"t\"),i=v(r)?null:parseInt(r,10);if(i===null||Number.isNaN(i))return null;if(t===i)return{prevSegmentsIdx:0,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(t<i){let a=n[0],o=0;for(;;){if(a.repeatCount>0){let s=i-a.start;if(s%a.duration===0&&s/a.duration<=a.repeatCount)return{repeatNumberInPrevSegments:s/a.duration,prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInNewElements:0}}if(o++,o>=n.length)return null;if(a=n[o],a.start===i)return{prevSegmentsIdx:o,newElementsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(a.start>i)return null}}else{let a=0,o=Array.isArray(e)?e[0]:null,s=Array.isArray(e)?null:e[0],u=i;for(;;){let d=o!==null?o.attributes.d:s==null?void 0:s.getAttribute(\"d\"),f=v(d)?null:parseInt(d,10);if(f===null||Number.isNaN(f))return null;let l=o!==null?o.attributes.r:s==null?void 0:s.getAttribute(\"r\"),c=v(l)?null:parseInt(l,10);if(c!==null){if(Number.isNaN(c)||c<0)return null;if(c>0){let h=t-u;if(h%f===0&&h/f<=c)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/f,prevSegmentsIdx:0,newElementsIdx:a}}u+=f*(c+1)}else u+=f;if(a++,a>=e.length)return null;Array.isArray(e)?o=e[a]:s=e[a];let g=o!==null?o.attributes.t:s==null?void 0:s.getAttribute(\"t\"),p=v(g)?null:parseInt(g,10);if(p!==null){if(Number.isNaN(p))return null;u=p}if(u===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(u>i)return null}}}function Ri(n,e){var h;let t=Ei(e,n);if(t===null)return m.warn('DASH: Cannot perform \"based\" update. Common segment not found.'),pt(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,u=e.length-r+i-1;if(u>=n.length)return m.info('DASH: Cannot perform \"based\" update. New timeline too short'),pt(n);let d=e.slice(r);if(a>0){let I=d[0];I.start+=I.duration*a,d[0].repeatCount-=a}if(o>0&&i!==0)return m.info('DASH: Cannot perform \"based\" update. The new timeline has a different form.'),pt(n);let f=d[d.length-1],l=Array.isArray(n)?mn(n[u]):pn(n[u]),c=((h=l.repeatCount)!=null?h:0)-o;if(l.duration!==f.duration||f.repeatCount>c)return m.info('DASH: Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),pt(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let g=[],p=[];if(Array.isArray(n))for(let I=u+1;I<n.length;I++)p.push(mn(n[I]));else for(let I=u+1;I<n.length;I++)p.push(pn(n[I]));for(let I=0;I<p.length;I++){let y=p[I],T=g[g.length-1]===void 0?f:g[g.length-1],P=p[I+1]===void 0?null:p[I+1],E=cn(y,T,P);E!==null&&g.push(E)}return d.concat(g)}var gn=class n{constructor(e,t){var E,C,_,x,A;if(!n.isTimelineIndexArgument(e))throw new Error(\"The given index is not compatible with a TimelineRepresentationIndex.\");let{availabilityTimeComplete:r,availabilityTimeOffset:i,manifestBoundsCalculator:a,isDynamic:o,isLastPeriod:s,representationId:u,representationBitrate:d,periodStart:f,periodEnd:l,isEMSGWhitelisted:c}=t,g=(E=e.timescale)!=null?E:1,p=(C=e.presentationTimeOffset)!=null?C:0,h=f*g,I=p-h;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=c,this._isLastPeriod=s,this._lastUpdate=(_=t.receivedTime)!=null?_:U(),this._unsafelyBaseOnPreviousIndex=null,t.unsafelyBaseOnPreviousRepresentation!==null&&t.unsafelyBaseOnPreviousRepresentation.index instanceof n&&(t.unsafelyBaseOnPreviousRepresentation.index._unsafelyBaseOnPreviousIndex=null,this._unsafelyBaseOnPreviousIndex=t.unsafelyBaseOnPreviousRepresentation.index),this._isDynamic=o,this._parseTimeline=(x=e.timelineParser)!=null?x:null;let y=((A=e.initialization)==null?void 0:A.media)===void 0?null:Ne(e.initialization.media,u,d),T=e.media===void 0?null:Ne(e.media,u,d),P;i===void 0&&r===void 0?P=1/0:P=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:P,indexRange:e.indexRange,indexTimeOffset:I,initialization:v(e.initialization)?void 0:{url:y,range:e.initialization.range},segmentUrlTemplate:T,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:Pi(e.timeline,e.startNumber,e.endNumber),timescale:g},this._scaledPeriodStart=Re(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:Re(l,this._index)}getInitSegment(){return et(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),fn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=this._index.timeline;return e.length===0?null:Qe(Math.max(this._scaledPeriodStart,e[0].start),this._index)}getLastAvailablePosition(){var r;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let e=br(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(e===null)return null;let t=Math.min(e.end,(r=this._scaledPeriodEnd)!=null?r:1/0);return Qe(t,this._index)}getEnd(){var r;if(this._isDynamic&&!this._isLastPeriod)return;if(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),this._index.timeline.length<=0)return null;let e=this._index.timeline[this._index.timeline.length-1],t=Math.min(Be(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return Qe(t,this._index)}awaitSegmentBetween(e,t){var d,f;if(be(e<=t),!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timescale:r,timeline:i}=this._index,a=Ft(r),o=Re(t,this._index),s=br(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(d=this._scaledPeriodEnd)!=null?d:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let u=Re(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],g=Be(l,null,this._scaledPeriodEnd)+a;if(u<g+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:u-a<this._scaledPeriodEnd&&o+a>this._scaledPeriodStart:!1}isSegmentStillAvailable(e){return e.isInit?!0:(this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),id(e,this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd))}checkDiscontinuity(e){this._refreshTimeline();let t=this._index.timeline;return t===null&&(t=this._getTimeline(),this._index.timeline=t),Oo({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof je&&e.isHttpError(404):!1}_replace(e){this._parseTimeline=e._parseTimeline,this._index=e._index,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._manifestBoundsCalculator=e._manifestBoundsCalculator,this._isLastPeriod=e._isLastPeriod}_update(e){this._index.timeline===null&&(this._index.timeline=this._getTimeline()),e._index.timeline===null&&(e._index.timeline=e._getTimeline()),_i(this._index.timeline,e._index.timeline)&&(this._index.startNumber=e._index.startNumber),this._index.availabilityTimeOffset=e._index.availabilityTimeOffset,this._index.availabilityTimeComplete=e._index.availabilityTimeComplete,this._index.endNumber=e._index.endNumber,this._isDynamic=e._isDynamic,this._scaledPeriodStart=e._scaledPeriodStart,this._scaledPeriodEnd=e._scaledPeriodEnd,this._lastUpdate=e._lastUpdate,this._isLastPeriod=e._isLastPeriod}isStillAwaitingFutureSegments(){var o;if(!this._isDynamic)return!1;this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline());let{timeline:e}=this._index;if(e.length===0){if(this._scaledPeriodEnd!==void 0){let s=this._manifestBoundsCalculator.getEstimatedLiveEdge();if(s!==void 0&&Re(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Ft(this._index.timescale),r=br(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(r!==null&&!r.isLastOfTimeline){let s=Math.min(r.end,(o=this._scaledPeriodEnd)!=null?o:1/0);return!(this._scaledPeriodEnd!==void 0&&s+t>=this._scaledPeriodEnd)}if(!this._isLastPeriod)return!1;if(this._scaledPeriodEnd===void 0)return!0;let i=e[e.length-1];return Be(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){m.error(\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){m.warn(\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}static isTimelineIndexArgument(e){return typeof e.timelineParser==\"function\"||Array.isArray(e.timeline)}_refreshTimeline(){var i,a;if(this._index.timeline===null&&(this._index.timeline=this._getTimeline()),!this._isDynamic)return;let e=this._manifestBoundsCalculator.getEstimatedMinimumSegmentTime(((a=(i=this._index.timeline[0])==null?void 0:i.duration)!=null?a:0)/this._index.timescale);if(v(e))return;let t=Re(e,this._index),r=Ti(this._index.timeline,t);this._index.startNumber!==void 0?this._index.startNumber+=r:this._index.endNumber!==void 0&&(this._index.startNumber=r+1)}_getTimeline(){if(this._parseTimeline===null)return this._index.timeline!==null?this._index.timeline:(m.error(\"DASH: Timeline already lazily parsed.\"),[]);let e=this._parseTimeline();this._parseTimeline=null;let{MIN_DASH_S_ELEMENTS_TO_PARSE_UNSAFELY:t}=L.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return Pi(pt(e),this._index.startNumber,this._index.endNumber);let r;return this._unsafelyBaseOnPreviousIndex._index.timeline===null?(r=this._unsafelyBaseOnPreviousIndex._getTimeline(),this._unsafelyBaseOnPreviousIndex._index.timeline=r):r=this._unsafelyBaseOnPreviousIndex._index.timeline,this._unsafelyBaseOnPreviousIndex=null,Pi(Ri(e,r),this._index.startNumber,this._index.endNumber)}};function Pi(n,e,t){if(t===void 0)return n;let r=e!=null?e:1;for(let i=0;i<n.length;i++){let a=n[i];if(r+=a.repeatCount+1,r>t){if(r===t+1)return n.slice(0,i+1);{let o=n.slice(0,i),s=Z({},a),u=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-u),o.push(s),o}}}return n}function id(n,e,t,r){let i=br(e,t,r);if(i===null)return!1;for(let a=0;a<e.timeline.length;a++){if(i.timelineIdx<a)return!1;let o=e.timeline[a],s=(o.start-e.indexTimeOffset)/e.timescale;if(s>n.time)return!1;if(s===n.time)return o.range===void 0?n.range===void 0:!v(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let d=(s-o.start)/o.duration-1;return d%1===0&&d<=i.newRepeatCount}}return!1}function br(n,e,t){if(n.timeline.length<=0)return null;if(n.availabilityTimeOffset===1/0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Be(a,null,t)}}let r=e.getEstimatedMaximumPosition(n.availabilityTimeOffset);if(r===void 0){let i=n.timeline.length-1,a=n.timeline[i];return{isLastOfTimeline:!0,timelineIdx:i,newRepeatCount:a.repeatCount,end:Be(a,null,t)}}for(let i=n.timeline.length-1;i>=n.timeline.length;i--){let a=n.timeline[i],o=a.start+a.duration;if(Qe(o,n)<=r){let s=Be(a,n.timeline[i+1],t);if(Qe(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let d=Re(r,n)-a.start,f=Math.floor(d/a.duration);return be(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var Sr=gn;var ad=/^(?:[a-z]+:)?\\/\\//i,od=/^(?:([^:\\/?#]+):)?(?:\\/\\/([^\\/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Ai(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(ad.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Ai(n.substring(0,t)):e+1}function sd(n,e){let t=wo(n),r=wo(e);if(r.scheme)return vi(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return r.authority?(i.authority=r.authority,i.path=Ci(r.path),vi(i)):(r.path===\"\"?(i.path=t.path,r.query||(i.query=t.query)):ze(r.path,\"/\")?i.path=Ci(r.path):i.path=Ci(dd(t,r.path)),vi(i))}var hn=new Map,ud=200;function wo(n){var r,i,a,o,s;if(hn.has(n))return hn.get(n);let e=n.match(od),t;return e===null?t={scheme:\"\",authority:\"\",path:\"\",query:\"\",fragment:\"\"}:t={scheme:(r=e[1])!=null?r:\"\",authority:(i=e[2])!=null?i:\"\",path:(a=e[3])!=null?a:\"\",query:(o=e[4])!=null?o:\"\",fragment:(s=e[5])!=null?s:\"\"},hn.size>=ud&&hn.clear(),hn.set(n,t),t}function vi(n){let e=\"\";return n.scheme&&(e+=n.scheme+\":\"),n.authority&&(e+=\"//\"+n.authority),e+=n.path,n.query&&(e+=\"?\"+n.query),n.fragment&&(e+=\"#\"+n.fragment),e}function Ci(n){let e=n.split(/(?=\\/)/),t=[];for(let r=0;r<e.length;r++){let i=e[r];if(!(i===\"..\"||i===\".\"||i===\"\")){if(i===\"/..\"){t.pop(),r===e.length-1&&t.push(\"/\");continue}if(i===\"/.\"){r===e.length-1&&t.push(\"/\");continue}t.push(i)}}return t.join(\"\")}function dd(n,e){if(n.authority&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function Do(...n){var r,i,a;let e=n.filter(o=>o!==\"\"),t=e.length;if(t===0)return\"\";if(t===1)return(r=e[0])!=null?r:\"\";{let o=(i=e[0])!=null?i:\"\",s=(a=e[1])!=null?a:\"\",u=sd(o,s),d=e.slice(2);return Do(u,...d)}}var yr=Do;var In=class{constructor(){this._refs=new Map,this._stored=[]}addReferences(e){for(let t of e)t.attributes.refId!==void 0&&this._refs.set(t.attributes.refId,t)}add(e,t){this._tryParsing(e,t,!1)||this._stored.push([e,t]),t.attributes.refId!==void 0&&(this._refs.set(t.attributes.refId,t),this._resolveStoredRefs(!1))}finalize(){this._resolveStoredRefs(!0)}_resolveStoredRefs(e){for(let t=this._stored.length-1;t>=0;t--){let[r,i]=this._stored[t];(this._tryParsing(r,i,e)||e)&&this._stored.splice(t,1)}return this._stored.length===0}_tryParsing(e,t,r){if(t.attributes.ref===void 0)return ki(e,t),!0;let i=this._getReferenced(t.attributes.ref);return i===void 0?(r&&(m.warn(\"DASH: forcing the parsing of a referencing ContentProtection\"),ki(e,t)),!1):(t.children.cencPssh.push(...i.children.cencPssh),t.attributes.keyId===void 0&&i.attributes.keyId!==void 0&&(t.attributes.keyId=i.attributes.keyId),t.attributes.schemeIdUri===void 0&&i.attributes.schemeIdUri!==void 0&&(t.attributes.schemeIdUri=i.attributes.schemeIdUri),t.attributes.value===void 0&&i.attributes.value!==void 0&&(t.attributes.value=i.attributes.value),ki(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function ki(n,e){let t;if(e.attributes.schemeIdUri!==void 0&&e.attributes.schemeIdUri.substring(0,9)===\"urn:uuid:\"&&(t=e.attributes.schemeIdUri.substring(9).replace(/-/g,\"\").toLowerCase()),e.attributes.keyId!==void 0&&e.attributes.keyId.length>0){let o={keyId:e.attributes.keyId,systemId:t};n.contentProtections===void 0?n.contentProtections={keyIds:[o],initData:[]}:n.contentProtections.keyIds===void 0?n.contentProtections.keyIds=[o]:n.contentProtections.keyIds.push(o)}if(t===void 0)return;let{cencPssh:r}=e.children,i=[];for(let o of r)i.push({systemId:t,data:o});if(i.length===0)return;if(n.contentProtections===void 0){n.contentProtections={keyIds:[],initData:[{type:\"cenc\",values:i}]};return}let a=Y(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function Tr(n){let e=Date.parse(n)-U();if(isNaN(e)){m.warn(\"DASH Parser: Invalid clock received: \",n);return}return e}function xi(n){let e=n.children.utcTimings.filter(t=>(t.schemeIdUri===\"urn:mpeg:dash:utc:http-iso:2014\"||t.schemeIdUri===\"urn:mpeg:dash:utc:http-xsdate:2014\")&&t.value!==void 0);return e.length>0?e[0].value:void 0}function _r(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function Mi(n){for(let e=n.length-1;e>=0;e--){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=_r(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=_r(i);if(s===void 0)return{safe:void 0,unsafe:void 0};o=s}if(r!==void 0&&a===null||i!==void 0&&o===null)return m.info(\"Parser utils: found Period with no segment. \",\"Going to previous one to calculate last position\"),{safe:void 0,unsafe:void 0};if(o!==null)return a!==null?{safe:Math.min(a,o),unsafe:Math.max(a,o)}:{safe:o,unsafe:o};if(a!==null)return{safe:a,unsafe:a}}}return{safe:void 0,unsafe:void 0}}function Er(n){let{representations:e}=n,t=null;for(let r=0;r<e.length;r++){let i=e[r].index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function Oi(n){for(let e=0;e<=n.length-1;e++){let t=n[e].adaptations,r=t.audio===void 0?void 0:t.audio[0],i=t.video===void 0?void 0:t.video[0];if(r!==void 0||i!==void 0){let a=null,o=null;if(r!==void 0){let s=Er(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Er(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){m.info(\"Parser utils: found Period with no segment. \",\"Going to next one to calculate first position\");return}if(o!==null)return a!==null?Math.max(a,o):o;if(a!==null)return a}}}function wi(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Oi(n),t=Mi(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var bn=class{constructor(e){this._isDynamic=e.isDynamic,this._timeShiftBufferDepth=!e.isDynamic||e.timeShiftBufferDepth===void 0?null:e.timeShiftBufferDepth,this._serverTimestampOffset=e.serverTimestampOffset,this._availabilityStartTime=e.availabilityStartTime}setLastPosition(e,t){this._lastPosition=e,this._positionTime=t}lastPositionIsKnown(){return this._isDynamic?this._positionTime!==void 0&&this._lastPosition!==void 0:this._lastPosition!==void 0}getEstimatedMinimumSegmentTime(e){var i;if(!this._isDynamic||this._timeShiftBufferDepth===null)return 0;let t=(i=this.getEstimatedLiveEdge())!=null?i:this.getEstimatedMaximumPosition(0);return t===void 0?void 0:t-(this._timeShiftBufferDepth+e)}getEstimatedLiveEdge(){if(!(!this._isDynamic||this._serverTimestampOffset===void 0))return(U()+this._serverTimestampOffset)/1e3-this._availabilityStartTime}getEstimatedMaximumPosition(e){if(!this._isDynamic)return this._lastPosition;let t=this.getEstimatedLiveEdge();return t!==void 0&&e!==1/0?t+e:this._positionTime!==void 0&&this._lastPosition!==void 0?Math.max(this._lastPosition-this._positionTime+U()/1e3,0):this._lastPosition}};function Di(n,e){return n.type!==\"dynamic\"?0:v(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Bi(n){if(n.length===0)return[];let e=[n[0]];for(let t=1;t<n.length;t++){let r=n[t],i=e[e.length-1];for(;(i.duration===void 0||i.start+i.duration>r.start)&&(m.warn(\"DASH: Updating overlapping Periods.\",i==null?void 0:i.start,r.start),i.duration=r.start-i.start,i.end=r.start,!(i.duration>0));){if(e.pop(),e.length===0)break;i=e[e.length-1]}e.push(r)}return e}function Ni(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!v(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||v(e.availabilityStartTime)?0:e.availabilityStartTime;else{let d=t[t.length-1];if(!v(d)&&!v(d.periodEnd))a=d.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];v(r.attributes.duration)?i===n.length-1?o=e.duration:v(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let u=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:u})}),t}function ld(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Ut){let s=n[o];if(s!==void 0)for(let u of s)u.id===a&&(u.trickModeTracks===void 0&&(u.trickModeTracks=[]),u.trickModeTracks.push(r))}}}var Bo=ld;var fd=[\"subtitle\",\"caption\"];function Ui(n,e,t,r){function i(o,s){let u=o.split(\"/\")[0];if(fe(Ut,u))return u;if(o===\"application/ttml+xml\")return\"text\";if(o===\"application/mp4\")return s!==null&&Y(s,d=>d.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&fe(fd,d.value))!==void 0?\"text\":void 0}function a(o){switch(o.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(o.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(e!==null){let o=i(e,r);if(o!==void 0)return o}if(t!==null){let o=a(t);if(o!==void 0)return o}for(let o=0;o<n.length;o++){let s=n[o],{mimeType:u,codecs:d}=s.attributes;if(u!==void 0){let f=i(u,r);if(f!==void 0)return f}if(d!==void 0){let f=a(d);if(f!==void 0)return f}}}var cd=/[, ]+/g;function No(n){return J(n)?n.trim().replace(cd,\", \"):\"\"}function Uo(n){let[e,t,r,i,a,o,s,u]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let d,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(d=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&u!==void 0&&o===\"09\"&&u===\"09\"&&(l=\"rec2020\"),!(d===void 0||f===void 0))return{colorDepth:d,eotf:f,colorSpace:l}}function Li(n,e){var p,h,I;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:u,inbandEventStreams:d,isLastPeriod:f}=e,c={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:u,isEMSGWhitelisted:y=>d===void 0?!1:d.some(({schemeIdUri:T})=>T===y.schemeIdUri),isLastPeriod:f,manifestBoundsCalculator:r,isDynamic:i,periodEnd:a,periodStart:o,receivedTime:s,representationBitrate:n.attributes.bitrate,representationId:n.attributes.id},g;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;g=new Rt(y,c)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;g=new Pt(y,c)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let y=e.parentSegmentTemplates.slice(),T=n.children.segmentTemplate;T!==void 0&&y.push(T);let P=H({},...y);(P.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(c.availabilityTimeOffset=((p=P.availabilityTimeOffset)!=null?p:0)+((h=e.availabilityTimeOffset)!=null?h:0)),(P.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(c.availabilityTimeComplete=(I=P.availabilityTimeComplete)!=null?I:e.availabilityTimeComplete),g=Sr.isTimelineIndexArgument(P)?new Sr(P,c):new vt(P,c)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:T}=y;g=new Rt(T,c)}else if(y.segmentList!==void 0){let{segmentList:T}=y;g=new Pt(T,c)}else g=new vt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},c)}return g}function tt(n,e){var i;if(e.length===0)return n;let t=e.map(a=>({url:a.value}));if(n.length===0)return t;let r=[];for(let a=0;a<n.length;a++){let o=n[a];for(let s=0;s<t.length;s++){let u=t[s],d=yr(o.url,u.url);r.push({url:d,serviceLocation:(i=u.serviceLocation)!=null?i:o.serviceLocation})}}return r}function md(n,e){let t=[];if(n.children.inbandEventStreams!==void 0&&t.push(...n.children.inbandEventStreams),e.children.inbandEventStreams!==void 0&&t.push(...e.children.inbandEventStreams),t.length!==0)return t}function pd({adaptationProfiles:n,essentialProperties:e,supplementalProperties:t,manifestProfiles:r,codecs:i}){if(((n!=null?n:\"\")+(r!=null?r:\"\")).indexOf(\"http://dashif.org/guidelines/dash-if-uhd#hevc-hdr-pq10\")!==-1&&(i===\"hvc1.2.4.L153.B0\"||i===\"hev1.2.4.L153.B0\"))return{colorDepth:10,eotf:\"pq\",colorSpace:\"rec2020\"};let o=Y([...e!=null?e:[],...t!=null?t:[]],s=>s.schemeIdUri===\"urn:mpeg:mpegB:cicp:TransferCharacteristics\");if(o!==void 0)switch(o.value){case\"15\":return;case\"16\":return{eotf:\"pq\"};case\"18\":return{eotf:\"hlg\"}}if(i!==void 0&&/^vp(08|09|10)/.exec(i))return Uo(i)}function Fi(n,e,t){var i,a,o,s,u,d,f;let r=[];for(let l of n){let c=l.attributes.id!==void 0?l.attributes.id:String(l.attributes.bitrate)+(l.attributes.height!==void 0?`-${l.attributes.height}`:\"\")+(l.attributes.width!==void 0?`-${l.attributes.width}`:\"\")+(l.attributes.mimeType!==void 0?`-${l.attributes.mimeType}`:\"\")+(l.attributes.codecs!==void 0?`-${l.attributes.codecs}`:\"\");for(;r.some(R=>R.id===c);)c+=\"-dup\";let g=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(c))!=null?a:null,p=md(l,e),h=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,I;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(I=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((u=t.availabilityTimeOffset)!=null?u:0));let y=H({},t,{availabilityTimeOffset:I,availabilityTimeComplete:h,unsafelyBaseOnPreviousRepresentation:g,adaptation:e,inbandEventStreams:p}),T=Li(l,y),P;l.attributes.bitrate===void 0?(m.warn(\"DASH: No usable bitrate found in the Representation.\"),P=0):P=l.attributes.bitrate;let E=tt(t.baseURLs,l.children.baseURLs),C=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(R=>({baseUrl:R.url,id:R.serviceLocation})),_={bitrate:P,cdnMetadata:C,index:T,id:c};l.children.supplementalProperties!==void 0&&Y(l.children.supplementalProperties,R=>R.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&R.value===\"JOC\")&&(_.isSpatialAudio=!0);let x;l.attributes.codecs!==void 0?x=l.attributes.codecs:e.attributes.codecs!==void 0&&(x=e.attributes.codecs),x!==void 0&&(x=x===\"mp4a.40.02\"?\"mp4a.40.2\":x,_.codecs=x);let A;l.attributes.supplementalCodecs!==void 0?A=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(A=e.attributes.supplementalCodecs),A!==void 0&&(_.supplementalCodecs=No(A)),l.attributes.frameRate!==void 0?_.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(_.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?_.height=l.attributes.height:e.attributes.height!==void 0&&(_.height=e.attributes.height),l.attributes.mimeType!==void 0?_.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(_.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?_.width=l.attributes.width:e.attributes.width!==void 0&&(_.width=e.attributes.width);{let R=[...(d=e.children.contentProtections)!=null?d:[],...(f=l.children.contentProtections)!=null?f:[]];for(let k of R)t.contentProtectionParser.add(_,k)}_.hdrInfo=pd({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:x}),r.push(_)}return r}function gd(n){if(n===void 0)return!1;let e=n.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&n.value===\"1\",t=n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"description\";return e||t}function hd(n,e){return!!(n!==void 0&&n.some(r=>r.schemeIdUri===\"urn:tva:metadata:cs:AudioPurposeCS:2007\"&&r.value===\"2\")||e!==void 0&&e.some(r=>r.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&r.value===\"caption\"))}function Id(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function bd(n,e){if(J(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,u=s;return J(n.attributes.language)&&(u+=`-${n.attributes.language}`),t===!0&&(u+=\"-cc\"),r===!0&&(u+=\"-cc\"),i===!0&&(u+=\"-ad\"),a===!0&&(u+=\"-si\"),o&&(u+=\"-trickMode\"),J(n.attributes.contentType)&&(u+=`-${n.attributes.contentType}`),J(n.attributes.codecs)&&(u+=`-${n.attributes.codecs}`),J(n.attributes.mimeType)&&(u+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(u+=`-${String(n.attributes.frameRate)}`),u}function Sd(n){if(!v(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!v(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>r)}return[]}function zi(n,e){var s,u,d,f,l,c,g;let t={video:[],audio:[],text:[]},r=[],i={},a=[];for(let p=0;p<n.length;p++){let h=n[p],I=h.children,{essentialProperties:y,roles:T,label:P}=I,E=Array.isArray(T)&&T.some(ye=>ye.value===\"main\")&&T.some(ye=>ye.schemeIdUri===\"urn:mpeg:dash:role:2011\"),C=h.children.representations,_=(s=h.attributes.availabilityTimeComplete)!=null?s:e.availabilityTimeComplete,x;(h.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(x=((u=h.attributes.availabilityTimeOffset)!=null?u:0)+((d=e.availabilityTimeOffset)!=null?d:0));let A=h.attributes.mimeType,R=h.attributes.codecs,k=Ui(C,J(A)?A:null,J(R)?R:null,v(I.roles)?null:I.roles);if(k===void 0)continue;let M=(f=h.attributes.selectionPriority)!=null?f:1,D=h.attributes.id,w=Sd(h),O=[];e.segmentTemplate!==void 0&&O.push(e.segmentTemplate),h.children.segmentTemplate!==void 0&&O.push(h.children.segmentTemplate);let N={availabilityTimeComplete:_,availabilityTimeOffset:x,baseURLs:tt(e.baseURLs,I.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:O,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},V=Array.isArray(y)?Y(y,ye=>ye.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,q=(l=V==null?void 0:V.value)==null?void 0:l.split(\" \"),ee=q!==void 0,{accessibilities:K}=I,G;T!==void 0&&T.some(ye=>ye.value===\"dub\")&&(G=!0);let W;k!==\"text\"?W=!1:W=hd(K,T);let Q;k===\"text\"&&T!==void 0&&T.some(ye=>ye.value===\"forced-subtitle\"||ye.value===\"forced_subtitle\")&&(Q=!0);let ue;k!==\"audio\"?ue=!1:K!==void 0&&(ue=K.some(gd));let Se;k!==\"video\"?Se=!1:K!==void 0&&(Se=K.some(Id));let ce=bd(h,{isAudioDescription:ue,isForcedSubtitle:Q,isClosedCaption:W,isSignInterpreted:Se,isTrickModeTrack:ee,type:k});for(;fe(a,ce);)ce+=\"-dup\";let He=ce;a.push(ce),N.unsafelyBaseOnPreviousAdaptation=(g=(c=e.unsafelyBaseOnPreviousPeriod)==null?void 0:c.getAdaptation(ce))!=null?g:null;let we=Fi(C,h,N),ge={id:ce,representations:we,type:k,isTrickModeTrack:ee};if(v(h.attributes.language)||(ge.language=h.attributes.language),v(W)||(ge.closedCaption=W),v(ue)||(ge.audioDescription=ue),G===!0&&(ge.isDub=!0),Q!==void 0&&(ge.forcedSubtitles=Q),Se===!0&&(ge.isSignInterpreted=!0),P!==void 0&&(ge.label=P),q!==void 0)r.push({adaptation:ge,trickModeAttachedAdaptationIds:q});else{let ye=-1;for(let Qt of w){let Ge=i[Qt];if(Ge!==void 0&&Ge.newID!==He&&fe(Ge.adaptationSetSwitchingIDs,D)){ye=re(t[k],Ot=>Ot[0].id===Qt);let ke=t[k][ye];if(ke!==void 0&&ke[0].audioDescription===ge.audioDescription&&ke[0].closedCaption===ge.closedCaption&&ke[0].language===ge.language){m.info('DASH Parser: merging \"switchable\" AdaptationSets',D,Qt),ke[0].representations.push(...ge.representations),ke[1]={priority:Math.max(M,ke[1].priority),isMainAdaptation:E||ke[1].isMainAdaptation,indexInMpd:Math.min(p,ke[1].indexInMpd)};break}}}ye<0&&t[k].push([ge,{priority:M,isMainAdaptation:E,indexInMpd:p}])}!v(D)&&v(i[D])&&(i[D]={newID:He,adaptationSetSwitchingIDs:w})}let o=Ut.reduce((p,h)=>{let I=t[h];return I.length>0&&(I.sort(Lo),p[h]=I.map(([y])=>y)),p},{});return t.video.sort(Lo),Bo(o,r),o}function Lo(n,e){let t=e[1].priority-n[1].priority;return t!==0?t:n[1].isMainAdaptation!==e[1].isMainAdaptation?n[1].isMainAdaptation?-1:1:n[1].indexInMpd-e[1].indexInMpd}var yd=Ce();function Wi(n,e){var o,s,u,d,f;let t=[],r=Ni(n,e);if(r.length!==n.length)throw new Error(\"MPD parsing error: the time information are incoherent.\");let{isDynamic:i,manifestBoundsCalculator:a}=e;!i&&!v(e.duration)&&a.setLastPosition(e.duration);for(let l=n.length-1;l>=0;l--){let c=l===n.length-1,g=n[l],p=e.xlinkInfos.get(g),h=tt(e.baseURLs,g.children.baseURLs),{periodStart:I,periodDuration:y,periodEnd:T}=r[l],P;for(v(g.attributes.id)?(m.warn(\"DASH: No usable id found in the Period. Generating one.\"),P=\"gen-dash-period-\"+yd()):P=g.attributes.id;t.some(V=>V.id===P);)P+=\"-dup\";let E=p!==void 0?p.receivedTime:e.receivedTime,C=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(P))!=null?s:null,_=g.attributes.availabilityTimeComplete,x=g.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:R}=e,{segmentTemplate:k}=g.children;R.addReferences((u=g.children.contentProtections)!=null?u:[]);let M={availabilityTimeComplete:_,availabilityTimeOffset:x,baseURLs:h,contentProtectionParser:R,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:c,manifestProfiles:A,receivedTime:E,segmentTemplate:k,start:I,unsafelyBaseOnPreviousPeriod:C},D=zi(g.children.adaptations,M),w=((d=e.xmlNamespaces)!=null?d:[]).concat((f=g.attributes.namespaces)!=null?f:[]),O=_d(g.children.eventStreams,I,w),N={id:P,start:I,end:T,duration:y,adaptations:D,streamEvents:O};if(t.unshift(N),!a.lastPositionIsKnown()){let V=Td(D);if(!i)typeof V==\"number\"&&a.setLastPosition(V);else if(typeof V==\"number\"){let q=U()/1e3;a.setLastPosition(V,q)}else{let q=Fo(e,I);if(q!==void 0){let[ee,K]=q;a.setLastPosition(ee,K)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=Fo(e,0);if(l!==void 0){let[c,g]=l;a.setLastPosition(c,g)}}return Bi(t)}function Fo(n,e){if(v(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){m.warn(\"DASH Parser: no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=U()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=U()/1e3,i=r+t;if(i>=e)return[i,r]}}function Td(n){let e=null,t=!0,r=gr(n).filter(a=>!v(a)),i=pi(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let u=s.index.getLastAvailablePosition();u!==null&&(t=!1,typeof u==\"number\"&&(e=v(e)?u:Math.max(e,u)))}}if(v(e)){if(t)return null}else return e}function _d(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:u=1}=o.attributes,d=t.concat((i=o.attributes.namespaces)!=null?i:[]);for(let f of o.children.events)if(f.eventStreamData!==void 0){let l=((a=f.presentationTime)!=null?a:0)/u+e,c=f.duration===void 0?void 0:l+f.duration/u,g,p;if(!wt&&f.eventStreamData instanceof Element)g=f.eventStreamData;else try{p={namespaces:d,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:De(new Uint8Array(f.eventStreamData))}}catch(h){m.error(\"DASH: Error while parsing event-stream:\",h instanceof Error?h.message:\"Unknown error\")}r.push({start:l,end:c,id:f.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:u,element:g,xmlData:p}}})}}return r}function zt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let u=o.type===\"dynamic\",d=Y(a.utcTimings,c=>c.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(c.value)),f=!v(d)&&!v(d.value)?Tr(d.value):void 0,l=!v(f)&&!isNaN(f)?f:void 0;if(!v(l)&&r!==!0)e.externalClockOffset=l;else if(u&&r!==!0){let c=xi(n);if(!v(c)&&c.length>0)return{type:\"needs-clock\",value:{url:c,continue:function(p){return p.success?(e.externalClockOffset=Tr(p.data),zt(n,e,t,!0)):(t.push(p.error),m.warn(\"DASH Parser: Error on fetching the clock ressource\",p.error),zt(n,e,t,!0))}}}}}let s=[];for(let u=0;u<a.periods.length;u++){let{xlinkHref:d,xlinkActuate:f}=a.periods[u].attributes;!v(d)&&f===\"onLoad\"&&s.push({index:u,ressource:d})}return s.length===0?Ed(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:u})=>u),continue:function(d){if(d.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=d.length-1;f>=0;f--){let l=s[f].index,{parsed:c,warnings:g,receivedTime:p,sendingTime:h,url:I}=d[f];g.length>0&&t.push(...g);for(let y of c)i.set(y,{receivedTime:p,sendingTime:h,url:I});a.periods.splice(l,1,...c)}return zt(n,e,t,r,i)}}}}function Ed(n,e,t,r){var O,N,V,q,ee;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Ai(e.url))}]:[],u=tt(s,i.baseURLs),d=Di(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:c,unsafelyBaseOnPreviousManifest:g}=e,{externalClockOffset:p}=e,h=new bn({availabilityStartTime:d,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:p}),I=new In;I.addReferences((O=i.contentProtections)!=null?O:[]);let y={availabilityStartTime:d,baseURLs:u,clockOffset:c,contentProtectionParser:I,duration:a.duration,isDynamic:o,manifestBoundsCalculator:h,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:g,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},T=Wi(i.periods,y);I.finalize();let P=a.duration,E,C,_=null,x;a.minimumUpdatePeriod!==void 0&&a.minimumUpdatePeriod>=0&&(E=a.minimumUpdatePeriod===0?L.getCurrent().DASH_FALLBACK_LIFETIME_WHEN_MINIMUM_UPDATE_PERIOD_EQUAL_0:a.minimumUpdatePeriod);let{minimumSafePosition:A,maximumSafePosition:R,maximumUnsafePosition:k}=wi(T),M=U();if(o){let K;R!==void 0?K=R:p===void 0?(m.warn(\"DASH Parser: use system clock to define maximum position\"),K=Date.now()/1e3-d):K=(U()+p)/1e3-d;let G=h.getEstimatedLiveEdge();G===void 0&&(k!==void 0?G=k:G=K),x={isLinear:!0,maximumSafePosition:K,livePosition:G,time:M},C=A,_=f!=null?f:null,_!==null&&(_+=l!=null?l:0),_!==null&&C!==void 0&&G-C>_&&(_=G-C)}else{C=A,C===void 0&&(C=(V=(N=T[0])==null?void 0:N.start)!=null?V:0);let K=P!=null?P:1/0;if(T[T.length-1]!==void 0){let G=T[T.length-1],W=(q=G.end)!=null?q:G.duration!==void 0?G.start+G.duration:void 0;W!==void 0&&W<K&&(K=W)}R!==void 0&&R<K&&(K=R),x={isLinear:!1,maximumSafePosition:K,livePosition:void 0,time:M}}let D=!o||n.attributes.minimumUpdatePeriod===void 0&&(((ee=T[T.length-1])==null?void 0:ee.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:d,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:D,periods:T,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:C,timeshiftDepth:_,maximumTimeData:x},lifetime:E,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var Rr=zt;var Rd=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Pd=/([0-9]+)-([0-9]+)/;function Pe(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new Me(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ne(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new Me(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function Ae(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new Me(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function Vi(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new Me(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function Pr(n,e){let t=Date.parse(n);return isNaN(t)?[null,new Me(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function We(n,e){if(!J(n))return[0,new Me(`\\`${e}\\` property is empty`)];let t=Rd.exec(n);return t===null?[null,new Me(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(J(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(J(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(J(t[6])?t[6]:\"0\")*24*60*60+parseFloat(J(t[8])?t[8]:\"0\")*60*60+parseFloat(J(t[10])?t[10]:\"0\")*60+parseFloat(J(t[12])?t[12]:\"0\"),null]}function Ct(n,e){let t=Pd.exec(n);return t===null?[null,new Me(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function zo(n,e){try{return[cr(n),null]}catch(t){return[null,new Me(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Wt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:Ae(n,e)}function Ee(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!v(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function pe(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(m.warn(s.message),e.push(s)),o!==null&&(n[r]=o)}}var Me=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function gt(n){return hr(n)}function nt(n){let e=typeof n==\"string\"?n:gt(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function vd(n){let e=[],t=[];for(let r=0;r<n.length;r++){let i=n[r];if(typeof i!=\"string\"&&i.tagName===\"cenc:pssh\"){let a=gt(i.children);if(a!==null&&a.length>0){let[o,s]=zo(a,\"cenc:pssh\");s!==null&&(m.warn(s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function Cd(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=an(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function rt(n){let[e,t]=vd(n.children),r=Cd(n);return[{children:e,attributes:r},t]}function qi(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!v(r))switch(t){case\"id\":e.id=r;break;case\"lang\":e.language=r;break;case\"contentType\":e.contentType=r;break;case\"par\":e.par=r;break}}return e}function Hi(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Ct,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function it(n){let e={},t=[],r=pe(e,t),i=n.children;for(let a=0;a<i.length;a++){let o=i[a];if(typeof o!=\"string\"&&o.tagName===\"Initialization\"){let[s,u]=Hi(o);e.initialization=s,t=t.concat(u)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!v(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ne,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:Ae,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Ct,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:Pe,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:Ae,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:Pe,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ne,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ne,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ne,dashName:\"endNumber\"});break}}return[e,t]}function Gi(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Ct,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Ct,dashName:\"mediaRange\"});break}}return[e,t]}function Sn(n){let[e,t]=it(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let u=a[s];if(typeof u!=\"string\"&&u.tagName===\"SegmentURL\"){let[d,f]=Gi(u);i.push(d),r=r.concat(f)}}return[H(e,{list:i}),r]}function Ki(n){let e=n.children;return function(){for(let t=e.length-1;t>=0;t--){let r=e[t];(typeof r==\"string\"||r.tagName!==\"S\")&&e.splice(t,1)}return e}}function At(n){let[e,t]=it(n),r=t,i;for(let s=0;s<n.children.length;s++){let u=n.children[s];typeof u!=\"string\"&&u.tagName===\"SegmentTimeline\"&&(i=Ki(u))}let a=H({},e,{duration:e.duration,timelineParser:i}),o=pe(a,r);for(let s of Object.keys(n.attributes)){let u=n.attributes[s];if(!v(u))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:u});break;case\"index\":a.index=u;break;case\"availabilityTimeOffset\":o(u,{asKey:\"availabilityTimeOffset\",parser:Ae,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(u,{asKey:\"availabilityTimeComplete\",parser:Pe,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=u;break;case\"bitstreamSwitching\":o(u,{asKey:\"bitstreamSwitching\",parser:Pe,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Ad(n){let e={baseURLs:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"BaseURL\":let[o,s]=nt(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Ee(a));break;case\"SegmentBase\":let[u,d]=it(a);e.segmentBase=u,d.length>0&&(r=r.concat(d));break;case\"SegmentList\":let[f,l]=Sn(a);r=r.concat(l),e.segmentList=f;break;case\"SegmentTemplate\":let[c,g]=At(a);r=r.concat(g),e.segmentTemplate=c;break;case\"ContentProtection\":let[p,h]=rt(a);h.length>0&&(r=r.concat(h)),p!==void 0&&t.push(p);break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Ee(a)]:e.supplementalProperties.push(Ee(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function kd(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ne,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Pe,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Wt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ne,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:Ae,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:Ae,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ne,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ne,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:Ae,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Pe,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new Me(\"No bitrate found on a Representation\")),[e,t]}function Wo(n){let[e,t]=Ad(n.children),[r,i]=kd(n),a=t.concat(i);return[{children:e,attributes:r},a]}function xd(n){let e={baseURLs:[],representations:[]},t=[],r=[];for(let i=0;i<n.length;i++){let a=n[i];if(typeof a!=\"string\")switch(a.tagName){case\"Accessibility\":e.accessibilities===void 0?e.accessibilities=[Ee(a)]:e.accessibilities.push(Ee(a));break;case\"BaseURL\":let[o,s]=nt(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break;case\"ContentComponent\":e.contentComponent=qi(a);break;case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[Ee(a)]:e.essentialProperties.push(Ee(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Ee(a));break;case\"Label\":let u=gt(a.children);u!=null&&(e.label=u);break;case\"Representation\":let[d,f]=Wo(a);e.representations.push(d),f.length>0&&(r=r.concat(f));break;case\"Role\":v(e.roles)?e.roles=[Ee(a)]:e.roles.push(Ee(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Ee(a)]:e.supplementalProperties.push(Ee(a));break;case\"SegmentBase\":let[l,c]=it(a);e.segmentBase=l,c.length>0&&(r=r.concat(c));break;case\"SegmentList\":let[g,p]=Sn(a);e.segmentList=g,p.length>0&&(r=r.concat(p));break;case\"SegmentTemplate\":let[h,I]=At(a);e.segmentTemplate=h,I.length>0&&(r=r.concat(I));break;case\"ContentProtection\":let[y,T]=rt(a);T.length>0&&(r=r.concat(T)),y!==void 0&&t.push(y);break}}return t.length>0&&(e.contentProtections=t),[e,r]}function Md(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ne,dashName:\"group\"});break;case\"lang\":e.language=a;break;case\"contentType\":e.contentType=a;break;case\"par\":e.par=a;break;case\"minBandwidth\":r(a,{asKey:\"minBitrate\",parser:ne,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ne,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ne,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ne,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ne,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ne,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Wt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Wt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ne,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:Vi,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:Vi,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Pe,dashName:\"bitstreamSwitching\"});break;case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"codecs\":e.codecs=a;break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Pe,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Wt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ne,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:Ae,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:Ae,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ne,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:Ae,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Pe,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function Vo(n){let e=n.children,[t,r]=xd(e),[i,a]=Md(n),o=r.concat(a);return[{children:t,attributes:i},o]}function Od(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ne,dashName:\"timescale\"});break;default:ze(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function qo(n,e){let[t,r]=Od(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(v(a.attributes.id)||(o.id=a.attributes.id),!v(a.attributes.presentationTime)){let[s,u]=ne(a.attributes.presentationTime,\"presentationTime\");u!==null&&r.push(u),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,u]=ne(a.attributes.duration,\"duration\");u!==null&&r.push(u),s!==null&&(o.duration=s)}if(a.posStart<a.posEnd){let s=e.substring(a.posStart,a.posEnd);o.eventStreamData=s}i.push(o)}return[{children:{events:i},attributes:t},r]}function wd(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let u=0;u<n.length;u++){let d=n[u];if(typeof d!=\"string\")switch(d.tagName){case\"BaseURL\":let[f,l]=nt(d);f!==void 0&&t.push(f),o=o.concat(l);break;case\"AdaptationSet\":let[c,g]=Vo(d);r.push(c),o=o.concat(g);break;case\"EventStream\":let[p,h]=qo(d,e);s.push(p),o=o.concat(h);break;case\"SegmentTemplate\":let[I,y]=At(d);i=I,y.length>0&&(o=o.concat(y));break;case\"ContentProtection\":let[T,P]=rt(d);P.length>0&&(o=o.concat(P)),T!==void 0&&a.push(T);break}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function Dd(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:We,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:We,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Pe,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:ze(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function vr(n,e){let[t,r]=wd(n.children,e),[i,a]=Dd(n),o=r.concat(a);return[{children:t,attributes:i},o]}function Bd(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let u=0;u<n.length;u++){let d=n[u];if(typeof d!=\"string\")switch(d.tagName){case\"BaseURL\":let[f,l]=nt(d);f!==void 0&&t.push(f),s=s.concat(l);break;case\"Location\":r.push(gt(d.children));break;case\"Period\":let[c,g]=vr(d,e);i.push(c),s=s.concat(g);break;case\"UTCTiming\":let p=Ee(d);a.push(p);break;case\"ContentProtection\":let[h,I]=rt(d);I.length>0&&(s=s.concat(I)),h!==void 0&&o.push(h);break}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function Nd(n){let e={},t=[],r=pe(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!v(a))switch(i){case\"id\":e.id=a;break;case\"profiles\":e.profiles=a;break;case\"type\":e.type=a;break;case\"availabilityStartTime\":r(a,{asKey:\"availabilityStartTime\",parser:Pr,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:Pr,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:Pr,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:We,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:We,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:We,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:We,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:We,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:We,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:We,dashName:\"maxSubsegmentDuration\"});break;default:ze(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Ho(n,e){let[t,r]=Bd(n.children,e),[i,a]=Nd(n),o=r.concat(a);return[{children:t,attributes:i},o]}function ji(n,e){let t=bi(n),r=t[t.length-1];if(r===void 0||typeof r==\"string\"||r.tagName!==\"MPD\")throw new Error(\"DASH Parser: document root should be MPD\");let[i,a]=Ho(r,n),o=Rr(i,e,a);return s(o);function s(u){if(u.type===\"done\")return u;if(u.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[u.value.url],format:\"string\",continue(d){if(d.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=u.value.continue(d[0].responseData);return s(f)}}};if(u.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:u.value.xlinksUrls,format:\"string\",continue(d){let f=[];for(let c=0;c<d.length;c++){let{responseData:g,receivedTime:p,sendingTime:h,url:I}=d[c];if(!g.success)throw g.error;let y=\"<root>\"+g.data+\"</root>\",T=bi(y),P=T[T.length-1];if(P===void 0||typeof P==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=P.children,C=[],_=[];for(let x=0;x<E.length;x++){let A=E[x];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[R,k]=vr(A,y);_.push(...k),C.push(R)}f.push({url:I,receivedTime:p,sendingTime:h,parsed:C,warnings:_})}let l=u.value.continue(f);return s(l)}}};Fe(u)}}var Go=ji;var Ud=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",Ko=Ud;function F(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Yi(n){return n===1/0?!0:n===-1/0?!1:n}function ht(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=F(t,e.buffer,a,o))}}function It(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,u){switch(o){case 16:t.schemeIdUri=F(i,e.buffer,s,u);break;case 13:t.value=F(i,e.buffer,s,u);break;case 14:let d=F(i,e.buffer,s,u);t.keyId=an(d.replace(/-/g,\"\"));break;case 15:try{let f=F(i,e.buffer,s,u);r.cencPssh.push(cr(f))}catch(f){}break;case 78:t.ref=F(i,e.buffer,s,u);break;case 79:t.refId=F(i,e.buffer,s,u);break}}}function jo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break}}}function Ve(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break}}}function Vt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 29:{let s=new DataView(e.buffer);n.initialization===void 0&&(n.initialization={}),n.initialization.range=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 67:n.initialization===void 0&&(n.initialization={}),n.initialization.media=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Yo(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=F(t,e.buffer,a,o);break;case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 30:n.media=F(t,e.buffer,a,o);break;case 18:{let s=new DataView(e.buffer);n.mediaRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}}}}function Cr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=Yo(a,e);t.pushParsers(i,B,o);break}default:t.pushParsers(i,B,B);break}}}function qt(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let u=a;for(let d=0;d<o/24;d++)n.timeline.push({start:s.getFloat64(u,!0),duration:s.getFloat64(u+8,!0),repeatCount:s.getFloat64(u+16,!0)}),u+=24;break}case 67:n.initialization={media:F(t,e.buffer,a,o)};break;case 28:n.index=F(t,e.buffer,a,o);break;case 43:{let s=new DataView(e.buffer);n.availabilityTimeOffset=s.getFloat64(a,!0);break}case 22:{n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break}case 24:{let s=new DataView(e.buffer);n.presentationTimeOffset=s.getFloat64(a,!0);break}case 27:{let s=new DataView(e.buffer);n.timescale=s.getFloat64(a,!0);break}case 31:{let s=new DataView(e.buffer);n.indexRange=[s.getFloat64(a,!0),s.getFloat64(a+8,!0)];break}case 23:{n.indexRangeExact=new DataView(e.buffer).getUint8(0)===0;break}case 30:n.media=F(t,e.buffer,a,o);break;case 32:{n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break}case 1:{let s=new DataView(e.buffer);n.duration=s.getFloat64(a,!0);break}case 20:{let s=new DataView(e.buffer);n.startNumber=s.getFloat64(a,!0);break}case 76:{let s=new DataView(e.buffer);n.endNumber=s.getFloat64(a,!0);break}}}}function Qo(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,B,ht(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=It(a,e);t.pushParsers(i,B,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,B,Ve(a,e));break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,B,o);break}case 17:{let a={};n.segmentBase=a;let o=Vt(a,e);t.pushParsers(i,B,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Cr(a,e,t),s=Vt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,B,qt(a,e));break}default:t.pushParsers(i,B,B);break}}}function $o(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 5:n.codingDependency=new DataView(e.buffer).getUint8(0)===0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break}}}function Xo(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=Ve(a,e);t.pushParsers(i,B,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=ht(a,e);t.pushParsers(i,B,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,B,jo(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=It(a,e);t.pushParsers(i,B,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=B,s=Ve(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=B,s=Ve(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=Qo(a.children,e,t),s=$o(a.attributes,e);t.pushParsers(i,o,s);break}case 12:{let a={};n.roles===void 0&&(n.roles=[]),n.roles.push(a);let o=Ve(a,e);t.pushParsers(i,B,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=Ve(a,e);t.pushParsers(i,B,o);break}case 17:{let a={};n.segmentBase=a;let o=Vt(a,e);t.pushParsers(i,B,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Cr(a,e,t),s=Vt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,B,qt(a,e));break}default:t.pushParsers(i,B,B);break}}}function Zo(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=F(t,e.buffer,a,o);break;case 61:n.contentType=F(t,e.buffer,a,o);break;case 62:n.par=F(t,e.buffer,a,o);break;case 53:n.minBitrate=s.getFloat64(a,!0);break;case 49:n.maxBitrate=s.getFloat64(a,!0);break;case 56:n.minWidth=s.getFloat64(a,!0);break;case 52:n.maxWidth=s.getFloat64(a,!0);break;case 55:n.minHeight=s.getFloat64(a,!0);break;case 51:n.maxHeight=s.getFloat64(a,!0);break;case 54:n.minFrameRate=s.getFloat64(a,!0);break;case 50:n.maxFrameRate=s.getFloat64(a,!0);break;case 57:n.selectionPriority=s.getFloat64(a,!0);break;case 58:n.segmentAlignment=Yi(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Yi(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=F(t,e.buffer,a,o);break;case 4:n.codecs=F(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=F(t,e.buffer,a,o);break;case 2:n.profiles=F(t,e.buffer,a,o);break;case 12:n.segmentProfiles=F(t,e.buffer,a,o);break;case 11:n.mimeType=F(t,e.buffer,a,o);break;case 5:n.codingDependency=s.getFloat64(a,!0)!==0;break;case 6:n.frameRate=s.getFloat64(a,!0);break;case 7:n.height=s.getFloat64(a,!0);break;case 8:n.width=s.getFloat64(a,!0);break;case 9:n.maxPlayoutRate=s.getFloat64(a,!0);break;case 10:n.maximumSAPPeriod=s.getFloat64(a,!0);break;case 43:n.availabilityTimeOffset=s.getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=s.getUint8(0)===0;break;case 71:let u=F(t,e.buffer,a,o);n.label=u;break}}}function Jo(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=Ld(o,e,r);t.pushParsers(a,B,s);break}default:t.pushParsers(a,B,B);break}}}function es(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=F(t,e.buffer,a,o);break;case 17:n.value=F(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:let u={key:\"\",value:\"\"},d=a,f=s.getUint32(d);d+=4,u.key=F(t,e.buffer,d,f),d+=f;let l=s.getUint32(d);d+=4,u.value=F(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[u]:n.namespaces.push(u);break}}}function Ld(n,e,t){let r=new TextDecoder;return function(a,o,s){let u=new DataView(e.buffer);switch(a){case 25:n.presentationTime=u.getFloat64(o,!0);break;case 1:n.duration=u.getFloat64(o,!0);break;case 0:n.id=F(r,e.buffer,o,s);break;case 69:let d=u.getFloat64(o,!0),f=u.getFloat64(o+8,!0);n.eventStreamData=t.slice(d,f);break}}}function Ar(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=Xo(o.children,e,t),u=Zo(o.attributes,e);t.pushParsers(a,s,u);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=B,u=ht(o,e);t.pushParsers(a,s,u);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=Jo(o.children,e,t,r),u=es(o.attributes,e);t.pushParsers(a,s,u);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,B,qt(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=It(o,e);t.pushParsers(a,B,s);break}default:t.pushParsers(a,B,B);break}}}function kr(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=F(t,e.buffer,a,o);break;case 45:n.start=new DataView(e.buffer).getFloat64(a,!0);break;case 1:n.duration=new DataView(e.buffer).getFloat64(a,!0);break;case 32:n.bitstreamSwitching=new DataView(e.buffer).getUint8(0)===0;break;case 46:n.xlinkHref=F(t,e.buffer,a,o);break;case 47:n.xlinkActuate=F(t,e.buffer,a,o);break;case 43:n.availabilityTimeOffset=new DataView(e.buffer).getFloat64(a,!0);break;case 22:n.availabilityTimeComplete=new DataView(e.buffer).getUint8(0)===0;break;case 70:let s={key:\"\",value:\"\"},u=new DataView(e.buffer),d=a,f=u.getUint32(d);d+=4,s.key=F(t,e.buffer,d,f),d+=f;let l=u.getUint32(d);d+=4,s.value=F(t,e.buffer,d,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}function ts(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=B,u=ht(o,e);t.pushParsers(a,s,u);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Ar(o.children,e,t,r),u=kr(o.attributes,e);t.pushParsers(a,s,u);break}case 3:{let o={};n.utcTimings.push(o);let s=B,u=Ve(o,e);t.pushParsers(a,s,u);break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=It(o,e);t.pushParsers(a,B,s);break}default:t.pushParsers(a,B,B);break}}}function ns(n,e,t){let r,i=new TextDecoder;return function(o,s,u){switch(o){case 0:e.id=F(i,t.buffer,s,u);break;case 2:e.profiles=F(i,t.buffer,s,u);break;case 33:e.type=F(i,t.buffer,s,u);break;case 34:let d=F(i,t.buffer,s,u);e.availabilityStartTime=new Date(d).getTime()/1e3;break;case 35:let f=F(i,t.buffer,s,u);e.availabilityEndTime=new Date(f).getTime()/1e3;break;case 36:let l=F(i,t.buffer,s,u);e.publishTime=new Date(l).getTime()/1e3;break;case 68:r=new DataView(t.buffer),e.duration=r.getFloat64(s,!0);break;case 37:r=new DataView(t.buffer),e.minimumUpdatePeriod=r.getFloat64(s,!0);break;case 38:r=new DataView(t.buffer),e.minBufferTime=r.getFloat64(s,!0);break;case 39:r=new DataView(t.buffer),e.timeShiftBufferDepth=r.getFloat64(s,!0);break;case 40:r=new DataView(t.buffer),e.suggestedPresentationDelay=r.getFloat64(s,!0);break;case 41:r=new DataView(t.buffer),e.maxSegmentDuration=r.getFloat64(s,!0);break;case 42:r=new DataView(t.buffer),e.maxSubsegmentDuration=r.getFloat64(s,!0);break;case 66:let c=F(i,t.buffer,s,u);n.locations.push(c);break;case 70:let g={key:\"\",value:\"\"};r=new DataView(t.buffer);let p=s,h=r.getUint32(p);p+=4,g.key=F(i,t.buffer,p,h),p+=h;let I=r.getUint32(p);p+=4,g.value=F(i,t.buffer,p,I),e.namespaces===void 0?e.namespaces=[g]:e.namespaces.push(g);break}}}function Qi(n,e,t,r){return function(a){switch(a){case 1:n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=ts(n.mpd.children,e,t,r),s=ns(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break;default:t.pushParsers(a,B,B);break}}}function rs(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Ar(o.children,e,t,r),u=kr(o.attributes,e);t.pushParsers(a,s,u);break}default:t.pushParsers(a,B,B);break}}}var yn=class{constructor(){this._currentNodeId=null,this.childrenParser=B,this.attributeParser=B,this._stack=[{nodeId:null,children:B,attribute:B}]}pushParsers(e,t,r){this._currentNodeId=e,this.childrenParser=t,this.attributeParser=r,this._stack.push({nodeId:e,attribute:r,children:t})}popIfCurrent(e){if(this._currentNodeId!==e)return;this._stack.pop();let{nodeId:t,children:r,attribute:i}=this._stack[this._stack.length-1];this._currentNodeId=t,this.attributeParser=i,this.childrenParser=r}reset(){this.childrenParser=B,this.attributeParser=B,this._stack=[{nodeId:null,children:B,attribute:B}]}};var Fd=15e3,Tn=class{constructor(){this._parsersStack=new yn,this._instance=null,this._mpdData=null,this._linearMemory=null,this.status=\"uninitialized\",this._initProm=null,this._warnings=[],this._isParsing=!1}waitForInitialization(){var e;return(e=this._initProm)!=null?e:Promise.reject(\"No initialization performed yet.\")}async initialize(e){if(this.status!==\"uninitialized\")return Promise.reject(new Error(\"DashWasmParser already initialized.\"));if(!this.isCompatible())return this.status=\"failure\",Promise.reject(new Error(\"Target not compatible with WebAssembly.\"));this.status=\"initializing\";let t=this._parsersStack,r=new TextDecoder,i=this,a={env:{memoryBase:0,tableBase:0,memory:new WebAssembly.Memory({initial:10}),table:new WebAssembly.Table({initial:1,element:\"anyfunc\"}),onTagOpen:d,onCustomEvent:c,onAttribute:l,readNext:g,onTagClose:f}},o=null,s;typeof e.wasmUrl==\"string\"?s=fetch(e.wasmUrl):(o=URL.createObjectURL(new Blob([e.wasmUrl],{type:\"application/wasm\"})),s=fetch(o));let u=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=u.catch(async p=>{o!==null&&(URL.revokeObjectURL(o),o=null),m.warn(\"Unable to call `instantiateStreaming` on WASM\",p instanceof Error?p:\"\");let h=await s;if(h.status<200||h.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(h.status));let I=await h.arrayBuffer();return WebAssembly.instantiate(I,a)}).then(p=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=p,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(p=>{let h=p instanceof Error?p.toString():\"Unknown error\";throw m.warn(\"DW: Could not create DASH-WASM parser:\",h),this.status=\"failure\",p}),this._initProm;function d(p){return t.childrenParser(p)}function f(p){return t.popIfCurrent(p)}function l(p,h,I){return t.attributeParser(p,h,I)}function c(p,h,I){let y=i._linearMemory,T=new Uint8Array(y.buffer,h,I);if(p===1){let P=r.decode(T);m.warn(\"WASM Error Event:\",P),i._warnings.push(new Error(P))}else if(p===0){let P=r.decode(T);m.warn(\"WASM Log Event:\",P)}}function g(p,h){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let I=i._linearMemory,{mpd:y,cursor:T}=i._mpdData,P=Math.min(h,Fd,y.byteLength-T);return new Uint8Array(I.buffer,p,P).set(new Uint8Array(y,T,P)),i._mpdData.cursor+=P,P}}runWasmParser(e,t){let[r,i]=this._parseMpd(e);if(r===null)throw new Error(\"DASH Parser: Unknown error while parsing the MPD\");let a=Rr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return Ko&&typeof se.TextDecoder==\"function\"}_parseMpd(e){var s;if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={},r=this._linearMemory,i=Qi(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,B),this._warnings=[];try{this._instance.instance.exports.parse()}catch(u){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,u}let a=(s=t.mpd)!=null?s:null,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_parseXlink(e){if(this._instance===null)throw new Error(\"DashWasmParser not initialized\");if(this._isParsing)throw new Error(\"Parsing operation already pending.\");this._isParsing=!0,this._mpdData={mpd:e,cursor:0};let t={periods:[]},r=this._linearMemory,i=rs(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,B),this._warnings=[];try{this._instance.instance.exports.parse()}catch(s){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,s}let{periods:a}=t,o=this._warnings;return this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,[a,o]}_processParserReturnValue(e){if(e.type===\"done\")return e;if(e.type===\"needs-clock\"){let t=r=>{if(r.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let i=e.value.continue(r[0].responseData);return this._processParserReturnValue(i)};return{type:\"needs-resources\",value:{urls:[e.value.url],format:\"string\",continue:t}}}else if(e.type===\"needs-xlinks\"){let t=r=>{let i=[];for(let o=0;o<r.length;o++){let{responseData:s,receivedTime:u,sendingTime:d,url:f}=r[o];if(!s.success)throw s.error;let[l,c]=this._parseXlink(s.data);i.push({url:f,receivedTime:u,sendingTime:d,parsed:l,warnings:c})}let a=e.value.continue(i);return this._processParserReturnValue(a)};return{type:\"needs-resources\",value:{urls:e.value.xlinksUrls,format:\"arraybuffer\",continue:t}}}else Fe(e)}};var is=Tn;var kt=class{constructor(e,t){this._last=e,this._wanted=t}serialize(){return[this._last,this._wanted]}getPolled(){return this._last}getWanted(){var e;return(e=this._wanted)!=null?e:this._last}forceWantedPosition(e){this._wanted=e}isAwaitingFuturePosition(){return this._wanted!==null}};function xr(n,e,t){let r=e(n.getReference(),t);return{getCurrentTime(){return n.getCurrentTime()},getReadyState(){return n.getReadyState()},getPlaybackRate(){return n.getPlaybackRate()},getIsPaused(){return n.getIsPaused()},getReference(){return r},listen(i,a){var o;t.isCancelled()||((o=a==null?void 0:a.clearSignal)==null?void 0:o.isCancelled())===!0||r.onUpdate(i,{clearSignal:a==null?void 0:a.clearSignal,emitCurrentValue:a==null?void 0:a.includeLastObservation})},deriveReadOnlyObserver(i){return xr(this,i,t)}}}var _n=class{constructor(e,t,r,i){this._src=e,this._contentId=t,this._messageSender=r,this._cancelSignal=i}getCurrentTime(){}getReadyState(){}getIsPaused(){}getReference(){return this._src}setPlaybackRate(e){this._messageSender({type:\"update-playback-rate\",contentId:this._contentId,value:e})}getPlaybackRate(){}listen(e,t){var r;this._cancelSignal.isCancelled()||((r=t==null?void 0:t.clearSignal)==null?void 0:r.isCancelled())===!0||this._src.onUpdate(e,{clearSignal:t==null?void 0:t.clearSignal,emitCurrentValue:t==null?void 0:t.includeLastObservation})}deriveReadOnlyObserver(e){return xr(this,e,this._cancelSignal)}};function at(n,e){if(e.length===0)return n;let t,r=\"\",i=n.indexOf(\"#\"),a=n;i>=0&&(r=n.substring(i),a=n.substring(0,i));let o=a.indexOf(\"?\");o===-1?t=\"?\":o+1===a.length?t=\"\":t=\"&\";let s=a+t;for(let u=0;u<e.length;u++){let d=e[u];d[1]===null?s+=d[0]:s+=`${d[0]}=${d[1]}`,u<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function $i(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-U(),u=!1,c={reject:h=>{var P,E;if(u||i.isCancelled())return;u=!0,i.deregister(p);let I=h,y=(P=I==null?void 0:I.message)!=null?P:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new Ke(y,(E=I==null?void 0:I.canRetry)!=null?E:!1,I==null?void 0:I.xhr);o(T)},resolve:h=>{if(u||i.isCancelled())return;u=!0,i.deregister(p);let I=h.receivingTime!==void 0?h.receivingTime-s:void 0,y=h.sendingTime!==void 0?h.sendingTime-s:void 0;a({responseData:h.data,size:h.size,requestDuration:h.duration,url:h.url,receivedTime:I,sendingTime:y})},fallback:()=>{u||i.isCancelled()||(u=!0,i.deregister(p),e(t,r,i).then(a,o))}},g=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},c);i.register(p);function p(h){u||(u=!0,typeof g==\"function\"&&g(),o(h))}})}function zd(n){return function(t,r,i){var s,u;if(t===void 0)throw new Error(\"Cannot perform HTTP(s) request. URL not known\");let a=((s=r.cmcdPayload)==null?void 0:s.type)===\"query\"?at(t,r.cmcdPayload.value):t,o=((u=r.cmcdPayload)==null?void 0:u.type)===\"headers\"?r.cmcdPayload.value:void 0;switch(n){case\"arraybuffer\":return me({url:a,headers:o,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return me({url:a,headers:o,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return me({url:a,headers:o,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:Fe(n)}}}function Xi({customManifestLoader:n},e,t){let r=zd(e),i=typeof n!=\"function\"?r:$i(n,r);return t!==null?t(i):i}function Zi(n,e){if(e){if(Ye(n,1718909296)<0)throw new he(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Ye(n,1836019574)<0)throw new he(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Ye(n,1836019558)<0)throw new he(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Ye(n,1835295092)<0)throw new he(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function qe(n,e){if(n===\"audio\"||n===\"video\")return e===\"video/mp4\"||e===\"audio/mp4\"?\"mp4\":e===\"video/webm\"||e===\"audio/webm\"?\"webm\":void 0;if(n===\"text\")return e===\"application/mp4\"?\"mp4\":void 0}function Mr(n){return(e,t,r,i,a)=>{return new Promise((s,u)=>{let d=new z,f=d.linkToSignal(i);d.signal.register(u),n(e,t,r,d.signal,ie(Z({},a),{onNewChunk(c){try{o(c),a.onNewChunk(c)}catch(g){l(),d.cancel(),u(g)}}})).then(c=>{if(l(),!d.isUsed()){if(c.resultType===\"segment-loaded\")try{o(c.resultData.responseData)}catch(g){u(g);return}s(c)}},c=>{l(),u(c)});function l(){d.signal.deregister(u),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||qe(t.type,t.mimeType)!==\"mp4\"||Zi(new Uint8Array(s),t.segment.isInit)}}}function as(n){return async(e,t,r)=>{let i=await n(e,t,r);return a(i.responseData),i;function a(o){if(typeof o==\"string\"){let s=o.length-1,u=[\"</\",\"MPD\",\">\"];for(let d=u.length-1;d>=0;d--){let f=u[d];for(;Wd(o[s]);)s--;for(let l=f.length-1;l>=0;l--){if(o[s]!==f[l])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(o instanceof ArrayBuffer){let s=o.byteLength-1,u=new DataView(o),d=[[60,47],[77,80,68],[62]];for(let f=d.length-1;f>=0;f--){let l=d[f];for(;Vd(u.getUint8(s));)s--;for(let c=l.length-1;c>=0;c--){if(u.getUint8(s)!==l[c])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!v(se.Document)&&o instanceof se.Document&&o.documentElement.nodeName!==\"MPD\")throw new he(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function Wd(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function Vd(n){return n===32||n===9||n===13||n===10}function Ji(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,u){var T;let{responseData:d}=i,f=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,c=t!=null?t:f,p={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:c},h=xe.dashParsers;if(h.wasm===null||h.wasm.status===\"uninitialized\"||h.wasm.status===\"failure\")return m.debug(\"DASH: WASM MPD Parser not initialized. Running JS one.\"),I();{let P=jd(d);if(!Yd(P))return m.info(\"DASH: MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),I();if(h.wasm.status===\"initialized\"){m.debug(\"DASH: Running WASM MPD Parser.\");let E=h.wasm.runWasmParser(P,p);return y(E)}else return m.debug(\"DASH: Awaiting WASM initialization before parsing the MPD.\"),h.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(h.wasm===null||h.wasm.status!==\"initialized\")return m.warn(\"DASH: WASM MPD parser initialization failed. Running JS parser instead\"),I();m.debug(\"DASH: Running WASM MPD Parser.\");let C=h.wasm.runWasmParser(P,p);return y(C)})}function I(){if(h.fastJs!==null){let P=Gd(d),E=h.fastJs(P,p);return y(E)}else if(h.native!==null){let P=Kd(d),E=h.native(P,p);return y(E)}else throw new Error(\"No MPD parser is imported\")}function y(P){if(P.type===\"done\"){if(P.value.warnings.length>0&&o(P.value.warnings),s.isCancelled())return Promise.reject(s.cancellationError);let _=[];return{manifest:new Lt(P.value.parsed,n,_),url:l,warnings:_}}let{value:E}=P,C=E.urls.map(_=>u(()=>{let x=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?me({url:_,responseType:\"text\",timeout:x,connectionTimeout:A,cancelSignal:s}):me({url:_,responseType:\"arraybuffer\",timeout:x,connectionTimeout:A,cancelSignal:s})}).then(x=>{if(E.format===\"string\"){if(typeof x.responseData!=\"string\")throw new Error(\"External DASH resources should have been a string\");return H(x,{responseData:{success:!0,data:x.responseData}})}else{if(!(x.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return H(x,{responseData:{success:!0,data:x.responseData}})}},x=>{let A=Ie(x,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return H({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:A}})}));return Promise.all(C).then(_=>E.format===\"string\"?(qd(_),y(E.continue(_))):(Hd(_),y(E.continue(_))))}}}function qd(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&typeof t.data==\"string\")&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function Hd(n){b.CURRENT_ENV!==b.PRODUCTION&&n.forEach(e=>{let{responseData:t}=e;if(!(t.success&&t.data instanceof ArrayBuffer)&&t.success)throw new Error(\"Invalid data given to the LoadedRessource\")})}function Gd(n){if(n instanceof ArrayBuffer)return De(new Uint8Array(n));if(typeof n==\"string\")return n;if(n instanceof Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Kd(n){if(n instanceof ArrayBuffer)return new DOMParser().parseFromString(De(new Uint8Array(n)),\"text/xml\");if(typeof n==\"string\")return new DOMParser().parseFromString(n,\"text/xml\");if(n instanceof Document)return n;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function jd(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return rn(n).buffer;if(n instanceof Document)return rn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Yd(n){let e=new DataView(n);return e.getUint16(0)===61371&&e.getUint8(2)===191?!0:!(e.getUint16(0)===65279||e.getUint16(0)===65534)}function $e([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function En(n,e){return n===null?null:e.url===null?n.baseUrl:yr(n.baseUrl,e.url)}function Rn(n,e,t,r,i){var d,f;let a=n;((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"&&(a=at(a,t.cmcdPayload.value));let o=((f=t.cmcdPayload)==null?void 0:f.type)===\"headers\"?t.cmcdPayload.value:void 0;if(e.range===void 0)return me({url:a,responseType:\"arraybuffer\",headers:o,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.indexRange===void 0)return me({url:a,headers:ie(Z({},o),{Range:$e(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));if(e.range[1]+1===e.indexRange[0])return me({url:a,headers:ie(Z({},o),{Range:$e([e.range[0],e.indexRange[1]])}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}).then(l=>({resultType:\"segment-loaded\",resultData:l}));let s=me({url:a,headers:ie(Z({},o),{Range:$e(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),u=me({url:a,headers:ie(Z({},o),{Range:$e(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,u]).then(([l,c])=>{let g=_t(new Uint8Array(l.responseData),new Uint8Array(c.responseData)),p=Math.min(l.sendingTime,c.sendingTime),h=Math.max(l.receivedTime,c.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:g,size:l.size+c.size,requestDuration:h-p,sendingTime:p,receivedTime:h}}})}async function Pn(n,e,t,r){let i=null;function a(s){let u=new Uint8Array(s.chunk),d=i!==null?_t(i,u):u,f=mr(d),l=f[0];i=f[1],!(l!==null&&(l.forEach(c=>{t.onNewChunk(c)}),r.isCancelled()))&&(t.onProgress({duration:s.duration,size:s.size,totalSize:s.totalSize}),r.isCancelled())}return{resultType:\"chunk-complete\",resultData:await or({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function os(n,e,t,r,i,a){var c,g;if(e.segment.isInit)return Rn(n,e.segment,r,a,i);let o=((c=r.cmcdPayload)==null?void 0:c.type)===\"query\"?at(n,r.cmcdPayload.value):n,s=((g=r.cmcdPayload)==null?void 0:g.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:u}=e,d;u.range!==void 0?d=ie(Z({},s),{Range:$e(u.range)}):s!==void 0&&(d=s);let f=qe(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(Jt())return Pn(o,{headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);Ze(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}return{resultType:\"segment-loaded\",resultData:await me({url:o,responseType:\"arraybuffer\",headers:d,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function ea({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:Mr(r);function r(i,a,o,s,u){let d=En(i,a.segment);return d===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?os(d,a,n,o,u,s):new Promise((f,l)=>{let c=!1,y={reject:_=>{var k,M;if(c||s.isCancelled())return;c=!0,s.deregister(C);let x=_,A=(k=x==null?void 0:x.message)!=null?k:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",R=new Ke(A,(M=x==null?void 0:x.canRetry)!=null?M:!1,x==null?void 0:x.xhr);l(R)},resolve:_=>{c||s.isCancelled()||(c=!0,s.deregister(C),f({resultType:\"segment-loaded\",resultData:{responseData:_.data,size:_.size,requestDuration:_.duration}}))},progress:_=>{c||s.isCancelled()||u.onProgress({duration:_.duration,size:_.size,totalSize:_.totalSize})},fallback:()=>{c||s.isCancelled()||(c=!0,s.deregister(C),os(d,a,n,o,u,s).then(f,l))}},T;a.segment.range!==void 0&&(T=[a.segment.range],a.segment.indexRange!==void 0&&T.push(a.segment.indexRange));let P={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:d,cmcdPayload:o.cmcdPayload},E=e(P,y);s.register(C);function C(_){c||(c=!0,typeof E==\"function\"&&E(),l(_))}})}}var na=408125543,ss=357149030,Qd=2807729,$d=17545,Xd=475249515,Zd=187,Jd=179,el=183,tl=241;function bt(n,e,t,[r,i]){let a=r;for(;a<i;){let o=rl(t,a);if(o===null)return null;let{value:s,length:u}=o,d=a+u,f=il(t,d);if(f===null)return null;let{length:l,value:c}=f,g=d+l,p=g+c;if(s===n)return[g,p];if(e.length>0){for(let h=0;h<e.length;h++)if(s===e[h]){let I=e.slice(h+1,e.length);return bt(n,I,t,[g,p])}}a=p}return null}function Or(n,e){let t=bt(Qd,[na,ss],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/ta(n,t[0],r)}function nl(n,e){let t=bt($d,[na,ss],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?al(n,t[0]):r===8?ol(n,t[0]):null}function ra(n,e){let t=bt(na,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=Or(n,r);if(a===null)return null;let o=nl(n,r);if(o===null)return null;let s=bt(Xd,[],n,[r,i]);if(s===null)return null;let u=[],d=s[0];for(;d<s[1];){let l=bt(Zd,[],n,[d,s[1]]);if(l===null)break;let c=bt(Jd,[],n,[l[0],l[1]]);if(c===null)return null;let g=ta(n,c[0],c[1]-c[0]),p=bt(tl,[el],n,[l[0],l[1]]);if(p===null)return null;let h=ta(n,p[0],p[1]-p[0])+r;u.push({time:g,rangeStart:h}),d=l[1]}let f=[];for(let l=0;l<u.length;l++){let c=u[l];l===u.length-1?f.push({time:c.time,timescale:a,duration:l===0?o:o-c.time,range:[c.rangeStart,1/0]}):f.push({time:c.time,timescale:a,duration:u[l+1].time-c.time,range:[c.rangeStart,u[l+1].rangeStart-1]})}return f}function us(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function rl(n,e){let t=us(n,e);if(t===void 0)return m.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return m.warn(\"webm: impossible length\"),null;let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function il(n,e){let t=us(n,e);if(t===void 0)return m.warn(\"webm: unrepresentable length\"),null;if(e+t>n.length)return m.warn(\"webm: impossible length\"),null;let r=(n[e]&(1<<8-t)-1)*Math.pow(2,(t-1)*8);for(let i=1;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return{length:t,value:r}}function al(n,e){return new DataView(n.buffer).getFloat32(e)}function ol(n,e){return new DataView(n.buffer).getFloat64(e)}function ta(n,e,t){let r=0;for(let i=0;i<t;i++)r=n[e+i]*Math.pow(2,(t-i-1)*8)+r;return r}function vn(n,e,t,r){let i=fi(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=ci(n);if(a<0&&(o!==void 0&&(o+=a),a=0),e||!t.complete)return o===void 0&&m.warn(\"DASH: Chunked segments should indicate a duration through their trun boxes\"),{time:a/r,duration:o!==void 0?o/r:void 0};let s,u=t.duration*r,d=Math.min(r*.9,u/4);return o!==void 0&&Math.abs(o-u)<=d&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function sl(n,e){if(n.length<=0)return!1;let t=n.length;for(let r=0;r<t;r++){let i=n[r],a=e,{messageData:o}=i,s=De(o),u=Date.parse(s);if(a===void 0||u===void 0||isNaN(u)||u>=a)return!0}return!1}function ia(n,e){if(n.length===0)return;let{manifestRefreshEventsFromEMSGs:t,EMSGs:r}=n.reduce((o,s)=>(s.schemeIdUri===\"urn:mpeg:dash:event:2012\"&&s.value===\"1\"?(o.manifestRefreshEventsFromEMSGs===void 0&&(o.manifestRefreshEventsFromEMSGs=[]),o.manifestRefreshEventsFromEMSGs.push(s)):(o.EMSGs===void 0&&(o.EMSGs=[]),o.EMSGs.push(s)),o),{manifestRefreshEventsFromEMSGs:void 0,EMSGs:void 0}),i=r==null?void 0:r.map(o=>({type:\"emsg\",value:o})),a=e===void 0||t===void 0?!1:sl(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function aa({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var P,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:u,isChunked:d}=t,f=[o,s];if(u===null)return a.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:0,protectionData:[],appendWindow:f};let l=u instanceof Uint8Array?u:new Uint8Array(u),c=qe(r.type,r.mimeType),g=c===\"mp4\"||c===void 0,p=[];if(g){let C=pr(l),_;a.isInit&&(_=(P=mo(l))!=null?P:void 0),(C.length>0||_!==void 0)&&p.push({initDataType:\"cenc\",keyId:_,initData:C})}if(!a.isInit){let C=g?vn(l,d,a,i):null,_=(E=a.timestampOffset)!=null?E:0;if(g){let x=co(l);if(x!==void 0){let A=x.filter(k=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(k)),R=ia(A,r.manifestPublishTime);if(R!==void 0){let{needsManifestRefresh:k,inbandEvents:M}=R;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:_,appendWindow:f,inbandEvents:M,protectionData:p,needsManifestRefresh:k}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:_,protectionData:p,appendWindow:f}}let{indexRange:h}=a,I;if(c===\"webm\")I=ra(l,0);else if(g&&(I=on(l,Array.isArray(h)?h[0]:0),n===!0&&I!==null&&I.length>0)){let C=I[I.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;g?y=sn(l):c===\"webm\"&&(y=Or(l,0));let T=v(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:p,initTimescale:T,segmentList:I!=null?I:void 0}}}function oa({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:Mr(t);async function t(r,i,a,o,s){var I,y;let{segment:u}=i,d=En(r,u);if(d===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(u.isInit)return Rn(d,u,a,o,s);let f=((I=a.cmcdPayload)==null?void 0:I.type)===\"query\"?at(d,a.cmcdPayload.value):d,l=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,c;u.range!==void 0?c=ie(Z({},l),{Range:$e(u.range)}):l!==void 0&&(c=l);let g=qe(i.type,i.mimeType),p=g===\"mp4\"||g===void 0;if(n&&p){if(Jt())return Pn(f,{headers:c,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);Ze(\"DASH: Your browser does not have the fetch API. You will have a higher chance of rebuffering when playing close to the live edge\")}let h;return p?h=await me({url:f,responseType:\"arraybuffer\",headers:c,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):h=await me({url:f,responseType:\"text\",headers:c,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:h}}}function ul(n){let e=di(n);return e===null?\"\":De(e)}function dl(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml.im1t\":return\"ttml\";case\"wvtt\":return\"vtt\"}throw new Error(`The codec used for the subtitles \"${n}\" is not managed yet.`)}function ll(n,e){switch(e){case\"application/ttml+xml\":return\"ttml\";case\"application/x-sami\":case\"application/smil\":return\"sami\";case\"text/vtt\":return\"vtt\"}if(n!==void 0&&n.toLowerCase()===\"srt\")return\"srt\";throw new Error(`could not find a text-track parser for the type ${e!=null?e:\"\"}`)}function ds({segment:n,language:e,codecs:t},r,i,a){if(n.isInit)return null;let o,s;i===null?a?(o=n.time,s=n.end):m.warn(\"Transport: Unavailable time data for current text track.\"):(o=i.time,i.duration!==void 0?s=o+i.duration:!a&&n.complete&&(s=o+n.duration));let u=dl(t);return{data:ul(r),type:u,language:e,start:o,end:s}}function ls(n,e,t){let{segment:r}=n;if(r.isInit)return null;let i,a;t?m.warn(\"Transport: Unavailable time data for current text track.\"):(i=r.time,r.complete&&(a=r.time+r.duration));let o=ll(n.codecs,n.mimeType);return{data:e,type:o,language:n.language,start:i,end:a}}function fl(n,e,t,r,i){var c;let{segment:a}=t,{isInit:o,indexRange:s}=a,u;if(typeof n==\"string\"?u=rn(n):n instanceof Uint8Array?u=n:u=new Uint8Array(n),o){let g=on(u,Array.isArray(s)?s[0]:0);if(i===!0&&g!==null&&g.length>0){let h=g[g.length-1];Array.isArray(h.range)&&(h.range[1]=1/0)}let p=sn(u);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:p,segmentList:g!=null?g:void 0}}let d=vn(u,e,a,r),f=ds(t,u,d,e),l=(c=a.timestampOffset)!=null?c:0;return{segmentType:\"media\",chunkData:f,chunkSize:u.length,chunkInfos:d,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function cl(n,e,t){let{periodStart:r,periodEnd:i,segment:a}=t,{timestampOffset:o=0}=a;if(a.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let s,u;if(typeof n!=\"string\"){let f=n instanceof Uint8Array?n:new Uint8Array(n);s=De(f),u=f.length}else s=n;return{segmentType:\"media\",chunkData:ls(t,s,e),chunkSize:u,chunkInfos:null,chunkOffset:o,protectionData:[],appendWindow:[r,i]}}function sa({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:u,isChunked:d}=t;if(u===null)return s.isInit?{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0}:{segmentType:\"media\",chunkData:null,chunkSize:0,chunkInfos:null,chunkOffset:(l=s.timestampOffset)!=null?l:0,protectionData:[],appendWindow:[a,o]};let f=qe(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?fl(u,d,r,i,n):cl(u,d,r)}}function fs(n){let e=Xi({customManifestLoader:n.manifestLoader},ml()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?as:null),t=Ji(n),r=ea(n),i=aa(n),a=oa(n),o=sa(n);return{transportName:\"dash\",manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o}}}function ml(){return xe.dashParsers.wasm!==null&&(xe.dashParsers.wasm.status===\"initialized\"||xe.dashParsers.wasm.status===\"initializing\")}var cs=fs;var xt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var Mt=class{constructor(e){this._array=[],this._sortingFn=e}add(...e){e.sort(this._sortingFn);let t=0;for(let r=0;r<e.length;r++){let i=e[r],a=!1;for(;!a&&t<this._array.length;)this._sortingFn(i,this._array[t])<0?(this._array.splice(t,0,i),a=!0):t++;a||this._array.push(i)}}length(){return this._array.length}get(e){if(e<0||e>=this._array.length)throw new Error(\"Invalid index.\");return this._array[e]}toArray(){return this._array.slice()}findFirst(e){return Y(this._array,e)}has(e){return fe(this._array,e)}removeElement(e){let t=this._array.indexOf(e);if(t>=0)return this._array.splice(t,1),t}head(){return this._array[0]}last(){return this._array[this._array.length-1]}shift(){return this._array.shift()}pop(){return this._array.pop()}};var Cn=class{constructor(e){this._weakMap=new WeakMap,this._fn=e}get(e){let t=this._weakMap.get(e);if(t===void 0){let r=this._fn(e);return this._weakMap.set(e,r),r}else return t}destroy(e){this._weakMap.delete(e)}};var pl=.016666666666666666;function ms(n,e){return Math.abs(n-e)<pl}function gs(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function gl(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function hl(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Is(t,r)){let i=gs(t,r);n.splice(--e,2,i)}}return n}function ua(n,e){return n.end<=e.start}function ps({start:n,end:e},t){return n<=t&&t<e}function hs(n,e){return ps(n,e.start)||n.start<e.end&&e.end<n.end||ps(e,n.start)}function Is(n,e){return ms(e.start,n.end)||ms(e.end,n.start)}function da(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function Il(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t].start;if(e>=r){let i=n[t].end;if(e<i)return n[t]}}return null}function bs(n,e){let t=null,r=[];for(let i=0;i<n.length;i++){let a=n[i].start,o=n[i].end;e<a||e>=o?r.push({start:a,end:o}):t={start:a,end:o}}return{outerRanges:r,innerRange:t}}function wr(n,e){let t=Il(n,e);return t!==null?t.end-e:1/0}function Ht(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=hs(t,i),o=Is(t,i);if(a||o)t=gs(t,i),n.splice(r--,1);else if(r===0){if(ua(t,n[0]))break}else if(ua(n[r-1],t)&&ua(t,i))break}return n.splice(r,0,t),hl(gl(n))}function bl(n,e){let t=[];for(let r=0;r<e.length;r++)hs(n,e[r])&&t.push(e[r]);return t}function Dr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=bl(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let u=o[s];a.push({start:Math.max(i.start,u.start),end:Math.min(i.end,u.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let u=0;u<a.length;u++)a[u].start>s&&t.push({start:s,end:a[u].start}),s=a[u].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function Br({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(u=>{a=u.position.getWanted(),o=u.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&Sl(n,a,o,t.getValue(),r.getValue(),i).catch(u=>{let d=u instanceof Error?u.message:\"Unknown error\";m.error(\"Could not run BufferGarbageCollector:\",d)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function Sl(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:u}=bs(t,e),d=()=>{if(isFinite(r)){for(let l of u)e-r>=l.end?o.push(l):e>=l.end&&e-r>l.start&&e-r<l.end&&o.push({start:l.start,end:e-r});v(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},f=()=>{if(isFinite(i)){for(let l of u)e+i<=l.start?o.push(l):e<=l.start&&e+i<l.end&&e+i>l.start&&o.push({start:e+i,end:l.end});v(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};d(),f();for(let l of o)if(l.start<l.end){if(m.debug(\"GC: cleaning range from SegmentSink\",l.start,l.end),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var An=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=U();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>Je(t.context,e))}_cleanHistory(e){let t=e-this._lifetime,r=0;for(let i of this._history)if(i.date<t)r++;else break;if(r>0&&(this._history=this._history.splice(r)),this._history.length>this._maxHistoryLength){let i=this._history.length-this._maxHistoryLength;this._history=this._history.splice(i)}}};var kn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=L.getCurrent();this._inventory=[],this._bufferedHistory=new An(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var u,d,f,l,c,g,p;let t=this._inventory,r=0,i=t[0],{MINIMUM_SEGMENT_SIZE:a}=L.getCurrent(),o=i==null?void 0:i.infos.adaptation.type;if(m.hasLevel(\"DEBUG\")){let h=e.map(I=>`${I.start}-${I.end}`).join(\",\");m.debug(`SI: synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,h)}let s=e.length;for(let h=0;h<s;h++){if(i===void 0)return;let I=e[h].start,y=e[h].end;if(y-I<a){m.warn(\"SI: skipped range when synchronizing because it was too small\",o,I,y);continue}let T=r;for(;i!==void 0&&((u=i.bufferedEnd)!=null?u:i.end)-I<a;)i=t[++r];let P=null,E=r-T;if(E>0){let _=t[T+E-1];P={end:(d=_.bufferedEnd)!=null?d:_.end,precizeEnd:_.precizeEnd},m.debug(`SI: ${E} segments GCed.`,o);let x=t.splice(T,E);for(let A of x)A.bufferedStart===void 0&&A.bufferedEnd===void 0&&A.status!==2&&this._bufferedHistory.addBufferedSegment(A.infos,null);r=T}if(i===void 0)return;if(y-((f=i.bufferedStart)!=null?f:i.start)>=a){if(yl(i,I,P,o),r===t.length-1){ys(i,y,o);return}i=t[++r];let _=(l=i.bufferedStart)!=null?l:i.start,x=(c=i.bufferedEnd)!=null?c:i.end,A=h<s-1?e[h+1].start:void 0;for(;i!==void 0&&!(y<_||y-_<a&&x-y>=a||A!==void 0&&y-_<x-A);){let R=t[r-1];R.bufferedEnd===void 0&&(i.precizeStart?R.bufferedEnd=i.start:R.infos.segment.complete?R.bufferedEnd=R.end:R.bufferedEnd=i.start,m.debug(\"SI: calculating buffered end of contiguous segment\",o,R.bufferedEnd,R.end)),i.bufferedStart=R.bufferedEnd,i=t[++r],i!==void 0&&(_=(g=i.bufferedStart)!=null?g:i.start,x=(p=i.bufferedEnd)!=null?p:i.end)}}let C=t[r-1];C!==void 0&&ys(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:h}=L.getCurrent(),I=U();for(let y=r;y<t.length;y++){let T=t[y];I-T.insertionTs>=h&&(m.debug(\"SI: A segment at the end has been completely GCed\",o,`${T.start}-${T.end}`),T.bufferedStart===void 0&&T.bufferedEnd===void 0&&T.status!==2&&this._bufferedHistory.addBufferedSegment(T.infos,null),t.splice(y,1),y--)}}o!==void 0&&m.hasLevel(\"DEBUG\")&&m.debug(`SI: current ${o} inventory timeline:\n`+Tl(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},u,d){if(i.isInit)return;let f=t.type;if(o>=s){m.warn(\"SI: Invalid chunked inserted: starts before it ends\",f,o,s);return}let l=this._inventory,c={status:u?0:2,insertionTs:d,chunkSize:a,splitted:!1,start:o,end:s,precizeStart:!1,precizeEnd:!1,bufferedStart:void 0,bufferedEnd:void 0,infos:{segment:i,period:e,adaptation:t,representation:r}};for(let p=l.length-1;p>=0;p--){let h=l[p];if(h.start<=o)if(h.end<=o){for(m.debug(\"SI: Pushing segment strictly after previous one.\",f,o,h.end),this._inventory.splice(p+1,0,c),p+=2;p<l.length&&l[p].start<c.end;){if(l[p].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[p].start),l[p].start=c.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else if(h.start===o)if(h.end<=s){for(m.debug(\"SI: Segment pushed replace another one\",f,o,s,h.end),this._inventory.splice(p,1,c),p+=1;p<l.length&&l[p].start<c.end;){if(l[p].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[p].start),l[p].start=c.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else{m.debug(\"SI: Segment pushed ends before another with the same start\",f,o,s,h.end),l.splice(p,0,c),h.start=c.end,h.bufferedStart=void 0,h.precizeStart=h.precizeStart&&c.precizeEnd;return}else if(h.end<=c.end){for(m.debug(\"SI: Segment pushed updates end of previous one\",f,o,s,h.start,h.end),this._inventory.splice(p+1,0,c),h.end=c.start,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&c.precizeStart,p+=2;p<l.length&&l[p].start<c.end;){if(l[p].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[p].start),l[p].start=c.end,l[p].bufferedStart=void 0,l[p].precizeStart=l[p].precizeStart&&c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[p].start,l[p].end),l.splice(p,1)}return}else{m.warn(\"SI: Segment pushed is contained in a previous one\",f,o,s,h.start,h.end);let I={status:h.status,insertionTs:h.insertionTs,chunkSize:h.chunkSize,splitted:!0,start:c.end,end:h.end,precizeStart:h.precizeStart&&h.precizeEnd&&c.precizeEnd,precizeEnd:h.precizeEnd,bufferedStart:void 0,bufferedEnd:h.end,infos:h.infos};h.end=c.start,h.splitted=!0,h.bufferedEnd=void 0,h.precizeEnd=h.precizeEnd&&c.precizeStart,l.splice(p+1,0,c),l.splice(p+2,0,I);return}}let g=this._inventory[0];if(g===void 0){m.debug(\"SI: first segment pushed\",f,o,s),this._inventory.push(c);return}if(g.start>=s)m.debug(\"SI: Segment pushed comes before all previous ones\",f,o,s,g.start),this._inventory.splice(0,0,c);else if(g.end<=s){for(m.debug(\"SI: Segment pushed starts before and completely recovers the previous first one\",f,o,s,g.start,g.end),this._inventory.splice(0,1,c);l.length>1&&l[1].start<c.end;){if(l[1].end>c.end){m.debug(\"SI: Segment pushed updates the start of the next one\",f,c.end,l[1].start),l[1].start=c.end,l[1].bufferedStart=void 0,l[1].precizeStart=c.precizeEnd;return}m.debug(\"SI: Segment pushed removes the next one\",f,o,s,l[1].start,l[1].end),l.splice(1,1)}return}else{m.debug(\"SI: Segment pushed start of the next one\",f,o,s,g.start,g.end),g.start=s,g.bufferedStart=void 0,g.precizeStart=c.precizeEnd,this._inventory.splice(0,0,c);return}}completeSegment(e){if(e.segment.isInit)return;let t=this._inventory,r=[];for(let i=0;i<t.length;i++)if(Je(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(m.warn(\"SI: Completed Segment is splitted.\",e.segment.id,e.segment.time,e.segment.end),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&Je(t[i].infos,e);){let c=t[i].chunkSize;s!==void 0&&c!==void 0&&(s+=c),i++}let u=i-1,d=u-o,f=t[u].end,l=t[u].bufferedEnd;d>0&&(this._inventory.splice(o+1,d),i-=d),this._inventory[o].status===0&&(this._inventory[o].status=1),this._inventory[o].chunkSize=s,this._inventory[o].end=f,this._inventory[o].bufferedEnd=l,this._inventory[o].splitted=a,r.push(this._inventory[o])}if(r.length===0)m.warn(\"SI: Completed Segment not found\",e.segment.id,e.segment.time);else for(let i of r)i.bufferedStart!==void 0&&i.bufferedEnd!==void 0?i.status!==2&&this._bufferedHistory.addBufferedSegment(i.infos,{start:i.bufferedStart,end:i.bufferedEnd}):m.debug(\"SI: buffered range not known after sync. Skipping history.\",i.start,i.end)}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function la(n){if(n.bufferedStart===void 0||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=L.getCurrent();return Math.abs(e-n.bufferedStart)<=i&&(n.bufferedEnd===void 0||n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3))}function Ss(n){if(n.bufferedEnd===void 0||!n.infos.segment.complete||n.status!==1)return!1;let{start:e,end:t}=n,r=t-e,{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MAX_MANIFEST_BUFFERED_DURATION_DIFFERENCE:a}=L.getCurrent();return Math.abs(t-n.bufferedEnd)<=i&&n.bufferedStart!==void 0&&n.bufferedEnd>n.bufferedStart&&Math.abs(n.bufferedEnd-n.bufferedStart-r)<=Math.min(a,r/3)}function yl(n,e,t,r){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:i,MISSING_DATA_TRIGGER_SYNC_DELAY:a,SEGMENT_SYNCHRONIZATION_DELAY:o}=L.getCurrent();if(n.bufferedStart!==void 0)n.bufferedStart<e&&(m.debug(\"SI: Segment partially GCed at the start\",r,n.bufferedStart,e),n.bufferedStart=e),!n.precizeStart&&la(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)m.debug(\"SI: buffered start is precize start\",r,n.start),n.bufferedStart=n.start;else if(t!==null&&t.end>e&&(t.precizeEnd||n.start-t.end<=i))m.debug(\"SI: buffered start is end of previous segment\",r,e,n.start,t.end),n.bufferedStart=t.end,la(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=U();if(n.start-e>=a&&s-n.insertionTs<o){m.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}m.debug(\"SI: found true buffered start\",r,e,n.start),n.bufferedStart=e,la(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)m.debug(\"SI: range start too far from expected start\",r,e,n.start),n.bufferedStart=n.start;else{let s=U();if(n.start-e>=a&&s-n.insertionTs<o){m.debug(\"SI: Ignored bufferedStart synchronization\",r,e,n.start,s-n.insertionTs);return}m.debug(\"SI: Segment appears immediately garbage collected at the start\",r,e,n.start),n.bufferedStart=e}}function ys(n,e,t){let{MAX_MANIFEST_BUFFERED_START_END_DIFFERENCE:r,MISSING_DATA_TRIGGER_SYNC_DELAY:i,SEGMENT_SYNCHRONIZATION_DELAY:a}=L.getCurrent();if(n.bufferedEnd!==void 0)n.bufferedEnd>e&&(m.debug(\"SI: Segment partially GCed at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&Ss(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)m.debug(\"SI: buffered end is precize end\",t,n.end),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=U();if(e-n.end>=i&&o-n.insertionTs<a){m.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}m.debug(\"SI: found true buffered end\",t,e,n.end),n.bufferedEnd=e,Ss(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)m.debug(\"SI: range end too far from expected end\",t,e,n.end),n.bufferedEnd=n.end;else{let o=U();if(e-n.end>=i&&o-n.insertionTs<a){m.debug(\"SI: Ignored bufferedEnd synchronization\",t,e,n.end,o-n.insertionTs);return}m.debug(\"SI: Segment appears immediately garbage collected at the end\",t,n.bufferedEnd,e),n.bufferedEnd=e}}function Tl(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(u){let d=String.fromCharCode(r.length+65);return r.push({letter:d,periodId:u.period.id,representationId:u.representation.id,bitrate:u.representation.bitrate}),d}let s=\"\";for(let u=0;u<n.length;u++){let d=n[u];if(d.bufferedStart!==void 0&&d.bufferedEnd!==void 0){let f=d.infos.period.id,l=d.infos.representation.id,c=t[f],g;c===void 0?(g=o(d.infos),t[f]={[l]:g}):c[l]===void 0?(g=o(d.infos),c[l]=g):g=c[l],i===null?s+=`${d.bufferedStart.toFixed(2)}|${g}|`:a===g?i.bufferedEnd+e<d.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${g}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${g}|`,i=d,a=g}}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(u=>{var d;s+=`\n[${u.letter}] P: ${u.periodId} || R: ${u.representationId}(${(d=u.bitrate)!=null?d:\"unknown bitrate\"})`}),s}function Gt(n,e){for(let t=0;t<n.length;t++)if(n[t].infos.period.start>=e.start)return t>0?n[t-1]:null;return n.length>0?n[n.length-1]:null}function Kt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var Ts=kn;var jt=class{constructor(){this._segmentInventory=new Ts}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var xn=class extends jt{constructor(e,t,r){super(),m.info(\"AVSB: calling `mediaSource.addSourceBuffer`\",t);let i=r.addSourceBuffer(e,t);this.bufferType=e,this._sourceBuffer=i,this._lastInitSegmentUniqueId=null,this.codec=t,this._initSegmentsMap=new Map,this._pendingOperations=[]}declareInitSegment(e,t){_s(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){_s(e.data.chunk),m.debug(\"AVSB: receiving order to push data to the SourceBuffer\",this.bufferType,Et(e.inventoryInfos));let t=this._getActualDataToPush(e.data);t.length===0&&t.push(new Uint8Array);let r=Promise.all(t.map(o=>{let{codec:s,timestampOffset:u,appendWindow:d}=e.data;return m.debug(\"AVSB: pushing segment\",this.bufferType,Et(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:u,appendWindow:d})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,U()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,U());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){m.debug(\"AVSB: receiving order to remove data from the SourceBuffer\",this.bufferType,e,t);let r=this._sourceBuffer.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){try{m.debug(\"AVSB: Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose()}catch(e){m.debug(`AVSB: Failed to dispose a ${this.bufferType} SourceBufferInterface:`,e instanceof Error?e:\"\")}}_getActualDataToPush(e){let t=[];if(e.initSegmentUniqueId!==null&&!this._isLastInitSegment(e.initSegmentUniqueId)){let r=this._initSegmentsMap.get(e.initSegmentUniqueId);if(r===void 0)throw new Error(\"Invalid initialization segment uniqueId\");let i=new ArrayBuffer(r.byteLength),a=new Uint8Array(i);a.set(r instanceof ArrayBuffer?new Uint8Array(r):new Uint8Array(r.buffer)),r=a,t.push(r),this._lastInitSegmentUniqueId=e.initSegmentUniqueId}return e.chunk!==null&&t.push(e.chunk),t}_isLastInitSegment(e){return this._lastInitSegmentUniqueId===null?!1:this._lastInitSegmentUniqueId===e}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function _s(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Ur=xn;var Mn=class extends jt{constructor(e){m.debug(\"HTSB: Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){m.warn(\"HTSB: Declaring initialization segment for Text SegmentSink\",e)}freeInitSegment(e){m.warn(\"HTSB: Freeing initialization segment for Text SegmentSink\",e)}async pushChunk(e){let{data:t}=e;El(t.chunk);let r=this._sender.pushTextData(ie(Z({},t),{chunk:t.chunk}));this._addToOperationQueue(r,{type:0,value:e});let i=await r;return e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,U()),this._segmentInventory.synchronizeBuffered(i),i}async removeBuffer(e,t){let r=this._sender.remove(e,t);this._addToOperationQueue(r,{type:1,value:{start:e,end:t}});let i=await r;return this._segmentInventory.synchronizeBuffered(i),i}async signalSegmentComplete(e){if(this._pendingOperations.length>0){let{promise:t}=this._pendingOperations[this._pendingOperations.length-1];this._addToOperationQueue(t,{type:2,value:e});try{await t}catch(r){}}this._segmentInventory.completeSegment(e)}getPendingOperations(){return this._pendingOperations.map(e=>e.operation)}dispose(){m.debug(\"HTSB: Disposing TextSegmentSink\"),this._sender.reset()}_addToOperationQueue(e,t){let r={operation:t,promise:e};this._pendingOperations.push(r);let i=()=>{let a=this._pendingOperations.indexOf(r);a>=0&&this._pendingOperations.splice(a,1)};e.then(i,i)}};function El(n){if(b.CURRENT_ENV!==b.PRODUCTION&&(typeof n!=\"object\"||n===null||typeof n.data!=\"string\"||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\"))throw new Error(\"Invalid format given to a TextSegmentSink\")}b.CURRENT_ENV===b.DEV&&(Rl=function(e){function t(r){}});var Rl;var Es=Mn;var Pl=[\"audio\",\"video\",\"text\"],On=class n{static isNative(e){return Rs(e)}constructor(e,t,r){this._mediaSource=e,this._textInterface=r,this._hasVideo=t,this._initializedSegmentSinks={},this._onNativeBufferAddedOrDisabled=[]}getBufferTypes(){let e=this.getNativeBufferTypes();return this._textInterface!==null&&e.push(\"text\"),e}getNativeBufferTypes(){return this._hasVideo?[\"video\",\"audio\"]:[\"audio\"]}getStatus(e){let t=this._initializedSegmentSinks[e];return t===void 0?{type:\"uninitialized\"}:t===null?{type:\"disabled\"}:{type:\"initialized\",value:t}}waitForUsableBuffers(e){return this._areNativeBuffersUsable()?Promise.resolve():Tt(e,t=>{let r,i=()=>{let a=this._onNativeBufferAddedOrDisabled.indexOf(r);a>=0&&this._onNativeBufferAddedOrDisabled.splice(a,1)};return r=()=>{this._areNativeBuffersUsable()&&(i(),t())},this._onNativeBufferAddedOrDisabled.push(r),i})}disableSegmentSink(e){let t=this._initializedSegmentSinks[e];if(t===null){m.warn(`SBS: The ${e} SegmentSink was already disabled.`);return}if(t!==void 0)throw new Error(\"Cannot disable an active SegmentSink.\");this._initializedSegmentSinks[e]=null,n.isNative(e)&&this._onNativeBufferAddedOrDisabled.forEach(r=>r())}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(Rs(e)){if(!v(r))return r instanceof Ur&&r.codec!==t?m.warn(\"SB: Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):m.info(\"SB: Reusing native SegmentSink with codec\",t),r;m.info(\"SB: Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Ur(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.forEach(s=>s()),o}if(!v(r))return m.info(\"SB: Reusing a previous custom SegmentSink for the type\",e),r;let i;if(e===\"text\"){if(m.info(\"SB: Creating a new text SegmentSink\"),this._textInterface===null)throw new Error(\"HTML Text track feature not activated\");return i=new Es(this._textInterface),this._initializedSegmentSinks.text=i,i}throw m.error(\"SB: Unknown buffer type:\",e),new $(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e){let t=this._initializedSegmentSinks[e];if(v(t)){m.warn(\"SB: Trying to dispose a SegmentSink that does not exist\");return}m.info(\"SB: Aborting SegmentSink\",e),t.dispose(),delete this._initializedSegmentSinks[e]}disposeAll(){Pl.forEach(e=>{this.getStatus(e).type===\"initialized\"&&this.disposeSegmentSink(e)})}_areNativeBuffersUsable(){let e=this.getNativeBufferTypes();return!(e.some(i=>this._initializedSegmentSinks[i]===void 0)||e.every(i=>this._initializedSegmentSinks[i]===null))}createSegmentSinkMetricsForType(e){var t,r;return{bufferType:e,codec:(t=this._initializedSegmentSinks[e])==null?void 0:t.codec,segmentInventory:(r=this._initializedSegmentSinks[e])==null?void 0:r.getLastKnownInventory().map(i=>ie(Z({},i),{infos:vl(i.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function Rs(n){return n===\"audio\"||n===\"video\"}function vl(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var St=On;var wn=class extends de{constructor(e,t,r,i){super(),this._content=e,this._currentCanceller=null,this._downloadQueue=t,this._initSegmentRequest=null,this._mediaSegmentRequest=null,this._segmentFetcher=r,this._initSegmentInfoRef=new j(void 0),this._mediaSegmentAwaitingInitMetadata=null,i||this._initSegmentInfoRef.setValue(null)}getRequestedInitSegment(){return this._initSegmentRequest===null?null:this._initSegmentRequest.segment}getRequestedMediaSegment(){return this._mediaSegmentRequest===null?null:this._mediaSegmentRequest.segment}start(){this._currentCanceller===null&&(this._currentCanceller=new z,this._downloadQueue.onUpdate(e=>{let{segmentQueue:t}=e;if(t.length>0&&t[0].segment.id===this._mediaSegmentAwaitingInitMetadata)return;let r=this._mediaSegmentRequest;if(t.length===0){if(r===null)return;m.debug(\"Stream: no more media segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}else if(r===null){m.debug(\"Stream: Media segments now need to be requested. Starting queue.\",this._content.adaptation.type,t.length),this._restartMediaSegmentDownloadingQueue();return}else{let i=t[0];if(r.segment.id!==i.segment.id){m.debug(\"Stream: Next media segment changed, cancelling previous\",this._content.adaptation.type),this._restartMediaSegmentDownloadingQueue();return}r.priority!==i.priority&&(m.debug(\"Stream: Priority of next media segment changed, updating\",this._content.adaptation.type,r.priority,i.priority),this._segmentFetcher.updatePriority(r.request,i.priority));return}},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}),this._downloadQueue.onUpdate(e=>{var r;let t=this._initSegmentRequest;if(e.initSegment!==null&&t!==null){e.initSegment.priority!==t.priority&&this._segmentFetcher.updatePriority(t.request,e.initSegment.priority);return}else if(((r=e.initSegment)==null?void 0:r.segment.id)===(t==null?void 0:t.segment.id))return;e.initSegment===null&&m.debug(\"Stream: no more init segment to request. Cancelling queue.\",this._content.adaptation.type),this._restartInitSegmentDownloadingQueue(e.initSegment)},{emitCurrentValue:!0,clearSignal:this._currentCanceller.signal}))}stop(){var e;(e=this._currentCanceller)==null||e.cancel(),this._currentCanceller=null}_restartMediaSegmentDownloadingQueue(){this._mediaSegmentRequest!==null&&this._mediaSegmentRequest.canceller.cancel();let{segmentQueue:e}=this._downloadQueue.getValue(),t=e[0],r=i=>{if(this._currentCanceller!==null&&this._currentCanceller.isUsed()){this._mediaSegmentRequest=null;return}if(i===void 0){this._mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let a=new z,o=this._currentCanceller===null?B:a.linkToSignal(this._currentCanceller.signal),{segment:s,priority:u}=i,d=H({segment:s},this._content),f=!1,l=!1;a.signal.register(()=>{this._mediaSegmentRequest=null,!f&&(this._mediaSegmentAwaitingInitMetadata===s.id&&(this._mediaSegmentAwaitingInitMetadata=null),f=!0,l=!1)});let c=h=>{be(h.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",H({},h,{segment:s}))},g=()=>{let h=this._downloadQueue.getValue().segmentQueue;if(h.length===0){f=!0,this.trigger(\"emptyQueue\",null);return}else h[0].segment.id===s.id&&h.shift();f=!0,r(h[0])},p=this._segmentFetcher.createRequest(d,u,{onRetry:h=>{this.trigger(\"requestRetry\",{segment:s,error:h})},beforeInterrupted(){m.info(\"Stream: segment request interrupted temporarly.\",s.id,s.time)},onChunk:h=>{let I=this._initSegmentInfoRef.getValue();I!==void 0?c(h(I!=null?I:void 0)):(l=!0,this._initSegmentInfoRef.waitUntilDefined(y=>{c(h(y!=null?y:void 0))},{clearSignal:a.signal}))},onAllChunksReceived:()=>{l?(this._mediaSegmentAwaitingInitMetadata=s.id,this._initSegmentInfoRef.waitUntilDefined(()=>{this._mediaSegmentAwaitingInitMetadata=null,l=!1,this.trigger(\"fullyLoadedSegment\",s)},{clearSignal:a.signal})):this.trigger(\"fullyLoadedSegment\",s)},beforeEnded:()=>{o(),this._mediaSegmentRequest=null,l?this._initSegmentInfoRef.waitUntilDefined(g,{clearSignal:a.signal}):g()}},a.signal);p.catch(h=>{o(),f||(f=!0,this.stop(),this.trigger(\"error\",h))}),this._mediaSegmentRequest={segment:s,priority:u,request:p,canceller:a}};r(t)}_restartInitSegmentDownloadingQueue(e){if(this._currentCanceller!==null&&this._currentCanceller.isUsed()||(this._initSegmentRequest!==null&&this._initSegmentRequest.canceller.cancel(),e===null))return;let t=new z,r=this._currentCanceller===null?B:t.linkToSignal(this._currentCanceller.signal),{segment:i,priority:a}=e,o=H({segment:i},this._content),s=!1,u=this._segmentFetcher.createRequest(o,a,{onRetry:d=>{this.trigger(\"requestRetry\",{segment:i,error:d})},beforeInterrupted:()=>{m.info(\"Stream: init segment request interrupted temporarly.\",i.id)},beforeEnded:()=>{r(),this._initSegmentRequest=null,s=!0},onChunk:d=>{var l;let f=d(void 0);be(f.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",H({},f,{segment:i})),f.segmentType===\"init\"&&this._initSegmentInfoRef.setValue((l=f.initTimescale)!=null?l:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",i)}},t.signal);u.catch(d=>{r(),s||(s=!0,this.stop(),this.trigger(\"error\",d))}),t.signal.register(()=>{this._initSegmentRequest=null,!s&&(s=!0)}),this._initSegmentRequest={segment:i,priority:a,request:u,canceller:t}}};function fa(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,u=Cl(i,e);if(u===null){if(t===null){if(r&&a.end!==void 0&&e.end>=a.end)return{start:void 0,end:null};let l=s.index.checkDiscontinuity(e.start);if(l!==null)return{start:void 0,end:l}}return null}let d=i[u];if(d.bufferedStart!==void 0&&d.bufferedStart>e.start&&(t===null||d.infos.segment.end<=t)){let l=d.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(m.debug(\"RS: current discontinuity encountered\",o.type,d.bufferedStart),{start:void 0,end:l})}let f=Al(i,e,u+1);if(f!==null){let l=i[f-1],c=i[f];if(t===null||c.infos.segment.end<=t){if(!r&&s.index.awaitSegmentBetween(l.infos.segment.end,c.infos.segment.time)!==!1)return null;let g=l.bufferedEnd,p=c.bufferedStart;return m.debug(\"RS: future discontinuity encountered\",o.type,g,p),{start:g,end:p}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=kl(i,a.end);if(l!==null){let c=i[l];if(c.bufferedEnd!==void 0&&c.bufferedEnd<a.end)return m.debug(\"RS: discontinuity encountered at the end of the current period\",o.type,c.bufferedEnd,a.end),{start:c.bufferedEnd,end:null}}}if(a.end!==void 0&&e.end>=a.end)return null;for(let l=i.length-1;l>=0;l--){let c=i[l];if(c.bufferedStart===void 0)break;if(c.bufferedStart<e.end){if(c.bufferedEnd!==void 0&&c.bufferedEnd<e.end){let g=s.index.checkDiscontinuity(e.end);if(g!==null)return{start:c.bufferedEnd,end:g}}return null}}}return null}function Cl(n,e){for(let t=0;t<n.length;t++){let r=n[t];if(r.bufferedStart===void 0||r.bufferedEnd===void 0||r.bufferedStart>=e.end)return null;if(r.bufferedEnd>e.start)return t}return null}function Al(n,e,t){if(t<=0)return m.error(\"RS: Asked to check a discontinuity before the first chunk.\"),null;for(let r=t;r<n.length;r++){let i=n[r],a=n[r-1];if(i.bufferedStart===void 0||a.bufferedEnd===void 0||i.bufferedStart>=e.end)return null;if(i.bufferedStart-a.bufferedEnd>0)return r}return null}function kl(n,e){for(let t=n.length-1;t>=0;t--){let r=n[t];if(r.bufferedStart===void 0)return null;if(r.bufferedStart<e)return t}return null}function ca({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:u,representation:d}=e,f=xl(n,o,s),l=d.index.getSegments(a.start,a.end-a.start),c=n.filter(C=>!Ps(C.infos,e,t,r)),g=Ul(c,a,i),{MINIMUM_SEGMENT_SIZE:p,MIN_BUFFER_AHEAD:h}=L.getCurrent(),I=!1,y=Math.min(1/60,p),T=!1,P=[];return{segmentsToLoad:l.filter(C=>{let _=H({segment:C},e);if(o.length>0&&o.some(w=>Je(_,w)))return!1;let{duration:x,time:A,end:R}=C;if(C.isInit)return!0;if(I)return P.push(C),!1;if(C.complete&&x<p||o.length>0&&o.some(w=>{if(w.period.id!==e.period.id||w.adaptation.id!==e.adaptation.id)return!1;let{segment:O}=w;if(O.time-y>A)return!1;if(O.complete){if(O.end+y<R)return!1}else if(Math.abs(A-O.time)>A)return!1;return!Ps(w,_,t,r)}))return!1;for(let D=0;D<g.length;D++){let w=g[D],O=w.infos.period.id===e.period.id;if(w.status===1&&O){let N=w.infos.segment;if(A-N.time>-y){if(N.complete){if(N.end-R>-y)return!1}else if(Math.abs(A-N.time)<y)return!1}}}let k=x*e.representation.bitrate;if(f-k<0&&(T=!0,A>a.start+h))return I=!0,P.push(C),!1;let M=i(_);if(M.length>1){let D=M[M.length-1],w=M[M.length-2];if(D.buffered===null&&w.buffered===null)return m.warn(\"Stream: Segment GCed multiple times in a row, ignoring it.\",\"If this happens a lot and lead to unpleasant experience, please check your device's available memory. If it's low when this message is emitted, you might want to update the RxPlayer's settings (`maxBufferAhead`, `maxVideoBufferSize` etc.) so less memory is used by regular media data buffering.\"+u.type,d.id,C.time),!1}for(let D=0;D<g.length;D++){let w=g[D];if(w.end+y>A){let O=w.start>A+y||Ml(g,D).end<R-y;return O&&(f-=k),O}}return f-=k,!0}),segmentsOnHold:P,isBufferFull:T}}function xl(n,e,t){let r=t*8e3;return r-=e.reduce((i,a)=>{let{bitrate:o}=a.representation,{duration:s}=a.segment;return i+o*s},0),n.reduce((i,a)=>a.chunkSize!==void 0?i-a.chunkSize*8:i,r)}function Ml(n,e){let t=e+1,{MINIMUM_SEGMENT_SIZE:r}=L.getCurrent(),i=Math.min(1/60,r);for(;t<n.length-1&&n[t-1].end+i>n[t].start;)t++;return t--,n[t]}function Ps(n,e,t,r){let{CONTENT_REPLACEMENT_PADDING:i}=L.getCurrent();if(n.period.id!==e.period.id)return!1;let{segment:a}=n;return a.time<t+i?!1:n.adaptation.id!==e.adaptation.id?!0:Ol(n.representation,e.representation,r)}function Ol(n,e,t){let r=n.bitrate,{BITRATE_REBUFFERING_RATIO:i}=L.getCurrent();if(t===void 0){let a=r*i;return e.bitrate>a}return r<t&&e.bitrate>r}function wl(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=L.getCurrent();return n.bufferedStart===void 0||e!==null&&e.bufferedEnd!==void 0&&n.bufferedStart-e.bufferedEnd<.1?!1:t<n.bufferedStart&&n.bufferedStart-n.start>r?(m.info(\"Stream: The start of the wanted segment has been garbage collected\",n.start,n.bufferedStart),!0):!1}function Dl(n,e,t){let{MAX_TIME_MISSING_FROM_COMPLETE_SEGMENT:r}=L.getCurrent();return n.bufferedEnd===void 0||e!==null&&e.bufferedStart!==void 0&&e.bufferedStart-n.bufferedEnd<.1?!1:t>n.bufferedEnd&&n.end-n.bufferedEnd>r?(m.info(\"Stream: The end of the wanted segment has been garbage collected\",n.end,n.bufferedEnd),!0):!1}function Bl(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.start;if(e!==void 0&&r!==void 0&&e-r>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.start;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function Nl(n,e){var o,s;if(n.length<2)return!0;let r=(o=n[n.length-1].buffered)==null?void 0:o.end;if(e!==void 0&&r!==void 0&&r-e>.05)return!0;let a=(s=n[n.length-2].buffered)==null?void 0:s.end;return a===void 0||r===void 0?!0:Math.abs(a-r)>.01}function Ul(n,e,t){return n.filter((r,i,a)=>{let o=i===0?null:a[i-1],s=i>=a.length-1?null:a[i+1],u=null;if(wl(r,o,e.start)){if(u=t(r.infos),Bl(u,r.bufferedStart))return!1;m.debug(\"Stream: skipping segment gc-ed at the start\",r.start,r.bufferedStart)}if(Dl(r,s,e.end)){if(u=u!=null?u:t(r.infos),Nl(u,r.bufferedEnd))return!1;m.debug(\"Stream: skipping segment gc-ed at the end\",r.end,r.bufferedEnd)}return!0})}function Dn(n,e){let t=n-e,{SEGMENT_PRIORITIES_STEPS:r}=L.getCurrent();for(let i=0;i<r.length;i++)if(t<r[i])return i;return r.length}function ma(n,e,t,r,i,a,o){var A,R,k;let{representation:s}=n,u=(R=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?R:t.getReference().getValue().paused.last,d=(k=t.getPlaybackRate())!=null?k:t.getReference().getValue().speed,f=e;(u===void 0||d===void 0||u||d<=0)&&(f-=.1);let l=Ll(n,f,i),c=s.index.shouldRefresh(l.start,l.end),g=o.getPendingOperations().filter(M=>M.type===2).map(M=>M.value),p=o.getLastKnownInventory(),h=t.getCurrentTime();h===void 0&&(h=t.getReference().getValue().position.getWanted());let I=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:T,isBufferFull:P}=ca({content:n,bufferedSegments:p,currentPlaybackTime:h,fastSwitchThreshold:r,getBufferedHistory:I,neededRange:l,segmentsBeingPushed:g,maxBufferSize:a}),E=y.map(M=>({priority:Dn(M.time,f),segment:M})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,_=null;return g.length>0&&(_=Math.min(...g.map(M=>M.segment.time))),T.length>0&&(_=_!==null?Math.min(_,T[0].time):T[0].time),E.length>0&&(_=_!==null?Math.min(_,E[0].segment.time):E[0].segment.time),{imminentDiscontinuity:fa(n,l,_,C,p),hasFinishedLoading:C,neededSegments:E,isBufferFull:P,shouldRefreshManifest:c}}function Ll(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),u=o.index;!v(s)&&St.isNative(n.adaptation.type)&&e>=s&&u.isInitialized()&&!u.isStillAwaitingFutureSegments()&&Fl(i,a,e)?r=s-1:r=e-.1;let d=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=d>=a.end:s===null?f=!0:f=d>=s,{start:Math.max(r,a.start),end:Math.min(d,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function Fl(n,e,t){var i;let r=n.getPeriodAfter(e);return e.containsTime(t,r)&&n.isLastPeriodKnown&&e.id===((i=n.periods[n.periods.length-1])==null?void 0:i.id)}async function Bn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof oe)throw a;if(!(a instanceof ve)||!a.isBufferFull){let u=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new $(\"BUFFER_APPEND_ERROR\",u,{tracks:[ct(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{m.warn(\"Stream: Running garbage collector\");let u=Math.max(s-5,0),d=s+r.getValue()+12;if(await e.removeBuffer(0,u),await e.removeBuffer(d,Number.MAX_VALUE),await ni(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(u){if(u instanceof oe)throw u;let d=u instanceof Error?u.toString():\"Could not clean the buffer\";throw new $(\"BUFFER_FULL_ERROR\",d,{tracks:[ct(t.inventoryInfos.adaptation)]})}}}async function pa({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){if(o.cancellationError!==null)throw o.cancellationError;let s=e.representation.getMimeTypeString(),u={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},d=H({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Bn(n,i,{data:u,inventoryInfos:d},a,o);return{content:e,segment:r,buffered:f}}async function ga({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var _,x;if(i.chunkData===null)return null;if(s.cancellationError!==null)throw s.cancellationError;let{chunkData:u,chunkInfos:d,chunkOffset:f,chunkSize:l,appendWindow:c}=i,g=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:p}=L.getCurrent(),h=[c[0]!==void 0?Math.max(0,c[0]-p.START):void 0,c[1]!==void 0?c[1]+p.END:void 0],I={initSegmentUniqueId:r,chunk:u,timestampOffset:f,appendWindow:h,codec:g},y=(_=d==null?void 0:d.time)!=null?_:a.time,T=(x=d==null?void 0:d.duration)!=null?x:a.duration,P=y+T;h[0]!==void 0&&(y=Math.max(y,h[0])),h[1]!==void 0&&(P=Math.min(P,h[1]));let E=H({segment:a,chunkSize:l,start:y,end:P},t),C=await Bn(n,o,{data:I,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:C}}function ha({content:n,options:e,playbackObserver:t,segmentSink:r,segmentFetcher:i,terminate:a},o,s){let{period:u,adaptation:d,representation:f}=n,{bufferGoal:l,maxBufferSize:c,drmSystemId:g,fastSwitchThreshold:p}=e,h=d.type,I=new z;I.linkToSignal(s);let y=new z;y.linkToSignal(I.signal);let T={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};I.signal.register(()=>{T.uniqueId!==null&&r.freeInitSegment(T.uniqueId)});let P=new j({initSegment:null,segmentQueue:[]},y.signal),E=T.segment!==null;E||(T.isLoaded=!0);let C=!1;if(g!==void 0){let k=f.getEncryptionData(g);if(k.length>0&&k.every(M=>M.keyIds!==void 0)&&(C=!0,o.encryptionDataEncountered(k.map(M=>H({content:n},M))),I.isUsed()))return}let _=new wn(n,P,i,E);_.addEventListener(\"error\",k=>{y.signal.isCancelled()||(I.cancel(),o.error(k))}),_.addEventListener(\"parsedInitSegment\",A),_.addEventListener(\"parsedMediaSegment\",A),_.addEventListener(\"emptyQueue\",x),_.addEventListener(\"requestRetry\",k=>{if(o.warning(k.error),y.signal.isCancelled())return;let M=k.segment,{index:D}=f;D.isSegmentStillAvailable(M)===!1?x():D.canBeOutOfSyncError(k.error,M)&&o.manifestMightBeOufOfSync()}),_.addEventListener(\"fullyLoadedSegment\",k=>{r.signalSegmentComplete(H({segment:k},n)).catch(R)}),_.start(),y.signal.register(()=>{_.removeEventListener(),_.stop()}),t.listen(x,{includeLastObservation:!1,clearSignal:y.signal}),n.manifest.addEventListener(\"manifestUpdate\",x,y.signal),l.onUpdate(x,{emitCurrentValue:!1,clearSignal:y.signal}),c.onUpdate(x,{emitCurrentValue:!1,clearSignal:y.signal}),a.onUpdate(x,{emitCurrentValue:!1,clearSignal:y.signal}),x();return;function x(){if(y.isUsed())return;let k=t.getReference().getValue(),M=k.position.getWanted(),D=ma(n,M,t,p.getValue(),l.getValue(),c.getValue(),r),{neededSegments:w}=D,O=null;if(f.index.isInitialized()){if(w.length>0&&!T.isLoaded&&T.segment!==null){let q=w[0].priority;O={segment:T.segment,priority:q}}}else if(T.segment===null)m.warn(\"Stream: Uninitialized index without an initialization segment\");else if(T.isLoaded)m.warn(\"Stream: Uninitialized index with an already loaded initialization segment\");else{let q=k.position.getWanted();O={segment:T.segment,priority:Dn(u.start,q)}}let N=a.getValue();if(N===null)P.setValue({initSegment:O,segmentQueue:w});else if(N.urgent){m.debug(\"Stream: Urgent switch, terminate now.\",h),P.setValue({initSegment:null,segmentQueue:[]}),P.finish(),y.cancel(),o.terminating();return}else{let q=w[0],ee=_.getRequestedInitSegment(),K=_.getRequestedMediaSegment(),G=K===null||q===void 0||K.id!==q.segment.id?[]:[q],W=ee===null?null:O;if(P.setValue({initSegment:W,segmentQueue:G}),G.length===0&&W===null){m.debug(\"Stream: No request left, terminate\",h),P.finish(),y.cancel(),o.terminating();return}}if(o.streamStatusUpdate({period:u,position:k.position.getWanted(),bufferType:h,imminentDiscontinuity:D.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:D.hasFinishedLoading,neededSegments:D.neededSegments}),y.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:V}=L.getCurrent();if(D.isBufferFull){let q=Math.max(0,M-V);q>0&&r.removeBuffer(0,q).catch(R)}D.shouldRefreshManifest&&o.needsManifestRefresh()}function A(k){if(!I.isUsed()){for(let M of k.protectionData)f.addProtectionData(M.initDataType,M.keyId,M.initData);if(!C){let M=f.getAllEncryptionData();if(M.length>0&&(o.encryptionDataEncountered(M.map(D=>H({content:n},D))),C=!0,I.isUsed()))return}if(k.segmentType===\"init\"){if(!f.index.isInitialized()&&k.segmentList!==void 0&&f.index.initialize(k.segmentList),T.isLoaded=!0,k.initializationData!==null){let M=f.uniqueId;T.uniqueId=M,r.declareInitSegment(M,k.initializationData),pa({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:M,segment:k.segment,segmentData:k.initializationData,segmentSink:r},I.signal).then(D=>{D!==null&&o.addedSegment(D)}).catch(R)}x();return}else{let{inbandEvents:M,predictedSegments:D,needsManifestRefresh:w}=k;if(D!==void 0&&f.index.addPredictedSegments(D,k.segment),w===!0&&(o.needsManifestRefresh(),I.isUsed())||M!==void 0&&M.length>0&&(o.inbandEvent(M),I.isUsed()))return;let O=T.uniqueId;ga({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:O,parsedSegment:k,segment:k.segment,segmentSink:r},I.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(R)}}}function R(k){I.isUsed()&&k instanceof oe||(I.cancel(),o.error(k))}}var vs=ha;function Ia(n,e,t,r,i){var c,g,p,h;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let I of a)I.infos.period.id===n.id&&(I.infos.adaptation.id!==e.id||!fe(t.representationIds,I.infos.representation.id))&&Ht(o,{start:(c=I.bufferedStart)!=null?c:I.start,end:(g=I.bufferedEnd)!=null?g:I.end});let s=r.getPendingOperations();for(let I of s)if(I.type===0){let y=I.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!fe(t.representationIds,y.representation.id))){let T=y.segment.time,P=T+y.segment.duration;Ht(o,{start:T,end:P})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let I=i.getReadyState();if(I===void 0||I>1)return{type:\"needs-reload\",value:void 0}}let u=t.switchingMode===\"direct\",d=[],f=Gt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&d.push({start:0,end:n.start+1}),!u){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:I}=L.getCurrent(),y=e.type,T=(p=I[y].before)!=null?p:0,P=(h=I[y].after)!=null?h:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),d.push({start:E-T,end:E+P})}if(n.end!==void 0){let I=Kt(a,n);I!==null&&(I.bufferedStart===void 0||I.bufferedStart-n.end<1)&&d.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Dr(o,d);return l.length===0?{type:\"continue\",value:void 0}:u?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function ba({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentFetcherCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},u,d){let{manifest:f,period:l,adaptation:c}=e,g=new z;g.linkToSignal(d);let p=new Map,h=new j(null,g.signal),I,y=e.representations.getValue().representationIds,T=e.adaptation.representations.filter(w=>fe(y,w.id)&&w.decipherable!==!1&&w.isSupported!==!1),P=new j(T,g.signal),{estimates:E,callbacks:C}=r({manifest:f,period:l,adaptation:c},h,P,n,g.signal),_=a.createSegmentFetcher(c.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics}),x=new j(0);E.onUpdate(({bitrate:w,knownStableBitrate:O})=>{t.enableFastSwitching&&x.setValueIfChanged(O),!(w===void 0||w===I)&&(I=w,m.debug(`Stream: new ${c.type} bitrate estimate`,w),u.bitrateEstimateChange({type:c.type,bitrate:w}))},{emitCurrentValue:!0,clearSignal:g.signal});let A;e.representations.onUpdate(w=>{A!==void 0&&A.cancel();let O=e.representations.getValue().representationIds,N=e.adaptation.representations.filter(V=>fe(O,V.id));P.setValueIfChanged(N),A=new z,A.linkToSignal(g.signal),R(w,A.signal).catch(V=>{(A==null?void 0:A.isUsed())===!0&&z.isCancellationError(V)||(g.cancel(),u.error(V))})},{clearSignal:g.signal,emitCurrentValue:!0});return;async function R(w,O){let N=Ia(l,c,w,i,n);switch(N.type){case\"continue\":break;case\"needs-reload\":return xt(()=>{n.listen(()=>{if(O.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:V}=L.getCurrent(),q=V.bitrateSwitch;return u.waitingMediaSourceReload({bufferType:c.type,period:l,timeOffset:q,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:O})});case\"flush-buffer\":case\"clean-buffer\":for(let V of N.value)if(await i.removeBuffer(V.start,V.end),O.isCancelled())return;if(N.type===\"flush-buffer\"&&(u.needsBufferFlush(),O.isCancelled()))return;break;default:Fe(N)}k(O)}function k(w){let O=new z;O.linkToSignal(w);let{representation:N}=E.getValue();if(N===null)return;let V=new j(null,O.signal);E.onUpdate(K=>{if(!(K.representation===null||K.representation.id===N.id))return K.urgent?(m.info(\"Stream: urgent Representation switch\",c.type),V.setValue({urgent:!0})):(m.info(\"Stream: slow Representation switch\",c.type),V.setValue({urgent:!1}))},{clearSignal:O.signal,emitCurrentValue:!0});let q={type:c.type,adaptation:c,period:l,representation:N};if(h.setValue(N),g.isUsed()||(u.representationChange(q),g.isUsed()))return;let ee={streamStatusUpdate:u.streamStatusUpdate,encryptionDataEncountered:u.encryptionDataEncountered,manifestMightBeOufOfSync:u.manifestMightBeOufOfSync,needsManifestRefresh:u.needsManifestRefresh,inbandEvent:u.inbandEvent,warning:u.warning,error(K){g.cancel(),u.error(K)},addedSegment(K){C.addedSegment(K)},terminating(){if(!O.isUsed())return O.cancel(),k(w)}};M(N,V,ee,w)}function M(w,O,N,V){let q=new z;q.linkToSignal(V);let ee=Xt(o,W=>W*D(w),q.signal),K=c.type===\"video\"?s:new j(1/0);m.info(\"Stream: changing representation\",c.type,w.id,w.bitrate);let G=H({},N,{error(W){var ue;let Q=Ie(W,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(Q.code!==\"BUFFER_FULL_ERROR\")N.error(W);else{let Se=o.getValue(),He=((ue=p.get(w.id))!=null?ue:1)*.7;if(He<=.05||Se*He<=2)throw Q;p.set(w.id,He),nn(4e3,g.signal).then(()=>M(w,O,N,V)).catch(B)}},terminating(){q.cancel(),N.terminating()}});vs({playbackObserver:n,content:{representation:w,adaptation:c,period:l,manifest:f},segmentSink:i,segmentFetcher:_,terminate:O,options:{bufferGoal:ee,maxBufferSize:K,drmSystemId:t.drmSystemId,fastSwitchThreshold:x}},G,V),f.addEventListener(\"manifestUpdate\",W=>{for(let Q of W.updatedPeriods)if(Q.period.id===l.id){for(let ue of Q.result.updatedAdaptations)if(ue.adaptation===c.id){for(let Se of ue.removedRepresentations)if(Se===w.id)return V.isCancelled()?void 0:u.waitingMediaSourceReload({bufferType:c.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(Q.period.start>l.start)break},V)}function D(w){let O=p.get(w.id),N=O!==void 0?O:1;return O===void 0&&p.set(w.id,N),N}}var Cs=ba;function Sa(n,e,t,r,i,a){var g,p,h,I;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!zl(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let y of o)y.infos.period.id===e.id&&y.infos.adaptation.id!==t.id&&Ht(s,{start:(g=y.bufferedStart)!=null?g:y.start,end:(p=y.bufferedEnd)!=null?p:y.end});let u=n.getPendingOperations();for(let y of u)if(y.type===0){let T=y.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let P=T.segment.time,E=P+T.segment.duration;Ht(s,{start:P,end:E})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let y=i.getReadyState();if(y===void 0||y>1)return{type:\"needs-reload\",value:void 0}}let d=r===\"direct\",f=[],l=Gt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!d){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=L.getCurrent(),P=(h=T[y].before)!=null?h:0,E=(I=T[y].after)!=null?I:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),f.push({start:C-P,end:C+E})}if(e.end!==void 0){let y=Kt(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&f.push({start:e.end-1,end:Number.MAX_VALUE})}let c=Dr(s,f);return c.length===0?{type:\"continue\",value:void 0}:d&&t.type!==\"text\"?{type:\"flush-buffer\",value:c}:{type:\"clean-buffer\",value:c}}function zl(n,e){return n.representations.some(t=>t.isSupported===!0&&t.decipherable!==!1&&go(t.getMimeTypeString(),e))}function ya({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentFetcherCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:u,maxVideoBufferSize:d},f,l){let{manifest:c,period:g}=e,p=new j(void 0,l);if(f.periodStreamReady({type:n,manifest:c,period:g,adaptationRef:p}),l.isCancelled())return;let h,I=!0;p.onUpdate(P=>{(async()=>{var w;if(P===void 0)return;let E=new z;if(E.linkToSignal(l),h==null||h.cancel(),h=E,P===null){m.info(`Stream: Set no ${n} Adaptation. P:`,g.start);let O=o.getStatus(n);if(O.type===\"initialized\"){if(m.info(`Stream: Clearing previous ${n} SegmentSink`),St.isNative(n))return T(0,!0,E.signal);{let N=(w=g.end)!=null?w:1/0;if(g.start>N)m.warn(\"Stream: Can't free buffer: period's start is after its end\");else if(await O.value.removeBuffer(g.start,N),E.isUsed())return}}else if(O.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:g}),E.isUsed()?void 0:As(r,u,n,{period:g},f,E.signal)}let C=g.adaptations[n],_=Y(C!=null?C:[],O=>O.id===P.adaptationId);if(_===void 0){h.cancel(),m.warn(\"Stream: Unfound chosen Adaptation choice\",P.adaptationId);return}let{DELTA_POSITION_AFTER_RELOAD:x}=L.getCurrent(),A=!1,R;if(I)R=0;else if(P.relativeResumingPosition!==void 0)R=P.relativeResumingPosition;else switch(A=!0,n){case\"audio\":R=x.trackSwitch.audio;break;case\"video\":R=x.trackSwitch.video;break;default:R=x.trackSwitch.other;break}if(I=!1,St.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(R,!0,E.signal);c.addEventListener(\"manifestUpdate\",O=>{for(let N of O.updatedPeriods)if(N.period.id===g.id){for(let V of N.result.removedAdaptations)if(V.id===_.id)return T(R,!0,E.signal)}else if(N.period.start>g.start)break},h.signal);let{representations:k}=P;if(m.info(`Stream: Updating ${n} adaptation`,`A: ${_.id}`,`P: ${g.start}`),f.adaptationChange({type:n,adaptation:_,period:g}),E.isUsed())return;let M=Wl(o,n,_),D=Sa(M,g,_,P.switchingMode,r,s);if(D.type===\"needs-reload\")return T(R,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(D.type===\"flush-buffer\"||D.type===\"clean-buffer\"){for(let{start:O,end:N}of D.value)if(await M.removeBuffer(O,N),E.isUsed())return;if(D.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:R,relativePosHasBeenDefaulted:A}),E.isUsed()))return}t.get(M)(E.signal),y(_,k,M,E.signal)}})().catch(E=>{E instanceof oe||(h==null||h.cancel(),f.error(E))})},{clearSignal:l,emitCurrentValue:!0});function y(P,E,C,_){let x=ql(r,P.type);Cs({content:{manifest:c,period:g,adaptation:P,representations:E},options:s,playbackObserver:x,representationEstimator:i,segmentSink:C,segmentFetcherCreator:a,wantedBufferAhead:u,maxVideoBufferSize:d},ie(Z({},f),{error:A}),_);function A(R){if(!St.isNative(n)){m.error(`Stream: ${n} Stream crashed. Aborting it.`,R instanceof Error?R:\"\"),o.disposeSegmentSink(n);let k=Ie(R,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(k),_.isCancelled()?void 0:As(r,u,n,{period:g},f,_)}m.error(`Stream: ${n} Stream crashed. Stopping playback.`,R instanceof Error?R:\"\"),f.error(R)}}function T(P,E,C){xt(()=>{r.listen(()=>{C.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:g,timeOffset:P,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:C})})}}function Wl(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return m.info(\"Stream: Reusing a previous SegmentSink for the type\",e),r.value;let i=Vl(t);return n.createSegmentSink(e,i)}function Vl(n){let e=n.representations.filter(t=>t.isSupported===!0&&t.decipherable!==!1);if(e.length===0)throw new $(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[ct(n)]});return e[0].getMimeTypeString()}function ql(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new j(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let u=r.getValue(),d=u.buffered[e],f=d!==null?wr(d,u.position.getWanted()):0;return H({},u,{bufferGap:f,buffered:d})}function s(){a.setValue(o())}})}function As(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(u,{emitCurrentValue:!1,clearSignal:a}),n.listen(u,{includeLastObservation:!1,clearSignal:a}),u();function u(){let d=n.getReference().getValue(),f=e.getValue(),l=d.position.getWanted();o.end!==void 0&&l+f>=o.end&&(m.debug('Stream: full \"empty\" AdaptationStream',t),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var ks=ya;function Lr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory();for(let i=0;i<r.length;i++){let a=r[i];if(e.some(s=>a.infos.period.id===s.period.id&&a.infos.adaptation.id===s.adaptation.id&&a.infos.representation.id===s.representation.id)){let{bufferedStart:s,bufferedEnd:u}=a;if(s===void 0||u===void 0)return m.warn(\"SO: No buffered start or end found from a segment.\"),[{start:0,end:Number.MAX_VALUE}];let d=t[t.length-1];d!==void 0&&d.end===s?d.end=u:t.push({start:s,end:u})}}return t}function Ta(n,e,t,r,i,a,o,s){let{manifest:u,initialPeriod:d}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:c,maxVideoBufferSize:g}=a,{MINIMUM_MAX_BUFFER_AHEAD:p,MAXIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_BEHIND:I}=L.getCurrent(),y=new Cn(E=>{var A,R;let{bufferType:C}=E,_=(A=I[C])!=null?A:1/0,x=(R=h[C])!=null?R:1/0;return k=>{Br({segmentSink:E,playbackObserver:e,maxBufferBehind:Xt(l,M=>Math.min(M,_),k),maxBufferAhead:Xt(f,M=>{var w;let D=Math.max(M,(w=p[C])!=null?w:0);return Math.min(D,x)},k)},k)}});for(let E of r.getBufferTypes())T(E,d);function T(E,C){let _=new Mt((D,w)=>D.start-w.start),x=!1,A=new z;return A.linkToSignal(s),e.listen(({position:D})=>{var N;let w=D.getWanted();if(!x||!k(w))return;for(m.info(\"Stream: Destroying all PeriodStreams due to out of bounds situation\",E,w),x=!1;_.length()>0;){let V=_.get(_.length()-1);_.removeElement(V),o.periodStreamCleared({type:E,manifest:u,period:V})}A.cancel(),A=new z,A.linkToSignal(s);let O=(N=u.getPeriodForTime(w))!=null?N:u.getNextPeriod(w);if(O===void 0){m.warn(\"Stream: The wanted position is not found in the Manifest.\"),x=!0;return}R(O)},{clearSignal:s,includeLastObservation:!0}),u.addEventListener(\"decipherabilityUpdate\",D=>{s.isCancelled()||M(D).catch(w=>{s.isCancelled()||(A.cancel(),o.error(w))})},s),R(C);function R(D){let w=ie(Z({},o),{waitingMediaSourceReload(O){let N=_.head();N===void 0||N.id!==O.period.id?o.lockedStream({bufferType:O.bufferType,period:O.period}):o.needsMediaSourceReload({timeOffset:O.timeOffset,minimumPosition:O.stayInPeriod?O.period.start:void 0,maximumPosition:O.stayInPeriod?O.period.end:void 0})},periodStreamReady(O){x=!0,_.add(O.period),o.periodStreamReady(O)},periodStreamCleared(O){_.removeElement(O.period),o.periodStreamCleared(O)},error(O){A.cancel(),o.error(O)}});P(E,D,w,A.signal)}function k(D){let w=_.head(),O=_.last();return w===void 0||O===void 0?!0:w.start>D||(v(O.end)?1/0:O.end)<D}async function M(D){let w=r.getStatus(E),O=D.filter(G=>G.adaptation.type===E);if(O.length===0||w.type!==\"initialized\"||O.every(G=>G.representation.decipherable===!0))return;let N=w.value,V=O.filter(G=>G.representation.decipherable===void 0),q=O.filter(G=>G.representation.decipherable===!1),ee=Lr(N,q),K=Lr(N,V);for(x=!1,m.info(\"Stream: Destroying all PeriodStreams for decipherability matters\",E);_.length()>0;){let G=_.get(_.length()-1);_.removeElement(G),o.periodStreamCleared({type:E,manifest:u,period:G})}A.cancel(),A=new z,A.linkToSignal(s);for(let{start:G,end:W}of[...ee,...K]){if(s.isCancelled())return;if(G<W){if(s.isCancelled())return;await N.removeBuffer(G,W)}}xt(()=>{if(s.isCancelled())return;let G=e.getReference().getValue();if(xs(G,ee)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(xs(G,K)&&(o.needsBufferFlush(),s.isCancelled()))return;let W=G.position.getWanted(),Q=u.getPeriodForTime(W);if(Q===void 0){o.error(new $(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}R(Q)})}}function P(E,C,_,x){m.info(\"Stream: Creating new Stream for\",E,C.start);let A=null,R=new z;R.linkToSignal(x),e.listen(({position:O},N)=>{if(C.end!==void 0&&O.getWanted()>=C.end){let V=u.getPeriodAfter(C);if(C.containsTime(O.getWanted(),V))return;m.info(\"Stream: Destroying PeriodStream as the current playhead moved above it\",E,C.start,O.getWanted(),C.end),N(),_.periodStreamCleared({type:E,manifest:u,period:C}),R.cancel()}},{clearSignal:x,includeLastObservation:!0});let k={bufferType:E,content:{manifest:u,period:C},garbageCollectors:y,maxVideoBufferSize:g,segmentFetcherCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:c},M=ie(Z({},_),{streamStatusUpdate(O){if(O.hasFinishedLoading){let N=u.getPeriodAfter(C);N!==null&&D(N)}else A!==null&&(m.info(\"Stream: Destroying next PeriodStream due to current one being active\",E,A.period.start),_.periodStreamCleared({type:E,manifest:u,period:A.period}),A.canceller.cancel(),A=null);_.streamStatusUpdate(O)},error(O){A!==null&&(A.canceller.cancel(),A=null),R.cancel(),_.error(O)}});ks(k,M,R.signal),w(R.signal);function D(O){if(A!==null){if(A.period.id===O.id)return;m.warn(\"Stream: Creating next `PeriodStream` while one was already created.\",E,O.id,A.period.id),_.periodStreamCleared({type:E,manifest:u,period:A.period}),A.canceller.cancel()}let N=new z;N.linkToSignal(x),A={canceller:N,period:O},P(E,O,_,A.canceller.signal)}function w(O){u.addEventListener(\"manifestUpdate\",N=>{for(let V of N.removedPeriods)if(V.id===C.id){if(u.periods.length>0&&u.periods[0].start<=V.start)return xt(()=>{if(!O.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(V.start>C.start)break;if(N.addedPeriods.length>0&&A!==null){let V=u.getPeriodAfter(C);(V===null||A.period.id!==V.id)&&(m.warn(\"Stream: Destroying next PeriodStream due to new one being added\",E,A.period.start),_.periodStreamCleared({type:E,manifest:u,period:A.period}),A.canceller.cancel(),A=null)}},O)}}}function xs(n,e){if(e.length===0)return!1;let t=n.position.getPolled();return n.speed>=0?e[e.length-1].end>=t-5:e[0].start<=t+5}var Ms=Ta;var Os=Ms;var Nn=class extends de{constructor(e,t,r){super(),this._canceller=new z,this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new _a(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let u=new $(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",u)}else if(s>i.getMaximumAvailablePosition()){let u=new $(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",u)}},{includeLastObservation:!0,clearSignal:a}),e.addEventListener(\"manifestUpdate\",()=>{this.trigger(\"endingPositionChange\",this._getManifestEndTime()),!a.isCancelled()&&this._checkEndOfStream()},a)}getCurrentEndingTime(){return this._getManifestEndTime()}onAdaptationChange(e,t,r){if(this._manifest.isLastPeriodKnown){let i=this._manifest.periods[this._manifest.periods.length-1];if(t.id===(i==null?void 0:i.id)&&(e===\"audio\"||e===\"video\")){e===\"audio\"?this._maximumPositionCalculator.updateLastAudioAdaptation(r):this._maximumPositionCalculator.updateLastVideoAdaptation(r);let a=this._maximumPositionCalculator.getEndingPosition(),o=a!==void 0?{isEnd:!0,endingPosition:a}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()};this.trigger(\"endingPositionChange\",o)}}this._canceller.isUsed()||r===null&&this._addActivelyLoadedPeriod(t,e)}onRepresentationChange(e,t){this._addActivelyLoadedPeriod(t,e)}onPeriodCleared(e,t){this._removeActivelyLoadedPeriod(t,e)}onLastSegmentFinishedLoading(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod||(t.hasFinishedLoadingLastPeriod=!0,this._checkEndOfStream())}onLastSegmentLoadingResume(e){let t=this._lazilyCreateActiveStreamInfo(e);t.hasFinishedLoadingLastPeriod&&(t.hasFinishedLoadingLastPeriod=!1,this._checkEndOfStream())}dispose(){this.removeEventListener(),this._canceller.cancel()}_addActivelyLoadedPeriod(e,t){let r=this._lazilyCreateActiveStreamInfo(t);r.activePeriods.has(e)||(r.activePeriods.add(e),this._checkCurrentPeriod())}_removeActivelyLoadedPeriod(e,t){let r=this._activeStreams.get(t);r!==void 0&&r.activePeriods.has(e)&&(r.activePeriods.removeElement(e),this._checkCurrentPeriod())}_checkCurrentPeriod(){if(this._allBufferTypes.length===0)return;let e=this._activeStreams.get(this._allBufferTypes[0]);if(e!==void 0)for(let t of e.activePeriods.toArray()){let r=!0;for(let i of this._allBufferTypes){let a=this._activeStreams.get(i);if(a===void 0)return;if(!a.activePeriods.toArray().some(u=>u.id===t.id)){r=!1;break}}if(r){this._lastCurrentPeriodId!==t.id&&(this._lastCurrentPeriodId=t.id,this.trigger(\"periodChange\",t));return}}}_getManifestEndTime(){let e=this._maximumPositionCalculator.getEndingPosition();return e!==void 0?{isEnd:!0,endingPosition:e}:{isEnd:!1,endingPosition:this._maximumPositionCalculator.getMaximumAvailablePosition()}}_lazilyCreateActiveStreamInfo(e){let t=this._activeStreams.get(e);return t===void 0&&(t={activePeriods:new Mt((r,i)=>r.start-i.start),hasFinishedLoadingLastPeriod:!1},this._activeStreams.set(e,t)),t}_checkEndOfStream(){if(!this._manifest.isLastPeriodKnown)return;this._allBufferTypes.every(t=>{let r=this._activeStreams.get(t);return r!==void 0&&r.hasFinishedLoadingLastPeriod})?this.trigger(\"endOfStream\",null):this.trigger(\"resumeStream\",null)}},_a=class{constructor(e){this._manifest=e,this._lastAudioAdaptation=void 0,this._lastVideoAdaptation=void 0}updateLastAudioAdaptation(e){this._lastAudioAdaptation=e}updateLastVideoAdaptation(e){this._lastVideoAdaptation=e}getMaximumAvailablePosition(){if(this._manifest.isDynamic)return this._manifest.getMaximumSafePosition();if(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)return this._manifest.getMaximumSafePosition();if(this._lastAudioAdaptation===null){if(this._lastVideoAdaptation===null)return this._manifest.getMaximumSafePosition();{let e=Fr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Fr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Fr(this._lastAudioAdaptation),t=Fr(this._lastVideoAdaptation);return typeof e!=\"number\"||typeof t!=\"number\"?this._manifest.getMaximumSafePosition():Math.min(e,t)}}getEndingPosition(){var e,t;if(!this._manifest.isDynamic)return this.getMaximumAvailablePosition();if(!(this._lastVideoAdaptation===void 0||this._lastAudioAdaptation===void 0)){if(this._lastAudioAdaptation===null)return this._lastVideoAdaptation===null?void 0:(e=zr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=zr(this._lastAudioAdaptation))!=null?t:void 0;{let r=zr(this._lastAudioAdaptation),i=zr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Fr(n){let{representations:e}=n,t=null,r;for(let i of e)if(i.index!==r){r=i.index;let a=i.index.getLastAvailablePosition();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function zr(n){let{representations:e}=n,t=null,r;for(let i=0;i<e.length;i++)if(e[i].index!==r){r=e[i].index;let a=e[i].index.getEnd();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function Ea(n,e,t,r,i,a){a.register(()=>{e.interruptDurationSetting()});let o=new Nn(n,t,r.getBufferTypes());a.register(()=>{o.dispose()}),o.addEventListener(\"warning\",u=>i.onWarning(u)),o.addEventListener(\"periodChange\",u=>i.onPeriodChanged(u)),o.addEventListener(\"endingPositionChange\",u=>{e.setDuration(u.endingPosition,u.isEnd)}),o.addEventListener(\"endOfStream\",()=>{m.debug(\"Init: end-of-stream order received.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function Ra(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=Y(n.sourceBuffers,s=>s.type===\"audio\"),i=Y(n.sourceBuffers,s=>s.type===\"video\"),a=r==null?void 0:r.getBuffered();a!==void 0&&(t.audio=a);let o=i==null?void 0:i.getBuffered();return o!==void 0&&(t.video=o),t}function Pa(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return m.warn(\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function Hl(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Un(n,e){if(m.debug(\"Init: Trying to call endOfStream\"),n.readyState!==\"open\"){m.debug(\"Init: MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=Hl(t);if(r.length===0){m.info(\"Init: Triggering end of stream\");try{n.endOfStream()}catch(a){m.error(\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}m.debug(\"Init: Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new z;i.linkToSignal(e);for(let a of r)to(a,()=>{i.cancel(),Un(n,e)},i.signal);no(t,()=>{i.cancel(),Un(n,e)},i.signal)}function ws(n,e){let t=new z;t.linkToSignal(e),Bt(n,()=>{m.debug(\"Init: MediaSource re-opened while end-of-stream is active\"),t.cancel(),t=new z,t.linkToSignal(e),Un(n,t.signal)},e),Un(n,t.signal)}function va(){return ti}var Gl=365*24*3600,Ln=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=new z;let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Yl(r,i),o=new z;o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(),!a.getValue())return;o=new z,o.linkToSignal(i);let u=jl(r.sourceBuffers,o.signal),d=new z;return d.linkToSignal(o.signal),u.onUpdate(f=>{d.cancel(),d=new z,d.linkToSignal(o.signal),!f&&Bs(r,e,t,d.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(),this._currentMediaSourceDurationUpdateCanceller=null)}};function Kl(n,e,t){let r=e;t||(r=va()?1/0:Ds(e));let i=0;for(let a=0;a<n.sourceBuffers.length;a++){let o=n.sourceBuffers[a],s=o.buffered.length;s>0&&(i=Math.max(o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{m.info(\"Init: Updating duration to what is currently buffered\",i),n.duration=i}catch(a){return m.warn(\"Duration Updater: Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(m.info(\"Init: Updating duration\",r),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=Ds(e);m.info(\"Init: calling `mediaSource.setLiveSeekableRange`\",s),n.setLiveSeekableRange(0,s)}}catch(s){return m.warn(\"Duration Updater: Can't update duration on the MediaSource.\",s instanceof Error?s:\"\"),\"failed\"}let o=Math.abs(n.duration-r);if(o>=.1){let s=Math.abs(n.duration-a);return o<s?\"partial\":\"failed\"}return\"success\"}}function jl(n,e){if(n.length===0){let i=new j(!1);return i.finish(),i}let t=new j(!1,e);r();for(let i=0;i<n.length;i++){let a=n[i];a.addEventListener(\"updatestart\",r),a.addEventListener(\"update\",r),e.register(()=>{a.removeEventListener(\"updatestart\",r),a.removeEventListener(\"update\",r)})}return t;function r(){for(let i=0;i<n.length;i++)if(n[i].updating){t.setValueIfChanged(!0);return}t.setValueIfChanged(!1)}}function Yl(n,e){let t=new j(n.readyState===\"open\",e);return Bt(n,()=>{m.debug(\"Init: Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),lr(n,()=>{m.debug(\"Init: Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),dr(n,()=>{m.debug(\"Init: Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function Bs(n,e,t,r){if(Kl(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),Bs(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function Ds(n){return Math.max(Math.pow(2,32),n+Gl)}var Fn=class extends de{constructor(e){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new z,v(ei))throw new $(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");m.info(\"Init: Creating MediaSource\");let t=new ei,r=t.handle;this.handle=v(r)?{type:\"media-source\",value:t}:{type:\"handle\",value:r},this._mediaSource=t,this.readyState=t.readyState,this._durationUpdater=new Ln(t),this._endOfStreamCanceller=null,Bt(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),lr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),dr(t,()=>{this.readyState=t.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal)}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Ca(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(){this._durationUpdater.stopUpdating()}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new z,this._endOfStreamCanceller.linkToSignal(this._canceller.signal),m.debug(\"Init: end-of-stream order received.\"),ws(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(m.debug(\"Init: resume-stream order received.\"),this._endOfStreamCanceller.cancel(),this._endOfStreamCanceller=null)}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),Ql(this._mediaSource)}},Ca=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new z,this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=o=>{let s;o instanceof Error?s=o:o.error instanceof Error?s=o.error:s=new Error(\"Unknown SourceBuffer Error\");let u=this._currentOperations;if(this._currentOperations=[],u.length===0)m.error(\"SBI: error for an unknown operation\",s);else{let d=new ve(s.name,s.message,s.name===\"QuotaExceededError\");for(let f of u)f.reject(d)}},a=()=>{let o=this._currentOperations;this._currentOperations=[];try{for(let s of o)s.resolve(da(this._sourceBuffer.buffered))}catch(s){for(let u of o)s instanceof Error&&s.name===\"InvalidStateError\"?u.resolve([]):u.reject(s)}this._performNextOperation()};r.addEventListener(\"updateend\",a),r.addEventListener(\"error\",i),this._canceller.signal.register(()=>{r.removeEventListener(\"updateend\",a),r.removeEventListener(\"error\",i)})}appendBuffer(...e){return m.debug(\"SBI: receiving order to push data to the SourceBuffer\",this.type),this._addToQueue({operationName:0,params:e})}remove(e,t){return m.debug(\"SBI: receiving order to remove data from the SourceBuffer\",this.type,e,t),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return da(this._sourceBuffer.buffered)}catch(e){return m.error(\"Failed to get buffered time range of SourceBuffer\",this.type,e instanceof Error?e:null),[]}}abort(){try{this._sourceBuffer.abort()}catch(e){m.debug(\"Init: Failed to abort SourceBuffer:\",e instanceof Error?e:null)}this._emptyCurrentQueue()}dispose(){try{this._sourceBuffer.abort()}catch(e){}this._emptyCurrentQueue()}_emptyCurrentQueue(){let e=new oe;this._currentOperations.length>0&&(this._currentOperations.forEach(t=>{t.reject(e)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(t=>{t.reject(e)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=H({resolve:t,reject:r},e);this._operationQueue.push(a),i&&this._performNextOperation()})}_performNextOperation(){var t,r,i,a,o;if(this._currentOperations.length!==0||this._sourceBuffer.updating)return;let e=this._operationQueue.shift();if(e!==void 0)if(e.operationName===0){this._currentOperations=[{operationName:0,resolve:e.resolve,reject:e.reject}];let s=e.params[0],u=e.params[1],d=s;if(this._operationQueue.length>0&&this._operationQueue[0].operationName===0){let f;s instanceof ArrayBuffer?f=new Uint8Array(s):s instanceof Uint8Array?f=s:f=new Uint8Array(s.buffer);let l=[f];for(;((t=this._operationQueue[0])==null?void 0:t.operationName)===0;){let c=this._operationQueue[0],g=(r=u.appendWindow)!=null?r:[void 0,void 0],p=(i=c.params[1].appendWindow)!=null?i:[void 0,void 0],h=(a=u.timestampOffset)!=null?a:0,I=(o=c.params[1].timestampOffset)!=null?o:0;if(g[0]===p[0]&&g[1]===p[1]&&u.codec===c.params[1].codec&&h===I){let y=c.params[0],T;y instanceof ArrayBuffer?T=new Uint8Array(y):y instanceof Uint8Array?T=y:T=new Uint8Array(y.buffer),l.push(T),this._operationQueue.splice(0,1),this._currentOperations.push({operationName:0,resolve:c.resolve,reject:c.reject})}else break}l.length>1&&(m.info(`MMSI: Merging ${l.length} segments together for perf`,this.type),d=_t(...l))}try{this._appendBufferNow(d,u)}catch(f){let l=f instanceof Error?new ve(f.name,f.message,f.name===\"QuotaExceededError\"):new ve(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(c=>{c.reject(l)}),this._currentOperations=[]}}else{this._currentOperations=[e];let[s,u]=e.params;m.debug(\"SBI: removing data from SourceBuffer\",this.type,s,u);try{this._sourceBuffer.remove(s,u)}catch(d){let f=d instanceof Error?new ve(d.name,d.message,!1):new ve(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations=[]}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(m.debug(\"SBI: updating codec\",i),Pa(r,i)?this.codec=i:m.debug(\"SBI: could not update codec\",i,this.codec)),a!==void 0&&r.timestampOffset!==a){let s=a;m.debug(\"SBI: updating timestampOffset\",i,r.timestampOffset,s),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(m.debug(\"SBI: re-setting `appendWindowStart` to `0`\"),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;m.debug(\"SBI: pre-updating `appendWindowEnd`\",s),r.appendWindowEnd=s}m.debug(\"SBI: setting `appendWindowStart`\",o[0]),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(m.debug(\"SBI: re-setting `appendWindowEnd` to `Infinity`\"),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(m.debug(\"SBI: setting `appendWindowEnd`\",o[1]),r.appendWindowEnd=o[1]),m.debug(\"SBI: pushing segment\",this.type),r.appendBuffer(e)}};function Ql(n){if(n.readyState!==\"closed\"){let{readyState:e,sourceBuffers:t}=n;for(let r=t.length-1;r>=0;r--){let i=t[r];try{if(e===\"open\"){m.info(\"Init: Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}m.info(\"Init: Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&m.info(\"Init: Not all SourceBuffers could have been removed.\")}}var $l=Ce(),Wr=Ce(),Ns=1/0,zn=class extends de{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z,this.readyState=\"closed\",this._messageSender=r;let i=$l();this._messageSender({type:\"create-media-source\",contentId:t,mediaSourceId:i})}onMediaSourceReadyStateChanged(e){switch(e){case\"closed\":this.readyState=\"closed\",this.trigger(\"mediaSourceClose\",null);break;case\"open\":this.readyState=\"open\",this.trigger(\"mediaSourceOpen\",null);break;case\"ended\":this.readyState=\"ended\",this.trigger(\"mediaSourceEnded\",null);break}}addSourceBuffer(e,t){this._messageSender({type:\"add-source-buffer\",mediaSourceId:this.id,value:{sourceBufferType:e,codec:t}});let r=new Aa(e,t,this.id,this._messageSender);return this.sourceBuffers.push(r),r}setDuration(e,t){this._messageSender({type:\"update-media-source-duration\",mediaSourceId:this.id,value:{duration:e,isRealEndKnown:t}})}interruptDurationSetting(){this._messageSender({type:\"stop-media-source-duration\",mediaSourceId:this.id,value:null})}maintainEndOfStream(){this._messageSender({type:\"end-of-stream\",mediaSourceId:this.id,value:null})}stopEndOfStream(){this._messageSender({type:\"stop-end-of-stream\",mediaSourceId:this.id,value:null})}dispose(){this.sourceBuffers.forEach(e=>e.dispose()),this._canceller.cancel(),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Aa=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new z,this._mediaSourceId=r,this._queuedOperations=[],this._pendingOperations=new Map,this._messageSender=i}onOperationSuccess(e,t){let r=this._pendingOperations.get(e);r===void 0?m.warn(\"SBI: unknown SourceBuffer operation succeeded\"):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new oe:new ve(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?m.info(\"SBI: unknown SourceBuffer operation failed\",r):(this._pendingOperations.delete(e),i.reject(r));let a=new oe;for(let o of this._queuedOperations)o.reject(a);this._queuedOperations=[]}appendBuffer(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=Ns){this._queuedOperations.push({operationName:0,params:[e,t],resolve:r,reject:i});return}try{let a;e instanceof ArrayBuffer?a=e:e.byteLength===e.buffer.byteLength?a=e.buffer:a=e.buffer.slice(e.byteOffset,e.byteLength+e.byteOffset);let o=Wr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:o,value:{data:a,params:t}},[a]),this._addOperationToQueue(o,r,i)}catch(a){i(a)}})}remove(e,t){return new Promise((r,i)=>{if(this._queuedOperations.length>0||this._pendingOperations.size>=Ns){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Wr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{start:e,end:t}}),this._addOperationToQueue(a,r,i)}catch(a){i(a)}})}abort(){this._messageSender({type:\"abort-source-buffer\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,value:null})}dispose(){this.abort(),this._canceller.cancel()}getBuffered(){}_addOperationToQueue(e,t,r){this._pendingOperations.set(e,{resolve:a,reject:o});let i=this._canceller.signal.register(s=>{this._pendingOperations.delete(e),r(s)});function a(s){i(),t(s)}function o(s){i(),r(s)}}_performNextQueuedOperationIfItExists(){let e=this._queuedOperations.shift();if(e!==void 0)try{if(e.operationName===0){let[t,r]=e.params,i;t instanceof ArrayBuffer?i=t:t.byteLength===t.buffer.byteLength?i=t.buffer:i=t.buffer.slice(t.byteOffset,t.byteLength+t.byteOffset);let a=Wr();this._messageSender({type:\"source-buffer-append\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:a,value:{data:i,params:r}},[i]),this._addOperationToQueue(a,e.resolve,e.reject)}else{let[t,r]=e.params,i=Wr();this._messageSender({type:\"source-buffer-remove\",mediaSourceId:this._mediaSourceId,sourceBufferType:this.type,operationId:i,value:{start:t,end:r}}),this._addOperationToQueue(i,e.resolve,e.reject)}}catch(t){e.reject(t)}}};function ka(n){let e=n.map(o=>Math.log(o/n[0])),t=e.map(o=>o-e[0]+1),r=(t[t.length-1]-1)/(n.length*2+10),i=1/r;return n.map((o,s)=>a(s));function a(o){if(o===0)return 0;let s=Math.min(Math.max(1,o),n.length-1);return n[s]===n[s-1]?a(o-1):i*(r+(n[s]*t[s-1]-n[s-1]*t[s])/(n[s]-n[s-1]))+4}}var Ue=class{constructor(e){this._alpha=Math.exp(Math.log(.5)/e),this._lastEstimate=0,this._totalWeight=0}addSample(e,t){let r=Math.pow(this._alpha,e),i=t*(1-r)+r*this._lastEstimate;isNaN(i)||(this._lastEstimate=i,this._totalWeight+=e)}getEstimate(){let e=1-Math.pow(this._alpha,this._totalWeight);return this._lastEstimate/e}};var Wn=class{constructor(){this._currentRepresentationData=null,this._lastRepresentationWithGoodScore=null}addSample(e,t,r){let i=r/t,a=this._currentRepresentationData,o;a!==null&&a.representation.id===e.id?(o=a.ewma,a.ewma.addSample(t,i),a.loadedDuration+=r,a.loadedSegments++):(o=new Ue(5),o.addSample(t,i),this._currentRepresentationData={representation:e,ewma:o,loadedDuration:r,loadedSegments:0}),o.getEstimate()>1&&this._lastRepresentationWithGoodScore!==e&&(m.debug(\"ABR: New last stable representation\",e.bitrate),this._lastRepresentationWithGoodScore=e)}getEstimate(e){if(this._currentRepresentationData===null||this._currentRepresentationData.representation.id!==e.id)return;let{ewma:t,loadedSegments:r,loadedDuration:i}=this._currentRepresentationData,a=t.getEstimate(),o=r>=5&&i>=10?1:0;return{score:a,confidenceLevel:o}}getLastStableRepresentation(){return this._lastRepresentationWithGoodScore}};var Us=6e3,Xl=15e3,Zl=3e3,Jl=1e3,ef=9e3,Vn=class{constructor(e){this._levelsMap=ka(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=Us,m.debug(\"ABR: Steps for buffer based chooser.\",this._levelsMap.map((t,r)=>`bufferLevel: ${t}, bitrate: ${e[r]}`).join(\" ,\"))}onAddedSegment(e){let t=this._levelsMap,r=this._bitrates,{bufferGap:i,currentBitrate:a,currentScore:o,speed:s}=e;if(v(a)){this._currentEstimate=r[0];return}let u=-1;for(let p=0;p<r.length;p++){let h=r[p];if(h===a)u=p;else if(h>a)break}if(u<0||r.length!==t.length){m.info(\"ABR: Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let d;o!==void 0&&(d=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=U();if(f<t[u]||d!==void 0&&d<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+ef){let I=this._blockRaiseDelay+Zl;this._blockRaiseDelay=Math.min(I,Xl),m.debug(\"ABR: Incrementing blocking raise in BufferBasedChooser due to unstable quality\",this._blockRaiseDelay)}else{let I=this._blockRaiseDelay-Jl;this._blockRaiseDelay=Math.max(Us,I),m.debug(\"ABR: Lowering quality in BufferBasedChooser\",this._blockRaiseDelay)}this._lastUnsuitableQualityTimestamp=l;let h=re(r,I=>I===a);for(let I=h-1;I>=0;I--)if(f>=t[I]){this._currentEstimate=r[I];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||d===void 0||d<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let c=t[u],g=(()=>{for(let p=u+1;p<t.length;p++)if(t[p]>c)return p})();if(g!==void 0){let p=t[g];if(i>=p){m.debug(\"ABR: Raising quality in BufferBasedChooser\",r[g]),this._currentEstimate=r[g];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function tf(n,e){let t=-1;for(let o=0;o<n.length;o++){let{segment:s}=n[o].content;if(s.duration<=0)continue;let u=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(u>e&&e-s.time>-1.2){t=o;break}}if(t<0)return[];let r=n[t],i=r.content.segment.time,a=[r];for(let o=t+1;o<n.length&&n[o].content.segment.time===i;o++)a.push(n[o]);return a}function Vr(n){if(n.progress.length<5)return;let e=new Ue(2),{progress:t}=n;for(let r=1;r<t.length;r++){let i=t[r].size-t[r-1].size,a=t[r].timestamp-t[r-1].timestamp,o=i*8/(a/1e3);e.addSample(a/1e3,o)}return e.getEstimate()}function Ls(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function nf(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,u=isFinite(a)?a:0,d=s.getWanted()+u,f=tf(n,d);if(f.length!==1)return;let l=f[0],c=U(),g=l.content.segment.duration*1.5;if(g=Math.min(g,3e3),g=Math.max(g,12e3),c-l.requestTimestamp<g)return;let p=l.progress.length>0?l.progress[l.progress.length-1]:void 0,h=Vr(l);if(p!==void 0&&h!==void 0){let C=Ls(p,h);if((c-p.timestamp)/1e3<=C&&C-u/o>2500)return h}if(!l.content.segment.complete)return;let I=l.content.segment.duration,y=(c-l.requestTimestamp)/1e3,T=y<=(I*1.5+2)/o;if(v(t)||T)return;let P=I/y,E=t.bitrate*Math.min(.7,P);if(i===void 0||E<i)return E}function rf(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=Y(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=U(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,u=Vr(a);if(s===void 0||u===void 0)return!0;let d=Ls(s,u);return(o-s.timestamp)/1e3>d*1.2?!0:d-r/n.speed>-1.5}var qn=class{constructor(e,t){let{ABR_STARVATION_GAP:r,OUT_OF_STARVATION_GAP:i,ABR_STARVATION_FACTOR:a,ABR_REGULAR_FACTOR:o}=L.getCurrent();this._initialBitrate=e,this._inStarvationMode=!1,this._lowLatencyMode=t,t?this._config={starvationGap:r.LOW_LATENCY,outOfStarvationGap:i.LOW_LATENCY,starvationBitrateFactor:a.LOW_LATENCY,regularBitrateFactor:o.LOW_LATENCY}:this._config={starvationGap:r.DEFAULT,outOfStarvationGap:i.DEFAULT,starvationBitrateFactor:a.DEFAULT,regularBitrateFactor:o.DEFAULT}}getBandwidthEstimate(e,t,r,i,a){let o,s,u=this._config,{bufferGap:d,position:f,duration:l}=e,c=isFinite(d)?d:0,{ABR_STARVATION_DURATION_DELTA:g}=L.getCurrent();return isNaN(l)||c+f.getWanted()<l-g?!this._inStarvationMode&&c<=u.starvationGap?(m.info(\"ABR: enter starvation mode.\"),this._inStarvationMode=!0):this._inStarvationMode&&c>=u.outOfStarvationGap&&(m.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1):this._inStarvationMode&&(m.info(\"ABR: exit starvation mode.\"),this._inStarvationMode=!1),this._inStarvationMode&&(s=nf(i,e,r,this._lowLatencyMode,a),s!==void 0&&(m.info(\"ABR: starvation mode emergency estimate:\",s),t.reset(),o=v(r)?s:Math.min(s,r.bitrate))),v(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?u.starvationBitrateFactor:u.regularBitrateFactor):o=this._initialBitrate),e.speed>1&&(o/=e.speed),{bandwidthEstimate:s,bitrateChosen:o}}isUrgent(e,t,r,i){return t===null?!0:e>=t.bitrate?!1:rf(i,r,this._lowLatencyMode)}};var Hn=class{constructor(){this.bandwidth=void 0,this.representation=null,this.algorithmType=3}update(e,t,r){this.representation=e,this.bandwidth=t,this.algorithmType=r}};var Gn=class{constructor(e,t){this._scoreCalculator=e,this._lastAbrEstimate=t,this._consecutiveWrongGuesses=0,this._blockGuessesUntil=0,this._lastMaintanableBitrate=null}getGuess(e,t,r,i,a){let{bufferGap:o,speed:s}=t,u=this._lastAbrEstimate.representation;if(u===null)return null;if(i>u.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let d=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(d===void 0)return null;if(this._canGuessHigher(o,s,d)){let l=Fs(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(u,i,d)&&(m.debug(\"ABR: Guessed Representation validated\",u.bitrate),this._lastMaintanableBitrate=u.bitrate,this._consecutiveWrongGuesses=0),r.id!==u.id)return u;if(this._shouldStopGuess(r,d,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=U()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),af(e,r);if(d===void 0)return r;if(this._canGuessHigher(o,s,d)){let l=Fs(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&U()>this._blockGuessesUntil&&i===1&&r/t>1.01}_shouldStopGuess(e,t,r,i){if(t!==void 0&&t.score<1.01)return!0;if((t===void 0||t.score<1.2)&&r<.6)return!0;let a=i.filter(s=>s.content.representation.id===e.id),o=U();for(let s of a){let u=o-s.requestTimestamp;if(s.content.segment.isInit){if(u>1e3)return!0}else{if(u>s.content.segment.duration*1e3+200)return!0;{let d=Vr(s);if(d!==void 0&&d<e.bitrate*.8)return!0}}}return!1}_isLastGuessValidated(e,t,r){return r!==void 0&&r.confidenceLevel===1&&r.score>1.5?!0:t>=e.bitrate&&(this._lastMaintanableBitrate===null||this._lastMaintanableBitrate<e.bitrate)}};function Fs(n,e){let t=n.length,r=re(n,({id:i})=>i===e.id);if(r<0)return m.error(\"ABR: Current Representation not found.\"),null;for(;++r<t;)if(n[r].bitrate>e.bitrate)return n[r];return null}function af(n,e){let t=re(n,({id:r})=>r===e.id);if(t<0)return m.error(\"ABR: Current Representation not found.\"),null;for(;--t>=0;)if(n[t].bitrate<e.bitrate)return n[t];return null}var Kn=class{constructor(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=L.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}addSample(e,t){let{ABR_MINIMUM_CHUNK_SIZE:r}=L.getCurrent();if(t<r)return;let i=t*8e3/e,a=e/1e3;this._bytesSampled+=t,this._fastEWMA.addSample(a,i),this._slowEWMA.addSample(a,i)}getEstimate(){let{ABR_MINIMUM_TOTAL_BYTES:e}=L.getCurrent();if(!(this._bytesSampled<e))return Math.min(this._fastEWMA.getEstimate(),this._slowEWMA.getEstimate())}reset(){let{ABR_FAST_EMA:e,ABR_SLOW_EMA:t}=L.getCurrent();this._fastEWMA=new Ue(e),this._slowEWMA=new Ue(t),this._bytesSampled=0}};function xa(n,e){if(n.length===0)return[];n.sort((a,o)=>a.bitrate-o.bitrate);let t=n[0].bitrate,r=Math.max(e,t),i=re(n,a=>a.bitrate>r);return i===-1?n:n.slice(0,i)}function Ma(n,e){if(e.width===void 0||e.height===void 0)return n;let t=e.width*e.pixelRatio,r=e.height*e.pixelRatio,i=n.slice().sort((s,u)=>{var d,f;return((d=s.width)!=null?d:0)-((f=u.width)!=null?f:0)}),a=Y(i,s=>typeof s.width==\"number\"&&s.width>=t&&typeof s.height==\"number\"&&s.height>=r);if(a===void 0)return n;let o=typeof a.width==\"number\"?a.width:0;return n.filter(s=>typeof s.width==\"number\"?s.width<=o:!0)}var jn=class{constructor(){this._currentRequests={}}add(e){let{id:t,requestTimestamp:r,content:i}=e;this._currentRequests[t]={requestTimestamp:r,progress:[],content:i}}addProgress(e){let t=this._currentRequests[e.id];if(v(t)){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: progress for a request not added\");m.warn(\"ABR: progress for a request not added\");return}t.progress.push(e)}remove(e){if(v(this._currentRequests[e])){if(b.CURRENT_ENV===b.DEV)throw new Error(\"ABR: can't remove unknown request\");m.warn(\"ABR: can't remove unknown request\")}delete this._currentRequests[e]}getRequests(){return gr(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function qr(n,e){let t=re(n,r=>r.bitrate>e);return t===-1?n[n.length-1]:t===0?n[0]:n[t-1]}var zs=new j(void 0);zs.finish();var Ws=new j(1/0);Ws.finish();function Oa(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,u,d,f,l){var I,y,T;let{type:c}=s.adaptation,g=a(c),p=(I=t[c])!=null?I:0,h={limitResolution:(y=r.limitResolution[c])!=null?y:zs,throttleBitrate:(T=r.throttleBitrate[c])!=null?T:Ws};return of({bandwidthEstimator:g,context:s,currentRepresentation:u,filters:h,initialBitrate:p,playbackObserver:f,representations:d,lowLatencyMode:i},l)};function a(o){let s=e[o];if(v(s)){m.debug(\"ABR: Creating new BandwidthEstimator for \",o);let u=new Kn;return e[o]=u,u}return s}}function of({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},u){let d=new Wn,f=new qn(i!=null?i:0,a),l=new jn,c=B,g={metrics:T,requestBegin:P,requestProgress:E,requestEnd:C,addedSegment(_){c(_)}},p=new z;p.linkToSignal(u);let h=I(s.getValue(),p.signal);return s.onUpdate(y,{clearSignal:u}),{estimates:h,callbacks:g};function I(_,x){if(_.length<=1)return new j({bitrate:void 0,representation:_[0],urgent:!0,knownStableBitrate:void 0});let A=!1,R=_.sort((q,ee)=>q.bitrate-ee.bitrate),k=new Vn(R.map(q=>q.bitrate)),M=new Hn,D=new Gn(d,M),w=o.getReference().getValue(),O=new j(V());return o.listen(q=>{w=q,N()},{includeLastObservation:!1,clearSignal:x}),c=function(q){if(w===null)return;let{position:ee,speed:K}=w,G=q.buffered,W=wr(G,ee.getWanted()),{representation:Q}=q.content,ue=d.getEstimate(Q),Se=Q.bitrate,ce={bufferGap:W,currentBitrate:Se,currentScore:ue,speed:K};k.onAddedSegment(ce),N()},x.register(()=>{c=B}),r.throttleBitrate.onUpdate(N,{clearSignal:x}),r.limitResolution.onUpdate(N,{clearSignal:x}),O;function N(){O.setValue(V())}function V(){let{bufferGap:q,position:ee,maximumPosition:K}=w,G=r.limitResolution.getValue(),W=r.throttleBitrate.getValue(),Q=t.getValue(),ue=sf(R,G,W),Se=l.getRequests(),{bandwidthEstimate:ce,bitrateChosen:He}=f.getBandwidthEstimate(w,n,Q,Se,M.bandwidth),we=d.getLastStableRepresentation(),ge=we===null?void 0:we.bitrate/(w.speed>0?w.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:ye,ABR_EXIT_BUFFER_BASED_ALGO:Qt}=L.getCurrent();A&&q<=Qt?A=!1:!A&&isFinite(q)&&q>=ye&&(A=!0);let Ge=qr(ue,He),ke=k.getLastEstimate(),Ot=Ge.bitrate,st=null;A&&ke!==void 0&&ke>Ot&&(st=qr(ue,ke),Ot=st.bitrate);let ut=null;return a&&Q!==null&&e.manifest.isDynamic&&K-ee.getWanted()<40&&(ut=D.getGuess(R,w,Q,Ot,Se)),ut!==null&&ut.bitrate>Ot?(m.debug(\"ABR: Choosing representation with guess-based estimation.\",ut.bitrate,ut.id),M.update(ut,ce,2),{bitrate:ce,representation:ut,urgent:Q===null||ut.bitrate<Q.bitrate,knownStableBitrate:ge}):st!==null?(m.debug(\"ABR: Choosing representation with buffer-based estimation.\",st.bitrate,st.id),M.update(st,ce,0),{bitrate:ce,representation:st,urgent:f.isUrgent(st.bitrate,Q,Se,w),knownStableBitrate:ge}):(m.debug(\"ABR: Choosing representation with bandwidth estimation.\",Ge.bitrate,Ge.id),M.update(Ge,ce,1),{bitrate:ce,representation:Ge,urgent:f.isUrgent(Ge.bitrate,Q,Se,w),knownStableBitrate:ge})}}function y(){let _=s.getValue();p.cancel(),p=new z,p.linkToSignal(u),I(_,p.signal).onUpdate(function(R){h.setValue(R)},{clearSignal:p.signal,emitCurrentValue:!0})}function T(_){let{requestDuration:x,segmentDuration:A,size:R,content:k}=_;if(n.addSample(x,R),!k.segment.isInit){let{segment:M,representation:D}=k;if(A===void 0&&!M.complete)return;let w=A!=null?A:M.duration;d.addSample(D,x/1e3,w)}}function P(_){l.add(_)}function E(_){l.addProgress(_)}function C(_){l.remove(_.id)}}function sf(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=xa(r,t)),e!==void 0&&(r=Ma(r,e)),r}var Vs=Oa;function Hr(){var t;if(typeof((t=se.crypto)==null?void 0:t.randomUUID)==\"function\")return se.crypto.randomUUID();let n=new Date().getTime(),e=U();return\"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g,function(r){let i=Math.random()*16;return n>0?(i=(n+i)%16|0,n=Math.floor(n/16)):(i=(e+i)%16|0,e=Math.floor(e/16)),(r===\"x\"?i:i&3|8).toString(16)})}var uf=4,Yn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Hr(),this._contentId=(r=e.contentId)!=null?r:Hr(),this._typePreference=e.communicationType===\"headers\"?0:1,this._bufferStarvationToggle=!1,this._playbackObserver=null,this._lastThroughput={},this._canceller=null}startMonitoringPlayback(e){var t;(t=this._canceller)==null||t.cancel(),this._canceller=new z,this._playbackObserver=e,e.listen(r=>{r.rebuffering!==null&&(this._bufferStarvationToggle=!0)},{includeLastObservation:!0,clearSignal:this._canceller.signal})}stopMonitoringPlayback(){var e;(e=this._canceller)==null||e.cancel(),this._canceller=null,this._playbackObserver=null}updateThroughput(e,t){this._lastThroughput[e]=t}_getCommonCmcdData(e){var i;let t={};t.bs=this._bufferStarvationToggle,this._bufferStarvationToggle=!1,t.cid=this._contentId,t.mtp=e!==void 0?Math.floor(Math.round(e/1e3/100)*100):void 0,t.sid=this._sessionId;let r=(i=this._playbackObserver)==null?void 0:i.getReference().getValue();return t.pr=r===void 0||r.speed===1?void 0:r.speed,r!==void 0&&(t.su=r.rebuffering!==null),t}getCmcdDataForManifest(e){var r;let t=this._getCommonCmcdData((r=this._lastThroughput.video)!=null?r:this._lastThroughput.audio);switch(t.ot=\"m\",e){case\"dash\":t.sf=\"d\";break;case\"smooth\":t.sf=\"s\";break;default:t.sf=\"o\";break}return this._producePayload(t)}getCmcdDataForSegmentRequest(e){var o,s,u,d;let t=(o=this._playbackObserver)==null?void 0:o.getReference().getValue(),r=this._getCommonCmcdData(this._lastThroughput[e.adaptation.type]);switch(r.br=Math.round(e.representation.bitrate/1e3),r.d=Math.round(e.segment.duration*1e3),e.adaptation.type){case\"video\":r.ot=\"v\";break;case\"audio\":r.ot=\"a\";break;case\"text\":r.ot=\"c\";break}e.segment.isInit&&(r.ot=\"i\");let i;if(t!==void 0&&(r.ot===\"v\"||r.ot===\"a\"||r.ot===\"av\")){let f=t.buffered[e.adaptation.type];if(!v(f)){let l=(d=(u=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?u:t.position.getWanted())!=null?d:t.position.getPolled();for(let c of f)if(l>=c.start&&l<c.end){i=(c.end-l)*1e3,r.bl=Math.floor(Math.round(i/100)*100);break}}}let a=i===void 0||t===void 0?void 0:i/t.speed;if(r.dl=a===void 0?void 0:Math.floor(Math.round(a/100)*100),a!==void 0){let l=e.representation.bitrate*e.segment.duration/1e3/(a/1e3);r.rtp=Math.floor(Math.round(l*uf/100)*100)}switch(e.manifest.transport){case\"dash\":r.sf=\"d\";break;case\"smooth\":r.sf=\"s\";break;default:r.sf=\"o\";break}return r.st=e.manifest.isDynamic?\"l\":\"v\",r.tb=e.adaptation.representations.reduce((f,l)=>l.isSupported!==!0||l.decipherable===!1?f:f===void 0?Math.round(l.bitrate/1e3):Math.max(f,Math.round(l.bitrate/1e3)),void 0),this._producePayload(r)}_producePayload(e){let t={object:\"\",request:\"\",session:\"\",status:\"\"},r=\"\",i=(d,f)=>{this._typePreference===0?t[f]+=d:r+=d},a=(d,f)=>{let l=e[d];if(l!==void 0){let c=`${d}=${String(l)},`;i(c,f)}},o=(d,f)=>{if(e[d]===!0){let l=`${d},`;i(l,f)}},s=(d,f)=>{let l=e[d];if(l!==void 0){let g=`prop=${`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`},`;i(g,f)}},u=(d,f)=>{let l=e[d];if(l!==void 0){let c=`prop=${l},`;i(c,f)}};return a(\"br\",\"object\"),a(\"bl\",\"request\"),o(\"bs\",\"status\"),s(\"cid\",\"session\"),a(\"d\",\"object\"),a(\"dl\",\"request\"),a(\"mtp\",\"request\"),u(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),u(\"sf\",\"session\"),s(\"sid\",\"session\"),u(\"st\",\"session\"),o(\"su\",\"request\"),a(\"tb\",\"object\"),this._typePreference===0?(t.object[t.object.length-1]===\",\"&&(t.object=t.object.substring(0,t.object.length-1)),t.request[t.request.length-1]===\",\"&&(t.request=t.request.substring(0,t.request.length-1)),t.session[t.session.length-1]===\",\"&&(t.session=t.session.substring(0,t.session.length-1)),t.status[t.status.length-1]===\",\"&&(t.status=t.status.substring(0,t.status.length-1)),m.debug(\"CMCD: proposing headers payload\"),{type:\"headers\",value:{\"CMCD-Object\":t.object,\"CMCD-Request\":t.request,\"CMCD-Session\":t.session,\"CMCD-Status\":t.status}}):(r[r.length-1]===\",\"&&(r=r.substring(0,r.length-1)),r=encodeURIComponent(r),m.debug(\"CMCD: proposing query string payload\",r),{type:\"query\",value:[[\"CMCD\",r]]})}};var qs=Yn;function ot(n){return n instanceof ae?new je(\"PIPELINE_LOAD_ERROR\",n):Ie(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function df(n){return n instanceof ae?n.type===yt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===yt.TIMEOUT||n.type===yt.ERROR_EVENT:n instanceof Ke?typeof n.canRetry==\"boolean\"?n.canRetry:n.xhr!==void 0?n.xhr.status>=500||n.xhr.status===404||n.xhr.status===415||n.xhr.status===412:!1:Dt(n)&&n.code===\"INTEGRITY_ERROR\"}async function wa(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:u}=r;n!==null&&n.length===0&&m.warn(\"Fetchers: no CDN given to `scheduleRequestWithCdns`.\");let d=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return c(f);function l(){if(n===null){let I=d.get(null);return I!==void 0&&I.isBlacklisted?void 0:null}else{if(e===null)return h(n);{let I=e.getCdnPreferenceForResource(n);return h(I)}}}async function c(I){try{return await t(I,i)}catch(y){if(z.isCancellationError(y))throw y;I!==null&&e!==null&&e.downgradeCdn(I);let T=d.get(I);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},d.set(I,T)):T.errorCounter++,!df(y))return T.blockedUntil=void 0,T.isBlacklisted=!0,g(y);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let P=T.errorCounter,E=Math.min(a*Math.pow(2,P-1),o),C=gi(E);T.blockedUntil=U()+C}return g(y)}}async function g(I){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw I;if(u(I),i.isCancelled())throw i.cancellationError;return p(y,I)}function p(I,y){let T=d.get(I);if(T===void 0||T.blockedUntil===void 0)return c(I);let P=U(),E=T.blockedUntil-P;if(E<=0)return c(I);let C=new z,_=C.linkToSignal(i);return new Promise((x,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let M=l();if(i.isCancelled())throw i.cancellationError;if(M===void 0)return k(y);M!==I&&(C.cancel(),p(M,y).then(R,k))},C.signal),nn(E,C.signal).then(()=>c(I).then(R,k),B);function R(M){_(),x(M)}function k(M){_(),A(M)}})}function h(I){var T;if(d.size===0)return I[0];let y=U();return(T=I.filter(P=>{var E;return((E=d.get(P))==null?void 0:E.isBlacklisted)!==!0}).reduce((P,E)=>{var _;let C=(_=d.get(E))==null?void 0:_.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),P===void 0?[E,C]:P[1]===void 0?P:C===void 0?[E,void 0]:C<P[1]?[E,C]:P},void 0))==null?void 0:T[0]}}function Da(n,e,t){return wa(null,null,n,e,t)}var Qn=class extends de{constructor(e,t,r){super(),this.scheduleManualRefresh=B,this._manifestUrls=e,this._pipelines=t.manifest,this._transportName=t.transportName,this._settings=r,this._canceller=new z,this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(){this._canceller.cancel(),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof Lt?e=Promise.resolve({manifest:t}):t!==void 0?e=this.parse(t,{previousManifest:null,unsafeMode:!1},void 0):e=this._fetchManifest(void 0).then(r=>r.parse({previousManifest:null,unsafeMode:!1})),e.then(r=>{this.trigger(\"manifestReady\",r.manifest),this._canceller.isUsed()||this._recursivelyRefreshManifest(r.manifest,r)}).catch(r=>this._onFatalError(r))}updateContentUrls(e,t){var r;this._prioritizedContentUrl=(r=e==null?void 0:e[0])!=null?r:void 0,t&&this.scheduleManualRefresh({enablePartialRefresh:!1,delay:0,canUseUnsafeMode:!1})}async _fetchManifest(e){var d;let t=this._canceller.signal,r=this._settings,i=this._transportName,a=this._pipelines,o=e!=null?e:(d=this._manifestUrls)==null?void 0:d[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",ot(f))});try{let f=await u(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw ot(f)}function u(f){var I;let{loadManifest:l}=a,c=r.requestTimeout===void 0?L.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,g=r.connectionTimeout===void 0?L.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;c<0&&(c=void 0),g<0&&(g=void 0);let p={timeout:c,connectionTimeout:g,cmcdPayload:(I=r.cmcdDataBuilder)==null?void 0:I.getCmcdDataForManifest(i)};return Da(()=>l(f,p,t),s,t)}}parse(e,t,r){return this._parseLoadedManifest({responseData:e,size:void 0,requestDuration:void 0},t,r)}async _parseLoadedManifest(e,t,r){var h;let i=U(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:u}=e,d=this._getBackoffSetting(I=>{this.trigger(\"warning\",ot(I))}),f=r!=null?r:(h=this._manifestUrls)==null?void 0:h[0],l={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:f};try{let I=this._pipelines.parseManifest(e,l,g,a,c);if(lf(I)){let{manifest:y,warnings:T}=await I;return p(y,T)}else return p(I.manifest,I.warnings)}catch(I){throw Ie(I,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function c(I){try{return await Da(I,d,a)}catch(y){throw ot(y)}}function g(I){for(let y of I){if(a.isCancelled())return;let T=Ie(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function p(I,y){g(y);let T=U()-i;return m.info(`MF: Manifest parsed in ${T}ms`),{manifest:I,sendingTime:s,receivedTime:u,parsingTime:T}}}_getBackoffSetting(e){let{DEFAULT_MAX_MANIFEST_REQUEST_RETRY:t,INITIAL_BACKOFF_DELAY_BASE:r,MAX_BACKOFF_DELAY_BASE:i}=L.getCurrent(),{lowLatencyMode:a,maxRetry:o}=this._settings,s=a?r.LOW_LATENCY:r.REGULAR,u=a?i.LOW_LATENCY:i.REGULAR,d=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:u,maxRetry:d}}_recursivelyRefreshManifest(e,{sendingTime:t,parsingTime:r,updatingTime:i}){let{MAX_CONSECUTIVE_MANIFEST_PARSING_IN_UNSAFE_MODE:a,MIN_MANIFEST_PARSING_TIME_TO_ENTER_UNSAFE_MODE:o}=L.getCurrent(),s=r!==void 0?r+(i!=null?i:0):void 0,u=!1;this._consecutiveUnsafeMode>0?u=this._consecutiveUnsafeMode<a:s!==void 0&&(u=s>=o);let d=t===void 0?0:U()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-d,0),l=new z;if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=c=>{let{enablePartialRefresh:g,delay:p,canUseUnsafeMode:h}=c,I=h&&u,y=t===void 0?0:U()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),P=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:g,unsafeMode:I})},Math.max((p!=null?p:0)-y,T));l.signal.register(()=>{clearTimeout(P)})},e.expired!==null){let c=setTimeout(()=>{var g;(g=e.expired)==null||g.then(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},B)},f);l.signal.register(()=>{clearTimeout(c)})}if(e.lifetime!==void 0&&e.lifetime>=0){let c=e.lifetime*1e3-d,g;s===void 0?g=c:e.lifetime<3&&s>=100?(g=Math.min(Math.max(3e3-d,Math.max(c,0)+s),c*6),m.info(\"MUS: Manifest update rythm is too frequent. Postponing next request.\",c,g)):s>=e.lifetime*1e3/10?(g=Math.min(Math.max(c,0)+s,c*6),m.info(\"MUS: Manifest took too long to parse. Postponing next request\",g,g)):g=c;let p=setTimeout(()=>{l.cancel(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:u})},Math.max(g,f));l.signal.register(()=>{clearTimeout(p)})}}_triggerNextManifestRefresh(e,{enablePartialRefresh:t,unsafeMode:r}){let i=e.updateUrl,a,o;this._prioritizedContentUrl!==null?(a=!0,o=this._prioritizedContentUrl,this._prioritizedContentUrl=null):(a=!t||i===void 0,o=a?e.getUrls()[0]:i);let s=e.clockOffset;r?(this._consecutiveUnsafeMode+=1,m.info('Init: Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(m.info('Init: Not parsing the Manifest in \"unsafeMode\" anymore after '+String(this._consecutiveUnsafeMode)+\" consecutive times.\"),this._consecutiveUnsafeMode=0),!this._isRefreshPending&&(this._isRefreshPending=!0,this._fetchManifest(o).then(u=>u.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(u=>{this._isRefreshPending=!1;let{manifest:d,sendingTime:f,parsingTime:l}=u,c=U();if(a)e.replace(d);else try{e.update(d)}catch(p){let h=p instanceof Error?p.message:\"unknown error\";m.warn(`MUS: Attempt to update Manifest failed: ${h}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:I}=L.getCurrent(),y=f===void 0?0:U()-f,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),P=B,E=setTimeout(()=>{P(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(I-y,T));P=this._canceller.signal.register(()=>{clearTimeout(E)});return}let g=U()-c;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:g})}).catch(u=>{this._isRefreshPending=!1,this._onFatalError(u)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose())}};function lf(n){return n instanceof Promise}var Ba=Qn;var $n=class extends de{constructor(e){super(),this._downgradedCdnList={metadata:[],timeouts:[]},e.register(()=>{for(let t of this._downgradedCdnList.timeouts)clearTimeout(t);this._downgradedCdnList={metadata:[],timeouts:[]}})}getCdnPreferenceForResource(e){return e.length<=1?e:this._innerGetCdnPreferenceForResource(e)}downgradeCdn(e){let t=Hs(this._downgradedCdnList.metadata,e);t>=0&&this._removeIndexFromDowngradeList(t);let{DEFAULT_CDN_DOWNGRADE_TIME:r}=L.getCurrent(),i=r;this._downgradedCdnList.metadata.push(e);let a=setTimeout(()=>{let o=Hs(this._downgradedCdnList.metadata,e);o>=0&&this._removeIndexFromDowngradeList(o),this.trigger(\"priorityChange\",null)},i);this._downgradedCdnList.timeouts.push(a),this.trigger(\"priorityChange\",null)}_innerGetCdnPreferenceForResource(e){let[t,r]=e.reduce((i,a)=>(this._downgradedCdnList.metadata.some(o=>o.id===a.id&&o.baseUrl===a.baseUrl)?i[1].push(a):i[0].push(a),i),[[],[]]);return t.concat(r)}_removeIndexFromDowngradeList(e){this._downgradedCdnList.metadata.splice(e,1);let t=this._downgradedCdnList.timeouts.splice(e,1);clearTimeout(t[0])}};function Hs(n,e){return n.length===0?-1:e.id!==void 0?re(n,t=>t.id===e.id):re(n,t=>t.baseUrl===e.baseUrl)}function Na(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=d=>e(r,a,d),u=n.create(s,i,a,o);return t.set(u,s),u},updatePriority(r,i){let a=t.get(r);if(a===void 0){m.warn(\"Fetchers: Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Ua=class{constructor(){this._cache=new WeakMap}add({representation:e,segment:t},r){t.isInit&&this._cache.set(e,r)}get({representation:e,segment:t}){if(t.isInit){let r=this._cache.get(e);if(r!==void 0)return r}return null}},Gs=Ua;var ff=Ce();function La({bufferType:n,pipeline:e,cdnPrioritizer:t,cmcdDataBuilder:r,eventListeners:i,requestOptions:a}){let o;a.connectionTimeout===void 0||a.connectionTimeout<0?o=void 0:o=a.connectionTimeout;let s={timeout:a.requestTimeout<0?void 0:a.requestTimeout,connectionTimeout:o,cmcdPayload:void 0},u=fe([\"audio\",\"video\"],n)?new Gs:void 0,{loadSegment:d,parseSegment:f}=e;return async function(c,g,p){var ee,K,G;let{segment:h,adaptation:I,representation:y,manifest:T,period:P}=c,E=Et(c),C=ff(),_,x=[],A=0,R=!1,k={segment:h,type:I.type,language:I.language,isLive:T.isLive,periodStart:P.start,periodEnd:P.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:T.publishTime},M={onProgress(W){var Q;_===void 0&&W.totalSize!==void 0&&W.size<W.totalSize&&((Q=i.onProgress)==null||Q.call(i,{duration:W.duration,size:W.size,totalSize:W.totalSize,timestamp:U(),id:C}))},onNewChunk(W){g.onChunk(N(W,!0))}},D=u!==void 0?u.get(c):null;if(D!==null)return m.debug(\"SF: Found wanted segment in cache\",E),g.onChunk(N(D,!1)),Promise.resolve();m.debug(\"SF: Beginning request\",E),(ee=i.onRequestBegin)==null||ee.call(i,{requestTimestamp:U(),id:C,content:c}),p.register(w);try{let W=await wa(c.representation.cdnMetadata,t,O,H({onRetry:V},a),p);if(W.resultType===\"segment-loaded\"){let Q=W.resultData.responseData;u!==void 0&&u.add(c,W.resultData.responseData),g.onChunk(N(Q,!1))}else W.resultType===\"segment-created\"&&g.onChunk(N(W.resultData,!1));m.debug(\"SF: Segment request ended with success\",E),g.onAllChunksReceived(),W.resultType!==\"segment-created\"?(_=W.resultData,q()):_=null,p.isCancelled()||(K=i.onRequestEnd)==null||K.call(i,{id:C}),p.deregister(w)}catch(W){throw p.deregister(w),_=null,W instanceof oe?(m.debug(\"SF: Segment request aborted\",E),W):(m.debug(\"SF: Segment request failed\",E),(G=i.onRequestEnd)==null||G.call(i,{id:C}),ot(W))}function w(){var W;_===void 0&&(m.debug(\"SF: Segment request cancelled\",E),_=null,(W=i.onRequestEnd)==null||W.call(i,{id:C}))}function O(W){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(c),d(W,k,s,p,M)}function N(W,Q){x.push(!1);let ue=x.length-1;return function(ce){let He={data:W,isChunked:Q};try{let we=f(He,k,ce);return x[ue]||(A=A!==void 0&&we.segmentType===\"media\"&&we.chunkInfos!==null&&we.chunkInfos.duration!==void 0?A+we.chunkInfos.duration:void 0,x[ue]=!0,q()),we}catch(we){throw Ie(we,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function V(W){g.onRetry(ot(W))}function q(){var W;R||!v(_)&&_.size!==void 0&&_.requestDuration!==void 0&&x.length>0&&x.every(Q=>Q)&&(R=!0,(W=i.onMetrics)==null||W.call(i,{size:_.size,requestDuration:_.requestDuration,content:c,segmentDuration:A}))}}}function Ks({maxRetry:n,lowLatencyMode:e,requestTimeout:t,connectionTimeout:r}){let{DEFAULT_MAX_REQUESTS_RETRY_ON_ERROR:i,DEFAULT_REQUEST_TIMEOUT:a,DEFAULT_CONNECTION_TIMEOUT:o,INITIAL_BACKOFF_DELAY_BASE:s,MAX_BACKOFF_DELAY_BASE:u}=L.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?u.LOW_LATENCY:u.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Zn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"TP: the max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return Tt(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let d=()=>{g(),this._endTask(a)},f=p=>{r.beforeEnded(),d(),o(p)},l=p=>{d(),s(p)},c=new z,g=c.linkToSignal(i);a.interrupter=c,c.signal.register(()=>{a.interrupter=null,i.isCancelled()||r.beforeInterrupted()}),this._minPendingPriority=this._minPendingPriority===null?a.priority:Math.min(this._minPendingPriority,a.priority),this._pendingTasks.push(a),a.taskFn(c.signal).then(f).catch(p=>{!i.isCancelled()&&c.isUsed()&&p instanceof oe||l(p)})},taskFn:e,interrupter:null},this._canBeStartedNow(a)?(a.trigger(),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()):this._waitingQueue.push(a),()=>this._endTask(a)))}_endTask(e){e.hasEnded=!0;let t=Xn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Xn(e.taskFn,this._pendingTasks);if(r<0)return;this._pendingTasks.splice(r,1),this._pendingTasks.length>0?this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))):this._minPendingPriority=null,this._loopThroughWaitingQueue()}}updatePriority(e,t){let r=Xn(e,this._waitingQueue);if(r>=0){let s=this._waitingQueue[r];if(s.priority===t||(s.priority=t,!this._canBeStartedNow(s)))return;this._findAndRunWaitingQueueTask(r),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks();return}let i=Xn(e,this._pendingTasks);if(i<0){m.warn(\"TP: request to update the priority of a non-existent task\");return}let a=this._pendingTasks[i];if(a.priority===t)return;let o=a.priority;a.priority=t,this._minPendingPriority===null||t<this._minPendingPriority?this._minPendingPriority=t:this._minPendingPriority===o&&(this._pendingTasks.length===1?this._minPendingPriority=t:this._minPendingPriority=Math.min(...this._pendingTasks.map(s=>s.priority)),this._loopThroughWaitingQueue()),this._isRunningHighPriorityTasks()&&this._interruptCancellableTasks()}_loopThroughWaitingQueue(){let e=this._waitingQueue.reduce((t,r)=>t===null||t>r.priority?r.priority:t,null);if(!(e===null||this._minPendingPriority!==null&&this._minPendingPriority<e))for(let t=0;t<this._waitingQueue.length;t++){let r=this._minPendingPriority===null?e:Math.min(this._minPendingPriority,e);this._waitingQueue[t].priority<=r&&(this._findAndRunWaitingQueueTask(t),t--)}}_interruptCancellableTasks(){for(let e=0;e<this._pendingTasks.length;e++){let t=this._pendingTasks[e];if(t.priority>=this._prioritySteps.low)return this._interruptPendingTask(t),this._interruptCancellableTasks()}}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(m.warn(\"TP : Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=Xn(e.taskFn,this._pendingTasks);if(t<0){m.warn(\"TP: Interrupting a non-existent pending task. Aborting...\");return}this._pendingTasks.splice(t,1),this._waitingQueue.push(e),this._pendingTasks.length===0?this._minPendingPriority=null:this._minPendingPriority===e.priority&&(this._minPendingPriority=Math.min(...this._pendingTasks.map(i=>i.priority))),(r=e.interrupter)==null||r.cancel()}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Xn(n,e){return re(e,t=>t.taskFn===n)}var Jn=class{constructor(e,t,r,i){let a=new $n(i),{MIN_CANCELABLE_PRIORITY:o,MAX_HIGH_PRIORITY_LEVEL:s}=L.getCurrent();this._transport=e,this._prioritizer=new Zn({prioritySteps:{high:s,low:o}}),this._cdnPrioritizer=a,this._backoffOptions=r,this._cmcdDataBuilder=t}createSegmentFetcher(e,t){let r=Ks(this._backoffOptions),i=this._transport[e],a=La({bufferType:e,pipeline:i,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:r});return Na(this._prioritizer,a)}};var Fa=Jn;var er=class{constructor(e){this._segmentSinksStore=e,this._currentFreezeTimestamp=null}needToReload(e){let{readyState:t,rebuffering:r,freezing:i}=e;if((e.bufferGap!==void 0&&isFinite(e.bufferGap)?e.bufferGap:0)<6||r===null&&i===null||t>1)return this._currentFreezeTimestamp=null,!1;let o=U();this._currentFreezeTimestamp===null&&(this._currentFreezeTimestamp=o);let s=r!==null&&o-r.timestamp>4e3,u=i!==null&&o-i.timestamp>4e3;if((s||u)&&U()-this._currentFreezeTimestamp>4e3){let d=this._segmentSinksStore.getStatus(\"audio\"),f=this._segmentSinksStore.getStatus(\"video\"),l=!0,c=!0;for(let g of[d,f])if(g.type===\"initialized\")for(let p of g.value.getLastKnownInventory()){let{representation:h}=p.infos;if(h.decipherable===!1)return m.warn(\"Init: we have undecipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0;h.contentProtections!==void 0&&(c=!1,h.decipherable!==!0&&(l=!1))}if(!c&&l)return m.warn(\"Init: we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._currentFreezeTimestamp=null,!0}return!1}};var{DEFAULT_WANTED_BUFFER_AHEAD:cf,DEFAULT_MAX_VIDEO_BUFFER_SIZE:mf,DEFAULT_MAX_BUFFER_AHEAD:pf,DEFAULT_MAX_BUFFER_BEHIND:gf}=L.getCurrent(),za=new j(cf),Wa=new j(mf),Va=new j(pf),qa=new j(gf),Gr=new j({height:void 0,width:void 0,pixelRatio:1}),Kr=new j(1/0);function X(n,e){m.debug(\"<--- Sending to Main:\",n.type),e===void 0?postMessage(n):postMessage(n,e)}function Oe(n){return Ie(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var tr=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,u,d,f,l,c;for(let g of this._refs.keys())(t=(e=this._refs.get(g))==null?void 0:e.audio)==null||t.trackReference.finish(),(i=(r=this._refs.get(g))==null?void 0:r.audio)==null||i.representations.finish(),(o=(a=this._refs.get(g))==null?void 0:a.video)==null||o.trackReference.finish(),(u=(s=this._refs.get(g))==null?void 0:s.video)==null||u.representations.finish(),(f=(d=this._refs.get(g))==null?void 0:d.text)==null||f.trackReference.finish(),(c=(l=this._refs.get(g))==null?void 0:l.text)==null||c.representations.finish();this._refs=new Map}addTrackSetter(e,t,r){var s,u;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(m.warn(\"WP: Track for periodId already declared\",e,t),(s=i[t])==null||s.trackReference.finish(),(u=i[t])==null||u.representations.finish());let a=r.getValue(),o;v(a)?o=new j({representationIds:[],switchingMode:\"lazy\"}):(o=new j(a.representations.getValue()),r.setValue(H({},a,{representations:o}))),i[t]={trackReference:r,representations:o}}setTrack(e,t,r){var a;let i=(a=this._refs.get(e))==null?void 0:a[t];return i===void 0?(m.debug(\"WP: Setting track for inexistent periodId\",e,t),!1):(v(r)?(i.representations=new j({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new j(r.initialRepresentations),i.trackReference.setValue({adaptationId:r.adaptationId,switchingMode:r.switchingMode,representations:i.representations,relativeResumingPosition:r.relativeResumingPosition})),!0)}updateRepresentations(e,t,r,i){var s;let a=(s=this._refs.get(e))==null?void 0:s[r];if(a===void 0)return m.debug(\"WP: Setting track for inexistent periodId\",e,r),!1;let o=a.trackReference.getValue();return v(o)||o.adaptationId!==t?(m.debug(\"WP: Desynchronized Adaptation id\",o==null?void 0:o.adaptationId,t),!1):(a.representations.setValue(i),!0)}removeTrackSetter(e,t){let r=this._refs.get(e),i=r==null?void 0:r[t];return r===void 0||i===void 0?(m.debug(\"WP: Removing track setter for inexistent periodId\",e,t),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};var nr=class{constructor(e,t){this._contentId=e,this._messageSender=t,this._queues={pushTextData:[],remove:[]}}pushTextData(e){return new Promise((t,r)=>{this._messageSender({type:\"push-text-data\",contentId:this._contentId,value:e}),this._queues.pushTextData.push({resolve:t,reject:r})})}remove(e,t){return new Promise((r,i)=>{this._messageSender({type:\"remove-text-data\",contentId:this._contentId,value:{start:e,end:t}}),this._queues.remove.push({resolve:r,reject:i})})}reset(){this._messageSender({type:\"reset-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}stop(){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue()}_resetCurrentQueue(){let e=new oe;this._queues.pushTextData.forEach(t=>{t.reject(e)}),this._queues.remove.forEach(t=>{t.reject(e)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){m.error(\"WMS: pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){m.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){m.error(\"WMS: remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){m.error(\"WMS: pushTextData error for inexistant operation\");return}t.reject(e)}};var js=Ce(),Yt=class{constructor({hasMseInWorker:e,hasVideo:t}){this._currentContent=null,this._currentMediaSourceCanceller=new z,this._hasVideo=t,this._hasMseInWorker=e;let r=new z;this._contentCanceller=r}initializeNewContent(e){return new Promise((t,r)=>{var A,R;this.disposeCurrentContent();let i=this._contentCanceller,a=new z;this._currentMediaSourceCanceller=a,a.linkToSignal(i.signal);let{contentId:o,url:s,hasText:u,transportOptions:d}=e,f=null;be(xe.transports.dash!==void 0,\"Multithread RxPlayer should have access to the DASH feature\");let l=typeof d.representationFilter==\"string\"?Po(d.representationFilter):void 0,c=xe.transports.dash(ie(Z({},d),{representationFilter:l})),g=e.cmcd===void 0?null:new qs(e.cmcd),p=new Ba(s===void 0?void 0:[s],c,Z({cmcdDataBuilder:g},e.manifestRetryOptions)),h=Vs({initialBitrates:{audio:(A=e.initialAudioBitrate)!=null?A:0,video:(R=e.initialVideoBitrate)!=null?R:0},lowLatencyMode:d.lowLatencyMode,throttlers:{limitResolution:{video:Gr},throttleBitrate:{video:Kr}}}),I=a.signal.register(k=>{r(k)}),y=new Fa(c,g,e.segmentRetryOptions,i.signal),T=new tr,[P,E,C]=Ys(o,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:u},a.signal),_=new er(E);this._currentContent={cmcdDataBuilder:g,contentId:o,decipherabilityFreezeDetector:_,mediaSource:P,manifest:null,manifestFetcher:p,representationEstimator:h,segmentSinksStore:E,segmentFetcherCreator:y,workerTextSender:C,trackChoiceSetter:T},P.addEventListener(\"mediaSourceOpen\",function(){x()},a.signal),i.signal.register(()=>{p.dispose()}),p.addEventListener(\"warning\",k=>{X({type:\"warning\",contentId:o,value:Oe(k)})},i.signal),p.addEventListener(\"manifestReady\",k=>{if(f!==null){m.warn(\"WP: Multiple `manifestReady` events, ignoring\");return}f=k,this._currentContent!==null&&(this._currentContent.manifest=f),x()},a.signal),p.addEventListener(\"error\",k=>{r(k)},i.signal),p.start();function x(){if(f===null||P.readyState===\"closed\"||a.isUsed())return;let k=f.getMetadataSnapshot();f.addEventListener(\"manifestUpdate\",M=>{if(f===null)return;let D=H(f.getMetadataSnapshot(),{periods:[]});X({type:\"manifest-update\",contentId:o,value:{manifest:D,updates:M}})},i.signal),I(),t(k)}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new z,X({type:\"reloading-media-source\",contentId:this._currentContent.contentId,value:e},[]);let[t,r,i]=Ys(this._currentContent.contentId,{hasMseInWorker:this._hasMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.workerTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.workerTextSender=i,new Promise((a,o)=>{t.addEventListener(\"mediaSourceOpen\",function(){a()},this._currentMediaSourceCanceller.signal),t.addEventListener(\"mediaSourceClose\",function(){o(new Error(\"MediaSource ReadyState changed to close during init.\"))},this._currentMediaSourceCanceller.signal),this._currentMediaSourceCanceller.signal.register(s=>{o(s)})})}disposeCurrentContent(){this._contentCanceller.cancel(),this._contentCanceller=new z}};function Ys(n,e,t){let r;if(e.hasMseInWorker){let s=new Fn(js());r=s;let u,d=s.handle;if(d.type===\"handle\")u={type:\"handle\",value:d.value};else{let f=URL.createObjectURL(d.value);u={type:\"url\",value:f},t.register(()=>{URL.revokeObjectURL(f)})}X({type:\"attach-media-source\",contentId:n,value:u,mediaSourceId:r.id},[d.value])}else r=new zn(js(),n,X);let i=e.hasText?new nr(n,X):null,{hasVideo:a}=e,o=new St(r,a,i);return t.register(()=>{o.disposeAll(),i==null||i.stop(),r.dispose()}),[r,o,i]}function Ha(){let n=!1,e=new Yt({hasMseInWorker:!1,hasVideo:!0}),t=null,r=new is;xe.dashParsers.wasm=r,xe.dashParsers.fastJs=Go,xe.transports.dash=cs;let i=null;onmessage=function(a){var s,u;m.debug(\"Worker: received message\",a.data.type);let o=a.data;switch(o.type){case\"init\":be(!n),n=!0,Ya(o.value),Qs(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs),o.value.dashWasmUrl!==void 0&&r.isCompatible()&&r.initialize({wasmUrl:o.value.dashWasmUrl}).catch(d=>{let f=d instanceof Error?d.toString():\"Unknown Error\";m.error(\"Worker: Could not initialize DASH_WASM parser\",f)}),(!o.value.hasVideo||o.value.hasMseInWorker)&&(e.disposeCurrentContent(),e=new Yt({hasMseInWorker:o.value.hasMseInWorker,hasVideo:o.value.hasVideo})),X({type:\"init-success\",value:null});break;case\"log-level-update\":Qs(o.value.logLevel,o.value.logFormat,o.value.sendBackLogs);break;case\"prepare\":hf(e,o.value);break;case\"start\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;t!==null&&(t.cancel(),t=null);let f=new z,l=new j(H(o.value.initialObservation,{position:new kt(...o.value.initialObservation.position)}));i=l,t=f,t.signal.register(()=>{l.finish()}),$s(o.value,e,l,f.signal);break}case\"observation\":{let d=e.getCurrentContent();if(o.contentId!==(d==null?void 0:d.contentId))return;let f=o.value,{buffered:l}=f,c=Ra(d.mediaSource,null);c.audio!==null&&(l.audio=c.audio),c.video!==null&&(l.video=c.video),i==null||i.setValue(H(f,{position:new kt(...o.value.position)}));break}case\"ref-update\":If(o);break;case\"stop\":if(o.contentId!==((s=e.getCurrentContent())==null?void 0:s.contentId))return;e.disposeCurrentContent(),t!==null&&(t.cancel(),t=null);break;case\"sb-success\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,l=Y(f,c=>c.type===o.sourceBufferType);if(l===void 0){m.info(\"WP: Success for an unknown SourceBuffer\",o.sourceBufferType);return}if(l.onOperationSuccess===void 0){m.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}l.onOperationSuccess(o.operationId,o.value.buffered);break}case\"sb-error\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;let{sourceBuffers:f}=d.mediaSource,l=Y(f,c=>c.type===o.sourceBufferType);if(l===void 0){m.info(\"WP: Error for an unknown SourceBuffer\",o.sourceBufferType);return}if(l.onOperationFailure===void 0){m.warn(\"WP: A SourceBufferInterface with MSE performed a cross-thread operation\",o.sourceBufferType);return}l.onOperationFailure(o.operationId,o.value);break}case\"media-source-ready-state-change\":{let d=e.getCurrentContent();if(o.mediaSourceId!==(d==null?void 0:d.mediaSource.id))return;if(d.mediaSource.onMediaSourceReadyStateChanged===void 0){m.warn(\"WP: A MediaSourceInterface with MSE performed a cross-thread operation\");return}d.mediaSource.onMediaSourceReadyStateChanged(o.value);break}case\"decipherability-update\":{if(o.contentId!==((u=e.getCurrentContent())==null?void 0:u.contentId))return;let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;d.manifest.updateRepresentationsDeciperability(l=>{for(let c of f)if(l.representation.uniqueId===c.representationUniqueId)return c.decipherable;return l.representation.decipherable});break}case\"codec-support-update\":{let d=e.getCurrentContent();if(d===null||d.manifest===null)return;let f=o.value;try{let l=d.manifest.updateCodecSupport(f);l!==null&&X({type:\"warning\",contentId:d.contentId,value:Oe(l)})}catch(l){X({type:\"error\",contentId:d.contentId,value:Oe(l)})}break}case\"urls-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.manifestFetcher.updateContentUrls(o.value.urls,o.value.refreshNow);break}case\"track-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.setTrack(o.value.periodId,o.value.bufferType,o.value.choice);break}case\"rep-update\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;d.trackChoiceSetter.updateRepresentations(o.value.periodId,o.value.adaptationId,o.value.bufferType,o.value.choice);break}case\"add-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackSuccess(o.value.ranges);break}case\"push-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Added text track but text track aren't enabled\");return}d.workerTextSender.onPushedTrackError(new Error(o.value.message));break}case\"remove-text-success\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveSuccess(o.value.ranges);break}case\"remove-text-error\":{let d=e.getCurrentContent();if(d===null||d.contentId!==o.contentId)return;if(d.workerTextSender===null){m.error(\"WP: Removed text track but text track aren't enabled\");return}d.workerTextSender.onRemoveError(new Error(o.value.message));break}case\"pull-segment-sink-store-infos\":{bf(e,o.value.messageId);break}default:Fe(o)}}}function hf(n,e){n.initializeNewContent(e).then(t=>{X({type:\"manifest-ready\",contentId:e.contentId,value:{manifest:t}})},t=>{X({type:\"error\",contentId:e.contentId,value:Oe(t)})})}function If(n){switch(n.value.name){case\"wantedBufferAhead\":za.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":Wa.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":qa.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":Va.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":Gr.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":Kr.setValueIfChanged(n.value.newVal);break;default:Fe(n.value)}}function $s(n,e,t,r){var A;let i=new z;i.linkToSignal(r);let a=new Map,o=e.getCurrentContent();if(o===null||o.manifest===null){let R=new he(\"NONE\",\"Loading content when none is prepared\");X({type:\"error\",contentId:void 0,value:Oe(R)});return}let{contentId:s,cmcdDataBuilder:u,manifest:d,mediaSource:f,representationEstimator:l,segmentSinksStore:c,segmentFetcherCreator:g}=o,{drmSystemId:p,enableFastSwitching:h,initialTime:I,onCodecSwitch:y}=n;if(t.onUpdate(R=>{o.decipherabilityFreezeDetector.needToReload(R)&&x({timeOffset:0,minimumPosition:0,maximumPosition:1/0}),[\"video\",\"audio\",\"text\"].forEach(k=>{var D;let M=c.getStatus(k);M.type===\"initialized\"&&M.value.synchronizeInventory((D=R.buffered[k])!=null?D:[])})}),((A=d.getPeriodForTime(I))!=null?A:d.getNextPeriod(I))===void 0){let R=new $(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");X({type:\"error\",contentId:s,value:Oe(R)});return}let P=new _n(t,s,X,i.signal);u==null||u.startMonitoringPlayback(P),i.signal.register(()=>{u==null||u.stopMonitoringPlayback()});let E=Ea(d,f,P,c,{onWarning:R=>X({type:\"warning\",contentId:s,value:Oe(R)}),onPeriodChanged:R=>{X({type:\"active-period-changed\",contentId:s,value:{periodId:R.id}})}},i.signal);Os({initialPeriod:d.periods[0],manifest:d},P,l,c,g,{wantedBufferAhead:za,maxVideoBufferSize:Wa,maxBufferAhead:Va,maxBufferBehind:qa,drmSystemId:p,enableFastSwitching:h,onCodecSwitch:y},C(),i.signal);function C(){return{needsBufferFlush(R){X({type:\"needs-buffer-flush\",contentId:s,value:R})},streamStatusUpdate(R){_(R),d.isLastPeriodKnown&&R.period.id===d.periods[d.periods.length-1].id&&(R.hasFinishedLoading||R.isEmptyStream?E.onLastSegmentFinishedLoading(R.bufferType):E.onLastSegmentLoadingResume(R.bufferType))},needsManifestRefresh(){e.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:R}=L.getCurrent();e.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:R})},lockedStream(R){X({type:\"locked-stream\",contentId:s,value:{periodId:R.period.id,bufferType:R.bufferType}})},adaptationChange(R){var k,M;E.onAdaptationChange(R.type,R.period,R.adaptation),!i.signal.isCancelled()&&X({type:\"adaptation-changed\",contentId:s,value:{adaptationId:(M=(k=R.adaptation)==null?void 0:k.id)!=null?M:null,periodId:R.period.id,type:R.type}})},representationChange(R){var k,M;E.onRepresentationChange(R.type,R.period),!i.signal.isCancelled()&&X({type:\"representation-changed\",contentId:s,value:{adaptationId:R.adaptation.id,representationId:(M=(k=R.representation)==null?void 0:k.id)!=null?M:null,periodId:R.period.id,type:R.type}})},inbandEvent(R){X({type:\"inband-event\",contentId:s,value:R})},warning(R){X({type:\"warning\",contentId:s,value:Oe(R)})},periodStreamReady(R){o!==null&&(o.trackChoiceSetter.addTrackSetter(R.period.id,R.type,R.adaptationRef),X({type:\"period-stream-ready\",contentId:s,value:{periodId:R.period.id,bufferType:R.type}}))},periodStreamCleared(R){if(o===null)return;let k=a.get(R.period);k!==void 0&&(k.delete(R.type),k.size===0&&a.delete(R.period)),o.trackChoiceSetter.removeTrackSetter(R.period.id,R.type),X({type:\"period-stream-cleared\",contentId:s,value:{periodId:R.period.id,bufferType:R.type}})},bitrateEstimateChange(R){var k;o!==null&&((k=o.cmcdDataBuilder)==null||k.updateThroughput(R.type,R.bitrate)),X({type:\"bitrate-estimate-change\",contentId:s,value:{bitrate:R.bitrate,bufferType:R.type}})},needsMediaSourceReload(R){x(R)},needsDecipherabilityFlush(){X({type:\"needs-decipherability-flush\",contentId:s,value:null})},encryptionDataEncountered(R){for(let k of R){let M=k.content,D=Z({},M);D.manifest instanceof Lt&&(D.manifest=D.manifest.getMetadataSnapshot()),D.period instanceof mt&&(D.period=D.period.getMetadataSnapshot()),D.adaptation instanceof dt&&(D.adaptation=D.adaptation.getMetadataSnapshot()),D.representation instanceof tn&&(D.representation=D.representation.getMetadataSnapshot()),X({type:\"encryption-data-encountered\",contentId:s,value:{keyIds:k.keyIds,values:k.values,content:D,type:k.type}})}},error(R){X({type:\"error\",contentId:s,value:Oe(R)})}}}function _(R){let{imminentDiscontinuity:k}=R,M=a.get(R.period),D=M==null?void 0:M.get(R.bufferType);if(D!==void 0){if(D.discontinuity===null){if(k===null)return}else if(k!==null&&D.discontinuity.start===k.start&&D.discontinuity.end===k.end)return}M===void 0&&(M=new Map,a.set(R.period,M));let w={periodId:R.period.id,bufferType:R.bufferType,discontinuity:R.imminentDiscontinuity,position:R.position};M.set(R.bufferType,w),X({type:\"discontinuity-update\",contentId:s,value:w})}function x(R){let M=t.getValue().position.getWanted();i!==null&&i.cancel(),e.reloadMediaSource(R).then(()=>{$s({initialTime:M,drmSystemId:n.drmSystemId,enableFastSwitching:n.enableFastSwitching,onCodecSwitch:n.onCodecSwitch},e,t,r)},D=>{X({type:\"error\",contentId:s,value:Oe(D)})})}}function Qs(n,e,t){t?m.setLevel(n,\"standard\",(r,i)=>{let a=i.map(o=>o instanceof Error?Oe(o):o);postMessage({type:\"log\",value:{logLevel:r,logs:a}})}):m.setLevel(n,e)}function bf(n,e){let t=n.getCurrentContent();if(t===null)return;let r=t.segmentSinksStore.getSegmentSinksMetrics();X({type:\"segment-sink-store-update\",contentId:t.contentId,value:{segmentSinkMetrics:r,messageId:e}})}var Xs=Ha;Xs();})();\n" + "})()"], { type: "application/javascript" });
2
2
  export { blob as EMBEDDED_WORKER };
3
3
  export default blob;