rx-player 4.5.0-dev.2026012302 → 4.5.0-dev.2026031700

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 (180) hide show
  1. package/CHANGELOG.md +21 -3
  2. package/VERSION +1 -1
  3. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  4. package/dist/commonjs/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  5. package/dist/commonjs/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  6. package/dist/commonjs/__GENERATED_CODE/embedded_worker.js +1 -1
  7. package/dist/commonjs/compat/should_seek_at_zero.d.ts +12 -0
  8. package/dist/commonjs/compat/should_seek_at_zero.d.ts.map +1 -0
  9. package/dist/commonjs/compat/should_seek_at_zero.js +23 -0
  10. package/dist/commonjs/core/cmcd/cmcd_data_builder.js +2 -2
  11. package/dist/commonjs/core/entry/FreezeResolver.js +2 -2
  12. package/dist/commonjs/core/entry/content_preparer.d.ts +1 -6
  13. package/dist/commonjs/core/entry/content_preparer.d.ts.map +1 -1
  14. package/dist/commonjs/core/entry/content_preparer.js +2 -125
  15. package/dist/commonjs/core/entry/content_time_boundaries_observer.d.ts.map +1 -1
  16. package/dist/commonjs/core/entry/content_time_boundaries_observer.js +8 -0
  17. package/dist/commonjs/core/entry/core_entry.d.ts +1 -1
  18. package/dist/commonjs/core/entry/core_entry.d.ts.map +1 -1
  19. package/dist/commonjs/core/entry/core_entry.js +2 -7
  20. package/dist/commonjs/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  21. package/dist/commonjs/core/entry/core_text_displayer_interface.js +3 -1
  22. package/dist/commonjs/core/entry/index.d.ts +1 -1
  23. package/dist/commonjs/core/entry/index.d.ts.map +1 -1
  24. package/dist/commonjs/core/entry/utils.d.ts +64 -0
  25. package/dist/commonjs/core/entry/utils.d.ts.map +1 -1
  26. package/dist/commonjs/core/entry/utils.js +165 -0
  27. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts +5 -6
  28. package/dist/commonjs/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  29. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  30. package/dist/commonjs/core/fetchers/thumbnails/thumbnail_fetcher.js +34 -30
  31. package/dist/commonjs/core/stream/representation/encryption_data_notifier.d.ts +70 -0
  32. package/dist/commonjs/core/stream/representation/encryption_data_notifier.d.ts.map +1 -0
  33. package/dist/commonjs/core/stream/representation/encryption_data_notifier.js +107 -0
  34. package/dist/commonjs/core/stream/representation/representation_stream.d.ts.map +1 -1
  35. package/dist/commonjs/core/stream/representation/representation_stream.js +12 -60
  36. package/dist/commonjs/core/stream/representation/utils/get_needed_segments.js +1 -1
  37. package/dist/commonjs/default_config.d.ts +5 -0
  38. package/dist/commonjs/default_config.d.ts.map +1 -1
  39. package/dist/commonjs/default_config.js +5 -0
  40. package/dist/commonjs/experimental/features/worker/index.d.ts +2 -1
  41. package/dist/commonjs/experimental/features/worker/index.d.ts.map +1 -1
  42. package/dist/commonjs/experimental/features/worker/index.js +4 -3
  43. package/dist/commonjs/main_thread/api/public_api.d.ts.map +1 -1
  44. package/dist/commonjs/main_thread/api/public_api.js +28 -4
  45. package/dist/commonjs/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  46. package/dist/commonjs/main_thread/init/directfile_content_initializer.js +23 -1
  47. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  48. package/dist/commonjs/main_thread/init/utils/initial_seek_and_play.js +3 -1
  49. package/dist/commonjs/manifest/classes/index.d.ts +2 -1
  50. package/dist/commonjs/manifest/classes/index.d.ts.map +1 -1
  51. package/dist/commonjs/manifest/classes/representation.d.ts +1 -1
  52. package/dist/commonjs/manifest/classes/representation.d.ts.map +1 -1
  53. package/dist/commonjs/manifest/classes/representation.js +2 -2
  54. package/dist/commonjs/manifest/classes/representation_index/types.d.ts +2 -2
  55. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  56. package/dist/commonjs/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  57. package/dist/commonjs/utils/base64.d.ts +15 -1
  58. package/dist/commonjs/utils/base64.d.ts.map +1 -1
  59. package/dist/commonjs/utils/base64.js +6 -0
  60. package/dist/commonjs/utils/ranges.d.ts +1 -1
  61. package/dist/commonjs/utils/ranges.js +1 -1
  62. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.d.ts.map +1 -1
  63. package/dist/es2017/__GENERATED_CODE/embedded_dash_wasm.js +1 -1
  64. package/dist/es2017/__GENERATED_CODE/embedded_worker.d.ts.map +1 -1
  65. package/dist/es2017/__GENERATED_CODE/embedded_worker.js +1 -1
  66. package/dist/es2017/compat/should_seek_at_zero.d.ts +12 -0
  67. package/dist/es2017/compat/should_seek_at_zero.d.ts.map +1 -0
  68. package/dist/es2017/compat/should_seek_at_zero.js +20 -0
  69. package/dist/es2017/core/cmcd/cmcd_data_builder.js +2 -2
  70. package/dist/es2017/core/entry/FreezeResolver.js +1 -1
  71. package/dist/es2017/core/entry/content_preparer.d.ts +1 -6
  72. package/dist/es2017/core/entry/content_preparer.d.ts.map +1 -1
  73. package/dist/es2017/core/entry/content_preparer.js +1 -76
  74. package/dist/es2017/core/entry/content_time_boundaries_observer.d.ts.map +1 -1
  75. package/dist/es2017/core/entry/content_time_boundaries_observer.js +8 -0
  76. package/dist/es2017/core/entry/core_entry.d.ts +1 -1
  77. package/dist/es2017/core/entry/core_entry.d.ts.map +1 -1
  78. package/dist/es2017/core/entry/core_entry.js +2 -7
  79. package/dist/es2017/core/entry/core_text_displayer_interface.d.ts.map +1 -1
  80. package/dist/es2017/core/entry/core_text_displayer_interface.js +3 -1
  81. package/dist/es2017/core/entry/index.d.ts +1 -1
  82. package/dist/es2017/core/entry/index.d.ts.map +1 -1
  83. package/dist/es2017/core/entry/utils.d.ts +64 -0
  84. package/dist/es2017/core/entry/utils.d.ts.map +1 -1
  85. package/dist/es2017/core/entry/utils.js +98 -0
  86. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts +5 -6
  87. package/dist/es2017/core/fetchers/segment/segment_queue.d.ts.map +1 -1
  88. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.d.ts.map +1 -1
  89. package/dist/es2017/core/fetchers/thumbnails/thumbnail_fetcher.js +21 -16
  90. package/dist/es2017/core/stream/representation/encryption_data_notifier.d.ts +70 -0
  91. package/dist/es2017/core/stream/representation/encryption_data_notifier.d.ts.map +1 -0
  92. package/dist/es2017/core/stream/representation/encryption_data_notifier.js +80 -0
  93. package/dist/es2017/core/stream/representation/representation_stream.d.ts.map +1 -1
  94. package/dist/es2017/core/stream/representation/representation_stream.js +10 -38
  95. package/dist/es2017/core/stream/representation/utils/get_needed_segments.js +1 -1
  96. package/dist/es2017/default_config.d.ts +5 -0
  97. package/dist/es2017/default_config.d.ts.map +1 -1
  98. package/dist/es2017/default_config.js +5 -0
  99. package/dist/es2017/experimental/features/worker/index.d.ts +2 -1
  100. package/dist/es2017/experimental/features/worker/index.d.ts.map +1 -1
  101. package/dist/es2017/experimental/features/worker/index.js +2 -3
  102. package/dist/es2017/main_thread/api/public_api.d.ts.map +1 -1
  103. package/dist/es2017/main_thread/api/public_api.js +28 -4
  104. package/dist/es2017/main_thread/init/directfile_content_initializer.d.ts.map +1 -1
  105. package/dist/es2017/main_thread/init/directfile_content_initializer.js +23 -1
  106. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.d.ts.map +1 -1
  107. package/dist/es2017/main_thread/init/utils/initial_seek_and_play.js +3 -1
  108. package/dist/es2017/manifest/classes/index.d.ts +2 -1
  109. package/dist/es2017/manifest/classes/index.d.ts.map +1 -1
  110. package/dist/es2017/manifest/classes/representation.d.ts +1 -1
  111. package/dist/es2017/manifest/classes/representation.d.ts.map +1 -1
  112. package/dist/es2017/manifest/classes/representation.js +1 -1
  113. package/dist/es2017/manifest/classes/representation_index/types.d.ts +2 -2
  114. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.d.ts.map +1 -1
  115. package/dist/es2017/parsers/texttracks/ttml/html/apply_line_height.js +16 -1
  116. package/dist/es2017/utils/base64.d.ts +15 -1
  117. package/dist/es2017/utils/base64.d.ts.map +1 -1
  118. package/dist/es2017/utils/base64.js +6 -0
  119. package/dist/es2017/utils/ranges.d.ts +1 -1
  120. package/dist/es2017/utils/ranges.js +1 -1
  121. package/dist/mpd-parser.wasm +0 -0
  122. package/dist/worker.js +8 -8
  123. package/package.json +26 -23
  124. package/src/__GENERATED_CODE/embedded_dash_wasm.ts +1 -1
  125. package/src/__GENERATED_CODE/embedded_worker.ts +1 -1
  126. package/src/compat/should_seek_at_zero.ts +23 -0
  127. package/src/core/adaptive/__tests__/adaptive_representation_selector.test.ts +734 -0
  128. package/src/core/adaptive/__tests__/guess_based_chooser.test.ts +793 -0
  129. package/src/core/adaptive/__tests__/network_analyzer.test.ts +514 -0
  130. package/src/core/adaptive/utils/__tests__/bandwidth_estimator.test.ts +117 -0
  131. package/src/core/adaptive/utils/__tests__/last_estimate_storage.test.ts +76 -0
  132. package/src/core/adaptive/utils/__tests__/pending_requests_store.test.ts +288 -0
  133. package/src/core/adaptive/utils/__tests__/representation_score_calculator.test.ts +249 -0
  134. package/src/core/cmcd/__tests__/cmcd_data_builder.test.ts +464 -0
  135. package/src/core/cmcd/cmcd_data_builder.ts +2 -2
  136. package/src/core/entry/FreezeResolver.ts +1 -1
  137. package/src/core/entry/__tests__/FreezeResolver.test.ts +542 -0
  138. package/src/core/entry/__tests__/content_time_boundaries_observer.test.ts +867 -0
  139. package/src/core/entry/__tests__/core_text_displayer_interface.test.ts +205 -0
  140. package/src/core/entry/__tests__/get_buffered_data_per_media_buffer.test.ts +95 -0
  141. package/src/core/entry/__tests__/track_choice_setter.test.ts +288 -0
  142. package/src/core/entry/__tests__/utils.test.ts +309 -0
  143. package/src/core/entry/content_preparer.ts +7 -118
  144. package/src/core/entry/content_time_boundaries_observer.ts +10 -0
  145. package/src/core/entry/core_entry.ts +7 -14
  146. package/src/core/entry/core_text_displayer_interface.ts +3 -1
  147. package/src/core/entry/index.ts +1 -1
  148. package/src/core/entry/utils.ts +151 -0
  149. package/src/core/fetchers/__tests__/cdn_prioritizer.test.ts +166 -0
  150. package/src/core/fetchers/manifest/__tests__/manifest_fetcher.test.ts +803 -0
  151. package/src/core/fetchers/segment/__tests__/segment_fetcher.test.ts +872 -0
  152. package/src/core/fetchers/segment/__tests__/segment_queue.test.ts +557 -0
  153. package/src/core/fetchers/segment/segment_queue.ts +5 -6
  154. package/src/core/fetchers/thumbnails/__tests__/thumbnail_fetcher.test.ts +435 -0
  155. package/src/core/fetchers/thumbnails/thumbnail_fetcher.ts +28 -20
  156. package/src/core/fetchers/utils/__tests__/schedule_request.test.ts +331 -0
  157. package/src/core/stream/adaptation/__tests__/get_representations_switch_strategy.test.ts +593 -0
  158. package/src/core/stream/period/utils/__tests__/get_adaptation_switch_strategy.test.ts +646 -0
  159. package/src/core/stream/representation/__tests__/encryption_data_notifier.test.ts +531 -0
  160. package/src/core/stream/representation/encryption_data_notifier.ts +122 -0
  161. package/src/core/stream/representation/representation_stream.ts +11 -49
  162. package/src/core/stream/representation/utils/__tests__/append_segment_to_buffer.test.ts +321 -0
  163. package/src/core/stream/representation/utils/__tests__/check_for_discontinuity.test.ts +513 -0
  164. package/src/core/stream/representation/utils/__tests__/get_segment_priority.test.ts +132 -0
  165. package/src/core/stream/representation/utils/__tests__/push_init_segment.test.ts +209 -0
  166. package/src/core/stream/representation/utils/__tests__/push_media_segment.test.ts +343 -0
  167. package/src/core/stream/representation/utils/get_needed_segments.ts +1 -1
  168. package/src/default_config.ts +6 -0
  169. package/src/experimental/features/worker/index.ts +2 -4
  170. package/src/main_thread/api/public_api.ts +33 -4
  171. package/src/main_thread/init/directfile_content_initializer.ts +26 -1
  172. package/src/main_thread/init/utils/initial_seek_and_play.ts +5 -1
  173. package/src/manifest/classes/index.ts +2 -0
  174. package/src/manifest/classes/representation.ts +2 -1
  175. package/src/manifest/classes/representation_index/types.ts +2 -2
  176. package/src/mse/__tests__/main_media_source_interface.test.ts +846 -0
  177. package/src/parsers/texttracks/ttml/html/apply_line_height.ts +16 -1
  178. package/src/utils/__tests__/base64.test.ts +159 -191
  179. package/src/utils/base64.ts +30 -1
  180. package/src/utils/ranges.ts +1 -1
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EMBEDDED_WORKER = void 0;
4
- var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Td=Object.defineProperty,Ed=Object.defineProperties;var _d=Object.getOwnPropertyDescriptors;var eo=Object.getOwnPropertySymbols;var Rd=Object.prototype.hasOwnProperty,Pd=Object.prototype.propertyIsEnumerable;var to=(n,e,t)=>e in n?Td(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,J=(n,e)=>{for(var t in e||(e={}))Rd.call(e,t)&&to(n,t,e[t]);if(eo)for(var t of eo(e))Pd.call(e,t)&&to(n,t,e[t]);return n},se=(n,e)=>Ed(n,_d(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var no={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_AUDIO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",DEFAULT_VIDEO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",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,FREEZING_FLUSH_FAILURE_DELAY:{MAXIMUM:2e4,MINIMUM:4e3,POSITION_DELTA:1},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\"','audio/mp4;codecs=\"ec-3\"'],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\",DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:1,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:1e4,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:7e3,FORCE_CANNOT_RELY_ON_REQUEST_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_CANNOT_REUSE_MEDIA_KEYS:!1,FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:!1,FORCE_IS_SEEKING_APPROXIMATE:!1,FORCE_MEDIA_ELEMENT_FAIL_ON_UNDECIPHERABLE_DATA:!1,FORCE_SHOULD_AWAIT_SET_MEDIA_KEYS:!1,FORCE_SHOULD_FAVOUR_CUSTOM_SAFARI_EME:!1,FORCE_SHOULD_RELOAD_MEDIA_SOURCE_ON_DECIPHERABILITY_UPDATE:!1,FORCE_SHOULD_RENEW_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_SHOULD_UNSET_MEDIA_KEYS:!1,FORCE_SHOULD_VALIDATE_METADATA:!1,FORCE_DONT_WAIT_FOR_DATA_BEFORE_LOADED:!1,FORCE_WAIT_FOR_HAVE_ENOUGH_DATA:!1},ro=no;function Cd(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r of e)for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}var K=typeof Object.assign==\"function\"?Object.assign:Cd;function ri(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function en(n,...e){if(e.length===0)return n;let t=e.shift();if(ri(n)&&ri(t))for(let r in t)if(ri(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),en(i,t[r])}else K(n,{[r]:t[r]});return en(n,...e)}function C(n){return n==null}function O(){}var le=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=O;if(r!==void 0){if(r.isCancelled())return;i=r.register(()=>this.removeEventListener(e,t))}let a=this._listeners[e];Array.isArray(a)?a.push({cb:t,onRemove:i}):this._listeners[e]=[{cb:t,onRemove:i}]}removeEventListener(e,t){if(C(e)){for(let i of Object.keys(this._listeners)){let a=this._listeners[i];Array.isArray(a)&&a.forEach(o=>o.onRemove())}this._listeners={};return}let r=this._listeners[e];if(Array.isArray(r)){if(C(t)){r.forEach(i=>i.onRemove()),delete this._listeners[e];return}for(let i=0;i<r.length;i++)if(r[i].cb===t){r[i].onRemove(),r.splice(i,1);break}r.length===0&&delete this._listeners[e]}}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i.cb(t)}catch(a){if(I.CURRENT_ENV===I.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};var ii=class extends le{constructor(){super(...arguments);this.updated=!1;this._config=ro}update(t){let r=en(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Ad=new ii,L=Ad;var $e=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 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 ur=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){I.CURRENT_ENV===I.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.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.emitCurrentValue===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return O;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 tn(n,e,t){let r=new ur(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var X=ur;var ai=new X(0);function io({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;ai.setValueIfChanged(r-t)}var xd=typeof performance!=\"undefined\"?()=>performance.now()+ai.getValue():()=>Date.now()+ai.getValue(),F=xd;var kd=\"NONE\",Rt=class extends le{constructor(){super(),this.error=O,this.warn=O,this.info=O,this.debug=O,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat=\"standard\",this._currentLevel=kd}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 d=F();console.log(String(d.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(d,u)=>(f,...l)=>{let m=F();return u(String(m.toFixed(2)),`[${d}]`,f+\":\",...l.map(p=>typeof p==\"object\"&&p!==null&&!(p instanceof Error)?ao(p):p))}:(d,u)=>(f,...l)=>u(f+\":\",...l.map(m=>typeof m==\"object\"&&m!==null&&!(m instanceof Error)?ao(m):m));if(r===void 0)this.error=i>=this._levels.ERROR?s(\"error\",console.error.bind(console)):O,this.warn=i>=this._levels.WARNING?s(\"warn\",console.warn.bind(console)):O,this.info=i>=this._levels.INFO?s(\"info\",console.info.bind(console)):O,this.debug=i>=this._levels.DEBUG?s(\"log\",console.log.bind(console)):O;else{let d=u=>i>=this._levels[u]?(f,...l)=>r(u,f,l):O;this.error=d(\"ERROR\"),this.warn=d(\"WARNING\"),this.info=d(\"INFO\"),this.debug=d(\"DEBUG\")}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]}};function ao(n){let e=\"\";for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){e.length>0&&(e+=\" \");let r=n[t];r instanceof Error?e+=`${t}=\"${JSON.stringify(r==null?void 0:r.toString())}\"`:e+=`${t}=${typeof r==\"string\"?`${JSON.stringify(r)}`:String(r)}`}return e}var Md=new Rt,c=Md;var lr=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Od=typeof window==\"undefined\"&&!lr,fr=Od;var mr;lr?mr=self:fr?mr=global:mr=window;var ee=mr;var de=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}}},Re={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var oi=typeof Headers==\"function\"?Headers:null,cr=typeof AbortController==\"function\"?AbortController:null;function pr(n){var m,p;let e;if(!C(n.headers))if(C(oi))e=n.headers;else{e=new oi;let h=Object.keys(n.headers);for(let b=0;b<h.length;b++){let g=h[b];e.append(g,n.headers[g])}}c.debug(\"utils\",\"Fetch\",{url:n.url});let t=null,r=!1,i=!1,a=F(),o=C(cr)?null:new cr;function s(){if(C(o)){c.warn(\"utils\",\"Fetch: AbortController API not available.\");return}o.abort()}let d;n.timeout!==void 0&&(d=setTimeout(()=>{r=!0,u!==void 0&&clearTimeout(u),s()},n.timeout));let u;n.connectionTimeout!==void 0&&(u=setTimeout(()=>{i=!0,d!==void 0&&clearTimeout(d),s()},n.connectionTimeout));let f=n.cancelSignal.register(function(b){t=b,s()}),l={method:\"GET\"};if(e!==void 0&&(l.headers=e),l.signal=C(o)?null:o.signal,c.hasLevel(\"DEBUG\")){let h=\"fetch GET \"+n.url;n.timeout!==void 0&&(h+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(h+=\" cto=\"+String(n.connectionTimeout/1e3)),((m=n.headers)==null?void 0:m.Range)!==void 0&&(h+=\" Range=\"+((p=n.headers)==null?void 0:p.Range)),c.debug(\"utils\",h)}return fetch(n.url,l).then(h=>{if(u!==void 0&&clearTimeout(u),h.status>=300)throw c.warn(\"utils\",\"Fetch: Request HTTP Error\",{status:h.status,responseUrl:h.url}),new de(h.url,h.status,Re.ERROR_HTTP_CODE);if(C(h.body))throw new de(h.url,h.status,Re.PARSE_ERROR);let b=h.headers.get(\"Content-Length\"),g=!C(b)&&!isNaN(+b)?+b:void 0,S=h.body.getReader(),T=0;return v();async function v(){let E=await S.read();if(!E.done&&!C(E.value)){T+=E.value.byteLength;let R=F(),_={url:h.url,currentTime:R,duration:R-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:g};return n.onData(_),v()}else if(E.done){d!==void 0&&clearTimeout(d),f();let R=F();return{requestDuration:R-a,receivedTime:R,sendingTime:a,size:T,status:h.status,url:h.url}}return v()}}).catch(h=>{throw t!==null?t:(f(),r?(c.warn(\"utils\",\"Fetch: Request timed out.\",{url:n.url,timeout:n.timeout}),new de(n.url,0,Re.TIMEOUT)):i?(c.warn(\"utils\",\"Fetch: Request connection timed out.\",{url:n.url,connectionTimeout:n.connectionTimeout}),new de(n.url,0,Re.TIMEOUT)):h instanceof de?h:(c.warn(\"utils\",\"Fetch: Request Error\",{error:h instanceof Error?h.toString():\"Unkwown Error\"}),new de(n.url,0,Re.ERROR_EVENT)))})}function nn(){let n=/\\[\\s*native\\s+code\\s*\\]/;return typeof ee.fetch==\"function\"&&!C(cr)&&n.test(cr.toString())&&!C(oi)}function Q(n){return typeof n==\"string\"&&n.length>0}var wd=\"json\";function rn(n){let e={url:n.url,headers:n.headers,responseType:C(n.responseType)?wd:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:d,timeout:u,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let m;u!==void 0&&(l.timeout=u,m=setTimeout(()=>{g(),r(new de(o,l.status,Re.TIMEOUT))},u+3e3));let p;if(f!==void 0&&(p=setTimeout(()=>{g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new de(o,l.status,Re.TIMEOUT))},f)),l.responseType=d,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!C(s)){let S=s;for(let T in S)Object.prototype.hasOwnProperty.call(S,T)&&l.setRequestHeader(T,S[T])}let h=F(),b=null;if(a!==void 0&&(b=a.register(function(T){g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){g(),r(new de(o,l.status,Re.ERROR_EVENT))},l.ontimeout=function(){g(),r(new de(o,l.status,Re.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(l.onprogress=function(T){let v=F();i({url:o,duration:v-h,sendingTime:h,currentTime:v,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(g(),l.status>=200&&l.status<300){let v=F(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,R=l.status,_=l.responseType,k=Q(l.responseURL)?l.responseURL:o,A;if(_===\"json\"?A=typeof l.response==\"object\"?l.response:Dd(l.responseText):A=l.response,C(A)){r(new de(o,l.status,Re.PARSE_ERROR));return}t({status:R,url:k,responseType:_,sendingTime:h,receivedTime:v,requestDuration:v-h,size:E,responseData:A})}else r(new de(o,l.status,Re.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let S=\"XHR GET \"+o;n.responseType!==void 0&&(S+=\" type=\"+n.responseType),u!==void 0&&(S+=\" to=\"+String(u/1e3)),f!==void 0&&(S+=\" cto=\"+String(f/1e3)),(s==null?void 0:s.Range)!==void 0&&(S+=\" Range=\"+(s==null?void 0:s.Range)),c.debug(\"utils\",S)}l.send();function g(){m!==void 0&&clearTimeout(m),p!==void 0&&clearTimeout(p),b!==null&&b()}})}function Dd(n){try{return JSON.parse(n)}catch(e){return null}}var he=rn;var Pt=Re,Ve={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function et(n,e){return`${n}: ${e}`}var an=class n extends Error{constructor(e,t,r){super(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=Ve.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,this.keyStatuses=r.keyStatuses,this.keySystemConfiguration=r.keySystemConfiguration,this.keySystem=r.keySystem}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses,keySystemConfiguration:this.keySystemConfiguration,keySystem:this.keySystem}}};var Z=class n extends Error{constructor(e,t,r){super(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=Ve.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{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Xe=class n extends Error{constructor(e,t){super(et(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=Ve.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===Pt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Ee=class n extends Error{constructor(e,t){super(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Ve.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage}}};function Ut(n){return(n instanceof an||n instanceof Z||n instanceof Ee||n instanceof Xe)&&Object.keys(Ve).indexOf(n.type)>=0}function ce(n,{defaultCode:e,defaultReason:t}){if(Ut(n))return n;let r=n instanceof Error?n.toString():t;return new Ee(e,r)}var xe=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 Bd={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},monothread:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},oo=Bd;var ke=oo;function j(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 Nd={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\"},so=Nd;var Ud={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\"},uo=Ud;function Ld(n){if(C(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Fd(t);return Q(r)?r:n}function Fd(n){let e;switch(n.length){case 2:e=so[n];break;case 3:e=uo[n];break}return e}var lo=Ld;var fo=lo;function gr(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 si(n){return Object.keys(n).map(e=>n[e])}var hr=typeof Object.values==\"function\"?Object.values:si;var Lt=[\"audio\",\"video\",\"text\"];function co(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=F()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function po(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=F()-e.time;return e.livePosition+t/1e3}function go(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=F()-e.time;return e.maximumSafePosition+t/1e3}function ho(n,e){if(e===void 0)return ui(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 Io(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(di(i,e,t))return i;t=i}}function bo(n,e){let t=e.end;if(t===void 0)return null;let r=j(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function di(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 ui(n){let e=n.adaptations;return si(e).reduce((t,r)=>C(r)?t:t.concat(r),[])}function zd(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=>on(a)===!0):n.representations).map(Vd),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function Wd(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 qd(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>on(s)===!0):i.representations).map(mo),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=>on(i)===!0):n.representations).map(mo),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Vd(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 mo(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:d,decipherable:u,contentProtections:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:d,decipherable:u,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function vt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:zd(n,!1)};case\"video\":return{type:\"video\",track:qd(n,!1)};case\"text\":return{type:\"text\",track:Wd(n)}}}function on(n){return n.decipherable===!1?!1:n.isSupported}function So(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}function Me(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var Ir=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function Ie(n,e){if(I.DEV===I.CURRENT_ENV&&!n)throw new Ir(e===void 0?\"invalid assertion\":e)}function Be(n){throw new Ir(\"Unreachable path taken\")}var Gd=typeof ee==\"object\"&&typeof ee.TextDecoder==\"function\",Hd=typeof ee==\"object\"&&typeof ee.TextEncoder==\"function\";function sn(n){if(Hd)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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 d=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(d),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let d=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(d),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 Kd(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 yo(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function He(n){if(Gd)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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=Kd(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\"+yo(o,4):\"%\"+yo(o,2)}}return decodeURIComponent(r)}function dn(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 br(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 li(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:He(r)}}var jd=Me(),fi=class{constructor(e,t,r){var a,o,s,d,u;this.id=e.id,this.uniqueId=jd(),this.shouldBeAvoided=!1,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((d=this.mimeType)!=null?d:\"\",(u=e.codecs)!=null?u:\"\",i)))}else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,d;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(d=this.codecs)!=null?d:[];a.length===0&&(a=[\"\"]);let o=!1;for(let u of a){if(r=e.isSupported(i,u,t),r===!0){this.codecs=[u];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;let t=this.getAllEncryptionData(),r=[];for(let a=0;a<t.length;a++){let o=!1,s=t[a];for(let d=0;d<s.values.length;d++)if(s.values[d].systemId.toLowerCase()===e.toLowerCase())if(o)r[r.length-1].values.push(s.values[d]);else{let u=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:u,values:[s.values[d]]}),o=!0}}return r}getAllEncryptionData(){var t;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(t=this.contentProtections)==null?void 0:t.keyIds;return this.contentProtections.initData.map(r=>({type:r.type,keyIds:e,values:r.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[t]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[t];else{let s=!1;for(let d of o)gr(d,t)&&(s=!0);s||(c.warn(\"manifest\",\"found unanounced key id.\",{keyId:br(t)}),o.push(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 d=0;d<r.length;d++){let u=r[d],f;for(f=0;f<s.length;f++)if(u.systemId===s[f].systemId){if(gr(u.data,s[f].data))break;c.warn(\"manifest\",\"different init data for the same system ID\",{systemId:u.systemId})}f===s.length&&(s.push(u),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return on(this)}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,isCodecSupportedInWebWorker:this.isCodecSupportedInWebWorker}}},un=fi;var ft=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=fo(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(u=>new n(u,t)));let s=e.representations,d=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let u=0;u<s.length;u++){let f=new un(s[u],this.type,t),l=!0;if(!C(a)){let m={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&&(m.contentProtections={},f.contentProtections.keyIds!==void 0)){let p=f.contentProtections.keyIds;m.contentProtections.keyIds=p}l=a(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}l?(d.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)):c.debug(\"manifest\",\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${f.id}`,`(${f.bitrate})`)}d.sort((u,f)=>u.bitrate-f.bitrate),this.representations=d,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 j(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 be=ee,To,Eo,_o,Ro,Po,mt=(Po=(Ro=(_o=(Eo=(To=be==null?void 0:be.MediaSource)!=null?To:be==null?void 0:be.MozMediaSource)!=null?Eo:be==null?void 0:be.WebKitMediaSource)!=null?_o:be==null?void 0:be.MSMediaSource)!=null?Ro:be==null?void 0:be.ManagedMediaSource)!=null?Po:void 0,Yg=mt!==void 0&&mt===(be==null?void 0:be.ManagedMediaSource);var ct={EdgeChromium:0,Firefox:1,Ie11:2,OtherIeOrEdgePreEdgeChromium:3,SafariDesktop:4,SafariMobile:5,Other:6},Ne={A1KStb40xx:100,Panasonic:101,PhilipsNetTv:102,PlayStation4:103,PlayStation5:104,Tizen:105,WebOs2021:106,WebOs2022:107,WebOsOther:108,Xbox:109,Other:110},Se={DEVICES:Ne,BROWSERS:ct,browser:ct.Other,device:Ne.Other,isSamsungBrowser:!1};Yd();function Yd(){var n,e,t;fr||(typeof ee.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?Se.browser=ct.Ie11:navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?Se.browser=ct.OtherIeOrEdgePreEdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?Se.browser=ct.EdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?Se.browser=ct.Firefox:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?Se.browser=ct.SafariMobile:(Object.prototype.toString.call(ee.HTMLElement).indexOf(\"Constructor\")>=0||((e=(n=ee.safari)==null?void 0:n.pushNotification)==null?void 0:e.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((t=navigator.vendor)==null?void 0:t.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(Se.browser=ct.SafariDesktop),/SamsungBrowser/.test(navigator.userAgent)&&(Se.isSamsungBrowser=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?Se.device=Ne.PlayStation4:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?Se.device=Ne.PlayStation5:/Tizen/.test(navigator.userAgent)?Se.device=Ne.Tizen:/[Ww]eb[O0]S/.test(navigator.userAgent)?/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?Se.device=Ne.WebOs2022:/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent)?Se.device=Ne.WebOs2021:Se.device=Ne.WebOsOther:navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?Se.device=Ne.PhilipsNetTv:/[Pp]anasonic/.test(navigator.userAgent)?Se.device=Ne.Panasonic:navigator.userAgent.indexOf(\"Xbox\")!==-1?Se.device=Ne.Xbox:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(Se.device=Ne.A1KStb40xx))}var mi=Se;function ci(n){return new Promise(e=>{setTimeout(e,n)})}function Ct(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(d){n.deregister(o),a=!0,r(d)},function(d){n.deregister(o),a=!0,i(d)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}function ln(n,e){return Ct(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var z=class{constructor(e){let[t,r]=Qd();this._isUsed=!1,this._trigger=t,this._taskName=e,this.signal=new pi(r)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(r=>{this.cancel(r.reason)});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=new oe(this._taskName,e);this._trigger(t)}static isCancellationError(e){return e instanceof oe}},pi=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(\"utils\",\"Error while calling clean up listener\",r instanceof Error?r:\"Unknown Error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(Ie(this.cancellationError!==null),e(this.cancellationError),O):(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(e,t){let r=e!==void 0?`\"${e}\" task cancelled.`:\"This task was cancelled.\";t!==void 0&&(r+=\" Reason: \"+t),super(r),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\",this.reason=t,e!==void 0&&c.debug(\"utils\",`task cancellation: \"${e}\"`+(t===void 0?\"\":` - Reason: \"${t}\"`))}};function Qd(){let n=O;return[function(t){n(t)},function(t){n=t}]}var $d=[\"\",\"webkit\",\"moz\",\"ms\"];function Xd(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 Zd(n,e){return e.filter(t=>Xd(n,t))[0]}function Jd(n,e){return n.reduce((t,r)=>t.concat((e===void 0?$d:e).map(i=>i+r)),[])}function Pe(n,e){let t,r=Jd(n,e);return(i,a,o)=>{if(!o.isCancelled()){if(typeof HTMLElement!=\"undefined\"&&i instanceof HTMLElement)if(typeof t==\"undefined\"&&(t=Zd(i,r)),Q(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{c.warn(\"utils\",`element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let d=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(d=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),d&&delete i[\"on\"+s]})})}}}var Th=Pe([\"loadedmetadata\"]),Eh=Pe([\"timeupdate\"]),_h=Pe([\"addtrack\"]),Rh=Pe([\"removetrack\"]),Ft=Pe([\"sourceopen\",\"webkitsourceopen\"]),Sr=Pe([\"sourceclose\",\"webkitsourceclose\"]),yr=Pe([\"sourceended\",\"webkitsourceended\"]),vo=Pe([\"update\"]),Co=Pe([\"removesourcebuffer\"]),Ph=Pe([\"keymessage\",\"message\"]),vh=Pe([\"keyadded\",\"ready\"]),Ch=Pe([\"keyerror\",\"error\"]),Ah=Pe([\"keystatuseschange\"]),xh=Pe([\"seeking\"]),kh=Pe([\"seeked\"]),Mh=Pe([\"ended\"]);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 Tr(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 Er(n){let e=n.length%4,t=n;e!==0&&(c.warn(\"utils\",\"base64ToBytes: base64 given miss padding\",{padding:e}),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 d=0,u=0;d<a;d+=4,u+=3)s=Tr(t.charCodeAt(d))<<18|Tr(t.charCodeAt(d+1))<<12|Tr(t.charCodeAt(d+2))<<6|Tr(t.charCodeAt(d+3)),o[u]=s>>16,o[u+1]=s>>8&255,o[u+2]=s&255;return o.subarray(0,o.length-i)}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 xo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function gi(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function re(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function pt(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 ko(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)}function Oe(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 Ze(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=re(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=pt(n,r+8)}if(isNaN(i)||i<=0)return-1;if(re(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function _r(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=Ze(r,1836019558);if(i<0)break;let a=re(n,i+e),o=e+i+a;if(o>n.length)break;let s=Ze(r,1835295092);if(s<0)break;let d=re(n,s+e),u=e+s+d;if(u>n.length)break;let f=Math.max(o,u),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function eu(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function tu(n,e,t){return n.slice(e,t)}var hi=typeof Uint8Array.prototype.slice==\"function\"?tu:eu;function Ii(n,e){let t=n;for(let r of e){let i=pe(t,r);if(i===null)return null;t=i}return t}function pe(n,e){let t=zt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function Mo(n,e){let t=[],r=n;for(;;){let i=zt(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 zt(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=re(n,o),o+=4,i=re(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=pt(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 Rr(n){let e=0,t=pe(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=zt(t,1886614376)}catch(s){let d=s instanceof Error?s:\"\";return c.warn(\"isobmff\",\"Error while removing PSSH from ISOBMFF\",d),r}if(i===null)return r;let a=hi(t,i[0],i[2]),o=Oo(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 Oo(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=hi(n,t,t+16);return br(r)}function bi(n){let e=pe(n,1836019558);return e===null?null:pe(e,1953653094)}function wo(n){return Mo(n,1836019558).reduce((t,r)=>{let i=pe(r,1953653094);return i!==null&&t.push(i),t},[])}function Si(n){return pe(n,1835295092)}function yi(n){let e=pe(n,1836019574);if(e===null)return null;let t=pe(e,1953653099);return t===null?null:pe(t,1835297121)}function Do(n,e=0){return pe(n.subarray(e),1701671783)}function fn(n,e){let t=zt(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=re(n,a);a+=4;let d;if(o===0)d=re(n,a),a+=4,r+=re(n,a)+i,a+=4;else if(o===1)d=pt(n,a),a+=8,r+=pt(n,a)+i,a+=8;else return null;let u=[];a+=2;let f=xo(n,a);for(a+=2;--f>=0;){let l=re(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 h=re(n,a);a+=4,a+=4,u.push({time:d,duration:h,timescale:s,range:[r,r+p-1]}),d+=h,r+=p}return u}function Ti(n){let e=bi(n);if(e===null)return;let t=pe(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return pt(t,4);if(r===0)return re(t,4)}function nu(n){let e=pe(n,1952868452);if(e===null)return;let t=1,r=gi(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),re(e,t)):void 0}function Ei(n){let e=wo(n);if(e.length===0)return;let t=0;for(let r of e){let i=pe(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=gi(i,a);a+=3;let d=(s&256)>0,u=0;if(!d&&(u=nu(r),u===void 0))return;let f=(s&1)>0,l=(s&4)>0,m=(s&512)>0,p=(s&1024)>0,h=(s&2048)>0,b=re(i,a);a+=4,f&&(a+=4),l&&(a+=4);let g=b,S=0;for(;g-- >0;)d?(S+=re(i,a),a+=4):S+=u,m&&(a+=4),p&&(a+=4),h&&(a+=4);t+=S}return t}function mn(n){let e=yi(n);if(e===null)return;let t=pe(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return re(t,r+16);if(i===0)return re(t,r+8)}function Bo(n){let e=[],t=0;for(;t<n.length;){let r=Do(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:d}=li(r,o);o=s;let{end:u,string:f}=li(r,o);o=u;let l=re(r,o);o+=4;let m=re(r,o);o+=4;let p=re(r,o);o+=4;let h=re(r,o);o+=4;let b=r.subarray(o,i),g={schemeIdUri:d,value:f,timescale:l,presentationTimeDelta:m,eventDuration:p,id:h,messageData:b};e.push(g)}}if(e.length!==0)return e}function No(n){let e=Ii(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=pe(t,1701733238),i=0;if(r===null?(i=28,r=pe(t,1701733217)):i=78,r===null)return null;let a=Ii(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 ge(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,d)=>s===d||typeof s==\"number\"&&typeof d==\"number\"&&isNaN(s)&&isNaN(d);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function ru(n,e){let{mimeType:t,codecs:r}=Uo(n),{mimeType:i,codecs:a}=Uo(e);if(t!==i||r===\"\"||a===\"\")return!1;let o=r.split(\".\")[0];o=o===\"hev1\"?\"hvc1\":o;let s=a.split(\".\")[0];return s=s===\"hev1\"?\"hvc1\":s,o===s}var iu=7;function Uo(n){var i;let[e,...t]=n.split(\";\"),r=(i=j(t,a=>Oe(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(iu),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Lo=ru;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)},[])}function Ri(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Fo(n){var t,r,i,a,o;let e=[];for(let s of n.periods){let d=[...(t=s.adaptations.video)!=null?t:[],...(r=s.adaptations.audio)!=null?r:[]];for(let u of d)if(u.supportStatus.hasCodecWithUndefinedSupport)for(let f of u.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 zo=[];function nt(n){ge(zo,n)||(console.warn(n),zo.push(n))}var cn=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 gt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=au(e.adaptations,t,r),Wo(this.adaptations.video)&&Wo(this.adaptations.audio))throw new Z(\"MANIFEST_PARSE_ERROR\",\"The manifest has no video nor audio tracks.\");this.thumbnailTracks=e.thumbnailTracks.map(i=>({id:i.id,mimeType:i.mimeType,index:i.index,cdnMetadata:i.cdnMetadata,height:i.height,width:i.width,horizontalTiles:i.horizontalTiles,verticalTiles:i.verticalTiles,start:i.start,end:i.end,tileDuration:i.tileDuration})),this.duration=e.duration,this.start=e.start,!C(this.duration)&&!C(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)for(let a of i){if(!a.supportStatus.hasCodecWithUndefinedSupport)continue;let o=a.supportStatus.hasSupportedCodec;a.refreshCodecSupport(t),o!==!1&&a.supportStatus.hasSupportedCodec===!1&&e.push(a)}},{})}getAdaptations(){return ui(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return j(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return ho(this,e)}containsTime(e,t){return di(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,thumbnailTracks:this.thumbnailTracks.map(r=>({id:r.id,mimeType:r.mimeType,height:r.height,width:r.width,horizontalTiles:r.horizontalTiles,verticalTiles:r.verticalTiles,start:r.start,end:r.end,tileDuration:r.tileDuration}))}}};function Wo(n){return Array.isArray(n)?n.length===0:!0}function au(n,e,t){let r={};for(let[i,a]of Object.entries(n))C(a)||(r[i]=a.map(o=>new ft(o,e,{representationFilter:t})).filter(o=>o.representations.length>0));return r}function pn(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[],updatedThumbnailTracks:[],removedThumbnailTracks:[],addedThumbnailTracks:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.thumbnailTracks,a=e.thumbnailTracks;for(let d=0;d<i.length;d++){let u=i[d],f=ne(a,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'ThumbnailTrack \"'+i[d].id+'\" not found when merging.');let[l]=i.splice(d,1);d--,r.removedThumbnailTracks.push({id:l.id})}else{let[l]=a.splice(f,1);u.mimeType=l.mimeType,u.height=l.height,u.width=l.width,u.horizontalTiles=l.horizontalTiles,u.verticalTiles=l.verticalTiles,u.start=l.start,u.end=l.end,u.tileDuration=l.tileDuration,u.cdnMetadata=l.cdnMetadata,t===0?u.index._replace(l.index):u.index._update(l.index),r.updatedThumbnailTracks.push({id:u.id,mimeType:u.mimeType,height:u.height,width:u.width,horizontalTiles:u.horizontalTiles,verticalTiles:u.verticalTiles,start:u.start,end:u.end,tileDuration:u.tileDuration})}}a.length>0&&(c.warn(\"manifest\",`${a.length} new Thumbnail tracks found when merging.`),r.addedThumbnailTracks.push(...a.map(d=>({id:d.id,mimeType:d.mimeType,height:d.height,width:d.width,horizontalTiles:d.horizontalTiles,verticalTiles:d.verticalTiles,start:d.start,end:d.end,tileDuration:d.tileDuration}))),n.thumbnailTracks.push(...a));let o=n.getAdaptations(),s=e.getAdaptations();for(let d=0;d<o.length;d++){let u=o[d],f=ne(s,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'Adaptation \"'+o[d].id+'\" not found when merging.');let[l]=o.splice(d,1);d--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=s.splice(f,1),m=[],p=[],h=[];r.updatedAdaptations.push({adaptation:u.id,trackType:u.type,updatedRepresentations:m,addedRepresentations:p,removedRepresentations:h});let b=u.representations,g=l.representations.slice();for(let S=0;S<b.length;S++){let T=b[S],v=ne(g,E=>E.id===T.id);if(v===-1){c.warn(\"manifest\",`Representation \"${b[S].id}\" not found when merging.`);let[E]=b.splice(S,1);S--,h.push(E.id)}else{let[E]=g.splice(v,1);m.push(T.getMetadataSnapshot()),T.cdnMetadata=E.cdnMetadata,t===0?T.index._replace(E.index):T.index._update(E.index)}}g.length>0&&(c.warn(\"manifest\",`${g.length} new Representations found when merging.`),u.representations.push(...g),p.push(...g.map(S=>S.getMetadataSnapshot())))}}if(s.length>0){c.warn(\"manifest\",`${s.length} new Adaptations found when merging.`);for(let d of s){let u=n.adaptations[d.type];u===void 0?n.adaptations[d.type]=[d]:u.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function qo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,d=n[s];for(;d!==void 0&&d.id!==o.id;)s++,d=n[s];if(d!==void 0){let u=pn(d,o,0);t.updatedPeriods.push({period:{id:d.id,start:d.start,end:d.end,duration:d.duration,streamEvents:d.streamEvents},result:u});let f=e.slice(r,a),l=s-r,m=n.splice(r,l,...f);t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end}))),t.addedPeriods.push(...f.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 Vo(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 Z(\"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 Z(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=pn(n[i],e[0],1);t.updatedPeriods.push({period:K(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let d=e[s],u=-1;for(let f=o;f<n.length;f++)if(d.id===n[f].id){u=f;break}if(u<0){let f=-1;for(let p=o;p<n.length;p++)if(d.start<n[p].start){f=p;break}let l=f-o,m=n.splice(o,l,d);t.addedPeriods.push(d.getMetadataSnapshot()),t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end})))}else{if(u>o){c.warn(\"manifest\",\"old Periods not found in new when updating, removing\");let l=n.splice(o,u-o);t.removedPeriods.push(...l.map(m=>({id:m.id,start:m.start,end:m.end}))),u=o}let f=pn(n[u],d,0);t.updatedPeriods.push({period:K(n[u].getMetadataSnapshot(),{adaptations:void 0}),result:f})}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(d=>({id:d.id,start:d.start,end:d.end})))}return t}var ou=Me(),gn=class extends le{constructor(e,t){var a;super();let{representationFilter:r,manifestUpdateUrl:i}=t;this.manifestFormat=0,this.id=ou(),this.expired=(a=e.expired)!=null?a:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new cn([]),this.periods=e.periods.map(o=>new gt(o,this._cachedCodecSupport,r)).sort((o,s)=>o.start-s.start),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=i,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 Z(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(vt)}):null}getPeriod(e){return j(this.periods,t=>e===t.id)}getPeriodForTime(e){return Io(this,e)}getNextPeriod(e){return j(this.periods,t=>t.start>e)}getPeriodAfter(e){return bo(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return co(this)}getLivePosition(){return po(this)}getMaximumSafePosition(){return go(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=su(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}addRepresentationsToAvoid(e){let t=[];for(let r of e){let i=this.getPeriod(r.period.id);if(i===void 0)continue;let a=i.getAdaptation(r.adaptation.id);if(a===void 0)continue;let o=a.getRepresentation(r.representation.id);o!==void 0&&(o.shouldBeAvoided=!0,t.push({manifest:this,period:i,adaptation:a,representation:o}))}t.length>0&&this.trigger(\"representationAvoidanceUpdate\",t)}getAdaptations(){nt(\"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(Object.prototype.hasOwnProperty.call(t,i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){nt(\"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 nt(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),j(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 Fo(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=qo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Vo(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 su(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},d=e(s);d!==!1&&(a=!1),d!==o.decipherable&&(t.push(s),o.decipherable=d,d===!0?i.supportStatus.isDecipherable=!0:d===void 0&&i.supportStatus.isDecipherable===!1&&(i.supportStatus.isDecipherable=void 0),c.debug(\"manifest\",`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function tt(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function Ge(n){if(C(n))return null;let{period:e,adaptation:t,representation:r,segment:i}=n;return{t:t.type[0],p:e.id,a:t.id,r:r.id,ss:i.isInit?null:i.time,se:i.isInit||!i.complete?null:i.end}}var ht=gn;var xt=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 Pr(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){t.isCancelled()||a.clearSignal.isCancelled()||r.onUpdate(i,{clearSignal:a.clearSignal,emitCurrentValue:a.includeLastObservation})},deriveReadOnlyObserver(i){return Pr(this,i,t)}}}var hn=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){this._cancelSignal.isCancelled()||t.clearSignal.isCancelled()||this._src.onUpdate(e,{clearSignal:t.clearSignal,emitCurrentValue:t.includeLastObservation})}deriveReadOnlyObserver(e){return Pr(this,e,this._cancelSignal)}};var rt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var kt=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 j(this._array,e)}has(e){return ge(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 In=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 du=.016666666666666666;function Go(n,e){return Math.abs(n-e)<du}function Ko(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function uu(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function lu(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Yo(t,r)){let i=Ko(t,r);n.splice(--e,2,i)}}return n}function Pi(n,e){return n.end<=e.start}function Ho({start:n,end:e},t){return n<=t&&t<e}function jo(n,e){return Ho(n,e.start)||n.start<e.end&&e.end<n.end||Ho(e,n.start)}function Yo(n,e){return Go(e.start,n.end)||Go(e.end,n.start)}function vi(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function fu(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 Qo(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 vr(n,e){let t=fu(n,e);return t!==null?t.end-e:1/0}function It(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=jo(t,i),o=Yo(t,i);if(a||o)t=Ko(t,i),n.splice(r--,1);else if(r===0){if(Pi(t,n[0]))break}else if(Pi(n[r-1],t)&&Pi(t,i))break}return n.splice(r,0,t),lu(uu(n))}function mu(n,e){let t=[];for(let r=0;r<e.length;r++)jo(n,e[r])&&t.push(e[r]);return t}function Cr(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=mu(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let d=o[s];a.push({start:Math.max(i.start,d.start),end:Math.min(i.end,d.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let d=0;d<a.length;d++)a[d].start>s&&t.push({start:s,end:a[d].start}),s=a[d].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function Ar({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(d=>{a=d.position.getWanted(),o=d.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&cu(n,a,o,t.getValue(),r.getValue(),i).catch(d=>{if(i.isCancelled()&&z.isCancellationError(d))return;let u=d instanceof Error?d.message:\"Unknown error\";c.error(\"Stream\",\"Could not run BufferGarbageCollector:\",u)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function cu(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:d}=Qo(t,e),u=()=>{if(isFinite(r)){for(let l of d)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});C(s)||e-r>s.start&&o.push({start:s.start,end:e-r})}},f=()=>{if(isFinite(i)){for(let l of d)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});C(s)||e+i<s.end&&o.push({start:e+i,end:s.end})}};u(),f();for(let l of o)if(l.start<l.end){if(c.debug(\"Stream\",\"cleaning range from SegmentSink\",{start:l.start,end:l.end}),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var bn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=F();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>tt(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 Sn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=L.getCurrent();this._inventory=[],this._bufferedHistory=new bn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var d,u,f,l,m,p,h;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(c.hasLevel(\"DEBUG\")){let b=e.map(g=>`${g.start}-${g.end}`).join(\",\");c.debug(\"SI\",`synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,b)}let s=e.length;for(let b=0;b<s;b++){if(i===void 0)return;let g=e[b].start,S=e[b].end;if(S-g<a){c.warn(\"SI\",\"skipped range when synchronizing because it was too small\",{t:o,rangeStart:g,rangeEnd:S});continue}let T=r;for(;i!==void 0&&((d=i.bufferedEnd)!=null?d:i.end)-g<a;)i=t[++r];let v=null,E=r-T;if(E>0){let _=t[T+E-1];v={end:(u=_.bufferedEnd)!=null?u:_.end,precizeEnd:_.precizeEnd},c.debug(\"SI\",`${E} segments GCed.`,{t:o});let k=t.splice(T,E);for(let A of k)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(S-((f=i.bufferedStart)!=null?f:i.start)>=a){if(pu(i,g,v,o),r===t.length-1){Xo(i,S,o);return}i=t[++r];let _=(l=i.bufferedStart)!=null?l:i.start,k=(m=i.bufferedEnd)!=null?m:i.end,A=b<s-1?e[b+1].start:void 0;for(;i!==void 0&&!(S<_||S-_<a&&k-S>=a||A!==void 0&&S-_<k-A);){let x=t[r-1];x.bufferedEnd===void 0&&(i.precizeStart?x.bufferedEnd=i.start:x.infos.segment.complete?x.bufferedEnd=x.end:x.bufferedEnd=i.start,c.debug(\"SI\",\"calculating buffered end of contiguous segment\",{t:o,prevSegmentBufferedEnd:x.bufferedEnd,pse:x.end})),i.bufferedStart=x.bufferedEnd,i=t[++r],i!==void 0&&(_=(p=i.bufferedStart)!=null?p:i.start,k=(h=i.bufferedEnd)!=null?h:i.end)}}let R=t[r-1];R!==void 0&&Xo(R,S,o)}if(!C(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:b}=L.getCurrent(),g=F();for(let S=r;S<t.length;S++){let T=t[S];g-T.insertionTs>=b&&(c.debug(\"SI\",\"A segment at the end has been completely GCed\",Ge(T.infos)),T.bufferedStart===void 0&&T.bufferedEnd===void 0&&T.status!==2&&this._bufferedHistory.addBufferedSegment(T.infos,null),t.splice(S,1),S--)}}o!==void 0&&c.hasLevel(\"DEBUG\")&&c.debug(\"SI\",`current ${o} inventory timeline:\n`+gu(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},d,u){if(i.isInit)return;let f=t.type;if(o>=s){c.warn(\"SI\",\"Invalid chunked inserted: starts before it ends\",{t:f,start:o,end:s});return}let l=this._inventory,m={status:d?0:2,insertionTs:u,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 h=l.length-1;h>=0;h--){let b=l[h];if(b.start<=o)if(b.end<=o){for(c.debug(\"SI\",\"Pushing segment strictly after previous one.\",{t:f,pse:b.end,ss:o}),this._inventory.splice(h+1,0,m),h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,pss:l[h].start,ss:o,se:s}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,1)}return}else if(b.start===o)if(b.end<=s){for(c.debug(\"SI\",\"Segment pushed replace another one\",{t:f,ss:o,se:s,pss:b.start,pse:b.end}),this._inventory.splice(h,1,m),h+=1;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,1)}return}else{c.debug(\"SI\",\"Segment pushed ends before another with the same start\",{t:f,ss:o,se:s,pse:b.end}),l.splice(h,0,m),b.start=m.end,b.bufferedStart=void 0,b.precizeStart=b.precizeStart&&m.precizeEnd;return}else if(b.end<=m.end){for(c.debug(\"SI\",\"Segment pushed updates end of previous one\",{t:f,ss:o,se:s,pss:b.start,pse:b.end}),this._inventory.splice(h+1,0,m),b.end=m.start,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,1)}return}else{c.warn(\"SI\",\"Segment pushed is contained in a previous one\",{t:f,ss:o,se:s,pss:b.start,pse:b.end});let g={status:b.status,insertionTs:b.insertionTs,chunkSize:b.chunkSize,splitted:!0,start:m.end,end:b.end,precizeStart:b.precizeStart&&b.precizeEnd&&m.precizeEnd,precizeEnd:b.precizeEnd,bufferedStart:void 0,bufferedEnd:b.end,infos:b.infos};b.end=m.start,b.splitted=!0,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,l.splice(h+1,0,m),l.splice(h+2,0,g);return}}let p=this._inventory[0];if(p===void 0){c.debug(\"SI\",\"first segment pushed\",{t:f,ss:o,se:s}),this._inventory.push(m);return}if(p.start>=s)c.debug(\"SI\",\"Segment pushed comes before all previous ones\",{t:f,ss:o,se:s,pss: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\",{t:f,ss:o,se:s,pss:p.start,pse: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\",{t:f,ss:o,se:s,pss:l[1].start,pse:l[1].end}),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\",{t:f,ss:o,se:s,pss:l[1].start,pse:l[1].end}),l.splice(1,1)}return}else{c.debug(\"SI\",\"Segment pushed start of the next one\",f,{ss:o,se:s,pss:p.start,pse: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(tt(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI\",\"Completed Segment is splitted.\",Ge(e)),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&tt(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let d=i-1,u=d-o,f=t[d].end,l=t[d].bufferedEnd;u>0&&(this._inventory.splice(o+1,u),i-=u),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)c.warn(\"SI\",\"Completed Segment not found\",Ge(e));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.\",{ss:i.start,se:i.end})}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function Ci(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 $o(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 pu(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&&(c.debug(\"SI\",\"Segment partially GCed at the start\",{t:r,firstsbs:n.bufferedStart,rs:e}),n.bufferedStart=e),!n.precizeStart&&Ci(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI\",\"buffered start is precize start\",{t:r,firstss: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\",{t:r,rs:e,firstss:n.start,lastdelse:t.end}),n.bufferedStart=t.end,Ci(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=F();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI\",\"Ignored bufferedStart synchronization\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"found true buffered start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e,Ci(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI\",\"range start too far from expected start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=n.start;else{let s=F();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI\",\"Ignored bufferedStart synchronization\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e}}function Xo(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&&(c.debug(\"SI\",\"Segment partially GCed at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&$o(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI\",\"buffered end is precize end\",{t,lastse:n.end}),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=F();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI\",\"Ignored bufferedEnd synchronization\",{t,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"found true buffered end\",{t,re:e,lastse:n.end}),n.bufferedEnd=e,$o(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI\",\"range end too far from expected end\",{t,re:e,lastse:n.end}),n.bufferedEnd=n.end;else{let o=F();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI\",\"Ignored bufferedEnd synchronization\",{t,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e}}function gu(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(d){let u=String.fromCharCode(r.length+65);return r.push({letter:u,periodId:d.period.id,representationId:d.representation.id,bitrate:d.representation.bitrate}),u}let s=\"\";for(let d of n)if(d.bufferedStart!==void 0&&d.bufferedEnd!==void 0){let u=d.infos.period.id,f=d.infos.representation.id,l=t[u],m;if(l===void 0)m=o(d.infos),t[u]={[f]:m};else{let p=l[f];p===void 0?(m=o(d.infos),l[f]=m):m=p}i===null?s+=`${d.bufferedStart.toFixed(2)}|${m}|`:a===m?i.bufferedEnd+e<d.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`,i=d,a=m}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(d=>{var u;s+=`\n[${d.letter}] P: ${d.periodId} || R: ${d.representationId}(${(u=d.bitrate)!=null?u:\"unknown bitrate\"})`}),s}function Wt(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 qt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var Zo=Sn;var Vt=class{constructor(){this._segmentInventory=new Zo}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var yn=class extends Vt{constructor(e,t,r){super(),c.info(\"Stream\",\"calling `mediaSource.addSourceBuffer`\",{codec: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){Jo(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Jo(e.data.chunk),c.debug(\"Stream\",\"queuing push order\",Ge(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:d,appendWindow:u}=e.data;return c.debug(\"Stream\",\"now pushing\",Ge(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:d,appendWindow:u})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,F()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,F());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"Stream\",\"queuing remove order\",{bufferType:this.bufferType,start:e,end: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(e){try{c.debug(\"Stream\",\"Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose(e)}catch(t){c.debug(\"Stream\",`Failed to dispose a ${this.bufferType} SourceBufferInterface:`,t instanceof Error?t:\"Unknown Error\")}}_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 Jo(n){if(I.CURRENT_ENV!==I.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var kr=yn;var Tn=class extends Vt{constructor(e){c.debug(\"Stream\",\"Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"Stream\",\"Declaring initialization segment for Text SegmentSink\",{uniqueId:e})}freeInitSegment(e){c.warn(\"Stream\",\"Freeing initialization segment for Text SegmentSink\",{uniqueId:e})}async pushChunk(e){let{data:t}=e;Iu(t.chunk);let r=this._sender.pushTextData(se(J({},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,F()),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(\"Stream\",\"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 Iu(n){if(I.CURRENT_ENV!==I.PRODUCTION){if(typeof n!=\"object\"||n===null||C(n.data))throw new Error(\"Invalid format given to a TextSegmentSink\");if(!bu(n))throw new Error(\"Invalid format given to a TextSegmentSink\");if(typeof n.data!=\"string\"&&typeof n.data.byteLength!=\"number\")throw new Error(\"Invalid format given to a TextSegmentSink\")}}function bu(n){return!(typeof n!=\"object\"||n===null||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.initTimescale!==null&&typeof n.initTimescale!=\"number\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\")}I.CURRENT_ENV===I.DEV&&(Su=function(e){function t(r){}});var Su;var es=Tn;var yu=[\"audio\",\"video\",\"text\"],En=class n{static isNative(e){return ts(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():Ct(e,t=>{let r=O,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(\"Stream\",`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.slice().forEach(r=>r()),Ie(this._onNativeBufferAddedOrDisabled.length===0))}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(ts(e)){if(!C(r))return r instanceof kr&&r.codec!==t?c.warn(\"Stream\",\"Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"Stream\",\"Reusing native SegmentSink with codec\",t),r;c.info(\"Stream\",\"Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new kr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),Ie(this._onNativeBufferAddedOrDisabled.length===0),o}if(!C(r))return c.info(\"Stream\",\"Reusing a previous custom SegmentSink\",{bufferType:e}),r;let i;if(e===\"text\"){if(c.info(\"Stream\",\"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 c.error(\"Stream\",\"Unknown buffer type:\",{bufferType:e}),new Z(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(C(r)){c.warn(\"Stream\",\"Trying to dispose a SegmentSink that does not exist\",{bufferType:e});return}c.info(\"Stream\",\"Aborting SegmentSink\",{bufferType:e}),r.dispose(t),delete this._initializedSegmentSinks[e]}disposeAll(e){yu.forEach(t=>{this.getStatus(t).type===\"initialized\"&&this.disposeSegmentSink(t,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 i,a;let t=(i=this._initializedSegmentSinks[e])==null?void 0:i.getLastKnownInventory(),r;if(t!==void 0){r=0;for(let o of t){if(o.chunkSize===void 0||r===void 0){r=void 0;break}r+=o.chunkSize}}return{bufferType:e,sizeEstimate:r,codec:(a=this._initializedSegmentSinks[e])==null?void 0:a.codec,segmentInventory:t==null?void 0:t.map(o=>se(J({},o),{infos:Tu(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function ts(n){return n===\"audio\"||n===\"video\"}function Tu(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=En;function Ai(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,d=Eu(i,e);if(d===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 u=i[d];if(u.bufferedStart!==void 0&&u.bufferedStart>e.start&&(t===null||u.infos.segment.end<=t)){let l=u.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(c.debug(\"Stream\",\"current discontinuity encountered\",{bufferType:o.type,nextSegmentTime:u.bufferedStart,checkStartTime:e.start}),{start:void 0,end:l})}let f=_u(i,e,d+1);if(f!==null){let l=i[f-1],m=i[f];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,h=m.bufferedStart;return c.debug(\"Stream\",\"future discontinuity encountered\",{bufferType:o.type,discontinuityStart:p,discontinuityEnd:h}),{start:p,end:h}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=Ru(i,a.end);if(l!==null){let m=i[l];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"Stream\",\"discontinuity encountered at the end of the current period\",{bufferType:o.type,segmentsEndTimeFromPeriod:m.bufferedEnd,periodEnd: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 Eu(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 _u(n,e,t){if(t<=0)return c.error(\"Stream\",\"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 Ru(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 xi({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:d,representation:u}=e,f=Pu(n,o,s),l=u.index.getSegments(a.start,a.end-a.start),m=n.filter(R=>!ns(R.infos,e,t,r)),p=Ou(m,a,i),{MINIMUM_SEGMENT_SIZE:h,MIN_BUFFER_AHEAD:b}=L.getCurrent(),g=!1,S=Math.min(1/60,h),T=!1,v=[];return{segmentsToLoad:l.filter(R=>{let _=K({segment:R},e);if(o.length>0&&o.some(N=>tt(_,N)))return!1;let{duration:k,time:A,end:x}=R;if(R.isInit)return!0;if(g)return v.push(R),!1;if(R.complete&&k<h||o.length>0&&o.some(N=>{if(N.period.id!==e.period.id||N.adaptation.id!==e.adaptation.id)return!1;let{segment:P}=N;if(P.time-S>A)return!1;if(P.complete){if(P.end+S<x)return!1}else if(Math.abs(A-P.time)>A)return!1;return!ns(N,_,t,r)}))return!1;for(let W of p){let N=W.infos.period.id===e.period.id;if(W.status===1&&N){let P=W.infos.segment;if(A-P.time>-S){if(P.complete){if(P.end-x>-S)return!1}else if(Math.abs(A-P.time)<S)return!1}}}let B=k*e.representation.bitrate;if(f-B<0&&(T=!0,A>a.start+b))return g=!0,v.push(R),!1;let D=i(_);if(D.length>1){let W=D[D.length-1],N=D[D.length-2];if(W.buffered===null&&N.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.\",{bufferType:d.type,representationId:u.id,segmentTime:R.time}),!1}for(let W=0;W<p.length;W++){let N=p[W];if(N.end+S>A){let P=N.start>A+S||vu(p,W).end<x-S;return P&&(f-=B),P}}return f-=B,!0}),segmentsOnHold:v,isBufferFull:T}}function Pu(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 vu(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 ns(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:Cu(n.representation,e.representation,r)}function Cu(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 Au(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?(c.info(\"Stream\",\"The start of the wanted segment has been garbage collected\",{segmentStart:n.start,currentStartInBuffer:n.bufferedStart}),!0):!1}function xu(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?(c.info(\"Stream\",\"The end of the wanted segment has been garbage collected\",{segmentEnd:n.end,currentEndInBuffer:n.bufferedEnd}),!0):!1}function ku(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 Mu(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 Ou(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],d=null;if(Au(r,o,e.start)){if(d=t(r.infos),ku(d,r.bufferedStart))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the start\",{segmentStart:r.start,currentStartInBuffer:r.bufferedStart})}if(xu(r,s,e.end)){if(d=d!=null?d:t(r.infos),Mu(d,r.bufferedEnd))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the end\",{segmentEnd:r.end,currentEndInBuffer:r.bufferedEnd})}return!0})}function _n(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 ki(n,e,t,r,i,a,o){var A,x,B;let{representation:s}=n,d=(x=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?x:t.getReference().getValue().paused.last,u=(B=t.getPlaybackRate())!=null?B:t.getReference().getValue().speed,f=e;(d===void 0||u===void 0||d||u<=0)&&(f-=.1);let l=wu(n,f,i),m=s.index.shouldRefresh(l.start,l.end),p=o.getPendingOperations().filter(D=>D.type===2).map(D=>D.value),h=o.getLastKnownInventory(),b=t.getCurrentTime();b===void 0&&(b=t.getReference().getValue().position.getWanted());let g=o.getSegmentHistory.bind(o),{segmentsToLoad:S,segmentsOnHold:T,isBufferFull:v}=xi({content:n,bufferedSegments:h,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:g,neededRange:l,segmentsBeingPushed:p,maxBufferSize:a}),E=S.map(D=>({priority:_n(D.time,f),segment:D})),R=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,_=null;return p.length>0&&(_=Math.min(...p.map(D=>D.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:Ai(n,l,_,R,h),hasFinishedLoading:R,neededSegments:E,isBufferFull:v,shouldRefreshManifest:m}}function wu(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),d=o.index;!C(s)&&bt.isNative(n.adaptation.type)&&e>=s&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&Du(i,a,e)?r=s-1:r=e-.1;let u=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=u>=a.end:s===null?f=!0:f=u>=s,{start:Math.max(r,a.start),end:Math.min(u,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function Du(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 Rn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof oe)throw a;if(!(a instanceof xe)||!a.isBufferFull){let d=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",d,{tracks:[vt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream\",\"Running garbage collector\");let d=Math.max(s-5,0),u=s+r.getValue()+12;if(d>0&&await e.removeBuffer(0,d),u<Number.MAX_VALUE&&await e.removeBuffer(u,Number.MAX_VALUE),await ci(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(d){if(d instanceof oe)throw d;let u=d instanceof Error?d.toString():\"Could not clean the buffer\";throw new Z(\"BUFFER_FULL_ERROR\",u,{tracks:[vt(t.inventoryInfos.adaptation)]})}}}async function Mi({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){let s=e.representation.getMimeTypeString(),d={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},u=K({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Rn(n,i,{data:d,inventoryInfos:u},a,o);return{content:e,segment:r,buffered:f}}async function Oi({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var _,k;if(i.chunkData===null)return null;let{chunkData:d,chunkInfos:u,chunkOffset:f,chunkSize:l,appendWindow:m}=i,p=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:h}=L.getCurrent(),b=[m[0]!==void 0?Math.max(0,m[0]-h.START):void 0,m[1]!==void 0?m[1]+h.END:void 0],g={initSegmentUniqueId:r,chunk:d,timestampOffset:f,appendWindow:b,codec:p},S=(_=u==null?void 0:u.time)!=null?_:a.time,T=(k=u==null?void 0:u.duration)!=null?k:a.duration,v=S+T;b[0]!==void 0&&(S=Math.max(S,b[0])),b[1]!==void 0&&(v=Math.min(v,b[1]));let E=K({segment:a,chunkSize:l,start:S,end:v},t),R=await Rn(n,o,{data:g,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:R}}function wi({content:n,options:e,playbackObserver:t,segmentSink:r,segmentQueue:i,terminate:a},o,s){c.debug(\"Stream\",\"Creating RepresentationStream\",{periodStart:n.period.start,bufferType:n.adaptation.type,adaptationId:n.adaptation.id,representationBitrate:n.representation.bitrate,mimeType:n.representation.getMimeTypeString()});let{period:d,adaptation:u,representation:f}=n,{bufferGoal:l,maxBufferSize:m,drmSystemId:p,fastSwitchThreshold:h}=e,b=u.type,g=new z(\"RepresentationStream \"+b);g.linkToSignal(s);let S={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};g.signal.register(()=>{S.uniqueId!==null&&r.freeInitSegment(S.uniqueId)});let T=S.segment!==null;T||(S.isLoaded=!0);let v=!1;if(p!==void 0){let A=f.getEncryptionData(p);if(A.length>0&&A.every(x=>x.keyIds!==void 0)&&(v=!0,o.encryptionDataEncountered(A.map(x=>K({content:n},x))),g.isUsed()))return}i.addEventListener(\"error\",A=>{g.signal.isCancelled()||(g.cancel(\"RepresentationStream: SegmentQueue err\"),o.error(A))},g.signal),i.addEventListener(\"parsedInitSegment\",_,g.signal),i.addEventListener(\"parsedMediaSegment\",_,g.signal),i.addEventListener(\"emptyQueue\",R,g.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),g.signal.isCancelled())return;let x=A.segment,{index:B}=f;B.isSegmentStillAvailable(x)===!1?R():B.canBeOutOfSyncError(A.error,x)&&o.manifestMightBeOufOfSync()},g.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(K({segment:A},n)).catch(k)},g.signal);let E=i.resetForContent(n,T,\"new RepresentationStream linked to SegmentQueue\");g.signal.register(A=>{i.stop(A.reason)}),t.listen(R,{includeLastObservation:!1,clearSignal:g.signal}),n.manifest.addEventListener(\"manifestUpdate\",R,g.signal),l.onUpdate(R,{emitCurrentValue:!1,clearSignal:g.signal}),m.onUpdate(R,{emitCurrentValue:!1,clearSignal:g.signal}),a.onUpdate(R,{emitCurrentValue:!1,clearSignal:g.signal}),R();return;function R(){if(g.isUsed())return;let A=t.getReference().getValue(),x=A.position.getWanted(),B=ki(n,x,t,h.getValue(),l.getValue(),m.getValue(),r),{neededSegments:D}=B,W=null;if(f.index.isInitialized()){if(D.length>0&&!S.isLoaded&&S.segment!==null){let M=D[0].priority;W={segment:S.segment,priority:M}}}else if(S.segment===null)c.warn(\"Stream\",\"Uninitialized index without an initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else if(S.isLoaded)c.warn(\"Stream\",\"Uninitialized index with an already loaded initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else{let M=A.position.getWanted();W={segment:S.segment,priority:_n(d.start,M)}}let N=a.getValue();if(N===null)E.setValue({initSegment:W,segmentQueue:D});else if(N.urgent){c.debug(\"Stream\",\"Urgent switch, terminate now.\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),g.cancel(N.reason),o.terminating();return}else{let M=D[0],w=i.getRequestedInitSegment(),U=i.getRequestedMediaSegment(),H=U===null||M===void 0||U.id!==M.segment.id?[]:[M],$=w===null?null:W;if(E.setValue({initSegment:$,segmentQueue:H}),H.length===0&&$===null){c.debug(\"Stream\",\"No request left, terminate\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.finish(),g.cancel(N.reason),o.terminating();return}}if(o.streamStatusUpdate({period:d,position:A.position.getWanted(),bufferType:b,imminentDiscontinuity:B.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:B.hasFinishedLoading,neededSegments:B.neededSegments}),g.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:P}=L.getCurrent();if(B.isBufferFull){let M=Math.max(0,x-P);M>0&&r.removeBuffer(0,M).catch(k)}B.shouldRefreshManifest&&o.needsManifestRefresh()}function _(A){for(let x of A.protectionData)f.addProtectionData(x.initDataType,x.keyId,x.initData);if(!v){let x=f.getAllEncryptionData();x.length>0&&(o.encryptionDataEncountered(x.map(B=>K({content:n},B))),v=!0)}if(A.segmentType===\"init\"){if(!f.index.isInitialized()&&A.segmentList!==void 0&&f.index.initialize(A.segmentList),S.isLoaded=!0,A.initializationData!==null){let x=f.uniqueId;S.uniqueId=x,r.declareInitSegment(x,A.initializationData),Mi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:x,segment:A.segment,segmentData:A.initializationData,segmentSink:r},g.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(k)}R();return}else{let{inbandEvents:x,predictedSegments:B,needsManifestRefresh:D}=A;if(B!==void 0&&f.index.addPredictedSegments(B,A.segment),D===!0&&(o.needsManifestRefresh(),g.isUsed())||x!==void 0&&x.length>0&&(o.inbandEvent(x),g.isUsed()))return;let W=S.uniqueId;Oi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:W,parsedSegment:A,segment:A.segment,segmentSink:r},g.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(k)}}function k(A){g.isUsed()&&A instanceof oe||(c.warn(\"Stream\",\"Received fatal buffer error\",{bufferType:b,representationBitrate:n.representation.bitrate},A instanceof Error?A:null),g.cancel(\"RepresentationStream: fatal buffer err\"),o.error(A))}}var rs=wi;function Di(n,e,t,r,i){var m,p,h,b;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let g of a)g.infos.period.id===n.id&&(g.infos.adaptation.id!==e.id||!ge(t.representationIds,g.infos.representation.id))&&It(o,{start:(m=g.bufferedStart)!=null?m:g.start,end:(p=g.bufferedEnd)!=null?p:g.end});let s=r.getPendingOperations();for(let g of s)if(g.type===0){let S=g.value.inventoryInfos;if(S.period.id===n.id&&(S.adaptation.id!==e.id||!ge(t.representationIds,S.representation.id))){let T=S.segment.time,v=T+S.segment.duration;It(o,{start:T,end:v})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let g=i.getReadyState();if(g===void 0||g>1)return{type:\"needs-reload\",value:void 0}}let d=t.switchingMode===\"direct\",u=[],f=Wt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&u.push({start:0,end:n.start+1}),!d){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:g}=L.getCurrent(),S=e.type,T=(h=g[S].before)!=null?h:0,v=(b=g[S].after)!=null?b:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),u.push({start:E-T,end:E+v})}if(n.end!==void 0){let g=qt(a,n);g!==null&&(g.bufferedStart===void 0||g.bufferedStart-n.end<1)&&u.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Cr(o,u);return l.length===0?{type:\"continue\",value:void 0}:d?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function Bi({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},d,u){let{manifest:f,period:l,adaptation:m}=e,p=new z(\"AdaptationStream \"+m.type);p.linkToSignal(u);let h=new Map,b=new X(null,p.signal),g,S=e.representations.getValue().representationIds,T=is(e.adaptation.representations,S),v=new X(T,p.signal),{estimates:E,callbacks:R}=r({manifest:f,period:l,adaptation:m},b,v,n,p.signal),_=new X(!1);n.listen(P=>{var w;let M=(w=P.canStream)!=null?w:!0;_.getValue()===M&&(c.debug(\"Stream\",\"isMediaSegmentQueueInterrupted updated to\",!M),_.setValue(!M))},{clearSignal:p.signal});let k=a.createSegmentQueue(m.type,{onRequestBegin:R.requestBegin,onRequestEnd:R.requestEnd,onProgress:R.requestProgress,onMetrics:R.metrics},_),A=new X(0);E.onUpdate(({bitrate:P,knownStableBitrate:M})=>{t.enableFastSwitching&&A.setValueIfChanged(M),!(P===void 0||P===g)&&(g=P,c.debug(\"Stream\",`new ${m.type} bitrate estimate received from ABR`,{bitrate:P}),d.bitrateEstimateChange({type:m.type,bitrate:P}))},{emitCurrentValue:!0,clearSignal:p.signal});let x;e.representations.onUpdate(P=>{x!==void 0&&x.cancel(\"locked representations changed\");let M=e.representations.getValue().representationIds,w=is(e.adaptation.representations,M);v.setValueIfChanged(w),x=new z(\"AdaptationStream: RepresentationStream Group \"+m.type),x.linkToSignal(p.signal),B(P,x.signal).catch(U=>{(x==null?void 0:x.isUsed())===!0&&z.isCancellationError(U)||(p.cancel(\"RepresentationStream err\"),d.error(U))})},{clearSignal:p.signal,emitCurrentValue:!0});return;async function B(P,M){let w=Di(l,m,P,i,n);switch(w.type){case\"continue\":break;case\"needs-reload\":return rt(()=>{n.listen(()=>{if(M.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:U}=L.getCurrent(),H=U.bitrateSwitch;return d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:H,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:M})});case\"flush-buffer\":case\"clean-buffer\":for(let U of w.value)if(await i.removeBuffer(U.start,U.end),M.isCancelled())return;if(w.type===\"flush-buffer\"&&(d.needsBufferFlush(),M.isCancelled()))return;break;default:Be(w)}D(M)}function D(P){let M=new z(\"AdaptationStream: RepresentationStream creation \"+m.type);M.linkToSignal(P);let{representation:w}=E.getValue();if(w===null)return;let U=new X(null,M.signal);E.onUpdate(V=>{if(!(V.representation===null||V.representation.id===w.id))return V.urgent?(c.info(\"Stream\",\"urgent Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!0,reason:\"Urgent Representation switch\"})):(c.info(\"Stream\",\"slow Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!1,reason:\"Non-urgent Representation switch\"}))},{clearSignal:M.signal,emitCurrentValue:!0});let H={type:m.type,adaptation:m,period:l,representation:w};if(b.setValue(w),P.isCancelled()||(d.representationChange(H),P.isCancelled()))return;let $={streamStatusUpdate:d.streamStatusUpdate,encryptionDataEncountered:d.encryptionDataEncountered,manifestMightBeOufOfSync:d.manifestMightBeOufOfSync,needsManifestRefresh:d.needsManifestRefresh,inbandEvent:d.inbandEvent,warning:d.warning,error(V){p.cancel(\"RepresentationStream err cb\"),d.error(V)},addedSegment(V){R.addedSegment(V)},terminating(){if(!M.isUsed())return M.cancel(\"RepresentationStream terminating\"),D(P)}};W(w,U,$,P)}function W(P,M,w,U){let H=!1,$=new z(`RepresentationStream-linked listeners in AdaptationStream - periodStart=${l.start} type=${m.type}`);$.linkToSignal(U);let V=tn(o,fe=>N(P,fe),$.signal),G=m.type===\"video\"?s:new X(1/0);c.info(\"Stream\",\"changing representation\",{bufferType:m.type,representationId:P.id,representationBitrate:P.bitrate});let Y=K({},w,{error(fe){var me;if(H){c.warn(\"Stream\",\"Ignoring RepresentationStream error\",fe);return}H=!0;let ue=ce(fe,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(ue.code!==\"BUFFER_FULL_ERROR\")w.error(fe);else{c.warn(\"Stream\",\"received BUFFER_FULL_ERROR\",{bufferType:m.type,representationBitrate:P.bitrate});let Qe=o.getValue(),ae=((me=h.get(P.id))!=null?me:1)*.7;if(h.set(P.id,ae),ae<=.05||N(P,Qe)<=2){w.error(ue);return}ln(4e3,$.signal).then(()=>W(P,M,w,U)).catch(O)}},terminating(){$.cancel(\"Representation terminating\"),w.terminating()}});rs({playbackObserver:n,content:{representation:P,adaptation:m,period:l,manifest:f},segmentSink:i,segmentQueue:k,terminate:M,options:{bufferGoal:V,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:A}},Y,U),f.addEventListener(\"manifestUpdate\",fe=>{for(let ue of fe.updatedPeriods)if(ue.period.id===l.id){for(let me of ue.result.updatedAdaptations)if(me.adaptation===m.id){for(let Qe of me.removedRepresentations)if(Qe===P.id)return $.isUsed()?void 0:d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(ue.period.start>l.start)break},$.signal)}function N(P,M){let w=h.get(P.id),U=w!==void 0?w:1;return w===void 0&&h.set(P.id,U),U<1&&M===1/0?300*1e3*U:M*U}}function is(n,e){let t=n.filter(r=>ge(e,r.id)&&!r.shouldBeAvoided&&r.isPlayable()!==!1);return t.length>0?t:n.filter(r=>ge(e,r.id)&&r.isPlayable()!==!1)}var as=Bi;function Ni(n,e,t,r,i,a){var p,h,b,g;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!Bu(t,n.codec))return{type:\"needs-reload\",value:void 0};let o=n.getLastKnownInventory(),s=[];for(let S of o)S.infos.period.id===e.id&&S.infos.adaptation.id!==t.id&&It(s,{start:(p=S.bufferedStart)!=null?p:S.start,end:(h=S.bufferedEnd)!=null?h:S.end});let d=n.getPendingOperations();for(let S of d)if(S.type===0){let T=S.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let v=T.segment.time,E=v+T.segment.duration;It(s,{start:v,end:E})}}if(s.length===0)return{type:\"continue\",value:void 0};if(r===\"reload\"){let S=i.getReadyState();if(S===void 0||S>1)return{type:\"needs-reload\",value:void 0}}let u=r===\"direct\",f=[],l=Wt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!u){let S=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=L.getCurrent(),v=(b=T[S].before)!=null?b:0,E=(g=T[S].after)!=null?g:0,R=i.getCurrentTime();R===void 0&&(R=i.getReference().getValue().position.getPolled()),f.push({start:R-v,end:R+E})}if(e.end!==void 0){let S=qt(o,e);S!==null&&(S.bufferedStart===void 0||S.bufferedStart-e.end<1)&&f.push({start:e.end-1,end:Number.MAX_VALUE})}let m=Cr(s,f);return m.length===0?{type:\"continue\",value:void 0}:u&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function Bu(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Lo(t.getMimeTypeString(),e))}function Ui({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:d,maxVideoBufferSize:u},f,l){let{manifest:m,period:p}=e,h=new X(void 0,l);if(f.periodStreamReady({type:n,manifest:m,period:p,adaptationRef:h}),l.isCancelled())return;let b,g=!0;h.onUpdate(v=>{(async()=>{var N;if(v===void 0)return;let E=new z(\"PeriodStream: Adaptation choice \"+n);if(E.linkToSignal(l),b==null||b.cancel(\"PeriodStream: Adaptation update\"),b=E,v===null){c.info(\"Stream\",\"Set no Adaptation\",{periodStart:p.start,bufferType:n});let P=o.getStatus(n);if(P.type===\"initialized\"){if(c.info(\"Stream\",\"Clearing previous SegmentSink\",{periodStart:p.start,bufferType:n}),bt.isNative(n))return T(0,!0,E.signal);{let M=(N=p.end)!=null?N:1/0;if(p.start>M)c.warn(\"Stream\",\"Can't free buffer: period's start is after its end\",{periodStart:p.start,periodEnd:M,bufferType:n});else if(await P.value.removeBuffer(p.start,M),E.isUsed())return}}else if(P.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:p}),E.isUsed()?void 0:os(r,d,n,{period:p},f,E.signal)}let R=p.adaptations[n],_=j(R!=null?R:[],P=>P.id===v.adaptationId);if(_===void 0){b.cancel(\"PeriodStream: Adaptation not found\"),c.warn(\"Stream\",\"Unfound chosen Adaptation choice\",{adaptationId:v.adaptationId});return}let{DELTA_POSITION_AFTER_RELOAD:k}=L.getCurrent(),A=!1,x;if(g)x=0;else if(v.relativeResumingPosition!==void 0)x=v.relativeResumingPosition;else switch(A=!0,n){case\"audio\":x=k.trackSwitch.audio;break;case\"video\":x=k.trackSwitch.video;break;default:x=k.trackSwitch.other;break}if(g=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(x,!0,E.signal);m.addEventListener(\"manifestUpdate\",P=>{for(let M of P.updatedPeriods)if(M.period.id===p.id){for(let w of M.result.removedAdaptations)if(w.id===_.id)return T(x,!0,E.signal)}else if(M.period.start>p.start)break},b.signal);let{representations:B}=v;if(c.info(\"Stream\",\"Updating adaptation\",{bufferType:_.type,periodStart:p.start,adaptationId:_.id}),f.adaptationChange({type:n,adaptation:_,period:p}),E.isUsed())return;let D=Nu(o,n,_),W=Ni(D,p,_,v.switchingMode,r,s);if(W.type===\"needs-reload\")return T(x,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(W.type===\"flush-buffer\"||W.type===\"clean-buffer\"){for(let{start:P,end:M}of W.value)if(await D.removeBuffer(P,M),E.isUsed())return;if(W.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:x,relativePosHasBeenDefaulted:A}),E.isUsed()))return}t.get(D)(E.signal),S(_,B,D,E.signal)}})().catch(E=>{E instanceof oe||(b==null||b.cancel(\"PeriodStream err\"),f.error(E))})},{clearSignal:l,emitCurrentValue:!0});function S(v,E,R,_){let k=Lu(r,v.type);as({content:{manifest:m,period:p,adaptation:v,representations:E},options:s,playbackObserver:k,representationEstimator:i,segmentSink:R,segmentQueueCreator:a,wantedBufferAhead:d,maxVideoBufferSize:u},se(J({},f),{error:A}),_);function A(x){if(!bt.isNative(n)){c.error(\"Stream\",`${n} Stream crashed. Aborting it.`,x instanceof Error?x:\"\"),o.disposeSegmentSink(n,\"AdaptationStream err\");let B=ce(x,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(B),_.isCancelled()?void 0:os(r,d,n,{period:p},f,_)}c.error(\"Stream\",`${n} Stream crashed. Stopping playback.`,x instanceof Error?x:\"\"),f.error(x)}}function T(v,E,R){rt(()=>{r.listen(()=>{R.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:p,timeOffset:v,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:R})})}}function Nu(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream\",\"Reusing a previous SegmentSink for the type\",{bufferType:e}),r.value;let i=Uu(t);return n.createSegmentSink(e,i)}function Uu(n){let e=n.representations.filter(t=>t.isPlayable()!==!1);if(e.length>0)return e[0].getMimeTypeString();if(n.representations.length>0)return n.representations[0].getMimeTypeString();throw new Z(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[vt(n)]})}function Lu(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new X(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let d=r.getValue(),u=d.buffered[e],f=u!==null?vr(u,d.position.getWanted()):0;return K({},d,{bufferGap:f,buffered:u})}function s(){a.setValue(o())}})}function os(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(d,{emitCurrentValue:!1,clearSignal:a}),n.listen(d,{includeLastObservation:!1,clearSignal:a}),d();function d(){let u=n.getReference().getValue(),f=e.getValue(),l=u.position.getWanted();o.end!==void 0&&l+f>=o.end&&(c.debug(\"Stream\",'full \"empty\" AdaptationStream',{bufferType:t,periodEnd:o.end,position:l,wantedBufferAhead:f}),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var ss=Ui;function Mr(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory(),i=n.getPendingOperations();for(let a of r)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:d}=a;if(s===void 0||d===void 0)return c.warn(\"Stream\",\"No buffered start or end found from a segment.\",{bufferType:a.infos.adaptation.type,segmentStart:a.infos.segment.time}),[{start:0,end:Number.MAX_VALUE}];let u=t[t.length-1];u!==void 0&&u.end===s?u.end=d:t.push({start:s,end:d})}for(let a of i){if(a.type!==0)continue;let o=a.value;e.some(d=>o.inventoryInfos.period.id===d.period.id&&o.inventoryInfos.adaptation.id===d.adaptation.id&&o.inventoryInfos.representation.id===d.representation.id)&&It(t,{start:o.inventoryInfos.start,end:o.inventoryInfos.end})}return t}function Li(n,e,t,r,i,a,o,s){let{manifest:d,initialPeriod:u}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:m,maxVideoBufferSize:p}=a,{MINIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_AHEAD:b,MAXIMUM_MAX_BUFFER_BEHIND:g}=L.getCurrent(),S=new In(E=>{var A,x;let{bufferType:R}=E,_=(A=g[R])!=null?A:1/0,k=(x=b[R])!=null?x:1/0;return B=>{Ar({segmentSink:E,playbackObserver:e,maxBufferBehind:tn(l,D=>Math.min(D,_),B),maxBufferAhead:tn(f,D=>{var N;let W=Math.max(D,(N=h[R])!=null?N:0);return Math.min(W,k)},B)},B)}});for(let E of r.getBufferTypes())T(E,u);function T(E,R){let _=new kt((W,N)=>W.start-N.start),k=!1,A=new z(\"StreamOrchestrator Streams for \"+E);return A.linkToSignal(s),e.listen(({position:W})=>{let N=W.getWanted();if(!k||!B(N))return;let P=()=>{var w;return(w=d.getPeriodForTime(N))!=null?w:d.getNextPeriod(N)},M=P();if(!(!C(M)&&_.has(M))){for(c.info(\"Stream\",\"Destroying all PeriodStreams due to out of bounds situation\",{bufferType:E,time:N}),k=!1;_.length()>0;){let w=_.get(_.length()-1);_.removeElement(w),o.periodStreamCleared({type:E,manifest:d,period:w})}if(A.cancel(\"PeriodStream is out of bounds\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s),M=P(),M===void 0){c.warn(\"Stream\",\"The wanted position is not found in the Manifest.\"),k=!0;return}x(M)}},{clearSignal:s,includeLastObservation:!0}),d.addEventListener(\"decipherabilityUpdate\",W=>{s.isCancelled()||D(W).catch(N=>{s.isCancelled()||(A.cancel(\"decipherabilityUpdate event\"),o.error(N))})},s),x(R);function x(W){let N=se(J({},o),{waitingMediaSourceReload(P){let M=_.head();M===void 0||M.id!==P.period.id?o.lockedStream({bufferType:P.bufferType,period:P.period}):o.needsMediaSourceReload({timeOffset:P.timeOffset,minimumPosition:P.stayInPeriod?P.period.start:void 0,maximumPosition:P.stayInPeriod?P.period.end:void 0})},periodStreamReady(P){k=!0,_.add(P.period),o.periodStreamReady(P)},periodStreamCleared(P){_.removeElement(P.period),o.periodStreamCleared(P)},error(P){A.cancel(\"PeriodStream err callback\"),o.error(P)}});v(E,W,N,A.signal)}function B(W){let N=_.head(),P=_.last();return N===void 0||P===void 0?!0:N.start>W||(C(P.end)?1/0:P.end)<W}async function D(W){let N=r.getStatus(E),P=W.filter(V=>V.adaptation.type===E);if(P.length===0||N.type!==\"initialized\"||P.every(V=>V.representation.decipherable===!0))return;let M=N.value,w=P.filter(V=>V.representation.decipherable===void 0),U=P.filter(V=>V.representation.decipherable===!1),H=Mr(M,U),$=Mr(M,w);for(k=!1,c.info(\"Stream\",\"Destroying all PeriodStreams for decipherability matters\",{bufferType:E});_.length()>0;){let V=_.get(_.length()-1);_.removeElement(V),o.periodStreamCleared({type:E,manifest:d,period:V})}A.cancel(\"decipherability update\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s);for(let{start:V,end:G}of[...H,...$]){if(s.isCancelled())return;if(V<G){if(s.isCancelled())return;await M.removeBuffer(V,G)}}rt(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(ds(V,H)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(ds(V,$)&&(o.needsBufferFlush(),s.isCancelled()))return;let G=V.position.getWanted(),Y=d.getPeriodForTime(G);if(Y===void 0&&(Y=d.getNextPeriod(G),c.warn(\"Stream\",\"No Period found for the reloading position, selecting next one instead\",{reloadPosition:G,nextPeriodStart:Y==null?void 0:Y.start})),Y===void 0&&(Y=d.periods[d.periods.length-1],c.warn(\"Stream\",\"No Period found for of after the reloading position, selecting the last one\",{reloadPosition:G,nextPeriodStart:Y==null?void 0:Y.start,nextPeriodEnd:Y==null?void 0:Y.end})),Y===void 0){o.error(new Z(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}x(Y)})}}function v(E,R,_,k){c.info(\"Stream\",\"Creating new PeriodStream\",{bufferType:E,periodStart:R.start});let A=null,x=new z(\"StreamOrchestrator current consecutive Streams \"+E);x.linkToSignal(k),e.listen(({position:P},M)=>{if(R.end!==void 0&&P.getWanted()>=R.end){let w=d.getPeriodAfter(R);if(R.containsTime(P.getWanted(),w))return;c.info(\"Stream\",\"Destroying PeriodStream as the current playhead moved above it\",{bufferType:E,periodStart:R.start,periodEnd:R.end,position:P.getWanted()}),M(),_.periodStreamCleared({type:E,manifest:d,period:R}),x.cancel(\"Position ahead of PeriodStream\")}},{clearSignal:k,includeLastObservation:!0});let B={bufferType:E,content:{manifest:d,period:R},garbageCollectors:S,maxVideoBufferSize:p,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},D=se(J({},_),{streamStatusUpdate(P){if(P.hasFinishedLoading){let M=d.getPeriodAfter(R);M!==null&&W(M)}else A!==null&&(c.info(\"Stream\",\"Destroying next PeriodStream due to current one being active\",{bufferType:E,periodStart:R.start,nextPeriodStart:A.period.start}),_.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"previous PeriodStream is active\"),A=null);_.streamStatusUpdate(P)},error(P){A!==null&&(A.canceller.cancel(\"previous PeriodStream err\"),A=null),x.cancel(\"PeriodStream err\"),_.error(P)}});ss(B,D,x.signal),N(x.signal);function W(P){if(A!==null){if(A.period.id===P.id)return;c.warn(\"Stream\",\"Creating next `PeriodStream` while one was already created.\",{bufferType:E,nextPeriodStart:P.start}),_.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"PeriodStream recreation\")}let M=new z(\"StreamOrchestrator next PeriodStream \"+E);M.linkToSignal(k),A={canceller:M,period:P},v(E,P,_,A.canceller.signal)}function N(P){d.addEventListener(\"manifestUpdate\",M=>{for(let w of M.removedPeriods)if(w.id===R.id){if(d.periods.length>0&&d.periods[0].start<=w.start)return rt(()=>{if(!P.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(w.start>R.start)break;if(M.addedPeriods.length>0&&A!==null){let w=d.getPeriodAfter(R);(w===null||A.period.id!==w.id)&&(c.warn(\"Stream\",\"Destroying next PeriodStream due to new one being added\",{bufferType:E,nextPeriodStart:A.period.start}),_.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"Next Period changed\"),A=null)}},P)}}}function ds(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 us=Li;var ls=us;function Fi(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"mse\",\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function Fu(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function Pn(n,e){if(c.debug(\"mse\",\"Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"mse\",\"MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=Fu(t);if(r.length===0){c.info(\"mse\",\"Triggering end of stream\");try{n.endOfStream()}catch(a){c.error(\"mse\",\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}c.debug(\"mse\",\"Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new z(\"EndOfStream current iteration\");i.linkToSignal(e);for(let a of r)vo(a,()=>{i.cancel(\"SourceBuffer update\"),Pn(n,e)},i.signal);Co(t,()=>{i.cancel(\"SourceBuffer remove\"),Pn(n,e)},i.signal)}function fs(n,e){let t=new z(\"EndOfStream\");t.linkToSignal(e),Ft(n,()=>{c.debug(\"mse\",\"MediaSource re-opened while end-of-stream is active\"),t.cancel(\"MediaSource re-opened\"),t=new z(\"EndOfStream\"),t.linkToSignal(e),Pn(n,t.signal)},e),Pn(n,t.signal)}function zi(){let{FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:n}=L.getCurrent();return n||mi.device===mi.DEVICES.PlayStation5}var zu=365*24*3600,vn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(\"manual duration update\"),this._currentMediaSourceDurationUpdateCanceller=new z(\"MediaSource Duration Update\");let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Vu(r,i),o=new z(void 0);o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(\"MediaSource open status changed\"),!a.getValue())return;o=new z(void 0),o.linkToSignal(i);let d=qu(r.sourceBuffers,o.signal),u=new z(void 0);return u.linkToSignal(o.signal),d.onUpdate(f=>{u.cancel(\"SourceBuffer status update\"),u=new z(void 0),u.linkToSignal(o.signal),!f&&cs(r,e,t,u.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(e){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(e!=null?e:\"stop MSDU\"),this._currentMediaSourceDurationUpdateCanceller=null)}};function Wu(n,e,t){let r=e;t||(r=zi()?1/0:ms(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(i,o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"mse\",\"Updating duration to what is currently buffered\",{maxBufferedEnd:i}),n.duration=i}catch(a){return c.warn(\"mse\",\"Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"mse\",\"Updating duration\",{newDuration:r}),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=ms(e);c.info(\"mse\",\"calling `mediaSource.setLiveSeekableRange`\",{maxSeekable:s}),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"mse\",\"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 qu(n,e){if(n.length===0){let i=new X(!1);return i.finish(),i}let t=new X(!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 Vu(n,e){let t=new X(n.readyState===\"open\",e);return Ft(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),yr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Sr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function cs(n,e,t,r){if(Wu(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),cs(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function ms(n){return Math.max(Math.pow(2,32),n+zu)}var Cn=class extends le{constructor(e,t){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"MainMediaSourceInterface\"),C(mt))throw new Z(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"mse\",\"Creating MediaSource\");let r=t!==void 0?new t:new mt,i=r.handle;this.handle=C(i)?{type:\"media-source\",value:r}:{type:\"handle\",value:i},this._mediaSource=r,this.readyState=r.readyState,this._durationUpdater=new vn(r),this._endOfStreamCanceller=null,Ft(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),yr(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Sr(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal),this._mediaSource.streaming!==void 0&&(this.streaming=this._mediaSource.streaming),this._mediaSource.addEventListener(\"startstreaming\",()=>{this.streaming=!0,this.trigger(\"streamingChanged\",null)}),this._mediaSource.addEventListener(\"endstreaming\",()=>{this.streaming=!1,this.trigger(\"streamingChanged\",null)})}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Wi(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(e){this._durationUpdater.stopUpdating(e)}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new z(\"MainMediaSourceInterface EndOfStream\"),this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"mse\",\"end-of-stream order received.\"),fs(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"mse\",\"resume-stream order received.\"),this._endOfStreamCanceller.cancel(\"MediaSourceInterface stopEndOfStream\"),this._endOfStreamCanceller=null)}dispose(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(e!=null?e:\"MainMediaSourceInterface dispose\"),Gu(this._mediaSource)}},Wi=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new z(\"MainSourceBufferInterface \"+e),this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=this._onError.bind(this),a=this._onUpdateEnd.bind(this);r.addEventListener(\"updateend\",a),r.addEventListener(\"error\",i),this._canceller.signal.register(()=>{r.removeEventListener(\"updateend\",a),r.removeEventListener(\"error\",i)})}appendBuffer(...e){return c.debug(\"mse\",\"receiving order to push data to the SourceBuffer\",{type:this.type}),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"mse\",\"receiving order to remove data from the SourceBuffer\",{type:this.type,start:e,end:t}),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return vi(this._sourceBuffer.buffered)}catch(e){return c.error(\"mse\",\"Failed to get buffered time range of SourceBuffer\",{type:this.type},e instanceof Error?e:\"Unknown Error\"),[]}}abort(e){try{this._sourceBuffer.abort()}catch(t){c.debug(\"mse\",\"Failed to abort SourceBuffer:\",t instanceof Error?t:\"Unknown Error\")}this._emptyCurrentQueue(e)}dispose(e){try{this._sourceBuffer.abort()}catch(t){}this._emptyCurrentQueue(e)}_onError(e){let t;e instanceof Error?t=e:e.error instanceof Error?t=e.error:t=new Error(\"Unknown SourceBuffer Error\");let r=this._currentOperations;if(this._currentOperations=[],r.length===0)c.error(\"mse\",\"error for an unknown operation\",t);else{let i=new xe(t.name,t.message,t.name===\"QuotaExceededError\");for(let a of r)a.reject(i)}}_onUpdateEnd(){let e=this._currentOperations;this._currentOperations=[];try{for(let t of e)t.resolve(vi(this._sourceBuffer.buffered))}catch(t){for(let r of e)t instanceof Error&&t.name===\"InvalidStateError\"?r.resolve([]):r.reject(t)}this._performNextOperation()}_emptyCurrentQueue(e){let t=new oe(\"MainSourceBufferInterface queue \"+this.type,e);this._currentOperations.length>0&&(this._currentOperations.forEach(r=>{r.reject(t)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(r=>{r.reject(t)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=K({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],d=e.params[1],u=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 m=this._operationQueue[0],p=(r=d.appendWindow)!=null?r:[void 0,void 0],h=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],b=(a=d.timestampOffset)!=null?a:0,g=(o=m.params[1].timestampOffset)!=null?o:0;if(p[0]===h[0]&&p[1]===h[1]&&d.codec===m.params[1].codec&&b===g){let S=m.params[0],T;S instanceof ArrayBuffer?T=new Uint8Array(S):S instanceof Uint8Array?T=S:T=new Uint8Array(S.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(\"mse\",`: Merging ${l.length} segments together for perf`,{type:this.type}),u=At(...l).buffer)}try{this._appendBufferNow(u,d)}catch(f){let l=f instanceof Error?new xe(f.name,f.message,f.name===\"QuotaExceededError\"):new xe(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(l)}),this._currentOperations=[],this._performNextOperation()}}else{this._currentOperations=[e];let[s,d]=e.params;c.debug(\"mse\",\"removing data from SourceBuffer\",{type:this.type,start:s,end:d});try{this._sourceBuffer.remove(s,d)}catch(u){let f=u instanceof Error?new xe(u.name,u.message,!1):new xe(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations.forEach(l=>{l.reject(f)}),this._currentOperations=[],this._performNextOperation()}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"mse\",\"updating codec\",{type:this.type,prevCodec:this.codec,newCodec:i}),Fi(r,i)?this.codec=i:c.debug(\"mse\",\"could not update codec\",{type:this.type,prevCodec:this.codec,newCodec:i})),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"mse\",\"updating timestampOffset\",{type:this.type,codec:i,prevTimestampOffset:r.timestampOffset,newTimestampOffset:s}),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"mse\",\"re-setting `appendWindowStart`\",{type:this.type,prevWindowStart:r.appendWindowStart}),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"mse\",\"pre-updating `appendWindowEnd`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:s}),r.appendWindowEnd=s}c.debug(\"mse\",\"setting `appendWindowStart`\",{type:this.type,appendWindowStart:o[0]}),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"mse\",\"re-setting `appendWindowEnd`\",{type:this.type,prevWindowStart:r.appendWindowStart}),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"mse\",\"setting `appendWindowEnd`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:o[1]}),r.appendWindowEnd=o[1]),c.debug(\"mse\",\"pushing segment\",{type:this.type}),r.appendBuffer(e)}};function Gu(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(\"mse\",\"Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"mse\",\"Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"mse\",\"Not all SourceBuffers could have been removed.\")}}var Hu=Me(),Or=Me(),ps=1/0,An=class extends le{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"WorkerMediaSourceInterface\"),this.readyState=\"closed\",this._messageSender=r;let i=Hu();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 qi(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(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(\"WorkerMediaSourceInterface dispose\"),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},qi=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new z(\"WorkerSourceBufferInterface \"+e),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(\"mse\",\"unknown SourceBuffer operation succeeded\",{type:this.type}):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new oe(\"Pending SBI Operation \"+this.type,\"SBI Failure\"):new xe(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"mse\",\"unknown SourceBuffer operation failed\",{type:this.type},r):(this._pendingOperations.delete(e),i.reject(r));let a=new oe(\"Queued SBI Operation \"+this.type,\"SBI failure\");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>=ps){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=Or();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>=ps){this._queuedOperations.push({operationName:1,params:[e,t],resolve:r,reject:i});return}try{let a=Or();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(e){this.abort(),this._canceller.cancel(e!=null?e:\"WorkerSourceBufferInterface dispose\")}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=Or();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=Or();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 Vi(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 xn=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&&(c.debug(\"ABR\",\"New last stable representation\",{bitrate: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 gs=6e3,Ku=15e3,ju=3e3,Yu=1e3,Qu=9e3,kn=class{constructor(e){this._levelsMap=Vi(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=gs,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(C(a)){this._currentEstimate=r[0];return}let d=-1;for(let h=0;h<r.length;h++){let b=r[h];if(b===a)d=h;else if(b>a)break}if(d<0||r.length!==t.length){c.info(\"ABR\",\"Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let u;o!==void 0&&(u=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=F();if(f<t[d]||u!==void 0&&u<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Qu){let g=this._blockRaiseDelay+ju;c.debug(\"ABR\",\"Incrementing blocking raise in BufferBasedChooser due to unstable quality\",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.min(g,Ku)}else{let g=this._blockRaiseDelay-Yu;c.debug(\"ABR\",\"Lowering quality in BufferBasedChooser\",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.max(gs,g)}this._lastUnsuitableQualityTimestamp=l;let b=ne(r,g=>g===a);for(let g=b-1;g>=0;g--)if(f>=t[g]){this._currentEstimate=r[g];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||u===void 0||u<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[d],p=(()=>{for(let h=d+1;h<t.length;h++)if(t[h]>m)return h})();if(p!==void 0){let h=t[p];if(i>=h){c.debug(\"ABR\",\"Raising quality in BufferBasedChooser\",{bitrate:r[p]}),this._currentEstimate=r[p];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function $u(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 d=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(d>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 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 hs(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function Xu(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,d=isFinite(a)?a:0,u=s.getWanted()+d,f=$u(n,u);if(f.length!==1)return;let l=f[0],m=F(),p=l.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),m-l.requestTimestamp<p)return;let h=l.progress.length>0?l.progress[l.progress.length-1]:void 0,b=wr(l);if(h!==void 0&&b!==void 0){let R=hs(h,b);if((m-h.timestamp)/1e3<=R&&R-d/o>2500)return b}if(!l.content.segment.complete)return;let g=l.content.segment.duration,S=(m-l.requestTimestamp)/1e3,T=S<=(g*1.5+2)/o;if(C(t)||T)return;let v=g/S,E=t.bitrate*Math.min(.7,v);if(i===void 0||E<i)return E}function Zu(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=j(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=F(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,d=wr(a);if(s===void 0||d===void 0)return!0;let u=hs(s,d);return(o-s.timestamp)/1e3>u*1.2?!0:u-r/n.speed>-1.5}var Mn=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,d=this._config,{bufferGap:u,position:f,duration:l}=e,m=isFinite(u)?u:0,{ABR_STARVATION_DURATION_DELTA:p}=L.getCurrent();return isNaN(l)||m+f.getWanted()<l-p?!this._inStarvationMode&&m<=d.starvationGap?(c.info(\"ABR\",\"enter starvation mode.\",{buffergap:m,enterStarvation:d.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&m>=d.outOfStarvationGap&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m,outOfStarvation:d.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m}),this._inStarvationMode=!1),this._inStarvationMode&&(s=Xu(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR\",\"starvation mode emergency estimate:\",{bandwidth:s}),t.reset(),o=C(r)?s:Math.min(s,r.bitrate))),C(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?d.starvationBitrateFactor:d.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?d.starvationBitrateFactor:d.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:Zu(i,r,this._lowLatencyMode)}};var On=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 wn=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,d=this._lastAbrEstimate.representation;if(d===null)return null;if(i>d.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let u=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(u===void 0)return null;if(this._canGuessHigher(o,s,u)){let l=Is(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(d,i,u)&&(c.debug(\"ABR\",\"Guessed Representation validated\",{chosenBitrate:d.bitrate,otherAbrAlgosBitrate:i,scoreData:u==null?void 0:u.score,scoreConfidence:u==null?void 0:u.confidenceLevel}),this._lastMaintanableBitrate=d.bitrate,this._consecutiveWrongGuesses=0),r.id!==d.id)return d;if(this._shouldStopGuess(r,u,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=F()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),Ju(e,r);if(u===void 0)return r;if(this._canGuessHigher(o,s,u)){let l=Is(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&F()>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=F();for(let s of a){let d=o-s.requestTimestamp;if(s.content.segment.isInit){if(d>1e3)return!0}else{if(d>s.content.segment.duration*1e3+200)return!0;{let u=wr(s);if(u!==void 0&&u<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 Is(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 Ju(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 Dn=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 Gi(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 Hi(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,d)=>{var u,f;return((u=s.width)!=null?u:0)-((f=d.width)!=null?f:0)}),a=j(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 Bn=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(C(t)){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR\",\"progress for a request not added\",{requestId:e.id});return}t.progress.push(e)}remove(e){if(C(this._currentRequests[e])){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR\",\"can't remove unknown request\",{requestId:e})}delete this._currentRequests[e]}getRequests(){return hr(this._currentRequests).filter(e=>!C(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Dr(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 bs=new X(void 0);bs.finish();var Ss=new X(1/0);Ss.finish();function Ki(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,d,u,f,l){var g,S,T;let{type:m}=s.adaptation,p=a(m),h=(g=t[m])!=null?g:0,b={limitResolution:(S=r.limitResolution[m])!=null?S:bs,throttleBitrate:(T=r.throttleBitrate[m])!=null?T:Ss};return el({bandwidthEstimator:p,context:s,currentRepresentation:d,filters:b,initialBitrate:h,playbackObserver:f,representations:u,lowLatencyMode:i},l)};function a(o){let s=e[o];if(C(s)){c.debug(\"ABR\",\"Creating new BandwidthEstimator\",{bufferType:o});let d=new Dn;return e[o]=d,d}return s}}function el({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},d){let u=new xn,f=new Mn(i!=null?i:0,a),l=new Bn,m=O,p={metrics:T,requestBegin:v,requestProgress:E,requestEnd:R,addedSegment(_){m(_)}},h=new z(\"ABR \"+e.adaptation.type);h.linkToSignal(d);let b=g(s.getValue(),h.signal);return s.onUpdate(S,{clearSignal:d}),{estimates:b,callbacks:p};function g(_,k){if(_.length<=1)return new X({bitrate:void 0,representation:_[0],urgent:!0,knownStableBitrate:void 0});let A=!1,x=_.sort((U,H)=>U.bitrate-H.bitrate),B=new kn(x.map(U=>U.bitrate)),D=new On,W=new wn(u,D),N=o.getReference().getValue(),P=new X(w());return o.listen(U=>{N=U,M()},{includeLastObservation:!1,clearSignal:k}),m=function(U){if(N===null)return;let{position:H,speed:$}=N,V=U.buffered,G=vr(V,H.getWanted()),{representation:Y}=U.content,fe=u.getEstimate(Y),ue=Y.bitrate,me={bufferGap:G,currentBitrate:ue,currentScore:fe,speed:$};B.onAddedSegment(me),M()},k.register(()=>{m=O}),r.throttleBitrate.onUpdate(M,{clearSignal:k}),r.limitResolution.onUpdate(M,{clearSignal:k}),P;function M(){P.setValue(w())}function w(){let{bufferGap:U,position:H,maximumPosition:$}=N,V=r.limitResolution.getValue(),G=r.throttleBitrate.getValue(),Y=t.getValue(),fe=tl(x,V,G),ue=l.getRequests(),{bandwidthEstimate:me,bitrateChosen:Qe}=f.getBandwidthEstimate(N,n,Y,ue,D.bandwidth),te=u.getLastStableRepresentation(),ae=te===null?void 0:te.bitrate/(N.speed>0?N.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Xt,ABR_EXIT_BUFFER_BASED_ALGO:Zt}=L.getCurrent();A&&U<=Zt?A=!1:!A&&isFinite(U)&&U>=Xt&&(A=!0);let _e=Dr(fe,Qe),Jt=B.getLastEstimate(),dr=_e.bitrate,ut=null;A&&Jt!==void 0&&Jt>dr&&(ut=Dr(fe,Jt),dr=ut.bitrate);let lt=null;return a&&Y!==null&&e.manifest.isDynamic&&$-H.getWanted()<40&&(lt=W.getGuess(x,N,Y,dr,ue)),lt!==null&&lt.bitrate>dr?(c.debug(\"ABR\",\"new guess-based estimate\",{bitrate:lt.bitrate,representation:lt.id}),D.update(lt,me,2),{bitrate:me,representation:lt,urgent:Y===null||lt.bitrate<Y.bitrate,knownStableBitrate:ae}):ut!==null?(c.debug(\"ABR\",\"new buffer-based estimate\",{bitrate:ut.bitrate,representation:ut.id}),D.update(ut,me,0),{bitrate:me,representation:ut,urgent:f.isUrgent(ut.bitrate,Y,ue,N),knownStableBitrate:ae}):(c.debug(\"ABR\",\"new bandwidth estimate\",{bitrate:_e.bitrate,representation:_e.id}),D.update(_e,me,1),{bitrate:me,representation:_e,urgent:f.isUrgent(_e.bitrate,Y,ue,N),knownStableBitrate:ae})}}function S(){let _=s.getValue();h.cancel(\"restart\"),h=new z(\"ABR \"+e.adaptation.type),h.linkToSignal(d),g(_,h.signal).onUpdate(function(x){b.setValue(x)},{clearSignal:h.signal,emitCurrentValue:!0})}function T(_){let{requestDuration:k,segmentDuration:A,size:x,content:B}=_;if(n.addSample(k,x),!B.segment.isInit){let{segment:D,representation:W}=B;if(A===void 0&&!D.complete)return;let N=A!=null?A:D.duration;u.addSample(W,k/1e3,N)}}function v(_){l.add(_)}function E(_){l.addProgress(_)}function R(_){l.remove(_.id)}}function tl(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Gi(r,t)),e!==void 0&&(r=Hi(r,e)),r}var ys=Ki;function Br(){var t;if(typeof((t=ee.crypto)==null?void 0:t.randomUUID)==\"function\")return ee.crypto.randomUUID();let n=new Date().getTime(),e=F();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 nl=/^(?:[a-z]+:)?\\/\\//i,rl=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Yi(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(nl.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Yi(n.substring(0,t)):e+1}function Ts(n,e){let t=Nr(n),r=Nr(e);if(t.scheme!==r.scheme||t.authority!==r.authority||t.path[0]!==void 0&&t.path[0]!==\"/\"&&r.path[0]===\"/\"||r.path[0]!==void 0&&r.path[0]!==\"/\"&&t.path[0]===\"/\")return null;let i=Un(t.path),a=Un(r.path),o;if(i===a)o=\"\";else{let d=i.split(\"/\");d.pop();let u=a.split(\"/\");for(;d.length>0&&u.length>0&&d[0]===u[0];)d.shift(),u.shift();for(;d.length>0;)d.shift(),u.unshift(\"..\");let f=u.join(\"/\");(f.endsWith(\"../\")||f.endsWith(\"./\"))&&(f=f.slice(0,f.length-1)),o=f===\"\"?\".\":f}let s=o;return o===\"\"&&r.query===t.query||Q(r.query)&&(s+=\"?\",s+=r.query),Q(r.fragment)&&(s+=\"#\",s+=r.fragment),s}function il(n,e){let t=Nr(n),r=Nr(e);if(Q(r.scheme))return ji(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return Q(r.authority)?(i.authority=r.authority,i.path=Un(r.path),ji(i)):(r.path===\"\"?(i.path=t.path,Q(r.query)||(i.query=t.query)):Oe(r.path,\"/\")?i.path=Un(r.path):i.path=Un(ol(t,r.path)),ji(i))}var Nn=new Map,al=200;function Nr(n){var r,i,a,o,s;if(Nn.has(n))return Nn.get(n);let e=n.match(rl),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:\"\"},Nn.size>=al&&Nn.clear(),Nn.set(n,t),t}function ji(n){let e=\"\";return Q(n.scheme)&&(e+=n.scheme+\":\"),Q(n.authority)&&(e+=\"//\"+n.authority),e+=n.path,Q(n.query)&&(e+=\"?\"+n.query),Q(n.fragment)&&(e+=\"#\"+n.fragment),e}function Un(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 ol(n,e){if(Q(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function Ln(...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:\"\",d=il(o,s),u=e.slice(2);return Ln(d,...u)}}var sl=4,Fn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Br(),this._contentId=(r=e.contentId)!=null?r:Br(),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(\"CmcdDataBuilder start\"),this._canceller=new z(\"CMCD monitoring\"),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(\"CmcdDataBuilder stop\"),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,d,u;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}if(e.segment.isInit&&(r.ot=\"i\"),!C(e.nextSegment)&&e.segment.url!==null&&e.nextSegment.url!==null&&(!e.nextSegment.isInit||e.nextSegment.indexRange===void 0)){let f=e.segment.url,l=e.nextSegment.url,m=Ts(f,l);m!==null&&(m!==\".\"&&(r.nor=encodeURIComponent(m)),e.nextSegment.range!==void 0&&(r.nrr=String(e.nextSegment.range[0])+\"-\",isFinite(e.nextSegment.range[1])&&(r.nrr+=String(e.nextSegment.range[1]))))}let i;if(t!==void 0&&(r.ot===\"v\"||r.ot===\"a\"||r.ot===\"av\")){let f=t.buffered[e.adaptation.type];if(!C(f)){let l=(u=(d=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?d:t.position.getWanted())!=null?u:t.position.getPolled();for(let m of f)if(l>=m.start&&l<m.end){i=(m.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*sl/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.isPlayable()!==!0?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=(u,f)=>{this._typePreference===0?t[f]+=u:r+=u},a=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${String(l)},`;i(m,f)}},o=(u,f)=>{if(e[u]===!0){let l=`${u},`;i(l,f)}},s=(u,f)=>{let l=e[u];if(l!==void 0){let p=`prop=${`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`},`;i(p,f)}},d=(u,f)=>{let l=e[u];if(l!==void 0){let m=`prop=${l},`;i(m,f)}};return a(\"bl\",\"request\"),a(\"br\",\"object\"),o(\"bs\",\"status\"),s(\"cid\",\"session\"),a(\"d\",\"object\"),a(\"dl\",\"request\"),a(\"mtp\",\"request\"),s(\"nor\",\"request\"),s(\"nrr\",\"request\"),d(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),d(\"sf\",\"session\"),s(\"sid\",\"session\"),d(\"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)),c.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),c.debug(\"CMCD\",\"proposing query string payload\",{queryString:r}),{type:\"query\",value:[[\"CMCD\",r]]})}};var Es=Fn;var zn=class extends le{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=_s(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=_s(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 _s(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 Le(n){return n instanceof de?new Xe(\"PIPELINE_LOAD_ERROR\",n):ce(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function dl(n){return n instanceof de?n.type===Pt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===Pt.TIMEOUT||n.type===Pt.ERROR_EVENT:n instanceof $e?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:Ut(n)&&n.code===\"INTEGRITY_ERROR\"}async function Wn(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:d}=r;n!==null&&n.length===0&&c.warn(\"utils\",\"No CDN given to `scheduleRequestWithCdns`.\");let u=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return m(f);function l(){if(n===null){let g=u.get(null);return g!==void 0&&g.isBlacklisted?void 0:null}else{if(e===null)return b(n);{let g=e.getCdnPreferenceForResource(n);return b(g)}}}async function m(g){try{return await t(g,i)}catch(S){if(z.isCancellationError(S))throw S;g!==null&&e!==null&&e.downgradeCdn(g);let T=u.get(g);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},u.set(g,T)):T.errorCounter++,!dl(S))return T.blockedUntil=void 0,T.isBlacklisted=!0,p(S);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let v=T.errorCounter,E=Math.min(a*Math.pow(2,v-1),o),R=Ri(E);T.blockedUntil=F()+R}return p(S)}}async function p(g){let S=l();if(i.isCancelled())throw i.cancellationError;if(S===void 0)throw g;if(d(g),i.isCancelled())throw i.cancellationError;return h(S,g)}function h(g,S){let T=u.get(g);if(T===void 0||T.blockedUntil===void 0)return m(g);let v=F(),E=T.blockedUntil-v;if(E<=0)return m(g);let R=new z(\"Request Backoff\"),_=R.linkToSignal(i);return new Promise((k,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let D=l();if(i.isCancelled())throw i.cancellationError;if(D===void 0)return B(S);D!==g&&(R.cancel(\"new prioritized CDN\"),h(D,S).then(x,B))},R.signal),ln(E,R.signal).then(()=>m(g).then(x,B),O);function x(D){_(),k(D)}function B(D){_(),A(D)}})}function b(g){var T;if(u.size===0)return g[0];let S=F();return(T=g.filter(v=>{var E;return((E=u.get(v))==null?void 0:E.isBlacklisted)!==!0}).reduce((v,E)=>{var _;let R=(_=u.get(E))==null?void 0:_.blockedUntil;return R!==void 0&&R<=S&&(R=void 0),v===void 0?[E,R]:v[1]===void 0?v:R===void 0?[E,void 0]:R<v[1]?[E,R]:v},void 0))==null?void 0:T[0]}}function Qi(n,e,t){return Wn(null,null,n,e,t)}var qn=class extends le{constructor(e,t,r){super(),this.scheduleManualRefresh=O,this._manifestUrls=e,this._pipelines=t.manifest,this._transportName=t.transportName,this._settings=r,this._canceller=new z(\"ManifestFetcher\"),this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(e){this._canceller.cancel(e!=null?e:\"ManifestFetcher dispose\"),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof ht?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._transportName,a=this._pipelines,o=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",Le(f))});try{let f=await d(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw Le(f)}function d(f){var g;let{loadManifest:l}=a,m=r.requestTimeout===void 0?L.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,p=r.connectionTimeout===void 0?L.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;m<0&&(m=void 0),p<0&&(p=void 0);let h={timeout:m,connectionTimeout:p,cmcdPayload:(g=r.cmcdDataBuilder)==null?void 0:g.getCmcdDataForManifest(i)};return Qi(()=>l(f,h,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 b;let i=F(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:d}=e,u=this._getBackoffSetting(g=>{this.trigger(\"warning\",Le(g))}),f=r!=null?r:(b=this._manifestUrls)==null?void 0:b[0],l={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:f};try{let g=this._pipelines.parseManifest(e,l,p,a,m);if(ul(g)){let{manifest:S}=await g;return h(S)}else return h(g.manifest)}catch(g){throw ce(g,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(g){try{return await Qi(g,u,a)}catch(S){throw Le(S)}}function p(g){for(let S of g){if(a.isCancelled())return;let T=ce(S,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function h(g){let S=F()-i;return c.info(\"MF\",`Manifest parsed in ${S}ms`),{manifest:g,sendingTime:s,receivedTime:d,parsingTime:S}}}_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,d=a?i.LOW_LATENCY:i.REGULAR,u=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:d,maxRetry:u}}_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,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<a:s!==void 0&&(d=s>=o);let u=t===void 0?0:F()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-u,0),l=new z(\"ManifestFetcher refresh handling\");if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:p,delay:h,canUseUnsafeMode:b}=m,g=b&&d,S=t===void 0?0:F()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-S,0),v=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:p,unsafeMode:g})},Math.max((h!=null?h:0)-S,T));l.signal.register(()=>{clearTimeout(v)})},e.expired!==null){let m=setTimeout(()=>{var p;(p=e.expired)==null||p.then(()=>{l.cancel(\"manifest expiration\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},O)},f);l.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-u,p;s===void 0?p=m:e.lifetime<3&&s>=100?(p=Math.min(Math.max(3e3-u,Math.max(m,0)+s),m*6),c.info(\"MF\",\"Manifest update rythm is too frequent. Postponing next request.\",{regularRefreshDelay:m,newRefreshDelay:p})):s>=e.lifetime*1e3/10?(p=Math.min(Math.max(m,0)+s,m*6),c.info(\"MF\",\"Manifest took too long to parse. Postponing next request\",{regularRefreshDelay:m,newRefreshDelay:p})):p=m;let h=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},Math.max(p,f));l.signal.register(()=>{clearTimeout(h)})}}_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(\"MF\",'Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info(\"MF\",'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(d=>d.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(d=>{this._isRefreshPending=!1;let{manifest:u,sendingTime:f,parsingTime:l}=d,m=F();if(a)e.replace(u);else try{e.update(u)}catch(h){let b=h instanceof Error?h.message:\"unknown error\";c.warn(\"MF\",`Attempt to update Manifest failed: ${b}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:g}=L.getCurrent(),S=f===void 0?0:F()-f,T=Math.max(this._settings.minimumManifestUpdateInterval-S,0),v=O,E=setTimeout(()=>{v(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(g-S,T));v=this._canceller.signal.register(()=>{clearTimeout(E)});return}let p=F()-m;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:p})}).catch(d=>{this._isRefreshPending=!1,this._onFatalError(d)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose(\"ManifestFetcher fatal err\"))}};function ul(n){return n instanceof Promise}var $i=qn;function Xi(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=u=>e(r,a,u),d=n.create(s,i,a,o);return t.set(d,s),d},updatePriority(r,i){let a=t.get(r);if(a===void 0){c.warn(\"SF\",\"Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Zi=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}},Rs=Zi;var ll=Me();function Ji({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},d=ge([\"audio\",\"video\"],n)?new Rs:void 0,{loadSegment:u,parseSegment:f}=e;return async function(m,p,h){var H,$,V;let{segment:b,adaptation:g,representation:S,manifest:T,period:v}=m,E=Ge(m),R=ll(),_,k=[],A=0,x=!1,B={segment:b,type:g.type,language:g.language,isLive:T.isLive,periodStart:v.start,periodEnd:v.end,mimeType:S.mimeType,codecs:S.codecs[0],manifestPublishTime:T.publishTime},D={onProgress(G){var Y;_===void 0&&G.totalSize!==void 0&&G.size<G.totalSize&&((Y=i.onProgress)==null||Y.call(i,{duration:G.duration,size:G.size,totalSize:G.totalSize,timestamp:F(),id:R}))},onNewChunk(G){p.onChunk(M(G,!0))}},W=d!==void 0?d.get(m):null;if(W!==null)return c.debug(\"SF\",\"Found wanted segment in cache\",E),p.onChunk(M(W,!1)),Promise.resolve();c.debug(\"SF\",\"Beginning request\",E),(H=i.onRequestBegin)==null||H.call(i,{requestTimestamp:F(),id:R,content:m}),h.register(N);try{let G=await Wn(m.representation.cdnMetadata,t,P,K({onRetry:w},a),h);if(G.resultType===\"segment-loaded\"){let Y=G.resultData.responseData;d!==void 0&&d.add(m,G.resultData.responseData),p.onChunk(M(Y,!1))}else G.resultType===\"segment-created\"&&p.onChunk(M(G.resultData,!1));c.debug(\"SF\",\"Segment request ended with success\",E),p.onAllChunksReceived(),G.resultType!==\"segment-created\"?(_=G.resultData,U()):_=null,h.isCancelled()||($=i.onRequestEnd)==null||$.call(i,{id:R}),h.deregister(N)}catch(G){throw h.deregister(N),_=null,G instanceof oe?(c.debug(\"SF\",\"Segment request aborted\",E),G):(c.debug(\"SF\",\"Segment request failed\",E),(V=i.onRequestEnd)==null||V.call(i,{id:R}),Le(G))}function N(){var G;_===void 0&&(c.debug(\"SF\",\"Segment request cancelled\",E),_=null,(G=i.onRequestEnd)==null||G.call(i,{id:R}))}function P(G){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),u(G,B,s,h,D)}function M(G,Y){k.push(!1);let fe=k.length-1;return function(me){let Qe={data:G,isChunked:Y};try{let te=f(Qe,B,me);return k[fe]||(A=A!==void 0&&te.segmentType===\"media\"&&te.chunkInfos!==null&&te.chunkInfos.duration!==void 0?A+te.chunkInfos.duration:void 0,k[fe]=!0,U()),te}catch(te){throw ce(te,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function w(G){p.onRetry(Le(G))}function U(){var G;x||!C(_)&&_.size!==void 0&&_.requestDuration!==void 0&&k.length>0&&k.every(Y=>Y)&&(x=!0,(G=i.onMetrics)==null||G.call(i,{size:_.size,requestDuration:_.requestDuration,content:m,segmentDuration:A}))}}}function Ps({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:d}=L.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?d.LOW_LATENCY:d.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Vn=class extends le{constructor(e,t){super(),this._segmentFetcher=e,this._currentContentInfo=null,this.isMediaSegmentQueueInterrupted=t}getRequestedInitSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.initSegmentRequest)==null?void 0:t.segment)!=null?r:null}getRequestedMediaSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.mediaSegmentRequest)==null?void 0:t.segment)!=null?r:null}resetForContent(e,t,r){var s;(s=this._currentContentInfo)==null||s.currentCanceller.cancel(r!=null?r:\"SegmentQueue reset\");let i=new X({initSegment:null,segmentQueue:[]}),a=new z(\"SegmentQueue \"+e.adaptation.type);a.signal.register(()=>{i.finish()});let o={content:e,downloadQueue:i,initSegmentInfoRef:t?new X(void 0):new X(null),currentCanceller:a,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=o,this.isMediaSegmentQueueInterrupted.onUpdate(d=>{d||(c.debug(\"SF\",\"Media segment can be loaded again, restarting queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"interrupt end\"))},{clearSignal:a.signal}),i.onUpdate(d=>{let{segmentQueue:u}=d;if(u.length>0&&u[0].segment.id===o.mediaSegmentAwaitingInitMetadata)return;let f=o.mediaSegmentRequest;if(u.length===0){if(f===null)return;c.debug(\"SF\",\"no more media segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue empty\");return}else if(f===null){c.debug(\"SF\",\"Media segments now need to be requested. Starting queue.\",{type:e.adaptation.type,queueLength:u.length}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue start\");return}else{let l=u[0];if(f.segment.id!==l.segment.id){c.debug(\"SF\",\"Next media segment changed, cancelling previous\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"next media segment changed\");return}f.priority!==l.priority&&(c.debug(\"SF\",\"Priority of next media segment changed, updating\",{type:e.adaptation.type,prevPriority:f.priority,newPriority:l.priority}),this._segmentFetcher.updatePriority(f.request,l.priority));return}},{emitCurrentValue:!0,clearSignal:a.signal}),i.onUpdate(d=>{var f;let u=o.initSegmentRequest;if(d.initSegment!==null&&u!==null){d.initSegment.priority!==u.priority&&this._segmentFetcher.updatePriority(u.request,d.initSegment.priority);return}else if(((f=d.initSegment)==null?void 0:f.segment.id)===(u==null?void 0:u.segment.id))return;d.initSegment===null&&c.debug(\"SF\",\"no more init segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartInitSegmentDownloadingQueue(o,d.initSegment,\"init segment queue empty\")},{emitCurrentValue:!0,clearSignal:a.signal}),i}stop(e){var t;(t=this._currentContentInfo)==null||t.currentCanceller.cancel(e!=null?e:\"SegmentQueue stop\"),this._currentContentInfo=null}_restartMediaSegmentDownloadingQueue(e,t){e.mediaSegmentRequest!==null&&e.mediaSegmentRequest.canceller.cancel(t!=null?t:\"SegmentQueue media restart\");let{downloadQueue:r,content:i,initSegmentInfoRef:a,currentCanceller:o}=e,s=()=>{var E;if(this.isMediaSegmentQueueInterrupted.getValue()){c.debug(\"SF\",\"Segment fetching postponed because it cannot stream now.\");return}let{segmentQueue:d}=r.getValue(),u=d[0];if(o!==null&&o.isUsed()){e.mediaSegmentRequest=null;return}if(u===void 0){e.mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let f=new z(\"SegmentQueue media segments queue \"+i.adaptation.type),l=o===null?O:f.linkToSignal(o.signal),{segment:m,priority:p}=u,h=K({segment:m,nextSegment:(E=d[1])==null?void 0:E.segment},i),b=!1,g=!1;f.signal.register(()=>{e.mediaSegmentRequest=null,!b&&(e.mediaSegmentAwaitingInitMetadata===m.id&&(e.mediaSegmentAwaitingInitMetadata=null),b=!0,g=!1)});let S=R=>{Ie(R.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",K({},R,{segment:m}))},T=()=>{let R=r.getValue().segmentQueue;if(R.length===0){b=!0,this.trigger(\"emptyQueue\",null);return}else R[0].segment.id===m.id&&R.shift();b=!0,s()},v=this._segmentFetcher.createRequest(h,p,{onRetry:R=>{this.trigger(\"requestRetry\",{segment:m,error:R})},beforeInterrupted(){c.info(\"SF\",\"segment request interrupted temporarly.\",{segmentId:m.id,segmentTime:m.time})},onChunk:R=>{let _=a.getValue();_!==void 0?S(R(_!=null?_:void 0)):(g=!0,a.waitUntilDefined(k=>{S(R(k!=null?k:void 0))},{clearSignal:f.signal}))},onAllChunksReceived:()=>{g?(e.mediaSegmentAwaitingInitMetadata=m.id,a.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,g=!1,this.trigger(\"fullyLoadedSegment\",m)},{clearSignal:f.signal})):this.trigger(\"fullyLoadedSegment\",m)},beforeEnded:()=>{l(),e.mediaSegmentRequest=null,g?a.waitUntilDefined(T,{clearSignal:f.signal}):T()}},f.signal);v.catch(R=>{l(),b||(b=!0,this.stop(\"request err\"),this.trigger(\"error\",R))}),e.mediaSegmentRequest={segment:m,priority:p,request:v,canceller:f}};s()}_restartInitSegmentDownloadingQueue(e,t,r){let{content:i,initSegmentInfoRef:a}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(r!=null?r:\"SegmentQueue init restart\"),t===null)return;let o=new z(\"SegmentQueue init segment \"+i.adaptation.type),s=e.currentCanceller===null?O:o.linkToSignal(e.currentCanceller.signal),{segment:d,priority:u}=t,f=K({segment:d,nextSegment:void 0},i),l=!1,m=this._segmentFetcher.createRequest(f,u,{onRetry:p=>{this.trigger(\"requestRetry\",{segment:d,error:p})},beforeInterrupted:()=>{c.info(\"SF\",\"init segment request interrupted temporarly.\",{segmentId:d.id})},beforeEnded:()=>{s(),e.initSegmentRequest=null,l=!0},onChunk:p=>{var b;let h=p(void 0);Ie(h.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",K({},h,{segment:d})),h.segmentType===\"init\"&&a.setValue((b=h.initTimescale)!=null?b:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",d)}},o.signal);m.catch(p=>{s(),l||(l=!0,this.stop(\"request err\"),this.trigger(\"error\",p))}),o.signal.register(()=>{e.initSegmentRequest=null,!l&&(l=!0)}),e.initSegmentRequest={segment:d,priority:u,request:m,canceller:o}}};var Hn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"The max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return Ct(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let u=()=>{p(),this._endTask(a)},f=h=>{r.beforeEnded(),u(),o(h)},l=h=>{u(),s(h)},m=new z(void 0),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(f).catch(h=>{!i.isCancelled()&&m.isUsed()&&h instanceof oe||l(h)})},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=Gn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Gn(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=Gn(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=Gn(e,this._pendingTasks);if(i<0){c.warn(\"SF\",\"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 of this._pendingTasks)if(e.priority>=this._prioritySteps.low)return this._interruptPendingTask(e),this._interruptCancellableTasks()}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(c.warn(\"SF\",\"Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=Gn(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"SF\",\"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(\"TaskPrioritizer interrupt\")}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Gn(n,e){return ne(e,t=>t.taskFn===n)}var Kn=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=L.getCurrent();this._transport=e,this._prioritizer=new Hn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=Ps(this._backoffOptions),a=this._transport[e],o=Ji({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=Xi(this._prioritizer,o);return new Vn(s,r)}};var ea=Kn;function ta(n,e){let{loadThumbnail:t}=n,r=[];return async function(a,o){o.register(T);let s,d=j(r,({thumbnailContext:R})=>R.period.id===a.period.id&&R.track.id===a.track.id&&R.segment.id===a.segment.id);if(d!==void 0){c.debug(\"Thumbnails\",\"Requesting same thumbnail than the pending one\",{time:a.segment.time}),s=d,s.referenceCount++;let R;try{R=await s.promise}catch(_){throw o.deregister(T),_}return o.deregister(T),R}let{segment:u,track:f}=a,l=fl({}),m;l.connectionTimeout===void 0||l.connectionTimeout<0?m=void 0:m=l.connectionTimeout;let p={timeout:l.requestTimeout<0?void 0:l.requestTimeout,connectionTimeout:m,cmcdPayload:void 0},h=new z(\"Thumbnail request\"),b=S();s={thumbnailContext:a,promise:b,referenceCount:1},r.push(s);let g=()=>{let R=r.indexOf(s);R>=0&&r.splice(R,1)};try{let R=await b;return g(),R}catch(R){throw g(),R}async function S(){c.debug(\"Thumbnails\",\"Beginning thumbnail request\",{time:u.time});let R;try{if(R=await Wn(f.cdnMetadata,e,v,K({onRetry:E},l),h.signal),o.isCancelled())return Promise.reject(o.cancellationError);c.debug(\"Thumbnails\",\"Thumbnail request ended with success\",{time:u.time}),o.deregister(T)}catch(_){throw o.deregister(T),_ instanceof oe?(c.debug(\"Thumbnails\",\"Thumbnail request aborted\",{time:u.time}),_):(c.debug(\"Thumbnails\",\"Thumbnail request failed\",{time:u.time}),Le(_))}try{return n.parseThumbnail(R.responseData,{thumbnail:u,thumbnailTrack:f})}catch(_){throw ce(_,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}function T(){c.debug(\"Thumbnails\",\"Thumbnail request cancelled\",{time:u.time});let R=r.indexOf(s);R<0||(r[R].referenceCount--,r[R].referenceCount<=0&&(h.cancel(\"Thumbnail request aborted\"),r.splice(R,1)))}function v(R){return t(R,u,p,o)}function E(R){let _=Le(R);c.warn(\"Thumbnails\",\"Thumbnail request retry \",{time:u.time},_)}}}function fl({maxRetry:n,requestTimeout:e,connectionTimeout:t}){let{DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:r,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:i,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:a,INITIAL_BACKOFF_DELAY_BASE:o,MAX_BACKOFF_DELAY_BASE:s}=L.getCurrent();return{maxRetry:n!=null?n:r,baseDelay:o.REGULAR,maxDelay:s.REGULAR,requestTimeout:e===void 0?i:e,connectionTimeout:t===void 0?a:t}}var jn=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(\"WorkerTextDisplayerInterface reset\")}stop(e){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue(e)}_resetCurrentQueue(e){let t=new oe(\"WorkerTextDisplayerInterface queue\",e!=null?e:\"reset\");this._queues.pushTextData.forEach(r=>{r.reject(t)}),this._queues.remove.forEach(r=>{r.reject(t)})}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"text\",\"remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}};var vs=6,na=4e3,Ur=6e3,ml=6e4,Gt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var g,S;let t=F();if(this._addPositionToHistory(e,t),this._ignoreFreezeUntil!==null&&t<this._ignoreFreezeUntil)return null;this._ignoreFreezeUntil=null;let{UNFREEZING_SEEK_DELAY:r,UNFREEZING_DELTA_POSITION:i,FREEZING_FLUSH_FAILURE_DELAY:a}=L.getCurrent(),{readyState:o,rebuffering:s,freezing:d,fullyLoaded:u}=e,f=e.position.getPolled(),l=Cs(e.bufferGap);if(!(d!==null||o===1&&(l>=vs||u)))return this._decipherabilityFreezeStartingTimestamp=null,null;let p=(S=(g=d==null?void 0:d.timestamp)!=null?g:s==null?void 0:s.timestamp)!=null?S:null;if(c.info(\"Freeze\",\"Freeze detected\",{freezeStart:p,timeFrozen:t-(p!=null?p:t)}),this._lastFlushAttempt!==null&&t-this._lastFlushAttempt.timestamp<a.MAXIMUM&&t-this._lastFlushAttempt.timestamp>=a.MINIMUM&&Math.abs(f-this._lastFlushAttempt.position)<a.POSITION_DELTA){let T=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,T}let b=this._checkForDecipherabilityRelatedFreeze(e,t);return b!==null?b:p!==null&&t-p>r?(this._lastFlushAttempt={timestamp:t,position:f+i},c.debug(\"Freeze\",\"Trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=Cs(e.bufferGap),d=i!==null&&t-i.timestamp>na,{hasUndecipherableData:u,hasEncryptedData:f}=cl(this._segmentSinksStore);if(u===!0)return c.warn(\"Freeze\",\"we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,{type:\"reload\",value:null};let l=a!==null&&t-a.timestamp>na;return(d||l)&&(s>=vs||o)&&r<=1?this._decipherabilityFreezeStartingTimestamp===null&&(c.debug(\"Freeze\",\"Start of a potential decipherability freeze detected\"),this._decipherabilityFreezeStartingTimestamp=t):this._decipherabilityFreezeStartingTimestamp=null,this._decipherabilityFreezeStartingTimestamp!==null&&F()-this._decipherabilityFreezeStartingTimestamp>na&&f&&u===!1?(c.warn(\"Freeze\",\"we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Ur,{type:\"reload\",value:null}):null}_getStrategyIfFlushingFails(e){c.warn(\"Freeze\",\"A recent flush seemed to have no effect on freeze, checking for transitions\");let t=[];for(let r of[\"audio\",\"video\"]){let i=this._lastSegmentInfo[r];if(i.length===0)continue;let a=i[i.length-1];if(a.segment===null)continue;let o=a.segment,s;for(let d=i.length-2;d>=0;d--){let u=i[d];if(u.segment===null){s=u;break}else if(u.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-u.timestamp<5e3){s=u;break}else u.segment.start===o.start&&e-u.position<3e3&&(a=u)}if(s===void 0||s.segment===null)c.debug(\"Freeze\",\"Freeze when beginning to play a content, try avoiding this quality\"),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation});else{if(o.infos.period.id!==s.segment.infos.period.id)return c.debug(\"Freeze\",\"Freeze when switching Period, reloading\"),{type:\"reload\",value:null};o.infos.representation.uniqueId!==s.segment.infos.representation.uniqueId&&(c.warn(\"Freeze\",\"Freeze when switching Representation, avoiding\",{bitrate:o.infos.representation.bitrate}),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation}))}}return t.length>0?{type:\"avoid-representations\",value:t}:(c.debug(\"Freeze\",\"Reloading because flush doesn't work\"),{type:\"reload\",value:null})}_addPositionToHistory(e,t){var i,a;let r=e.position.getPolled();for(let o of[\"audio\",\"video\"]){let s=this._segmentSinksStore.getStatus(o);if(s.type===\"initialized\")for(let f of s.value.getLastKnownInventory())((i=f.bufferedStart)!=null?i:f.start)<=r&&((a=f.bufferedEnd)!=null?a:f.end)>r&&this._lastSegmentInfo[o].push({segment:f,position:r,timestamp:t});else this._lastSegmentInfo[o].push({segment:null,position:r,timestamp:t});if(this._lastSegmentInfo[o].length>100){let f=this._lastSegmentInfo[o].length-100;this._lastSegmentInfo[o].splice(0,f)}let d=t-ml,u;for(u=0;u<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][u].timestamp>d);u++);u>0&&this._lastSegmentInfo[o].splice(0,u)}}};function cl(n){let e=!0,t=!0;for(let r of[\"audio\",\"video\"]){let i=n.getStatus(r);if(i.type===\"initialized\")for(let a of i.value.getLastKnownInventory()){let{representation:o}=a.infos;if(o.decipherable===!1)return{hasUndecipherableData:!0,hasEncryptedData:!0};o.contentProtections!==void 0&&(t=!1,o.decipherable!==!0&&(e=!1))}}return{hasEncryptedData:!t,hasUndecipherableData:e?!1:void 0}}function Cs(n){return n!==void 0&&isFinite(n)?n:0}var Yn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,d,u,f,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(),(d=(s=this._refs.get(p))==null?void 0:s.video)==null||d.representations.finish(),(f=(u=this._refs.get(p))==null?void 0:u.text)==null||f.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,d;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(c.warn(\"Track\",\"Track for periodId already declared\",{periodId:e,bufferType:t}),(s=i[t])==null||s.trackReference.finish(),(d=i[t])==null||d.representations.finish());let a=r.getValue(),o;C(a)?o=new X({representationIds:[],switchingMode:\"lazy\"}):(o=new X(a.representations.getValue()),r.setValue(K({},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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:t}),!1):(C(r)?(i.representations=new X({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new X(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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:r}),!1;let o=a.trackReference.getValue();return C(o)||o.adaptationId!==t?(c.debug(\"Track\",\"Desynchronized Adaptation id\",{oldId:o==null?void 0:o.adaptationId,newId: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(\"Track\",\"Removing track setter for inexistent periodId\",{periodId:e,bufferType:t}),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};function ve(n){return ce(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}var As=Me(),Ht=class{constructor({hasVideo:e}){this._currentContent=null,this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\"),this._hasVideo=e;let t=new z(\"ContentPreparer\");this._contentCanceller=t}initializeNewContent(e,t,r,i){return new Promise((a,o)=>{var w,U;this.disposeCurrentContent(\"new init\");let s=this._contentCanceller,d=new z(\"ContentPreparer MediaSource\");this._currentMediaSourceCanceller=d,d.linkToSignal(s.signal);let{contentId:u,url:f,hasText:l,transportOptions:m,useMseInWorker:p,enableRepresentationAvoidance:h,transport:b}=t,g=null,S=ke.transports[b];if(typeof S!=\"function\"){o(new Error(`transport \"${b}\" not supported. Did you add the corresponding feature?`));return}let T=S(J(J({},m),gl(m,i))),v=t.cmcd===void 0?null:new Es(t.cmcd),E=new $i(f===void 0?void 0:[f],T,J({cmcdDataBuilder:v},t.manifestRetryOptions)),R=ys({initialBitrates:{audio:(w=t.initialAudioBitrate)!=null?w:0,video:(U=t.initialVideoBitrate)!=null?U:0},lowLatencyMode:m.lowLatencyMode,throttlers:r}),_=d.signal.register(H=>{o(H)}),k=new zn(s.signal),A=new ea(T,k,v,t.segmentRetryOptions),x=ta(T.thumbnails,k),B=new Yn,[D,W,N]=xs(e,u,{useMseInWorker:p,hasVideo:this._hasVideo,hasText:l},d.signal),P=new Gt(W);this._currentContent={cmcdDataBuilder:v,contentId:u,enableRepresentationAvoidance:h,freezeResolver:P,mediaSource:D,manifest:null,manifestFetcher:E,representationEstimator:R,segmentSinksStore:W,segmentQueueCreator:A,fetchThumbnailData:x,coreTextSender:N,trackChoiceSetter:B,useMseInWorker:p},D.addEventListener(\"mediaSourceOpen\",function(){M()},d.signal),s.signal.register(H=>{E.dispose(H.reason)}),E.addEventListener(\"warning\",H=>{e({type:\"warning\",contentId:u,value:ve(H)})},s.signal),E.addEventListener(\"manifestReady\",H=>{if(g!==null){c.warn(\"Core\",\"Multiple `manifestReady` events, ignoring\");return}g=H,this._currentContent!==null&&(this._currentContent.manifest=g),M()},d.signal),E.addEventListener(\"error\",H=>{e({type:\"error\",contentId:u,value:ve(H)}),o(H)},s.signal),E.start();function M(){g===null||D.readyState===\"closed\"||d.isUsed()||(pl(g),g.addEventListener(\"manifestUpdate\",H=>{g!==null&&e({type:\"manifest-update\",contentId:u,value:{manifest:g,updates:H}})},s.signal),_(),a(g))}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(\"ContentPreparer MediaSource reload\"),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\");let[t,r,i]=xs(e,this._currentContent.contentId,{useMseInWorker:this._currentContent.useMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.coreTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.freezeResolver=new Gt(r),this._currentContent.coreTextSender=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(e){this._contentCanceller.cancel(e),this._contentCanceller=new z(\"ContentPreparer\")}};function xs(n,e,t,r){let i;if(t.useMseInWorker){let d=new Cn(As());i=d;let u,f=d.handle;if(f.type===\"handle\")u={type:\"handle\",value:f.value};else{let l=URL.createObjectURL(f.value);u={type:\"url\",value:l},r.register(()=>{URL.revokeObjectURL(l)})}n({type:\"attach-media-source\",contentId:e,value:u,mediaSourceId:i.id},[f.value])}else i=new An(As(),e,n);let a=t.hasText?new jn(e,n):null,{hasVideo:o}=t,s=new bt(i,o,a);return r.register(d=>{s.disposeAll(d.reason),a==null||a.stop(d.reason),i.dispose(d.reason)}),[i,s,a]}function pl(n){var t,r;if(C(mt))return;let e=new Map;for(let i of n.periods){let a=[...(t=i.adaptations.video)!=null?t:[],...(r=i.adaptations.audio)!=null?r:[]];for(let o of a)for(let s of o.representations){let d=`${s.mimeType};codecs=\"${s.codecs[0]}\"`;if(e.has(d))s.isCodecSupportedInWebWorker=e.get(d);else{let u=mt.isTypeSupported(d);s.isCodecSupportedInWebWorker=u,e.set(d,u)}}}}function gl(n,e){var a,o,s,d,u,f,l;let t,r,i;return typeof((a=n.representationFilter)==null?void 0:a.fn)==\"function\"?i=n.representationFilter.fn:typeof((o=n.representationFilter)==null?void 0:o.eval)==\"string\"?i=So(n.representationFilter.eval):typeof((s=n.representationFilter)==null?void 0:s.workerId)==\"string\"&&(i=e.representationFilters.get(n.representationFilter.workerId)),typeof((d=n.manifestLoader)==null?void 0:d.fn)==\"function\"?t=n.manifestLoader.fn:typeof((u=n.manifestLoader)==null?void 0:u.workerId)==\"string\"&&(t=e.manifestLoaders.get(n.manifestLoader.workerId)),typeof((f=n.segmentLoader)==null?void 0:f.fn)==\"function\"?r=n.segmentLoader.fn:typeof((l=n.segmentLoader)==null?void 0:l.workerId)==\"string\"&&(r=e.segmentLoaders.get(n.segmentLoader.workerId)),{manifestLoader:t,segmentLoader:r,representationFilter:i}}var Qn=class extends le{constructor(e,t,r){super(),this._canceller=new z(\"Boundaries Observation\"),this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ra(e);this._maximumPositionCalculator=i;let a=this._canceller.signal;rt(()=>{t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let d=new Z(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",d)}else if(s>i.getMaximumAvailablePosition()){let d=new Z(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",d)}},{includeLastObservation:!1,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(e){this.removeEventListener(),this._canceller.cancel(e!=null?e:\"ContentTimeBoundariesObserver dispose\")}_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(d=>d.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 kt((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)}},ra=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=Lr(this._lastVideoAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}}else if(this._lastVideoAdaptation===null){let e=Lr(this._lastAudioAdaptation);return typeof e!=\"number\"?this._manifest.getMaximumSafePosition():e}else{let e=Lr(this._lastAudioAdaptation),t=Lr(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=Fr(this._lastVideoAdaptation))!=null?e:void 0;if(this._lastVideoAdaptation===null)return(t=Fr(this._lastAudioAdaptation))!=null?t:void 0;{let r=Fr(this._lastAudioAdaptation),i=Fr(this._lastVideoAdaptation);return typeof r!=\"number\"||typeof i!=\"number\"?void 0:Math.min(r,i)}}}};function Lr(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=C(t)?a:Math.min(t,a))}return t}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.getEnd();if(a===void 0)return;a!==null&&(t=C(t)?a:Math.min(t,a))}return t}function ia(n,e,t,r,i,a){a.register(d=>{e.interruptDurationSetting(d.reason)});let o=new Qn(n,t,r.getBufferTypes());a.register(d=>{o.dispose(d.reason)}),o.addEventListener(\"warning\",d=>i.onWarning(d)),o.addEventListener(\"periodChange\",d=>i.onPeriodChanged(d)),o.addEventListener(\"endingPositionChange\",d=>{e.setDuration(d.endingPosition,d.isEnd)}),o.addEventListener(\"endOfStream\",()=>{c.debug(\"mse\",\"Start applying end-of-stream order.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function aa(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=j(n.sourceBuffers,s=>s.type===\"audio\"),i=j(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}async function oa(n,e,t,r,i){let a=e.getPeriod(t);if(a===void 0)throw new Error(\"Wanted Period not found.\");let o=j(a.thumbnailTracks,d=>d.id===r);if(o===void 0)throw new Error(\"Wanted Period has no thumbnail track.\");let s=o.index.getSegments(i,1)[0];if(s===void 0)throw new Error(\"No thumbnail for the given timestamp\");return n({segment:s,track:o,period:a},new z(void 0).signal)}function sa(n,e){[\"video\",\"audio\",\"text\"].forEach(t=>{var i;let r=e.getStatus(t);r.type===\"initialized\"&&r.value.synchronizeInventory((i=n.buffered[t])!=null?i:[])})}function da(n,e,t){let{DEFAULT_WANTED_BUFFER_AHEAD:r,DEFAULT_MAX_VIDEO_BUFFER_SIZE:i,DEFAULT_MAX_BUFFER_AHEAD:a,DEFAULT_MAX_BUFFER_BEHIND:o}=L.getCurrent(),s={wantedBufferAhead:new X(r),maxVideoBufferSize:new X(i),maxBufferAhead:new X(a),maxBufferBehind:new X(o),limitVideoResolution:new X({height:void 0,width:void 0,pixelRatio:1}),throttleVideoBitrate:new X(1/0)},d=!1,u=new Ht({hasVideo:!0}),f=null,l=null;n(m=>{var h,b;c.debug(\"Core\",\"received message\",{name:m.data.type});let p=m.data;switch(p.type){case\"init\":{if(Ie(!d),d=!0,io(p.value),ks(p.value.logLevel,p.value.logFormat,p.value.sendBackLogs),!C(p.value.dashWasmUrl)){let g=ke.dashParsers.wasm;g===null?c.error(\"Core\",\"Could not initialize DASH_WASM parser: DASH_WASM feature not added\"):g.isCompatible()?g.initialize({wasmUrl:p.value.dashWasmUrl}).catch(S=>{let T=S instanceof Error?S.toString():\"Unknown Error\";c.error(\"Core\",\"Could not initialize DASH_WASM parser\",T)}):c.warn(\"Core\",\"Could not initialize DASH_WASM parser: Browser not compatible\")}p.value.hasVideo||(u.disposeCurrentContent(\"Received Init msg\"),u=new Ht({hasVideo:p.value.hasVideo})),e({type:\"init-success\",value:null})}break;case\"log-level-update\":ks(p.value.logLevel,p.value.logFormat,p.value.sendBackLogs);break;case\"prepare\":hl(e,u,p.value,s,t);break;case\"start\":{let g=u.getCurrentContent();if(p.contentId!==(g==null?void 0:g.contentId))return;f==null||f.stop(),l==null||l.finish();let S=new X(K(p.value.initialObservation,{position:new xt(...p.value.initialObservation.position)}));l=S,f=bl(e,p.value,u,S,s);break}case\"observation\":{let g=u.getCurrentContent();if(p.contentId!==(g==null?void 0:g.contentId))return;let S=p.value,{buffered:T}=S,v=aa(g.mediaSource,null);v.audio!==null&&(T.audio=v.audio),v.video!==null&&(T.video=v.video),l==null||l.setValue(K(S,{position:new xt(...p.value.position)}));break}case\"ref-update\":Il(p,s);break;case\"stop\":if(p.contentId!==((h=u.getCurrentContent())==null?void 0:h.contentId))return;u.disposeCurrentContent(\"StopContent message\"),f==null||f.stop(),f=null,l==null||l.finish(),l=null;break;case\"ms-reload\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;f==null||f.signalMediaSourceReload()}break;case\"sb-success\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;let{sourceBuffers:S}=g.mediaSource,T=j(S,v=>v.type===p.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Success for an unknown SourceBuffer\",{sourceBufferType:p.sourceBufferType});return}if(T.onOperationSuccess===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:p.sourceBufferType});return}T.onOperationSuccess(p.operationId,p.value.buffered);break}case\"sb-error\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;let{sourceBuffers:S}=g.mediaSource,T=j(S,v=>v.type===p.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Error for an unknown SourceBuffer\",{sourceBufferType:p.sourceBufferType});return}if(T.onOperationFailure===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:p.sourceBufferType});return}T.onOperationFailure(p.operationId,p.value);break}case\"media-source-ready-state-change\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;if(g.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"Core\",\"A MediaSourceInterface with MSE performed a cross-thread operation\");return}g.mediaSource.onMediaSourceReadyStateChanged(p.value);break}case\"decipherability-update\":{if(p.contentId!==((b=u.getCurrentContent())==null?void 0:b.contentId))return;let g=u.getCurrentContent();if(g===null||g.manifest===null)return;let S=p.value;g.manifest.updateRepresentationsDeciperability(T=>{for(let v of S)if(T.representation.uniqueId===v.representationUniqueId)return v.decipherable;return T.representation.decipherable});break}case\"codec-support-update\":{let g=u.getCurrentContent();if(g===null||g.manifest===null)return;let S=p.value;try{let T=g.manifest.updateCodecSupport(S);T!==null&&e({type:\"warning\",contentId:g.contentId,value:ve(T)})}catch(T){e({type:\"error\",contentId:g.contentId,value:ve(T)})}break}case\"urls-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.manifestFetcher.updateContentUrls(p.value.urls,p.value.refreshNow);break}case\"track-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.trackChoiceSetter.setTrack(p.value.periodId,p.value.bufferType,p.value.choice);break}case\"rep-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.trackChoiceSetter.updateRepresentations(p.value.periodId,p.value.adaptationId,p.value.bufferType,p.value.choice);break}case\"add-text-success\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}g.coreTextSender.onPushedTrackSuccess(p.value.ranges);break}case\"push-text-error\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}g.coreTextSender.onPushedTrackError(new Error(p.value.message));break}case\"remove-text-success\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}g.coreTextSender.onRemoveSuccess(p.value.ranges);break}case\"remove-text-error\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}g.coreTextSender.onRemoveError(new Error(p.value.message));break}case\"pull-segment-sink-store-infos\":{Sl(e,u,p.value.requestId);break}case\"thumbnail-request\":{Tl(e,u,p);break}case\"config-update\":{L.update(p.value);break}case\"app-defined\":break;default:Be(p)}})}function hl(n,e,t,r,i){e.initializeNewContent(n,t,{limitResolution:{video:r.limitVideoResolution},throttleBitrate:{video:r.throttleVideoBitrate}},i).then(a=>{n({type:\"manifest-ready\",contentId:t.contentId,value:{manifest:a}})},a=>{n({type:\"error\",contentId:t.contentId,value:ve(a)})})}function Il(n,e){switch(n.value.name){case\"wantedBufferAhead\":e.wantedBufferAhead.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":e.maxVideoBufferSize.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":e.maxBufferBehind.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":e.maxBufferAhead.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":e.limitVideoResolution.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":e.throttleVideoBitrate.setValueIfChanged(n.value.newVal);break;default:Be(n.value)}}function bl(n,e,t,r,i){c.debug(\"Core\",\"Loading pepared content.\");let a=new z(\"Start Content Worker\"),o=null;return s(e.initialTime),{signalMediaSourceReload:()=>u(),stop:()=>{a.cancel(\"ContentHandle stop\")}};function s(f){var N;o==null||o.cancel(\"Reloading content worker\"),o=new z(\"(Re)Loading Content Worker\"),o.linkToSignal(a.signal);let l=new Map,m=t.getCurrentContent();if(m===null||m.manifest===null){let P=new Ee(\"NONE\",\"Loading content when none is prepared\");throw n({type:\"error\",contentId:void 0,value:ve(P)}),P}let{contentId:p,cmcdDataBuilder:h,enableRepresentationAvoidance:b,manifest:g,mediaSource:S,representationEstimator:T,segmentSinksStore:v,segmentQueueCreator:E}=m,{drmSystemId:R,enableFastSwitching:_,onCodecSwitch:k}=e;r.onUpdate(P=>{sa(P,v);let M=m.freezeResolver.onNewObservation(P);M!==null&&yl(n,M,{contentId:p,manifest:g,handleMediaSourceReload:d,enableRepresentationAvoidance:b})},{clearSignal:o.signal});let A=(N=g.getPeriodForTime(f))!=null?N:g.getNextPeriod(f);if(A===void 0){let P=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");throw n({type:\"error\",contentId:p,value:ve(P)}),P}let x=new hn(r,p,n,o.signal);h==null||h.startMonitoringPlayback(x),o.signal.register(()=>{h==null||h.stopMonitoringPlayback()});let B=ia(g,S,x,v,{onWarning:P=>n({type:\"warning\",contentId:p,value:ve(P)}),onPeriodChanged:P=>{n({type:\"active-period-changed\",contentId:p,value:{periodId:P.id}})}},o.signal);ls({initialPeriod:A,manifest:g},x,T,v,E,{wantedBufferAhead:i.wantedBufferAhead,maxVideoBufferSize:i.maxVideoBufferSize,maxBufferAhead:i.maxBufferAhead,maxBufferBehind:i.maxBufferBehind,drmSystemId:R,enableFastSwitching:_,onCodecSwitch:k},D(),o.signal);function D(){return{needsBufferFlush(P){n({type:\"needs-buffer-flush\",contentId:p,value:P})},streamStatusUpdate(P){W(P),g.isLastPeriodKnown&&P.period.id===g.periods[g.periods.length-1].id&&(P.hasFinishedLoading||P.isEmptyStream?B.onLastSegmentFinishedLoading(P.bufferType):B.onLastSegmentLoadingResume(P.bufferType))},needsManifestRefresh(){t.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:P}=L.getCurrent();t.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:P})},lockedStream(P){n({type:\"locked-stream\",contentId:p,value:{periodId:P.period.id,bufferType:P.bufferType}})},adaptationChange(P){var M,w;B.onAdaptationChange(P.type,P.period,P.adaptation),!(o===null||o.signal.isCancelled())&&n({type:\"adaptation-changed\",contentId:p,value:{adaptationId:(w=(M=P.adaptation)==null?void 0:M.id)!=null?w:null,periodId:P.period.id,type:P.type}})},representationChange(P){var M,w;B.onRepresentationChange(P.type,P.period),!(o===null||o.signal.isCancelled())&&n({type:\"representation-changed\",contentId:p,value:{adaptationId:P.adaptation.id,representationId:(w=(M=P.representation)==null?void 0:M.id)!=null?w:null,periodId:P.period.id,type:P.type}})},inbandEvent(P){n({type:\"inband-event\",contentId:p,value:P})},warning(P){n({type:\"warning\",contentId:p,value:ve(P)})},periodStreamReady(P){m!==null&&(m.trackChoiceSetter.addTrackSetter(P.period.id,P.type,P.adaptationRef),n({type:\"period-stream-ready\",contentId:p,value:{periodId:P.period.id,bufferType:P.type}}))},periodStreamCleared(P){if(m===null)return;let M=l.get(P.period);M!==void 0&&(M.delete(P.type),M.size===0&&l.delete(P.period)),B.onPeriodCleared(P.type,P.period),m.trackChoiceSetter.removeTrackSetter(P.period.id,P.type),n({type:\"period-stream-cleared\",contentId:p,value:{periodId:P.period.id,bufferType:P.type}})},bitrateEstimateChange(P){var M;m!==null&&((M=m.cmcdDataBuilder)==null||M.updateThroughput(P.type,P.bitrate)),n({type:\"bitrate-estimate-change\",contentId:p,value:{bitrate:P.bitrate,bufferType:P.type}})},needsMediaSourceReload(P){d(P)},needsDecipherabilityFlush(){n({type:\"needs-decipherability-flush\",contentId:p,value:null})},encryptionDataEncountered(P){for(let M of P){let w=M.content,U=J({},w);U.manifest instanceof ht&&(U.manifest=U.manifest.getMetadataSnapshot()),U.period instanceof gt&&(U.period=U.period.getMetadataSnapshot()),U.adaptation instanceof ft&&(U.adaptation=U.adaptation.getMetadataSnapshot()),U.representation instanceof un&&(U.representation=U.representation.getMetadataSnapshot()),n({type:\"encryption-data-encountered\",contentId:p,value:{keyIds:M.keyIds,values:M.values,content:U,type:M.type}})}},error(P){n({type:\"error\",contentId:p,value:ve(P)})}}}function W(P){let{imminentDiscontinuity:M}=P,w=l.get(P.period),U=w==null?void 0:w.get(P.bufferType);if(U!==void 0){if(U.discontinuity===null){if(M===null)return}else if(M!==null&&U.discontinuity.start===M.start&&U.discontinuity.end===M.end)return}w===void 0&&(w=new Map,l.set(P.period,w));let H={periodId:P.period.id,bufferType:P.bufferType,discontinuity:P.imminentDiscontinuity,position:P.position};w.set(P.bufferType,H),n({type:\"discontinuity-update\",contentId:p,value:H})}}function d(f){var m;o!==null&&(o.cancel(\"WorkerMain MediaSource reload\"),o=null);let l=(m=t.getCurrentContent())==null?void 0:m.mediaSource.id;if(l===void 0){c.warn(\"Core\",\"Cannot reload MediaSource: no MediaSource currently.\");return}c.debug(\"Core\",\"Reloading MediaSource\",{timeOffset:f.timeOffset,minimumPosition:f.minimumPosition,maximumPosition:f.maximumPosition}),n({type:\"reloading-media-source\",mediaSourceId:l,value:f},[]),u()}function u(){var p;let l=r.getValue().position.getWanted();o!==null&&(o.cancel(\"MediaSource reload\"),o=null);let m=(p=t.getCurrentContent())==null?void 0:p.contentId;t.reloadMediaSource(n).then(()=>{c.info(\"Core\",\"MediaSource Reloaded, loading content again\",{newInitialTime:l}),s(l)},h=>{if(z.isCancellationError(h)){c.info(\"Core\",\"A reloading operation was cancelled\");return}n({type:\"error\",contentId:m,value:ve(h)})})}}function ks(n,e,t){t?c.setLevel(n,\"standard\",(r,i,a)=>{let o=a.map(s=>s instanceof Error?ve(s):s);postMessage({type:\"log\",value:{namespace:i,logLevel:r,logs:o}})}):c.setLevel(n,e)}function Sl(n,e,t){let r=e.getCurrentContent();if(r===null)return;let i=r.segmentSinksStore.getSegmentSinksMetrics();n({type:\"segment-sink-store-update\",contentId:r.contentId,value:{segmentSinkMetrics:i,requestId:t}})}function yl(n,e,{contentId:t,manifest:r,handleMediaSourceReload:i,enableRepresentationAvoidance:a}){switch(e.type){case\"reload\":{c.info(\"Core\",\"Planning reload due to freeze\"),i({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}case\"flush\":{c.info(\"Core\",\"Flushing buffer due to freeze\"),n({type:\"needs-buffer-flush\",contentId:t,value:{relativeResumingPosition:e.value.relativeSeek,relativePosHasBeenDefaulted:!1}});break}case\"avoid-representations\":{c.info(\"Core\",\"Planning Representation avoidance due to freeze\");let o=e.value;a&&r.addRepresentationsToAvoid(o),i({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}default:Be(e)}}function Tl(n,e,t){let r=e.getCurrentContent(),i=a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"error\",requestId:t.value.requestId,error:ve(a)}})};if(r===null||r.manifest===null||r.contentId!==t.contentId)return i(new Error(\"Content changed\"));oa(r.fetchThumbnailData,r.manifest,t.value.periodId,t.value.thumbnailTrackId,t.value.time).then(a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"success\",requestId:t.value.requestId,data:a}},[a.data])},a=>i(a))}var Ms=da;var El=new Rt,zr=El;var _l=\"<\",Rl=60,Os=\">\",Wr=62,ua=45,ws=47,Pl=33,Ds=39,Bs=34,la=91,vl=93,Cl=`\\r\n\t>/= `;function fa(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(u()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=Ns(a,e.filter)),a;function o(h){let b=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===Rl){if(n.charCodeAt(t+1)===ws){let S=t+2;if(t=n.indexOf(Os,t),n.substring(S,t).indexOf(h)===-1){let v=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(v.length-1)+`\nColumn: `+(v[v.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),b}else if(n.charCodeAt(t+1)===Pl){if(n.charCodeAt(t+2)===ua){let S=t;for(;t!==-1&&!(n.charCodeAt(t)===Wr&&n.charCodeAt(t-1)===ua&&n.charCodeAt(t-2)===ua);)t=n.indexOf(Os,t+1);t===-1&&(t=n.length),r&&b.push(n.substring(S,t+1))}else if(n.charCodeAt(t+2)===la&&n.charCodeAt(t+8)===la&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let S=n.indexOf(\"]]>\",t);S===-1?(b.push(n.substring(t+9)),t=n.length):(b.push(n.substring(t+9,S)),t=S+3);continue}else{let S=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==Wr||T)&&n[t]!==void 0;)n.charCodeAt(t)===la?T=!0:T&&n.charCodeAt(t)===vl&&(T=!1),t++;b.push(n.substring(S,t))}t++;continue}let g=u();b.push(g),g.tagName[0]===\"?\"&&(b.push(...g.children),g.children=[])}else{let g=s();if(i)g.length>0&&b.push(g);else{let S=g.trim();S.length>0&&b.push(S)}t++}return b}function s(){let h=t;return t=n.indexOf(_l,t)-1,t===-2&&(t=n.length),n.slice(h,t+1)}function d(){let h=t;for(;Cl.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(h,t)}function u(){let h=t;t++;let b=d(),g={},S=[];for(;n.charCodeAt(t)!==Wr&&n[t]!==void 0;){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let v=d(),E=n.charCodeAt(t);for(;!isNaN(E)&&E!==Ds&&E!==Bs&&!(E>64&&E<91||E>96&&E<123)&&E!==Wr;)t++,E=n.charCodeAt(t);let R;E===Ds||E===Bs?R=f():(R=null,t--),g[v]=R===null?null:Us(R)}t++}return n.charCodeAt(t-1)!==ws?(t++,S=o(b)):t++,{tagName:b,attributes:g,children:S,posStart:h,posEnd:t}}function f(){let h=n[t],b=t+1;return t=n.indexOf(h,b),n.slice(b,t)}function l(){let h=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return h!==null?h.index:-1}}function Ns(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=Ns(a.children,e,t+1,(Q(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function qr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+qr(t),e=e.trim()}),e}else return typeof n==\"object\"?qr(n.children):\" \"+Us(n)}function Us(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 ma(n,e,t){let{repeatCount:r}=n;if(r>=0)return r;let i;return C(e)?t!==void 0?i=t:i=Number.MAX_VALUE:i=e.start,Math.ceil((i-n.start)/n.duration)-1}function Fe(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ma(n,e,t);return r+(a+1)*i}function Ce(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function Je(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function Ls(n,e,t){return[n*t,(n+e)*t]}function Al(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 Fs(n,e,t){let{timeline:r}=n,i=Ce(e,n);if(i<0)return null;let a=Al(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 d=s.start,u=Fe(o,s,t);return i>=u&&i<d?Je(d,n):null}function it(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:C(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 xl(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function ca(n){return(e,t,r)=>{let i=Q(r)?parseInt(r,10):1;return xl(String(n),i)}}function ze(n,e,t){return kl(n,e,t)}function kl(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(%0(\\d+)d)?\\$/g,ca(t===void 0?0:t))}function Vr(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 ca(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 ca(n)(i,a,o)})}}function Ml(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function $n(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),d=Ce(e,n),u=Ce(s,n),{timeline:f,timescale:l,segmentUrlTemplate:m,startNumber:p,endNumber:h}=n,b=p!=null?p:1,g=[],S=f.length;for(let v=0;v<S;v++){let E=f[v],{duration:R,start:_,range:k}=E,A;o===void 0?A=i:A=Math.min(o*l,i!=null?i:1/0);let x=ma(E,f[v+1],A),B=n.availabilityTimeComplete!==!1||v!==S-1&&x!==0,D=Ml(_,R,d),W=_+D*R;for(;W<u&&D<=x;){let N=b+D;if(h!==void 0&&N>h)break;let P=m===null?null:Vr(W,N)(m),M=W-n.indexTimeOffset,w=R;M<0&&(w=R+M,M=0);let U={id:String(W),time:M/l,end:(M+w)/l,duration:w/l,isInit:!1,range:k,timescale:1,url:P,number:N,timestampOffset:-(n.indexTimeOffset/l),complete:B,privateInfos:{isEMSGWhitelisted:a}};g.push(U),D++,W=_+D*R}if(W>=u||(b+=x+1,h!==void 0&&b>h))return g}return g}function Ol(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 Mt=class{constructor(e,t){var h,b,g,S;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,d=(h=e.timescale)!=null?h:1,f=((b=e.presentationTimeOffset)!=null?b:0)-r*d,l=((g=e.initialization)==null?void 0:g.media)===void 0?null:ze(e.initialization.media,a,o),m=e.media===void 0?null:ze(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:f,initialization:{url:l,range:p},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(S=e.timeline)!=null?S:[],timescale:d},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Ce(r,this._index),this._scaledPeriodEnd=C(i)?void 0:Ce(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return $n(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:Je(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(Fe(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return Je(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++)Ol(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}getTargetSegmentDuration(){let{timeline:e,timescale:t}=this._index,r=e[0];if(r!==void 0)return{duration:r.duration/t,isPrecize:!1}}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){c.error(\"dash\",\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Ot=class{constructor(e,t){var p,h,b;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 d=(p=e.presentationTimeOffset)!=null?p:0,u=(h=e.timescale)!=null?h:1,f=d-r*u,l=((b=e.initialization)==null?void 0:b.media)===void 0?null:ze(e.initialization.media,a,o),m=e.list.map(g=>({url:g.media===void 0?null:ze(g.media,a,o),mediaRange:g.mediaRange}));this._index={list:m,timescale:u,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:C(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=it(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,d=e-this._periodStart,[u,f]=Ls(d,t,o),l=Math.min(a.length-1,Math.floor(f/i)),m=[],p=Math.floor(u/i);for(;p<=l;){let h=a[p].mediaRange,b=a[p].url,g=p*s+this._periodStart,S={id:String(p),time:g,isInit:!1,range:h,duration:s,timescale:1,end:g+s,url:b,timestampOffset:-(r.indexTimeOffset/o),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};m.push(S),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(\"dash\",\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `ListRepresentationIndex`\")}getTargetSegmentDuration(){let{duration:e,timescale:t}=this._index;return{duration:e/t,isPrecize:!0}}_replace(e){this._index=e._index}_update(){c.error(\"dash\",\"A `ListRepresentationIndex` cannot be updated\")}};function Kt(n){return L.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var wt=class{constructor(e,t){var S,T,v;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:d,representationBitrate:u,isEMSGWhitelisted:f}=t,l=(S=e.timescale)!=null?S:1;this._availabilityTimeOffset=r,this._manifestBoundsCalculator=i;let m=(T=e.presentationTimeOffset)!=null?T:0,p=s*l,h=m-p;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let b=((v=e.initialization)==null?void 0:v.media)===void 0?null:ze(e.initialization.media,d,u),g=e.media===void 0?null:ze(e.media,d,u);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:h,initialization:C(e.initialization)?void 0:{url:b,range:e.initialization.range},url:g,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=f}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:d}=r,u=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-u,m=(e+t)*s-u,p=this._getFirstSegmentStart(),h=this._getLastSegmentStart();if(C(p)||C(h))return[];let b=Math.max(p,l),g=Math.min(h,m);if(g+i<=b)return[];let S=[],T=a!=null?a:1,v=Math.floor(b/i);for(let E=v*i;E<=g;E+=i){let R=v+T;if(o!==void 0&&R>o)return S;let _=!C(f)&&E+i>f?f-E:i,k=E+u,A=E+this._index.presentationTimeOffset,x=d===null?null:Vr(A,R)(d),B={id:String(R),number:R,time:k/s,end:(k+_)/s,duration:_/s,timescale:1,isInit:!1,scaledDuration:_/s,url:x,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};S.push(B),v++}return S}getFirstAvailablePosition(){let e=this._getFirstSegmentStart();return C(e)?e:e/this._index.timescale+this._periodStart}getLastAvailablePosition(){let e=this._getLastSegmentStart();if(C(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=Kt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,d=this._getLastSegmentStart();if(C(d)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let u=d+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>u-i:s>u-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(C(r))return!0;let i=r+this._index.duration,a=Kt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}getTargetSegmentDuration(){return{duration:this._index.duration/this._index.timescale,isPrecize:!0}}_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 d=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(d===void 0)return;let u=(d-this._periodStart)*t;if(u<0)return null;let f=Math.floor(u/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,d=Math.ceil(s/e);r!==void 0&&r-i+1<d&&(d=r-i+1);let u=(d-1)*e,f=L.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-u>f||d<2?u:(d-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 pa(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 ga(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(Fe(i,e[0])<r)throw new Z(\"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 m=t-f;return n.splice(f,m,...e),!1}else if(l<r){let m=n[f];if(m.start+m.duration>r)return c.warn(\"utils\",\"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(f+1,t-(f+1),...e),!1;if(m.start+m.duration*(m.repeatCount+1)<=r)return n.splice(f+1,t-(f+1),...e),!1;let h=(r-m.start)/m.duration-1;if(h%1===0&&m.duration===e[0].duration){let b=e[0].repeatCount<0?-1:e[0].repeatCount+h+1;return n.splice(f,t-f,...e),n[f].start=m.start,n[f].repeatCount=b,!1}return c.warn(\"utils\",\"Manifest update removed previous segments\"),n[f].repeatCount=Math.floor(h),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?(c.warn(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let d=o.start+o.duration*(o.repeatCount+1),u=s.start+s.duration*(s.repeatCount+1);return d>=u?(c.warn(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function Xn(n,e,t){let r=n.start,i=n.duration,a=n.repeatCount;return r===void 0&&(e===null?r=0:C(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 Zn(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!C(r))switch(t){case\"t\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid t value for <S> element\",{val:r}):e.start=i;break}case\"d\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid d value for <S> element\",{val:r}):e.duration=i;break}case\"r\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid r value for <S> element\",{val:r}):e.repeatCount=i;break}}}return e}function St(n){let e=[];for(let r=0;r<n.length;r++)e.push(Zn(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=Xn(i,a,o);s!==null&&t.push(s)}return t}function ha(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=e[0].attributes.t,i=C(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=e[0],s=i;for(;;){let d=o.attributes.d,u=C(d)?null:parseInt(d,10);if(u===null||Number.isNaN(u))return null;let f=o.attributes.r,l=C(f)?null:parseInt(f,10);if(l!==null){if(Number.isNaN(l)||l<0)return null;if(l>0){let h=t-s;if(h%u===0&&h/u<=l)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/u,prevSegmentsIdx:0,newElementsIdx:a}}s+=u*(l+1)}else s+=u;if(a++,a>=e.length)return null;o=e[a];let m=o.attributes.t,p=C(m)?null:parseInt(m,10);if(p!==null){if(Number.isNaN(p))return null;s=p}if(s===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(s>i)return null}}}function Ia(n,e){var b;let t=ha(e,n);if(t===null)return c.warn(\"dash\",'Cannot perform \"based\" update. Common segment not found.'),St(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,d=e.length-r+i-1;if(d>=n.length)return c.info(\"dash\",'Cannot perform \"based\" update. New timeline too short'),St(n);let u=e.slice(r);if(a>0){let g=u[0];g.start+=g.duration*a,u[0].repeatCount-=a}if(o>0&&i!==0)return c.info(\"dash\",'Cannot perform \"based\" update. The new timeline has a different form.'),St(n);let f=u[u.length-1],l=Zn(n[d]),m=((b=l.repeatCount)!=null?b:0)-o;if(l.duration!==f.duration||f.repeatCount>m)return c.info(\"dash\",'Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),St(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let p=[],h=[];for(let g=d+1;g<n.length;g++)h.push(Zn(n[g]));for(let g=0;g<h.length;g++){let S=h[g],T=p[p.length-1]===void 0?f:p[p.length-1],v=h[g+1]===void 0?null:h[g+1],E=Xn(S,T,v);E!==null&&p.push(E)}return u.concat(p)}var Jn=class n{constructor(e,t){var E,R,_,k,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:d,representationBitrate:u,periodStart:f,periodEnd:l,isEMSGWhitelisted:m}=t,p=(E=e.timescale)!=null?E:1,h=(R=e.presentationTimeOffset)!=null?R:0,b=f*p,g=h-b;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(_=t.receivedTime)!=null?_:F(),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 S=((A=e.initialization)==null?void 0:A.media)===void 0?null:ze(e.initialization.media,d,u),T=e.media===void 0?null:ze(e.media,d,u),v;i===void 0&&r===void 0?v=1/0:v=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:v,indexRange:e.indexRange,indexTimeOffset:g,initialization:C(e.initialization)?void 0:{url:S,range:e.initialization.range},segmentUrlTemplate:T,startNumber:e.startNumber,endNumber:e.endNumber,timeline:e.timeline===void 0?null:ba(e.timeline,e.startNumber,e.endNumber),timescale:p},this._scaledPeriodStart=Ce(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:Ce(l,this._index)}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),$n(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:Je(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=Gr(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 Je(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(Fe(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return Je(t,this._index)}awaitSegmentBetween(e,t){var u,f;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=Kt(r),o=Ce(t,this._index),s=Gr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(u=this._scaledPeriodEnd)!=null?u:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let d=Ce(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],p=Fe(l,null,this._scaledPeriodEnd)+a;if(d<p+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:d-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()),wl(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),Fs({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Xe&&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()),ga(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&&Ce(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Kt(this._index.timescale),r=Gr(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 Fe(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}getTargetSegmentDuration(){this._refreshTimeline();let{timeline:e,timescale:t}=this._index;if(e===null)return;let r=e[0];if(r!==void 0)return{duration:r.duration/t,isPrecize:!1}}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(C(e))return;let t=Ce(e,this._index),r=pa(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}=L.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return ba(St(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,ba(Ia(e,r),this._index.startNumber,this._index.endNumber)}};function ba(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=J({},a),d=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-d),o.push(s),o}}}return n}function wl(n,e,t,r){let i=Gr(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:!C(n.range)&&o.range[0]===n.range[0]&&o.range[1]===n.range[1];if(o.repeatCount>=0&&o.duration!==void 0){let u=(s-o.start)/o.duration-1;return u%1===0&&u<=i.newRepeatCount}}return!1}function Gr(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:Fe(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:Fe(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(Je(o,n)<=r){let s=Fe(a,n.timeline[i+1],t);if(Je(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let u=Ce(r,n)-a.start,f=Math.floor(u/a.duration);return Ie(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var Hr=Jn;var er=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 Sa(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\"),Sa(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),Sa(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function Sa(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=e.attributes.keyId;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=j(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function Kr(n){let e=Date.parse(n)-F();if(isNaN(e)){c.warn(\"dash\",\"Invalid clock received\",{clock:n});return}return e}function ya(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 jr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function Ta(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=jr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=jr(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(\"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 Yr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function Ea(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=Yr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Yr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"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 _a(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Ea(n),t=Ta(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var tr=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(F()+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+F()/1e3,0):this._lastPosition}};function Ra(n,e){return n.type!==\"dynamic\"?0:C(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Pa(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.\",{lastStart:i==null?void 0:i.start,newStart: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 va(n,e){let t=[];return n.forEach((r,i)=>{let a;if(!C(r.attributes.start))a=r.attributes.start;else if(i===0)a=!e.isDynamic||C(e.availabilityStartTime)?0:e.availabilityStartTime;else{let u=t[t.length-1];if(!C(u)&&!C(u.periodEnd))a=u.periodEnd;else throw new Error(\"Missing start time when parsing periods.\")}let o,s=n[i+1];C(r.attributes.duration)?i===n.length-1?o=e.duration:C(s.attributes.start)||(o=s.attributes.start-a):o=r.attributes.duration;let d=C(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:d})}),t}function Dl(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Lt){let s=n[o];if(s!==void 0)for(let d of s)d.id===a&&(d.trickModeTracks===void 0&&(d.trickModeTracks=[]),d.trickModeTracks.push(r))}}}var zs=Dl;var Bl=[\"subtitle\",\"caption\"];function Ca(n,e){var s,d,u,f;let t=(f=j((s=n.children.essentialProperties)!=null?s:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:j((u=(d=e!=null?e:n.children.representations[0])==null?void 0:d.children.essentialProperties)!=null?u:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\");if(t===void 0)return null;let r=/(\\d+)x(\\d+)/;if(t===void 0||t.value===void 0||!r.test(t.value))return c.warn(\"dash\",\"Invalid thumbnails Representation, no tile-related information\"),null;let i=t.value.match(r),a=parseInt(i[1],10),o=parseInt(i[2],10);return{horizontalTiles:a,verticalTiles:o}}function Aa(n,e){if(n.attributes.contentType===\"image\")return Ca(n)!==null?\"thumbnails\":void 0;let t=Q(n.attributes.mimeType)?n.attributes.mimeType:null,r=Q(n.attributes.codecs)?n.attributes.codecs:null,i=C(n.children.roles)?null:n.children.roles;function a(s,d){let u=s.split(\"/\")[0];if(ge(Lt,u))return u;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return d!==null&&j(d,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&ge(Bl,f.value))!==void 0?\"text\":void 0}function o(s){switch(s.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(s.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(t!==null){let s=a(t,i);if(s!==void 0)return s}if(r!==null){let s=o(r);if(s!==void 0)return s}for(let s=0;s<e.length;s++){let d=e[s],{mimeType:u,codecs:f}=d.attributes;if(u!==void 0){let l=a(u,i);if(l!==void 0)return l}if(f!==void 0){let l=o(f);if(l!==void 0)return l}}}var Nl=/[, ]+/g;function Ws(n){return Q(n)?n.trim().replace(Nl,\", \"):\"\"}function qs(n){let[e,t,r,i,a,o,s,d]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let u,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(u=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&d!==void 0&&o===\"09\"&&d===\"09\"&&(l=\"rec2020\"),!(u===void 0||f===void 0))return{colorDepth:u,eotf:f,colorSpace:l}}function xa(n,e){var h,b,g;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:d,inbandEventStreams:u,isLastPeriod:f}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:d,isEMSGWhitelisted:S=>u===void 0?!1:u.some(({schemeIdUri:T})=>T===S.schemeIdUri),isLastPeriod:f,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:S}=n.children;p=new Mt(S,m)}else if(n.children.segmentList!==void 0){let{segmentList:S}=n.children;p=new Ot(S,m)}else if(n.children.segmentTemplate!==void 0||e.parentSegmentTemplates.length>0){let S=e.parentSegmentTemplates.slice(),T=n.children.segmentTemplate;T!==void 0&&S.push(T);let v=K({},...S);(v.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((h=v.availabilityTimeOffset)!=null?h:0)+((b=e.availabilityTimeOffset)!=null?b:0)),(v.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(g=v.availabilityTimeComplete)!=null?g:e.availabilityTimeComplete),p=Hr.isTimelineIndexArgument(v)?new Hr(v,m):new wt(v,m)}else{let S=e.adaptation.children;if(S.segmentBase!==void 0){let{segmentBase:T}=S;p=new Mt(T,m)}else if(S.segmentList!==void 0){let{segmentList:T}=S;p=new Ot(T,m)}else p=new wt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return p}function at(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 d=t[s],u=Ln(o.url,d.url);r.push({url:u,serviceLocation:(i=d.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Ul(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 Ll({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=j([...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)/.test(i))return qs(i)}function ka(n,e,t){var i,a,o,s,d,u,f;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(x=>x.id===m);)m+=\"-dup\";let p=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,h=Ul(l,e),b=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,g;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(g=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((d=t.availabilityTimeOffset)!=null?d:0));let S=K({},t,{availabilityTimeOffset:g,availabilityTimeComplete:b,unsafelyBaseOnPreviousRepresentation:p,adaptation:e,inbandEventStreams:h}),T=xa(l,S),v;l.attributes.bitrate===void 0?(c.warn(\"dash\",\"No usable bitrate found in the Representation.\"),v=0):v=l.attributes.bitrate;let E=at(t.baseURLs,l.children.baseURLs),R=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(x=>({baseUrl:x.url,id:x.serviceLocation})),_={bitrate:v,cdnMetadata:R,index:T,id:m};l.children.supplementalProperties!==void 0&&j(l.children.supplementalProperties,x=>x.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&x.value===\"JOC\")!==void 0&&(_.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,_.codecs=k);let A;l.attributes.supplementalCodecs!==void 0?A=l.attributes.supplementalCodecs:e.attributes.supplementalCodecs!==void 0&&(A=e.attributes.supplementalCodecs),A!==void 0&&(_.supplementalCodecs=Ws(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 x=[...(u=e.children.contentProtections)!=null?u:[],...(f=l.children.contentProtections)!=null?f:[]];for(let B of x)t.contentProtectionParser.add(_,B)}_.hdrInfo=Ll({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:k}),r.push(_)}return r}function Fl(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 zl(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 Wl(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function ql(n,e){if(Q(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,d=s;return Q(n.attributes.language)&&(d+=`-${n.attributes.language}`),t===!0&&(d+=\"-cc\"),r===!0&&(d+=\"-cc\"),i===!0&&(d+=\"-ad\"),a===!0&&(d+=\"-si\"),o&&(d+=\"-trickMode\"),Q(n.attributes.contentType)&&(d+=`-${n.attributes.contentType}`),Q(n.attributes.codecs)&&(d+=`-${n.attributes.codecs}`),Q(n.attributes.mimeType)&&(d+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(d+=`-${String(n.attributes.frameRate)}`),d}function Vl(n){if(!C(n.children.supplementalProperties)){let{supplementalProperties:e}=n.children;for(let t of e)if(t.schemeIdUri===\"urn:mpeg:dash:adaptation-set-switching:2016\"&&!C(t.value))return t.value.split(\",\").map(r=>r.trim()).filter(r=>Q(r))}return[]}function Ma(n,e){var d,u,f,l,m,p,h;let t={video:[],audio:[],text:[]},r=[],i=[],a={},o=[];for(let b=0;b<n.length;b++){let g=n[b],S=g.children,{essentialProperties:T,roles:v,label:E}=S,R=Array.isArray(v)&&v.some(ae=>ae.value===\"main\")&&v.some(ae=>ae.schemeIdUri===\"urn:mpeg:dash:role:2011\"),_=g.children.representations,k=(d=g.attributes.availabilityTimeComplete)!=null?d:e.availabilityTimeComplete,A;(g.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(A=((u=g.attributes.availabilityTimeOffset)!=null?u:0)+((f=e.availabilityTimeOffset)!=null?f:0));let x=Aa(g,_);if(x===void 0)continue;let B=(l=g.attributes.selectionPriority)!=null?l:1,D=g.attributes.id,W=Vl(g),N=[];e.segmentTemplate!==void 0&&N.push(e.segmentTemplate),g.children.segmentTemplate!==void 0&&N.push(g.children.segmentTemplate);let P={availabilityTimeComplete:k,availabilityTimeOffset:A,baseURLs:at(e.baseURLs,S.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:N,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},M=Array.isArray(T)?j(T,ae=>ae.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,w=(m=M==null?void 0:M.value)==null?void 0:m.split(\" \"),U=w!==void 0,{accessibilities:H}=S,$;v!==void 0&&v.some(ae=>ae.value===\"dub\")&&($=!0);let V;x!==\"text\"?V=!1:V=zl(H,v);let G;x===\"text\"&&v!==void 0&&v.some(ae=>ae.value===\"forced-subtitle\"||ae.value===\"forced_subtitle\")&&(G=!0);let Y;x!==\"audio\"?Y=!1:H!==void 0&&(Y=H.some(Fl));let fe;x!==\"video\"?fe=!1:H!==void 0&&(fe=H.some(Wl));let ue=ql(g,{isAudioDescription:Y,isForcedSubtitle:G,isClosedCaption:V,isSignInterpreted:fe,isTrickModeTrack:U,type:x});for(;ge(o,ue);)ue+=\"-dup\";let me=ue;o.push(ue),P.unsafelyBaseOnPreviousAdaptation=(h=(p=e.unsafelyBaseOnPreviousPeriod)==null?void 0:p.getAdaptation(ue))!=null?h:null;let Qe=ka(_,g,P);if(x===\"thumbnails\"){let ae=Gl(g,Qe);ae!==null&&r.push(...ae);continue}let te={id:ue,representations:Qe,type:x,isTrickModeTrack:U};if(C(g.attributes.language)||(te.language=g.attributes.language),C(V)||(te.closedCaption=V),C(Y)||(te.audioDescription=Y),$===!0&&(te.isDub=!0),G!==void 0&&(te.forcedSubtitles=G),fe===!0&&(te.isSignInterpreted=!0),E!==void 0&&(te.label=E),w!==void 0)i.push({adaptation:te,trickModeAttachedAdaptationIds:w});else{let ae=-1;for(let Xt of W){let Zt=a[Xt];if(Zt!==void 0&&Zt.newID!==me&&ge(Zt.adaptationSetSwitchingIDs,D)){ae=ne(t[x],Jt=>Jt[0].id===Xt);let _e=t[x][ae];if(_e!==void 0&&_e[0].audioDescription===te.audioDescription&&_e[0].closedCaption===te.closedCaption&&_e[0].language===te.language){c.info(\"dash\",'merging \"switchable\" AdaptationSets',{originalID:D,id:Xt}),_e[0].representations.push(...te.representations),_e[1]={priority:Math.max(B,_e[1].priority),isMainAdaptation:R||_e[1].isMainAdaptation,indexInMpd:Math.min(b,_e[1].indexInMpd)};break}}}ae<0&&t[x].push([te,{priority:B,isMainAdaptation:R,indexInMpd:b}])}!C(D)&&C(a[D])&&(a[D]={newID:me,adaptationSetSwitchingIDs:W})}let s=Lt.reduce((b,g)=>{let S=t[g];return S.length>0&&(S.sort(Vs),b[g]=S.map(([T])=>T)),b},{});return t.video.sort(Vs),zs(s,i),{adaptations:s,thumbnailTracks:r}}function Gl(n,e){var r,i;let t=[];for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(o.mimeType===void 0){c.warn(\"dash\",\"Invalid thumbnails Representation, no mime-type\");continue}let s=Ca(n,n.children.representations[a]);if(s===null)continue;if(o.height===void 0){c.warn(\"dash\",\"Invalid thumbnails Representation, no height information\");continue}if(o.width===void 0){c.warn(\"dash\",\"Invalid thumbnails Representation, no width information\");continue}let d=(r=o.index.getFirstAvailablePosition())!=null?r:void 0,u=(i=o.index.getEnd())!=null?i:void 0,f,l=o.index.getTargetSegmentDuration();l!==void 0&&l.isPrecize?f=l.duration:c.warn(\"dash\",\"Cannot produce duration estimate for thumbnail track\"),t.push({id:o.id,cdnMetadata:o.cdnMetadata,index:o.index,mimeType:o.mimeType,height:o.height,width:o.width,horizontalTiles:s.horizontalTiles,verticalTiles:s.verticalTiles,start:d,end:u,tileDuration:f===void 0?void 0:f/(s.horizontalTiles*s.verticalTiles)})}}return t}function Vs(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 Hl=Me();function Oa(n,e){var o,s,d,u,f;let t=[],r=va(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&&!C(e.duration)&&a.setLastPosition(e.duration);for(let l=n.length-1;l>=0;l--){let m=l===n.length-1,p=n[l],h=e.xlinkInfos.get(p),b=at(e.baseURLs,p.children.baseURLs),{periodStart:g,periodDuration:S,periodEnd:T}=r[l],v;for(C(p.attributes.id)?(v=\"gen-dash-period-\"+Hl(),c.warn(\"dash\",\"No usable id found in the Period. Generating one.\",{periodId:v})):v=p.attributes.id;t.some(U=>U.id===v);)v+=\"-dup\";let E=h!==void 0?h.receivedTime:e.receivedTime,R=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(v))!=null?s:null,_=p.attributes.availabilityTimeComplete,k=p.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:x}=e,{segmentTemplate:B}=p.children;x.addReferences((d=p.children.contentProtections)!=null?d:[]);let D={availabilityTimeComplete:_,availabilityTimeOffset:k,baseURLs:b,contentProtectionParser:x,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:m,manifestProfiles:A,receivedTime:E,segmentTemplate:B,start:g,unsafelyBaseOnPreviousPeriod:R},{adaptations:W,thumbnailTracks:N}=Ma(p.children.adaptations,D),P=((u=e.xmlNamespaces)!=null?u:[]).concat((f=p.attributes.namespaces)!=null?f:[]),M=jl(p.children.eventStreams,g,P),w={id:v,start:g,end:T,duration:S,thumbnailTracks:N,adaptations:W,streamEvents:M};if(t.unshift(w),!a.lastPositionIsKnown()){let U=Kl(W);if(!i)typeof U==\"number\"&&a.setLastPosition(U);else if(typeof U==\"number\"){let H=F()/1e3;a.setLastPosition(U,H)}else{let H=Gs(e,g);if(H!==void 0){let[$,V]=H;a.setLastPosition($,V)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=Gs(e,0);if(l!==void 0){let[m,p]=l;a.setLastPosition(m,p)}}return Pa(t)}function Gs(n,e){if(C(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"dash\",\"no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=F()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=F()/1e3,i=r+t;if(i>=e)return[i,r]}}function Kl(n){let e=null,t=!0,r=hr(n).filter(a=>!C(a)),i=_i(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let d=s.index.getLastAvailablePosition();d!==null&&(t=!1,typeof d==\"number\"&&(e=C(e)?d:Math.max(e,d)))}}if(C(e)){if(t)return null}else return e}function jl(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:d=1}=o.attributes,u=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)/d+e,m=f.duration===void 0?void 0:l+f.duration/d,p,h;try{h={namespaces:u,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:He(new Uint8Array(f.eventStreamData))}}catch(b){c.error(\"dash\",\"Error while parsing event-stream:\",b instanceof Error?b.message:\"Unknown error\")}r.push({start:l,end:m,id:f.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:d,element:p,xmlData:h}}})}}return r}function jt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(C(e.externalClockOffset)){let d=o.type===\"dynamic\",u=j(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!C(m.value)),f=!C(u)&&!C(u.value)?Kr(u.value):void 0,l=!C(f)&&!isNaN(f)?f:void 0;if(!C(l)&&r!==!0)e.externalClockOffset=l;else if(d&&r!==!0){let m=ya(n);if(!C(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(h){return h.success?(e.externalClockOffset=Kr(h.data),jt(n,e,t,!0)):(t.push(h.error),c.warn(\"dash\",\"Error on fetching the clock ressource\",h.error),jt(n,e,t,!0))}}}}}let s=[];for(let d=0;d<a.periods.length;d++){let{xlinkHref:u,xlinkActuate:f}=a.periods[d].attributes;!C(u)&&f===\"onLoad\"&&s.push({index:d,ressource:u})}return s.length===0?Yl(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:d})=>d),continue:function(u){if(u.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=u.length-1;f>=0;f--){let l=s[f].index,{parsed:m,warnings:p,receivedTime:h,sendingTime:b,url:g}=u[f];p.length>0&&t.push(...p);for(let S of m)i.set(S,{receivedTime:h,sendingTime:b,url:g});a.periods.splice(l,1,...m)}return jt(n,e,t,r,i)}}}}function Yl(n,e,t,r){var P,M,w,U,H;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Yi(e.url))}]:[],d=at(s,i.baseURLs),u=Ra(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:p}=e,{externalClockOffset:h}=e,b=new tr({availabilityStartTime:u,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:h}),g=new er;g.addReferences((P=i.contentProtections)!=null?P:[]);let S={availabilityStartTime:u,baseURLs:d,clockOffset:m,contentProtectionParser:g,duration:a.duration,isDynamic:o,manifestBoundsCalculator:b,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:p,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},T=Oa(i.periods,S);g.finalize();let v=a.duration,E,R,_=null,k;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:x,maximumUnsafePosition:B}=_a(T),D=F();if(o){let $;x!==void 0?$=x:h===void 0?(c.warn(\"dash\",\"use system clock to define maximum position\"),$=Date.now()/1e3-u):$=(F()+h)/1e3-u;let V=b.getEstimatedLiveEdge();V===void 0&&(B!==void 0?V=B:V=$),k={isLinear:!0,maximumSafePosition:$,livePosition:V,time:D},R=A,_=f!=null?f:null,_!==null&&(_+=l!=null?l:0),_!==null&&R!==void 0&&V-R>_&&(_=V-R)}else{R=A,R===void 0&&(R=(w=(M=T[0])==null?void 0:M.start)!=null?w:0);let $=v!=null?v:1/0;if(T[T.length-1]!==void 0){let V=T[T.length-1],G=(U=V.end)!=null?U:V.duration!==void 0?V.start+V.duration:void 0;G!==void 0&&G<$&&($=G)}x!==void 0&&x<$&&($=x),k={isLinear:!1,maximumSafePosition:$,livePosition:void 0,time:D}}let W=!o||n.attributes.minimumUpdatePeriod===void 0&&(((H=T[T.length-1])==null?void 0:H.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:u,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:W,periods:T,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:R,timeshiftDepth:_,maximumTimeData:k},lifetime:E,uris:C(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var Qr=jt;var Ql=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,$l=/([0-9]+)-([0-9]+)/;function Ae(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new De(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ie(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new De(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function we(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new De(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function wa(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new De(`\\`${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 De(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function Ke(n,e){if(!Q(n))return[0,new De(`\\`${e}\\` property is empty`)];let t=Ql.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(Q(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(Q(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(Q(t[6])?t[6]:\"0\")*24*60*60+parseFloat(Q(t[8])?t[8]:\"0\")*60*60+parseFloat(Q(t[10])?t[10]:\"0\")*60+parseFloat(Q(t[12])?t[12]:\"0\"),null]}function Dt(n,e){let t=$l.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Hs(n,e){try{return[Er(n),null]}catch(t){return[null,new De(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Yt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:we(n,e)}function ye(n){let e,t;for(let r of Object.keys(n.attributes)){let i=n.attributes[r];if(!C(i))switch(r){case\"schemeIdUri\":e=i;break;case\"value\":t=i;break}}return{schemeIdUri:e,value:t}}function Te(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(\"dash\",\"failed to parse DASH value:\",s.message,{dashName:a}),e.push(s)),o!==null&&(n[r]=o)}}var De=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function yt(n){return qr(n)}function ot(n){let e=typeof n==\"string\"?n:yt(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function Xl(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=yt(i.children);if(a!==null&&a.length>0){let[o,s]=Hs(a,\"cenc:pssh\");s!==null&&(c.warn(\"dash\",\"Content protection parsing failure\",s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function Zl(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!C(r))switch(t){case\"schemeIdUri\":e.schemeIdUri=r;break;case\"value\":e.value=r;break;case\"cenc:default_KID\":e.keyId=dn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function st(n){let[e,t]=Xl(n.children),r=Zl(n);return[{children:e,attributes:r},t]}function Da(n){let e={};for(let t of Object.keys(n.attributes)){let r=n.attributes[t];if(!C(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 Ba(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"range\":r(a,{asKey:\"range\",parser:Dt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function dt(n){let e={},t=[],r=Te(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,d]=Ba(o);e.initialization=s,t=t.concat(d)}}for(let a of Object.keys(n.attributes)){let o=n.attributes[a];if(!C(o))switch(a){case\"timescale\":r(o,{asKey:\"timescale\",parser:ie,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:we,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Dt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:Ae,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ie,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ie,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ie,dashName:\"endNumber\"});break}}return[e,t]}function Na(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"media\":e.media=a;break;case\"indexRange\":r(a,{asKey:\"indexRange\",parser:Dt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Dt,dashName:\"mediaRange\"});break}}return[e,t]}function nr(n){let[e,t]=dt(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let d=a[s];if(typeof d!=\"string\"&&d.tagName===\"SegmentURL\"){let[u,f]=Na(d);i.push(u),r=r.concat(f)}}return[K(e,{list:i}),r]}function Ua(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 Bt(n){let[e,t]=dt(n),r=t,i;for(let s=0;s<n.children.length;s++){let d=n.children[s];typeof d!=\"string\"&&d.tagName===\"SegmentTimeline\"&&(i=Ua(d))}let a=K({},e,{duration:e.duration,timelineParser:i}),o=Te(a,r);for(let s of Object.keys(n.attributes)){let d=n.attributes[s];if(!C(d))switch(s){case\"initialization\":C(a.initialization)&&(a.initialization={media:d});break;case\"index\":a.index=d;break;case\"availabilityTimeOffset\":o(d,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(d,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=d;break;case\"bitstreamSwitching\":o(d,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function Jl(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]=ot(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break}case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"SegmentBase\":{let[o,s]=dt(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=nr(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=Bt(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=st(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}case\"EssentialProperty\":C(e.essentialProperties)?e.essentialProperties=[ye(a)]:e.essentialProperties.push(ye(a));break;case\"SupplementalProperty\":C(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function ef(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"audioSamplingRate\":e.audioSamplingRate=a;break;case\"bandwidth\":r(a,{asKey:\"bitrate\",parser:ie,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Yt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ie,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ie,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new De(\"No bitrate found on a Representation\")),[e,t]}function Ks(n){let[e,t]=Jl(n.children),[r,i]=ef(n),a=t.concat(i);return[{children:e,attributes:r},a]}function tf(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=[ye(a)]:e.accessibilities.push(ye(a));break;case\"BaseURL\":{let[o,s]=ot(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=Da(a);break;case\"EssentialProperty\":C(e.essentialProperties)?e.essentialProperties=[ye(a)]:e.essentialProperties.push(ye(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(ye(a));break;case\"Label\":{let o=yt(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=Ks(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":C(e.roles)?e.roles=[ye(a)]:e.roles.push(ye(a));break;case\"SupplementalProperty\":C(e.supplementalProperties)?e.supplementalProperties=[ye(a)]:e.supplementalProperties.push(ye(a));break;case\"SegmentBase\":{let[o,s]=dt(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=nr(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=Bt(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=st(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}}}return t.length>0&&(e.contentProtections=t),[e,r]}function nf(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"id\":e.id=a;break;case\"group\":r(a,{asKey:\"group\",parser:ie,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:ie,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ie,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ie,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ie,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ie,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ie,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Yt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Yt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ie,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:wa,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:wa,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,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:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Yt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,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:ie,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function js(n){let e=n.children,[t,r]=tf(e),[i,a]=nf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function rf(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"schemeIdUri\":e.schemeIdUri=a;break;case\"value\":e.value=a;break;case\"timescale\":r(a,{asKey:\"timescale\",parser:ie,dashName:\"timescale\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Ys(n,e){let[t,r]=rf(n),i=[];for(let a of n.children)if(typeof a!=\"string\"&&a.tagName===\"Event\"){let o={};if(C(a.attributes.id)||(o.id=a.attributes.id),!C(a.attributes.presentationTime)){let[s,d]=ie(a.attributes.presentationTime,\"presentationTime\");d!==null&&r.push(d),s!==null&&(o.presentationTime=s)}if(!C(a.attributes.duration)){let[s,d]=ie(a.attributes.duration,\"duration\");d!==null&&r.push(d),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 af(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=ot(u);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=js(u);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=Ys(u,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=Bt(u);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=st(u);l.length>0&&(o=o.concat(l)),f!==void 0&&a.push(f);break}}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function of(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(a))switch(i){case\"id\":e.id=a;break;case\"start\":r(a,{asKey:\"start\",parser:Ke,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:Ke,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Xr(n,e){let[t,r]=af(n.children,e),[i,a]=of(n),o=r.concat(a);return[{children:t,attributes:i},o]}function sf(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=ot(u);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(yt(u.children));break;case\"Period\":{let[f,l]=Xr(u,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=ye(u);a.push(f);break}case\"ContentProtection\":{let[f,l]=st(u);l.length>0&&(s=s.concat(l)),f!==void 0&&o.push(f);break}}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function df(n){let e={},t=[],r=Te(e,t);for(let i of Object.keys(n.attributes)){let a=n.attributes[i];if(!C(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:Ke,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:Ke,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:Ke,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:Ke,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:Ke,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:Ke,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:Ke,dashName:\"maxSubsegmentDuration\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Qs(n,e){let[t,r]=sf(n.children,e),[i,a]=df(n),o=r.concat(a);return[{children:t,attributes:i},o]}function La(n,e){let t=fa(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]=Qs(r,n),o=Qr(i,e,a);return s(o);function s(d){if(d.type===\"done\")return d;if(d.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[d.value.url],format:\"string\",continue(u){if(u.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=d.value.continue(u[0].responseData);return s(f)}}};if(d.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:d.value.xlinksUrls,format:\"string\",continue(u){let f=[];for(let m=0;m<u.length;m++){let{responseData:p,receivedTime:h,sendingTime:b,url:g}=u[m];if(!p.success)throw p.error;let S=\"<root>\"+p.data+\"</root>\",T=fa(S),v=T[T.length-1];if(v===void 0||typeof v==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=v.children,R=[],_=[];for(let k=0;k<E.length;k++){let A=E[k];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[x,B]=Xr(A,S);_.push(...B),R.push(x)}f.push({url:g,receivedTime:h,sendingTime:b,parsed:R,warnings:_})}let l=d.value.continue(f);return s(l)}}};Be(d)}}var $s=La;var uf=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",Xs=uf;function q(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Fa(n){return n===1/0?!0:n===-1/0?!1:n}function Tt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=q(t,e.buffer,a,o))}}function Et(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,d){switch(o){case 16:t.schemeIdUri=q(i,e.buffer,s,d);break;case 13:t.value=q(i,e.buffer,s,d);break;case 14:{let u=q(i,e.buffer,s,d);t.keyId=dn(u.replace(/-/g,\"\"));break}case 15:try{let u=q(i,e.buffer,s,d);r.cencPssh.push(Er(u))}catch(u){}break;case 78:t.ref=q(i,e.buffer,s,d);break;case 79:t.refId=q(i,e.buffer,s,d);break}}}function Zs(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=q(t,e.buffer,a,o);break;case 60:n.language=q(t,e.buffer,a,o);break;case 61:n.contentType=q(t,e.buffer,a,o);break;case 62:n.par=q(t,e.buffer,a,o);break}}}function Js(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=q(t,e.buffer,a,o))}}function We(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=q(t,e.buffer,a,o);break;case 17:n.value=q(t,e.buffer,a,o);break}}}function Qt(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=q(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 ed(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=q(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=q(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 Zr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=ed(a,e);t.pushParsers(i,O,o);break}default:t.pushParsers(i,O,O);break}}}function $t(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let d=a;for(let u=0;u<o/24;u++)n.timeline.push({start:s.getFloat64(d,!0),duration:s.getFloat64(d+8,!0),repeatCount:s.getFloat64(d+16,!0)}),d+=24;break}case 67:n.initialization={media:q(t,e.buffer,a,o)};break;case 28:n.index=q(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=q(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 td(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,O,Tt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=Et(a,e);t.pushParsers(i,O,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,O,We(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Qt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Zr(a,e,t),s=Qt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,$t(a,e));break}default:t.pushParsers(i,O,O);break}}}function nd(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=q(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=q(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=q(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=q(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=q(t,e.buffer,a,o);break;case 2:n.profiles=q(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=q(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 rd(n,e,t){return function(i){switch(i){case 8:{let a={};n.accessibilities===void 0&&(n.accessibilities=[]),n.accessibilities.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=Tt(a,e);t.pushParsers(i,O,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,O,Zs(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=Et(a,e);t.pushParsers(i,O,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=O,s=We(a,e);t.pushParsers(i,o,s);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a);let o=O,s=We(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=td(a.children,e,t),s=nd(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=We(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=We(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Qt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Zr(a,e,t),s=Qt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,$t(a,e));break}case 21:{t.pushParsers(i,O,Js(n,e));break}default:t.pushParsers(i,O,O);break}}}function id(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=q(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=q(t,e.buffer,a,o);break;case 61:n.contentType=q(t,e.buffer,a,o);break;case 62:n.par=q(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=Fa(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Fa(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=q(t,e.buffer,a,o);break;case 4:n.codecs=q(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=q(t,e.buffer,a,o);break;case 2:n.profiles=q(t,e.buffer,a,o);break;case 12:n.segmentProfiles=q(t,e.buffer,a,o);break;case 11:n.mimeType=q(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}}}function ad(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=lf(o,e,r);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function od(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=q(t,e.buffer,a,o);break;case 17:n.value=q(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:{let d={key:\"\",value:\"\"},u=a,f=s.getUint32(u);u+=4,d.key=q(t,e.buffer,u,f),u+=f;let l=s.getUint32(u);u+=4,d.value=q(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[d]:n.namespaces.push(d);break}}}}function lf(n,e,t){let r=new TextDecoder;return function(a,o,s){let d=new DataView(e.buffer);switch(a){case 25:n.presentationTime=d.getFloat64(o,!0);break;case 1:n.duration=d.getFloat64(o,!0);break;case 0:n.id=q(r,e.buffer,o,s);break;case 69:{let u=d.getFloat64(o,!0),f=d.getFloat64(o+8,!0);n.eventStreamData=t.slice(u,f);break}}}}function Jr(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=rd(o.children,e,t),d=id(o.attributes,e);t.pushParsers(a,s,d);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=ad(o.children,e,t,r),d=od(o.attributes,e);t.pushParsers(a,s,d);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,O,$t(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=Et(o,e);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function ei(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=q(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=q(t,e.buffer,a,o);break;case 47:n.xlinkActuate=q(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:\"\"},d=new DataView(e.buffer),u=a,f=d.getUint32(u);u+=4,s.key=q(t,e.buffer,u,f),u+=f;let l=d.getUint32(u);u+=4,s.value=q(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function sd(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Jr(o.children,e,t,r),d=ei(o.attributes,e);t.pushParsers(a,s,d);break}case 3:{let o={};n.utcTimings.push(o);let s=O,d=We(o,e);t.pushParsers(a,s,d);break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=Et(o,e);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function dd(n,e,t){let r,i=new TextDecoder;return function(o,s,d){switch(o){case 0:e.id=q(i,t.buffer,s,d);break;case 2:e.profiles=q(i,t.buffer,s,d);break;case 33:e.type=q(i,t.buffer,s,d);break;case 34:{let u=q(i,t.buffer,s,d);e.availabilityStartTime=new Date(u).getTime()/1e3;break}case 35:{let u=q(i,t.buffer,s,d);e.availabilityEndTime=new Date(u).getTime()/1e3;break}case 36:{let u=q(i,t.buffer,s,d);e.publishTime=new Date(u).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 u=q(i,t.buffer,s,d);n.locations.push(u);break}case 70:{let u={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,l=r.getUint32(f);f+=4,u.key=q(i,t.buffer,f,l),f+=l;let m=r.getUint32(f);f+=4,u.value=q(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[u]:e.namespaces.push(u);break}}}}function za(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=sd(n.mpd.children,e,t,r),s=dd(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,O,O);break}}}function ud(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=Jr(o.children,e,t,r),d=ei(o.attributes,e);t.pushParsers(a,s,d);break}default:t.pushParsers(a,O,O);break}}}var rr=class{constructor(){this._currentNodeId=null,this.childrenParser=O,this.attributeParser=O,this._stack=[{nodeId:null,children:O,attribute:O}]}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=O,this.attributeParser=O,this._stack=[{nodeId:null,children:O,attribute:O}]}};var ff=15e3,ir=class{constructor(){this._parsersStack=new rr,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:u,onCustomEvent:m,onAttribute:l,readNext:p,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 d=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=d.catch(async h=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"dash\",\"Unable to call `instantiateStreaming` on WASM\",h instanceof Error?h:\"\");let b=await s;if(b.status<200||b.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(b.status));let g=await b.arrayBuffer();return WebAssembly.instantiate(g,a)}).then(h=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=h,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(h=>{let b=h instanceof Error?h.toString():\"Unknown error\";throw c.warn(\"dash\",\"Could not create DASH-WASM parser:\",b),this.status=\"failure\",h}),this._initProm;function u(h){return t.childrenParser(h)}function f(h){return t.popIfCurrent(h)}function l(h,b,g){return t.attributeParser(h,b,g)}function m(h,b,g){let S=i._linearMemory,T=new Uint8Array(S.buffer,b,g);if(h===1){let v=r.decode(T);c.warn(\"dash\",\"WASM Error Event:\",v),i._warnings.push(new Error(v))}else if(h===0){let v=r.decode(T);c.warn(\"dash\",\"WASM Log Event:\",v)}}function p(h,b){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let g=i._linearMemory,{mpd:S,cursor:T}=i._mpdData,v=Math.min(b,ff,S.byteLength-T);return new Uint8Array(g.buffer,h,v).set(new Uint8Array(S,T,v)),i._mpdData.cursor+=v,v}}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=Qr(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return Xs&&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=za(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),this._warnings=[];try{this._instance.instance.exports.parse()}catch(d){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,d}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=ud(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),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:d,sendingTime:u,url:f}=r[o];if(!s.success)throw s.error;let[l,m]=this._parseXlink(s.data);i.push({url:f,receivedTime:d,sendingTime:u,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 Be(e)}};var ld=ir;function je(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 d=0;d<e.length;d++){let u=e[d];u[1]===null?s+=u[0]:s+=`${u[0]}=${u[1]}`,d<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function Wa(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-F(),d=!1,m={reject:b=>{var v,E;if(d||i.isCancelled())return;d=!0,i.deregister(h);let g=b,S=(v=g==null?void 0:g.message)!=null?v:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new $e(S,(E=g==null?void 0:g.canRetry)!=null?E:!1,g==null?void 0:g.xhr);o(T)},resolve:b=>{if(d||i.isCancelled())return;d=!0,i.deregister(h);let g=b.receivingTime!==void 0?b.receivingTime-s:void 0,S=b.sendingTime!==void 0?b.sendingTime-s:void 0;a({responseData:b.data,size:b.size,requestDuration:b.duration,url:b.url,receivedTime:g,sendingTime:S})},fallback:()=>{d||i.isCancelled()||(d=!0,i.deregister(h),e(t,r,i).then(a,o))}},p=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},m);i.register(h);function h(b){d||(d=!0,typeof p==\"function\"&&p(),o(b))}})}function mf(n){return function(t,r,i){var s,d;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\"?je(t,r.cmcdPayload.value):t,o=((d=r.cmcdPayload)==null?void 0:d.type)===\"headers\"?r.cmcdPayload.value:void 0;switch(n){case\"arraybuffer\":return he({url:a,headers:o,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return he({url:a,headers:o,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return he({url:a,headers:o,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:Be(n)}}}function qa({customManifestLoader:n},e,t){let r=mf(e),i=typeof n!=\"function\"?r:Wa(n,r);return t!==null?t(i):i}function Va(n,e){if(e){if(Ze(n,1718909296)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Ze(n,1836019574)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Ze(n,1836019558)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Ze(n,1835295092)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function Ye(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 ti(n){return(e,t,r,i,a)=>{return new Promise((s,d)=>{let u=new z(\"Segment integrity checks\"),f=u.linkToSignal(i);u.signal.register(d),n(e,t,r,u.signal,se(J({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(p){l(),u.cancel(\"Integrity check failed\"),d(p)}}})).then(m=>{if(l(),!u.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(p){d(p);return}s(m)}},m=>{l(),d(m)});function l(){u.signal.deregister(d),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||Ye(t.type,t.mimeType)!==\"mp4\"||Va(new Uint8Array(s),t.segment.isInit)}}}function fd(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,d=[\"</\",\"MPD\",\">\"];for(let u=d.length-1;u>=0;u--){let f=d[u];for(;cf(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,d=new DataView(o),u=[[60,47],[77,80,68],[62]];for(let f=u.length-1;f>=0;f--){let l=u[f];for(;pf(d.getUint8(s));)s--;for(let m=l.length-1;m>=0;m--){if(d.getUint8(s)!==l[m])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!C(ee.Document)&&o instanceof ee.Document&&o.documentElement.nodeName!==\"MPD\")throw new Ee(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function cf(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function pf(n){return n===32||n===9||n===13||n===10}function Ga(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,d){var T;let{responseData:u}=i,f=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,m=t!=null?t:f,h={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},b=ke.dashParsers;if(b.wasm===null||b.wasm.status===\"uninitialized\"||b.wasm.status===\"failure\")return c.debug(\"dash\",\"WASM MPD Parser not initialized. Running JS one.\"),g();{let v=bf(u);if(!Sf(v))return c.info(\"dash\",\"MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),g();if(b.wasm.status===\"initialized\"){c.debug(\"dash\",\"Running WASM MPD Parser.\");let E=b.wasm.runWasmParser(v,h);return S(E)}else return c.debug(\"dash\",\"Awaiting WASM initialization before parsing the MPD.\"),b.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(b.wasm===null||b.wasm.status!==\"initialized\")return c.warn(\"dash\",\"WASM MPD parser initialization failed. Running JS parser instead\"),g();c.debug(\"dash\",\"Running WASM MPD Parser.\");let R=b.wasm.runWasmParser(v,h);return S(R)})}function g(){if(b.js!==null){let v=If(u),E=b.js(v,h);return S(E)}else throw new Error(\"No MPD parser is imported\")}function S(v){if(v.type===\"done\")return v.value.warnings.length>0&&o(v.value.warnings),s.isCancelled()?Promise.reject(s.cancellationError):{manifest:new ht(v.value.parsed,n),url:l};let{value:E}=v,R=E.urls.map(_=>d(()=>{let k=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?he({url:_,responseType:\"text\",timeout:k,connectionTimeout:A,cancelSignal:s}):he({url:_,responseType:\"arraybuffer\",timeout:k,connectionTimeout:A,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 K(k,{responseData:{success:!0,data:k.responseData}})}else{if(!(k.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return K(k,{responseData:{success:!0,data:k.responseData}})}},k=>{let A=ce(k,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return K({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:A}})}));return Promise.all(R).then(_=>E.format===\"string\"?(gf(_),S(E.continue(_))):(hf(_),S(E.continue(_))))}}}function gf(n){I.CURRENT_ENV!==I.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 hf(n){I.CURRENT_ENV!==I.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 If(n){if(n instanceof ArrayBuffer)return He(new Uint8Array(n));if(typeof n==\"string\")return n;if(!C(ee.Document)&&n instanceof ee.Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function bf(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return sn(n).buffer;if(!C(ee.Document)&&n instanceof ee.Document)return sn(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Sf(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 qe([n,e]){return e===1/0?`bytes=${n}-`:`bytes=${n}-${e}`}function Nt(n,e){return n===null?null:e.url===null?n.baseUrl:Ln(n.baseUrl,e.url)}function ar(n,e,t,r,i){var u,f;let a=n;((u=t.cmcdPayload)==null?void 0:u.type)===\"query\"&&(a=je(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 he({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 he({url:a,headers:se(J({},o),{Range:qe(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 he({url:a,headers:se(J({},o),{Range:qe([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=he({url:a,headers:se(J({},o),{Range:qe(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),d=he({url:a,headers:se(J({},o),{Range:qe(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,d]).then(([l,m])=>{let p=At(new Uint8Array(l.responseData),new Uint8Array(m.responseData)),h=Math.min(l.sendingTime,m.sendingTime),b=Math.max(l.receivedTime,m.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:p,size:l.size+m.size,requestDuration:b-h,sendingTime:h,receivedTime:b}}})}async function or(n,e,t,r){let i=null;function a(s){let d=new Uint8Array(s.chunk),u=i!==null?At(i,d):d,f=_r(u),l=f[0];i=f[1],!(l!==null&&(l.forEach(m=>{t.onNewChunk(m)}),r.isCancelled()))&&(t.onProgress({duration:s.duration,size:s.size,totalSize:s.totalSize}),r.isCancelled())}return{resultType:\"chunk-complete\",resultData:await pr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function md(n,e,t,r,i,a){var m,p;if(e.segment.isInit)return ar(n,e.segment,r,a,i);let o=((m=r.cmcdPayload)==null?void 0:m.type)===\"query\"?je(n,r.cmcdPayload.value):n,s=((p=r.cmcdPayload)==null?void 0:p.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:d}=e,u;d.range!==void 0?u=se(J({},s),{Range:qe(d.range)}):s!==void 0&&(u=s);let f=Ye(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(nn())return or(o,{headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);nt(\"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 he({url:o,responseType:\"arraybuffer\",headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function Ha({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:ti(r);function r(i,a,o,s,d){let u=Nt(i,a.segment);return u===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?md(u,a,n,o,d,s):new Promise((f,l)=>{let m=!1,S={reject:_=>{var B,D;if(m||s.isCancelled())return;m=!0,s.deregister(R);let k=_,A=(B=k==null?void 0:k.message)!=null?B:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",x=new $e(A,(D=k==null?void 0:k.canRetry)!=null?D:!1,k==null?void 0:k.xhr);l(x)},resolve:_=>{if(m||s.isCancelled())return;m=!0,s.deregister(R);let k;_.data instanceof Uint8Array?_.data.buffer instanceof ArrayBuffer?k=_.data:k=_.data.slice():k=_.data,f({resultType:\"segment-loaded\",resultData:{responseData:k,size:_.size,requestDuration:_.duration}})},progress:_=>{m||s.isCancelled()||d.onProgress({duration:_.duration,size:_.size,totalSize:_.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(R),md(u,a,n,o,d,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 v={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:u,cmcdPayload:o.cmcdPayload},E=e(v,S);s.register(R);function R(_){m||(m=!0,typeof E==\"function\"&&E(),l(_))}})}}var ja=408125543,cd=357149030,yf=2807729,Tf=17545,Ef=475249515,_f=187,Rf=179,Pf=183,vf=241;function _t(n,e,t,[r,i]){let a=r;for(;a<i;){let o=Af(t,a);if(o===null)return null;let{value:s,length:d}=o,u=a+d,f=xf(t,u);if(f===null)return null;let{length:l,value:m}=f,p=u+l,h=p+m;if(s===n)return[p,h];if(e.length>0){for(let b=0;b<e.length;b++)if(s===e[b]){let g=e.slice(b+1,e.length);return _t(n,g,t,[p,h])}}a=h}return null}function ni(n,e){let t=_t(yf,[ja,cd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/Ka(n,t[0],r)}function Cf(n,e){let t=_t(Tf,[ja,cd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?kf(n,t[0]):r===8?Mf(n,t[0]):null}function Ya(n,e){let t=_t(ja,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=ni(n,r);if(a===null)return null;let o=Cf(n,r);if(o===null)return null;let s=_t(Ef,[],n,[r,i]);if(s===null)return null;let d=[],u=s[0];for(;u<s[1];){let l=_t(_f,[],n,[u,s[1]]);if(l===null)break;let m=_t(Rf,[],n,[l[0],l[1]]);if(m===null)return null;let p=Ka(n,m[0],m[1]-m[0]),h=_t(vf,[Pf],n,[l[0],l[1]]);if(h===null)return null;let b=Ka(n,h[0],h[1]-h[0])+r;d.push({time:p,rangeStart:b}),u=l[1]}let f=[];for(let l=0;l<d.length;l++){let m=d[l];l===d.length-1?f.push({time:m.time,timescale:a,duration:l===0?o:o-m.time,range:[m.rangeStart,1/0]}):f.push({time:m.time,timescale:a,duration:d[l+1].time-m.time,range:[m.rangeStart,d[l+1].rangeStart-1]})}return f}function pd(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function Af(n,e){let t=pd(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 xf(n,e){let t=pd(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 kf(n,e){return new DataView(n.buffer).getFloat32(e)}function Mf(n,e){return new DataView(n.buffer).getFloat64(e)}function Ka(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 sr(n,e,t,r){let i=Ti(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=Ei(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,d=t.duration*r,u=Math.min(r*.9,d/4);return o!==void 0&&Math.abs(o-d)<=u&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function Of(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=He(o),d=Date.parse(s);if(a===void 0||d===void 0||isNaN(d)||d>=a)return!0}return!1}function Qa(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:Of(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function $a({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var v,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:d,isChunked:u}=t,f=[o,s];if(d===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=ko(d),m=Ye(r.type,r.mimeType),p=m===\"mp4\"||m===void 0,h=[];if(p){let R=Rr(l),_;a.isInit&&(_=(v=No(l))!=null?v:void 0),(R.length>0||_!==void 0)&&h.push({initDataType:\"cenc\",keyId:_,initData:R})}if(!a.isInit){let R=p?sr(l,u,a,i):null,_=(E=a.timestampOffset)!=null?E:0;if(p){let k=Bo(l);if(k!==void 0){let A=k.filter(B=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(B)),x=Qa(A,r.manifestPublishTime);if(x!==void 0){let{needsManifestRefresh:B,inbandEvents:D}=x;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:R,chunkOffset:_,appendWindow:f,inbandEvents:D,protectionData:h,needsManifestRefresh:B}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:R,chunkOffset:_,protectionData:h,appendWindow:f}}let{indexRange:b}=a,g;if(m===\"webm\")g=Ya(l,0);else if(p&&(g=fn(l,Array.isArray(b)?b[0]:0),n===!0&&g!==null&&g.length>0)){let R=g[g.length-1];Array.isArray(R.range)&&(R.range[1]=1/0)}let S;p?S=mn(l):m===\"webm\"&&(S=ni(l,0));let T=C(S)?void 0:S;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:h,initTimescale:T,segmentList:g!=null?g:void 0}}}function Xa({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:ti(t);async function t(r,i,a,o,s){var g,S;let{segment:d}=i,u=Nt(r,d);if(u===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(d.isInit)return ar(u,d,a,o,s);let f=((g=a.cmcdPayload)==null?void 0:g.type)===\"query\"?je(u,a.cmcdPayload.value):u,l=((S=a.cmcdPayload)==null?void 0:S.type)===\"headers\"?a.cmcdPayload.value:void 0,m;d.range!==void 0?m=se(J({},l),{Range:qe(d.range)}):l!==void 0&&(m=l);let p=Ye(i.type,i.mimeType),h=p===\"mp4\"||p===void 0;if(n&&h){if(nn())return or(f,{headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);nt(\"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 b;return h?b=await he({url:f,responseType:\"arraybuffer\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):b=await he({url:f,responseType:\"text\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:b}}}function wf(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml\":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 Df(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 gd({segment:n,language:e,codecs:t},r,i,a,o){if(n.isInit)return null;let s,d;a===null?o?(s=n.time,d=n.end):c.warn(\"utils\",\"Unavailable time data for current text track.\"):(s=a.time,a.duration!==void 0?d=s+a.duration:!o&&n.complete&&(d=s+n.duration));let u=wf(t),f=Si(r),l=f!==null?He(f):\"\";return t===\"wvtt\"&&!Oe(l,\"WEBVTT\")&&!Oe(l,\"\\xFE\\xFFWEBVTT\")?{data:r,type:\"mp4vtt\",language:e,start:s,end:d,initTimescale:i!=null?i:null}:{data:l,type:u,language:e,start:s,end:d,initTimescale:i!=null?i:null}}function hd(n,e,t,r){let{segment:i}=n;if(i.isInit)return null;let a,o;r?c.warn(\"utils\",\"Unavailable time data for current text track.\"):(a=i.time,i.complete&&(o=i.time+i.duration));let s=Df(n.codecs,n.mimeType);return{data:e,type:s,language:n.language,start:a,end:o,initTimescale:t!=null?t:null}}function Bf(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,d;if(typeof n==\"string\"?d=sn(n):n instanceof Uint8Array?d=n:d=new Uint8Array(n),o){let p=fn(d,Array.isArray(s)?s[0]:0);if(i===!0&&p!==null&&p.length>0){let b=p[p.length-1];Array.isArray(b.range)&&(b.range[1]=1/0)}let h=mn(d);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:h,segmentList:p!=null?p:void 0}}let u=sr(d,e,a,r),f=gd(t,d,r,u,e),l=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:f,chunkSize:d.length,chunkInfos:u,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Nf(n,e,t,r){let{periodStart:i,periodEnd:a,segment:o}=r,{timestampOffset:s=0}=o;if(o.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let d,u;if(typeof n!=\"string\"){let l=n instanceof Uint8Array?n:new Uint8Array(n);d=He(l),u=l.length}else d=n;return{segmentType:\"media\",chunkData:hd(r,d,e,t),chunkSize:u,chunkInfos:null,chunkOffset:s,protectionData:[],appendWindow:[i,a]}}function Za({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:d,isChunked:u}=t;if(d===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=Ye(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?Bf(d,u,r,i,n):Nf(d,i,u,r)}}async function Id(n,e,t,r){var d,u;let i=Nt(n,e);if(i===null)return Promise.reject(new Error(\"Cannot load thumbnail: no URL\"));let a=((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"?je(i,t.cmcdPayload.value):i,o=((u=t.cmcdPayload)==null?void 0:u.type)===\"headers\"?t.cmcdPayload.value:void 0,s;return e.range!==void 0?s=se(J({},o),{Range:qe(e.range)}):o!==void 0&&(s=o),rn({url:a,responseType:\"arraybuffer\",headers:s,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r})}function bd(n,e){var u;let{thumbnailTrack:t,thumbnail:r}=e,i=t.height/t.verticalTiles,a=t.width/t.horizontalTiles,o=[],s=(u=t.tileDuration)!=null?u:(r.end-r.time)/(t.horizontalTiles*t.verticalTiles),d=r.time;for(let f=0;f<t.verticalTiles;f++)for(let l=0;l<t.horizontalTiles;l++)o.push({start:d,end:d+s,offsetX:Math.round(l*a),offsetY:Math.round(f*i),height:Math.floor(i),width:Math.floor(a)}),d+=s;return{mimeType:t.mimeType,data:n,thumbnails:o}}function Sd(n){let e=qa({customManifestLoader:n.manifestLoader},Uf()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?fd:null),t=Ga(n),r=Ha(n),i=$a(n),a=Xa(n),o=Za(n);return{transportName:\"dash\",manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o},thumbnails:{loadThumbnail:Id,parseThumbnail:bd}}}function Uf(){return ke.dashParsers.wasm!==null&&(ke.dashParsers.wasm.status===\"initialized\"||ke.dashParsers.wasm.status===\"initializing\")}var yd=Sd;function Ja(n){let e=new ld;ke.dashParsers.wasm=e,ke.dashParsers.js=$s,ke.transports.dash=yd,ee.onmessageerror=t=>{zr.error(\"Core\",\"Error when receiving message from main thread.\")},Ms(t=>{onmessage=t},Lf,n)}function Lf(n,e){Ff(n),n.type!==\"log\"&&zr.debug(\"M<--C\",\"Sending message from worker\",{name:n.type}),e===void 0?postMessage(n):postMessage(n,e)}function Ff(n){(n.type===\"manifest-ready\"||n.type===\"manifest-update\")&&(n.value.manifest instanceof ht?(n.value.manifest=n.value.manifest.getMetadataSnapshot(),n.type===\"manifest-update\"&&(n.value.manifest.periods=[])):zr.warn(\"Core\",\"the Manifest instance should be communicated to `sendMessage`.\"))}Ja({representationFilters:new Map,segmentLoaders:new Map,manifestLoaders:new Map});})();\n" + "})()"], { type: "application/javascript" });
4
+ var blob = new Blob(["(function(){" + "\"use strict\";(()=>{var Rd=Object.defineProperty,Pd=Object.defineProperties;var vd=Object.getOwnPropertyDescriptors;var eo=Object.getOwnPropertySymbols;var Cd=Object.prototype.hasOwnProperty,Ad=Object.prototype.propertyIsEnumerable;var to=(n,e,t)=>e in n?Rd(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,J=(n,e)=>{for(var t in e||(e={}))Cd.call(e,t)&&to(n,t,e[t]);if(eo)for(var t of eo(e))Ad.call(e,t)&&to(n,t,e[t]);return n},se=(n,e)=>Pd(n,vd(e));var I={PRODUCTION:0,DEV:1,CURRENT_ENV:0};var no={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_AUDIO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",DEFAULT_VIDEO_TRACKS_NOT_PLAYABLE_BEHAVIOR:\"error\",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,FREEZING_FLUSH_FAILURE_DELAY:{MAXIMUM:2e4,MINIMUM:4e3,POSITION_DELTA:1},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\"','audio/mp4;codecs=\"ec-3\"'],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\",DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:1,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:1e4,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:7e3,FORCE_CANNOT_RELY_ON_REQUEST_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_CANNOT_REUSE_MEDIA_KEYS:!1,FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:!1,FORCE_IS_SEEKING_APPROXIMATE:!1,FORCE_MEDIA_ELEMENT_FAIL_ON_UNDECIPHERABLE_DATA:!1,FORCE_SHOULD_AWAIT_SET_MEDIA_KEYS:!1,FORCE_SHOULD_FAVOUR_CUSTOM_SAFARI_EME:!1,FORCE_SHOULD_RELOAD_MEDIA_SOURCE_ON_DECIPHERABILITY_UPDATE:!1,FORCE_SHOULD_RENEW_MEDIA_KEY_SYSTEM_ACCESS:!1,FORCE_SHOULD_UNSET_MEDIA_KEYS:!1,FORCE_SHOULD_VALIDATE_METADATA:!1,FORCE_DONT_WAIT_FOR_DATA_BEFORE_LOADED:!1,FORCE_WAIT_FOR_HAVE_ENOUGH_DATA:!1,FORCE_INITIAL_SEEK_TO_ZERO:!1},ro=no;function kd(n,...e){if(n==null)throw new TypeError(\"Cannot convert undefined or null to object\");let t=Object(n);for(let r of e)for(let i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i]);return t}var K=typeof Object.assign==\"function\"?Object.assign:kd;function ii(n){return n!=null&&!Array.isArray(n)&&typeof n==\"object\"}function en(n,...e){if(e.length===0)return n;let t=e.shift();if(ii(n)&&ii(t))for(let r in t)if(ii(t[r])){let i=n[r];i===void 0&&(i={},n[r]=i),en(i,t[r])}else K(n,{[r]:t[r]});return en(n,...e)}function v(n){return n==null}function O(){}var fe=class{constructor(){this._listeners={}}addEventListener(e,t,r){let i=O;if(r!==void 0){if(r.isCancelled())return;i=r.register(()=>this.removeEventListener(e,t))}let a=this._listeners[e];Array.isArray(a)?a.push({cb:t,onRemove:i}):this._listeners[e]=[{cb:t,onRemove:i}]}removeEventListener(e,t){if(v(e)){for(let i of Object.keys(this._listeners)){let a=this._listeners[i];Array.isArray(a)&&a.forEach(o=>o.onRemove())}this._listeners={};return}let r=this._listeners[e];if(Array.isArray(r)){if(v(t)){r.forEach(i=>i.onRemove()),delete this._listeners[e];return}for(let i=0;i<r.length;i++)if(r[i].cb===t){r[i].onRemove(),r.splice(i,1);break}r.length===0&&delete this._listeners[e]}}trigger(e,t){let r=this._listeners[e];Array.isArray(r)&&r.slice().forEach(i=>{try{i.cb(t)}catch(a){if(I.CURRENT_ENV===I.DEV)throw a instanceof Error?a:new Error(\"EventEmitter: listener error\");console.error(\"RxPlayer: EventEmitter error\",a instanceof Error?a:null)}})}};var ai=class extends fe{constructor(){super(...arguments);this.updated=!1;this._config=ro}update(t){let r=en(this._config,t);this._config=r,this.updated=!0,this.trigger(\"update\",t)}getCurrent(){return this._config}},Md=new ai,L=Md;var $e=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 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 lr=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){I.CURRENT_ENV===I.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.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.emitCurrentValue===!0&&e(this._value,r),this._isFinished||i.hasBeenCleared){r();return}t.clearSignal.register(r)}waitUntilDefined(e,t){this.onUpdate((r,i)=>{r!==void 0&&(i(),e(this._value))},{clearSignal:t.clearSignal,emitCurrentValue:!0})}_onFinished(e,t){if(t.isCancelled())return O;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 tn(n,e,t){let r=new lr(e(n.getValue()),t);return n.onUpdate(function(a){r.setValue(e(a))},{clearSignal:t}),n._onFinished(()=>{r.finish()},t),r}var X=lr;var oi=new X(0);function io({date:n,timestamp:e}){let t=n-e,r=typeof performance!=\"undefined\"?Date.now()-performance.now():0;oi.setValueIfChanged(r-t)}var Od=typeof performance!=\"undefined\"?()=>performance.now()+oi.getValue():()=>Date.now()+oi.getValue(),F=Od;var wd=\"NONE\",Rt=class extends fe{constructor(){super(),this.error=O,this.warn=O,this.info=O,this.debug=O,this._levels={NONE:0,ERROR:1,WARNING:2,INFO:3,DEBUG:4},this._currentFormat=\"standard\",this._currentLevel=wd}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 d=F();console.log(String(d.toFixed(2)),\"[Init]\",`Local-Date: ${Date.now()}`)}this._currentFormat=o;let s=this._currentFormat===\"full\"?(d,u)=>(f,...l)=>{let m=F();return u(String(m.toFixed(2)),`[${d}]`,f+\":\",...l.map(p=>typeof p==\"object\"&&p!==null&&!(p instanceof Error)?ao(p):p))}:(d,u)=>(f,...l)=>u(f+\":\",...l.map(m=>typeof m==\"object\"&&m!==null&&!(m instanceof Error)?ao(m):m));if(r===void 0)this.error=i>=this._levels.ERROR?s(\"error\",console.error.bind(console)):O,this.warn=i>=this._levels.WARNING?s(\"warn\",console.warn.bind(console)):O,this.info=i>=this._levels.INFO?s(\"info\",console.info.bind(console)):O,this.debug=i>=this._levels.DEBUG?s(\"log\",console.log.bind(console)):O;else{let d=u=>i>=this._levels[u]?(f,...l)=>r(u,f,l):O;this.error=d(\"ERROR\"),this.warn=d(\"WARNING\"),this.info=d(\"INFO\"),this.debug=d(\"DEBUG\")}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]}};function ao(n){let e=\"\";for(let t in n)if(Object.prototype.hasOwnProperty.call(n,t)){e.length>0&&(e+=\" \");let r=n[t];r instanceof Error?e+=`${t}=\"${JSON.stringify(r==null?void 0:r.toString())}\"`:e+=`${t}=${typeof r==\"string\"?`${JSON.stringify(r)}`:String(r)}`}return e}var Dd=new Rt,c=Dd;var fr=typeof WorkerGlobalScope!=\"undefined\"&&self instanceof WorkerGlobalScope;var Bd=typeof window==\"undefined\"&&!fr,mr=Bd;var cr;fr?cr=self:mr?cr=global:cr=window;var ee=cr;var de=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}}},Re={TIMEOUT:\"TIMEOUT\",ERROR_EVENT:\"ERROR_EVENT\",ERROR_HTTP_CODE:\"ERROR_HTTP_CODE\",PARSE_ERROR:\"PARSE_ERROR\"};var si=typeof Headers==\"function\"?Headers:null,pr=typeof AbortController==\"function\"?AbortController:null;function gr(n){var m,p;let e;if(!v(n.headers))if(v(si))e=n.headers;else{e=new si;let h=Object.keys(n.headers);for(let b=0;b<h.length;b++){let g=h[b];e.append(g,n.headers[g])}}c.debug(\"utils\",\"Fetch\",{url:n.url});let t=null,r=!1,i=!1,a=F(),o=v(pr)?null:new pr;function s(){if(v(o)){c.warn(\"utils\",\"Fetch: AbortController API not available.\");return}o.abort()}let d;n.timeout!==void 0&&(d=setTimeout(()=>{r=!0,u!==void 0&&clearTimeout(u),s()},n.timeout));let u;n.connectionTimeout!==void 0&&(u=setTimeout(()=>{i=!0,d!==void 0&&clearTimeout(d),s()},n.connectionTimeout));let f=n.cancelSignal.register(function(b){t=b,s()}),l={method:\"GET\"};if(e!==void 0&&(l.headers=e),l.signal=v(o)?null:o.signal,c.hasLevel(\"DEBUG\")){let h=\"fetch GET \"+n.url;n.timeout!==void 0&&(h+=\" to=\"+String(n.timeout/1e3)),n.connectionTimeout!==void 0&&(h+=\" cto=\"+String(n.connectionTimeout/1e3)),((m=n.headers)==null?void 0:m.Range)!==void 0&&(h+=\" Range=\"+((p=n.headers)==null?void 0:p.Range)),c.debug(\"utils\",h)}return fetch(n.url,l).then(h=>{if(u!==void 0&&clearTimeout(u),h.status>=300)throw c.warn(\"utils\",\"Fetch: Request HTTP Error\",{status:h.status,responseUrl:h.url}),new de(h.url,h.status,Re.ERROR_HTTP_CODE);if(v(h.body))throw new de(h.url,h.status,Re.PARSE_ERROR);let b=h.headers.get(\"Content-Length\"),g=!v(b)&&!isNaN(+b)?+b:void 0,y=h.body.getReader(),T=0;return R();async function R(){let E=await y.read();if(!E.done&&!v(E.value)){T+=E.value.byteLength;let C=F(),P={url:h.url,currentTime:C,duration:C-a,sendingTime:a,chunkSize:E.value.byteLength,chunk:E.value.buffer,size:T,totalSize:g};return n.onData(P),R()}else if(E.done){d!==void 0&&clearTimeout(d),f();let C=F();return{requestDuration:C-a,receivedTime:C,sendingTime:a,size:T,status:h.status,url:h.url}}return R()}}).catch(h=>{throw t!==null?t:(f(),r?(c.warn(\"utils\",\"Fetch: Request timed out.\",{url:n.url,timeout:n.timeout}),new de(n.url,0,Re.TIMEOUT)):i?(c.warn(\"utils\",\"Fetch: Request connection timed out.\",{url:n.url,connectionTimeout:n.connectionTimeout}),new de(n.url,0,Re.TIMEOUT)):h instanceof de?h:(c.warn(\"utils\",\"Fetch: Request Error\",{error:h instanceof Error?h.toString():\"Unkwown Error\"}),new de(n.url,0,Re.ERROR_EVENT)))})}function nn(){let n=/\\[\\s*native\\s+code\\s*\\]/;return typeof ee.fetch==\"function\"&&!v(pr)&&n.test(pr.toString())&&!v(si)}function Q(n){return typeof n==\"string\"&&n.length>0}var Nd=\"json\";function rn(n){let e={url:n.url,headers:n.headers,responseType:v(n.responseType)?Nd:n.responseType,timeout:n.timeout,connectionTimeout:n.connectionTimeout};return new Promise((t,r)=>{let{onProgress:i,cancelSignal:a}=n,{url:o,headers:s,responseType:d,timeout:u,connectionTimeout:f}=e,l=new XMLHttpRequest;l.open(\"GET\",o,!0);let m;u!==void 0&&(l.timeout=u,m=setTimeout(()=>{g(),r(new de(o,l.status,Re.TIMEOUT))},u+3e3));let p;if(f!==void 0&&(p=setTimeout(()=>{g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(new de(o,l.status,Re.TIMEOUT))},f)),l.responseType=d,l.responseType===\"document\"&&l.overrideMimeType(\"text/xml\"),!v(s)){let y=s;for(let T in y)Object.prototype.hasOwnProperty.call(y,T)&&l.setRequestHeader(T,y[T])}let h=F(),b=null;if(a!==void 0&&(b=a.register(function(T){g(),l.readyState!==XMLHttpRequest.DONE&&l.abort(),r(T)}),a.isCancelled()))return;if(l.onerror=function(){g(),r(new de(o,l.status,Re.ERROR_EVENT))},l.ontimeout=function(){g(),r(new de(o,l.status,Re.TIMEOUT))},f!==void 0&&(l.onreadystatechange=function(){l.readyState>=XMLHttpRequest.HEADERS_RECEIVED&&clearTimeout(p)}),i!==void 0&&(l.onprogress=function(T){let R=F();i({url:o,duration:R-h,sendingTime:h,currentTime:R,size:T.loaded,totalSize:T.total})}),l.onload=function(T){if(l.readyState===XMLHttpRequest.DONE)if(g(),l.status>=200&&l.status<300){let R=F(),E=l.response instanceof ArrayBuffer?l.response.byteLength:T.total,C=l.status,P=l.responseType,x=Q(l.responseURL)?l.responseURL:o,A;if(P===\"json\"?A=typeof l.response==\"object\"?l.response:Ud(l.responseText):A=l.response,v(A)){r(new de(o,l.status,Re.PARSE_ERROR));return}t({status:C,url:x,responseType:P,sendingTime:h,receivedTime:R,requestDuration:R-h,size:E,responseData:A})}else r(new de(o,l.status,Re.ERROR_HTTP_CODE))},c.hasLevel(\"DEBUG\")){let y=\"XHR GET \"+o;n.responseType!==void 0&&(y+=\" type=\"+n.responseType),u!==void 0&&(y+=\" to=\"+String(u/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)),c.debug(\"utils\",y)}l.send();function g(){m!==void 0&&clearTimeout(m),p!==void 0&&clearTimeout(p),b!==null&&b()}})}function Ud(n){try{return JSON.parse(n)}catch(e){return null}}var he=rn;var Pt=Re,Ve={NETWORK_ERROR:\"NETWORK_ERROR\",MEDIA_ERROR:\"MEDIA_ERROR\",ENCRYPTED_MEDIA_ERROR:\"ENCRYPTED_MEDIA_ERROR\",OTHER_ERROR:\"OTHER_ERROR\"};function et(n,e){return`${n}: ${e}`}var an=class n extends Error{constructor(e,t,r){super(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"EncryptedMediaError\",this.type=Ve.ENCRYPTED_MEDIA_ERROR,this.code=e,this._originalMessage=t,this.fatal=!1,this.keyStatuses=r.keyStatuses,this.keySystemConfiguration=r.keySystemConfiguration,this.keySystem=r.keySystem}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,keyStatuses:this.keyStatuses,keySystemConfiguration:this.keySystemConfiguration,keySystem:this.keySystem}}};var Z=class n extends Error{constructor(e,t,r){super(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"MediaError\",this.type=Ve.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{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage,tracks:this.tracksInfo}}};var Xe=class n extends Error{constructor(e,t){super(et(e,t.message)),Object.setPrototypeOf(this,n.prototype),this.name=\"NetworkError\",this.type=Ve.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===Pt.ERROR_HTTP_CODE&&this.status===e}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,baseError:this._baseError.serialize()}}};var Ee=class n extends Error{constructor(e,t){super(et(e,t)),Object.setPrototypeOf(this,n.prototype),this.name=\"OtherError\",this.type=Ve.OTHER_ERROR,this.code=e,this.fatal=!1,this._originalMessage=t}serialize(){return{isSerializedError:!0,name:this.name,code:this.code,reason:this._originalMessage}}};function Ut(n){return(n instanceof an||n instanceof Z||n instanceof Ee||n instanceof Xe)&&Object.keys(Ve).indexOf(n.type)>=0}function pe(n,{defaultCode:e,defaultReason:t}){if(Ut(n))return n;let r=n instanceof Error?n.toString():t;return new Ee(e,r)}var xe=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 Ld={dashParsers:{wasm:null,js:null},createDebugElement:null,directfile:null,decrypt:null,htmlTextDisplayer:null,htmlTextTracksParsers:{},monothread:null,multithread:null,nativeTextDisplayer:null,nativeTextTracksParsers:{},transports:{}},oo=Ld;var ke=oo;function j(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 Fd={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\"},so=Fd;var zd={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\"},uo=zd;function qd(n){if(v(n)||n===\"\")return\"und\";let t=(\"\"+n).toLowerCase().split(\"-\")[0],r=Wd(t);return Q(r)?r:n}function Wd(n){let e;switch(n.length){case 2:e=so[n];break;case 3:e=uo[n];break}return e}var lo=qd;var fo=lo;function hr(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 Me(){let n=\"\",e=-1;return function(){return e++,e>=Number.MAX_SAFE_INTEGER&&(n+=\"0\",e=0),n+String(e)}}var Ir=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"AssertionError\"}};function Ie(n,e){if(I.DEV===I.CURRENT_ENV&&!n)throw new Ir(e===void 0?\"invalid assertion\":e)}function Be(n){throw new Ir(\"Unreachable path taken\")}var Vd=typeof ee==\"object\"&&typeof ee.TextDecoder==\"function\",Gd=typeof ee==\"object\"&&typeof ee.TextEncoder==\"function\";function on(n){if(Gd)try{return new TextEncoder().encode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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 d=parseInt(t.substring(o+1,o+6),16);e+=String.fromCharCode(d),s=!0,o+=5}else if(o<=a-3&&i.test(t[o+1])&&i.test(t[o+2])){let d=parseInt(t.substring(o+1,o+3),16);e+=String.fromCharCode(d),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 Hd(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 mo(n,e){let t=n.toString(16);return t.length>=e?t:new Array(e-t.length+1).join(\"0\")+t}function Ge(n){if(Vd)try{return new TextDecoder().decode(n)}catch(i){let a=i instanceof Error?i:\"Unknown Error\";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=Hd(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\"+mo(o,4):\"%\"+mo(o,2)}}return decodeURIComponent(r)}function sn(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 br(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 di(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:Ge(r)}}function ui(n){return Object.keys(n).map(e=>n[e])}var yr=typeof Object.values==\"function\"?Object.values:ui;var Lt=[\"audio\",\"video\",\"text\"];function po(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=F()-t.time;r=t.maximumSafePosition+s/1e3}let i=r-e.timeshiftDepth;return Math.max((o=e.minimumSafePosition)!=null?o:0,i)}function go(n){let{maximumTimeData:e}=n.timeBounds;if(!n.isLive||e.livePosition===void 0)return;if(!e.isLinear)return e.livePosition;let t=F()-e.time;return e.livePosition+t/1e3}function ho(n){let{maximumTimeData:e}=n.timeBounds;if(!e.isLinear)return e.maximumSafePosition;let t=F()-e.time;return e.maximumSafePosition+t/1e3}function Io(n,e){if(e===void 0)return fi(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 bo(n,e){let t=null;for(let r=n.periods.length-1;r>=0;r--){let i=n.periods[r];if(li(i,e,t))return i;t=i}}function yo(n,e){let t=e.end;if(t===void 0)return null;let r=j(n.periods,i=>i.end===void 0||t<i.end);return r===void 0?null:r}function li(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 fi(n){let e=n.adaptations;return ui(e).reduce((t,r)=>v(r)?t:t.concat(r),[])}function Kd(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=>dn(a)===!0):n.representations).map(Qd),label:n.label};return n.isDub===!0&&(t.dub=!0),t}function jd(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 Yd(n,e){let t=n.trickModeTracks!==void 0?n.trickModeTracks.map(i=>{let a=(e?i.representations.filter(s=>dn(s)===!0):i.representations).map(co),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=>dn(i)===!0):n.representations).map(co),label:n.label};return n.isSignInterpreted===!0&&(r.signInterpreted=!0),n.isTrickModeTrack===!0&&(r.isTrickModeTrack=!0),t!==void 0&&(r.trickModeTracks=t),r}function Qd(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 co(n){let{id:e,bitrate:t,frameRate:r,width:i,height:a,codecs:o,hdrInfo:s,isSupported:d,decipherable:u,contentProtections:f}=n;return{id:e,bitrate:t,frameRate:r,width:i,height:a,codec:o==null?void 0:o[0],hdrInfo:s,isCodecSupported:d,decipherable:u,contentProtections:f!==void 0?{keyIds:f.keyIds}:void 0}}function vt(n){switch(n.type){case\"audio\":return{type:\"audio\",track:Kd(n,!1)};case\"video\":return{type:\"video\",track:Yd(n,!1)};case\"text\":return{type:\"text\",track:jd(n)}}}function dn(n){return n.decipherable===!1?!1:n.isSupported}function So(n){return new Function(`return (${n}(arguments[0], arguments[1]))`)}var $d=Me(),mi=class{constructor(e,t,r){var a,o,s,d,u;this.id=e.id,this.uniqueId=$d(),this.shouldBeAvoided=!1,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((d=this.mimeType)!=null?d:\"\",(u=e.codecs)!=null?u:\"\",i)))}else e.codecs!==void 0&&this.codecs.push(e.codecs),this.isSupported=!0}refreshCodecSupport(e){var s,d;if(this.isSupported!==void 0)return;let t=this.contentProtections!==void 0,r=!1,i=(s=this.mimeType)!=null?s:\"\",a=(d=this.codecs)!=null?d:[];a.length===0&&(a=[\"\"]);let o=!1;for(let u of a){if(r=e.isSupported(i,u,t),r===!0){this.codecs=[u];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;let t=this.getAllEncryptionData(),r=[];for(let a=0;a<t.length;a++){let o=!1,s=t[a];for(let d=0;d<s.values.length;d++)if(s.values[d].systemId.toLowerCase()===e.toLowerCase())if(o)r[r.length-1].values.push(s.values[d]);else{let u=(i=this.contentProtections)==null?void 0:i.keyIds;r.push({type:s.type,keyIds:u,values:[s.values[d]]}),o=!0}}return r}getAllEncryptionData(){var t;if(this.contentProtections===void 0||this.contentProtections.initData.length===0)return[];let e=(t=this.contentProtections)==null?void 0:t.keyIds;return this.contentProtections.initData.map(r=>({type:r.type,keyIds:e,values:r.values}))}addProtectionData(e,t,r){let i=!1;if(this.contentProtections===void 0)return this.contentProtections={keyIds:t!==void 0?[t]:[],initData:[{type:e,values:r}]},!0;if(t!==void 0){let o=this.contentProtections.keyIds;if(o===void 0)this.contentProtections.keyIds=[t];else{let s=!1;for(let d of o)hr(d,t)&&(s=!0);s||(c.warn(\"manifest\",\"found unanounced key id.\",{keyId:br(t)}),o.push(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 d=0;d<r.length;d++){let u=r[d],f;for(f=0;f<s.length;f++)if(u.systemId===s[f].systemId){if(hr(u.data,s[f].data))break;c.warn(\"manifest\",\"different init data for the same system ID\",{systemId:u.systemId})}f===s.length&&(s.push(u),i=!0)}return i}return this.contentProtections.initData.push({type:e,values:r}),!0}isPlayable(){return dn(this)}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,isCodecSupportedInWebWorker:this.isCodecSupportedInWebWorker}}},un=mi;var ft=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=fo(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(u=>new n(u,t)));let s=e.representations,d=[];this.supportStatus={hasSupportedCodec:!1,hasCodecWithUndefinedSupport:!1,isDecipherable:!1};for(let u=0;u<s.length;u++){let f=new un(s[u],this.type,t),l=!0;if(!v(a)){let m={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&&(m.contentProtections={},f.contentProtections.keyIds!==void 0)){let p=f.contentProtections.keyIds;m.contentProtections.keyIds=p}l=a(m,{trackType:this.type,language:this.language,normalizedLanguage:this.normalizedLanguage,isClosedCaption:this.isClosedCaption,isDub:this.isDub,isAudioDescription:this.isAudioDescription,isSignInterpreted:this.isSignInterpreted})}l?(d.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)):c.debug(\"manifest\",\"Filtering Representation due to representationFilter\",this.type,`Adaptation: ${this.id}`,`Representation: ${f.id}`,`(${f.bitrate})`)}d.sort((u,f)=>u.bitrate-f.bitrate),this.representations=d,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 j(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 be=ee,To,Eo,_o,Ro,Po,mt=(Po=(Ro=(_o=(Eo=(To=be==null?void 0:be.MediaSource)!=null?To:be==null?void 0:be.MozMediaSource)!=null?Eo:be==null?void 0:be.WebKitMediaSource)!=null?_o:be==null?void 0:be.MSMediaSource)!=null?Ro:be==null?void 0:be.ManagedMediaSource)!=null?Po:void 0,Gg=mt!==void 0&&mt===(be==null?void 0:be.ManagedMediaSource);var ct={EdgeChromium:0,Firefox:1,Ie11:2,OtherIeOrEdgePreEdgeChromium:3,SafariDesktop:4,SafariMobile:5,Other:6},Ne={A1KStb40xx:100,Panasonic:101,PhilipsNetTv:102,PlayStation4:103,PlayStation5:104,Tizen:105,WebOs2021:106,WebOs2022:107,WebOsOther:108,Xbox:109,Other:110},ye={DEVICES:Ne,BROWSERS:ct,browser:ct.Other,device:Ne.Other,isSamsungBrowser:!1};Xd();function Xd(){var n,e,t;mr||(typeof ee.MSInputMethodContext!=\"undefined\"&&typeof document.documentMode!=\"undefined\"?ye.browser=ct.Ie11:navigator.appName===\"Microsoft Internet Explorer\"||navigator.appName===\"Netscape\"&&/(Trident|Edge)\\//.test(navigator.userAgent)?ye.browser=ct.OtherIeOrEdgePreEdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"edg/\")!==-1?ye.browser=ct.EdgeChromium:navigator.userAgent.toLowerCase().indexOf(\"firefox\")!==-1?ye.browser=ct.Firefox:typeof navigator.platform==\"string\"&&/iPad|iPhone|iPod/.test(navigator.platform)?ye.browser=ct.SafariMobile:(Object.prototype.toString.call(ee.HTMLElement).indexOf(\"Constructor\")>=0||((e=(n=ee.safari)==null?void 0:n.pushNotification)==null?void 0:e.toString())===\"[object SafariRemoteNotification]\"||/Safari\\/(\\d+)/.test(navigator.userAgent)&&/Version\\/(\\d+)/.test(navigator.userAgent)&&((t=navigator.vendor)==null?void 0:t.indexOf(\"Apple\"))!==-1&&!/Chrome\\/(\\d+)/.test(navigator.userAgent)&&!/Chromium\\/(\\d+)/.test(navigator.userAgent))&&(ye.browser=ct.SafariDesktop),/SamsungBrowser/.test(navigator.userAgent)&&(ye.isSamsungBrowser=!0),navigator.userAgent.indexOf(\"PlayStation 4\")!==-1?ye.device=Ne.PlayStation4:navigator.userAgent.indexOf(\"PlayStation 5\")!==-1?ye.device=Ne.PlayStation5:/Tizen/.test(navigator.userAgent)?ye.device=Ne.Tizen:/[Ww]eb[O0]S/.test(navigator.userAgent)?/[Ww]eb[O0]S.TV-2022/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/87/.test(navigator.userAgent)?ye.device=Ne.WebOs2022:/[Ww]eb[O0]S.TV-2021/.test(navigator.userAgent)||/[Cc]hr[o0]me\\/79/.test(navigator.userAgent)?ye.device=Ne.WebOs2021:ye.device=Ne.WebOsOther:navigator.userAgent.indexOf(\"NETTV\")!==-1&&navigator.userAgent.indexOf(\"Philips\")!==-1?ye.device=Ne.PhilipsNetTv:/[Pp]anasonic/.test(navigator.userAgent)?ye.device=Ne.Panasonic:navigator.userAgent.indexOf(\"Xbox\")!==-1?ye.device=Ne.Xbox:navigator.userAgent.indexOf(\"Model/a1-kstb40xx\")!==-1&&(ye.device=Ne.A1KStb40xx))}var ci=ye;function pi(n){return new Promise(e=>{setTimeout(e,n)})}function Ct(n,e){let t;return new Promise((r,i)=>{if(n.cancellationError!==null)return i(n.cancellationError);let a=!1;t=e(function(d){n.deregister(o),a=!0,r(d)},function(d){n.deregister(o),a=!0,i(d)}),a||n.register(o);function o(s){t!==void 0&&t(),i(s)}})}function ln(n,e){return Ct(e,t=>{let r=setTimeout(()=>t(),n);return()=>clearTimeout(r)})}var z=class{constructor(e){let[t,r]=Zd();this._isUsed=!1,this._trigger=t,this._taskName=e,this.signal=new gi(r)}isUsed(){return this._isUsed}linkToSignal(e){let t=e.register(r=>{this.cancel(r.reason)});return this.signal.register(t),t}cancel(e){if(this._isUsed)return;this._isUsed=!0;let t=new oe(this._taskName,e);this._trigger(t)}static isCancellationError(e){return e instanceof oe}},gi=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(\"utils\",\"Error while calling clean up listener\",r instanceof Error?r:\"Unknown Error\")}})}isCancelled(){return this._isCancelled}register(e){return this._isCancelled?(Ie(this.cancellationError!==null),e(this.cancellationError),O):(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(e,t){let r=e!==void 0?`\"${e}\" task cancelled.`:\"This task was cancelled.\";t!==void 0&&(r+=\" Reason: \"+t),super(r),Object.setPrototypeOf(this,n.prototype),this.name=\"CancellationError\",this.reason=t,e!==void 0&&c.debug(\"utils\",`task cancellation: \"${e}\"`+(t===void 0?\"\":` - Reason: \"${t}\"`))}};function Zd(){let n=O;return[function(t){n(t)},function(t){n=t}]}var Jd=[\"\",\"webkit\",\"moz\",\"ms\"];function eu(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 tu(n,e){return e.filter(t=>eu(n,t))[0]}function nu(n,e){return n.reduce((t,r)=>t.concat((e===void 0?Jd:e).map(i=>i+r)),[])}function Pe(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=tu(i,r)),Q(t))i.addEventListener(t,a),o.register(()=>{t!==void 0&&i.removeEventListener(t,a)});else{c.warn(\"utils\",`element ${i.tagName} does not support any of these events: `+r.join(\", \"));return}r.forEach(s=>{let d=!1;typeof i.addEventListener==\"function\"?i.addEventListener(s,a):(d=!0,i[\"on\"+s]=a),o.register(()=>{typeof i.removeEventListener==\"function\"&&i.removeEventListener(s,a),d&&delete i[\"on\"+s]})})}}}var Ih=Pe([\"loadedmetadata\"]),bh=Pe([\"timeupdate\"]),yh=Pe([\"addtrack\"]),Sh=Pe([\"removetrack\"]),Ft=Pe([\"sourceopen\",\"webkitsourceopen\"]),Sr=Pe([\"sourceclose\",\"webkitsourceclose\"]),Tr=Pe([\"sourceended\",\"webkitsourceended\"]),vo=Pe([\"update\"]),Co=Pe([\"removesourcebuffer\"]),Th=Pe([\"keymessage\",\"message\"]),Eh=Pe([\"keyadded\",\"ready\"]),_h=Pe([\"keyerror\",\"error\"]),Rh=Pe([\"keystatuseschange\"]),Ph=Pe([\"seeking\"]),vh=Pe([\"seeked\"]),Ch=Pe([\"ended\"]);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 Er(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 _r(n){if(typeof Uint8Array.fromBase64==\"function\")return Uint8Array.fromBase64(n);let e=n.length%4,t=n;e!==0&&(c.warn(\"utils\",\"base64ToBytes: base64 given miss padding\",{padding:e}),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 d=0,u=0;d<a;d+=4,u+=3)s=Er(t.charCodeAt(d))<<18|Er(t.charCodeAt(d+1))<<12|Er(t.charCodeAt(d+2))<<6|Er(t.charCodeAt(d+3)),o[u]=s>>16,o[u+1]=s>>8&255,o[u+2]=s&255;return o.subarray(0,o.length-i)}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 xo(n,e){return(n[e+0]<<8)+(n[e+1]<<0)}function hi(n,e){return n[e+0]*65536+n[e+1]*256+n[e+2]}function re(n,e){return n[e+0]*16777216+n[e+1]*65536+n[e+2]*256+n[e+3]}function pt(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 ko(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer)}function Oe(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 Ze(n,e){let t=n.length,r=0;for(;r+8<=t;){let i=re(n,r);if(i===0)i=t-r;else if(i===1){if(r+16>t)return-1;i=pt(n,r+8)}if(isNaN(i)||i<=0)return-1;if(re(n,r+4)===e)return r+i<=t?r:-1;r+=i}return-1}function Rr(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=Ze(r,1836019558);if(i<0)break;let a=re(n,i+e),o=e+i+a;if(o>n.length)break;let s=Ze(r,1835295092);if(s<0)break;let d=re(n,s+e),u=e+s+d;if(u>n.length)break;let f=Math.max(o,u),l=n.subarray(e,f);t.push(l),e=f}return t.length===0?[null,r]:[t,r]}function ru(n,e,t){return new Uint8Array(Array.prototype.slice.call(n,e,t))}function iu(n,e,t){return n.slice(e,t)}var Ii=typeof Uint8Array.prototype.slice==\"function\"?iu:ru;function bi(n,e){let t=n;for(let r of e){let i=ge(t,r);if(i===null)return null;t=i}return t}function ge(n,e){let t=zt(n,e);return t!==null?n.subarray(t[1],t[2]):null}function Mo(n,e){let t=[],r=n;for(;;){let i=zt(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 zt(n,e){let t=n.length,r=0,i,a=0,o;for(;r+8<=t;){if(o=r,a=re(n,o),o+=4,i=re(n,o),o+=4,a===0)a=t-r;else if(a===1){if(o+8>t)return null;a=pt(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=ge(n,1836019574);if(t===null)return[];let r=[];for(;e<t.length;){let i;try{i=zt(t,1886614376)}catch(s){let d=s instanceof Error?s:\"\";return c.warn(\"isobmff\",\"Error while removing PSSH from ISOBMFF\",d),r}if(i===null)return r;let a=Ii(t,i[0],i[2]),o=Oo(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 Oo(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=Ii(n,t,t+16);return br(r)}function yi(n){let e=ge(n,1836019558);return e===null?null:ge(e,1953653094)}function wo(n){return Mo(n,1836019558).reduce((t,r)=>{let i=ge(r,1953653094);return i!==null&&t.push(i),t},[])}function Si(n){return ge(n,1835295092)}function Ti(n){let e=ge(n,1836019574);if(e===null)return null;let t=ge(e,1953653099);return t===null?null:ge(t,1835297121)}function Do(n,e=0){return ge(n.subarray(e),1701671783)}function fn(n,e){let t=zt(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=re(n,a);a+=4;let d;if(o===0)d=re(n,a),a+=4,r+=re(n,a)+i,a+=4;else if(o===1)d=pt(n,a),a+=8,r+=pt(n,a)+i,a+=8;else return null;let u=[];a+=2;let f=xo(n,a);for(a+=2;--f>=0;){let l=re(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 h=re(n,a);a+=4,a+=4,u.push({time:d,duration:h,timescale:s,range:[r,r+p-1]}),d+=h,r+=p}return u}function Ei(n){let e=yi(n);if(e===null)return;let t=ge(e,1952867444);if(t===null)return;let r=t[0];if(r===1)return pt(t,4);if(r===0)return re(t,4)}function au(n){let e=ge(n,1952868452);if(e===null)return;let t=1,r=hi(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),re(e,t)):void 0}function _i(n){let e=wo(n);if(e.length===0)return;let t=0;for(let r of e){let i=ge(r,1953658222);if(i===null)return;let a=0,o=i[a];if(a+=1,o>1)return;let s=hi(i,a);a+=3;let d=(s&256)>0,u=0;if(!d&&(u=au(r),u===void 0))return;let f=(s&1)>0,l=(s&4)>0,m=(s&512)>0,p=(s&1024)>0,h=(s&2048)>0,b=re(i,a);a+=4,f&&(a+=4),l&&(a+=4);let g=b,y=0;for(;g-- >0;)d?(y+=re(i,a),a+=4):y+=u,m&&(a+=4),p&&(a+=4),h&&(a+=4);t+=y}return t}function mn(n){let e=Ti(n);if(e===null)return;let t=ge(e,1835296868);if(t===null)return;let r=0,i=t[r];if(r+=4,i===1)return re(t,r+16);if(i===0)return re(t,r+8)}function Bo(n){let e=[],t=0;for(;t<n.length;){let r=Do(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:d}=di(r,o);o=s;let{end:u,string:f}=di(r,o);o=u;let l=re(r,o);o+=4;let m=re(r,o);o+=4;let p=re(r,o);o+=4;let h=re(r,o);o+=4;let b=r.subarray(o,i),g={schemeIdUri:d,value:f,timescale:l,presentationTimeDelta:m,eventDuration:p,id:h,messageData:b};e.push(g)}}if(e.length!==0)return e}function No(n){let e=bi(n,[1836019574,1953653099,1835297121,1835626086,1937007212,1937011556]);if(e===null)return null;let t=e.subarray(8),r=ge(t,1701733238),i=0;if(r===null?(i=28,r=ge(t,1701733217)):i=78,r===null)return null;let a=bi(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 ue(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,d)=>s===d||typeof s==\"number\"&&typeof d==\"number\"&&isNaN(s)&&isNaN(d);for(;a<r;){if(o(n[a],e))return!0;a++}return!1}function ou(n,e){let{mimeType:t,codecs:r}=Uo(n),{mimeType:i,codecs:a}=Uo(e);if(t!==i||r===\"\"||a===\"\")return!1;let o=r.split(\".\")[0];o=o===\"hev1\"?\"hvc1\":o;let s=a.split(\".\")[0];return s=s===\"hev1\"?\"hvc1\":s,o===s}var su=7;function Uo(n){var i;let[e,...t]=n.split(\";\"),r=(i=j(t,a=>Oe(a,\"codecs=\")))!=null?i:\"\";return r=r.substring(su),r[0]==='\"'&&(r=r.substring(1,r.length-1)),{mimeType:e,codecs:r}}var Lo=ou;function Ri(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 Pi(n){let e=(Math.random()*2-1)*.3;return n*(e+1)}function Fo(n){var t,r,i,a,o;let e=[];for(let s of n.periods){let d=[...(t=s.adaptations.video)!=null?t:[],...(r=s.adaptations.audio)!=null?r:[]];for(let u of d)if(u.supportStatus.hasCodecWithUndefinedSupport)for(let f of u.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 zo=[];function tt(n){ue(zo,n)||(console.warn(n),zo.push(n))}var cn=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 gt=class{constructor(e,t,r){if(this.id=e.id,this.adaptations=du(e.adaptations,t,r),qo(this.adaptations.video)&&qo(this.adaptations.audio))throw new Z(\"MANIFEST_PARSE_ERROR\",\"The manifest has no video nor audio tracks.\");this.thumbnailTracks=e.thumbnailTracks.map(i=>({id:i.id,mimeType:i.mimeType,index:i.index,cdnMetadata:i.cdnMetadata,height:i.height,width:i.width,horizontalTiles:i.horizontalTiles,verticalTiles:i.verticalTiles,start:i.start,end:i.end,tileDuration:i.tileDuration})),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)for(let a of i){if(!a.supportStatus.hasCodecWithUndefinedSupport)continue;let o=a.supportStatus.hasSupportedCodec;a.refreshCodecSupport(t),o!==!1&&a.supportStatus.hasSupportedCodec===!1&&e.push(a)}},{})}getAdaptations(){return fi(this)}getAdaptationsForType(e){let t=this.adaptations[e];return t!=null?t:[]}getAdaptation(e){return j(this.getAdaptations(),({id:t})=>e===t)}getSupportedAdaptations(e){return Io(this,e)}containsTime(e,t){return li(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,thumbnailTracks:this.thumbnailTracks.map(r=>({id:r.id,mimeType:r.mimeType,height:r.height,width:r.width,horizontalTiles:r.horizontalTiles,verticalTiles:r.verticalTiles,start:r.start,end:r.end,tileDuration:r.tileDuration}))}}};function qo(n){return Array.isArray(n)?n.length===0:!0}function du(n,e,t){let r={};for(let[i,a]of Object.entries(n))v(a)||(r[i]=a.map(o=>new ft(o,e,{representationFilter:t})).filter(o=>o.representations.length>0));return r}function pn(n,e,t){let r={updatedAdaptations:[],removedAdaptations:[],addedAdaptations:[],updatedThumbnailTracks:[],removedThumbnailTracks:[],addedThumbnailTracks:[]};n.start=e.start,n.end=e.end,n.duration=e.duration,n.streamEvents=e.streamEvents;let i=n.thumbnailTracks,a=e.thumbnailTracks;for(let d=0;d<i.length;d++){let u=i[d],f=ne(a,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'ThumbnailTrack \"'+i[d].id+'\" not found when merging.');let[l]=i.splice(d,1);d--,r.removedThumbnailTracks.push({id:l.id})}else{let[l]=a.splice(f,1);u.mimeType=l.mimeType,u.height=l.height,u.width=l.width,u.horizontalTiles=l.horizontalTiles,u.verticalTiles=l.verticalTiles,u.start=l.start,u.end=l.end,u.tileDuration=l.tileDuration,u.cdnMetadata=l.cdnMetadata,t===0?u.index._replace(l.index):u.index._update(l.index),r.updatedThumbnailTracks.push({id:u.id,mimeType:u.mimeType,height:u.height,width:u.width,horizontalTiles:u.horizontalTiles,verticalTiles:u.verticalTiles,start:u.start,end:u.end,tileDuration:u.tileDuration})}}a.length>0&&(c.warn(\"manifest\",`${a.length} new Thumbnail tracks found when merging.`),r.addedThumbnailTracks.push(...a.map(d=>({id:d.id,mimeType:d.mimeType,height:d.height,width:d.width,horizontalTiles:d.horizontalTiles,verticalTiles:d.verticalTiles,start:d.start,end:d.end,tileDuration:d.tileDuration}))),n.thumbnailTracks.push(...a));let o=n.getAdaptations(),s=e.getAdaptations();for(let d=0;d<o.length;d++){let u=o[d],f=ne(s,l=>l.id===u.id);if(f===-1){c.warn(\"manifest\",'Adaptation \"'+o[d].id+'\" not found when merging.');let[l]=o.splice(d,1);d--,r.removedAdaptations.push({id:l.id,trackType:l.type})}else{let[l]=s.splice(f,1),m=[],p=[],h=[];r.updatedAdaptations.push({adaptation:u.id,trackType:u.type,updatedRepresentations:m,addedRepresentations:p,removedRepresentations:h});let b=u.representations,g=l.representations.slice();for(let y=0;y<b.length;y++){let T=b[y],R=ne(g,E=>E.id===T.id);if(R===-1){c.warn(\"manifest\",`Representation \"${b[y].id}\" not found when merging.`);let[E]=b.splice(y,1);y--,h.push(E.id)}else{let[E]=g.splice(R,1);m.push(T.getMetadataSnapshot()),T.cdnMetadata=E.cdnMetadata,t===0?T.index._replace(E.index):T.index._update(E.index)}}g.length>0&&(c.warn(\"manifest\",`${g.length} new Representations found when merging.`),u.representations.push(...g),p.push(...g.map(y=>y.getMetadataSnapshot())))}}if(s.length>0){c.warn(\"manifest\",`${s.length} new Adaptations found when merging.`);for(let d of s){let u=n.adaptations[d.type];u===void 0?n.adaptations[d.type]=[d]:u.push(d),r.addedAdaptations.push(d.getMetadataSnapshot())}}return r}function Wo(n,e){let t={updatedPeriods:[],addedPeriods:[],removedPeriods:[]},r=0;for(let a=0;a<e.length;a++){let o=e[a],s=r,d=n[s];for(;d!==void 0&&d.id!==o.id;)s++,d=n[s];if(d!==void 0){let u=pn(d,o,0);t.updatedPeriods.push({period:{id:d.id,start:d.start,end:d.end,duration:d.duration,streamEvents:d.streamEvents},result:u});let f=e.slice(r,a),l=s-r,m=n.splice(r,l,...f);t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end}))),t.addedPeriods.push(...f.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 Vo(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 Z(\"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 Z(\"MANIFEST_UPDATE_ERROR\",\"Cannot perform partial update: incoherent data\");let a=pn(n[i],e[0],1);t.updatedPeriods.push({period:K(n[i].getMetadataSnapshot(),{adaptations:void 0}),result:a});let o=i+1;for(let s=1;s<e.length;s++){let d=e[s],u=-1;for(let f=o;f<n.length;f++)if(d.id===n[f].id){u=f;break}if(u<0){let f=-1;for(let p=o;p<n.length;p++)if(d.start<n[p].start){f=p;break}let l=f-o,m=n.splice(o,l,d);t.addedPeriods.push(d.getMetadataSnapshot()),t.removedPeriods.push(...m.map(p=>({id:p.id,start:p.start,end:p.end})))}else{if(u>o){c.warn(\"manifest\",\"old Periods not found in new when updating, removing\");let l=n.splice(o,u-o);t.removedPeriods.push(...l.map(m=>({id:m.id,start:m.start,end:m.end}))),u=o}let f=pn(n[u],d,0);t.updatedPeriods.push({period:K(n[u].getMetadataSnapshot(),{adaptations:void 0}),result:f})}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(d=>({id:d.id,start:d.start,end:d.end})))}return t}var uu=Me(),gn=class extends fe{constructor(e,t){var a;super();let{representationFilter:r,manifestUpdateUrl:i}=t;this.manifestFormat=0,this.id=uu(),this.expired=(a=e.expired)!=null?a:null,this.transport=e.transportType,this.clockOffset=e.clockOffset,this._cachedCodecSupport=new cn([]),this.periods=e.periods.map(o=>new gt(o,this._cachedCodecSupport,r)).sort((o,s)=>o.start-s.start),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=i,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 Z(\"MANIFEST_INCOMPATIBLE_CODECS_ERROR\",\"An Adaptation contains only incompatible codecs.\",{tracks:t.map(vt)}):null}getPeriod(e){return j(this.periods,t=>e===t.id)}getPeriodForTime(e){return bo(this,e)}getNextPeriod(e){return j(this.periods,t=>t.start>e)}getPeriodAfter(e){return yo(this,e)}getUrls(){return this.uris}replace(e){this._performUpdate(e,0)}update(e){this._performUpdate(e,1)}getMinimumSafePosition(){return po(this)}getLivePosition(){return go(this)}getMaximumSafePosition(){return ho(this)}updateCodecSupportList(e){this._cachedCodecSupport=e}updateRepresentationsDeciperability(e){let t=lu(this,e);t.length>0&&this.trigger(\"decipherabilityUpdate\",t)}addRepresentationsToAvoid(e){let t=[];for(let r of e){let i=this.getPeriod(r.period.id);if(i===void 0)continue;let a=i.getAdaptation(r.adaptation.id);if(a===void 0)continue;let o=a.getRepresentation(r.representation.id);o!==void 0&&(o.shouldBeAvoided=!0,t.push({manifest:this,period:i,adaptation:a,representation:o}))}t.length>0&&this.trigger(\"representationAvoidanceUpdate\",t)}getAdaptations(){tt(\"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(Object.prototype.hasOwnProperty.call(t,i)){let a=t[i];r.push(...a)}return r}getAdaptationsForType(e){tt(\"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 tt(\"manifest.getAdaptation(id) is deprecated. Please use manifest.period[].getAdaptation(id) instead\"),j(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 Fo(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=Wo(this.periods,e.periods);else{this.timeBounds.maximumTimeData=e.timeBounds.maximumTimeData,this.updateUrl=e.uris[0],r=Vo(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 lu(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},d=e(s);d!==!1&&(a=!1),d!==o.decipherable&&(t.push(s),o.decipherable=d,d===!0?i.supportStatus.isDecipherable=!0:d===void 0&&i.supportStatus.isDecipherable===!1&&(i.supportStatus.isDecipherable=void 0),c.debug(\"manifest\",`Decipherability changed for \"${o.id}\"`,`(${o.bitrate})`,String(o.decipherable)))}a&&(i.supportStatus.isDecipherable=!1)}return t}function nt(n,e){return n.segment.id===e.segment.id&&n.representation.uniqueId===e.representation.uniqueId}function He(n){if(v(n))return null;let{period:e,adaptation:t,representation:r,segment:i}=n;return{t:t.type[0],p:e.id,a:t.id,r:r.id,ss:i.isInit?null:i.time,se:i.isInit||!i.complete?null:i.end}}var ht=gn;var xt=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){t.isCancelled()||a.clearSignal.isCancelled()||r.onUpdate(i,{clearSignal:a.clearSignal,emitCurrentValue:a.includeLastObservation})},deriveReadOnlyObserver(i){return vr(this,i,t)}}}var hn=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){this._cancelSignal.isCancelled()||t.clearSignal.isCancelled()||this._src.onUpdate(e,{clearSignal:t.clearSignal,emitCurrentValue:t.includeLastObservation})}deriveReadOnlyObserver(e){return vr(this,e,this._cancelSignal)}};var rt=typeof queueMicrotask==\"function\"?queueMicrotask:function(e){Promise.resolve().then(e,()=>e())};var kt=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 j(this._array,e)}has(e){return ue(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 In=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 fu=.016666666666666666;function Go(n,e){return Math.abs(n-e)<fu}function Ko(n,e){let t=Math.min(n.start,e.start),r=Math.max(n.end,e.end);return{start:t,end:r}}function mu(n){for(let e=0;e<n.length;e++){let t=n[e];t.start===t.end&&n.splice(e--,1)}return n}function cu(n){for(let e=1;e<n.length;e++){let t=n[e-1],r=n[e];if(Yo(t,r)){let i=Ko(t,r);n.splice(--e,2,i)}}return n}function vi(n,e){return n.end<=e.start}function Ho({start:n,end:e},t){return n<=t&&t<e}function jo(n,e){return Ho(n,e.start)||n.start<e.end&&e.end<n.end||Ho(e,n.start)}function Yo(n,e){return Go(e.start,n.end)||Go(e.end,n.start)}function Ci(n){let e=[];for(let t=0;t<n.length;t++)e.push({start:n.start(t),end:n.end(t)});return e}function pu(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 Qo(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 Cr(n,e){let t=pu(n,e);return t!==null?t.end-e:1/0}function It(n,e){if(e.start===e.end)return n;let t=e,r=0;for(;r<n.length;r++){let i=n[r],a=jo(t,i),o=Yo(t,i);if(a||o)t=Ko(t,i),n.splice(r--,1);else if(r===0){if(vi(t,n[0]))break}else if(vi(n[r-1],t)&&vi(t,i))break}return n.splice(r,0,t),cu(mu(n))}function gu(n,e){let t=[];for(let r=0;r<e.length;r++)jo(n,e[r])&&t.push(e[r]);return t}function Ar(n,e){let t=[];for(let r=0;r<n.length;r++){let i=n[r],a=[],o=gu(i,e);if(o.length>0)for(let s=0;s<o.length;s++){let d=o[s];a.push({start:Math.max(i.start,d.start),end:Math.min(i.end,d.end)})}if(a.length===0)t.push(i);else{let s=i.start;for(let d=0;d<a.length;d++)a[d].start>s&&t.push({start:s,end:a[d].start}),s=a[d].end;s<i.end&&t.push({start:s,end:i.end})}}return t}function xr({segmentSink:n,playbackObserver:e,maxBufferBehind:t,maxBufferAhead:r},i){let a,o=[];e.listen(d=>{a=d.position.getWanted(),o=d.buffered[n.bufferType],s()},{includeLastObservation:!0,clearSignal:i});function s(){o!==null&&hu(n,a,o,t.getValue(),r.getValue(),i).catch(d=>{if(i.isCancelled()&&z.isCancellationError(d))return;let u=d instanceof Error?d.message:\"Unknown error\";c.error(\"Stream\",\"Could not run BufferGarbageCollector:\",u)})}t.onUpdate(s,{clearSignal:i}),r.onUpdate(s,{clearSignal:i}),s()}async function hu(n,e,t,r,i,a){if(!isFinite(r)&&!isFinite(i))return Promise.resolve();let o=[],{innerRange:s,outerRanges:d}=Qo(t,e),u=()=>{if(isFinite(r)){for(let l of d)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 d)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})}};u(),f();for(let l of o)if(l.start<l.end){if(c.debug(\"Stream\",\"cleaning range from SegmentSink\",{start:l.start,end:l.end}),a.cancellationError!==null)throw a.cancellationError;await n.removeBuffer(l.start,l.end)}}var bn=class{constructor(e,t){this._history=[],this._lifetime=e,this._maxHistoryLength=t}addBufferedSegment(e,t){let r=F();this._history.push({date:r,buffered:t,context:e}),this._cleanHistory(r)}getHistoryFor(e){return this._history.filter(t=>nt(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 yn=class{constructor(){let{BUFFERED_HISTORY_RETENTION_TIME:e,BUFFERED_HISTORY_MAXIMUM_ENTRIES:t}=L.getCurrent();this._inventory=[],this._bufferedHistory=new bn(e,t)}reset(){this._inventory.length=0}synchronizeBuffered(e){var d,u,f,l,m,p,h;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(c.hasLevel(\"DEBUG\")){let b=e.map(g=>`${g.start}-${g.end}`).join(\",\");c.debug(\"SI\",`synchronizing ${o!=null?o:\"unknown\"} buffered ranges:`,b)}let s=e.length;for(let b=0;b<s;b++){if(i===void 0)return;let g=e[b].start,y=e[b].end;if(y-g<a){c.warn(\"SI\",\"skipped range when synchronizing because it was too small\",{t:o,rangeStart:g,rangeEnd:y});continue}let T=r;for(;i!==void 0&&((d=i.bufferedEnd)!=null?d:i.end)-g<a;)i=t[++r];let R=null,E=r-T;if(E>0){let P=t[T+E-1];R={end:(u=P.bufferedEnd)!=null?u:P.end,precizeEnd:P.precizeEnd},c.debug(\"SI\",`${E} segments GCed.`,{t: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(Iu(i,g,R,o),r===t.length-1){Xo(i,y,o);return}i=t[++r];let P=(l=i.bufferedStart)!=null?l:i.start,x=(m=i.bufferedEnd)!=null?m:i.end,A=b<s-1?e[b+1].start:void 0;for(;i!==void 0&&!(y<P||y-P<a&&x-y>=a||A!==void 0&&y-P<x-A);){let k=t[r-1];k.bufferedEnd===void 0&&(i.precizeStart?k.bufferedEnd=i.start:k.infos.segment.complete?k.bufferedEnd=k.end:k.bufferedEnd=i.start,c.debug(\"SI\",\"calculating buffered end of contiguous segment\",{t:o,prevSegmentBufferedEnd:k.bufferedEnd,pse:k.end})),i.bufferedStart=k.bufferedEnd,i=t[++r],i!==void 0&&(P=(p=i.bufferedStart)!=null?p:i.start,x=(h=i.bufferedEnd)!=null?h:i.end)}}let C=t[r-1];C!==void 0&&Xo(C,y,o)}if(!v(i)){let{SEGMENT_SYNCHRONIZATION_DELAY:b}=L.getCurrent(),g=F();for(let y=r;y<t.length;y++){let T=t[y];g-T.insertionTs>=b&&(c.debug(\"SI\",\"A segment at the end has been completely GCed\",He(T.infos)),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`+bu(this._inventory))}insertChunk({period:e,adaptation:t,representation:r,segment:i,chunkSize:a,start:o,end:s},d,u){if(i.isInit)return;let f=t.type;if(o>=s){c.warn(\"SI\",\"Invalid chunked inserted: starts before it ends\",{t:f,start:o,end:s});return}let l=this._inventory,m={status:d?0:2,insertionTs:u,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 h=l.length-1;h>=0;h--){let b=l[h];if(b.start<=o)if(b.end<=o){for(c.debug(\"SI\",\"Pushing segment strictly after previous one.\",{t:f,pse:b.end,ss:o}),this._inventory.splice(h+1,0,m),h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,pss:l[h].start,ss:o,se:s}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,1)}return}else if(b.start===o)if(b.end<=s){for(c.debug(\"SI\",\"Segment pushed replace another one\",{t:f,ss:o,se:s,pss:b.start,pse:b.end}),this._inventory.splice(h,1,m),h+=1;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,1)}return}else{c.debug(\"SI\",\"Segment pushed ends before another with the same start\",{t:f,ss:o,se:s,pse:b.end}),l.splice(h,0,m),b.start=m.end,b.bufferedStart=void 0,b.precizeStart=b.precizeStart&&m.precizeEnd;return}else if(b.end<=m.end){for(c.debug(\"SI\",\"Segment pushed updates end of previous one\",{t:f,ss:o,se:s,pss:b.start,pse:b.end}),this._inventory.splice(h+1,0,m),b.end=m.start,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,h+=2;h<l.length&&l[h].start<m.end;){if(l[h].end>m.end){c.debug(\"SI\",\"Segment pushed updates the start of the next one\",{t:f,ss:o,se:s,pss:l[h].start}),l[h].start=m.end,l[h].bufferedStart=void 0,l[h].precizeStart=l[h].precizeStart&&m.precizeEnd;return}c.debug(\"SI\",\"Segment pushed removes the next one\",{t:f,ss:o,se:s,pss:l[h].start,pse:l[h].end}),l.splice(h,1)}return}else{c.warn(\"SI\",\"Segment pushed is contained in a previous one\",{t:f,ss:o,se:s,pss:b.start,pse:b.end});let g={status:b.status,insertionTs:b.insertionTs,chunkSize:b.chunkSize,splitted:!0,start:m.end,end:b.end,precizeStart:b.precizeStart&&b.precizeEnd&&m.precizeEnd,precizeEnd:b.precizeEnd,bufferedStart:void 0,bufferedEnd:b.end,infos:b.infos};b.end=m.start,b.splitted=!0,b.bufferedEnd=void 0,b.precizeEnd=b.precizeEnd&&m.precizeStart,l.splice(h+1,0,m),l.splice(h+2,0,g);return}}let p=this._inventory[0];if(p===void 0){c.debug(\"SI\",\"first segment pushed\",{t:f,ss:o,se:s}),this._inventory.push(m);return}if(p.start>=s)c.debug(\"SI\",\"Segment pushed comes before all previous ones\",{t:f,ss:o,se:s,pss: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\",{t:f,ss:o,se:s,pss:p.start,pse: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\",{t:f,ss:o,se:s,pss:l[1].start,pse:l[1].end}),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\",{t:f,ss:o,se:s,pss:l[1].start,pse:l[1].end}),l.splice(1,1)}return}else{c.debug(\"SI\",\"Segment pushed start of the next one\",f,{ss:o,se:s,pss:p.start,pse: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(nt(t[i].infos,e)){let a=!1;r.length>0&&(a=!0,r.length===1&&(c.warn(\"SI\",\"Completed Segment is splitted.\",He(e)),r[0].splitted=!0));let o=i,s=t[i].chunkSize;for(i+=1;i<t.length&&nt(t[i].infos,e);){let m=t[i].chunkSize;s!==void 0&&m!==void 0&&(s+=m),i++}let d=i-1,u=d-o,f=t[d].end,l=t[d].bufferedEnd;u>0&&(this._inventory.splice(o+1,u),i-=u),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)c.warn(\"SI\",\"Completed Segment not found\",He(e));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.\",{ss:i.start,se:i.end})}getInventory(){return this._inventory}getHistoryFor(e){return this._bufferedHistory.getHistoryFor(e)}};function Ai(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 $o(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 Iu(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&&(c.debug(\"SI\",\"Segment partially GCed at the start\",{t:r,firstsbs:n.bufferedStart,rs:e}),n.bufferedStart=e),!n.precizeStart&&Ai(n)&&(n.start=n.bufferedStart,n.precizeStart=!0);else if(n.precizeStart)c.debug(\"SI\",\"buffered start is precize start\",{t:r,firstss: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\",{t:r,rs:e,firstss:n.start,lastdelse:t.end}),n.bufferedStart=t.end,Ai(n)&&(n.start=t.end,n.precizeStart=!0);else if(n.start-e<=i){let s=F();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI\",\"Ignored bufferedStart synchronization\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"found true buffered start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e,Ai(n)&&(n.start=e,n.precizeStart=!0)}else if(e<n.start)c.debug(\"SI\",\"range start too far from expected start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=n.start;else{let s=F();if(n.start-e>=a&&s-n.insertionTs<o){c.debug(\"SI\",\"Ignored bufferedStart synchronization\",{t:r,rs:e,firstss:n.start,delta:s-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the start\",{t:r,rs:e,firstss:n.start}),n.bufferedStart=e}}function Xo(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&&(c.debug(\"SI\",\"Segment partially GCed at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e),!n.precizeEnd&&e-n.end<=r&&$o(n)&&(n.precizeEnd=!0,n.end=e);else if(n.precizeEnd)c.debug(\"SI\",\"buffered end is precize end\",{t,lastse:n.end}),n.bufferedEnd=n.end;else if(e-n.end<=r||!n.infos.segment.complete){let o=F();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI\",\"Ignored bufferedEnd synchronization\",{t,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"found true buffered end\",{t,re:e,lastse:n.end}),n.bufferedEnd=e,$o(n)&&(n.end=e,n.precizeEnd=!0)}else if(e>n.end)c.debug(\"SI\",\"range end too far from expected end\",{t,re:e,lastse:n.end}),n.bufferedEnd=n.end;else{let o=F();if(e-n.end>=i&&o-n.insertionTs<a){c.debug(\"SI\",\"Ignored bufferedEnd synchronization\",{t,re:e,lastse:n.end,delta:o-n.insertionTs});return}c.debug(\"SI\",\"Segment appears immediately garbage collected at the end\",{t,lastsbe:n.bufferedEnd,re:e}),n.bufferedEnd=e}}function bu(n){let e=.016666666666666666,t={},r=[],i=null,a=null;function o(d){let u=String.fromCharCode(r.length+65);return r.push({letter:u,periodId:d.period.id,representationId:d.representation.id,bitrate:d.representation.bitrate}),u}let s=\"\";for(let d of n)if(d.bufferedStart!==void 0&&d.bufferedEnd!==void 0){let u=d.infos.period.id,f=d.infos.representation.id,l=t[u],m;if(l===void 0)m=o(d.infos),t[u]={[f]:m};else{let p=l[f];p===void 0?(m=o(d.infos),l[f]=m):m=p}i===null?s+=`${d.bufferedStart.toFixed(2)}|${m}|`:a===m?i.bufferedEnd+e<d.bufferedStart&&(s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`):s+=`${i.bufferedEnd.toFixed(2)} ~ ${d.bufferedStart.toFixed(2)}|${m}|`,i=d,a=m}return i!==null&&(s+=String(i.end.toFixed(2))),r.forEach(d=>{var u;s+=`\n[${d.letter}] P: ${d.periodId} || R: ${d.representationId}(${(u=d.bitrate)!=null?u:\"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 Wt(n,e){for(let t of n)if(t.infos.period.start>e.start)return t;return null}var Zo=yn;var Vt=class{constructor(){this._segmentInventory=new Zo}synchronizeInventory(e){this._segmentInventory.synchronizeBuffered(e)}getLastKnownInventory(){return this._segmentInventory.getInventory()}getSegmentHistory(e){return this._segmentInventory.getHistoryFor(e)}};var Sn=class extends Vt{constructor(e,t,r){super(),c.info(\"Stream\",\"calling `mediaSource.addSourceBuffer`\",{codec: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){Jo(t),this._initSegmentsMap.set(e,t)}freeInitSegment(e){this._initSegmentsMap.delete(e)}async pushChunk(e){Jo(e.data.chunk),c.debug(\"Stream\",\"queuing push order\",He(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:d,appendWindow:u}=e.data;return c.debug(\"Stream\",\"now pushing\",He(e.inventoryInfos)),this._sourceBuffer.appendBuffer(o,{codec:s,timestampOffset:d,appendWindow:u})}));this._addToOperationQueue(r,{type:0,value:e});let i;try{i=await r}catch(o){throw this._segmentInventory.insertChunk(e.inventoryInfos,!1,F()),o}e.inventoryInfos!==null&&this._segmentInventory.insertChunk(e.inventoryInfos,!0,F());let a=i[i.length-1];return this._segmentInventory.synchronizeBuffered(a),a}async removeBuffer(e,t){c.debug(\"Stream\",\"queuing remove order\",{bufferType:this.bufferType,start:e,end: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(e){try{c.debug(\"Stream\",\"Calling `dispose` on the SourceBufferInterface\"),this._sourceBuffer.dispose(e)}catch(t){c.debug(\"Stream\",`Failed to dispose a ${this.bufferType} SourceBufferInterface:`,t instanceof Error?t:\"Unknown Error\")}}_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 Jo(n){if(I.CURRENT_ENV!==I.PRODUCTION&&(typeof n!=\"object\"||n!==null&&!(n instanceof ArrayBuffer)&&!(n.buffer instanceof ArrayBuffer)))throw new Error(\"Invalid data given to the AudioVideoSegmentSink\")}var Mr=Sn;var Tn=class extends Vt{constructor(e){c.debug(\"Stream\",\"Creating TextSegmentSink\"),super(),this.bufferType=\"text\",this._sender=e,this._pendingOperations=[],this._sender.reset()}declareInitSegment(e){c.warn(\"Stream\",\"Declaring initialization segment for Text SegmentSink\",{uniqueId:e})}freeInitSegment(e){c.warn(\"Stream\",\"Freeing initialization segment for Text SegmentSink\",{uniqueId:e})}async pushChunk(e){let{data:t}=e;Su(t.chunk);let r=this._sender.pushTextData(se(J({},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,F()),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(\"Stream\",\"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 Su(n){if(I.CURRENT_ENV!==I.PRODUCTION){if(typeof n!=\"object\"||n===null||v(n.data))throw new Error(\"Invalid format given to a TextSegmentSink\");if(!Tu(n))throw new Error(\"Invalid format given to a TextSegmentSink\");if(typeof n.data!=\"string\"&&typeof n.data.byteLength!=\"number\")throw new Error(\"Invalid format given to a TextSegmentSink\")}}function Tu(n){return!(typeof n!=\"object\"||n===null||typeof n.type!=\"string\"||n.language!==void 0&&typeof n.language!=\"string\"||n.initTimescale!==null&&typeof n.initTimescale!=\"number\"||n.start!==void 0&&typeof n.start!=\"number\"||n.end!==void 0&&typeof n.end!=\"number\")}I.CURRENT_ENV===I.DEV&&(Eu=function(e){function t(r){}});var Eu;var es=Tn;var _u=[\"audio\",\"video\",\"text\"],En=class n{static isNative(e){return ts(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():Ct(e,t=>{let r=O,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(\"Stream\",`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.slice().forEach(r=>r()),Ie(this._onNativeBufferAddedOrDisabled.length===0))}createSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(ts(e)){if(!v(r))return r instanceof Mr&&r.codec!==t?c.warn(\"Stream\",\"Reusing native SegmentSink with codec\",r.codec,\"for codec\",t):c.info(\"Stream\",\"Reusing native SegmentSink with codec\",t),r;c.info(\"Stream\",\"Adding native SegmentSink with codec\",t);let a=e===\"audio\"?\"audio\":\"video\",o=new Mr(a,t,this._mediaSource);return this._initializedSegmentSinks[e]=o,this._onNativeBufferAddedOrDisabled.slice().forEach(s=>s()),Ie(this._onNativeBufferAddedOrDisabled.length===0),o}if(!v(r))return c.info(\"Stream\",\"Reusing a previous custom SegmentSink\",{bufferType:e}),r;let i;if(e===\"text\"){if(c.info(\"Stream\",\"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 c.error(\"Stream\",\"Unknown buffer type:\",{bufferType:e}),new Z(\"BUFFER_TYPE_UNKNOWN\",\"The player wants to create a SegmentSink of an unknown type.\")}disposeSegmentSink(e,t){let r=this._initializedSegmentSinks[e];if(v(r)){c.warn(\"Stream\",\"Trying to dispose a SegmentSink that does not exist\",{bufferType:e});return}c.info(\"Stream\",\"Aborting SegmentSink\",{bufferType:e}),r.dispose(t),delete this._initializedSegmentSinks[e]}disposeAll(e){_u.forEach(t=>{this.getStatus(t).type===\"initialized\"&&this.disposeSegmentSink(t,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 i,a;let t=(i=this._initializedSegmentSinks[e])==null?void 0:i.getLastKnownInventory(),r;if(t!==void 0){r=0;for(let o of t){if(o.chunkSize===void 0||r===void 0){r=void 0;break}r+=o.chunkSize}}return{bufferType:e,sizeEstimate:r,codec:(a=this._initializedSegmentSinks[e])==null?void 0:a.codec,segmentInventory:t==null?void 0:t.map(o=>se(J({},o),{infos:Ru(o.infos)}))}}getSegmentSinksMetrics(){return{segmentSinks:{audio:this.createSegmentSinkMetricsForType(\"audio\"),video:this.createSegmentSinkMetricsForType(\"video\"),text:this.createSegmentSinkMetricsForType(\"text\")}}}};function ts(n){return n===\"audio\"||n===\"video\"}function Ru(n){return{adaptation:n.adaptation.getMetadataSnapshot(),period:n.period.getMetadataSnapshot(),representation:n.representation.getMetadataSnapshot()}}var bt=En;var _n=class{constructor({drmSystemId:e,representation:t,notify:r}){if(this._hasSentEncryptionData=!1,this._representation=t,this._notify=r,e!==void 0){let i=t.getEncryptionData(e);i.length>0&&i.every(a=>a.keyIds!==void 0)&&(this._hasSentEncryptionData=!0,r(i))}}onNewProtectionData(e){for(let t of e)this._representation.addProtectionData(t.initDataType,t.keyId,t.initData);if(!this._hasSentEncryptionData){let t=this._representation.getAllEncryptionData();t.length>0&&(this._notify(t),this._hasSentEncryptionData=!0)}}};function xi(n,e,t,r,i){let{period:a,adaptation:o,representation:s}=n,d=Pu(i,e);if(d===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 u=i[d];if(u.bufferedStart!==void 0&&u.bufferedStart>e.start&&(t===null||u.infos.segment.end<=t)){let l=u.bufferedStart;return!r&&s.index.awaitSegmentBetween(e.start,l)!==!1?null:(c.debug(\"Stream\",\"current discontinuity encountered\",{bufferType:o.type,nextSegmentTime:u.bufferedStart,checkStartTime:e.start}),{start:void 0,end:l})}let f=vu(i,e,d+1);if(f!==null){let l=i[f-1],m=i[f];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,h=m.bufferedStart;return c.debug(\"Stream\",\"future discontinuity encountered\",{bufferType:o.type,discontinuityStart:p,discontinuityEnd:h}),{start:p,end:h}}}if(t===null){if(r&&a.end!==void 0){if(e.end<a.end)return null;let l=Cu(i,a.end);if(l!==null){let m=i[l];if(m.bufferedEnd!==void 0&&m.bufferedEnd<a.end)return c.debug(\"Stream\",\"discontinuity encountered at the end of the current period\",{bufferType:o.type,segmentsEndTimeFromPeriod:m.bufferedEnd,periodEnd: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 Pu(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 vu(n,e,t){if(t<=0)return c.error(\"Stream\",\"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 Cu(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 ki({bufferedSegments:n,content:e,currentPlaybackTime:t,fastSwitchThreshold:r,getBufferedHistory:i,neededRange:a,segmentsBeingPushed:o,maxBufferSize:s}){let{adaptation:d,representation:u}=e,f=Au(n,o,s),l=u.index.getSegments(a.start,a.end-a.start),m=n.filter(C=>!ns(C.infos,e,t,r)),p=Bu(m,a,i),{MINIMUM_SEGMENT_SIZE:h,MIN_BUFFER_AHEAD:b}=L.getCurrent(),g=!1,y=Math.min(1/60,h),T=!1,R=[];return{segmentsToLoad:l.filter(C=>{let P=K({segment:C},e);if(o.length>0&&o.some(B=>nt(P,B)))return!1;let{duration:x,time:A,end:k}=C;if(C.isInit)return!0;if(g)return R.push(C),!1;if(C.complete&&x<h||o.length>0&&o.some(B=>{if(B.period.id!==e.period.id||B.adaptation.id!==e.adaptation.id)return!1;let{segment:_}=B;if(_.time-y>A)return!1;if(_.complete){if(_.end+y<k)return!1}else if(Math.abs(A-_.time)>A)return!1;return!ns(B,P,t,r)}))return!1;for(let q of p){let B=q.infos.period.id===e.period.id;if(q.status===1&&B){let _=q.infos.segment;if(A-_.time>-y){if(_.complete){if(_.end-k>-y)return!1}else if(Math.abs(A-_.time)<y)return!1}}}let N=x*e.representation.bitrate;if(f-N<0&&(T=!0,A>a.start+b))return g=!0,R.push(C),!1;let D=i(P);if(D.length>1){let q=D[D.length-1],B=D[D.length-2];if(q.buffered===null&&B.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.\",{bufferType:d.type,representationId:u.id,segmentTime:C.time}),!1}for(let q=0;q<p.length;q++){let B=p[q];if(B.end+y>A){let _=B.start>A+y||xu(p,q).end<k-y;return _&&(f-=N),_}}return f-=N,!0}),segmentsOnHold:R,isBufferFull:T}}function Au(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 xu(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 ns(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:ku(n.representation,e.representation,r)}function ku(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 Mu(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?(c.info(\"Stream\",\"The start of the wanted segment has been garbage collected\",{segmentStart:n.start,currentStartInBuffer:n.bufferedStart}),!0):!1}function Ou(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?(c.info(\"Stream\",\"The end of the wanted segment has been garbage collected\",{segmentEnd:n.end,currentEndInBuffer:n.bufferedEnd}),!0):!1}function wu(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 Du(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 Bu(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],d=null;if(Mu(r,o,e.start)){if(d=t(r.infos),wu(d,r.bufferedStart))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the start\",{segmentStart:r.start,currentStartInBuffer:r.bufferedStart})}if(Ou(r,s,e.end)){if(d=d!=null?d:t(r.infos),Du(d,r.bufferedEnd))return!1;c.debug(\"Stream\",\"skipping segment gc-ed at the end\",{segmentEnd:r.end,currentEndInBuffer:r.bufferedEnd})}return!0})}function Rn(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 Mi(n,e,t,r,i,a,o){var A,k,N;let{representation:s}=n,d=(k=(A=t.getIsPaused())!=null?A:t.getReference().getValue().paused.pending)!=null?k:t.getReference().getValue().paused.last,u=(N=t.getPlaybackRate())!=null?N:t.getReference().getValue().speed,f=e;(d===void 0||u===void 0||d||u<=0)&&(f-=.1);let l=Nu(n,f,i),m=s.index.shouldRefresh(l.start,l.end),p=o.getPendingOperations().filter(D=>D.type===2).map(D=>D.value),h=o.getLastKnownInventory(),b=t.getCurrentTime();b===void 0&&(b=t.getReference().getValue().position.getWanted());let g=o.getSegmentHistory.bind(o),{segmentsToLoad:y,segmentsOnHold:T,isBufferFull:R}=ki({content:n,bufferedSegments:h,currentPlaybackTime:b,fastSwitchThreshold:r,getBufferedHistory:g,neededRange:l,segmentsBeingPushed:p,maxBufferSize:a}),E=y.map(D=>({priority:Rn(D.time,f),segment:D})),C=s.index.isInitialized()&&!s.index.isStillAwaitingFutureSegments()&&l.hasReachedPeriodEnd&&E.length===0&&T.length===0,P=null;return p.length>0&&(P=Math.min(...p.map(D=>D.segment.time))),T.length>0&&(P=P!==null?Math.min(P,T[0].time):T[0].time),E.length>0&&(P=P!==null?Math.min(P,E[0].segment.time):E[0].segment.time),{imminentDiscontinuity:xi(n,l,P,C,h),hasFinishedLoading:C,neededSegments:E,isBufferFull:R,shouldRefreshManifest:m}}function Nu(n,e,t){var l;let r,{manifest:i,period:a,representation:o}=n,s=o.index.getLastAvailablePosition(),d=o.index;!v(s)&&bt.isNative(n.adaptation.type)&&e>=s&&d.isInitialized()&&!d.isStillAwaitingFutureSegments()&&Uu(i,a,e)?r=s-1:r=e-.1;let u=r+t,f;return!o.index.isInitialized()||o.index.isStillAwaitingFutureSegments()||a.end===void 0?f=!1:s===void 0?f=u>=a.end:s===null?f=!0:f=u>=s,{start:Math.max(r,a.start),end:Math.min(u,(l=a.end)!=null?l:1/0),hasReachedPeriodEnd:f}}function Uu(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 Pn(n,e,t,r,i){try{return await e.pushChunk(t)}catch(a){if(i.isCancelled()&&a instanceof oe)throw a;if(!(a instanceof xe)||!a.isBufferFull){let d=a instanceof Error?a.toString():\"An unknown error happened when pushing content\";throw new Z(\"BUFFER_APPEND_ERROR\",d,{tracks:[vt(t.inventoryInfos.adaptation)]})}let{position:o}=n.getReference().getValue(),s=o.getWanted();try{c.warn(\"Stream\",\"Running garbage collector\");let d=Math.max(s-5,0),u=s+r.getValue()+12;if(d>0&&await e.removeBuffer(0,d),u<Number.MAX_VALUE&&await e.removeBuffer(u,Number.MAX_VALUE),await pi(200),i.cancellationError!==null)throw i.cancellationError;return await e.pushChunk(t)}catch(d){if(d instanceof oe)throw d;let u=d instanceof Error?d.toString():\"Could not clean the buffer\";throw new Z(\"BUFFER_FULL_ERROR\",u,{tracks:[vt(t.inventoryInfos.adaptation)]})}}}async function Oi({playbackObserver:n,content:e,initSegmentUniqueId:t,segment:r,segmentSink:i,bufferGoal:a},o){let s=e.representation.getMimeTypeString(),d={initSegmentUniqueId:t,chunk:null,timestampOffset:0,appendWindow:[void 0,void 0],codec:s},u=K({segment:r,chunkSize:void 0,start:0,end:0},e),f=await Pn(n,i,{data:d,inventoryInfos:u},a,o);return{content:e,segment:r,buffered:f}}async function wi({playbackObserver:n,bufferGoal:e,content:t,initSegmentUniqueId:r,parsedSegment:i,segment:a,segmentSink:o},s){var P,x;if(i.chunkData===null)return null;let{chunkData:d,chunkInfos:u,chunkOffset:f,chunkSize:l,appendWindow:m}=i,p=t.representation.getMimeTypeString(),{APPEND_WINDOW_SECURITIES:h}=L.getCurrent(),b=[m[0]!==void 0?Math.max(0,m[0]-h.START):void 0,m[1]!==void 0?m[1]+h.END:void 0],g={initSegmentUniqueId:r,chunk:d,timestampOffset:f,appendWindow:b,codec:p},y=(P=u==null?void 0:u.time)!=null?P:a.time,T=(x=u==null?void 0:u.duration)!=null?x:a.duration,R=y+T;b[0]!==void 0&&(y=Math.max(y,b[0])),b[1]!==void 0&&(R=Math.min(R,b[1]));let E=K({segment:a,chunkSize:l,start:y,end:R},t),C=await Pn(n,o,{data:g,inventoryInfos:E},e,s);return{content:t,segment:a,buffered:C}}function Di({content:n,options:e,playbackObserver:t,segmentSink:r,segmentQueue:i,terminate:a},o,s){c.debug(\"Stream\",\"Creating RepresentationStream\",{periodStart:n.period.start,bufferType:n.adaptation.type,adaptationId:n.adaptation.id,representationBitrate:n.representation.bitrate,mimeType:n.representation.getMimeTypeString()});let{period:d,adaptation:u,representation:f}=n,{bufferGoal:l,maxBufferSize:m,drmSystemId:p,fastSwitchThreshold:h}=e,b=u.type,g=new z(\"RepresentationStream \"+b);g.linkToSignal(s);let y={segment:f.index.getInitSegment(),uniqueId:null,isLoaded:!1};g.signal.register(()=>{y.uniqueId!==null&&r.freeInitSegment(y.uniqueId)});let T=y.segment!==null;T||(y.isLoaded=!0);let R=new _n({drmSystemId:p,representation:f,notify:A=>o.encryptionDataEncountered(A.map(k=>K({content:n},k)))});if(g.isUsed())return;i.addEventListener(\"error\",A=>{g.signal.isCancelled()||(g.cancel(\"RepresentationStream: SegmentQueue err\"),o.error(A))},g.signal),i.addEventListener(\"parsedInitSegment\",P,g.signal),i.addEventListener(\"parsedMediaSegment\",P,g.signal),i.addEventListener(\"emptyQueue\",C,g.signal),i.addEventListener(\"requestRetry\",A=>{if(o.warning(A.error),g.signal.isCancelled())return;let k=A.segment,{index:N}=f;N.isSegmentStillAvailable(k)===!1?C():N.canBeOutOfSyncError(A.error,k)&&o.manifestMightBeOufOfSync()},g.signal),i.addEventListener(\"fullyLoadedSegment\",A=>{r.signalSegmentComplete(K({segment:A},n)).catch(x)},g.signal);let E=i.resetForContent(n,T,\"new RepresentationStream linked to SegmentQueue\");g.signal.register(A=>{i.stop(A.reason)}),t.listen(C,{includeLastObservation:!1,clearSignal:g.signal}),n.manifest.addEventListener(\"manifestUpdate\",C,g.signal),l.onUpdate(C,{emitCurrentValue:!1,clearSignal:g.signal}),m.onUpdate(C,{emitCurrentValue:!1,clearSignal:g.signal}),a.onUpdate(C,{emitCurrentValue:!1,clearSignal:g.signal}),C();return;function C(){if(g.isUsed())return;let A=t.getReference().getValue(),k=A.position.getWanted(),N=Mi(n,k,t,h.getValue(),l.getValue(),m.getValue(),r),{neededSegments:D}=N,q=null;if(f.index.isInitialized()){if(D.length>0&&!y.isLoaded&&y.segment!==null){let M=D[0].priority;q={segment:y.segment,priority:M}}}else if(y.segment===null)c.warn(\"Stream\",\"Uninitialized index without an initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else if(y.isLoaded)c.warn(\"Stream\",\"Uninitialized index with an already loaded initialization segment\",{bufferType:b,representationBitrate:n.representation.bitrate});else{let M=A.position.getWanted();q={segment:y.segment,priority:Rn(d.start,M)}}let B=a.getValue();if(B===null)E.setValue({initSegment:q,segmentQueue:D});else if(B.urgent){c.debug(\"Stream\",\"Urgent switch, terminate now.\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.setValue({initSegment:null,segmentQueue:[]}),E.finish(),g.cancel(B.reason),o.terminating();return}else{let M=D[0],w=i.getRequestedInitSegment(),U=i.getRequestedMediaSegment(),H=U===null||M===void 0||U.id!==M.segment.id?[]:[M],$=w===null?null:q;if(E.setValue({initSegment:$,segmentQueue:H}),H.length===0&&$===null){c.debug(\"Stream\",\"No request left, terminate\",{bufferType:b,representationBitrate:n.representation.bitrate}),E.finish(),g.cancel(B.reason),o.terminating();return}}if(o.streamStatusUpdate({period:d,position:A.position.getWanted(),bufferType:b,imminentDiscontinuity:N.imminentDiscontinuity,isEmptyStream:!1,hasFinishedLoading:N.hasFinishedLoading,neededSegments:N.neededSegments}),g.signal.isCancelled())return;let{UPTO_CURRENT_POSITION_CLEANUP:_}=L.getCurrent();if(N.isBufferFull){let M=Math.max(0,k-_);M>0&&r.removeBuffer(0,M).catch(x)}N.shouldRefreshManifest&&o.needsManifestRefresh()}function P(A){if(R.onNewProtectionData(A.protectionData),A.segmentType===\"init\"){if(!f.index.isInitialized()&&A.segmentList!==void 0&&f.index.initialize(A.segmentList),y.isLoaded=!0,A.initializationData!==null){let k=f.uniqueId;y.uniqueId=k,r.declareInitSegment(k,A.initializationData),Oi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:k,segment:A.segment,segmentData:A.initializationData,segmentSink:r},g.signal).then(N=>{N!==null&&o.addedSegment(N)}).catch(x)}C();return}else{let{inbandEvents:k,predictedSegments:N,needsManifestRefresh:D}=A;if(N!==void 0&&f.index.addPredictedSegments(N,A.segment),D===!0&&(o.needsManifestRefresh(),g.isUsed())||k!==void 0&&k.length>0&&(o.inbandEvent(k),g.isUsed()))return;let q=y.uniqueId;wi({playbackObserver:t,bufferGoal:l,content:n,initSegmentUniqueId:q,parsedSegment:A,segment:A.segment,segmentSink:r},g.signal).then(B=>{B!==null&&o.addedSegment(B)}).catch(x)}}function x(A){g.isUsed()&&A instanceof oe||(c.warn(\"Stream\",\"Received fatal buffer error\",{bufferType:b,representationBitrate:n.representation.bitrate},A instanceof Error?A:null),g.cancel(\"RepresentationStream: fatal buffer err\"),o.error(A))}}var rs=Di;function Bi(n,e,t,r,i){var m,p,h,b;if(t.switchingMode===\"lazy\")return{type:\"continue\",value:void 0};let a=r.getLastKnownInventory(),o=[];for(let g of a)g.infos.period.id===n.id&&(g.infos.adaptation.id!==e.id||!ue(t.representationIds,g.infos.representation.id))&&It(o,{start:(m=g.bufferedStart)!=null?m:g.start,end:(p=g.bufferedEnd)!=null?p:g.end});let s=r.getPendingOperations();for(let g of s)if(g.type===0){let y=g.value.inventoryInfos;if(y.period.id===n.id&&(y.adaptation.id!==e.id||!ue(t.representationIds,y.representation.id))){let T=y.segment.time,R=T+y.segment.duration;It(o,{start:T,end:R})}}if(o.length===0)return{type:\"continue\",value:void 0};if(t.switchingMode===\"reload\"){let g=i.getReadyState();if(g===void 0||g>1)return{type:\"needs-reload\",value:void 0}}let d=t.switchingMode===\"direct\",u=[],f=qt(a,n);if(f!==null&&(f.bufferedEnd===void 0||n.start-f.bufferedEnd<1)&&u.push({start:0,end:n.start+1}),!d){let{ADAP_REP_SWITCH_BUFFER_PADDINGS:g}=L.getCurrent(),y=e.type,T=(h=g[y].before)!=null?h:0,R=(b=g[y].after)!=null?b:0,E=i.getCurrentTime();E===void 0&&(E=i.getReference().getValue().position.getPolled()),u.push({start:E-T,end:E+R})}if(n.end!==void 0){let g=Wt(a,n);g!==null&&(g.bufferedStart===void 0||g.bufferedStart-n.end<1)&&u.push({start:n.end-1,end:Number.MAX_VALUE})}let l=Ar(o,u);return l.length===0?{type:\"continue\",value:void 0}:d?{type:\"flush-buffer\",value:l}:{type:\"clean-buffer\",value:l}}function Ni({playbackObserver:n,content:e,options:t,representationEstimator:r,segmentSink:i,segmentQueueCreator:a,wantedBufferAhead:o,maxVideoBufferSize:s},d,u){let{manifest:f,period:l,adaptation:m}=e,p=new z(\"AdaptationStream \"+m.type);p.linkToSignal(u);let h=new Map,b=new X(null,p.signal),g,y=e.representations.getValue().representationIds,T=is(e.adaptation.representations,y),R=new X(T,p.signal),{estimates:E,callbacks:C}=r({manifest:f,period:l,adaptation:m},b,R,n,p.signal),P=new X(!1);n.listen(_=>{var w;let M=(w=_.canStream)!=null?w:!0;P.getValue()===M&&(c.debug(\"Stream\",\"isMediaSegmentQueueInterrupted updated to\",!M),P.setValue(!M))},{clearSignal:p.signal});let x=a.createSegmentQueue(m.type,{onRequestBegin:C.requestBegin,onRequestEnd:C.requestEnd,onProgress:C.requestProgress,onMetrics:C.metrics},P),A=new X(0);E.onUpdate(({bitrate:_,knownStableBitrate:M})=>{t.enableFastSwitching&&A.setValueIfChanged(M),!(_===void 0||_===g)&&(g=_,c.debug(\"Stream\",`new ${m.type} bitrate estimate received from ABR`,{bitrate:_}),d.bitrateEstimateChange({type:m.type,bitrate:_}))},{emitCurrentValue:!0,clearSignal:p.signal});let k;e.representations.onUpdate(_=>{k!==void 0&&k.cancel(\"locked representations changed\");let M=e.representations.getValue().representationIds,w=is(e.adaptation.representations,M);R.setValueIfChanged(w),k=new z(\"AdaptationStream: RepresentationStream Group \"+m.type),k.linkToSignal(p.signal),N(_,k.signal).catch(U=>{(k==null?void 0:k.isUsed())===!0&&z.isCancellationError(U)||(p.cancel(\"RepresentationStream err\"),d.error(U))})},{clearSignal:p.signal,emitCurrentValue:!0});return;async function N(_,M){let w=Bi(l,m,_,i,n);switch(w.type){case\"continue\":break;case\"needs-reload\":return rt(()=>{n.listen(()=>{if(M.isCancelled())return;let{DELTA_POSITION_AFTER_RELOAD:U}=L.getCurrent(),H=U.bitrateSwitch;return d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:H,stayInPeriod:!0})},{includeLastObservation:!0,clearSignal:M})});case\"flush-buffer\":case\"clean-buffer\":for(let U of w.value)if(await i.removeBuffer(U.start,U.end),M.isCancelled())return;if(w.type===\"flush-buffer\"&&(d.needsBufferFlush(),M.isCancelled()))return;break;default:Be(w)}D(M)}function D(_){let M=new z(\"AdaptationStream: RepresentationStream creation \"+m.type);M.linkToSignal(_);let{representation:w}=E.getValue();if(w===null)return;let U=new X(null,M.signal);E.onUpdate(V=>{if(!(V.representation===null||V.representation.id===w.id))return V.urgent?(c.info(\"Stream\",\"urgent Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!0,reason:\"Urgent Representation switch\"})):(c.info(\"Stream\",\"slow Representation switch\",{bufferType:m.type,estimateBitrate:V.bitrate,prevRepresentationBitrate:w.bitrate,newRepresentationBitrate:V.representation.bitrate}),U.setValue({urgent:!1,reason:\"Non-urgent Representation switch\"}))},{clearSignal:M.signal,emitCurrentValue:!0});let H={type:m.type,adaptation:m,period:l,representation:w};if(b.setValue(w),_.isCancelled()||(d.representationChange(H),_.isCancelled()))return;let $={streamStatusUpdate:d.streamStatusUpdate,encryptionDataEncountered:d.encryptionDataEncountered,manifestMightBeOufOfSync:d.manifestMightBeOufOfSync,needsManifestRefresh:d.needsManifestRefresh,inbandEvent:d.inbandEvent,warning:d.warning,error(V){p.cancel(\"RepresentationStream err cb\"),d.error(V)},addedSegment(V){C.addedSegment(V)},terminating(){if(!M.isUsed())return M.cancel(\"RepresentationStream terminating\"),D(_)}};q(w,U,$,_)}function q(_,M,w,U){let H=!1,$=new z(`RepresentationStream-linked listeners in AdaptationStream - periodStart=${l.start} type=${m.type}`);$.linkToSignal(U);let V=tn(o,me=>B(_,me),$.signal),G=m.type===\"video\"?s:new X(1/0);c.info(\"Stream\",\"changing representation\",{bufferType:m.type,representationId:_.id,representationBitrate:_.bitrate});let Y=K({},w,{error(me){var ce;if(H){c.warn(\"Stream\",\"Ignoring RepresentationStream error\",me);return}H=!0;let le=pe(me,{defaultCode:\"NONE\",defaultReason:\"Unknown `RepresentationStream` error\"});if(le.code!==\"BUFFER_FULL_ERROR\")w.error(me);else{c.warn(\"Stream\",\"received BUFFER_FULL_ERROR\",{bufferType:m.type,representationBitrate:_.bitrate});let Qe=o.getValue(),ae=((ce=h.get(_.id))!=null?ce:1)*.7;if(h.set(_.id,ae),ae<=.05||B(_,Qe)<=2){w.error(le);return}ln(4e3,$.signal).then(()=>q(_,M,w,U)).catch(O)}},terminating(){$.cancel(\"Representation terminating\"),w.terminating()}});rs({playbackObserver:n,content:{representation:_,adaptation:m,period:l,manifest:f},segmentSink:i,segmentQueue:x,terminate:M,options:{bufferGoal:V,maxBufferSize:G,drmSystemId:t.drmSystemId,fastSwitchThreshold:A}},Y,U),f.addEventListener(\"manifestUpdate\",me=>{for(let le of me.updatedPeriods)if(le.period.id===l.id){for(let ce of le.result.updatedAdaptations)if(ce.adaptation===m.id){for(let Qe of ce.removedRepresentations)if(Qe===_.id)return $.isUsed()?void 0:d.waitingMediaSourceReload({bufferType:m.type,period:l,timeOffset:0,stayInPeriod:!0})}}else if(le.period.start>l.start)break},$.signal)}function B(_,M){let w=h.get(_.id),U=w!==void 0?w:1;return w===void 0&&h.set(_.id,U),U<1&&M===1/0?300*1e3*U:M*U}}function is(n,e){let t=n.filter(r=>ue(e,r.id)&&!r.shouldBeAvoided&&r.isPlayable()!==!1);return t.length>0?t:n.filter(r=>ue(e,r.id)&&r.isPlayable()!==!1)}var as=Ni;function Ui(n,e,t,r,i,a){var p,h,b,g;if(n.codec!==void 0&&a.onCodecSwitch===\"reload\"&&!Lu(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&&It(s,{start:(p=y.bufferedStart)!=null?p:y.start,end:(h=y.bufferedEnd)!=null?h:y.end});let d=n.getPendingOperations();for(let y of d)if(y.type===0){let T=y.value.inventoryInfos;if(T.period.id===e.id&&T.adaptation.id!==t.id){let R=T.segment.time,E=R+T.segment.duration;It(s,{start:R,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 u=r===\"direct\",f=[],l=qt(o,e);if(l!==null&&(l.bufferedEnd===void 0||e.start-l.bufferedEnd<1)&&f.push({start:0,end:e.start+1}),!u){let y=t.type,{ADAP_REP_SWITCH_BUFFER_PADDINGS:T}=L.getCurrent(),R=(b=T[y].before)!=null?b:0,E=(g=T[y].after)!=null?g:0,C=i.getCurrentTime();C===void 0&&(C=i.getReference().getValue().position.getPolled()),f.push({start:C-R,end:C+E})}if(e.end!==void 0){let y=Wt(o,e);y!==null&&(y.bufferedStart===void 0||y.bufferedStart-e.end<1)&&f.push({start:e.end-1,end:Number.MAX_VALUE})}let m=Ar(s,f);return m.length===0?{type:\"continue\",value:void 0}:u&&t.type!==\"text\"?{type:\"flush-buffer\",value:m}:{type:\"clean-buffer\",value:m}}function Lu(n,e){return n.representations.some(t=>t.isPlayable()===!0&&Lo(t.getMimeTypeString(),e))}function Li({bufferType:n,content:e,garbageCollectors:t,playbackObserver:r,representationEstimator:i,segmentQueueCreator:a,segmentSinksStore:o,options:s,wantedBufferAhead:d,maxVideoBufferSize:u},f,l){let{manifest:m,period:p}=e,h=new X(void 0,l);if(f.periodStreamReady({type:n,manifest:m,period:p,adaptationRef:h}),l.isCancelled())return;let b,g=!0;h.onUpdate(R=>{(async()=>{var B;if(R===void 0)return;let E=new z(\"PeriodStream: Adaptation choice \"+n);if(E.linkToSignal(l),b==null||b.cancel(\"PeriodStream: Adaptation update\"),b=E,R===null){c.info(\"Stream\",\"Set no Adaptation\",{periodStart:p.start,bufferType:n});let _=o.getStatus(n);if(_.type===\"initialized\"){if(c.info(\"Stream\",\"Clearing previous SegmentSink\",{periodStart:p.start,bufferType:n}),bt.isNative(n))return T(0,!0,E.signal);{let M=(B=p.end)!=null?B:1/0;if(p.start>M)c.warn(\"Stream\",\"Can't free buffer: period's start is after its end\",{periodStart:p.start,periodEnd:M,bufferType:n});else if(await _.value.removeBuffer(p.start,M),E.isUsed())return}}else if(_.type===\"uninitialized\"&&(o.disableSegmentSink(n),E.isUsed()))return;return f.adaptationChange({type:n,adaptation:null,period:p}),E.isUsed()?void 0:os(r,d,n,{period:p},f,E.signal)}let C=p.adaptations[n],P=j(C!=null?C:[],_=>_.id===R.adaptationId);if(P===void 0){b.cancel(\"PeriodStream: Adaptation not found\"),c.warn(\"Stream\",\"Unfound chosen Adaptation choice\",{adaptationId:R.adaptationId});return}let{DELTA_POSITION_AFTER_RELOAD:x}=L.getCurrent(),A=!1,k;if(g)k=0;else if(R.relativeResumingPosition!==void 0)k=R.relativeResumingPosition;else switch(A=!0,n){case\"audio\":k=x.trackSwitch.audio;break;case\"video\":k=x.trackSwitch.video;break;default:k=x.trackSwitch.other;break}if(g=!1,bt.isNative(n)&&o.getStatus(n).type===\"disabled\")return T(k,!0,E.signal);m.addEventListener(\"manifestUpdate\",_=>{for(let M of _.updatedPeriods)if(M.period.id===p.id){for(let w of M.result.removedAdaptations)if(w.id===P.id)return T(k,!0,E.signal)}else if(M.period.start>p.start)break},b.signal);let{representations:N}=R;if(c.info(\"Stream\",\"Updating adaptation\",{bufferType:P.type,periodStart:p.start,adaptationId:P.id}),f.adaptationChange({type:n,adaptation:P,period:p}),E.isUsed())return;let D=Fu(o,n,P),q=Ui(D,p,P,R.switchingMode,r,s);if(q.type===\"needs-reload\")return T(k,!0,E.signal);if(await o.waitForUsableBuffers(E.signal),!E.isUsed()){if(q.type===\"flush-buffer\"||q.type===\"clean-buffer\"){for(let{start:_,end:M}of q.value)if(await D.removeBuffer(_,M),E.isUsed())return;if(q.type===\"flush-buffer\"&&(f.needsBufferFlush({relativeResumingPosition:k,relativePosHasBeenDefaulted:A}),E.isUsed()))return}t.get(D)(E.signal),y(P,N,D,E.signal)}})().catch(E=>{E instanceof oe||(b==null||b.cancel(\"PeriodStream err\"),f.error(E))})},{clearSignal:l,emitCurrentValue:!0});function y(R,E,C,P){let x=qu(r,R.type);as({content:{manifest:m,period:p,adaptation:R,representations:E},options:s,playbackObserver:x,representationEstimator:i,segmentSink:C,segmentQueueCreator:a,wantedBufferAhead:d,maxVideoBufferSize:u},se(J({},f),{error:A}),P);function A(k){if(!bt.isNative(n)){c.error(\"Stream\",`${n} Stream crashed. Aborting it.`,k instanceof Error?k:\"\"),o.disposeSegmentSink(n,\"AdaptationStream err\");let N=pe(k,{defaultCode:\"NONE\",defaultReason:\"Unknown `AdaptationStream` error\"});return f.warning(N),P.isCancelled()?void 0:os(r,d,n,{period:p},f,P)}c.error(\"Stream\",`${n} Stream crashed. Stopping playback.`,k instanceof Error?k:\"\"),f.error(k)}}function T(R,E,C){rt(()=>{r.listen(()=>{C.isCancelled()||f.waitingMediaSourceReload({bufferType:n,period:p,timeOffset:R,stayInPeriod:E})},{includeLastObservation:!0,clearSignal:C})})}}function Fu(n,e,t){let r=n.getStatus(e);if(r.type===\"initialized\")return c.info(\"Stream\",\"Reusing a previous SegmentSink for the type\",{bufferType:e}),r.value;let i=zu(t);return n.createSegmentSink(e,i)}function zu(n){let e=n.representations.filter(t=>t.isPlayable()!==!1);if(e.length>0)return e[0].getMimeTypeString();if(n.representations.length>0)return n.representations[0].getMimeTypeString();throw new Z(\"NO_PLAYABLE_REPRESENTATION\",\"No Representation in the chosen \"+n.type+\" Adaptation can be played\",{tracks:[vt(n)]})}function qu(n,e){return n.deriveReadOnlyObserver(function(r,i){let a=new X(o(),i);return r.onUpdate(s,{clearSignal:i,emitCurrentValue:!1}),a;function o(){let d=r.getValue(),u=d.buffered[e],f=u!==null?Cr(u,d.position.getWanted()):0;return K({},d,{bufferGap:f,buffered:u})}function s(){a.setValue(o())}})}function os(n,e,t,r,i,a){let{period:o}=r,s=!1;e.onUpdate(d,{emitCurrentValue:!1,clearSignal:a}),n.listen(d,{includeLastObservation:!1,clearSignal:a}),d();function d(){let u=n.getReference().getValue(),f=e.getValue(),l=u.position.getWanted();o.end!==void 0&&l+f>=o.end&&(c.debug(\"Stream\",'full \"empty\" AdaptationStream',{bufferType:t,periodEnd:o.end,position:l,wantedBufferAhead:f}),s=!0),i.streamStatusUpdate({period:o,bufferType:t,imminentDiscontinuity:null,position:l,isEmptyStream:!0,hasFinishedLoading:s,neededSegments:[]})}}var ss=Li;function Or(n,e){if(e.length===0)return[];let t=[],r=n.getLastKnownInventory(),i=n.getPendingOperations();for(let a of r)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:d}=a;if(s===void 0||d===void 0)return c.warn(\"Stream\",\"No buffered start or end found from a segment.\",{bufferType:a.infos.adaptation.type,segmentStart:a.infos.segment.time}),[{start:0,end:Number.MAX_VALUE}];let u=t[t.length-1];u!==void 0&&u.end===s?u.end=d:t.push({start:s,end:d})}for(let a of i){if(a.type!==0)continue;let o=a.value;e.some(d=>o.inventoryInfos.period.id===d.period.id&&o.inventoryInfos.adaptation.id===d.adaptation.id&&o.inventoryInfos.representation.id===d.representation.id)&&It(t,{start:o.inventoryInfos.start,end:o.inventoryInfos.end})}return t}function Fi(n,e,t,r,i,a,o,s){let{manifest:d,initialPeriod:u}=n,{maxBufferAhead:f,maxBufferBehind:l,wantedBufferAhead:m,maxVideoBufferSize:p}=a,{MINIMUM_MAX_BUFFER_AHEAD:h,MAXIMUM_MAX_BUFFER_AHEAD:b,MAXIMUM_MAX_BUFFER_BEHIND:g}=L.getCurrent(),y=new In(E=>{var A,k;let{bufferType:C}=E,P=(A=g[C])!=null?A:1/0,x=(k=b[C])!=null?k:1/0;return N=>{xr({segmentSink:E,playbackObserver:e,maxBufferBehind:tn(l,D=>Math.min(D,P),N),maxBufferAhead:tn(f,D=>{var B;let q=Math.max(D,(B=h[C])!=null?B:0);return Math.min(q,x)},N)},N)}});for(let E of r.getBufferTypes())T(E,u);function T(E,C){let P=new kt((q,B)=>q.start-B.start),x=!1,A=new z(\"StreamOrchestrator Streams for \"+E);return A.linkToSignal(s),e.listen(({position:q})=>{let B=q.getWanted();if(!x||!N(B))return;let _=()=>{var w;return(w=d.getPeriodForTime(B))!=null?w:d.getNextPeriod(B)},M=_();if(!(!v(M)&&P.has(M))){for(c.info(\"Stream\",\"Destroying all PeriodStreams due to out of bounds situation\",{bufferType:E,time:B}),x=!1;P.length()>0;){let w=P.get(P.length()-1);P.removeElement(w),o.periodStreamCleared({type:E,manifest:d,period:w})}if(A.cancel(\"PeriodStream is out of bounds\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s),M=_(),M===void 0){c.warn(\"Stream\",\"The wanted position is not found in the Manifest.\"),x=!0;return}k(M)}},{clearSignal:s,includeLastObservation:!0}),d.addEventListener(\"decipherabilityUpdate\",q=>{s.isCancelled()||D(q).catch(B=>{s.isCancelled()||(A.cancel(\"decipherabilityUpdate event\"),o.error(B))})},s),k(C);function k(q){let B=se(J({},o),{waitingMediaSourceReload(_){let M=P.head();M===void 0||M.id!==_.period.id?o.lockedStream({bufferType:_.bufferType,period:_.period}):o.needsMediaSourceReload({timeOffset:_.timeOffset,minimumPosition:_.stayInPeriod?_.period.start:void 0,maximumPosition:_.stayInPeriod?_.period.end:void 0})},periodStreamReady(_){x=!0,P.add(_.period),o.periodStreamReady(_)},periodStreamCleared(_){P.removeElement(_.period),o.periodStreamCleared(_)},error(_){A.cancel(\"PeriodStream err callback\"),o.error(_)}});R(E,q,B,A.signal)}function N(q){let B=P.head(),_=P.last();return B===void 0||_===void 0?!0:B.start>q||(v(_.end)?1/0:_.end)<q}async function D(q){let B=r.getStatus(E),_=q.filter(V=>V.adaptation.type===E);if(_.length===0||B.type!==\"initialized\"||_.every(V=>V.representation.decipherable===!0))return;let M=B.value,w=_.filter(V=>V.representation.decipherable===void 0),U=_.filter(V=>V.representation.decipherable===!1),H=Or(M,U),$=Or(M,w);for(x=!1,c.info(\"Stream\",\"Destroying all PeriodStreams for decipherability matters\",{bufferType:E});P.length()>0;){let V=P.get(P.length()-1);P.removeElement(V),o.periodStreamCleared({type:E,manifest:d,period:V})}A.cancel(\"decipherability update\"),A=new z(\"StreamOrchestrator Streams for \"+E),A.linkToSignal(s);for(let{start:V,end:G}of[...H,...$]){if(s.isCancelled())return;if(V<G){if(s.isCancelled())return;await M.removeBuffer(V,G)}}rt(()=>{if(s.isCancelled())return;let V=e.getReference().getValue();if(ds(V,H)){if(o.needsDecipherabilityFlush(),s.isCancelled())return}else if(ds(V,$)&&(o.needsBufferFlush(),s.isCancelled()))return;let G=V.position.getWanted(),Y=d.getPeriodForTime(G);if(Y===void 0&&(Y=d.getNextPeriod(G),c.warn(\"Stream\",\"No Period found for the reloading position, selecting next one instead\",{reloadPosition:G,nextPeriodStart:Y==null?void 0:Y.start})),Y===void 0&&(Y=d.periods[d.periods.length-1],c.warn(\"Stream\",\"No Period found for of after the reloading position, selecting the last one\",{reloadPosition:G,nextPeriodStart:Y==null?void 0:Y.start,nextPeriodEnd:Y==null?void 0:Y.end})),Y===void 0){o.error(new Z(\"MEDIA_TIME_NOT_FOUND\",\"The wanted position is not found in the Manifest.\"));return}k(Y)})}}function R(E,C,P,x){c.info(\"Stream\",\"Creating new PeriodStream\",{bufferType:E,periodStart:C.start});let A=null,k=new z(\"StreamOrchestrator current consecutive Streams \"+E);k.linkToSignal(x),e.listen(({position:_},M)=>{if(C.end!==void 0&&_.getWanted()>=C.end){let w=d.getPeriodAfter(C);if(C.containsTime(_.getWanted(),w))return;c.info(\"Stream\",\"Destroying PeriodStream as the current playhead moved above it\",{bufferType:E,periodStart:C.start,periodEnd:C.end,position:_.getWanted()}),M(),P.periodStreamCleared({type:E,manifest:d,period:C}),k.cancel(\"Position ahead of PeriodStream\")}},{clearSignal:x,includeLastObservation:!0});let N={bufferType:E,content:{manifest:d,period:C},garbageCollectors:y,maxVideoBufferSize:p,segmentQueueCreator:i,segmentSinksStore:r,options:a,playbackObserver:e,representationEstimator:t,wantedBufferAhead:m},D=se(J({},P),{streamStatusUpdate(_){if(_.hasFinishedLoading){let M=d.getPeriodAfter(C);M!==null&&q(M)}else A!==null&&(c.info(\"Stream\",\"Destroying next PeriodStream due to current one being active\",{bufferType:E,periodStart:C.start,nextPeriodStart:A.period.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"previous PeriodStream is active\"),A=null);P.streamStatusUpdate(_)},error(_){A!==null&&(A.canceller.cancel(\"previous PeriodStream err\"),A=null),k.cancel(\"PeriodStream err\"),P.error(_)}});ss(N,D,k.signal),B(k.signal);function q(_){if(A!==null){if(A.period.id===_.id)return;c.warn(\"Stream\",\"Creating next `PeriodStream` while one was already created.\",{bufferType:E,nextPeriodStart:_.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"PeriodStream recreation\")}let M=new z(\"StreamOrchestrator next PeriodStream \"+E);M.linkToSignal(x),A={canceller:M,period:_},R(E,_,P,A.canceller.signal)}function B(_){d.addEventListener(\"manifestUpdate\",M=>{for(let w of M.removedPeriods)if(w.id===C.id){if(d.periods.length>0&&d.periods[0].start<=w.start)return rt(()=>{if(!_.isCancelled())return o.needsMediaSourceReload({timeOffset:0,minimumPosition:void 0,maximumPosition:void 0})})}else if(w.start>C.start)break;if(M.addedPeriods.length>0&&A!==null){let w=d.getPeriodAfter(C);(w===null||A.period.id!==w.id)&&(c.warn(\"Stream\",\"Destroying next PeriodStream due to new one being added\",{bufferType:E,nextPeriodStart:A.period.start}),P.periodStreamCleared({type:E,manifest:d,period:A.period}),A.canceller.cancel(\"Next Period changed\"),A=null)}},_)}}}function ds(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 us=Fi;var ls=us;function zi(n,e){if(typeof n.changeType==\"function\"){try{n.changeType(e)}catch(t){return c.warn(\"mse\",\"Could not call 'changeType' on the given SourceBuffer:\",t instanceof Error?t:\"\"),!1}return!0}return!1}function Wu(n){let e=[];for(let t=0;t<n.length;t++){let r=n[t];r.updating&&e.push(r)}return e}function vn(n,e){if(c.debug(\"mse\",\"Trying to call endOfStream\"),n.readyState!==\"open\"){c.debug(\"mse\",\"MediaSource not open, cancel endOfStream\");return}let{sourceBuffers:t}=n,r=Wu(t);if(r.length===0){c.info(\"mse\",\"Triggering end of stream\");try{n.endOfStream()}catch(a){c.error(\"mse\",\"Unable to call endOfStream\",a instanceof Error?a:new Error(\"Unknown error\"))}return}c.debug(\"mse\",\"Waiting SourceBuffers to be updated before calling endOfStream.\");let i=new z(\"EndOfStream current iteration\");i.linkToSignal(e);for(let a of r)vo(a,()=>{i.cancel(\"SourceBuffer update\"),vn(n,e)},i.signal);Co(t,()=>{i.cancel(\"SourceBuffer remove\"),vn(n,e)},i.signal)}function fs(n,e){let t=new z(\"EndOfStream\");t.linkToSignal(e),Ft(n,()=>{c.debug(\"mse\",\"MediaSource re-opened while end-of-stream is active\"),t.cancel(\"MediaSource re-opened\"),t=new z(\"EndOfStream\"),t.linkToSignal(e),vn(n,t.signal)},e),vn(n,t.signal)}function qi(){let{FORCE_HAS_ISSUES_WITH_HIGH_MEDIA_SOURCE_DURATION:n}=L.getCurrent();return n||ci.device===ci.DEVICES.PlayStation5}var Vu=365*24*3600,Cn=class{constructor(e){this._mediaSource=e,this._currentMediaSourceDurationUpdateCanceller=null}updateDuration(e,t){this._currentMediaSourceDurationUpdateCanceller!==null&&this._currentMediaSourceDurationUpdateCanceller.cancel(\"manual duration update\"),this._currentMediaSourceDurationUpdateCanceller=new z(\"MediaSource Duration Update\");let r=this._mediaSource,i=this._currentMediaSourceDurationUpdateCanceller.signal,a=Ku(r,i),o=new z(void 0);o.linkToSignal(i),a.onUpdate(s,{emitCurrentValue:!0,clearSignal:i});function s(){if(o.cancel(\"MediaSource open status changed\"),!a.getValue())return;o=new z(void 0),o.linkToSignal(i);let d=Hu(r.sourceBuffers,o.signal),u=new z(void 0);return u.linkToSignal(o.signal),d.onUpdate(f=>{u.cancel(\"SourceBuffer status update\"),u=new z(void 0),u.linkToSignal(o.signal),!f&&cs(r,e,t,u.signal)},{clearSignal:o.signal,emitCurrentValue:!0})}}stopUpdating(e){this._currentMediaSourceDurationUpdateCanceller!==null&&(this._currentMediaSourceDurationUpdateCanceller.cancel(e!=null?e:\"stop MSDU\"),this._currentMediaSourceDurationUpdateCanceller=null)}};function Gu(n,e,t){let r=e;t||(r=qi()?1/0:ms(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(i,o.buffered.end(s-1)))}if(r===n.duration)return\"success\";if(i>r){if(i<n.duration)try{c.info(\"mse\",\"Updating duration to what is currently buffered\",{maxBufferedEnd:i}),n.duration=i}catch(a){return c.warn(\"mse\",\"Can't update duration on the MediaSource.\",a instanceof Error?a:\"\"),\"failed\"}return\"partial\"}else{let a=n.duration;try{if(c.info(\"mse\",\"Updating duration\",{newDuration:r}),n.duration=r,n.readyState===\"open\"&&!isFinite(r)){let s=ms(e);c.info(\"mse\",\"calling `mediaSource.setLiveSeekableRange`\",{maxSeekable:s}),n.setLiveSeekableRange(0,s)}}catch(s){return c.warn(\"mse\",\"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 Hu(n,e){if(n.length===0){let i=new X(!1);return i.finish(),i}let t=new X(!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 Ku(n,e){let t=new X(n.readyState===\"open\",e);return Ft(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource open in duration updater\"),t.setValueIfChanged(!0)},e),Tr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource ended in duration updater\"),t.setValueIfChanged(!1)},e),Sr(n,()=>{c.debug(\"mse\",\"Reacting to MediaSource close in duration updater\"),t.setValueIfChanged(!1)},e),t}function cs(n,e,t,r){if(Gu(n,e,t)===\"success\")return;let a=setTimeout(()=>{o(),cs(n,e,t,r)},2e3),o=r.register(()=>{clearTimeout(a)})}function ms(n){return Math.max(Math.pow(2,32),n+Vu)}var An=class extends fe{constructor(e,t){if(super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"MainMediaSourceInterface\"),v(mt))throw new Z(\"MEDIA_SOURCE_NOT_SUPPORTED\",\"No MediaSource Object was found in the current browser.\");c.info(\"mse\",\"Creating MediaSource\");let r=t!==void 0?new t:new mt,i=r.handle;this.handle=v(i)?{type:\"media-source\",value:r}:{type:\"handle\",value:i},this._mediaSource=r,this.readyState=r.readyState,this._durationUpdater=new Cn(r),this._endOfStreamCanceller=null,Ft(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceOpen\",null)},this._canceller.signal),Tr(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceEnded\",null)},this._canceller.signal),Sr(r,()=>{this.readyState=r.readyState,this.trigger(\"mediaSourceClose\",null)},this._canceller.signal),this._mediaSource.streaming!==void 0&&(this.streaming=this._mediaSource.streaming),this._mediaSource.addEventListener(\"startstreaming\",()=>{this.streaming=!0,this.trigger(\"streamingChanged\",null)}),this._mediaSource.addEventListener(\"endstreaming\",()=>{this.streaming=!1,this.trigger(\"streamingChanged\",null)})}addSourceBuffer(e,t){let r=this._mediaSource.addSourceBuffer(t),i=new Wi(e,t,r);return this.sourceBuffers.push(i),i}setDuration(e,t){this._durationUpdater.updateDuration(e,t)}interruptDurationSetting(e){this._durationUpdater.stopUpdating(e)}maintainEndOfStream(){this._endOfStreamCanceller===null&&(this._endOfStreamCanceller=new z(\"MainMediaSourceInterface EndOfStream\"),this._endOfStreamCanceller.linkToSignal(this._canceller.signal),c.debug(\"mse\",\"end-of-stream order received.\"),fs(this._mediaSource,this._endOfStreamCanceller.signal))}stopEndOfStream(){this._endOfStreamCanceller!==null&&(c.debug(\"mse\",\"resume-stream order received.\"),this._endOfStreamCanceller.cancel(\"MediaSourceInterface stopEndOfStream\"),this._endOfStreamCanceller=null)}dispose(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(e!=null?e:\"MainMediaSourceInterface dispose\"),ju(this._mediaSource)}},Wi=class{constructor(e,t,r){this.type=e,this.codec=t,this._canceller=new z(\"MainSourceBufferInterface \"+e),this._sourceBuffer=r,this._operationQueue=[],this._currentOperations=[];let i=this._onError.bind(this),a=this._onUpdateEnd.bind(this);r.addEventListener(\"updateend\",a),r.addEventListener(\"error\",i),this._canceller.signal.register(()=>{r.removeEventListener(\"updateend\",a),r.removeEventListener(\"error\",i)})}appendBuffer(...e){return c.debug(\"mse\",\"receiving order to push data to the SourceBuffer\",{type:this.type}),this._addToQueue({operationName:0,params:e})}remove(e,t){return c.debug(\"mse\",\"receiving order to remove data from the SourceBuffer\",{type:this.type,start:e,end:t}),this._addToQueue({operationName:1,params:[e,t]})}getBuffered(){try{return Ci(this._sourceBuffer.buffered)}catch(e){return c.error(\"mse\",\"Failed to get buffered time range of SourceBuffer\",{type:this.type},e instanceof Error?e:\"Unknown Error\"),[]}}abort(e){try{this._sourceBuffer.abort()}catch(t){c.debug(\"mse\",\"Failed to abort SourceBuffer:\",t instanceof Error?t:\"Unknown Error\")}this._emptyCurrentQueue(e)}dispose(e){try{this._sourceBuffer.abort()}catch(t){}this._emptyCurrentQueue(e)}_onError(e){let t;e instanceof Error?t=e:e.error instanceof Error?t=e.error:t=new Error(\"Unknown SourceBuffer Error\");let r=this._currentOperations;if(this._currentOperations=[],r.length===0)c.error(\"mse\",\"error for an unknown operation\",t);else{let i=new xe(t.name,t.message,t.name===\"QuotaExceededError\");for(let a of r)a.reject(i)}}_onUpdateEnd(){let e=this._currentOperations;this._currentOperations=[];try{for(let t of e)t.resolve(Ci(this._sourceBuffer.buffered))}catch(t){for(let r of e)t instanceof Error&&t.name===\"InvalidStateError\"?r.resolve([]):r.reject(t)}this._performNextOperation()}_emptyCurrentQueue(e){let t=new oe(\"MainSourceBufferInterface queue \"+this.type,e);this._currentOperations.length>0&&(this._currentOperations.forEach(r=>{r.reject(t)}),this._currentOperations=[]),this._operationQueue.length>0&&(this._operationQueue.forEach(r=>{r.reject(t)}),this._operationQueue=[])}_addToQueue(e){return new Promise((t,r)=>{let i=this._operationQueue.length===0&&this._currentOperations.length===0,a=K({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],d=e.params[1],u=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 m=this._operationQueue[0],p=(r=d.appendWindow)!=null?r:[void 0,void 0],h=(i=m.params[1].appendWindow)!=null?i:[void 0,void 0],b=(a=d.timestampOffset)!=null?a:0,g=(o=m.params[1].timestampOffset)!=null?o:0;if(p[0]===h[0]&&p[1]===h[1]&&d.codec===m.params[1].codec&&b===g){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(\"mse\",`: Merging ${l.length} segments together for perf`,{type:this.type}),u=At(...l).buffer)}try{this._appendBufferNow(u,d)}catch(f){let l=f instanceof Error?new xe(f.name,f.message,f.name===\"QuotaExceededError\"):new xe(\"Error\",\"Unknown SourceBuffer Error during appendBuffer\",!1);this._currentOperations.forEach(m=>{m.reject(l)}),this._currentOperations=[],this._performNextOperation()}}else{this._currentOperations=[e];let[s,d]=e.params;c.debug(\"mse\",\"removing data from SourceBuffer\",{type:this.type,start:s,end:d});try{this._sourceBuffer.remove(s,d)}catch(u){let f=u instanceof Error?new xe(u.name,u.message,!1):new xe(\"Error\",\"Unknown SourceBuffer Error during remove\",!1);e.reject(f),this._currentOperations.forEach(l=>{l.reject(f)}),this._currentOperations=[],this._performNextOperation()}}}_appendBufferNow(e,t){let r=this._sourceBuffer,{codec:i,timestampOffset:a,appendWindow:o=[]}=t;if(i!==void 0&&i!==this.codec&&(c.debug(\"mse\",\"updating codec\",{type:this.type,prevCodec:this.codec,newCodec:i}),zi(r,i)?this.codec=i:c.debug(\"mse\",\"could not update codec\",{type:this.type,prevCodec:this.codec,newCodec:i})),a!==void 0&&r.timestampOffset!==a){let s=a;c.debug(\"mse\",\"updating timestampOffset\",{type:this.type,codec:i,prevTimestampOffset:r.timestampOffset,newTimestampOffset:s}),r.timestampOffset=s}if(o[0]===void 0)r.appendWindowStart>0&&(c.debug(\"mse\",\"re-setting `appendWindowStart`\",{type:this.type,prevWindowStart:r.appendWindowStart}),r.appendWindowStart=0);else if(o[0]!==r.appendWindowStart){if(o[0]>=r.appendWindowEnd){let s=o[0]+1;c.debug(\"mse\",\"pre-updating `appendWindowEnd`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:s}),r.appendWindowEnd=s}c.debug(\"mse\",\"setting `appendWindowStart`\",{type:this.type,appendWindowStart:o[0]}),r.appendWindowStart=o[0]}o[1]===void 0?r.appendWindowEnd!==1/0&&(c.debug(\"mse\",\"re-setting `appendWindowEnd`\",{type:this.type,prevWindowStart:r.appendWindowStart}),r.appendWindowEnd=1/0):o[1]!==r.appendWindowEnd&&(c.debug(\"mse\",\"setting `appendWindowEnd`\",{type:this.type,prevWindowEnd:r.appendWindowEnd,newWindowEnd:o[1]}),r.appendWindowEnd=o[1]),c.debug(\"mse\",\"pushing segment\",{type:this.type}),r.appendBuffer(e)}};function ju(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(\"mse\",\"Aborting SourceBuffer before removing\");try{i.abort()}catch(a){}}c.info(\"mse\",\"Removing SourceBuffer from mediaSource\"),n.removeSourceBuffer(i)}catch(a){}}t.length>0&&c.info(\"mse\",\"Not all SourceBuffers could have been removed.\")}}var Yu=Me(),wr=Me(),ps=1/0,xn=class extends fe{constructor(e,t,r){super(),this.id=e,this.sourceBuffers=[],this._canceller=new z(\"WorkerMediaSourceInterface\"),this.readyState=\"closed\",this._messageSender=r;let i=Yu();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 Vi(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(e){this.sourceBuffers.forEach(t=>t.dispose(e)),this._canceller.cancel(\"WorkerMediaSourceInterface dispose\"),this._messageSender({type:\"dispose-media-source\",mediaSourceId:this.id,value:null})}},Vi=class{constructor(e,t,r,i){this.type=e,this.codec=t,this._canceller=new z(\"WorkerSourceBufferInterface \"+e),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(\"mse\",\"unknown SourceBuffer operation succeeded\",{type:this.type}):(this._pendingOperations.delete(e),r.resolve(t)),this._performNextQueuedOperationIfItExists()}onOperationFailure(e,t){let r=t.errorName===\"CancellationError\"?new oe(\"Pending SBI Operation \"+this.type,\"SBI Failure\"):new xe(t.errorName,t.message,t.isBufferFull),i=this._pendingOperations.get(e);i===void 0?c.info(\"mse\",\"unknown SourceBuffer operation failed\",{type:this.type},r):(this._pendingOperations.delete(e),i.reject(r));let a=new oe(\"Queued SBI Operation \"+this.type,\"SBI failure\");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>=ps){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>=ps){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(e){this.abort(),this._canceller.cancel(e!=null?e:\"WorkerSourceBufferInterface dispose\")}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 Gi(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 kn=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&&(c.debug(\"ABR\",\"New last stable representation\",{bitrate: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 gs=6e3,Qu=15e3,$u=3e3,Xu=1e3,Zu=9e3,Mn=class{constructor(e){this._levelsMap=Gi(e).map(t=>t+4),this._bitrates=e,this._lastUnsuitableQualityTimestamp=void 0,this._blockRaiseDelay=gs,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 d=-1;for(let h=0;h<r.length;h++){let b=r[h];if(b===a)d=h;else if(b>a)break}if(d<0||r.length!==t.length){c.info(\"ABR\",\"Current Bitrate not found in the calculated levels\"),this._currentEstimate=r[0];return}let u;o!==void 0&&(u=s===0?o.score:o.score/s);let f=isFinite(i)?i:0,l=F();if(f<t[d]||u!==void 0&&u<1&&(o==null?void 0:o.confidenceLevel)===1){if((this._lastUnsuitableQualityTimestamp===void 0?-1:l-this._lastUnsuitableQualityTimestamp)<this._blockRaiseDelay+Zu){let g=this._blockRaiseDelay+$u;c.debug(\"ABR\",\"Incrementing blocking raise in BufferBasedChooser due to unstable quality\",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.min(g,Qu)}else{let g=this._blockRaiseDelay-Xu;c.debug(\"ABR\",\"Lowering quality in BufferBasedChooser\",{prevDelay:this._blockRaiseDelay,newDelay:g}),this._blockRaiseDelay=Math.max(gs,g)}this._lastUnsuitableQualityTimestamp=l;let b=ne(r,g=>g===a);for(let g=b-1;g>=0;g--)if(f>=t[g]){this._currentEstimate=r[g];return}this._currentEstimate=r[0];return}if(this._lastUnsuitableQualityTimestamp!==void 0&&l-this._lastUnsuitableQualityTimestamp<this._blockRaiseDelay||u===void 0||u<1.15||(o==null?void 0:o.confidenceLevel)!==1){this._currentEstimate=a;return}let m=t[d],p=(()=>{for(let h=d+1;h<t.length;h++)if(t[h]>m)return h})();if(p!==void 0){let h=t[p];if(i>=h){c.debug(\"ABR\",\"Raising quality in BufferBasedChooser\",{bitrate:r[p]}),this._currentEstimate=r[p];return}}this._currentEstimate=a}getLastEstimate(){return this._currentEstimate}};function Ju(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 d=s.time+s.duration;if(!s.complete&&o===n.length-1&&e-s.time>-1.2){t=o;break}if(d>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 Dr(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 hs(n,e){let t=(n.totalSize-n.size)*8;return Math.max(t/e,0)}function el(n,e,t,r,i){if(r)return;let{bufferGap:a,speed:o,position:s}=e,d=isFinite(a)?a:0,u=s.getWanted()+d,f=Ju(n,u);if(f.length!==1)return;let l=f[0],m=F(),p=l.content.segment.duration*1.5;if(p=Math.min(p,3e3),p=Math.max(p,12e3),m-l.requestTimestamp<p)return;let h=l.progress.length>0?l.progress[l.progress.length-1]:void 0,b=Dr(l);if(h!==void 0&&b!==void 0){let C=hs(h,b);if((m-h.timestamp)/1e3<=C&&C-d/o>2500)return b}if(!l.content.segment.complete)return;let g=l.content.segment.duration,y=(m-l.requestTimestamp)/1e3,T=y<=(g*1.5+2)/o;if(v(t)||T)return;let R=g/y,E=t.bitrate*Math.min(.7,R);if(i===void 0||E<i)return E}function tl(n,e,t){if(t)return!0;let r=isFinite(n.bufferGap)?n.bufferGap:0,i=n.position.getWanted()+r,a=j(e,({content:l})=>l.segment.duration>0&&l.segment.time+l.segment.duration>i);if(a===void 0)return!0;let o=F(),s=a.progress.length>0?a.progress[a.progress.length-1]:void 0,d=Dr(a);if(s===void 0||d===void 0)return!0;let u=hs(s,d);return(o-s.timestamp)/1e3>u*1.2?!0:u-r/n.speed>-1.5}var On=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,d=this._config,{bufferGap:u,position:f,duration:l}=e,m=isFinite(u)?u:0,{ABR_STARVATION_DURATION_DELTA:p}=L.getCurrent();return isNaN(l)||m+f.getWanted()<l-p?!this._inStarvationMode&&m<=d.starvationGap?(c.info(\"ABR\",\"enter starvation mode.\",{buffergap:m,enterStarvation:d.starvationGap}),this._inStarvationMode=!0):this._inStarvationMode&&m>=d.outOfStarvationGap&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m,outOfStarvation:d.starvationGap}),this._inStarvationMode=!1):this._inStarvationMode&&(c.info(\"ABR\",\"exit starvation mode.\",{bufferGap:m}),this._inStarvationMode=!1),this._inStarvationMode&&(s=el(i,e,r,this._lowLatencyMode,a),s!==void 0&&(c.info(\"ABR\",\"starvation mode emergency estimate:\",{bandwidth:s}),t.reset(),o=v(r)?s:Math.min(s,r.bitrate))),v(o)&&(s=t.getEstimate(),s!==void 0?o=s*(this._inStarvationMode?d.starvationBitrateFactor:d.regularBitrateFactor):a!==void 0?o=a*(this._inStarvationMode?d.starvationBitrateFactor:d.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:tl(i,r,this._lowLatencyMode)}};var wn=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 Dn=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,d=this._lastAbrEstimate.representation;if(d===null)return null;if(i>d.bitrate)return this._lastAbrEstimate.algorithmType===2&&(this._lastAbrEstimate.representation!==null&&(this._lastMaintanableBitrate=this._lastAbrEstimate.representation.bitrate),this._consecutiveWrongGuesses=0),null;let u=this._scoreCalculator.getEstimate(r);if(this._lastAbrEstimate.algorithmType!==2){if(u===void 0)return null;if(this._canGuessHigher(o,s,u)){let l=Is(e,r);if(l!==null)return l}return null}if(this._isLastGuessValidated(d,i,u)&&(c.debug(\"ABR\",\"Guessed Representation validated\",{chosenBitrate:d.bitrate,otherAbrAlgosBitrate:i,scoreData:u==null?void 0:u.score,scoreConfidence:u==null?void 0:u.confidenceLevel}),this._lastMaintanableBitrate=d.bitrate,this._consecutiveWrongGuesses=0),r.id!==d.id)return d;if(this._shouldStopGuess(r,u,o,a))return this._consecutiveWrongGuesses++,this._blockGuessesUntil=F()+Math.min(this._consecutiveWrongGuesses*15e3,12e4),nl(e,r);if(u===void 0)return r;if(this._canGuessHigher(o,s,u)){let l=Is(e,r);if(l!==null)return l}return r}_canGuessHigher(e,t,{score:r,confidenceLevel:i}){return isFinite(e)&&e>=2.5&&F()>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=F();for(let s of a){let d=o-s.requestTimestamp;if(s.content.segment.isInit){if(d>1e3)return!0}else{if(d>s.content.segment.duration*1e3+200)return!0;{let u=Dr(s);if(u!==void 0&&u<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 Is(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 nl(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 Bn=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 Hi(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 Ki(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,d)=>{var u,f;return((u=s.width)!=null?u:0)-((f=d.width)!=null?f:0)}),a=j(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 Nn=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(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: progress for a request not added\");c.warn(\"ABR\",\"progress for a request not added\",{requestId:e.id});return}t.progress.push(e)}remove(e){if(v(this._currentRequests[e])){if(I.CURRENT_ENV===I.DEV)throw new Error(\"ABR: can't remove unknown request\");c.warn(\"ABR\",\"can't remove unknown request\",{requestId:e})}delete this._currentRequests[e]}getRequests(){return yr(this._currentRequests).filter(e=>!v(e)).sort((e,t)=>e.content.segment.time-t.content.segment.time)}};function Br(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 bs=new X(void 0);bs.finish();var ys=new X(1/0);ys.finish();function ji(n){let e={},{initialBitrates:t,throttlers:r,lowLatencyMode:i}=n;return function(s,d,u,f,l){var g,y,T;let{type:m}=s.adaptation,p=a(m),h=(g=t[m])!=null?g:0,b={limitResolution:(y=r.limitResolution[m])!=null?y:bs,throttleBitrate:(T=r.throttleBitrate[m])!=null?T:ys};return rl({bandwidthEstimator:p,context:s,currentRepresentation:d,filters:b,initialBitrate:h,playbackObserver:f,representations:u,lowLatencyMode:i},l)};function a(o){let s=e[o];if(v(s)){c.debug(\"ABR\",\"Creating new BandwidthEstimator\",{bufferType:o});let d=new Bn;return e[o]=d,d}return s}}function rl({bandwidthEstimator:n,context:e,currentRepresentation:t,filters:r,initialBitrate:i,lowLatencyMode:a,playbackObserver:o,representations:s},d){let u=new kn,f=new On(i!=null?i:0,a),l=new Nn,m=O,p={metrics:T,requestBegin:R,requestProgress:E,requestEnd:C,addedSegment(P){m(P)}},h=new z(\"ABR \"+e.adaptation.type);h.linkToSignal(d);let b=g(s.getValue(),h.signal);return s.onUpdate(y,{clearSignal:d}),{estimates:b,callbacks:p};function g(P,x){if(P.length<=1)return new X({bitrate:void 0,representation:P[0],urgent:!0,knownStableBitrate:void 0});let A=!1,k=P.sort((U,H)=>U.bitrate-H.bitrate),N=new Mn(k.map(U=>U.bitrate)),D=new wn,q=new Dn(u,D),B=o.getReference().getValue(),_=new X(w());return o.listen(U=>{B=U,M()},{includeLastObservation:!1,clearSignal:x}),m=function(U){if(B===null)return;let{position:H,speed:$}=B,V=U.buffered,G=Cr(V,H.getWanted()),{representation:Y}=U.content,me=u.getEstimate(Y),le=Y.bitrate,ce={bufferGap:G,currentBitrate:le,currentScore:me,speed:$};N.onAddedSegment(ce),M()},x.register(()=>{m=O}),r.throttleBitrate.onUpdate(M,{clearSignal:x}),r.limitResolution.onUpdate(M,{clearSignal:x}),_;function M(){_.setValue(w())}function w(){let{bufferGap:U,position:H,maximumPosition:$}=B,V=r.limitResolution.getValue(),G=r.throttleBitrate.getValue(),Y=t.getValue(),me=il(k,V,G),le=l.getRequests(),{bandwidthEstimate:ce,bitrateChosen:Qe}=f.getBandwidthEstimate(B,n,Y,le,D.bandwidth),te=u.getLastStableRepresentation(),ae=te===null?void 0:te.bitrate/(B.speed>0?B.speed:1),{ABR_ENTER_BUFFER_BASED_ALGO:Xt,ABR_EXIT_BUFFER_BASED_ALGO:Zt}=L.getCurrent();A&&U<=Zt?A=!1:!A&&isFinite(U)&&U>=Xt&&(A=!0);let _e=Br(me,Qe),Jt=N.getLastEstimate(),ur=_e.bitrate,ut=null;A&&Jt!==void 0&&Jt>ur&&(ut=Br(me,Jt),ur=ut.bitrate);let lt=null;return a&&Y!==null&&e.manifest.isDynamic&&$-H.getWanted()<40&&(lt=q.getGuess(k,B,Y,ur,le)),lt!==null&&lt.bitrate>ur?(c.debug(\"ABR\",\"new guess-based estimate\",{bitrate:lt.bitrate,representation:lt.id}),D.update(lt,ce,2),{bitrate:ce,representation:lt,urgent:Y===null||lt.bitrate<Y.bitrate,knownStableBitrate:ae}):ut!==null?(c.debug(\"ABR\",\"new buffer-based estimate\",{bitrate:ut.bitrate,representation:ut.id}),D.update(ut,ce,0),{bitrate:ce,representation:ut,urgent:f.isUrgent(ut.bitrate,Y,le,B),knownStableBitrate:ae}):(c.debug(\"ABR\",\"new bandwidth estimate\",{bitrate:_e.bitrate,representation:_e.id}),D.update(_e,ce,1),{bitrate:ce,representation:_e,urgent:f.isUrgent(_e.bitrate,Y,le,B),knownStableBitrate:ae})}}function y(){let P=s.getValue();h.cancel(\"restart\"),h=new z(\"ABR \"+e.adaptation.type),h.linkToSignal(d),g(P,h.signal).onUpdate(function(k){b.setValue(k)},{clearSignal:h.signal,emitCurrentValue:!0})}function T(P){let{requestDuration:x,segmentDuration:A,size:k,content:N}=P;if(n.addSample(x,k),!N.segment.isInit){let{segment:D,representation:q}=N;if(A===void 0&&!D.complete)return;let B=A!=null?A:D.duration;u.addSample(q,x/1e3,B)}}function R(P){l.add(P)}function E(P){l.addProgress(P)}function C(P){l.remove(P.id)}}function il(n,e,t){let r=n;return t!==void 0&&t<1/0&&(r=Hi(r,t)),e!==void 0&&(r=Ki(r,e)),r}var Ss=ji;function Nr(){var t;if(typeof((t=ee.crypto)==null?void 0:t.randomUUID)==\"function\")return ee.crypto.randomUUID();let n=new Date().getTime(),e=F();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 al=/^(?:[a-z]+:)?\\/\\//i,ol=/^(?:([^:/?#]+):)?(?:\\/\\/([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$/;function Qi(n){let e=n.lastIndexOf(\"/\");if(e<0)return n.length;if(al.test(n)){let r=n.indexOf(\"/\");if(r>=0&&e===r+1)return n.length}let t=n.indexOf(\"?\");return t>=0&&t<e?Qi(n.substring(0,t)):e+1}function Ts(n,e){let t=Ur(n),r=Ur(e);if(t.scheme!==r.scheme||t.authority!==r.authority||t.path[0]!==void 0&&t.path[0]!==\"/\"&&r.path[0]===\"/\"||r.path[0]!==void 0&&r.path[0]!==\"/\"&&t.path[0]===\"/\")return null;let i=Ln(t.path),a=Ln(r.path),o;if(i===a)o=\"\";else{let d=i.split(\"/\");d.pop();let u=a.split(\"/\");for(;d.length>0&&u.length>0&&d[0]===u[0];)d.shift(),u.shift();for(;d.length>0;)d.shift(),u.unshift(\"..\");let f=u.join(\"/\");(f.endsWith(\"../\")||f.endsWith(\"./\"))&&(f=f.slice(0,f.length-1)),o=f===\"\"?\".\":f}let s=o;return o===\"\"&&r.query===t.query||Q(r.query)&&(s+=\"?\",s+=r.query),Q(r.fragment)&&(s+=\"#\",s+=r.fragment),s}function sl(n,e){let t=Ur(n),r=Ur(e);if(Q(r.scheme))return Yi(r);let i={scheme:t.scheme,authority:t.authority,path:\"\",query:r.query,fragment:r.fragment};return Q(r.authority)?(i.authority=r.authority,i.path=Ln(r.path),Yi(i)):(r.path===\"\"?(i.path=t.path,Q(r.query)||(i.query=t.query)):Oe(r.path,\"/\")?i.path=Ln(r.path):i.path=Ln(ul(t,r.path)),Yi(i))}var Un=new Map,dl=200;function Ur(n){var r,i,a,o,s;if(Un.has(n))return Un.get(n);let e=n.match(ol),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:\"\"},Un.size>=dl&&Un.clear(),Un.set(n,t),t}function Yi(n){let e=\"\";return Q(n.scheme)&&(e+=n.scheme+\":\"),Q(n.authority)&&(e+=\"//\"+n.authority),e+=n.path,Q(n.query)&&(e+=\"?\"+n.query),Q(n.fragment)&&(e+=\"#\"+n.fragment),e}function Ln(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 ul(n,e){if(Q(n.authority)&&n.path===\"\")return\"/\"+e;let t=n.path;return t.substring(0,t.lastIndexOf(\"/\")+1)+e}function Fn(...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:\"\",d=sl(o,s),u=e.slice(2);return Fn(d,...u)}}var ll=4,zn=class{constructor(e){var t,r;this._sessionId=(t=e.sessionId)!=null?t:Nr(),this._contentId=(r=e.contentId)!=null?r:Nr(),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(\"CmcdDataBuilder start\"),this._canceller=new z(\"CMCD monitoring\"),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(\"CmcdDataBuilder stop\"),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,d,u;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}if(e.segment.isInit&&(r.ot=\"i\"),!v(e.nextSegment)&&e.segment.url!==null&&e.nextSegment.url!==null&&(!e.nextSegment.isInit||e.nextSegment.indexRange===void 0)){let f=e.segment.url,l=e.nextSegment.url,m=Ts(f,l);m!==null&&(m!==\".\"&&(r.nor=encodeURIComponent(m)),e.nextSegment.range!==void 0&&(r.nrr=String(e.nextSegment.range[0])+\"-\",isFinite(e.nextSegment.range[1])&&(r.nrr+=String(e.nextSegment.range[1]))))}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=(u=(d=(s=this._playbackObserver)==null?void 0:s.getCurrentTime())!=null?d:t.position.getWanted())!=null?u:t.position.getPolled();for(let m of f)if(l>=m.start&&l<m.end){i=(m.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*ll/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.isPlayable()!==!0?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=(u,f)=>{this._typePreference===0?t[f]+=u:r+=u},a=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${String(l)},`;i(m,f)}},o=(u,f)=>{if(e[u]===!0){let l=`${u},`;i(l,f)}},s=(u,f)=>{let l=e[u];if(l!==void 0){let m=`\"${l.replace(\"\\\\\",\"\\\\\\\\\").replace('\"','\\\\\"')}\"`,p=`${u}=${m},`;i(p,f)}},d=(u,f)=>{let l=e[u];if(l!==void 0){let m=`${u}=${l},`;i(m,f)}};return a(\"bl\",\"request\"),a(\"br\",\"object\"),o(\"bs\",\"status\"),s(\"cid\",\"session\"),a(\"d\",\"object\"),a(\"dl\",\"request\"),a(\"mtp\",\"request\"),s(\"nor\",\"request\"),s(\"nrr\",\"request\"),d(\"ot\",\"object\"),a(\"pr\",\"session\"),a(\"rtp\",\"status\"),d(\"sf\",\"session\"),s(\"sid\",\"session\"),d(\"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)),c.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),c.debug(\"CMCD\",\"proposing query string payload\",{queryString:r}),{type:\"query\",value:[[\"CMCD\",r]]})}};var Es=zn;var qn=class extends fe{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=_s(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=_s(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 _s(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 Le(n){return n instanceof de?new Xe(\"PIPELINE_LOAD_ERROR\",n):pe(n,{defaultCode:\"PIPELINE_LOAD_ERROR\",defaultReason:\"Unknown error when fetching the Manifest\"})}function fl(n){return n instanceof de?n.type===Pt.ERROR_HTTP_CODE?n.status>=500||n.status===404||n.status===415||n.status===412:n.type===Pt.TIMEOUT||n.type===Pt.ERROR_EVENT:n instanceof $e?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:Ut(n)&&n.code===\"INTEGRITY_ERROR\"}async function Wn(n,e,t,r,i){if(i.cancellationError!==null)return Promise.reject(i.cancellationError);let{baseDelay:a,maxDelay:o,maxRetry:s,onRetry:d}=r;n!==null&&n.length===0&&c.warn(\"utils\",\"No CDN given to `scheduleRequestWithCdns`.\");let u=new Map,f=l();if(f===void 0)throw new Error(\"No CDN to request\");return m(f);function l(){if(n===null){let g=u.get(null);return g!==void 0&&g.isBlacklisted?void 0:null}else{if(e===null)return b(n);{let g=e.getCdnPreferenceForResource(n);return b(g)}}}async function m(g){try{return await t(g,i)}catch(y){if(z.isCancellationError(y))throw y;g!==null&&e!==null&&e.downgradeCdn(g);let T=u.get(g);if(T===void 0?(T={errorCounter:1,blockedUntil:void 0,isBlacklisted:!1},u.set(g,T)):T.errorCounter++,!fl(y))return T.blockedUntil=void 0,T.isBlacklisted=!0,p(y);if(T.errorCounter>s)T.blockedUntil=void 0,T.isBlacklisted=!0;else{let R=T.errorCounter,E=Math.min(a*Math.pow(2,R-1),o),C=Pi(E);T.blockedUntil=F()+C}return p(y)}}async function p(g){let y=l();if(i.isCancelled())throw i.cancellationError;if(y===void 0)throw g;if(d(g),i.isCancelled())throw i.cancellationError;return h(y,g)}function h(g,y){let T=u.get(g);if(T===void 0||T.blockedUntil===void 0)return m(g);let R=F(),E=T.blockedUntil-R;if(E<=0)return m(g);let C=new z(\"Request Backoff\"),P=C.linkToSignal(i);return new Promise((x,A)=>{e==null||e.addEventListener(\"priorityChange\",()=>{let D=l();if(i.isCancelled())throw i.cancellationError;if(D===void 0)return N(y);D!==g&&(C.cancel(\"new prioritized CDN\"),h(D,y).then(k,N))},C.signal),ln(E,C.signal).then(()=>m(g).then(k,N),O);function k(D){P(),x(D)}function N(D){P(),A(D)}})}function b(g){var T;if(u.size===0)return g[0];let y=F();return(T=g.filter(R=>{var E;return((E=u.get(R))==null?void 0:E.isBlacklisted)!==!0}).reduce((R,E)=>{var P;let C=(P=u.get(E))==null?void 0:P.blockedUntil;return C!==void 0&&C<=y&&(C=void 0),R===void 0?[E,C]:R[1]===void 0?R:C===void 0?[E,void 0]:C<R[1]?[E,C]:R},void 0))==null?void 0:T[0]}}function $i(n,e,t){return Wn(null,null,n,e,t)}var Vn=class extends fe{constructor(e,t,r){super(),this.scheduleManualRefresh=O,this._manifestUrls=e,this._pipelines=t.manifest,this._transportName=t.transportName,this._settings=r,this._canceller=new z(\"ManifestFetcher\"),this._isStarted=!1,this._isRefreshPending=!1,this._consecutiveUnsafeMode=0,this._prioritizedContentUrl=null}dispose(e){this._canceller.cancel(e!=null?e:\"ManifestFetcher dispose\"),this.removeEventListener()}start(){if(this._isStarted)return;this._isStarted=!0;let e,t=this._settings.initialManifest;t instanceof ht?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._transportName,a=this._pipelines,o=e!=null?e:(u=this._manifestUrls)==null?void 0:u[0],s=this._getBackoffSetting(f=>{this.trigger(\"warning\",Le(f))});try{let f=await d(o);return{parse:l=>this._parseLoadedManifest(f,l,o)}}catch(f){throw Le(f)}function d(f){var g;let{loadManifest:l}=a,m=r.requestTimeout===void 0?L.getCurrent().DEFAULT_REQUEST_TIMEOUT:r.requestTimeout,p=r.connectionTimeout===void 0?L.getCurrent().DEFAULT_CONNECTION_TIMEOUT:r.connectionTimeout;m<0&&(m=void 0),p<0&&(p=void 0);let h={timeout:m,connectionTimeout:p,cmcdPayload:(g=r.cmcdDataBuilder)==null?void 0:g.getCmcdDataForManifest(i)};return $i(()=>l(f,h,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 b;let i=F(),a=this._canceller.signal,o=this.trigger.bind(this),{sendingTime:s,receivedTime:d}=e,u=this._getBackoffSetting(g=>{this.trigger(\"warning\",Le(g))}),f=r!=null?r:(b=this._manifestUrls)==null?void 0:b[0],l={externalClockOffset:t.externalClockOffset,unsafeMode:t.unsafeMode,previousManifest:t.previousManifest,originalUrl:f};try{let g=this._pipelines.parseManifest(e,l,p,a,m);if(ml(g)){let{manifest:y}=await g;return h(y)}else return h(g.manifest)}catch(g){throw pe(g,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"})}async function m(g){try{return await $i(g,u,a)}catch(y){throw Le(y)}}function p(g){for(let y of g){if(a.isCancelled())return;let T=pe(y,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown error when parsing the Manifest\"});o(\"warning\",T)}}function h(g){let y=F()-i;return c.info(\"MF\",`Manifest parsed in ${y}ms`),{manifest:g,sendingTime:s,receivedTime:d,parsingTime:y}}}_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,d=a?i.LOW_LATENCY:i.REGULAR,u=o!=null?o:t;return{onRetry:e,baseDelay:s,maxDelay:d,maxRetry:u}}_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,d=!1;this._consecutiveUnsafeMode>0?d=this._consecutiveUnsafeMode<a:s!==void 0&&(d=s>=o);let u=t===void 0?0:F()-t,f=Math.max(this._settings.minimumManifestUpdateInterval-u,0),l=new z(\"ManifestFetcher refresh handling\");if(l.linkToSignal(this._canceller.signal),this.scheduleManualRefresh=m=>{let{enablePartialRefresh:p,delay:h,canUseUnsafeMode:b}=m,g=b&&d,y=t===void 0?0:F()-t,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:p,unsafeMode:g})},Math.max((h!=null?h:0)-y,T));l.signal.register(()=>{clearTimeout(R)})},e.expired!==null){let m=setTimeout(()=>{var p;(p=e.expired)==null||p.then(()=>{l.cancel(\"manifest expiration\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},O)},f);l.signal.register(()=>{clearTimeout(m)})}if(e.lifetime!==void 0&&e.lifetime>=0){let m=e.lifetime*1e3-u,p;s===void 0?p=m:e.lifetime<3&&s>=100?(p=Math.min(Math.max(3e3-u,Math.max(m,0)+s),m*6),c.info(\"MF\",\"Manifest update rythm is too frequent. Postponing next request.\",{regularRefreshDelay:m,newRefreshDelay:p})):s>=e.lifetime*1e3/10?(p=Math.min(Math.max(m,0)+s,m*6),c.info(\"MF\",\"Manifest took too long to parse. Postponing next request\",{regularRefreshDelay:m,newRefreshDelay:p})):p=m;let h=setTimeout(()=>{l.cancel(\"manifest request timeout\"),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:d})},Math.max(p,f));l.signal.register(()=>{clearTimeout(h)})}}_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(\"MF\",'Refreshing the Manifest in \"unsafeMode\" for the '+String(this._consecutiveUnsafeMode)+\" consecutive time.\")):this._consecutiveUnsafeMode>0&&(c.info(\"MF\",'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(d=>d.parse({externalClockOffset:s,previousManifest:e,unsafeMode:r})).then(d=>{this._isRefreshPending=!1;let{manifest:u,sendingTime:f,parsingTime:l}=d,m=F();if(a)e.replace(u);else try{e.update(u)}catch(h){let b=h instanceof Error?h.message:\"unknown error\";c.warn(\"MF\",`Attempt to update Manifest failed: ${b}`,\"Re-downloading the Manifest fully\");let{FAILED_PARTIAL_UPDATE_MANIFEST_REFRESH_DELAY:g}=L.getCurrent(),y=f===void 0?0:F()-f,T=Math.max(this._settings.minimumManifestUpdateInterval-y,0),R=O,E=setTimeout(()=>{R(),this._triggerNextManifestRefresh(e,{enablePartialRefresh:!1,unsafeMode:!1})},Math.max(g-y,T));R=this._canceller.signal.register(()=>{clearTimeout(E)});return}let p=F()-m;this._recursivelyRefreshManifest(e,{sendingTime:f,parsingTime:l,updatingTime:p})}).catch(d=>{this._isRefreshPending=!1,this._onFatalError(d)}))}_onFatalError(e){this._canceller.isUsed()||(this.trigger(\"error\",e),this.dispose(\"ManifestFetcher fatal err\"))}};function ml(n){return n instanceof Promise}var Xi=Vn;function Zi(n,e){let t=new WeakMap;return{createRequest(r,i,a,o){let s=u=>e(r,a,u),d=n.create(s,i,a,o);return t.set(d,s),d},updatePriority(r,i){let a=t.get(r);if(a===void 0){c.warn(\"SF\",\"Cannot update the priority of a request: task not found.\");return}n.updatePriority(a,i)}}}var Ji=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}},Rs=Ji;var cl=Me();function ea({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},d=ue([\"audio\",\"video\"],n)?new Rs:void 0,{loadSegment:u,parseSegment:f}=e;return async function(m,p,h){var H,$,V;let{segment:b,adaptation:g,representation:y,manifest:T,period:R}=m,E=He(m),C=cl(),P,x=[],A=0,k=!1,N={segment:b,type:g.type,language:g.language,isLive:T.isLive,periodStart:R.start,periodEnd:R.end,mimeType:y.mimeType,codecs:y.codecs[0],manifestPublishTime:T.publishTime},D={onProgress(G){var Y;P===void 0&&G.totalSize!==void 0&&G.size<G.totalSize&&((Y=i.onProgress)==null||Y.call(i,{duration:G.duration,size:G.size,totalSize:G.totalSize,timestamp:F(),id:C}))},onNewChunk(G){p.onChunk(M(G,!0))}},q=d!==void 0?d.get(m):null;if(q!==null)return c.debug(\"SF\",\"Found wanted segment in cache\",E),p.onChunk(M(q,!1)),Promise.resolve();c.debug(\"SF\",\"Beginning request\",E),(H=i.onRequestBegin)==null||H.call(i,{requestTimestamp:F(),id:C,content:m}),h.register(B);try{let G=await Wn(m.representation.cdnMetadata,t,_,K({onRetry:w},a),h);if(G.resultType===\"segment-loaded\"){let Y=G.resultData.responseData;d!==void 0&&d.add(m,G.resultData.responseData),p.onChunk(M(Y,!1))}else G.resultType===\"segment-created\"&&p.onChunk(M(G.resultData,!1));c.debug(\"SF\",\"Segment request ended with success\",E),p.onAllChunksReceived(),G.resultType!==\"segment-created\"?(P=G.resultData,U()):P=null,h.isCancelled()||($=i.onRequestEnd)==null||$.call(i,{id:C}),h.deregister(B)}catch(G){throw h.deregister(B),P=null,G instanceof oe?(c.debug(\"SF\",\"Segment request aborted\",E),G):(c.debug(\"SF\",\"Segment request failed\",E),(V=i.onRequestEnd)==null||V.call(i,{id:C}),Le(G))}function B(){var G;P===void 0&&(c.debug(\"SF\",\"Segment request cancelled\",E),P=null,(G=i.onRequestEnd)==null||G.call(i,{id:C}))}function _(G){return s.cmcdPayload=r==null?void 0:r.getCmcdDataForSegmentRequest(m),u(G,N,s,h,D)}function M(G,Y){x.push(!1);let me=x.length-1;return function(ce){let Qe={data:G,isChunked:Y};try{let te=f(Qe,N,ce);return x[me]||(A=A!==void 0&&te.segmentType===\"media\"&&te.chunkInfos!==null&&te.chunkInfos.duration!==void 0?A+te.chunkInfos.duration:void 0,x[me]=!0,U()),te}catch(te){throw pe(te,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}}function w(G){p.onRetry(Le(G))}function U(){var G;k||!v(P)&&P.size!==void 0&&P.requestDuration!==void 0&&x.length>0&&x.every(Y=>Y)&&(k=!0,(G=i.onMetrics)==null||G.call(i,{size:P.size,requestDuration:P.requestDuration,content:m,segmentDuration:A}))}}}function Ps({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:d}=L.getCurrent();return{maxRetry:n!=null?n:i,baseDelay:e?s.LOW_LATENCY:s.REGULAR,maxDelay:e?d.LOW_LATENCY:d.REGULAR,requestTimeout:t===void 0?a:t,connectionTimeout:r===void 0?o:r}}var Gn=class extends fe{constructor(e,t){super(),this._segmentFetcher=e,this._currentContentInfo=null,this.isMediaSegmentQueueInterrupted=t}getRequestedInitSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.initSegmentRequest)==null?void 0:t.segment)!=null?r:null}getRequestedMediaSegment(){var e,t,r;return(r=(t=(e=this._currentContentInfo)==null?void 0:e.mediaSegmentRequest)==null?void 0:t.segment)!=null?r:null}resetForContent(e,t,r){var s;(s=this._currentContentInfo)==null||s.currentCanceller.cancel(r!=null?r:\"SegmentQueue reset\");let i=new X({initSegment:null,segmentQueue:[]}),a=new z(\"SegmentQueue \"+e.adaptation.type);a.signal.register(()=>{i.finish()});let o={content:e,downloadQueue:i,initSegmentInfoRef:t?new X(void 0):new X(null),currentCanceller:a,initSegmentRequest:null,mediaSegmentRequest:null,mediaSegmentAwaitingInitMetadata:null};return this._currentContentInfo=o,this.isMediaSegmentQueueInterrupted.onUpdate(d=>{d||(c.debug(\"SF\",\"Media segment can be loaded again, restarting queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"interrupt end\"))},{clearSignal:a.signal}),i.onUpdate(d=>{let{segmentQueue:u}=d;if(u.length>0&&u[0].segment.id===o.mediaSegmentAwaitingInitMetadata)return;let f=o.mediaSegmentRequest;if(u.length===0){if(f===null)return;c.debug(\"SF\",\"no more media segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue empty\");return}else if(f===null){c.debug(\"SF\",\"Media segments now need to be requested. Starting queue.\",{type:e.adaptation.type,queueLength:u.length}),this._restartMediaSegmentDownloadingQueue(o,\"media segment queue start\");return}else{let l=u[0];if(f.segment.id!==l.segment.id){c.debug(\"SF\",\"Next media segment changed, cancelling previous\",{type:e.adaptation.type}),this._restartMediaSegmentDownloadingQueue(o,\"next media segment changed\");return}f.priority!==l.priority&&(c.debug(\"SF\",\"Priority of next media segment changed, updating\",{type:e.adaptation.type,prevPriority:f.priority,newPriority:l.priority}),this._segmentFetcher.updatePriority(f.request,l.priority));return}},{emitCurrentValue:!0,clearSignal:a.signal}),i.onUpdate(d=>{var f;let u=o.initSegmentRequest;if(d.initSegment!==null&&u!==null){d.initSegment.priority!==u.priority&&this._segmentFetcher.updatePriority(u.request,d.initSegment.priority);return}else if(((f=d.initSegment)==null?void 0:f.segment.id)===(u==null?void 0:u.segment.id))return;d.initSegment===null&&c.debug(\"SF\",\"no more init segment to request. Cancelling queue.\",{type:e.adaptation.type}),this._restartInitSegmentDownloadingQueue(o,d.initSegment,\"init segment queue empty\")},{emitCurrentValue:!0,clearSignal:a.signal}),i}stop(e){var t;(t=this._currentContentInfo)==null||t.currentCanceller.cancel(e!=null?e:\"SegmentQueue stop\"),this._currentContentInfo=null}_restartMediaSegmentDownloadingQueue(e,t){e.mediaSegmentRequest!==null&&e.mediaSegmentRequest.canceller.cancel(t!=null?t:\"SegmentQueue media restart\");let{downloadQueue:r,content:i,initSegmentInfoRef:a,currentCanceller:o}=e,s=()=>{var E;if(this.isMediaSegmentQueueInterrupted.getValue()){c.debug(\"SF\",\"Segment fetching postponed because it cannot stream now.\");return}let{segmentQueue:d}=r.getValue(),u=d[0];if(o!==null&&o.isUsed()){e.mediaSegmentRequest=null;return}if(u===void 0){e.mediaSegmentRequest=null,this.trigger(\"emptyQueue\",null);return}let f=new z(\"SegmentQueue media segments queue \"+i.adaptation.type),l=o===null?O:f.linkToSignal(o.signal),{segment:m,priority:p}=u,h=K({segment:m,nextSegment:(E=d[1])==null?void 0:E.segment},i),b=!1,g=!1;f.signal.register(()=>{e.mediaSegmentRequest=null,!b&&(e.mediaSegmentAwaitingInitMetadata===m.id&&(e.mediaSegmentAwaitingInitMetadata=null),b=!0,g=!1)});let y=C=>{Ie(C.segmentType===\"media\",\"Should have loaded a media segment.\"),this.trigger(\"parsedMediaSegment\",K({},C,{segment:m}))},T=()=>{let C=r.getValue().segmentQueue;if(C.length===0){b=!0,this.trigger(\"emptyQueue\",null);return}else C[0].segment.id===m.id&&C.shift();b=!0,s()},R=this._segmentFetcher.createRequest(h,p,{onRetry:C=>{this.trigger(\"requestRetry\",{segment:m,error:C})},beforeInterrupted(){c.info(\"SF\",\"segment request interrupted temporarly.\",{segmentId:m.id,segmentTime:m.time})},onChunk:C=>{let P=a.getValue();P!==void 0?y(C(P!=null?P:void 0)):(g=!0,a.waitUntilDefined(x=>{y(C(x!=null?x:void 0))},{clearSignal:f.signal}))},onAllChunksReceived:()=>{g?(e.mediaSegmentAwaitingInitMetadata=m.id,a.waitUntilDefined(()=>{e.mediaSegmentAwaitingInitMetadata=null,g=!1,this.trigger(\"fullyLoadedSegment\",m)},{clearSignal:f.signal})):this.trigger(\"fullyLoadedSegment\",m)},beforeEnded:()=>{l(),e.mediaSegmentRequest=null,g?a.waitUntilDefined(T,{clearSignal:f.signal}):T()}},f.signal);R.catch(C=>{l(),b||(b=!0,this.stop(\"request err\"),this.trigger(\"error\",C))}),e.mediaSegmentRequest={segment:m,priority:p,request:R,canceller:f}};s()}_restartInitSegmentDownloadingQueue(e,t,r){let{content:i,initSegmentInfoRef:a}=e;if(e.initSegmentRequest!==null&&e.initSegmentRequest.canceller.cancel(r!=null?r:\"SegmentQueue init restart\"),t===null)return;let o=new z(\"SegmentQueue init segment \"+i.adaptation.type),s=e.currentCanceller===null?O:o.linkToSignal(e.currentCanceller.signal),{segment:d,priority:u}=t,f=K({segment:d,nextSegment:void 0},i),l=!1,m=this._segmentFetcher.createRequest(f,u,{onRetry:p=>{this.trigger(\"requestRetry\",{segment:d,error:p})},beforeInterrupted:()=>{c.info(\"SF\",\"init segment request interrupted temporarly.\",{segmentId:d.id})},beforeEnded:()=>{s(),e.initSegmentRequest=null,l=!0},onChunk:p=>{var b;let h=p(void 0);Ie(h.segmentType===\"init\",\"Should have loaded an init segment.\"),this.trigger(\"parsedInitSegment\",K({},h,{segment:d})),h.segmentType===\"init\"&&a.setValue((b=h.initTimescale)!=null?b:null)},onAllChunksReceived:()=>{this.trigger(\"fullyLoadedSegment\",d)}},o.signal);m.catch(p=>{s(),l||(l=!0,this.stop(\"request err\"),this.trigger(\"error\",p))}),o.signal.register(()=>{e.initSegmentRequest=null,!l&&(l=!0)}),e.initSegmentRequest={segment:d,priority:u,request:m,canceller:o}}};var Kn=class{constructor({prioritySteps:e}){if(this._minPendingPriority=null,this._waitingQueue=[],this._pendingTasks=[],this._prioritySteps=e,this._prioritySteps.high>=this._prioritySteps.low)throw new Error(\"The max high level priority should be given a lowerpriority number than the min low priority.\")}create(e,t,r,i){let a;return Ct(i,(o,s)=>(a={hasEnded:!1,priority:t,trigger:()=>{if(a.hasEnded)return;let u=()=>{p(),this._endTask(a)},f=h=>{r.beforeEnded(),u(),o(h)},l=h=>{u(),s(h)},m=new z(void 0),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(f).catch(h=>{!i.isCancelled()&&m.isUsed()&&h instanceof oe||l(h)})},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=Hn(e.taskFn,this._waitingQueue);if(t>=0)this._waitingQueue.splice(t,1);else{let r=Hn(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=Hn(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=Hn(e,this._pendingTasks);if(i<0){c.warn(\"SF\",\"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 of this._pendingTasks)if(e.priority>=this._prioritySteps.low)return this._interruptPendingTask(e),this._interruptCancellableTasks()}_findAndRunWaitingQueueTask(e){return e>=this._waitingQueue.length||e<0?(c.warn(\"SF\",\"Tried to start a non existing task\"),!1):(this._waitingQueue.splice(e,1)[0].trigger(),!0)}_interruptPendingTask(e){var r;let t=Hn(e.taskFn,this._pendingTasks);if(t<0){c.warn(\"SF\",\"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(\"TaskPrioritizer interrupt\")}_canBeStartedNow(e){return this._minPendingPriority===null||e.priority<=this._minPendingPriority}_isRunningHighPriorityTasks(){return this._minPendingPriority!==null&&this._minPendingPriority<=this._prioritySteps.high}};function Hn(n,e){return ne(e,t=>t.taskFn===n)}var jn=class{constructor(e,t,r,i){let{MIN_CANCELABLE_PRIORITY:a,MAX_HIGH_PRIORITY_LEVEL:o}=L.getCurrent();this._transport=e,this._prioritizer=new Kn({prioritySteps:{high:o,low:a}}),this._cdnPrioritizer=t,this._backoffOptions=i,this._cmcdDataBuilder=r}createSegmentQueue(e,t,r){let i=Ps(this._backoffOptions),a=this._transport[e],o=ea({bufferType:e,pipeline:a,cdnPrioritizer:this._cdnPrioritizer,cmcdDataBuilder:this._cmcdDataBuilder,eventListeners:t,requestOptions:i}),s=Zi(this._prioritizer,o);return new Gn(s,r)}};var ta=jn;function na(n,e){let{loadThumbnail:t}=n,r=[];return async function(a,o){o.register(E);let{segment:s,track:d}=a,u,f=j(r,({thumbnailContext:x})=>x.period.id===a.period.id&&x.track.id===a.track.id&&x.segment.id===a.segment.id);if(f!==void 0){c.debug(\"Thumbnails\",\"Requesting same thumbnail than the pending one\",{time:a.segment.time}),u=f,u.referenceCount++;let x;try{x=await u.promise}catch(A){throw o.deregister(E),A}if(o.deregister(E),o.isCancelled())throw o.cancellationError;return R(x)}let l=pl({}),m;l.connectionTimeout===void 0||l.connectionTimeout<0?m=void 0:m=l.connectionTimeout;let p={timeout:l.requestTimeout<0?void 0:l.requestTimeout,connectionTimeout:m,cmcdPayload:void 0},h=new z(\"Thumbnail request\"),b=T();u={thumbnailContext:a,promise:b,referenceCount:1},r.push(u);let g=()=>{let x=r.indexOf(u);x>=0&&r.splice(x,1)},y;try{y=await b}catch(x){throw g(),o.deregister(E),x}if(g(),o.deregister(E),o.isCancelled())throw o.cancellationError;return R(y);async function T(){c.debug(\"Thumbnails\",\"Beginning thumbnail request\",{time:s.time});try{let x=await Wn(d.cdnMetadata,e,C,K({onRetry:P},l),h.signal);return c.debug(\"Thumbnails\",\"Thumbnail request ended with success\",{time:s.time}),x}catch(x){throw x instanceof oe?(c.debug(\"Thumbnails\",\"Thumbnail request aborted\",{time:s.time}),x):(c.debug(\"Thumbnails\",\"Thumbnail request failed\",{time:s.time}),Le(x))}}function R(x){try{return n.parseThumbnail(x.responseData,{thumbnail:s,thumbnailTrack:d})}catch(A){throw pe(A,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"Unknown parsing error\"})}}function E(){c.debug(\"Thumbnails\",\"Thumbnail request cancelled\",{time:s.time});let x=r.indexOf(u);x<0||(r[x].referenceCount--,r[x].referenceCount<=0&&(h.cancel(\"Thumbnail request aborted\"),r.splice(x,1)))}function C(x){return t(x,s,p,o)}function P(x){let A=Le(x);c.warn(\"Thumbnails\",\"Thumbnail request retry \",{time:s.time},A)}}}function pl({maxRetry:n,requestTimeout:e,connectionTimeout:t}){let{DEFAULT_MAX_THUMBNAIL_REQUESTS_RETRY_ON_ERROR:r,DEFAULT_THUMBNAIL_REQUEST_TIMEOUT:i,DEFAULT_THUMBNAIL_CONNECTION_TIMEOUT:a,INITIAL_BACKOFF_DELAY_BASE:o,MAX_BACKOFF_DELAY_BASE:s}=L.getCurrent();return{maxRetry:n!=null?n:r,baseDelay:o.REGULAR,maxDelay:s.REGULAR,requestTimeout:e===void 0?i:e,connectionTimeout:t===void 0?a:t}}var Yn=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(\"WorkerTextDisplayerInterface reset\")}stop(e){this._messageSender({type:\"stop-text-displayer\",contentId:this._contentId,value:null}),this._resetCurrentQueue(e)}_resetCurrentQueue(e){let t=new oe(\"WorkerTextDisplayerInterface queue\",e!=null?e:\"reset\");this._queues.pushTextData.forEach(r=>{r.reject(t)}),this._queues.pushTextData.length=0,this._queues.remove.forEach(r=>{r.reject(t)}),this._queues.remove.length=0}onPushedTrackSuccess(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData success for inexistant operation\");return}t.resolve(e)}onPushedTrackError(e){let t=this._queues.pushTextData.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}onRemoveSuccess(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"text\",\"remove success for inexistant operation\");return}t.resolve(e)}onRemoveError(e){let t=this._queues.remove.shift();if(t===void 0){c.error(\"text\",\"pushTextData error for inexistant operation\");return}t.reject(e)}};var vs=6,ra=4e3,Lr=6e3,gl=6e4,Gt=class{constructor(e){this._segmentSinksStore=e,this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=null,this._lastFlushAttempt=null,this._lastSegmentInfo={audio:[],video:[]}}onNewObservation(e){var g,y;let t=F();if(this._addPositionToHistory(e,t),this._ignoreFreezeUntil!==null&&t<this._ignoreFreezeUntil)return null;this._ignoreFreezeUntil=null;let{UNFREEZING_SEEK_DELAY:r,UNFREEZING_DELTA_POSITION:i,FREEZING_FLUSH_FAILURE_DELAY:a}=L.getCurrent(),{readyState:o,rebuffering:s,freezing:d,fullyLoaded:u}=e,f=e.position.getPolled(),l=Cs(e.bufferGap);if(!(d!==null||o===1&&(l>=vs||u)))return this._decipherabilityFreezeStartingTimestamp=null,null;let p=(y=(g=d==null?void 0:d.timestamp)!=null?g:s==null?void 0:s.timestamp)!=null?y:null;if(c.info(\"Freeze\",\"Freeze detected\",{freezeStart:p,timeFrozen:t-(p!=null?p:t)}),this._lastFlushAttempt!==null&&t-this._lastFlushAttempt.timestamp<a.MAXIMUM&&t-this._lastFlushAttempt.timestamp>=a.MINIMUM&&Math.abs(f-this._lastFlushAttempt.position)<a.POSITION_DELTA){let T=this._getStrategyIfFlushingFails(f);return this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,T}let b=this._checkForDecipherabilityRelatedFreeze(e,t);return b!==null?b:p!==null&&t-p>r?(this._lastFlushAttempt={timestamp:t,position:f+i},c.debug(\"Freeze\",\"Trying to flush to un-freeze\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,{type:\"flush\",value:{relativeSeek:i}}):null}_checkForDecipherabilityRelatedFreeze(e,t){let{readyState:r,rebuffering:i,freezing:a,fullyLoaded:o}=e,s=Cs(e.bufferGap),d=i!==null&&t-i.timestamp>ra,{hasUndecipherableData:u,hasEncryptedData:f}=hl(this._segmentSinksStore);if(u===!0)return c.warn(\"Freeze\",\"we have undecipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,{type:\"reload\",value:null};let l=a!==null&&t-a.timestamp>ra;return(d||l)&&(s>=vs||o)&&r<=1?this._decipherabilityFreezeStartingTimestamp===null&&(c.debug(\"Freeze\",\"Start of a potential decipherability freeze detected\"),this._decipherabilityFreezeStartingTimestamp=t):this._decipherabilityFreezeStartingTimestamp=null,this._decipherabilityFreezeStartingTimestamp!==null&&F()-this._decipherabilityFreezeStartingTimestamp>ra&&f&&u===!1?(c.warn(\"Freeze\",\"we are frozen despite only having decipherable segments left in the buffer, reloading\"),this._decipherabilityFreezeStartingTimestamp=null,this._ignoreFreezeUntil=t+Lr,{type:\"reload\",value:null}):null}_getStrategyIfFlushingFails(e){c.warn(\"Freeze\",\"A recent flush seemed to have no effect on freeze, checking for transitions\");let t=[];for(let r of[\"audio\",\"video\"]){let i=this._lastSegmentInfo[r];if(i.length===0)continue;let a=i[i.length-1];if(a.segment===null)continue;let o=a.segment,s;for(let d=i.length-2;d>=0;d--){let u=i[d];if(u.segment===null){s=u;break}else if(u.segment.infos.representation.uniqueId!==o.infos.representation.uniqueId&&a.timestamp-u.timestamp<5e3){s=u;break}else u.segment.start===o.start&&e-u.position<3e3&&(a=u)}if(s===void 0||s.segment===null)c.debug(\"Freeze\",\"Freeze when beginning to play a content, try avoiding this quality\"),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation});else{if(o.infos.period.id!==s.segment.infos.period.id)return c.debug(\"Freeze\",\"Freeze when switching Period, reloading\"),{type:\"reload\",value:null};o.infos.representation.uniqueId!==s.segment.infos.representation.uniqueId&&(c.warn(\"Freeze\",\"Freeze when switching Representation, avoiding\",{bitrate:o.infos.representation.bitrate}),t.push({adaptation:o.infos.adaptation,period:o.infos.period,representation:o.infos.representation}))}}return t.length>0?{type:\"avoid-representations\",value:t}:(c.debug(\"Freeze\",\"Reloading because flush doesn't work\"),{type:\"reload\",value:null})}_addPositionToHistory(e,t){var i,a;let r=e.position.getPolled();for(let o of[\"audio\",\"video\"]){let s=this._segmentSinksStore.getStatus(o);if(s.type===\"initialized\")for(let f of s.value.getLastKnownInventory())((i=f.bufferedStart)!=null?i:f.start)<=r&&((a=f.bufferedEnd)!=null?a:f.end)>r&&this._lastSegmentInfo[o].push({segment:f,position:r,timestamp:t});else this._lastSegmentInfo[o].push({segment:null,position:r,timestamp:t});if(this._lastSegmentInfo[o].length>100){let f=this._lastSegmentInfo[o].length-100;this._lastSegmentInfo[o].splice(0,f)}let d=t-gl,u;for(u=0;u<this._lastSegmentInfo[o].length&&!(this._lastSegmentInfo[o][u].timestamp>d);u++);u>0&&this._lastSegmentInfo[o].splice(0,u)}}};function hl(n){let e=!0,t=!0;for(let r of[\"audio\",\"video\"]){let i=n.getStatus(r);if(i.type===\"initialized\")for(let a of i.value.getLastKnownInventory()){let{representation:o}=a.infos;if(o.decipherable===!1)return{hasUndecipherableData:!0,hasEncryptedData:!0};o.contentProtections!==void 0&&(t=!1,o.decipherable!==!0&&(e=!1))}}return{hasEncryptedData:!t,hasUndecipherableData:e?!1:void 0}}function Cs(n){return n!==void 0&&isFinite(n)?n:0}var Qn=class{constructor(){this._refs=new Map}reset(){var e,t,r,i,a,o,s,d,u,f,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(),(d=(s=this._refs.get(p))==null?void 0:s.video)==null||d.representations.finish(),(f=(u=this._refs.get(p))==null?void 0:u.text)==null||f.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,d;let i=this._refs.get(e);i===void 0&&(i={},this._refs.set(e,i)),i[t]!==void 0&&(c.warn(\"Track\",\"Track for periodId already declared\",{periodId:e,bufferType:t}),(s=i[t])==null||s.trackReference.finish(),(d=i[t])==null||d.representations.finish());let a=r.getValue(),o;v(a)?o=new X({representationIds:[],switchingMode:\"lazy\"}):(o=new X(a.representations.getValue()),r.setValue(K({},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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:t}),!1):(v(r)?(i.representations=new X({representationIds:[],switchingMode:\"lazy\"}),i.trackReference.setValue(r)):(i.representations=new X(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(\"Track\",\"Setting track for inexistent periodId\",{periodId:e,bufferType:r}),!1;let o=a.trackReference.getValue();return v(o)||o.adaptationId!==t?(c.debug(\"Track\",\"Desynchronized Adaptation id\",{oldId:o==null?void 0:o.adaptationId,newId: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(\"Track\",\"Removing track setter for inexistent periodId\",{periodId:e,bufferType:t}),!1):(i.trackReference.finish(),i.representations.finish(),delete r[t],Object.keys(r).length===0&&this._refs.delete(e),!0)}};function ve(n){return pe(n,{defaultCode:\"NONE\",defaultReason:\"An unknown error stopped content playback.\"}).serialize()}function As(n,e){[\"video\",\"audio\",\"text\"].forEach(t=>{var i;let r=e.getStatus(t);r.type===\"initialized\"&&r.value.synchronizeInventory((i=n.buffered[t])!=null?i:[])})}function xs(n){var t,r;if(v(mt))return;let e=new Map;for(let i of n.periods){let a=[...(t=i.adaptations.video)!=null?t:[],...(r=i.adaptations.audio)!=null?r:[]];for(let o of a)for(let s of o.representations){let d=`${s.mimeType};codecs=\"${s.codecs[0]}\"`;if(e.has(d))s.isCodecSupportedInWebWorker=e.get(d);else{let u=mt.isTypeSupported(d);s.isCodecSupportedInWebWorker=u,e.set(d,u)}}}}function ks(n,e){var a,o,s,d,u,f,l;let t,r,i;return typeof((a=n.representationFilter)==null?void 0:a.fn)==\"function\"?i=n.representationFilter.fn:typeof((o=n.representationFilter)==null?void 0:o.eval)==\"string\"?i=So(n.representationFilter.eval):typeof((s=n.representationFilter)==null?void 0:s.workerId)==\"string\"&&(i=e.representationFilters.get(n.representationFilter.workerId)),typeof((d=n.manifestLoader)==null?void 0:d.fn)==\"function\"?t=n.manifestLoader.fn:typeof((u=n.manifestLoader)==null?void 0:u.workerId)==\"string\"&&(t=e.manifestLoaders.get(n.manifestLoader.workerId)),typeof((f=n.segmentLoader)==null?void 0:f.fn)==\"function\"?r=n.segmentLoader.fn:typeof((l=n.segmentLoader)==null?void 0:l.workerId)==\"string\"&&(r=e.segmentLoaders.get(n.segmentLoader.workerId)),{manifestLoader:t,segmentLoader:r,representationFilter:i}}var Ms=Me(),Ht=class{constructor({hasVideo:e}){this._currentContent=null,this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\"),this._hasVideo=e;let t=new z(\"ContentPreparer\");this._contentCanceller=t}initializeNewContent(e,t,r,i){return new Promise((a,o)=>{var w,U;this.disposeCurrentContent(\"new init\");let s=this._contentCanceller,d=new z(\"ContentPreparer MediaSource\");this._currentMediaSourceCanceller=d,d.linkToSignal(s.signal);let{contentId:u,url:f,hasText:l,transportOptions:m,useMseInWorker:p,enableRepresentationAvoidance:h,transport:b}=t,g=null,y=ke.transports[b];if(typeof y!=\"function\"){o(new Error(`transport \"${b}\" not supported. Did you add the corresponding feature?`));return}let T=y(J(J({},m),ks(m,i))),R=t.cmcd===void 0?null:new Es(t.cmcd),E=new Xi(f===void 0?void 0:[f],T,J({cmcdDataBuilder:R},t.manifestRetryOptions)),C=Ss({initialBitrates:{audio:(w=t.initialAudioBitrate)!=null?w:0,video:(U=t.initialVideoBitrate)!=null?U:0},lowLatencyMode:m.lowLatencyMode,throttlers:r}),P=d.signal.register(H=>{o(H)}),x=new qn(s.signal),A=new ta(T,x,R,t.segmentRetryOptions),k=na(T.thumbnails,x),N=new Qn,[D,q,B]=Os(e,u,{useMseInWorker:p,hasVideo:this._hasVideo,hasText:l},d.signal),_=new Gt(q);this._currentContent={cmcdDataBuilder:R,contentId:u,enableRepresentationAvoidance:h,freezeResolver:_,mediaSource:D,manifest:null,manifestFetcher:E,representationEstimator:C,segmentSinksStore:q,segmentQueueCreator:A,fetchThumbnailData:k,coreTextSender:B,trackChoiceSetter:N,useMseInWorker:p},D.addEventListener(\"mediaSourceOpen\",function(){M()},d.signal),s.signal.register(H=>{E.dispose(H.reason)}),E.addEventListener(\"warning\",H=>{e({type:\"warning\",contentId:u,value:ve(H)})},s.signal),E.addEventListener(\"manifestReady\",H=>{if(g!==null){c.warn(\"Core\",\"Multiple `manifestReady` events, ignoring\");return}g=H,this._currentContent!==null&&(this._currentContent.manifest=g),M()},d.signal),E.addEventListener(\"error\",H=>{e({type:\"error\",contentId:u,value:ve(H)}),o(H)},s.signal),E.start();function M(){g===null||D.readyState===\"closed\"||d.isUsed()||(xs(g),g.addEventListener(\"manifestUpdate\",H=>{g!==null&&e({type:\"manifest-update\",contentId:u,value:{manifest:g,updates:H}})},s.signal),P(),a(g))}})}getCurrentContent(){return this._currentContent}scheduleManifestRefresh(e){var t;(t=this._currentContent)==null||t.manifestFetcher.scheduleManualRefresh(e)}reloadMediaSource(e){if(this._currentMediaSourceCanceller.cancel(\"ContentPreparer MediaSource reload\"),this._currentContent===null)return Promise.reject(new Error(\"CP: No content anymore\"));this._currentContent.trackChoiceSetter.reset(),this._currentMediaSourceCanceller=new z(\"ContentPreparer MediaSource\");let[t,r,i]=Os(e,this._currentContent.contentId,{useMseInWorker:this._currentContent.useMseInWorker,hasVideo:this._hasVideo,hasText:this._currentContent.coreTextSender!==null},this._currentMediaSourceCanceller.signal);return this._currentContent.mediaSource=t,this._currentContent.segmentSinksStore=r,this._currentContent.freezeResolver=new Gt(r),this._currentContent.coreTextSender=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(e){this._contentCanceller.cancel(e),this._contentCanceller=new z(\"ContentPreparer\")}};function Os(n,e,t,r){let i;if(t.useMseInWorker){let d=new An(Ms());i=d;let u,f=d.handle;if(f.type===\"handle\")u={type:\"handle\",value:f.value};else{let l=URL.createObjectURL(f.value);u={type:\"url\",value:l},r.register(()=>{URL.revokeObjectURL(l)})}n({type:\"attach-media-source\",contentId:e,value:u,mediaSourceId:i.id},[f.value])}else i=new xn(Ms(),e,n);let a=t.hasText?new Yn(e,n):null,{hasVideo:o}=t,s=new bt(i,o,a);return r.register(d=>{s.disposeAll(d.reason),a==null||a.stop(d.reason),i.dispose(d.reason)}),[i,s,a]}var $n=class extends fe{constructor(e,t,r){super(),this._canceller=new z(\"Boundaries Observation\"),this._manifest=e,this._activeStreams=new Map,this._allBufferTypes=r,this._lastCurrentPeriodId=null;let i=new ia(e);ue(this._allBufferTypes,\"video\")||i.updateLastVideoAdaptation(null),ue(this._allBufferTypes,\"audio\")||i.updateLastAudioAdaptation(null),this._maximumPositionCalculator=i;let a=this._canceller.signal;rt(()=>{t.listen(({position:o})=>{let s=o.getWanted();if(s<e.getMinimumSafePosition()){let d=new Z(\"MEDIA_TIME_BEFORE_MANIFEST\",\"The current position is behind the earliest time announced in the Manifest.\");this.trigger(\"warning\",d)}else if(s>i.getMaximumAvailablePosition()){let d=new Z(\"MEDIA_TIME_AFTER_MANIFEST\",\"The current position is after the latest time announced in the Manifest.\");this.trigger(\"warning\",d)}},{includeLastObservation:!1,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(e){this.removeEventListener(),this._canceller.cancel(e!=null?e:\"ContentTimeBoundariesObserver dispose\")}_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(d=>d.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 kt((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)}},ia=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 of e)if(i.index!==r){r=i.index;let a=i.index.getEnd();if(a===void 0)return;a!==null&&(t=v(t)?a:Math.min(t,a))}return t}function aa(n,e,t,r,i,a){a.register(d=>{e.interruptDurationSetting(d.reason)});let o=new $n(n,t,r.getBufferTypes());a.register(d=>{o.dispose(d.reason)}),o.addEventListener(\"warning\",d=>i.onWarning(d)),o.addEventListener(\"periodChange\",d=>i.onPeriodChanged(d)),o.addEventListener(\"endingPositionChange\",d=>{e.setDuration(d.endingPosition,d.isEnd)}),o.addEventListener(\"endOfStream\",()=>{c.debug(\"mse\",\"Start applying end-of-stream order.\"),e.maintainEndOfStream()}),o.addEventListener(\"resumeStream\",()=>{e.stopEndOfStream()});let s=o.getCurrentEndingTime();return e.setDuration(s.endingPosition,s.isEnd),o}function oa(n,e){let t={audio:null,video:null,text:null};if(e!==null&&(t.text=e.getBufferedRanges()),n===null)return t;let r=j(n.sourceBuffers,s=>s.type===\"audio\"),i=j(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}async function sa(n,e,t,r,i){let a=e.getPeriod(t);if(a===void 0)throw new Error(\"Wanted Period not found.\");let o=j(a.thumbnailTracks,d=>d.id===r);if(o===void 0)throw new Error(\"Wanted Period has no thumbnail track.\");let s=o.index.getSegments(i,1)[0];if(s===void 0)throw new Error(\"No thumbnail for the given timestamp\");return n({segment:s,track:o,period:a},new z(void 0).signal)}function da(n,e,t){let{DEFAULT_WANTED_BUFFER_AHEAD:r,DEFAULT_MAX_VIDEO_BUFFER_SIZE:i,DEFAULT_MAX_BUFFER_AHEAD:a,DEFAULT_MAX_BUFFER_BEHIND:o}=L.getCurrent(),s={wantedBufferAhead:new X(r),maxVideoBufferSize:new X(i),maxBufferAhead:new X(a),maxBufferBehind:new X(o),limitVideoResolution:new X({height:void 0,width:void 0,pixelRatio:1}),throttleVideoBitrate:new X(1/0)},d=!1,u=new Ht({hasVideo:!0}),f=null,l=null;n(m=>{var h,b;c.debug(\"Core\",\"received message\",{name:m.data.type});let p=m.data;switch(p.type){case\"init\":{if(Ie(!d),d=!0,io(p.value),ws(p.value.logLevel,p.value.logFormat,p.value.sendBackLogs),!v(p.value.dashWasmUrl)){let g=ke.dashParsers.wasm;g===null?c.error(\"Core\",\"Could not initialize DASH_WASM parser: DASH_WASM feature not added\"):g.isCompatible()?g.initialize({wasmUrl:p.value.dashWasmUrl}).catch(y=>{let T=y instanceof Error?y.toString():\"Unknown Error\";c.error(\"Core\",\"Could not initialize DASH_WASM parser\",T)}):c.warn(\"Core\",\"Could not initialize DASH_WASM parser: Browser not compatible\")}p.value.hasVideo||(u.disposeCurrentContent(\"Received Init msg\"),u=new Ht({hasVideo:p.value.hasVideo})),e({type:\"init-success\",value:null})}break;case\"log-level-update\":ws(p.value.logLevel,p.value.logFormat,p.value.sendBackLogs);break;case\"prepare\":Il(e,u,p.value,s,t);break;case\"start\":{let g=u.getCurrentContent();if(p.contentId!==(g==null?void 0:g.contentId))return;f==null||f.stop(),l==null||l.finish();let y=new X(K(p.value.initialObservation,{position:new xt(...p.value.initialObservation.position)}));l=y,f=yl(e,p.value,u,y,s);break}case\"observation\":{let g=u.getCurrentContent();if(p.contentId!==(g==null?void 0:g.contentId))return;let y=p.value,{buffered:T}=y,R=oa(g.mediaSource,null);R.audio!==null&&(T.audio=R.audio),R.video!==null&&(T.video=R.video),l==null||l.setValue(K(y,{position:new xt(...p.value.position)}));break}case\"ref-update\":bl(p,s);break;case\"stop\":if(p.contentId!==((h=u.getCurrentContent())==null?void 0:h.contentId))return;u.disposeCurrentContent(\"StopContent message\"),f==null||f.stop(),f=null,l==null||l.finish(),l=null;break;case\"ms-reload\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;f==null||f.signalMediaSourceReload()}break;case\"sb-success\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;let{sourceBuffers:y}=g.mediaSource,T=j(y,R=>R.type===p.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Success for an unknown SourceBuffer\",{sourceBufferType:p.sourceBufferType});return}if(T.onOperationSuccess===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:p.sourceBufferType});return}T.onOperationSuccess(p.operationId,p.value.buffered);break}case\"sb-error\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;let{sourceBuffers:y}=g.mediaSource,T=j(y,R=>R.type===p.sourceBufferType);if(T===void 0){c.info(\"Core\",\"Error for an unknown SourceBuffer\",{sourceBufferType:p.sourceBufferType});return}if(T.onOperationFailure===void 0){c.warn(\"Core\",\"A SourceBufferInterface with MSE performed a cross-thread operation\",{sourceBufferType:p.sourceBufferType});return}T.onOperationFailure(p.operationId,p.value);break}case\"media-source-ready-state-change\":{let g=u.getCurrentContent();if(p.mediaSourceId!==(g==null?void 0:g.mediaSource.id))return;if(g.mediaSource.onMediaSourceReadyStateChanged===void 0){c.warn(\"Core\",\"A MediaSourceInterface with MSE performed a cross-thread operation\");return}g.mediaSource.onMediaSourceReadyStateChanged(p.value);break}case\"decipherability-update\":{if(p.contentId!==((b=u.getCurrentContent())==null?void 0:b.contentId))return;let g=u.getCurrentContent();if(g===null||g.manifest===null)return;let y=p.value;g.manifest.updateRepresentationsDeciperability(T=>{for(let R of y)if(T.representation.uniqueId===R.representationUniqueId)return R.decipherable;return T.representation.decipherable});break}case\"codec-support-update\":{let g=u.getCurrentContent();if(g===null||g.manifest===null)return;let y=p.value;try{let T=g.manifest.updateCodecSupport(y);T!==null&&e({type:\"warning\",contentId:g.contentId,value:ve(T)})}catch(T){e({type:\"error\",contentId:g.contentId,value:ve(T)})}break}case\"urls-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.manifestFetcher.updateContentUrls(p.value.urls,p.value.refreshNow);break}case\"track-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.trackChoiceSetter.setTrack(p.value.periodId,p.value.bufferType,p.value.choice);break}case\"rep-update\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;g.trackChoiceSetter.updateRepresentations(p.value.periodId,p.value.adaptationId,p.value.bufferType,p.value.choice);break}case\"add-text-success\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}g.coreTextSender.onPushedTrackSuccess(p.value.ranges);break}case\"push-text-error\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Added text track but text track aren't enabled\");return}g.coreTextSender.onPushedTrackError(new Error(p.value.message));break}case\"remove-text-success\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}g.coreTextSender.onRemoveSuccess(p.value.ranges);break}case\"remove-text-error\":{let g=u.getCurrentContent();if(g===null||g.contentId!==p.contentId)return;if(g.coreTextSender===null){c.error(\"Core\",\"Removed text track but text track aren't enabled\");return}g.coreTextSender.onRemoveError(new Error(p.value.message));break}case\"pull-segment-sink-store-infos\":{Sl(e,u,p.value.requestId);break}case\"thumbnail-request\":{El(e,u,p);break}case\"config-update\":{L.update(p.value);break}case\"app-defined\":break;default:Be(p)}})}function Il(n,e,t,r,i){e.initializeNewContent(n,t,{limitResolution:{video:r.limitVideoResolution},throttleBitrate:{video:r.throttleVideoBitrate}},i).then(a=>{n({type:\"manifest-ready\",contentId:t.contentId,value:{manifest:a}})},a=>{n({type:\"error\",contentId:t.contentId,value:ve(a)})})}function bl(n,e){switch(n.value.name){case\"wantedBufferAhead\":e.wantedBufferAhead.setValueIfChanged(n.value.newVal);break;case\"maxVideoBufferSize\":e.maxVideoBufferSize.setValueIfChanged(n.value.newVal);break;case\"maxBufferBehind\":e.maxBufferBehind.setValueIfChanged(n.value.newVal);break;case\"maxBufferAhead\":e.maxBufferAhead.setValueIfChanged(n.value.newVal);break;case\"limitVideoResolution\":e.limitVideoResolution.setValueIfChanged(n.value.newVal);break;case\"throttleVideoBitrate\":e.throttleVideoBitrate.setValueIfChanged(n.value.newVal);break;default:Be(n.value)}}function yl(n,e,t,r,i){c.debug(\"Core\",\"Loading pepared content.\");let a=new z(\"Start Content Worker\"),o=null;return s(e.initialTime),{signalMediaSourceReload:()=>u(),stop:()=>{a.cancel(\"ContentHandle stop\")}};function s(f){var B;o==null||o.cancel(\"Reloading content worker\"),o=new z(\"(Re)Loading Content Worker\"),o.linkToSignal(a.signal);let l=new Map,m=t.getCurrentContent();if(m===null||m.manifest===null){let _=new Ee(\"NONE\",\"Loading content when none is prepared\");throw n({type:\"error\",contentId:void 0,value:ve(_)}),_}let{contentId:p,cmcdDataBuilder:h,enableRepresentationAvoidance:b,manifest:g,mediaSource:y,representationEstimator:T,segmentSinksStore:R,segmentQueueCreator:E}=m,{drmSystemId:C,enableFastSwitching:P,onCodecSwitch:x}=e;r.onUpdate(_=>{As(_,R);let M=m.freezeResolver.onNewObservation(_);M!==null&&Tl(n,M,{contentId:p,manifest:g,handleMediaSourceReload:d,enableRepresentationAvoidance:b})},{clearSignal:o.signal});let A=(B=g.getPeriodForTime(f))!=null?B:g.getNextPeriod(f);if(A===void 0){let _=new Z(\"MEDIA_STARTING_TIME_NOT_FOUND\",\"Wanted starting time not found in the Manifest.\");throw n({type:\"error\",contentId:p,value:ve(_)}),_}let k=new hn(r,p,n,o.signal);h==null||h.startMonitoringPlayback(k),o.signal.register(()=>{h==null||h.stopMonitoringPlayback()});let N=aa(g,y,k,R,{onWarning:_=>n({type:\"warning\",contentId:p,value:ve(_)}),onPeriodChanged:_=>{n({type:\"active-period-changed\",contentId:p,value:{periodId:_.id}})}},o.signal);ls({initialPeriod:A,manifest:g},k,T,R,E,{wantedBufferAhead:i.wantedBufferAhead,maxVideoBufferSize:i.maxVideoBufferSize,maxBufferAhead:i.maxBufferAhead,maxBufferBehind:i.maxBufferBehind,drmSystemId:C,enableFastSwitching:P,onCodecSwitch:x},D(),o.signal);function D(){return{needsBufferFlush(_){n({type:\"needs-buffer-flush\",contentId:p,value:_})},streamStatusUpdate(_){q(_),g.isLastPeriodKnown&&_.period.id===g.periods[g.periods.length-1].id&&(_.hasFinishedLoading||_.isEmptyStream?N.onLastSegmentFinishedLoading(_.bufferType):N.onLastSegmentLoadingResume(_.bufferType))},needsManifestRefresh(){t.scheduleManifestRefresh({enablePartialRefresh:!0,canUseUnsafeMode:!0})},manifestMightBeOufOfSync(){let{OUT_OF_SYNC_MANIFEST_REFRESH_DELAY:_}=L.getCurrent();t.scheduleManifestRefresh({enablePartialRefresh:!1,canUseUnsafeMode:!1,delay:_})},lockedStream(_){n({type:\"locked-stream\",contentId:p,value:{periodId:_.period.id,bufferType:_.bufferType}})},adaptationChange(_){var M,w;n({type:\"adaptation-changed\",contentId:p,value:{adaptationId:(w=(M=_.adaptation)==null?void 0:M.id)!=null?w:null,periodId:_.period.id,type:_.type}}),N.onAdaptationChange(_.type,_.period,_.adaptation)},representationChange(_){var M,w;N.onRepresentationChange(_.type,_.period),!(o===null||o.signal.isCancelled())&&n({type:\"representation-changed\",contentId:p,value:{adaptationId:_.adaptation.id,representationId:(w=(M=_.representation)==null?void 0:M.id)!=null?w:null,periodId:_.period.id,type:_.type}})},inbandEvent(_){n({type:\"inband-event\",contentId:p,value:_})},warning(_){n({type:\"warning\",contentId:p,value:ve(_)})},periodStreamReady(_){m!==null&&(m.trackChoiceSetter.addTrackSetter(_.period.id,_.type,_.adaptationRef),n({type:\"period-stream-ready\",contentId:p,value:{periodId:_.period.id,bufferType:_.type}}))},periodStreamCleared(_){if(m===null)return;let M=l.get(_.period);M!==void 0&&(M.delete(_.type),M.size===0&&l.delete(_.period)),N.onPeriodCleared(_.type,_.period),m.trackChoiceSetter.removeTrackSetter(_.period.id,_.type),n({type:\"period-stream-cleared\",contentId:p,value:{periodId:_.period.id,bufferType:_.type}})},bitrateEstimateChange(_){var M;m!==null&&((M=m.cmcdDataBuilder)==null||M.updateThroughput(_.type,_.bitrate)),n({type:\"bitrate-estimate-change\",contentId:p,value:{bitrate:_.bitrate,bufferType:_.type}})},needsMediaSourceReload(_){d(_)},needsDecipherabilityFlush(){n({type:\"needs-decipherability-flush\",contentId:p,value:null})},encryptionDataEncountered(_){for(let M of _){let w=M.content,U=J({},w);U.manifest instanceof ht&&(U.manifest=U.manifest.getMetadataSnapshot()),U.period instanceof gt&&(U.period=U.period.getMetadataSnapshot()),U.adaptation instanceof ft&&(U.adaptation=U.adaptation.getMetadataSnapshot()),U.representation instanceof un&&(U.representation=U.representation.getMetadataSnapshot()),n({type:\"encryption-data-encountered\",contentId:p,value:{keyIds:M.keyIds,values:M.values,content:U,type:M.type}})}},error(_){n({type:\"error\",contentId:p,value:ve(_)})}}}function q(_){let{imminentDiscontinuity:M}=_,w=l.get(_.period),U=w==null?void 0:w.get(_.bufferType);if(U!==void 0){if(U.discontinuity===null){if(M===null)return}else if(M!==null&&U.discontinuity.start===M.start&&U.discontinuity.end===M.end)return}w===void 0&&(w=new Map,l.set(_.period,w));let H={periodId:_.period.id,bufferType:_.bufferType,discontinuity:_.imminentDiscontinuity,position:_.position};w.set(_.bufferType,H),n({type:\"discontinuity-update\",contentId:p,value:H})}}function d(f){var m;o!==null&&(o.cancel(\"WorkerMain MediaSource reload\"),o=null);let l=(m=t.getCurrentContent())==null?void 0:m.mediaSource.id;if(l===void 0){c.warn(\"Core\",\"Cannot reload MediaSource: no MediaSource currently.\");return}c.debug(\"Core\",\"Reloading MediaSource\",{timeOffset:f.timeOffset,minimumPosition:f.minimumPosition,maximumPosition:f.maximumPosition}),n({type:\"reloading-media-source\",mediaSourceId:l,value:f},[]),u()}function u(){var p;let l=r.getValue().position.getWanted();o!==null&&(o.cancel(\"MediaSource reload\"),o=null);let m=(p=t.getCurrentContent())==null?void 0:p.contentId;t.reloadMediaSource(n).then(()=>{c.info(\"Core\",\"MediaSource Reloaded, loading content again\",{newInitialTime:l}),s(l)},h=>{if(z.isCancellationError(h)){c.info(\"Core\",\"A reloading operation was cancelled\");return}n({type:\"error\",contentId:m,value:ve(h)})})}}function ws(n,e,t){t?c.setLevel(n,\"standard\",(r,i,a)=>{let o=a.map(s=>s instanceof Error?ve(s):s);postMessage({type:\"log\",value:{namespace:i,logLevel:r,logs:o}})}):c.setLevel(n,e)}function Sl(n,e,t){let r=e.getCurrentContent();if(r===null)return;let i=r.segmentSinksStore.getSegmentSinksMetrics();n({type:\"segment-sink-store-update\",contentId:r.contentId,value:{segmentSinkMetrics:i,requestId:t}})}function Tl(n,e,{contentId:t,manifest:r,handleMediaSourceReload:i,enableRepresentationAvoidance:a}){switch(e.type){case\"reload\":{c.info(\"Core\",\"Planning reload due to freeze\"),i({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}case\"flush\":{c.info(\"Core\",\"Flushing buffer due to freeze\"),n({type:\"needs-buffer-flush\",contentId:t,value:{relativeResumingPosition:e.value.relativeSeek,relativePosHasBeenDefaulted:!1}});break}case\"avoid-representations\":{c.info(\"Core\",\"Planning Representation avoidance due to freeze\");let o=e.value;a&&r.addRepresentationsToAvoid(o),i({timeOffset:0,minimumPosition:0,maximumPosition:1/0});break}default:Be(e)}}function El(n,e,t){let r=e.getCurrentContent(),i=a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"error\",requestId:t.value.requestId,error:ve(a)}})};if(r===null||r.manifest===null||r.contentId!==t.contentId)return i(new Error(\"Content changed\"));sa(r.fetchThumbnailData,r.manifest,t.value.periodId,t.value.thumbnailTrackId,t.value.time).then(a=>{n({type:\"thumbnail-response\",contentId:t.contentId,value:{status:\"success\",requestId:t.value.requestId,data:a}},[a.data])},a=>i(a))}var Ds=da;var _l=new Rt,qr=_l;var Rl=\"<\",Pl=60,Bs=\">\",Wr=62,ua=45,Ns=47,vl=33,Us=39,Ls=34,la=91,Cl=93,Al=`\\r\n\t>/= `;function fa(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(u()),n=n.substring(t),t=0;else a=o(\"\");return e.filter!==void 0&&(a=Fs(a,e.filter)),a;function o(h){let b=[];for(;n[t]!==void 0;)if(n.charCodeAt(t)===Pl){if(n.charCodeAt(t+1)===Ns){let y=t+2;if(t=n.indexOf(Bs,t),n.substring(y,t).indexOf(h)===-1){let R=n.substring(0,t).split(`\n`);throw new Error(`Unexpected close tag\nLine: `+(R.length-1)+`\nColumn: `+(R[R.length-1].length+1)+`\nChar: `+n[t])}return t!==-1&&(t+=1),b}else if(n.charCodeAt(t+1)===vl){if(n.charCodeAt(t+2)===ua){let y=t;for(;t!==-1&&!(n.charCodeAt(t)===Wr&&n.charCodeAt(t-1)===ua&&n.charCodeAt(t-2)===ua);)t=n.indexOf(Bs,t+1);t===-1&&(t=n.length),r&&b.push(n.substring(y,t+1))}else if(n.charCodeAt(t+2)===la&&n.charCodeAt(t+8)===la&&n.substring(t+3,t+8).toLowerCase()===\"cdata\"){let y=n.indexOf(\"]]>\",t);y===-1?(b.push(n.substring(t+9)),t=n.length):(b.push(n.substring(t+9,y)),t=y+3);continue}else{let y=t+1;t+=2;let T=!1;for(;(n.charCodeAt(t)!==Wr||T)&&n[t]!==void 0;)n.charCodeAt(t)===la?T=!0:T&&n.charCodeAt(t)===Cl&&(T=!1),t++;b.push(n.substring(y,t))}t++;continue}let g=u();b.push(g),g.tagName[0]===\"?\"&&(b.push(...g.children),g.children=[])}else{let g=s();if(i)g.length>0&&b.push(g);else{let y=g.trim();y.length>0&&b.push(y)}t++}return b}function s(){let h=t;return t=n.indexOf(Rl,t)-1,t===-2&&(t=n.length),n.slice(h,t+1)}function d(){let h=t;for(;Al.indexOf(n[t])===-1&&n[t]!==void 0;)t++;return n.slice(h,t)}function u(){let h=t;t++;let b=d(),g={},y=[];for(;n.charCodeAt(t)!==Wr&&n[t]!==void 0;){let T=n.charCodeAt(t);if(T>64&&T<91||T>96&&T<123){let R=d(),E=n.charCodeAt(t);for(;!isNaN(E)&&E!==Us&&E!==Ls&&!(E>64&&E<91||E>96&&E<123)&&E!==Wr;)t++,E=n.charCodeAt(t);let C;E===Us||E===Ls?C=f():(C=null,t--),g[R]=C===null?null:zs(C)}t++}return n.charCodeAt(t-1)!==Ns?(t++,y=o(b)):t++,{tagName:b,attributes:g,children:y,posStart:h,posEnd:t}}function f(){let h=n[t],b=t+1;return t=n.indexOf(h,b),n.slice(b,t)}function l(){let h=new RegExp(\"\\\\s\"+e.attrName+`\\\\s*=['\"]`+e.attrValue+`['\"]`).exec(n);return h!==null?h.index:-1}}function Fs(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=Fs(a.children,e,t+1,(Q(r)?r+\".\":\"\")+o+\".\"+a.tagName);i=i.concat(s)}}),i}function Vr(n){if(Array.isArray(n)){let e=\"\";return n.forEach(function(t){e+=\" \"+Vr(t),e=e.trim()}),e}else return typeof n==\"object\"?Vr(n.children):\" \"+zs(n)}function zs(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 ma(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 Fe(n,e,t){let{start:r,duration:i}=n;if(i<=0)return r;let a=ma(n,e,t);return r+(a+1)*i}function Ce(n,e){var t;return n*e.timescale+((t=e.indexTimeOffset)!=null?t:0)}function Je(n,e){var t;return(n-((t=e.indexTimeOffset)!=null?t:0))/e.timescale}function qs(n,e,t){return[n*t,(n+e)*t]}function xl(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 Ws(n,e,t){let{timeline:r}=n,i=Ce(e,n);if(i<0)return null;let a=xl(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 d=s.start,u=Fe(o,s,t);return i>=u&&i<d?Je(d,n):null}function it(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 kl(n,e){let t=n.toString();return t.length>=e?t:(new Array(e+1).join(\"0\")+t).slice(-e)}function ca(n){return(e,t,r)=>{let i=Q(r)?parseInt(r,10):1;return kl(String(n),i)}}function ze(n,e,t){return Ml(n,e,t)}function Ml(n,e,t){return n.indexOf(\"$\")===-1?n:n.replace(/\\$\\$/g,\"$\").replace(/\\$RepresentationID\\$/g,String(e)).replace(/\\$Bandwidth(%0(\\d+)d)?\\$/g,ca(t===void 0?0:t))}function Gr(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 ca(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 ca(n)(i,a,o)})}}function Ol(n,e,t){let r=t-n;return r>0?Math.floor(r/e):0}function Xn(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),d=Ce(e,n),u=Ce(s,n),{timeline:f,timescale:l,segmentUrlTemplate:m,startNumber:p,endNumber:h}=n,b=p!=null?p:1,g=[],y=f.length;for(let R=0;R<y;R++){let E=f[R],{duration:C,start:P,range:x}=E,A;o===void 0?A=i:A=Math.min(o*l,i!=null?i:1/0);let k=ma(E,f[R+1],A),N=n.availabilityTimeComplete!==!1||R!==y-1&&k!==0,D=Ol(P,C,d),q=P+D*C;for(;q<u&&D<=k;){let B=b+D;if(h!==void 0&&B>h)break;let _=m===null?null:Gr(q,B)(m),M=q-n.indexTimeOffset,w=C;M<0&&(w=C+M,M=0);let U={id:String(q),time:M/l,end:(M+w)/l,duration:w/l,isInit:!1,range:x,timescale:1,url:_,number:B,timestampOffset:-(n.indexTimeOffset/l),complete:N,privateInfos:{isEMSGWhitelisted:a}};g.push(U),D++,q=P+D*C}if(q>=u||(b+=k+1,h!==void 0&&b>h))return g}return g}function wl(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 Mt=class{constructor(e,t){var h,b,g,y;let{periodStart:r,periodEnd:i,representationId:a,representationBitrate:o,isEMSGWhitelisted:s}=t,d=(h=e.timescale)!=null?h:1,f=((b=e.presentationTimeOffset)!=null?b:0)-r*d,l=((g=e.initialization)==null?void 0:g.media)===void 0?null:ze(e.initialization.media,a,o),m=e.media===void 0?null:ze(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:f,initialization:{url:l,range:p},segmentUrlTemplate:m,startNumber:e.startNumber,endNumber:e.endNumber,timeline:(y=e.timeline)!=null?y:[],timescale:d},this._manifestBoundsCalculator=t.manifestBoundsCalculator,this._scaledPeriodStart=Ce(r,this._index),this._scaledPeriodEnd=v(i)?void 0:Ce(i,this._index),this._isInitialized=this._index.timeline.length>0,this._isEMSGWhitelisted=s}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return Xn(this._index,e,t,this._manifestBoundsCalculator,this._scaledPeriodEnd,this._isEMSGWhitelisted)}shouldRefresh(){return!1}getFirstAvailablePosition(){let e=this._index;return e.timeline.length===0?null:Je(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(Fe(t,null,this._scaledPeriodEnd),(i=this._scaledPeriodEnd)!=null?i:1/0);return Je(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++)wl(this._index,e[t]);this._isInitialized=!0}}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `BaseRepresentationIndex`\")}getTargetSegmentDuration(){let{timeline:e,timescale:t}=this._index,r=e[0];if(r!==void 0)return{duration:r.duration/t,isPrecize:!1}}_replace(e){this._index=e._index,this._isInitialized=e._isInitialized,this._scaledPeriodEnd=e._scaledPeriodEnd,this._isEMSGWhitelisted=e._isEMSGWhitelisted}_update(){c.error(\"dash\",\"Base RepresentationIndex: Cannot update a SegmentList\")}};var Ot=class{constructor(e,t){var p,h,b;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 d=(p=e.presentationTimeOffset)!=null?p:0,u=(h=e.timescale)!=null?h:1,f=d-r*u,l=((b=e.initialization)==null?void 0:b.media)===void 0?null:ze(e.initialization.media,a,o),m=e.list.map(g=>({url:g.media===void 0?null:ze(g.media,a,o),mediaRange:g.mediaRange}));this._index={list:m,timescale:u,duration:e.duration,indexTimeOffset:f,indexRange:e.indexRange,initialization:v(e.initialization)?void 0:{url:l,range:e.initialization.range}}}getInitSegment(){let e=it(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,d=e-this._periodStart,[u,f]=qs(d,t,o),l=Math.min(a.length-1,Math.floor(f/i)),m=[],p=Math.floor(u/i);for(;p<=l;){let h=a[p].mediaRange,b=a[p].url,g=p*s+this._periodStart,y={id:String(p),time:g,isInit:!1,range:h,duration:s,timescale:1,end:g+s,url:b,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(\"dash\",\"A `ListRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `ListRepresentationIndex`\")}getTargetSegmentDuration(){let{duration:e,timescale:t}=this._index;return{duration:e/t,isPrecize:!0}}_replace(e){this._index=e._index}_update(){c.error(\"dash\",\"A `ListRepresentationIndex` cannot be updated\")}};function Kt(n){return L.getCurrent().DEFAULT_MAXIMUM_TIME_ROUNDING_ERROR*n}var wt=class{constructor(e,t){var y,T,R;let{availabilityTimeOffset:r,manifestBoundsCalculator:i,isDynamic:a,periodEnd:o,periodStart:s,representationId:d,representationBitrate:u,isEMSGWhitelisted:f}=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,h=m-p;if(e.duration===void 0)throw new Error(\"Invalid SegmentTemplate: no duration\");let b=((R=e.initialization)==null?void 0:R.media)===void 0?null:ze(e.initialization.media,d,u),g=e.media===void 0?null:ze(e.media,d,u);this._index={duration:e.duration,timescale:l,indexRange:e.indexRange,indexTimeOffset:h,initialization:v(e.initialization)?void 0:{url:b,range:e.initialization.range},url:g,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=f}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){let r=this._index,{duration:i,startNumber:a,endNumber:o,timescale:s,url:d}=r,u=this._periodStart*s,f=this._scaledRelativePeriodEnd,l=e*s-u,m=(e+t)*s-u,p=this._getFirstSegmentStart(),h=this._getLastSegmentStart();if(v(p)||v(h))return[];let b=Math.max(p,l),g=Math.min(h,m);if(g+i<=b)return[];let y=[],T=a!=null?a:1,R=Math.floor(b/i);for(let E=R*i;E<=g;E+=i){let C=R+T;if(o!==void 0&&C>o)return y;let P=!v(f)&&E+i>f?f-E:i,x=E+u,A=E+this._index.presentationTimeOffset,k=d===null?null:Gr(A,C)(d),N={id:String(C),number:C,time:x/s,end:(x+P)/s,duration:P/s,timescale:1,isInit:!1,scaledDuration:P/s,url:k,timestampOffset:-(r.indexTimeOffset/s),complete:!0,privateInfos:{isEMSGWhitelisted:this._isEMSGWhitelisted}};y.push(N),R++}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=Kt(r),a=this._periodStart*r,o=e*r-a,s=t*r-a,d=this._getLastSegmentStart();if(v(d)){let l=this._estimateRelativeScaledEnd();return l===void 0?s+i>=0:s+i>=0&&o<l-i}let u=d+this._index.duration,f=this._estimateRelativeScaledEnd();return f===void 0?s>u-i:s>u-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=Kt(t);return i+a<e}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TemplateRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `TemplateRepresentationIndex`\")}getTargetSegmentDuration(){return{duration:this._index.duration/this._index.timescale,isPrecize:!0}}_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 d=this._manifestBoundsCalculator.getEstimatedMaximumPosition((a=this._availabilityTimeOffset)!=null?a:0);if(d===void 0)return;let u=(d-this._periodStart)*t;if(u<0)return null;let f=Math.floor(u/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,d=Math.ceil(s/e);r!==void 0&&r-i+1<d&&(d=r-i+1);let u=(d-1)*e,f=L.getCurrent().MINIMUM_SEGMENT_SIZE*t;return r!==void 0||s-u>f||d<2?u:(d-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 pa(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 ga(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(Fe(i,e[0])<r)throw new Z(\"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 m=t-f;return n.splice(f,m,...e),!1}else if(l<r){let m=n[f];if(m.start+m.duration>r)return c.warn(\"utils\",\"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(f+1,t-(f+1),...e),!1;if(m.start+m.duration*(m.repeatCount+1)<=r)return n.splice(f+1,t-(f+1),...e),!1;let h=(r-m.start)/m.duration-1;if(h%1===0&&m.duration===e[0].duration){let b=e[0].repeatCount<0?-1:e[0].repeatCount+h+1;return n.splice(f,t-f,...e),n[f].start=m.start,n[f].repeatCount=b,!1}return c.warn(\"utils\",\"Manifest update removed previous segments\"),n[f].repeatCount=Math.floor(h),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?(c.warn(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0);let d=o.start+o.duration*(o.repeatCount+1),u=s.start+s.duration*(s.repeatCount+1);return d>=u?(c.warn(\"utils\",\"The new index is older than the previous one\"),!1):(c.warn(\"utils\",'The new index is \"bigger\" than the previous one'),n.splice(0,t,...e),!0)}function Zn(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 Jn(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 value for <S> element\",{val:r}):e.start=i;break}case\"d\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid d value for <S> element\",{val:r}):e.duration=i;break}case\"r\":{let i=parseInt(r,10);isNaN(i)?c.warn(\"dash\",\"invalid r value for <S> element\",{val:r}):e.repeatCount=i;break}}}return e}function yt(n){let e=[];for(let r=0;r<n.length;r++)e.push(Jn(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=Zn(i,a,o);s!==null&&t.push(s)}return t}function ha(n,e){if(n.length===0||e.length===0)return null;let t=n[0].start,r=e[0].attributes.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=e[0],s=i;for(;;){let d=o.attributes.d,u=v(d)?null:parseInt(d,10);if(u===null||Number.isNaN(u))return null;let f=o.attributes.r,l=v(f)?null:parseInt(f,10);if(l!==null){if(Number.isNaN(l)||l<0)return null;if(l>0){let h=t-s;if(h%u===0&&h/u<=l)return{repeatNumberInPrevSegments:0,repeatNumberInNewElements:h/u,prevSegmentsIdx:0,newElementsIdx:a}}s+=u*(l+1)}else s+=u;if(a++,a>=e.length)return null;o=e[a];let m=o.attributes.t,p=v(m)?null:parseInt(m,10);if(p!==null){if(Number.isNaN(p))return null;s=p}if(s===t)return{newElementsIdx:a,prevSegmentsIdx:0,repeatNumberInPrevSegments:0,repeatNumberInNewElements:0};if(s>i)return null}}}function Ia(n,e){var b;let t=ha(e,n);if(t===null)return c.warn(\"dash\",'Cannot perform \"based\" update. Common segment not found.'),yt(n);let{prevSegmentsIdx:r,newElementsIdx:i,repeatNumberInPrevSegments:a,repeatNumberInNewElements:o}=t,d=e.length-r+i-1;if(d>=n.length)return c.info(\"dash\",'Cannot perform \"based\" update. New timeline too short'),yt(n);let u=e.slice(r);if(a>0){let g=u[0];g.start+=g.duration*a,u[0].repeatCount-=a}if(o>0&&i!==0)return c.info(\"dash\",'Cannot perform \"based\" update. The new timeline has a different form.'),yt(n);let f=u[u.length-1],l=Jn(n[d]),m=((b=l.repeatCount)!=null?b:0)-o;if(l.duration!==f.duration||f.repeatCount>m)return c.info(\"dash\",'Cannot perform \"based\" update. The new timeline has a different form at the beginning.'),yt(n);l.repeatCount!==void 0&&l.repeatCount>f.repeatCount&&(f.repeatCount=l.repeatCount);let p=[],h=[];for(let g=d+1;g<n.length;g++)h.push(Jn(n[g]));for(let g=0;g<h.length;g++){let y=h[g],T=p[p.length-1]===void 0?f:p[p.length-1],R=h[g+1]===void 0?null:h[g+1],E=Zn(y,T,R);E!==null&&p.push(E)}return u.concat(p)}var er=class n{constructor(e,t){var E,C,P,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:d,representationBitrate:u,periodStart:f,periodEnd:l,isEMSGWhitelisted:m}=t,p=(E=e.timescale)!=null?E:1,h=(C=e.presentationTimeOffset)!=null?C:0,b=f*p,g=h-b;this._manifestBoundsCalculator=a,this._isEMSGWhitelisted=m,this._isLastPeriod=s,this._lastUpdate=(P=t.receivedTime)!=null?P:F(),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:ze(e.initialization.media,d,u),T=e.media===void 0?null:ze(e.media,d,u),R;i===void 0&&r===void 0?R=1/0:R=i!=null?i:0,this._index={availabilityTimeComplete:r!=null?r:!0,availabilityTimeOffset:R,indexRange:e.indexRange,indexTimeOffset:g,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:ba(e.timeline,e.startNumber,e.endNumber),timescale:p},this._scaledPeriodStart=Ce(f,this._index),this._scaledPeriodEnd=l===void 0?void 0:Ce(l,this._index)}getInitSegment(){return it(this._index,this._isEMSGWhitelisted)}getSegments(e,t){return this._refreshTimeline(),this._index.timeline===null&&(this._index.timeline=this._getTimeline()),Xn(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:Je(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=Hr(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 Je(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(Fe(e,null,this._scaledPeriodEnd),(r=this._scaledPeriodEnd)!=null?r:1/0);return Je(t,this._index)}awaitSegmentBetween(e,t){var u,f;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=Kt(r),o=Ce(t,this._index),s=Hr(this._index,this._manifestBoundsCalculator,this._scaledPeriodEnd);if(s!==null&&Math.min(s.end,(u=this._scaledPeriodEnd)!=null?u:1/0)+a>=Math.min(o,(f=this._scaledPeriodEnd)!=null?f:1/0))return!1;let d=Ce(e,this._index);if(i.length>0&&s!==null&&!s.isLastOfTimeline){let l=i[i.length-1],p=Fe(l,null,this._scaledPeriodEnd)+a;if(d<p+a)return!0}return this._isLastPeriod?this._scaledPeriodEnd===void 0?o+a>this._scaledPeriodStart?void 0:!1:d-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()),Dl(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),Ws({timeline:t,timescale:this._index.timescale,indexTimeOffset:this._index.indexTimeOffset},e,this._scaledPeriodEnd)}canBeOutOfSyncError(e){return this._isDynamic?e instanceof Xe&&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()),ga(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&&Ce(s,this._index)>this._scaledPeriodEnd)return!1}return this._isLastPeriod}let t=Kt(this._index.timescale),r=Hr(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 Fe(i,null,this._scaledPeriodEnd)+t<this._scaledPeriodEnd}isInitialized(){return!0}initialize(){c.error(\"dash\",\"A `TimelineRepresentationIndex` does not need to be initialized\")}addPredictedSegments(){c.warn(\"dash\",\"Cannot add predicted segments to a `TimelineRepresentationIndex`\")}getTargetSegmentDuration(){this._refreshTimeline();let{timeline:e,timescale:t}=this._index;if(e===null)return;let r=e[0];if(r!==void 0)return{duration:r.duration/t,isPrecize:!1}}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=Ce(e,this._index),r=pa(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}=L.getCurrent();if(this._unsafelyBaseOnPreviousIndex===null||e.length<t)return ba(yt(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,ba(Ia(e,r),this._index.startNumber,this._index.endNumber)}};function ba(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=J({},a),d=r-a.repeatCount-1;return s.repeatCount=Math.max(0,t-d),o.push(s),o}}}return n}function Dl(n,e,t,r){let i=Hr(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 u=(s-o.start)/o.duration-1;return u%1===0&&u<=i.newRepeatCount}}return!1}function Hr(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:Fe(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:Fe(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(Je(o,n)<=r){let s=Fe(a,n.timeline[i+1],t);if(Je(s,n)<=r)return{isLastOfTimeline:i===n.timeline.length-1,timelineIdx:i,newRepeatCount:a.repeatCount,end:o};{let u=Ce(r,n)-a.start,f=Math.floor(u/a.duration);return Ie(f>=1),{isLastOfTimeline:!1,timelineIdx:i,newRepeatCount:f-1,end:a.start+f*a.duration}}}}return null}var Kr=er;var tr=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 ya(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\"),ya(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),ya(e,t),!0)}_getReferenced(e){return this._refs.get(e)}};function ya(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=e.attributes.keyId;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=j(n.contentProtections.initData,o=>o.type===\"cenc\");a===void 0?n.contentProtections.initData.push({type:\"cenc\",values:i}):a.values.push(...i)}function jr(n){let e=Date.parse(n)-F();if(isNaN(e)){c.warn(\"dash\",\"Invalid clock received\",{clock:n});return}return e}function Sa(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 Yr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getLastAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.min(t,i))}return t===null?null:t}function Ta(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=Yr(r);if(s===void 0)return{safe:void 0,unsafe:void 0};a=s}if(i!==void 0){let s=Yr(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(\"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 Qr(n){let{representations:e}=n,t=null;for(let r of e){let i=r.index.getFirstAvailablePosition();if(i===void 0)return;i!==null&&(t=t===null?i:Math.max(t,i))}return t===null?null:t}function Ea(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=Qr(r);if(s===void 0)return;a=s}if(i!==void 0){let s=Qr(i);if(s===void 0)return;o=s}if(r!==void 0&&a===null||i!==void 0&&o===null){c.info(\"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 _a(n){if(n.length===0)throw new Error(\"DASH Parser: no period available for a dynamic content\");let e=Ea(n),t=Ta(n);return{minimumSafePosition:e,maximumSafePosition:t.safe,maximumUnsafePosition:t.unsafe}}var nr=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(F()+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+F()/1e3,0):this._lastPosition}};function Ra(n,e){return n.type!==\"dynamic\"?0:v(n.availabilityStartTime)?e!=null?e:0:n.availabilityStartTime}function Pa(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.\",{lastStart:i==null?void 0:i.start,newStart: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 va(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 u=t[t.length-1];if(!v(u)&&!v(u.periodEnd))a=u.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 d=v(o)?void 0:a+o;t.push({periodStart:a,periodDuration:o,periodEnd:d})}),t}function Bl(n,e){for(let t of e){let{adaptation:r,trickModeAttachedAdaptationIds:i}=t;for(let a of i)for(let o of Lt){let s=n[o];if(s!==void 0)for(let d of s)d.id===a&&(d.trickModeTracks===void 0&&(d.trickModeTracks=[]),d.trickModeTracks.push(r))}}}var Vs=Bl;var Nl=[\"subtitle\",\"caption\"];function Ca(n,e){var s,d,u,f;let t=(f=j((s=n.children.essentialProperties)!=null?s:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\"))!=null?f:j((u=(d=e!=null?e:n.children.representations[0])==null?void 0:d.children.essentialProperties)!=null?u:[],l=>l.schemeIdUri===\"http://dashif.org/guidelines/thumbnail_tile\"||l.schemeIdUri===\"http://dashif.org/thumbnail_tile\");if(t===void 0)return null;let r=/(\\d+)x(\\d+)/;if(t===void 0||t.value===void 0||!r.test(t.value))return c.warn(\"dash\",\"Invalid thumbnails Representation, no tile-related information\"),null;let i=t.value.match(r),a=parseInt(i[1],10),o=parseInt(i[2],10);return{horizontalTiles:a,verticalTiles:o}}function Aa(n,e){if(n.attributes.contentType===\"image\")return Ca(n)!==null?\"thumbnails\":void 0;let t=Q(n.attributes.mimeType)?n.attributes.mimeType:null,r=Q(n.attributes.codecs)?n.attributes.codecs:null,i=v(n.children.roles)?null:n.children.roles;function a(s,d){let u=s.split(\"/\")[0];if(ue(Lt,u))return u;if(s===\"application/ttml+xml\")return\"text\";if(s===\"application/mp4\")return d!==null&&j(d,f=>f.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&ue(Nl,f.value))!==void 0?\"text\":void 0}function o(s){switch(s.substring(0,3)){case\"avc\":case\"hev\":case\"hvc\":case\"vp8\":case\"vp9\":case\"av1\":return\"video\";case\"vtt\":return\"text\"}switch(s.substring(0,4)){case\"mp4a\":return\"audio\";case\"wvtt\":case\"stpp\":return\"text\"}}if(t!==null){let s=a(t,i);if(s!==void 0)return s}if(r!==null){let s=o(r);if(s!==void 0)return s}for(let s=0;s<e.length;s++){let d=e[s],{mimeType:u,codecs:f}=d.attributes;if(u!==void 0){let l=a(u,i);if(l!==void 0)return l}if(f!==void 0){let l=o(f);if(l!==void 0)return l}}}var Ul=/[, ]+/g;function Gs(n){return Q(n)?n.trim().replace(Ul,\", \"):\"\"}function Hs(n){let[e,t,r,i,a,o,s,d]=n.split(\".\");if(e!==\"vp08\"&&e!==\"vp09\"&&e!==\"vp10\")return;let u,f,l;if((i!==void 0&&i===\"10\"||i===\"12\")&&(u=parseInt(i,10)),s!==void 0&&(s===\"16\"?f=\"pq\":s===\"18\"&&(f=\"hlg\")),o!==void 0&&d!==void 0&&o===\"09\"&&d===\"09\"&&(l=\"rec2020\"),!(u===void 0||f===void 0))return{colorDepth:u,eotf:f,colorSpace:l}}function xa(n,e){var h,b,g;let{availabilityTimeOffset:t,manifestBoundsCalculator:r,isDynamic:i,end:a,start:o,receivedTime:s,unsafelyBaseOnPreviousRepresentation:d,inbandEventStreams:u,isLastPeriod:f}=e,m={availabilityTimeComplete:void 0,availabilityTimeOffset:t,unsafelyBaseOnPreviousRepresentation:d,isEMSGWhitelisted:y=>u===void 0?!1:u.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},p;if(n.children.segmentBase!==void 0){let{segmentBase:y}=n.children;p=new Mt(y,m)}else if(n.children.segmentList!==void 0){let{segmentList:y}=n.children;p=new Ot(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 R=K({},...y);(R.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(m.availabilityTimeOffset=((h=R.availabilityTimeOffset)!=null?h:0)+((b=e.availabilityTimeOffset)!=null?b:0)),(R.availabilityTimeComplete!==void 0||e.availabilityTimeComplete!==void 0)&&(m.availabilityTimeComplete=(g=R.availabilityTimeComplete)!=null?g:e.availabilityTimeComplete),p=Kr.isTimelineIndexArgument(R)?new Kr(R,m):new wt(R,m)}else{let y=e.adaptation.children;if(y.segmentBase!==void 0){let{segmentBase:T}=y;p=new Mt(T,m)}else if(y.segmentList!==void 0){let{segmentList:T}=y;p=new Ot(T,m)}else p=new wt({duration:Number.MAX_VALUE,timescale:1,startNumber:0,media:\"\"},m)}return p}function at(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 d=t[s],u=Fn(o.url,d.url);r.push({url:u,serviceLocation:(i=d.serviceLocation)!=null?i:o.serviceLocation})}}return r}function Ll(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 Fl({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=j([...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)/.test(i))return Hs(i)}function ka(n,e,t){var i,a,o,s,d,u,f;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(k=>k.id===m);)m+=\"-dup\";let p=(a=(i=t.unsafelyBaseOnPreviousAdaptation)==null?void 0:i.getRepresentation(m))!=null?a:null,h=Ll(l,e),b=(o=l.attributes.availabilityTimeComplete)!=null?o:t.availabilityTimeComplete,g;(l.attributes.availabilityTimeOffset!==void 0||t.availabilityTimeOffset!==void 0)&&(g=((s=l.attributes.availabilityTimeOffset)!=null?s:0)+((d=t.availabilityTimeOffset)!=null?d:0));let y=K({},t,{availabilityTimeOffset:g,availabilityTimeComplete:b,unsafelyBaseOnPreviousRepresentation:p,adaptation:e,inbandEventStreams:h}),T=xa(l,y),R;l.attributes.bitrate===void 0?(c.warn(\"dash\",\"No usable bitrate found in the Representation.\"),R=0):R=l.attributes.bitrate;let E=at(t.baseURLs,l.children.baseURLs),C=E.length===0?[{baseUrl:\"\",id:void 0}]:E.map(k=>({baseUrl:k.url,id:k.serviceLocation})),P={bitrate:R,cdnMetadata:C,index:T,id:m};l.children.supplementalProperties!==void 0&&j(l.children.supplementalProperties,k=>k.schemeIdUri===\"tag:dolby.com,2018:dash:EC3_ExtensionType:2018\"&&k.value===\"JOC\")!==void 0&&(P.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,P.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&&(P.supplementalCodecs=Gs(A)),l.attributes.frameRate!==void 0?P.frameRate=l.attributes.frameRate:e.attributes.frameRate!==void 0&&(P.frameRate=e.attributes.frameRate),l.attributes.height!==void 0?P.height=l.attributes.height:e.attributes.height!==void 0&&(P.height=e.attributes.height),l.attributes.mimeType!==void 0?P.mimeType=l.attributes.mimeType:e.attributes.mimeType!==void 0&&(P.mimeType=e.attributes.mimeType),l.attributes.width!==void 0?P.width=l.attributes.width:e.attributes.width!==void 0&&(P.width=e.attributes.width);{let k=[...(u=e.children.contentProtections)!=null?u:[],...(f=l.children.contentProtections)!=null?f:[]];for(let N of k)t.contentProtectionParser.add(P,N)}P.hdrInfo=Fl({adaptationProfiles:e.attributes.profiles,supplementalProperties:e.children.supplementalProperties,essentialProperties:e.children.essentialProperties,manifestProfiles:t.manifestProfiles,codecs:x}),r.push(P)}return r}function zl(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 ql(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 Wl(n){return n===void 0?!1:n.schemeIdUri===\"urn:mpeg:dash:role:2011\"&&n.value===\"sign\"}function Vl(n,e){if(Q(n.attributes.id))return n.attributes.id;let{isClosedCaption:t,isForcedSubtitle:r,isAudioDescription:i,isSignInterpreted:a,isTrickModeTrack:o,type:s}=e,d=s;return Q(n.attributes.language)&&(d+=`-${n.attributes.language}`),t===!0&&(d+=\"-cc\"),r===!0&&(d+=\"-cc\"),i===!0&&(d+=\"-ad\"),a===!0&&(d+=\"-si\"),o&&(d+=\"-trickMode\"),Q(n.attributes.contentType)&&(d+=`-${n.attributes.contentType}`),Q(n.attributes.codecs)&&(d+=`-${n.attributes.codecs}`),Q(n.attributes.mimeType)&&(d+=`-${n.attributes.mimeType}`),n.attributes.frameRate!==void 0&&(d+=`-${String(n.attributes.frameRate)}`),d}function Gl(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=>Q(r))}return[]}function Ma(n,e){var d,u,f,l,m,p,h;let t={video:[],audio:[],text:[]},r=[],i=[],a={},o=[];for(let b=0;b<n.length;b++){let g=n[b],y=g.children,{essentialProperties:T,roles:R,label:E}=y,C=Array.isArray(R)&&R.some(ae=>ae.value===\"main\")&&R.some(ae=>ae.schemeIdUri===\"urn:mpeg:dash:role:2011\"),P=g.children.representations,x=(d=g.attributes.availabilityTimeComplete)!=null?d:e.availabilityTimeComplete,A;(g.attributes.availabilityTimeOffset!==void 0||e.availabilityTimeOffset!==void 0)&&(A=((u=g.attributes.availabilityTimeOffset)!=null?u:0)+((f=e.availabilityTimeOffset)!=null?f:0));let k=Aa(g,P);if(k===void 0)continue;let N=(l=g.attributes.selectionPriority)!=null?l:1,D=g.attributes.id,q=Gl(g),B=[];e.segmentTemplate!==void 0&&B.push(e.segmentTemplate),g.children.segmentTemplate!==void 0&&B.push(g.children.segmentTemplate);let _={availabilityTimeComplete:x,availabilityTimeOffset:A,baseURLs:at(e.baseURLs,y.baseURLs),contentProtectionParser:e.contentProtectionParser,manifestBoundsCalculator:e.manifestBoundsCalculator,end:e.end,isDynamic:e.isDynamic,isLastPeriod:e.isLastPeriod,manifestProfiles:e.manifestProfiles,parentSegmentTemplates:B,receivedTime:e.receivedTime,start:e.start,unsafelyBaseOnPreviousAdaptation:null},M=Array.isArray(T)?j(T,ae=>ae.schemeIdUri===\"http://dashif.org/guidelines/trickmode\"):void 0,w=(m=M==null?void 0:M.value)==null?void 0:m.split(\" \"),U=w!==void 0,{accessibilities:H}=y,$;R!==void 0&&R.some(ae=>ae.value===\"dub\")&&($=!0);let V;k!==\"text\"?V=!1:V=ql(H,R);let G;k===\"text\"&&R!==void 0&&R.some(ae=>ae.value===\"forced-subtitle\"||ae.value===\"forced_subtitle\")&&(G=!0);let Y;k!==\"audio\"?Y=!1:H!==void 0&&(Y=H.some(zl));let me;k!==\"video\"?me=!1:H!==void 0&&(me=H.some(Wl));let le=Vl(g,{isAudioDescription:Y,isForcedSubtitle:G,isClosedCaption:V,isSignInterpreted:me,isTrickModeTrack:U,type:k});for(;ue(o,le);)le+=\"-dup\";let ce=le;o.push(le),_.unsafelyBaseOnPreviousAdaptation=(h=(p=e.unsafelyBaseOnPreviousPeriod)==null?void 0:p.getAdaptation(le))!=null?h:null;let Qe=ka(P,g,_);if(k===\"thumbnails\"){let ae=Hl(g,Qe);ae!==null&&r.push(...ae);continue}let te={id:le,representations:Qe,type:k,isTrickModeTrack:U};if(v(g.attributes.language)||(te.language=g.attributes.language),v(V)||(te.closedCaption=V),v(Y)||(te.audioDescription=Y),$===!0&&(te.isDub=!0),G!==void 0&&(te.forcedSubtitles=G),me===!0&&(te.isSignInterpreted=!0),E!==void 0&&(te.label=E),w!==void 0)i.push({adaptation:te,trickModeAttachedAdaptationIds:w});else{let ae=-1;for(let Xt of q){let Zt=a[Xt];if(Zt!==void 0&&Zt.newID!==ce&&ue(Zt.adaptationSetSwitchingIDs,D)){ae=ne(t[k],Jt=>Jt[0].id===Xt);let _e=t[k][ae];if(_e!==void 0&&_e[0].audioDescription===te.audioDescription&&_e[0].closedCaption===te.closedCaption&&_e[0].language===te.language){c.info(\"dash\",'merging \"switchable\" AdaptationSets',{originalID:D,id:Xt}),_e[0].representations.push(...te.representations),_e[1]={priority:Math.max(N,_e[1].priority),isMainAdaptation:C||_e[1].isMainAdaptation,indexInMpd:Math.min(b,_e[1].indexInMpd)};break}}}ae<0&&t[k].push([te,{priority:N,isMainAdaptation:C,indexInMpd:b}])}!v(D)&&v(a[D])&&(a[D]={newID:ce,adaptationSetSwitchingIDs:q})}let s=Lt.reduce((b,g)=>{let y=t[g];return y.length>0&&(y.sort(Ks),b[g]=y.map(([T])=>T)),b},{});return t.video.sort(Ks),Vs(s,i),{adaptations:s,thumbnailTracks:r}}function Hl(n,e){var r,i;let t=[];for(let a=0;a<e.length;a++){let o=e[a];if(o!==void 0){if(o.mimeType===void 0){c.warn(\"dash\",\"Invalid thumbnails Representation, no mime-type\");continue}let s=Ca(n,n.children.representations[a]);if(s===null)continue;if(o.height===void 0){c.warn(\"dash\",\"Invalid thumbnails Representation, no height information\");continue}if(o.width===void 0){c.warn(\"dash\",\"Invalid thumbnails Representation, no width information\");continue}let d=(r=o.index.getFirstAvailablePosition())!=null?r:void 0,u=(i=o.index.getEnd())!=null?i:void 0,f,l=o.index.getTargetSegmentDuration();l!==void 0&&l.isPrecize?f=l.duration:c.warn(\"dash\",\"Cannot produce duration estimate for thumbnail track\"),t.push({id:o.id,cdnMetadata:o.cdnMetadata,index:o.index,mimeType:o.mimeType,height:o.height,width:o.width,horizontalTiles:s.horizontalTiles,verticalTiles:s.verticalTiles,start:d,end:u,tileDuration:f===void 0?void 0:f/(s.horizontalTiles*s.verticalTiles)})}}return t}function Ks(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 Kl=Me();function Oa(n,e){var o,s,d,u,f;let t=[],r=va(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],h=e.xlinkInfos.get(p),b=at(e.baseURLs,p.children.baseURLs),{periodStart:g,periodDuration:y,periodEnd:T}=r[l],R;for(v(p.attributes.id)?(R=\"gen-dash-period-\"+Kl(),c.warn(\"dash\",\"No usable id found in the Period. Generating one.\",{periodId:R})):R=p.attributes.id;t.some(U=>U.id===R);)R+=\"-dup\";let E=h!==void 0?h.receivedTime:e.receivedTime,C=(s=(o=e.unsafelyBaseOnPreviousManifest)==null?void 0:o.getPeriod(R))!=null?s:null,P=p.attributes.availabilityTimeComplete,x=p.attributes.availabilityTimeOffset,{manifestProfiles:A,contentProtectionParser:k}=e,{segmentTemplate:N}=p.children;k.addReferences((d=p.children.contentProtections)!=null?d:[]);let D={availabilityTimeComplete:P,availabilityTimeOffset:x,baseURLs:b,contentProtectionParser:k,manifestBoundsCalculator:a,end:T,isDynamic:i,isLastPeriod:m,manifestProfiles:A,receivedTime:E,segmentTemplate:N,start:g,unsafelyBaseOnPreviousPeriod:C},{adaptations:q,thumbnailTracks:B}=Ma(p.children.adaptations,D),_=((u=e.xmlNamespaces)!=null?u:[]).concat((f=p.attributes.namespaces)!=null?f:[]),M=Yl(p.children.eventStreams,g,_),w={id:R,start:g,end:T,duration:y,thumbnailTracks:B,adaptations:q,streamEvents:M};if(t.unshift(w),!a.lastPositionIsKnown()){let U=jl(q);if(!i)typeof U==\"number\"&&a.setLastPosition(U);else if(typeof U==\"number\"){let H=F()/1e3;a.setLastPosition(U,H)}else{let H=js(e,g);if(H!==void 0){let[$,V]=H;a.setLastPosition($,V)}}}}if(e.isDynamic&&!a.lastPositionIsKnown()){let l=js(e,0);if(l!==void 0){let[m,p]=l;a.setLastPosition(m,p)}}return Pa(t)}function js(n,e){if(v(n.clockOffset)){let t=Date.now()/1e3;if(t>=e){c.warn(\"dash\",\"no clock synchronization mechanism found. Using the system clock instead.\");let r=t-n.availabilityStartTime,i=F()/1e3;return[r,i]}}else{let t=n.clockOffset/1e3-n.availabilityStartTime,r=F()/1e3,i=r+t;if(i>=e)return[i,r]}}function jl(n){let e=null,t=!0,r=yr(n).filter(a=>!v(a)),i=Ri(r,a=>a);for(let a of i){let o=a.representations;for(let s of o){let d=s.index.getLastAvailablePosition();d!==null&&(t=!1,typeof d==\"number\"&&(e=v(e)?d:Math.max(e,d)))}}if(v(e)){if(t)return null}else return e}function Yl(n,e,t){var i,a;let r=[];for(let o of n){let{schemeIdUri:s=\"\",timescale:d=1}=o.attributes,u=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)/d+e,m=f.duration===void 0?void 0:l+f.duration/d,p,h;try{h={namespaces:u,data:typeof f.eventStreamData==\"string\"?f.eventStreamData:Ge(new Uint8Array(f.eventStreamData))}}catch(b){c.error(\"dash\",\"Error while parsing event-stream:\",b instanceof Error?b.message:\"Unknown error\")}r.push({start:l,end:m,id:f.id,data:{type:\"dash-event-stream\",value:{schemeIdUri:s,timescale:d,element:p,xmlData:h}}})}}return r}function jt(n,e,t,r,i=new WeakMap){let{children:a,attributes:o}=n;if(v(e.externalClockOffset)){let d=o.type===\"dynamic\",u=j(a.utcTimings,m=>m.schemeIdUri===\"urn:mpeg:dash:utc:direct:2014\"&&!v(m.value)),f=!v(u)&&!v(u.value)?jr(u.value):void 0,l=!v(f)&&!isNaN(f)?f:void 0;if(!v(l)&&r!==!0)e.externalClockOffset=l;else if(d&&r!==!0){let m=Sa(n);if(!v(m)&&m.length>0)return{type:\"needs-clock\",value:{url:m,continue:function(h){return h.success?(e.externalClockOffset=jr(h.data),jt(n,e,t,!0)):(t.push(h.error),c.warn(\"dash\",\"Error on fetching the clock ressource\",h.error),jt(n,e,t,!0))}}}}}let s=[];for(let d=0;d<a.periods.length;d++){let{xlinkHref:u,xlinkActuate:f}=a.periods[d].attributes;!v(u)&&f===\"onLoad\"&&s.push({index:d,ressource:u})}return s.length===0?Ql(n,e,t,i):{type:\"needs-xlinks\",value:{xlinksUrls:s.map(({ressource:d})=>d),continue:function(u){if(u.length!==s.length)throw new Error(\"DASH parser: wrong number of loaded ressources.\");for(let f=u.length-1;f>=0;f--){let l=s[f].index,{parsed:m,warnings:p,receivedTime:h,sendingTime:b,url:g}=u[f];p.length>0&&t.push(...p);for(let y of m)i.set(y,{receivedTime:h,sendingTime:b,url:g});a.periods.splice(l,1,...m)}return jt(n,e,t,r,i)}}}}function Ql(n,e,t,r){var _,M,w,U,H;let{children:i,attributes:a}=n,o=a.type===\"dynamic\",s=e.url!==void 0?[{url:e.url.substring(0,Qi(e.url))}]:[],d=at(s,i.baseURLs),u=Ra(a,e.referenceDateTime),f=a.timeShiftBufferDepth,l=a.maxSegmentDuration,{externalClockOffset:m,unsafelyBaseOnPreviousManifest:p}=e,{externalClockOffset:h}=e,b=new nr({availabilityStartTime:u,isDynamic:o,timeShiftBufferDepth:f,serverTimestampOffset:h}),g=new tr;g.addReferences((_=i.contentProtections)!=null?_:[]);let y={availabilityStartTime:u,baseURLs:d,clockOffset:m,contentProtectionParser:g,duration:a.duration,isDynamic:o,manifestBoundsCalculator:b,manifestProfiles:n.attributes.profiles,receivedTime:e.manifestReceivedTime,unsafelyBaseOnPreviousManifest:p,xlinkInfos:r,xmlNamespaces:n.attributes.namespaces},T=Oa(i.periods,y);g.finalize();let R=a.duration,E,C,P=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:k,maximumUnsafePosition:N}=_a(T),D=F();if(o){let $;k!==void 0?$=k:h===void 0?(c.warn(\"dash\",\"use system clock to define maximum position\"),$=Date.now()/1e3-u):$=(F()+h)/1e3-u;let V=b.getEstimatedLiveEdge();V===void 0&&(N!==void 0?V=N:V=$),x={isLinear:!0,maximumSafePosition:$,livePosition:V,time:D},C=A,P=f!=null?f:null,P!==null&&(P+=l!=null?l:0),P!==null&&C!==void 0&&V-C>P&&(P=V-C)}else{C=A,C===void 0&&(C=(w=(M=T[0])==null?void 0:M.start)!=null?w:0);let $=R!=null?R:1/0;if(T[T.length-1]!==void 0){let V=T[T.length-1],G=(U=V.end)!=null?U:V.duration!==void 0?V.start+V.duration:void 0;G!==void 0&&G<$&&($=G)}k!==void 0&&k<$&&($=k),x={isLinear:!1,maximumSafePosition:$,livePosition:void 0,time:D}}let q=!o||n.attributes.minimumUpdatePeriod===void 0&&(((H=T[T.length-1])==null?void 0:H.end)!==void 0||n.attributes.duration!==void 0);return{type:\"done\",value:{parsed:{availabilityStartTime:u,clockOffset:e.externalClockOffset,isDynamic:o,isLive:o,isLastPeriodKnown:q,periods:T,publishTime:a.publishTime,suggestedPresentationDelay:a.suggestedPresentationDelay,transportType:\"dash\",timeBounds:{minimumSafePosition:C,timeshiftDepth:P,maximumTimeData:x},lifetime:E,uris:v(e.url)?i.locations:[e.url,...i.locations]},warnings:t}}}var $r=jt;var $l=/^P(([\\d.]*)Y)?(([\\d.]*)M)?(([\\d.]*)D)?T?(([\\d.]*)H)?(([\\d.]*)M)?(([\\d.]*)S)?/,Xl=/([0-9]+)-([0-9]+)/;function Ae(n,e){return n===\"true\"?[!0,null]:n===\"false\"?[!1,null]:[!1,new De(`\\`${e}\\` property is not a boolean value but \"${n}\"`)]}function ie(n,e){let t=parseInt(n,10);return isNaN(t)?[null,new De(`\\`${e}\\` property is not an integer value but \"${n}\"`)]:[t,null]}function we(n,e){if(n===\"INF\")return[1/0,null];let t=parseFloat(n);return isNaN(t)?[null,new De(`\\`${e}\\` property is invalid: \"${n}\"`)]:[t,null]}function wa(n,e){if(n===\"true\")return[!0,null];if(n===\"false\")return[!1,null];let t=parseInt(n,10);return isNaN(t)?[null,new De(`\\`${e}\\` property is not a boolean nor an integer but \"${n}\"`)]:[t,null]}function Xr(n,e){let t=Date.parse(n);return isNaN(t)?[null,new De(`\\`${e}\\` is in an invalid date format: \"${n}\"`)]:[new Date(Date.parse(n)).getTime()/1e3,null]}function Ke(n,e){if(!Q(n))return[0,new De(`\\`${e}\\` property is empty`)];let t=$l.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[parseFloat(Q(t[2])?t[2]:\"0\")*365*24*60*60+parseFloat(Q(t[4])?t[4]:\"0\")*30*24*60*60+parseFloat(Q(t[6])?t[6]:\"0\")*24*60*60+parseFloat(Q(t[8])?t[8]:\"0\")*60*60+parseFloat(Q(t[10])?t[10]:\"0\")*60+parseFloat(Q(t[12])?t[12]:\"0\"),null]}function Dt(n,e){let t=Xl.exec(n);return t===null?[null,new De(`\\`${e}\\` property has an unrecognized format \"${n}\"`)]:[[+t[1],+t[2]],null]}function Ys(n,e){try{return[_r(n),null]}catch(t){return[null,new De(`\\`${e}\\` is not a valid base64 string: \"${n}\"`)]}}function Yt(n,e){let t=/^(\\d+)\\/(\\d+)$/.exec(n);return t!==null?[+t[1]/+t[2],null]:we(n,e)}function Se(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 Te(n,e){return function(t,{asKey:r,parser:i,dashName:a}){let[o,s]=i(t,a);s!==null&&(c.warn(\"dash\",\"failed to parse DASH value:\",s.message,{dashName:a}),e.push(s)),o!==null&&(n[r]=o)}}var De=class n extends Error{constructor(e){super(e),Object.setPrototypeOf(this,n.prototype),this.name=\"MPDError\"}};function St(n){return Vr(n)}function ot(n){let e=typeof n==\"string\"?n:St(n.children),t=[];return e===null||e.length===0?[void 0,t]:[{value:e},t]}function Zl(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=St(i.children);if(a!==null&&a.length>0){let[o,s]=Ys(a,\"cenc:pssh\");s!==null&&(c.warn(\"dash\",\"Content protection parsing failure\",s.message),e.push(s)),o!==null&&t.push(o)}}}return[{cencPssh:t},e]}function Jl(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=sn(r.replace(/-/g,\"\"));break;case\"ref\":e.ref=r;break;case\"refId\":e.refId=r;break}}return e}function st(n){let[e,t]=Zl(n.children),r=Jl(n);return[{children:e,attributes:r},t]}function Da(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 Ba(n){let e={},t=[],r=Te(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:Dt,dashName:\"range\"});break;case\"sourceURL\":e.media=a;break}}return[e,t]}function dt(n){let e={},t=[],r=Te(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,d]=Ba(o);e.initialization=s,t=t.concat(d)}}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:ie,dashName:\"timescale\"});break;case\"presentationTimeOffset\":r(o,{asKey:\"presentationTimeOffset\",parser:we,dashName:\"presentationTimeOffset\"});break;case\"indexRange\":r(o,{asKey:\"indexRange\",parser:Dt,dashName:\"indexRange\"});break;case\"indexRangeExact\":r(o,{asKey:\"indexRangeExact\",parser:Ae,dashName:\"indexRangeExact\"});break;case\"availabilityTimeOffset\":r(o,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(o,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"duration\":r(o,{asKey:\"duration\",parser:ie,dashName:\"duration\"});break;case\"startNumber\":r(o,{asKey:\"startNumber\",parser:ie,dashName:\"startNumber\"});break;case\"endNumber\":r(o,{asKey:\"endNumber\",parser:ie,dashName:\"endNumber\"});break}}return[e,t]}function Na(n){let e={},t=[],r=Te(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:Dt,dashName:\"indexRange\"});break;case\"index\":e.index=a;break;case\"mediaRange\":r(a,{asKey:\"mediaRange\",parser:Dt,dashName:\"mediaRange\"});break}}return[e,t]}function rr(n){let[e,t]=dt(n),r=t,i=[],a=n.children;for(let s=0;s<a.length;s++){let d=a[s];if(typeof d!=\"string\"&&d.tagName===\"SegmentURL\"){let[u,f]=Na(d);i.push(u),r=r.concat(f)}}return[K(e,{list:i}),r]}function Ua(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 Bt(n){let[e,t]=dt(n),r=t,i;for(let s=0;s<n.children.length;s++){let d=n.children[s];typeof d!=\"string\"&&d.tagName===\"SegmentTimeline\"&&(i=Ua(d))}let a=K({},e,{duration:e.duration,timelineParser:i}),o=Te(a,r);for(let s of Object.keys(n.attributes)){let d=n.attributes[s];if(!v(d))switch(s){case\"initialization\":v(a.initialization)&&(a.initialization={media:d});break;case\"index\":a.index=d;break;case\"availabilityTimeOffset\":o(d,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":o(d,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break;case\"media\":a.media=d;break;case\"bitstreamSwitching\":o(d,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break}}return[a,r]}function ef(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]=ot(a);o!==void 0&&e.baseURLs.push(o),r=r.concat(s);break}case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Se(a));break;case\"SegmentBase\":{let[o,s]=dt(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=rr(a);r=r.concat(s),e.segmentList=o;break}case\"SegmentTemplate\":{let[o,s]=Bt(a);r=r.concat(s),e.segmentTemplate=o;break}case\"ContentProtection\":{let[o,s]=st(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[Se(a)]:e.essentialProperties.push(Se(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Se(a)]:e.supplementalProperties.push(Se(a));break}}return t.length>0&&(e.contentProtections=t),[e,r]}function tf(n){let e={},t=[],r=Te(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:ie,dashName:\"bandwidth\"});break;case\"codecs\":e.codecs=a;break;case\"codingDependency\":r(a,{asKey:\"codingDependency\",parser:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Yt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"id\":e.id=a;break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,dashName:\"maximumSAPPeriod\"});break;case\"mimeType\":e.mimeType=a;break;case\"profiles\":e.profiles=a;break;case\"qualityRanking\":r(a,{asKey:\"qualityRanking\",parser:ie,dashName:\"qualityRanking\"});break;case\"scte214:supplementalCodecs\":e.supplementalCodecs=a;break;case\"segmentProfiles\":e.segmentProfiles=a;break;case\"width\":r(a,{asKey:\"width\",parser:ie,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return e.bitrate===void 0&&t.push(new De(\"No bitrate found on a Representation\")),[e,t]}function Qs(n){let[e,t]=ef(n.children),[r,i]=tf(n),a=t.concat(i);return[{children:e,attributes:r},a]}function nf(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=[Se(a)]:e.accessibilities.push(Se(a));break;case\"BaseURL\":{let[o,s]=ot(a);o!==void 0&&e.baseURLs.push(o),s.length>0&&(r=r.concat(s));break}case\"ContentComponent\":e.contentComponent=Da(a);break;case\"EssentialProperty\":v(e.essentialProperties)?e.essentialProperties=[Se(a)]:e.essentialProperties.push(Se(a));break;case\"InbandEventStream\":e.inbandEventStreams===void 0&&(e.inbandEventStreams=[]),e.inbandEventStreams.push(Se(a));break;case\"Label\":{let o=St(a.children);o!=null&&(e.label=o);break}case\"Representation\":{let[o,s]=Qs(a);e.representations.push(o),s.length>0&&(r=r.concat(s));break}case\"Role\":v(e.roles)?e.roles=[Se(a)]:e.roles.push(Se(a));break;case\"SupplementalProperty\":v(e.supplementalProperties)?e.supplementalProperties=[Se(a)]:e.supplementalProperties.push(Se(a));break;case\"SegmentBase\":{let[o,s]=dt(a);e.segmentBase=o,s.length>0&&(r=r.concat(s));break}case\"SegmentList\":{let[o,s]=rr(a);e.segmentList=o,s.length>0&&(r=r.concat(s));break}case\"SegmentTemplate\":{let[o,s]=Bt(a);e.segmentTemplate=o,s.length>0&&(r=r.concat(s));break}case\"ContentProtection\":{let[o,s]=st(a);s.length>0&&(r=r.concat(s)),o!==void 0&&t.push(o);break}}}return t.length>0&&(e.contentProtections=t),[e,r]}function rf(n){let e={},t=[],r=Te(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:ie,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:ie,dashName:\"minBandwidth\"});break;case\"maxBandwidth\":r(a,{asKey:\"maxBitrate\",parser:ie,dashName:\"maxBandwidth\"});break;case\"minWidth\":r(a,{asKey:\"minWidth\",parser:ie,dashName:\"minWidth\"});break;case\"maxWidth\":r(a,{asKey:\"maxWidth\",parser:ie,dashName:\"maxWidth\"});break;case\"minHeight\":r(a,{asKey:\"minHeight\",parser:ie,dashName:\"minHeight\"});break;case\"maxHeight\":r(a,{asKey:\"maxHeight\",parser:ie,dashName:\"maxHeight\"});break;case\"minFrameRate\":r(a,{asKey:\"minFrameRate\",parser:Yt,dashName:\"minFrameRate\"});break;case\"maxFrameRate\":r(a,{asKey:\"maxFrameRate\",parser:Yt,dashName:\"maxFrameRate\"});break;case\"selectionPriority\":r(a,{asKey:\"selectionPriority\",parser:ie,dashName:\"selectionPriority\"});break;case\"segmentAlignment\":r(a,{asKey:\"segmentAlignment\",parser:wa,dashName:\"segmentAlignment\"});break;case\"subsegmentAlignment\":r(a,{asKey:\"subsegmentAlignment\",parser:wa,dashName:\"subsegmentAlignment\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,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:Ae,dashName:\"codingDependency\"});break;case\"frameRate\":r(a,{asKey:\"frameRate\",parser:Yt,dashName:\"frameRate\"});break;case\"height\":r(a,{asKey:\"height\",parser:ie,dashName:\"height\"});break;case\"maxPlayoutRate\":r(a,{asKey:\"maxPlayoutRate\",parser:we,dashName:\"maxPlayoutRate\"});break;case\"maximumSAPPeriod\":r(a,{asKey:\"maximumSAPPeriod\",parser:we,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:ie,dashName:\"width\"});break;case\"availabilityTimeOffset\":r(a,{asKey:\"availabilityTimeOffset\",parser:we,dashName:\"availabilityTimeOffset\"});break;case\"availabilityTimeComplete\":r(a,{asKey:\"availabilityTimeComplete\",parser:Ae,dashName:\"availabilityTimeComplete\"});break}}return[e,t]}function $s(n){let e=n.children,[t,r]=nf(e),[i,a]=rf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function af(n){let e={},t=[],r=Te(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:ie,dashName:\"timescale\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Xs(n,e){let[t,r]=af(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,d]=ie(a.attributes.presentationTime,\"presentationTime\");d!==null&&r.push(d),s!==null&&(o.presentationTime=s)}if(!v(a.attributes.duration)){let[s,d]=ie(a.attributes.duration,\"duration\");d!==null&&r.push(d),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 of(n,e){let t=[],r=[],i,a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=ot(u);f!==void 0&&t.push(f),o=o.concat(l);break}case\"AdaptationSet\":{let[f,l]=$s(u);r.push(f),o=o.concat(l);break}case\"EventStream\":{let[f,l]=Xs(u,e);s.push(f),o=o.concat(l);break}case\"SegmentTemplate\":{let[f,l]=Bt(u);i=f,l.length>0&&(o=o.concat(l));break}case\"ContentProtection\":{let[f,l]=st(u);l.length>0&&(o=o.concat(l)),f!==void 0&&a.push(f);break}}}return[{baseURLs:t,adaptations:r,eventStreams:s,segmentTemplate:i,contentProtections:a},o]}function sf(n){let e={},t=[],r=Te(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:Ke,dashName:\"start\"});break;case\"duration\":r(a,{asKey:\"duration\",parser:Ke,dashName:\"duration\"});break;case\"bitstreamSwitching\":r(a,{asKey:\"bitstreamSwitching\",parser:Ae,dashName:\"bitstreamSwitching\"});break;case\"xlink:href\":e.xlinkHref=a;break;case\"xlink:actuate\":e.xlinkActuate=a;break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Zr(n,e){let[t,r]=of(n.children,e),[i,a]=sf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function df(n,e){let t=[],r=[],i=[],a=[],o=[],s=[];for(let d=0;d<n.length;d++){let u=n[d];if(typeof u!=\"string\")switch(u.tagName){case\"BaseURL\":{let[f,l]=ot(u);f!==void 0&&t.push(f),s=s.concat(l);break}case\"Location\":r.push(St(u.children));break;case\"Period\":{let[f,l]=Zr(u,e);i.push(f),s=s.concat(l);break}case\"UTCTiming\":{let f=Se(u);a.push(f);break}case\"ContentProtection\":{let[f,l]=st(u);l.length>0&&(s=s.concat(l)),f!==void 0&&o.push(f);break}}}return[{baseURLs:t,locations:r,periods:i,utcTimings:a,contentProtections:o},s]}function uf(n){let e={},t=[],r=Te(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:Xr,dashName:\"availabilityStartTime\"});break;case\"availabilityEndTime\":r(a,{asKey:\"availabilityEndTime\",parser:Xr,dashName:\"availabilityEndTime\"});break;case\"publishTime\":r(a,{asKey:\"publishTime\",parser:Xr,dashName:\"publishTime\"});break;case\"mediaPresentationDuration\":r(a,{asKey:\"duration\",parser:Ke,dashName:\"mediaPresentationDuration\"});break;case\"minimumUpdatePeriod\":r(a,{asKey:\"minimumUpdatePeriod\",parser:Ke,dashName:\"minimumUpdatePeriod\"});break;case\"minBufferTime\":r(a,{asKey:\"minBufferTime\",parser:Ke,dashName:\"minBufferTime\"});break;case\"timeShiftBufferDepth\":r(a,{asKey:\"timeShiftBufferDepth\",parser:Ke,dashName:\"timeShiftBufferDepth\"});break;case\"suggestedPresentationDelay\":r(a,{asKey:\"suggestedPresentationDelay\",parser:Ke,dashName:\"suggestedPresentationDelay\"});break;case\"maxSegmentDuration\":r(a,{asKey:\"maxSegmentDuration\",parser:Ke,dashName:\"maxSegmentDuration\"});break;case\"maxSubsegmentDuration\":r(a,{asKey:\"maxSubsegmentDuration\",parser:Ke,dashName:\"maxSubsegmentDuration\"});break;default:Oe(i,\"xmlns:\")&&(e.namespaces===void 0&&(e.namespaces=[]),e.namespaces.push({key:i.substring(6),value:a}));break}}return[e,t]}function Zs(n,e){let[t,r]=df(n.children,e),[i,a]=uf(n),o=r.concat(a);return[{children:t,attributes:i},o]}function La(n,e){let t=fa(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]=Zs(r,n),o=$r(i,e,a);return s(o);function s(d){if(d.type===\"done\")return d;if(d.type===\"needs-clock\")return{type:\"needs-resources\",value:{urls:[d.value.url],format:\"string\",continue(u){if(u.length!==1)throw new Error(\"DASH parser: wrong number of loaded ressources.\");let f=d.value.continue(u[0].responseData);return s(f)}}};if(d.type===\"needs-xlinks\")return{type:\"needs-resources\",value:{urls:d.value.xlinksUrls,format:\"string\",continue(u){let f=[];for(let m=0;m<u.length;m++){let{responseData:p,receivedTime:h,sendingTime:b,url:g}=u[m];if(!p.success)throw p.error;let y=\"<root>\"+p.data+\"</root>\",T=fa(y),R=T[T.length-1];if(R===void 0||typeof R==\"string\")throw new Error(\"DASH parser: Invalid external ressources\");let E=R.children,C=[],P=[];for(let x=0;x<E.length;x++){let A=E[x];if(typeof A==\"string\"||A.tagName!==\"Period\")continue;let[k,N]=Zr(A,y);P.push(...N),C.push(k)}f.push({url:g,receivedTime:h,sendingTime:b,parsed:C,warnings:P})}let l=d.value.continue(f);return s(l)}}};Be(d)}}var Js=La;var lf=typeof WebAssembly==\"object\"&&typeof WebAssembly.instantiate==\"function\",ed=lf;function W(n,e,t,r){let i=new Uint8Array(e,t,r);return n.decode(i)}function Fa(n){return n===1/0?!0:n===-1/0?!1:n}function Tt(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.value=W(t,e.buffer,a,o))}}function Et(n,e){let t=n.attributes,r=n.children,i=new TextDecoder;return function(o,s,d){switch(o){case 16:t.schemeIdUri=W(i,e.buffer,s,d);break;case 13:t.value=W(i,e.buffer,s,d);break;case 14:{let u=W(i,e.buffer,s,d);t.keyId=sn(u.replace(/-/g,\"\"));break}case 15:try{let u=W(i,e.buffer,s,d);r.cencPssh.push(_r(u))}catch(u){}break;case 78:t.ref=W(i,e.buffer,s,d);break;case 79:t.refId=W(i,e.buffer,s,d);break}}}function td(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 60:n.language=W(t,e.buffer,a,o);break;case 61:n.contentType=W(t,e.buffer,a,o);break;case 62:n.par=W(t,e.buffer,a,o);break}}}function nd(n,e){let t=new TextDecoder;return function(i,a,o){i===64&&(n.label=W(t,e.buffer,a,o))}}function qe(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 16:n.schemeIdUri=W(t,e.buffer,a,o);break;case 17:n.value=W(t,e.buffer,a,o);break}}}function Qt(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=W(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 rd(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 28:n.index=W(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=W(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 Jr(n,e,t){return function(i){switch(i){case 20:{let a={};n.list===void 0&&(n.list=[]),n.list.push(a);let o=rd(a,e);t.pushParsers(i,O,o);break}default:t.pushParsers(i,O,O);break}}}function $t(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 19:{let s=new DataView(e.buffer);n.timeline=[];let d=a;for(let u=0;u<o/24;u++)n.timeline.push({start:s.getFloat64(d,!0),duration:s.getFloat64(d+8,!0),repeatCount:s.getFloat64(d+16,!0)}),d+=24;break}case 67:n.initialization={media:W(t,e.buffer,a,o)};break;case 28:n.index=W(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=W(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 id(n,e,t){return function(i){switch(i){case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a),t.pushParsers(i,O,Tt(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=Et(a,e);t.pushParsers(i,O,o);break}case 19:{let a={};n.inbandEventStreams===void 0&&(n.inbandEventStreams=[]),n.inbandEventStreams.push(a),t.pushParsers(i,O,qe(a,e));break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=qe(a,e);t.pushParsers(i,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Qt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Jr(a,e,t),s=Qt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,$t(a,e));break}default:t.pushParsers(i,O,O);break}}}function ad(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 3:n.audioSamplingRate=W(t,e.buffer,a,o);break;case 63:n.bitrate=s.getFloat64(a,!0);break;case 4:n.codecs=W(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=W(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=W(t,e.buffer,a,o);break;case 2:n.profiles=W(t,e.buffer,a,o);break;case 65:n.qualityRanking=s.getFloat64(a,!0);break;case 12:n.segmentProfiles=W(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 od(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,O,o);break}case 15:{let a={value:\"\",attributes:{}};n.baseURLs.push(a);let o=Tt(a,e);t.pushParsers(i,O,o);break}case 9:{let a={};n.contentComponent=a,t.pushParsers(i,O,td(a,e));break}case 10:{let a={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(a);let o=Et(a,e);t.pushParsers(i,O,o);break}case 11:{let a={};n.essentialProperties===void 0&&(n.essentialProperties=[]),n.essentialProperties.push(a);let o=O,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=O,s=qe(a,e);t.pushParsers(i,o,s);break}case 7:{let a={children:{baseURLs:[]},attributes:{}};n.representations.push(a);let o=id(a.children,e,t),s=ad(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,O,o);break}case 13:{let a={};n.supplementalProperties===void 0&&(n.supplementalProperties=[]),n.supplementalProperties.push(a);let o=qe(a,e);t.pushParsers(i,O,o);break}case 17:{let a={};n.segmentBase=a;let o=Qt(a,e);t.pushParsers(i,O,o);break}case 18:{let a={list:[]};n.segmentList=a;let o=Jr(a,e,t),s=Qt(a,e);t.pushParsers(i,o,s);break}case 16:{let a={};n.segmentTemplate=a,t.pushParsers(i,O,$t(a,e));break}case 21:{t.pushParsers(i,O,nd(n,e));break}default:t.pushParsers(i,O,O);break}}}function sd(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 0:n.id=W(t,e.buffer,a,o);break;case 48:n.group=s.getFloat64(a,!0);break;case 60:n.language=W(t,e.buffer,a,o);break;case 61:n.contentType=W(t,e.buffer,a,o);break;case 62:n.par=W(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=Fa(s.getFloat64(a,!0));break;case 59:n.subsegmentAlignment=Fa(s.getFloat64(a,!0));break;case 32:n.bitstreamSwitching=s.getFloat64(a,!0)!==0;break;case 3:n.audioSamplingRate=W(t,e.buffer,a,o);break;case 4:n.codecs=W(t,e.buffer,a,o);break;case 77:n.supplementalCodecs=W(t,e.buffer,a,o);break;case 2:n.profiles=W(t,e.buffer,a,o);break;case 12:n.segmentProfiles=W(t,e.buffer,a,o);break;case 11:n.mimeType=W(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}}}function dd(n,e,t,r){return function(a){switch(a){case 6:{let o={};n.events.push(o);let s=ff(o,e,r);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function ud(n,e){let t=new TextDecoder;return function(i,a,o){let s=new DataView(e.buffer);switch(i){case 16:n.schemeIdUri=W(t,e.buffer,a,o);break;case 17:n.value=W(t,e.buffer,a,o);break;case 27:n.timescale=s.getFloat64(a,!0);break;case 70:{let d={key:\"\",value:\"\"},u=a,f=s.getUint32(u);u+=4,d.key=W(t,e.buffer,u,f),u+=f;let l=s.getUint32(u);u+=4,d.value=W(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[d]:n.namespaces.push(d);break}}}}function ff(n,e,t){let r=new TextDecoder;return function(a,o,s){let d=new DataView(e.buffer);switch(a){case 25:n.presentationTime=d.getFloat64(o,!0);break;case 1:n.duration=d.getFloat64(o,!0);break;case 0:n.id=W(r,e.buffer,o,s);break;case 69:{let u=d.getFloat64(o,!0),f=d.getFloat64(o+8,!0);n.eventStreamData=t.slice(u,f);break}}}}function ei(n,e,t,r){return function(a){switch(a){case 4:{let o={children:{baseURLs:[],representations:[]},attributes:{}};n.adaptations.push(o);let s=od(o.children,e,t),d=sd(o.attributes,e);t.pushParsers(a,s,d);break}case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 5:{let o={children:{events:[]},attributes:{}};n.eventStreams.push(o);let s=dd(o.children,e,t,r),d=ud(o.attributes,e);t.pushParsers(a,s,d);break}case 16:{let o={};n.segmentTemplate=o,t.pushParsers(a,O,$t(o,e));break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=Et(o,e);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function ti(n,e){let t=new TextDecoder;return function(i,a,o){switch(i){case 0:n.id=W(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=W(t,e.buffer,a,o);break;case 47:n.xlinkActuate=W(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:\"\"},d=new DataView(e.buffer),u=a,f=d.getUint32(u);u+=4,s.key=W(t,e.buffer,u,f),u+=f;let l=d.getUint32(u);u+=4,s.value=W(t,e.buffer,u,l),n.namespaces===void 0?n.namespaces=[s]:n.namespaces.push(s);break}}}}function ld(n,e,t,r){return function(a){switch(a){case 15:{let o={value:\"\",attributes:{}};n.baseURLs.push(o);let s=O,d=Tt(o,e);t.pushParsers(a,s,d);break}case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=ei(o.children,e,t,r),d=ti(o.attributes,e);t.pushParsers(a,s,d);break}case 3:{let o={};n.utcTimings.push(o);let s=O,d=qe(o,e);t.pushParsers(a,s,d);break}case 10:{let o={children:{cencPssh:[]},attributes:{}};n.contentProtections===void 0&&(n.contentProtections=[]),n.contentProtections.push(o);let s=Et(o,e);t.pushParsers(a,O,s);break}default:t.pushParsers(a,O,O);break}}}function fd(n,e,t){let r,i=new TextDecoder;return function(o,s,d){switch(o){case 0:e.id=W(i,t.buffer,s,d);break;case 2:e.profiles=W(i,t.buffer,s,d);break;case 33:e.type=W(i,t.buffer,s,d);break;case 34:{let u=W(i,t.buffer,s,d);e.availabilityStartTime=new Date(u).getTime()/1e3;break}case 35:{let u=W(i,t.buffer,s,d);e.availabilityEndTime=new Date(u).getTime()/1e3;break}case 36:{let u=W(i,t.buffer,s,d);e.publishTime=new Date(u).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 u=W(i,t.buffer,s,d);n.locations.push(u);break}case 70:{let u={key:\"\",value:\"\"};r=new DataView(t.buffer);let f=s,l=r.getUint32(f);f+=4,u.key=W(i,t.buffer,f,l),f+=l;let m=r.getUint32(f);f+=4,u.value=W(i,t.buffer,f,m),e.namespaces===void 0?e.namespaces=[u]:e.namespaces.push(u);break}}}}function za(n,e,t,r){return function(a){switch(a){case 1:{n.mpd={children:{baseURLs:[],locations:[],periods:[],utcTimings:[]},attributes:{}};let o=ld(n.mpd.children,e,t,r),s=fd(n.mpd.children,n.mpd.attributes,e);t.pushParsers(a,o,s);break}default:t.pushParsers(a,O,O);break}}}function md(n,e,t,r){return function(a){switch(a){case 2:{let o={children:{adaptations:[],baseURLs:[],eventStreams:[]},attributes:{}};n.periods.push(o);let s=ei(o.children,e,t,r),d=ti(o.attributes,e);t.pushParsers(a,s,d);break}default:t.pushParsers(a,O,O);break}}}var ir=class{constructor(){this._currentNodeId=null,this.childrenParser=O,this.attributeParser=O,this._stack=[{nodeId:null,children:O,attribute:O}]}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=O,this.attributeParser=O,this._stack=[{nodeId:null,children:O,attribute:O}]}};var mf=15e3,ar=class{constructor(){this._parsersStack=new ir,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:u,onCustomEvent:m,onAttribute:l,readNext:p,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 d=typeof WebAssembly.instantiateStreaming==\"function\"?WebAssembly.instantiateStreaming(s,a):Promise.reject(\"`WebAssembly.instantiateStreaming` API not available\");return this._initProm=d.catch(async h=>{o!==null&&(URL.revokeObjectURL(o),o=null),c.warn(\"dash\",\"Unable to call `instantiateStreaming` on WASM\",h instanceof Error?h:\"\");let b=await s;if(b.status<200||b.status>=300)throw new Error(\"WebAssembly request failed. status: \"+String(b.status));let g=await b.arrayBuffer();return WebAssembly.instantiate(g,a)}).then(h=>{o!==null&&(URL.revokeObjectURL(o),o=null),this._instance=h,this._linearMemory=this._instance.instance.exports.memory,this.status=\"initialized\"}).catch(h=>{let b=h instanceof Error?h.toString():\"Unknown error\";throw c.warn(\"dash\",\"Could not create DASH-WASM parser:\",b),this.status=\"failure\",h}),this._initProm;function u(h){return t.childrenParser(h)}function f(h){return t.popIfCurrent(h)}function l(h,b,g){return t.attributeParser(h,b,g)}function m(h,b,g){let y=i._linearMemory,T=new Uint8Array(y.buffer,b,g);if(h===1){let R=r.decode(T);c.warn(\"dash\",\"WASM Error Event:\",R),i._warnings.push(new Error(R))}else if(h===0){let R=r.decode(T);c.warn(\"dash\",\"WASM Log Event:\",R)}}function p(h,b){if(i._mpdData===null)throw new Error(\"DashWasmParser Error: No MPD to read.\");let g=i._linearMemory,{mpd:y,cursor:T}=i._mpdData,R=Math.min(b,mf,y.byteLength-T);return new Uint8Array(g.buffer,h,R).set(new Uint8Array(y,T,R)),i._mpdData.cursor+=R,R}}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=$r(r,t,i);return this._processParserReturnValue(a)}isCompatible(){return ed&&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=za(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),this._warnings=[];try{this._instance.instance.exports.parse()}catch(d){throw this._parsersStack.reset(),this._warnings=[],this._isParsing=!1,d}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=md(t,r,this._parsersStack,e);this._parsersStack.pushParsers(null,i,O),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:d,sendingTime:u,url:f}=r[o];if(!s.success)throw s.error;let[l,m]=this._parseXlink(s.data);i.push({url:f,receivedTime:d,sendingTime:u,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 Be(e)}};var cd=ar;function je(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 d=0;d<e.length;d++){let u=e[d];u[1]===null?s+=u[0]:s+=`${u[0]}=${u[1]}`,d<e.length-1&&(s+=\"&\")}return r.length>0&&(s+=r),s}function qa(n,e){return(t,r,i)=>new Promise((a,o)=>{let s=Date.now()-F(),d=!1,m={reject:b=>{var R,E;if(d||i.isCancelled())return;d=!0,i.deregister(h);let g=b,y=(R=g==null?void 0:g.message)!=null?R:\"Unknown error when fetching the Manifest through a custom manifestLoader.\",T=new $e(y,(E=g==null?void 0:g.canRetry)!=null?E:!1,g==null?void 0:g.xhr);o(T)},resolve:b=>{if(d||i.isCancelled())return;d=!0,i.deregister(h);let g=b.receivingTime!==void 0?b.receivingTime-s:void 0,y=b.sendingTime!==void 0?b.sendingTime-s:void 0;a({responseData:b.data,size:b.size,requestDuration:b.duration,url:b.url,receivedTime:g,sendingTime:y})},fallback:()=>{d||i.isCancelled()||(d=!0,i.deregister(h),e(t,r,i).then(a,o))}},p=n({url:t,timeout:r.timeout,cmcdPayload:r.cmcdPayload},m);i.register(h);function h(b){d||(d=!0,typeof p==\"function\"&&p(),o(b))}})}function cf(n){return function(t,r,i){var s,d;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\"?je(t,r.cmcdPayload.value):t,o=((d=r.cmcdPayload)==null?void 0:d.type)===\"headers\"?r.cmcdPayload.value:void 0;switch(n){case\"arraybuffer\":return he({url:a,headers:o,responseType:\"arraybuffer\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"text\":return he({url:a,headers:o,responseType:\"text\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});case\"document\":return he({url:a,headers:o,responseType:\"document\",timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:i});default:Be(n)}}}function Wa({customManifestLoader:n},e,t){let r=cf(e),i=typeof n!=\"function\"?r:qa(n,r);return t!==null?t(i):i}function Va(n,e){if(e){if(Ze(n,1718909296)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `ftyp` box\");if(Ze(n,1836019574)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moov` box\")}else{if(Ze(n,1836019558)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `moof` box\");if(Ze(n,1835295092)<0)throw new Ee(\"INTEGRITY_ERROR\",\"Incomplete `mdat` box\")}}function Ye(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 ni(n){return(e,t,r,i,a)=>{return new Promise((s,d)=>{let u=new z(\"Segment integrity checks\"),f=u.linkToSignal(i);u.signal.register(d),n(e,t,r,u.signal,se(J({},a),{onNewChunk(m){try{o(m),a.onNewChunk(m)}catch(p){l(),u.cancel(\"Integrity check failed\"),d(p)}}})).then(m=>{if(l(),!u.isUsed()){if(m.resultType===\"segment-loaded\")try{o(m.resultData.responseData)}catch(p){d(p);return}s(m)}},m=>{l(),d(m)});function l(){u.signal.deregister(d),f()}});function o(s){!(s instanceof ArrayBuffer)&&!(s instanceof Uint8Array)||Ye(t.type,t.mimeType)!==\"mp4\"||Va(new Uint8Array(s),t.segment.isInit)}}}function pd(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,d=[\"</\",\"MPD\",\">\"];for(let u=d.length-1;u>=0;u--){let f=d[u];for(;pf(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,d=new DataView(o),u=[[60,47],[77,80,68],[62]];for(let f=u.length-1;f>=0;f--){let l=u[f];for(;gf(d.getUint8(s));)s--;for(let m=l.length-1;m>=0;m--){if(d.getUint8(s)!==l[m])throw new Error(\"INTEGRITY_ERROR MPD does not end with </MPD>\");s--}}}else if(!v(ee.Document)&&o instanceof ee.Document&&o.documentElement.nodeName!==\"MPD\")throw new Ee(\"INTEGRITY_ERROR\",\"MPD does not end with </MPD>\")}}}function pf(n){return n===\" \"||n===\"\t\"||n===\"\\r\"||n===`\n`}function gf(n){return n===32||n===9||n===13||n===10}function Ga(n){let{referenceDateTime:e}=n,t=n.serverSyncInfos!==void 0?n.serverSyncInfos.serverTimestamp-n.serverSyncInfos.clientTime:void 0;return function(i,a,o,s,d){var T;let{responseData:u}=i,f=a.externalClockOffset,l=(T=i.url)!=null?T:a.originalUrl,m=t!=null?t:f,h={unsafelyBaseOnPreviousManifest:a.unsafeMode?a.previousManifest:null,url:l,referenceDateTime:e,externalClockOffset:m},b=ke.dashParsers;if(b.wasm===null||b.wasm.status===\"uninitialized\"||b.wasm.status===\"failure\")return c.debug(\"dash\",\"WASM MPD Parser not initialized. Running JS one.\"),g();{let R=yf(u);if(!Sf(R))return c.info(\"dash\",\"MPD doesn't seem to be UTF-8-encoded. Running JS parser instead of the WASM one.\"),g();if(b.wasm.status===\"initialized\"){c.debug(\"dash\",\"Running WASM MPD Parser.\");let E=b.wasm.runWasmParser(R,h);return y(E)}else return c.debug(\"dash\",\"Awaiting WASM initialization before parsing the MPD.\"),b.wasm.waitForInitialization().catch(()=>{}).then(()=>{if(b.wasm===null||b.wasm.status!==\"initialized\")return c.warn(\"dash\",\"WASM MPD parser initialization failed. Running JS parser instead\"),g();c.debug(\"dash\",\"Running WASM MPD Parser.\");let C=b.wasm.runWasmParser(R,h);return y(C)})}function g(){if(b.js!==null){let R=bf(u),E=b.js(R,h);return y(E)}else throw new Error(\"No MPD parser is imported\")}function y(R){if(R.type===\"done\")return R.value.warnings.length>0&&o(R.value.warnings),s.isCancelled()?Promise.reject(s.cancellationError):{manifest:new ht(R.value.parsed,n),url:l};let{value:E}=R,C=E.urls.map(P=>d(()=>{let x=L.getCurrent().DEFAULT_REQUEST_TIMEOUT,A=L.getCurrent().DEFAULT_CONNECTION_TIMEOUT;return E.format===\"string\"?he({url:P,responseType:\"text\",timeout:x,connectionTimeout:A,cancelSignal:s}):he({url:P,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 K(x,{responseData:{success:!0,data:x.responseData}})}else{if(!(x.responseData instanceof ArrayBuffer))throw new Error(\"External DASH resources should have been ArrayBuffers\");return K(x,{responseData:{success:!0,data:x.responseData}})}},x=>{let A=pe(x,{defaultCode:\"PIPELINE_PARSE_ERROR\",defaultReason:\"An unknown error occured when parsing ressources.\"});return K({},{size:void 0,requestDuration:void 0,responseData:{success:!1,error:A}})}));return Promise.all(C).then(P=>E.format===\"string\"?(hf(P),y(E.continue(P))):(If(P),y(E.continue(P))))}}}function hf(n){I.CURRENT_ENV!==I.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 If(n){I.CURRENT_ENV!==I.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 bf(n){if(n instanceof ArrayBuffer)return Ge(new Uint8Array(n));if(typeof n==\"string\")return n;if(!v(ee.Document)&&n instanceof ee.Document)return n.documentElement.outerHTML;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function yf(n){if(n instanceof ArrayBuffer)return n;if(typeof n==\"string\")return on(n).buffer;if(!v(ee.Document)&&n instanceof ee.Document)return on(n.documentElement.innerHTML).buffer;throw new Error(\"DASH Manifest Parser: Unrecognized Manifest format\")}function Sf(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 Nt(n,e){return n===null?null:e.url===null?n.baseUrl:Fn(n.baseUrl,e.url)}function or(n,e,t,r,i){var u,f;let a=n;((u=t.cmcdPayload)==null?void 0:u.type)===\"query\"&&(a=je(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 he({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 he({url:a,headers:se(J({},o),{Range:We(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 he({url:a,headers:se(J({},o),{Range:We([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=he({url:a,headers:se(J({},o),{Range:We(e.range)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress}),d=he({url:a,headers:se(J({},o),{Range:We(e.indexRange)}),responseType:\"arraybuffer\",timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r,onProgress:i.onProgress});return Promise.all([s,d]).then(([l,m])=>{let p=At(new Uint8Array(l.responseData),new Uint8Array(m.responseData)),h=Math.min(l.sendingTime,m.sendingTime),b=Math.max(l.receivedTime,m.receivedTime);return{resultType:\"segment-loaded\",resultData:{url:a,responseData:p,size:l.size+m.size,requestDuration:b-h,sendingTime:h,receivedTime:b}}})}async function sr(n,e,t,r){let i=null;function a(s){let d=new Uint8Array(s.chunk),u=i!==null?At(i,d):d,f=Rr(u),l=f[0];i=f[1],!(l!==null&&(l.forEach(m=>{t.onNewChunk(m)}),r.isCancelled()))&&(t.onProgress({duration:s.duration,size:s.size,totalSize:s.totalSize}),r.isCancelled())}return{resultType:\"chunk-complete\",resultData:await gr({url:n,headers:e.headers,onData:a,timeout:e.timeout,connectionTimeout:e.connectionTimeout,cancelSignal:r})}}async function gd(n,e,t,r,i,a){var m,p;if(e.segment.isInit)return or(n,e.segment,r,a,i);let o=((m=r.cmcdPayload)==null?void 0:m.type)===\"query\"?je(n,r.cmcdPayload.value):n,s=((p=r.cmcdPayload)==null?void 0:p.type)===\"headers\"?r.cmcdPayload.value:void 0,{segment:d}=e,u;d.range!==void 0?u=se(J({},s),{Range:We(d.range)}):s!==void 0&&(u=s);let f=Ye(e.type,e.mimeType);if(t&&(f===\"mp4\"||f===void 0)){if(nn())return sr(o,{headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout},i,a);tt(\"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 he({url:o,responseType:\"arraybuffer\",headers:u,timeout:r.timeout,connectionTimeout:r.connectionTimeout,cancelSignal:a,onProgress:i.onProgress})}}function Ha({lowLatencyMode:n,segmentLoader:e,checkMediaSegmentIntegrity:t}){return t!==!0?r:ni(r);function r(i,a,o,s,d){let u=Nt(i,a.segment);return u===null?Promise.resolve({resultType:\"segment-created\",resultData:null}):n||e===void 0?gd(u,a,n,o,d,s):new Promise((f,l)=>{let m=!1,y={reject:P=>{var N,D;if(m||s.isCancelled())return;m=!0,s.deregister(C);let x=P,A=(N=x==null?void 0:x.message)!=null?N:\"Unknown error when fetching a DASH segment through a custom segmentLoader.\",k=new $e(A,(D=x==null?void 0:x.canRetry)!=null?D:!1,x==null?void 0:x.xhr);l(k)},resolve:P=>{if(m||s.isCancelled())return;m=!0,s.deregister(C);let x;P.data instanceof Uint8Array?P.data.buffer instanceof ArrayBuffer?x=P.data:x=P.data.slice():x=P.data,f({resultType:\"segment-loaded\",resultData:{responseData:x,size:P.size,requestDuration:P.duration}})},progress:P=>{m||s.isCancelled()||d.onProgress({duration:P.duration,size:P.size,totalSize:P.totalSize})},fallback:()=>{m||s.isCancelled()||(m=!0,s.deregister(C),gd(u,a,n,o,d,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 R={isInit:a.segment.isInit,timeout:o.timeout,byteRanges:T,trackType:a.type,url:u,cmcdPayload:o.cmcdPayload},E=e(R,y);s.register(C);function C(P){m||(m=!0,typeof E==\"function\"&&E(),l(P))}})}}var ja=408125543,hd=357149030,Tf=2807729,Ef=17545,_f=475249515,Rf=187,Pf=179,vf=183,Cf=241;function _t(n,e,t,[r,i]){let a=r;for(;a<i;){let o=xf(t,a);if(o===null)return null;let{value:s,length:d}=o,u=a+d,f=kf(t,u);if(f===null)return null;let{length:l,value:m}=f,p=u+l,h=p+m;if(s===n)return[p,h];if(e.length>0){for(let b=0;b<e.length;b++)if(s===e[b]){let g=e.slice(b+1,e.length);return _t(n,g,t,[p,h])}}a=h}return null}function ri(n,e){let t=_t(Tf,[ja,hd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return 1e9/Ka(n,t[0],r)}function Af(n,e){let t=_t(Ef,[ja,hd],n,[e,n.length]);if(t===null)return null;let r=t[1]-t[0];return r===4?Mf(n,t[0]):r===8?Of(n,t[0]):null}function Ya(n,e){let t=_t(ja,[],n,[e,n.length]);if(t===null)return null;let[r,i]=t,a=ri(n,r);if(a===null)return null;let o=Af(n,r);if(o===null)return null;let s=_t(_f,[],n,[r,i]);if(s===null)return null;let d=[],u=s[0];for(;u<s[1];){let l=_t(Rf,[],n,[u,s[1]]);if(l===null)break;let m=_t(Pf,[],n,[l[0],l[1]]);if(m===null)return null;let p=Ka(n,m[0],m[1]-m[0]),h=_t(Cf,[vf],n,[l[0],l[1]]);if(h===null)return null;let b=Ka(n,h[0],h[1]-h[0])+r;d.push({time:p,rangeStart:b}),u=l[1]}let f=[];for(let l=0;l<d.length;l++){let m=d[l];l===d.length-1?f.push({time:m.time,timescale:a,duration:l===0?o:o-m.time,range:[m.rangeStart,1/0]}):f.push({time:m.time,timescale:a,duration:d[l+1].time-m.time,range:[m.rangeStart,d[l+1].rangeStart-1]})}return f}function Id(n,e){for(let t=1;t<=8;t++)if(n[e]>=Math.pow(2,8-t))return t}function xf(n,e){let t=Id(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 kf(n,e){let t=Id(n,e);if(t===void 0)return c.warn(\"webm\",\"unrepresentable length\"),null;if(e+t>n.length)return c.warn(\"webm\",\"impossible length\",{offset:e,length:t,bufferLength:n.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 Mf(n,e){return new DataView(n.buffer).getFloat32(e)}function Of(n,e){return new DataView(n.buffer).getFloat64(e)}function Ka(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 dr(n,e,t,r){let i=Ei(n);if(i===void 0||r===void 0)return null;let a=t.timestampOffset!==void 0?i+t.timestampOffset*r:i,o=_i(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,d=t.duration*r,u=Math.min(r*.9,d/4);return o!==void 0&&Math.abs(o-d)<=u&&(s=o),{time:a/r,duration:s!==void 0?s/r:s}}function wf(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=Ge(o),d=Date.parse(s);if(a===void 0||d===void 0||isNaN(d)||d>=a)return!0}return!1}function Qa(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:wf(t,e);return{inbandEvents:i,needsManifestRefresh:a}}function $a({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var R,E;let{segment:a,periodStart:o,periodEnd:s}=r,{data:d,isChunked:u}=t,f=[o,s];if(d===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=ko(d),m=Ye(r.type,r.mimeType),p=m===\"mp4\"||m===void 0,h=[];if(p){let C=Pr(l),P;a.isInit&&(P=(R=No(l))!=null?R:void 0),(C.length>0||P!==void 0)&&h.push({initDataType:\"cenc\",keyId:P,initData:C})}if(!a.isInit){let C=p?dr(l,u,a,i):null,P=(E=a.timestampOffset)!=null?E:0;if(p){let x=Bo(l);if(x!==void 0){let A=x.filter(N=>a.privateInfos===void 0||a.privateInfos.isEMSGWhitelisted===void 0?!1:a.privateInfos.isEMSGWhitelisted(N)),k=Qa(A,r.manifestPublishTime);if(k!==void 0){let{needsManifestRefresh:N,inbandEvents:D}=k;return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:P,appendWindow:f,inbandEvents:D,protectionData:h,needsManifestRefresh:N}}}}return{segmentType:\"media\",chunkData:l,chunkSize:l.length,chunkInfos:C,chunkOffset:P,protectionData:h,appendWindow:f}}let{indexRange:b}=a,g;if(m===\"webm\")g=Ya(l,0);else if(p&&(g=fn(l,Array.isArray(b)?b[0]:0),n===!0&&g!==null&&g.length>0)){let C=g[g.length-1];Array.isArray(C.range)&&(C.range[1]=1/0)}let y;p?y=mn(l):m===\"webm\"&&(y=ri(l,0));let T=v(y)?void 0:y;return{segmentType:\"init\",initializationData:l,initializationDataSize:l.length,protectionData:h,initTimescale:T,segmentList:g!=null?g:void 0}}}function Xa({lowLatencyMode:n,checkMediaSegmentIntegrity:e}){return e!==!0?t:ni(t);async function t(r,i,a,o,s){var g,y;let{segment:d}=i,u=Nt(r,d);if(u===null)return Promise.resolve({resultType:\"segment-created\",resultData:null});if(d.isInit)return or(u,d,a,o,s);let f=((g=a.cmcdPayload)==null?void 0:g.type)===\"query\"?je(u,a.cmcdPayload.value):u,l=((y=a.cmcdPayload)==null?void 0:y.type)===\"headers\"?a.cmcdPayload.value:void 0,m;d.range!==void 0?m=se(J({},l),{Range:We(d.range)}):l!==void 0&&(m=l);let p=Ye(i.type,i.mimeType),h=p===\"mp4\"||p===void 0;if(n&&h){if(nn())return sr(f,{headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout},s,o);tt(\"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 b;return h?b=await he({url:f,responseType:\"arraybuffer\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}):b=await he({url:f,responseType:\"text\",headers:m,timeout:a.timeout,connectionTimeout:a.connectionTimeout,onProgress:s.onProgress,cancelSignal:o}),{resultType:\"segment-loaded\",resultData:b}}}function Df(n){if(n===void 0)throw new Error(\"Cannot parse subtitles: unknown format\");switch(n.toLowerCase()){case\"stpp\":case\"stpp.ttml\":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 Bf(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 bd({segment:n,language:e,codecs:t},r,i,a,o){if(n.isInit)return null;let s,d;a===null?o?(s=n.time,d=n.end):c.warn(\"utils\",\"Unavailable time data for current text track.\"):(s=a.time,a.duration!==void 0?d=s+a.duration:!o&&n.complete&&(d=s+n.duration));let u=Df(t),f=Si(r),l=f!==null?Ge(f):\"\";return t===\"wvtt\"&&!Oe(l,\"WEBVTT\")&&!Oe(l,\"\\xFE\\xFFWEBVTT\")?{data:r,type:\"mp4vtt\",language:e,start:s,end:d,initTimescale:i!=null?i:null}:{data:l,type:u,language:e,start:s,end:d,initTimescale:i!=null?i:null}}function yd(n,e,t,r){let{segment:i}=n;if(i.isInit)return null;let a,o;r?c.warn(\"utils\",\"Unavailable time data for current text track.\"):(a=i.time,i.complete&&(o=i.time+i.duration));let s=Bf(n.codecs,n.mimeType);return{data:e,type:s,language:n.language,start:a,end:o,initTimescale:t!=null?t:null}}function Nf(n,e,t,r,i){var m;let{segment:a}=t,{isInit:o,indexRange:s}=a,d;if(typeof n==\"string\"?d=on(n):n instanceof Uint8Array?d=n:d=new Uint8Array(n),o){let p=fn(d,Array.isArray(s)?s[0]:0);if(i===!0&&p!==null&&p.length>0){let b=p[p.length-1];Array.isArray(b.range)&&(b.range[1]=1/0)}let h=mn(d);return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:h,segmentList:p!=null?p:void 0}}let u=dr(d,e,a,r),f=bd(t,d,r,u,e),l=(m=a.timestampOffset)!=null?m:0;return{segmentType:\"media\",chunkData:f,chunkSize:d.length,chunkInfos:u,chunkOffset:l,protectionData:[],appendWindow:[t.periodStart,t.periodEnd]}}function Uf(n,e,t,r){let{periodStart:i,periodEnd:a,segment:o}=r,{timestampOffset:s=0}=o;if(o.isInit)return{segmentType:\"init\",initializationData:null,initializationDataSize:0,protectionData:[],initTimescale:void 0};let d,u;if(typeof n!=\"string\"){let l=n instanceof Uint8Array?n:new Uint8Array(n);d=Ge(l),u=l.length}else d=n;return{segmentType:\"media\",chunkData:yd(r,d,e,t),chunkSize:u,chunkInfos:null,chunkOffset:s,protectionData:[],appendWindow:[i,a]}}function Za({__priv_patchLastSegmentInSidx:n}){return function(t,r,i){var l;let{periodStart:a,periodEnd:o,segment:s}=r,{data:d,isChunked:u}=t;if(d===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=Ye(r.type,r.mimeType);if(f===\"webm\")throw new Error(\"Text tracks with a WEBM container are not yet handled.\");return f===\"mp4\"?Nf(d,u,r,i,n):Uf(d,i,u,r)}}async function Sd(n,e,t,r){var d,u;let i=Nt(n,e);if(i===null)return Promise.reject(new Error(\"Cannot load thumbnail: no URL\"));let a=((d=t.cmcdPayload)==null?void 0:d.type)===\"query\"?je(i,t.cmcdPayload.value):i,o=((u=t.cmcdPayload)==null?void 0:u.type)===\"headers\"?t.cmcdPayload.value:void 0,s;return e.range!==void 0?s=se(J({},o),{Range:We(e.range)}):o!==void 0&&(s=o),rn({url:a,responseType:\"arraybuffer\",headers:s,timeout:t.timeout,connectionTimeout:t.connectionTimeout,cancelSignal:r})}function Td(n,e){var u;let{thumbnailTrack:t,thumbnail:r}=e,i=t.height/t.verticalTiles,a=t.width/t.horizontalTiles,o=[],s=(u=t.tileDuration)!=null?u:(r.end-r.time)/(t.horizontalTiles*t.verticalTiles),d=r.time;for(let f=0;f<t.verticalTiles;f++)for(let l=0;l<t.horizontalTiles;l++)o.push({start:d,end:d+s,offsetX:Math.round(l*a),offsetY:Math.round(f*i),height:Math.floor(i),width:Math.floor(a)}),d+=s;return{mimeType:t.mimeType,data:n,thumbnails:o}}function Ed(n){let e=Wa({customManifestLoader:n.manifestLoader},Lf()?\"text\":\"arraybuffer\",n.checkManifestIntegrity===!0?pd:null),t=Ga(n),r=Ha(n),i=$a(n),a=Xa(n),o=Za(n);return{transportName:\"dash\",manifest:{loadManifest:e,parseManifest:t},audio:{loadSegment:r,parseSegment:i},video:{loadSegment:r,parseSegment:i},text:{loadSegment:a,parseSegment:o},thumbnails:{loadThumbnail:Sd,parseThumbnail:Td}}}function Lf(){return ke.dashParsers.wasm!==null&&(ke.dashParsers.wasm.status===\"initialized\"||ke.dashParsers.wasm.status===\"initializing\")}var _d=Ed;function Ja(n){let e=new cd;ke.dashParsers.wasm=e,ke.dashParsers.js=Js,ke.transports.dash=_d,ee.onmessageerror=t=>{qr.error(\"Core\",\"Error when receiving message from main thread.\")},Ds(t=>{onmessage=t},Ff,n)}function Ff(n,e){zf(n),n.type!==\"log\"&&qr.debug(\"M<--C\",\"Sending message from worker\",{name:n.type}),e===void 0?postMessage(n):postMessage(n,e)}function zf(n){(n.type===\"manifest-ready\"||n.type===\"manifest-update\")&&(n.value.manifest instanceof ht?(n.value.manifest=n.value.manifest.getMetadataSnapshot(),n.type===\"manifest-update\"&&(n.value.manifest.periods=[])):qr.warn(\"Core\",\"the Manifest instance should be communicated to `sendMessage`.\"))}Ja({representationFilters:new Map,segmentLoaders:new Map,manifestLoaders:new Map});})();\n" + "})()"], { type: "application/javascript" });
5
5
  exports.EMBEDDED_WORKER = blob;
6
6
  exports.default = blob;