@arcgis/core 6.0.0-next.23 → 6.0.0-next.25

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 (237) hide show
  1. package/Graphic.d.ts +47 -14
  2. package/PopupTemplate.js +1 -1
  3. package/WebScene.d.ts +3 -0
  4. package/arcade/functions/string.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/{db9921fbda556f142c4a.js → 04d55ed51e8b2683c4b4.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{435b90168f79c5587a07.js → 04ecf15524ff3838c01c.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{e2f42aec02bff33b25dd.js → 09300e74e5b014ce6269.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{fcb86d24fc7e0666b564.js → 096b2bf1c0d69d27f20c.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{612345f17f5eeb99ea8f.js → 0d9c4c6c571ce26d356b.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{0f725cf79ce00e790a7d.js → 1168bc5c9f0a7e1f63a2.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{12a7997a40c77f5c9160.js → 151e5799ede763a03ee2.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{a64446a3328a7323e307.js → 173f89c55a5c79ff065b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{8715661a838361d4211a.js → 1b24a40c0fa197014873.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{ca0d4ce453d8eb35467d.js → 277263466837e1673f56.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{b1d989b72203113a06fe.js → 2a36fe3f3f257a779a1b.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{ffcb99693182a621a93e.js → 2cf8172be83b10b11bdc.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{fcaf9450642fcef83286.js → 3048e74e6246324ce6fc.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{95b82cbbe355266c65d7.js → 30af63b3b750142faadb.js} +1 -1
  20. package/assets/esri/core/workers/chunks/30dcf2cfb31cb70de7df.js +1 -0
  21. package/assets/esri/core/workers/chunks/{9f0a973a0dd28953ce25.js → 371e2ddb88cc6b9a41e8.js} +1 -1
  22. package/assets/esri/core/workers/chunks/3fd5c3cd8457ddc68798.js +1 -0
  23. package/assets/esri/core/workers/chunks/{62fec1816907f070f079.js → 3fe04f13215474accb09.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{f47fe4433b05fca5c3ad.js → 42f6194633c2d879c8da.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{cddc3e285f763ccf33c2.js → 4869e097261ded90b8bb.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{d8a7eba588d374b2f961.js → 4bb9a5f4ca944d3fc206.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{8052da8be251c3ff2176.js → 4d93bed14945e3d34d5c.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{65cb5e39c467a35621ca.js → 56e903ccef66cbe18f92.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{44d5508042cacdfcac47.js → 58da3f8cf0f7f6a7e4fa.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{bc915fb182d463d804e6.js → 5c04835b0b52461183cd.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{7e8611cb709f105946f5.js → 6061232c96e11eb7b25d.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{1e514e1c9aabefa04201.js → 64382363d6dc04ff1eac.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{c82daefb193aae895bc0.js → 67e06d606c7fd2064adf.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{434a8ba841a59e0deab9.js → 67e533748435253aaba6.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{feb41abc03d677df6f73.js → 6b9961261241fdce0e94.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{949bee7b304e625a7891.js → 6db0f8fe1402643fbe1a.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{96c4ea9cfa3930f1c3fb.js → 6f1d6453184e0a1530ad.js} +1 -1
  38. package/assets/esri/core/workers/chunks/6f897b4e7ddd1dd1672b.js +1 -0
  39. package/assets/esri/core/workers/chunks/{0049b66ccbfb168caa76.js → 7124ad8dc5ad40dc66f3.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{6e107ce73633de8ac257.js → 72f4dad65e16a7d7c58f.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{0df9a906f7823c23d426.js → 7566321c6a2913f2852b.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{c4ddac23bd649d24f3f2.js → 75d551a449bba61ce238.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{af349c7bc8ef41a0e1bd.js → 7748c2886d0122b40eeb.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{b4c3ec081874b49ff89b.js → 78fbe330f16bdbdb886e.js} +1 -1
  45. package/assets/esri/core/workers/chunks/79483c05867ba1386f5a.js +1 -0
  46. package/assets/esri/core/workers/chunks/7b482afb9fd1229f5707.js +1 -0
  47. package/assets/esri/core/workers/chunks/7c631e2947243e2c9bde.js +1 -0
  48. package/assets/esri/core/workers/chunks/7db9e615e60d824eac1b.js +1 -0
  49. package/assets/esri/core/workers/chunks/{8a7b02037151767542f1.js → 7dbf4c7480bf9c72820d.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{64b360625c68cb863a08.js → 84940d8e14caf5a27e04.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{1b1d3f6916d2cb751435.js → 87177e0f82e8a6ae3189.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{5cb26bbaa08114aec5ce.js → 89cc1a5539b82fb46216.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{9d40786c5ceface786ba.js → 8a485130781b49dbf608.js} +1 -1
  54. package/assets/esri/core/workers/chunks/8b5dcc4282772bf6b675.js +1 -0
  55. package/assets/esri/core/workers/chunks/{8c12269d26f5a4c753cb.js → 8ebaf5754e86a45b0497.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{542e5640ea1b80ef801a.js → 9189dfe19a2a2ccd5173.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{67a35155b8b4d36f171e.js → 926e0a3827eaf16ca8b4.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{dc1761cba0454fda3cf9.js → 9630234267098115de4d.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{10d80e793019dfb45ca2.js → 987424121cf30b0f3c50.js} +1 -1
  60. package/assets/esri/core/workers/chunks/9afc87474cef1fc4fe4a.js +1 -0
  61. package/assets/esri/core/workers/chunks/{facd1ff23203fed67686.js → 9b048f80c2d28d527373.js} +1 -1
  62. package/assets/esri/core/workers/chunks/9dd48e75b4e8d9811d81.js +1 -0
  63. package/assets/esri/core/workers/chunks/{ee08ae5b73439a1ff666.js → a163c6005aba3378edaa.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{517106048980a3cbe072.js → a4b822ee45810c4c292a.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{092e311cb7aea92a6a26.js → acb265a22be5e12f38e5.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{1a411ddae7a47015370c.js → acf4737ba509cbd73cce.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{d247dd53788d512b9c9f.js → af3c6794334626b94f00.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{532e9cda8ac3601d8892.js → b12acf1f694f82e00df9.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{636cd05abfbdff19029e.js → ba3d5abff65aefcb8dee.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{504184828048310a052c.js → bdc221d94300c225665a.js} +1 -1
  71. package/assets/esri/core/workers/chunks/c0eb27263f608dc3684b.js +1 -0
  72. package/assets/esri/core/workers/chunks/c2318c014e97ba519be8.js +1 -0
  73. package/assets/esri/core/workers/chunks/{7f8e327acad48c9e75ea.js → c62237c344e341619341.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{a2ad3e620c98e2b2eb06.js → cd355baab983033c3ef0.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{7be6d621a0d1e33dfff4.js → d070fcb73ce274ab80e4.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{6d41444b46677aa762a7.js → db41490bd39d863305bf.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{fc5a36e54929e03efa86.js → dba5f44c4e4a3f075df2.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{3e30b96a8c75bd5b9ae2.js → ddc95cdac6c06fc4794c.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{a5c8f9f5be4ef5063b42.js → df26ec0b508cf4716e0a.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{f426da2210888cc264b4.js → e83f9abee611c5b80009.js} +1 -1
  81. package/assets/esri/core/workers/chunks/{8487727f1197cf7dbf50.js → ef12fa3574d4cbf8b084.js} +1 -1
  82. package/assets/esri/core/workers/chunks/f10c883eb26330e3421c.js +1 -0
  83. package/assets/esri/core/workers/chunks/f46e92c67986c8c09bdd.js +1 -0
  84. package/assets/esri/core/workers/chunks/{709e019885822b1f6f3e.js → f905f1a1aa4c123cbe83.js} +1 -1
  85. package/assets/esri/core/workers/chunks/{5b91e2dffdc84c006539.js → fb37f0848196c28b7fd7.js} +1 -1
  86. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  87. package/assets/esri/libs/librust-text/pkg/text_bg.wasm +0 -0
  88. package/chunks/MultiPathImpl.js +1 -1
  89. package/chunks/OperatorProximityGeodesic.js +1 -1
  90. package/chunks/basis_encoder.js +1 -1
  91. package/chunks/basis_transcoder.js +1 -1
  92. package/chunks/draco_mesh_decoder.js +1 -1
  93. package/chunks/dxt_encoder.js +1 -1
  94. package/chunks/i3s.js +1 -1
  95. package/chunks/lclayout.js +1 -1
  96. package/chunks/lerc-wasm.js +1 -1
  97. package/chunks/libtess-f32.js +1 -1
  98. package/chunks/libtess-f64.js +1 -1
  99. package/chunks/lyr3DMain.js +1 -1
  100. package/chunks/lyr3DWorker.js +1 -1
  101. package/chunks/parquet.js +1 -1
  102. package/chunks/qb3-wasm.js +1 -1
  103. package/chunks/rbush.js +1 -1
  104. package/chunks/text.js +1 -1
  105. package/chunks/vxlLayer.js +1 -1
  106. package/config.js +1 -1
  107. package/core/workers/WorkerFallback.js +4 -2
  108. package/core/workers/workerFactory.js +1 -1
  109. package/core/workers/workers.js +4 -2
  110. package/geometry/support/labelPoint.js +1 -1
  111. package/graphic/AnnotationFeatureGraphicOrigin.d.ts +49 -9
  112. package/graphic/BuildingGraphicOrigin.d.ts +49 -0
  113. package/graphic/CSVGraphicOrigin.d.ts +42 -9
  114. package/graphic/CatalogGraphicOrigin.d.ts +42 -9
  115. package/graphic/DimensionFeatureGraphicOrigin.d.ts +42 -9
  116. package/graphic/FeatureGraphicOrigin.d.ts +42 -9
  117. package/graphic/GeoJSONGraphicOrigin.d.ts +42 -9
  118. package/graphic/GeoRSSGraphicOrigin.d.ts +42 -9
  119. package/graphic/GraphicOrigin.d.ts +52 -12
  120. package/graphic/ImageryGraphicOrigin.d.ts +42 -9
  121. package/graphic/ImageryTileGraphicOrigin.d.ts +42 -9
  122. package/graphic/KMLGraphicOrigin.d.ts +47 -10
  123. package/graphic/KnowledgeGraphGraphicOrigin.d.ts +49 -1
  124. package/graphic/LinkChartGraphicOrigin.d.ts +49 -1
  125. package/graphic/MapImageGraphicOrigin.d.ts +49 -1
  126. package/graphic/MapNotesGraphicOrigin.d.ts +48 -1
  127. package/graphic/OGCFeatureGraphicOrigin.d.ts +42 -9
  128. package/graphic/OrientedImageryGraphicOrigin.d.ts +42 -9
  129. package/graphic/ParquetGraphicOrigin.d.ts +42 -9
  130. package/graphic/PointCloudGraphicOrigin.d.ts +43 -0
  131. package/graphic/SceneGraphicOrigin.d.ts +43 -0
  132. package/graphic/SketchGraphicOrigin.d.ts +43 -0
  133. package/graphic/StreamGraphicOrigin.d.ts +43 -0
  134. package/graphic/SubtypeGroupGraphicOrigin.d.ts +49 -1
  135. package/graphic/TileGraphicOrigin.d.ts +49 -1
  136. package/graphic/VectorTileGraphicOrigin.d.ts +43 -14
  137. package/graphic/VoxelGraphicOrigin.d.ts +43 -0
  138. package/graphic/WCSGraphicOrigin.d.ts +43 -0
  139. package/graphic/WFSGraphicOrigin.d.ts +42 -9
  140. package/graphic/getGraphicOriginTitle.d.ts +21 -3
  141. package/kernel.js +1 -1
  142. package/layers/GaussianSplatLayer.d.ts +2 -1
  143. package/layers/ParquetLayer.d.ts +24 -1
  144. package/layers/ParquetLayer.js +1 -1
  145. package/layers/mixins/ReloadableLayer.js +1 -1
  146. package/layers/orientedImagery/transformations/utils.js +1 -1
  147. package/layers/save/featureLayerUtils.js +1 -1
  148. package/layers/save/imageryUtils.js +1 -1
  149. package/layers/save/mapImageLayerUtils.js +1 -1
  150. package/layers/save/mediaLayerUtils.js +1 -1
  151. package/layers/save/parquetLayerUtils.js +2 -0
  152. package/layers/save/streamLayerUtils.js +1 -1
  153. package/layers/support/LabelClass.d.ts +8 -2
  154. package/layers/support/layersMapping.js +1 -1
  155. package/layers/support/rasterJobHelper.js +1 -1
  156. package/layers/video/VideoController.js +5 -5
  157. package/package.json +2 -2
  158. package/popup/content.js +1 -1
  159. package/portal/schemas/definitions.js +1 -1
  160. package/portal/schemas/webScene.js +1 -1
  161. package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
  162. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  163. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  164. package/undoredo/support/ApplySet.js +1 -1
  165. package/views/2d/engine/flow/ProcessingTimeEstimate.js +1 -1
  166. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  167. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  168. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  169. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  170. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  171. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  172. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  173. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  174. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  175. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  176. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  177. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  178. package/views/3d/layers/graphics/LabelParameters.js +1 -1
  179. package/views/3d/layers/graphics/Labeler.js +1 -1
  180. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  181. package/views/3d/layers/graphics/pointUtils.js +1 -1
  182. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  183. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  184. package/views/3d/layers/support/Tiles3DBVH.js +1 -1
  185. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  186. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  187. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  188. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  189. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  190. package/views/3d/state/utils/navigationUtils.js +1 -1
  191. package/views/3d/terrain/TerrainRenderer.js +1 -1
  192. package/views/3d/terrain/TerrainSurface.js +1 -1
  193. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  194. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowCastRenderer.js +1 -1
  195. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  196. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  197. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  198. package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +1 -1
  199. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  200. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  201. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  202. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  203. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  204. package/views/3d/webgl-engine/materials/internal/worldSizedRibbonLineIntersectionUtils.js +1 -1
  205. package/views/DOMContainer.js +1 -1
  206. package/views/draw/SegmentDrawAction.js +1 -1
  207. package/views/interactive/snapping/SnappingManagerPool.js +1 -1
  208. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  209. package/views/interactive/tooltip/fields/TooltipField.js +1 -1
  210. package/views/support/LayerViewManager.js +1 -1
  211. package/views/support/ScheduledQueueProcessor.js +1 -1
  212. package/views/support/screenshotUtils.js +1 -1
  213. package/views/ui/UI.js +1 -1
  214. package/webdoc/support/webdocSaveUtils.js +1 -1
  215. package/webscene/Slide.d.ts +1 -2
  216. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  217. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  218. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  219. package/widgets/FeatureTable/RelationshipColumn.js +1 -1
  220. package/widgets/OrientedImageryViewer/ImageMeasurementWorker.js +1 -1
  221. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  222. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  223. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  224. package/widgets/Sketch/SketchViewModel.js +1 -1
  225. package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +0 -1
  226. package/assets/esri/core/workers/chunks/42753cf4965a94bc91ca.js +0 -1
  227. package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +0 -1
  228. package/assets/esri/core/workers/chunks/5046214dd32029cb733d.js +0 -1
  229. package/assets/esri/core/workers/chunks/58865772bed48141a56a.js +0 -1
  230. package/assets/esri/core/workers/chunks/72e6d594b7262430ae55.js +0 -1
  231. package/assets/esri/core/workers/chunks/7d11710e1586a3d75887.js +0 -1
  232. package/assets/esri/core/workers/chunks/8f74d92ac69714b9fd4e.js +0 -1
  233. package/assets/esri/core/workers/chunks/947674b2ca8be65b9bcc.js +0 -1
  234. package/assets/esri/core/workers/chunks/9e7c4eda135c4911b268.js +0 -1
  235. package/assets/esri/core/workers/chunks/a09d2e1e2540921e4717.js +0 -1
  236. package/assets/esri/core/workers/chunks/dfa5f1311806473e473f.js +0 -1
  237. package/assets/esri/core/workers/chunks/fc76aff0f7d95e517d8f.js +0 -1
@@ -157,7 +157,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
157
157
  <path d="M1664 896q0 209-103 385.5T1281.5 1561 896 1664q-111 0-218-32 59-93 78-164 9-34 54-211 20 39 73 67.5t114 28.5q121 0 216-68.5t147-188.5 52-270q0-114-59.5-214T1180 449t-255-63q-105 0-196 29t-154.5 77-109 110.5-67 129.5T377 866q0 104 40 183t117 111q30 12 38-20 2-7 8-31t8-30q6-23-11-43-51-61-51-151 0-151 104.5-259.5T904 517q151 0 235.5 82t84.5 213q0 170-68.5 289T980 1220q-61 0-98-43.5T859 1072q8-35 26.5-93.5t30-103T927 800q0-50-27-83t-77-33q-62 0-105 57t-43 142q0 73 25 122l-99 418q-17 70-13 177-206-91-333-281T128 896q0-209 103-385.5T510.5 231 896 128t385.5 103T1561 510.5 1664 896z"></path>
158
158
  </symbol>
159
159
  </defs>
160
- </svg>`;const Ys=na?10009:ra?461:8,Xs={codes:{play:415,pause:19,ff:417,rw:412,back:Ys},names:{415:`play`,19:`pause`,417:`ff`,412:`rw`,[Ys]:`back`},isEventKey(e,t){return t=t.toLowerCase(),!!(this.names[e.keyCode]&&this.names[e.keyCode]===t)},getEventName(e){if(this.names[e.keyCode])return this.names[e.keyCode];if(this.codes[e.code]){let t=this.codes[e.code];return this.names[t]}return null}};class Zs extends go{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on(`keydown`,this.onKeyDown_),this.player_.on(`modalKeydown`,this.onKeyDown_),this.player_.on(`loadedmetadata`,()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on(`modalclose`,()=>{this.refocusComponent()}),this.player_.on(`focusin`,this.handlePlayerFocus_.bind(this)),this.player_.on(`focusout`,this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on(`aftermodalfill`,()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off(`keydown`,this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){let t=e.originalEvent?e.originalEvent:e;if([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(t.key)){if(this.isPaused_)return;t.preventDefault();let e=t.key.substring(5).toLowerCase();this.move(e)}else if(Xs.isEventKey(t,`play`)||Xs.isEventKey(t,`pause`)||Xs.isEventKey(t,`ff`)||Xs.isEventKey(t,`rw`)){t.preventDefault();let e=Xs.getEventName(t);this.performMediaAction_(e)}else Xs.isEventKey(t,`Back`)&&e.target&&typeof e.target.closeable==`function`&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case`play`:this.player_.paused()&&this.player_.play();break;case`pause`:this.player_.paused()||this.player_.pause();break;case`ff`:this.userSeek_(this.player_.currentTime()+5);break;case`rw`:this.userSeek_(this.player_.currentTime()-5)}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){let t=e.relatedTarget,n=null,r=this.getCurrentComponent(e.target);t&&(n=!!t.closest(`.video-js`),t.classList.contains(`vjs-text-track-settings`)&&!this.isPaused_&&this.searchForTrackSelect_()),(e.currentTarget.contains(e.relatedTarget)||n)&&t||(r&&r.name()===`CloseButton`?this.refocusComponent():(this.pause(),r&&r.el()&&(this.lastFocusedComponent_=r)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){let e=this.player_,t=[];function n(e){for(let r of e)r.hasOwnProperty(`el_`)&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty(`children_`)&&r.children_.length>0&&n(r.children_)}return e.children_.forEach(e=>{if(e.hasOwnProperty(`el_`)){if(e.getIsFocusable&&e.getIsAvailableToBeFocused&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())){t.push(e);return}e.hasOwnProperty(`children_`)&&e.children_.length>0?n(e.children_):e.hasOwnProperty(`items`)&&e.items.length>0?n(e.items):this.findSuitableDOMChild(e)&&t.push(e)}if(e.name_===`ErrorDisplay`&&e.opened_){let n=e.el_.querySelector(`.vjs-errors-ok-button-container`);n&&n.querySelectorAll(`button`).forEach((e,n)=>{t.push({name:()=>`ModalButton`+(n+1),el:()=>e,getPositions:()=>{let t=e.getBoundingClientRect();return{boundingClientRect:{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left},center:{x:t.left+t.width/2,y:t.top+t.height/2,width:0,height:0,top:t.top+t.height/2,right:t.left+t.width/2,bottom:t.top+t.height/2,left:t.left+t.width/2}}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:e=>!0,focus:()=>e.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(n){if(e.getIsFocusable(n)&&e.getIsAvailableToBeFocused(n))return n;for(let e=0;e<n.children.length;e++){let r=n.children[e],i=t(r);if(i)return i}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();let t=e||document.activeElement;if(this.focusableComponents.length){for(let e of this.focusableComponents)if(e.el()===t)return e}}add(e){let t=[...this.focusableComponents];e.hasOwnProperty(`el_`)&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:`focusableComponentsChanged`,focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:`focusableComponentsChanged`,focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:`focusableComponentsChanged`,focusableComponents:this.focusableComponents}))}move(e){let t=this.getCurrentComponent();if(!t)return;let n=t.getPositions(),r=this.focusableComponents.filter(r=>r!==t&&this.isInDirection_(n.boundingClientRect,r.getPositions().boundingClientRect,e)),i=this.findBestCandidate_(n.center,r,e);i?this.focus(i):this.trigger({type:`endOfFocusableComponents`,direction:e,focusedComponent:t})}findBestCandidate_(e,t,n){let r=1/0,i=null;for(let a of t){let t=a.getPositions().center,o=this.calculateDistance_(e,t,n);o<r&&(r=o,i=a)}return i}isInDirection_(e,t,n){switch(n){case`right`:return t.left>=e.right;case`left`:return t.right<=e.left;case`down`:return t.top>=e.bottom;case`up`:return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e==`object`&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,n){let r=Math.abs(e.x-t.x),i=Math.abs(e.y-t.y),a;switch(n){case`right`:case`left`:a=r+i*100;break;case`up`:a=i*2+r*.5;break;case`down`:a=i*5+r;break;default:a=r+i}return a}searchForTrackSelect_(){let e=this;for(let t of e.updateFocusableComponents())if(t.constructor.name===`TextTrackSelect`){e.focus(t);break}}}class Qs extends q{constructor(e,t,n){let r=W({createEl:!1},t);if(super(e,r,n),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let n=0,r=t.playerOptions.techOrder;n<r.length;n++){let t=jo(r[n]),i=J.getTech(t);if(t||(i=q.getComponent(t)),i&&i.isSupported()){e.loadTech_(t);break}}else e.src(t.playerOptions.sources)}}q.registerComponent(`MediaLoader`,Qs);class $s extends q{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=e=>this.handleMouseOver(e),this.handleMouseOut_=e=>this.handleMouseOut(e),this.handleClick_=e=>this.handleClick(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.emitTapEvents(),this.enable()}createEl(e=`div`,t={},n={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e===`button`&&U.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),n=Object.assign({role:`button`},n),this.tabIndex_=t.tabIndex;let r=G(e,t,n);return this.player_.options_.experimentalSvgIcons||r.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),this.createControlTextEl(r),r}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=G(`span`,{className:`vjs-control-text`},{"aria-live":`polite`}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||`Need Text`;let n=this.localize(e);this.controlText_=e,ga(this.controlTextEl_,n),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute(`title`,n)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass(`vjs-disabled`),this.el_.setAttribute(`aria-disabled`,`false`),this.tabIndex_!==void 0&&this.el_.setAttribute(`tabIndex`,this.tabIndex_),this.on([`tap`,`click`],this.handleClick_),this.on(`keydown`,this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass(`vjs-disabled`),this.el_.setAttribute(`aria-disabled`,`true`),this.tabIndex_!==void 0&&this.el_.removeAttribute(`tabIndex`),this.off(`mouseover`,this.handleMouseOver_),this.off(`mouseout`,this.handleMouseOut_),this.off([`tap`,`click`],this.handleClick_),this.off(`keydown`,this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===` `||e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),this.trigger(`click`)):super.handleKeyDown(e)}}q.registerComponent(`ClickableComponent`,$s);class ec extends $s{constructor(e,t){super(e,t);let{mainContent:n}=t&&t.playerOptions||{};this.isMainContent=n,this.update(),this.update_=e=>this.update(e),e.on(`posterchange`,this.update_)}dispose(){this.player().off(`posterchange`,this.update_),super.dispose()}createEl(){return G(`div`,{className:`vjs-poster`})}crossOrigin(e){if(e===void 0)return this.$(`img`)?this.$(`img`).crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;e!==null&&e!==`anonymous`&&e!==`use-credentials`?this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`):this.$(`img`)&&(this.$(`img`).crossOrigin=e)}update(e){let t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){e?(this.$(`img`)||this.el_.appendChild(G(`picture`,{className:`vjs-poster`,tabIndex:-1},{},G(`img`,{loading:this.isMainContent?`eager`:`lazy`,fetchPriority:this.isMainContent?`high`:`auto`,crossOrigin:this.crossOrigin()},{alt:``}))),this.$(`img`).src=e):this.el_.textContent=``}handleClick(e){if(!this.player_.controls())return;let t=this.player_.getChild(`controlBar`),n=t&&t.getChild(`playToggle`);Gi?(n||this.player_).focus():this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?qo(this.player_.play()):this.player_.pause()}}ec.prototype.crossorigin=ec.prototype.crossOrigin,q.registerComponent(`PosterImage`,ec);const tc=`#222`,nc=`#ccc`,rc={monospace:`monospace`,sansSerif:`sans-serif`,serif:`serif`,monospaceSansSerif:`"Andale Mono", "Lucida Console", monospace`,monospaceSerif:`"Courier New", monospace`,proportionalSansSerif:`sans-serif`,proportionalSerif:`serif`,casual:`"Comic Sans MS", Impact, fantasy`,script:`"Monotype Corsiva", cursive`,smallcaps:`"Andale Mono", "Lucida Console", monospace, sans-serif`};function ic(e,t){let n;if(e.length===4)n=e[1]+e[1]+e[2]+e[2]+e[3]+e[3];else if(e.length===7)n=e.slice(1);else throw Error(`Invalid color code provided, `+e+`; must be formatted as e.g. #f0e or #f604e2.`);return`rgba(`+parseInt(n.slice(0,2),16)+`,`+parseInt(n.slice(2,4),16)+`,`+parseInt(n.slice(4,6),16)+`,`+t+`)`}function ac(e,t,n){try{e.style[t]=n}catch{return}}function oc(e){return e?`${e}px`:``}class sc extends q{constructor(e,t,n){super(e,t,n);let r=e=>this.updateDisplay(e),i=e=>{this.updateDisplayOverlay(),this.updateDisplay(e)};e.on(`loadstart`,e=>this.toggleDisplay(e)),e.on(`useractive`,r),e.on(`userinactive`,r),e.on(`texttrackchange`,r),e.on(`loadedmetadata`,e=>{this.updateDisplayOverlay(),this.preselectTrack(e)}),e.ready(K(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on(`fullscreenchange`,i),e.on(`playerresize`,i);let t=x.screen.orientation||x,n=x.screen.orientation?`change`:`orientationchange`;t.addEventListener(n,i),e.on(`dispose`,()=>t.removeEventListener(n,i));let r=this.options_.playerOptions.tracks||[];for(let e=0;e<r.length;e++)this.player_.addRemoteTextTrack(r[e],!0);this.preselectTrack()}))}preselectTrack(){let e={captions:1,subtitles:1},t=this.player_.textTracks(),n=this.player_.cache_.selectedLanguage,r,i,a;for(let o=0;o<t.length;o++){let s=t[o];n&&n.enabled&&n.language&&n.language===s.language&&s.kind in e?s.kind===n.kind?a=s:a||=s:n&&!n.enabled?(a=null,r=null,i=null):s.default&&(s.kind===`descriptions`&&!r?r=s:s.kind in e&&!i&&(i=s))}a?a.mode=`showing`:i?i.mode=`showing`:r&&(r.mode=`showing`)}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl(`div`,{className:`vjs-text-track-display`},{translate:`yes`,"aria-live":`off`,"aria-atomic":`true`})}clearDisplay(){typeof x.WebVTT==`function`&&x.WebVTT.processCues(x,[],this.el_)}updateDisplay(){let e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){let t=[];for(let n=0;n<e.length;++n){let r=e[n];r.mode===`showing`&&t.push(r)}this.updateForTrack(t);return}let n=null,r=null,i=e.length;for(;i--;){let t=e[i];t.mode===`showing`&&(t.kind===`descriptions`?n=t:r=t)}if(r?(this.getAttribute(`aria-live`)!==`off`&&this.setAttribute(`aria-live`,`off`),this.updateForTrack(r)):n&&(this.getAttribute(`aria-live`)!==`assertive`&&this.setAttribute(`aria-live`,`assertive`),this.updateForTrack(n)),!(x.CSS!==void 0&&x.CSS.supports(`inset`,`10px`))){let e=this.el_,t=e.querySelectorAll(`.vjs-text-track-cue`),n=this.player_.controlBar.el_.getBoundingClientRect().height,r=this.player_.el_.getBoundingClientRect().height;e.style=``,ac(e,`position`,`relative`),ac(e,`height`,r-n+`px`),ac(e,`top`,`unset`),ia?ac(e,`bottom`,r+`px`):ac(e,`bottom`,`0px`),t.length>0&&t.forEach(e=>{if(e.style.inset){let t=e.style.inset.split(` `);t.length===3&&Object.assign(e.style,{top:t[0],right:t[1],bottom:t[2],left:`unset`})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!(x.CSS!==void 0&&x.CSS.supports(`inset-inline: 10px`)))return;let e=this.player_.currentWidth(),t=this.player_.currentHeight(),n=e/t,r=this.player_.videoWidth()/this.player_.videoHeight(),i=0,a=0;Math.abs(n-r)>.1&&(n>r?i=Math.round((e-t*r)/2):a=Math.round((t-e/r)/2)),ac(this.el_,`insetInline`,oc(i)),ac(this.el_,`insetBlock`,oc(a))}updateDisplayState(e){let t=this.player_.textTrackSettings.getValues(),n=e.activeCues,r=n.length;for(;r--;){let e=n[r];if(!e)continue;let i=e.displayState;if(t.color&&(i.firstChild.style.color=t.color),t.textOpacity&&ac(i.firstChild,`color`,ic(t.color||`#fff`,t.textOpacity)),t.backgroundColor&&(i.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&ac(i.firstChild,`backgroundColor`,ic(t.backgroundColor||`#000`,t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?ac(i,`backgroundColor`,ic(t.windowColor,t.windowOpacity)):i.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle===`dropshadow`?i.firstChild.style.textShadow=`2px 2px 3px ${tc}, 2px 2px 4px ${tc}, 2px 2px 5px ${tc}`:t.edgeStyle===`raised`?i.firstChild.style.textShadow=`1px 1px ${tc}, 2px 2px ${tc}, 3px 3px ${tc}`:t.edgeStyle===`depressed`?i.firstChild.style.textShadow=`1px 1px ${nc}, 0 1px ${nc}, -1px -1px ${tc}, 0 -1px ${tc}`:t.edgeStyle===`uniform`&&(i.firstChild.style.textShadow=`0 0 4px ${tc}, 0 0 4px ${tc}, 0 0 4px ${tc}, 0 0 4px ${tc}`)),t.fontPercent&&t.fontPercent!==1){let e=x.parseFloat(i.style.fontSize);i.style.fontSize=e*t.fontPercent+`px`,i.style.height=`auto`,i.style.top=`auto`}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily===`small-caps`?i.firstChild.style.fontVariant=`small-caps`:i.firstChild.style.fontFamily=rc[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof x.WebVTT!=`function`||e.every(e=>!e.activeCues))return;let t=[];for(let n=0;n<e.length;++n){let r=e[n];for(let e=0;e<r.activeCues.length;++e)t.push(r.activeCues[e])}x.WebVTT.processCues(x,t,this.el_);for(let t=0;t<e.length;++t){let n=e[t];for(let e=0;e<n.activeCues.length;++e){let r=n.activeCues[e].displayState;ya(r,`vjs-text-track-cue`,`vjs-text-track-cue-`+(n.language?n.language:t)),n.language&&Ta(r,`lang`,n.language)}this.player_.textTrackSettings&&this.updateDisplayState(n)}}}q.registerComponent(`TextTrackDisplay`,sc);class cc extends q{createEl(){let e=this.player_.isAudio(),t=this.localize(e?`Audio Player`:`Video Player`),n=G(`span`,{className:`vjs-control-text`,textContent:this.localize(`{1} is loading.`,[t])}),r=super.createEl(`div`,{className:`vjs-loading-spinner`,dir:`ltr`});return r.appendChild(n),r}handleLanguagechange(){this.$(`.vjs-control-text`).textContent=this.localize(`{1} is loading.`,[this.player_.isAudio()?`Audio Player`:`Video Player`])}}q.registerComponent(`LoadingSpinner`,cc);class lc extends $s{createEl(e,t={},n={}){e=`button`,t=Object.assign({className:this.buildCSSClass()},t),n=Object.assign({type:`button`},n);let r=G(e,t,n);return this.player_.options_.experimentalSvgIcons||r.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),this.createControlTextEl(r),r}addChild(e,t={}){let n=this.constructor.name;return U.warn(`Adding an actionable (user controllable) child to a Button (${n}) is not supported; use a ClickableComponent instead.`),q.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute(`disabled`)}disable(){super.disable(),this.el_.setAttribute(`disabled`,`disabled`)}handleKeyDown(e){e.key===` `||e.key===`Enter`?e.stopPropagation():super.handleKeyDown(e)}}q.registerComponent(`Button`,lc);class uc extends lc{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon(`play`),this.on(`mousedown`,e=>this.handleMouseDown(e))}buildCSSClass(){return`vjs-big-play-button`}handleClick(e){let t=this.player_.play(),n=this.player_.getChild(`controlBar`),r=n&&n.getChild(`playToggle`);if(e.type===`tap`||this.mouseused_&&`clientX`in e&&`clientY`in e){qo(t),Gi?(r||this.player_).focus():this.player_.tech(!0)&&this.player_.tech(!0).focus();return}if(!r){this.player_.tech(!0).focus();return}let i=()=>r.focus();Ko(t)?t.then(i,()=>{}):this.setTimeout(i,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}uc.prototype.controlText_=`Play Video`,q.registerComponent(`BigPlayButton`,uc);class dc extends lc{constructor(e,t){super(e,t),this.setIcon(`cancel`),this.controlText(t&&t.controlText||this.localize(`Close`))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:`close`,bubbles:!1})}handleKeyDown(e){e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this.trigger(`click`)):super.handleKeyDown(e)}}q.registerComponent(`CloseButton`,dc);class fc extends lc{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon(`play`),this.on(e,`play`,e=>this.handlePlay(e)),this.on(e,`pause`,e=>this.handlePause(e)),t.replay&&this.on(e,`ended`,e=>this.handleEnded(e))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?qo(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass(`vjs-ended`),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass(`vjs-ended`,`vjs-paused`),this.addClass(`vjs-playing`),this.setIcon(`pause`),this.controlText(`Pause`)}handlePause(e){this.removeClass(`vjs-playing`),this.addClass(`vjs-paused`),this.setIcon(`play`),this.controlText(`Play`)}handleEnded(e){this.removeClass(`vjs-playing`),this.addClass(`vjs-ended`),this.setIcon(`replay`),this.controlText(`Replay`),this.one(this.player_,`seeked`,e=>this.handleSeeked(e))}}fc.prototype.controlText_=`Play`,q.registerComponent(`PlayToggle`,fc);class pc extends q{constructor(e,t){super(e,t),this.on(e,[`timeupdate`,`ended`,`seeking`],e=>this.update(e)),this.updateTextNode_()}createEl(){let e=this.buildCSSClass(),t=super.createEl(`div`,{className:`${e} vjs-time-control vjs-control`}),n=G(`span`,{className:`vjs-control-text`,textContent:`${this.localize(this.labelText_)}\u00a0`},{role:`presentation`});return t.appendChild(n),this.contentEl_=G(`span`,{className:`${e}-display`},{role:`presentation`}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){(this.player_.options_.enableSmoothSeeking||e.type!==`seeking`)&&this.updateContent(e)}updateTextNode_(e=0){e=Ho(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame(`TimeDisplay#updateTextNode_`,()=>{if(!this.contentEl_)return;let e=this.textNode_;e&&this.contentEl_.firstChild!==e&&(e=null,U.warn(`TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.`)),this.textNode_=F.createTextNode(this.formattedTime_),this.textNode_&&(e?this.contentEl_.replaceChild(this.textNode_,e):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}pc.prototype.labelText_=`Time`,pc.prototype.controlText_=`Time`,q.registerComponent(`TimeDisplay`,pc);class mc extends pc{buildCSSClass(){return`vjs-current-time`}updateContent(e){let t;t=this.player_.ended()?this.player_.duration():e&&e.target&&typeof e.target.pendingSeekTime==`function`&&e.target.pendingSeekTime()!==null?e.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}mc.prototype.labelText_=`Current Time`,mc.prototype.controlText_=`Current Time`,q.registerComponent(`CurrentTimeDisplay`,mc);class hc extends pc{constructor(e,t){super(e,t);let n=e=>this.updateContent(e);this.on(e,`durationchange`,n),this.on(e,`loadstart`,n),this.on(e,`loadedmetadata`,n)}buildCSSClass(){return`vjs-duration`}updateContent(e){let t=this.player_.duration();this.updateTextNode_(t)}}hc.prototype.labelText_=`Duration`,hc.prototype.controlText_=`Duration`,q.registerComponent(`DurationDisplay`,hc);class gc extends q{createEl(){let e=super.createEl(`div`,{className:`vjs-time-control vjs-time-divider`},{"aria-hidden":!0}),t=super.createEl(`div`),n=super.createEl(`span`,{textContent:`/`});return t.appendChild(n),e.appendChild(t),e}}q.registerComponent(`TimeDivider`,gc);class _c extends pc{constructor(e,t){super(e,t),this.on(e,`durationchange`,e=>this.updateContent(e))}buildCSSClass(){return`vjs-remaining-time`}createEl(){let e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(G(`span`,{},{"aria-hidden":!0},`-`),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!=`number`)return;let t;t=this.player_.ended()?0:this.player_.remainingTimeDisplay?this.player_.remainingTimeDisplay():this.player_.remainingTime(),this.updateTextNode_(t)}}_c.prototype.labelText_=`Remaining Time`,_c.prototype.controlText_=`Remaining Time`,q.registerComponent(`RemainingTimeDisplay`,_c);class vc extends q{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),`durationchange`,e=>this.updateShowing(e))}createEl(){let e=super.createEl(`div`,{className:`vjs-live-control vjs-control`});return this.contentEl_=G(`div`,{className:`vjs-live-display`},{"aria-live":`off`}),this.contentEl_.appendChild(G(`span`,{className:`vjs-control-text`,textContent:`${this.localize(`Stream Type`)}\u00a0`})),this.contentEl_.appendChild(F.createTextNode(this.localize(`LIVE`))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}q.registerComponent(`LiveDisplay`,vc);class yc extends lc{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=e=>this.updateLiveEdgeStatus(e),this.on(this.player_.liveTracker,`liveedgechange`,this.updateLiveEdgeStatusHandler_))}createEl(){let e=super.createEl(`button`,{className:`vjs-seek-to-live-control vjs-control`});return this.setIcon(`circle`,e),this.textEl_=G(`span`,{className:`vjs-seek-to-live-text`,textContent:this.localize(`LIVE`)},{"aria-hidden":`true`}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute(`aria-disabled`,!0),this.addClass(`vjs-at-live-edge`),this.controlText(`Seek to live, currently playing live`)):(this.setAttribute(`aria-disabled`,!1),this.removeClass(`vjs-at-live-edge`),this.controlText(`Seek to live, currently behind live`))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,`liveedgechange`,this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}yc.prototype.controlText_=`Seek to live, currently playing live`,q.registerComponent(`SeekToLive`,yc);function bc(e,t,n){return e=Number(e),Math.min(n,Math.max(t,isNaN(e)?t:e))}var xc=Object.freeze({__proto__:null,clamp:bc});class Sc extends q{constructor(e,t){super(e,t),this.handleMouseDown_=e=>this.handleMouseDown(e),this.handleMouseUp_=e=>this.handleMouseUp(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.handleClick_=e=>this.handleClick(e),this.handleMouseMove_=e=>this.handleMouseMove(e),this.update_=e=>this.update(e),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on(`mousedown`,this.handleMouseDown_),this.on(`touchstart`,this.handleMouseDown_),this.on(`keydown`,this.handleKeyDown_),this.on(`click`,this.handleClick_),this.on(this.player_,`controlsvisible`,this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass(`disabled`),this.setAttribute(`tabindex`,0),this.enabled_=!0)}disable(){if(!this.enabled())return;let e=this.bar.el_.ownerDocument;this.off(`mousedown`,this.handleMouseDown_),this.off(`touchstart`,this.handleMouseDown_),this.off(`keydown`,this.handleKeyDown_),this.off(`click`,this.handleClick_),this.off(this.player_,`controlsvisible`,this.update_),this.off(e,`mousemove`,this.handleMouseMove_),this.off(e,`mouseup`,this.handleMouseUp_),this.off(e,`touchmove`,this.handleMouseMove_),this.off(e,`touchend`,this.handleMouseUp_),this.removeAttribute(`tabindex`),this.addClass(`disabled`),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},n={}){return t.className+=` vjs-slider`,t=Object.assign({tabIndex:0},t),n=Object.assign({role:`slider`,"aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},n),super.createEl(e,t,n)}handleMouseDown(e){let t=this.bar.el_.ownerDocument;e.type===`mousedown`&&e.preventDefault(),e.type===`touchstart`&&!qi&&e.preventDefault(),Da(),this.addClass(`vjs-sliding`),this.trigger(`slideractive`),this.on(t,`mousemove`,this.handleMouseMove_),this.on(t,`mouseup`,this.handleMouseUp_),this.on(t,`touchmove`,this.handleMouseMove_),this.on(t,`touchend`,this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){let t=this.bar.el_.ownerDocument;Oa(),this.removeClass(`vjs-sliding`),this.trigger(`sliderinactive`),this.off(t,`mousemove`,this.handleMouseMove_),this.off(t,`mouseup`,this.handleMouseUp_),this.off(t,`touchmove`,this.handleMouseMove_),this.off(t,`touchend`,this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;let e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame(`Slider#update`,()=>{let t=this.vertical()?`height`:`width`;this.bar.el().style[t]=(e*100).toFixed(2)+`%`})),e}getProgress(){return Number(bc(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){let t=ja(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){let t=this.options_.playerOptions.spatialNavigation,n=t&&t.enabled,r=t&&t.horizontalSeek;n?r&&e.key===`ArrowLeft`||!r&&e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),this.stepBack()):r&&e.key===`ArrowRight`||!r&&e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(this.pendingSeekTime()&&(this.pendingSeekTime(null),this.userSeek_(this.player_.currentTime())),super.handleKeyDown(e)):e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key===`ArrowUp`||e.key===`ArrowRight`?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass(`vjs-slider-vertical`):this.addClass(`vjs-slider-horizontal`)}}q.registerComponent(`Slider`,Sc);const Cc=(e,t)=>bc(e/t*100,0,100).toFixed(2)+`%`;class wc extends q{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,`progress`,e=>this.update(e))}createEl(){let e=super.createEl(`div`,{className:`vjs-load-progress`}),t=G(`span`,{className:`vjs-control-text`}),n=G(`span`,{textContent:this.localize(`Loaded`)}),r=F.createTextNode(`: `);return this.percentageEl_=G(`span`,{className:`vjs-control-text-loaded-percentage`,textContent:`0%`}),e.appendChild(t),t.appendChild(n),t.appendChild(r),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame(`LoadProgressBar#update`,()=>{let e=this.player_.liveTracker,t=this.player_.buffered(),n=e&&e.isLive()?e.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),i=this.partEls_,a=Cc(r,n);this.percent_!==a&&(this.el_.style.width=a,ga(this.percentageEl_,a),this.percent_=a);for(let e=0;e<t.length;e++){let n=t.start(e),a=t.end(e),o=i[e];o||(o=this.el_.appendChild(G()),i[e]=o),(o.dataset.start!==n||o.dataset.end!==a)&&(o.dataset.start=n,o.dataset.end=a,o.style.left=Cc(n,r),o.style.width=Cc(a-n,r))}for(let e=i.length;e>t.length;e--)this.el_.removeChild(i[e-1]);i.length=t.length})}}q.registerComponent(`LoadProgressBar`,wc);class Tc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-time-tooltip`},{"aria-hidden":`true`})}update(e,t,n){let r=Aa(this.el_),i=ka(this.player_.el()),a=e.width*t;if(!i||!r)return;let o=e.left-i.left+a,s=e.width-a+(i.right-e.right);s||(s=e.width-a,o=a);let c=r.width/2;o<c?c+=c-o:s<c&&(c=s),c<0?c=0:c>r.width&&(c=r.width),c=Math.round(c),this.el_.style.right=`-${c}px`,this.write(n)}write(e){ga(this.el_,e)}updateTime(e,t,n,r){this.requestNamedAnimationFrame(`TimeTooltip#updateTime`,()=>{let i,a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){let e=this.player_.liveTracker.liveWindow(),n=e-t*e;i=(n<1?``:`-`)+Ho(n,e)}else i=Ho(n,a);this.update(e,t,i),r&&r()})}}q.registerComponent(`TimeTooltip`,Tc);class Ec extends q{constructor(e,t){super(e,t),this.setIcon(`circle`),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-play-progress vjs-slider-bar`},{"aria-hidden":`true`})}update(e,t,n){let r=this.getChild(`timeTooltip`);if(!r)return;let i=n&&n.target&&typeof n.target.pendingSeekTime==`function`?n.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();r.updateTime(e,t,i)}}Ec.prototype.options_={children:[]},!sa&&!Hi&&Ec.prototype.options_.children.push(`timeTooltip`),q.registerComponent(`PlayProgressBar`,Ec);class Dc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-mouse-display`})}update(e,t){let n=t*this.player_.duration();this.getChild(`timeTooltip`).updateTime(e,t,n,()=>{this.el_.style.left=`${e.width*t}px`})}}Dc.prototype.options_={children:[`timeTooltip`]},q.registerComponent(`MouseTimeDisplay`,Dc);class Oc extends Sc{constructor(e,t){t=W(Oc.prototype.options_,t),t.children=[...t.children];let n=e.options_.disableSeekWhileScrubbingOnMobile&&(sa||Hi)||e.options_.disableSeekWhileScrubbingOnSTV;(!sa&&!Hi||n)&&t.children.splice(1,0,`mouseTimeDisplay`),super(e,t),this.shouldDisableSeekWhileScrubbing_=n,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=K(this,this.update),this.update=fo(this.update_,30),this.on(this.player_,[`durationchange`,`timeupdate`],this.update),this.on(this.player_,[`ended`],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,`liveedgechange`,this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,[`playing`],this.enableIntervalHandler_),this.on(this.player_,[`ended`,`pause`,`waiting`],this.disableIntervalHandler_),`hidden`in F&&`visibilityState`in F&&this.on(F,`visibilitychange`,this.toggleVisibility_)}toggleVisibility_(e){F.visibilityState===`hidden`?(this.cancelNamedAnimationFrame(`SeekBar#update`),this.cancelNamedAnimationFrame(`Slider#update`),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||=this.setInterval(this.update,30)}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!==`ended`||(this.updateInterval&&=(this.clearInterval(this.updateInterval),null))}createEl(){return super.createEl(`div`,{className:`vjs-progress-holder`},{"aria-label":this.localize(`Progress Bar`)})}update(e){if(F.visibilityState===`hidden`)return;let t=super.update();return this.requestNamedAnimationFrame(`SeekBar#update`,()=>{let n=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),r=this.player_.liveTracker,i=this.player_.duration();r&&r.isLive()&&(i=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute(`aria-valuenow`,(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==n||this.duration_!==i)&&(this.el_.setAttribute(`aria-valuetext`,this.localize(`progress bar timing: currentTime={1} duration={2}`,[Ho(n,i),Ho(i,i)],`{1} of {2}`)),this.currentTime_=n,this.duration_=i),this.bar&&this.bar.update(ka(this.el()),this.getProgress(),e)}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}pendingSeekTime(e){if(e!==void 0){if(e!==null){let t=this.player_.duration();this.pendingSeekTime_=Math.max(0,Math.min(e,t))}else this.pendingSeekTime_=null}return this.pendingSeekTime_}getPercent(){if(this.pendingSeekTime()!==null)return this.pendingSeekTime()/this.player_.duration();let e=this.getCurrentTime_(),t,n=this.player_.liveTracker;return n&&n.isLive()?(t=(e-n.seekableStart())/n.liveWindow(),n.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){La(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbing_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!La(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let n,r=this.calculateDistance(e),i=this.player_.liveTracker;if(!i||!i.isLive())n=r*this.player_.duration(),n===this.player_.duration()&&(n-=.1);else{if(r>=.99){i.seekToLiveEdge();return}let e=i.seekableStart(),t=i.liveCurrentTime();if(n=e+r*i.liveWindow(),n>=t&&(n=t),n<=e&&(n=e+.1),n===1/0)return}this.shouldDisableSeekWhileScrubbing_?this.pendingSeekTime(n):this.userSeek_(n),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();let e=this.getChild(`mouseTimeDisplay`);e&&e.show()}disable(){super.disable();let e=this.getChild(`mouseTimeDisplay`);e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.trigger({type:`timeupdate`,target:this,manuallyTriggered:!0}),this.videoWasPlaying?qo(this.player_.play()):this.update_()}handlePendingSeek_(e){this.player_.paused()||this.player_.pause();let t=this.pendingSeekTime()===null?this.player_.currentTime():this.pendingSeekTime();this.pendingSeekTime(t+e),this.player_.trigger({type:`timeupdate`,target:this,manuallyTriggered:!0})}stepForward(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(this.options().stepSeconds):this.userSeek_(this.player_.currentTime()+this.options().stepSeconds)}stepBack(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(-this.options().stepSeconds):this.userSeek_(this.player_.currentTime()-this.options().stepSeconds)}handleAction(e){this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){let t=this.player_.liveTracker;if(e.key===` `||e.key===`Enter`)e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key===`Home`)e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key===`End`)e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();let n=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*n):this.userSeek_(this.player_.duration()*n)}else e.key===`PageDown`?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-this.options().stepSeconds*this.options().pageMultiplier)):e.key===`PageUp`?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+this.options().stepSeconds*this.options().pageMultiplier)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,[`durationchange`,`timeupdate`],this.update),this.off(this.player_,[`ended`],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,`liveedgechange`,this.update),this.off(this.player_,[`playing`],this.enableIntervalHandler_),this.off(this.player_,[`ended`,`pause`,`waiting`],this.disableIntervalHandler_),`hidden`in F&&`visibilityState`in F&&this.off(F,`visibilitychange`,this.toggleVisibility_),super.dispose()}}Oc.prototype.options_={children:[`loadProgressBar`,`playProgressBar`],barName:`playProgressBar`,stepSeconds:5,pageMultiplier:12},q.registerComponent(`SeekBar`,Oc);class kc extends q{constructor(e,t){super(e,t),this.handleMouseMove=fo(K(this,this.handleMouseMove),30),this.throttledHandleMouseSeek=fo(K(this,this.handleMouseSeek),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.handleMouseDownHandler_=e=>this.handleMouseDown(e),this.enable()}createEl(){return super.createEl(`div`,{className:`vjs-progress-control vjs-control`})}handleMouseMove(e){let t=this.getChild(`seekBar`);if(!t)return;let n=t.getChild(`playProgressBar`),r=t.getChild(`mouseTimeDisplay`);if(!n&&!r)return;let i=t.el(),a=Aa(i),o=ja(i,e).x;o=bc(o,0,1),r&&r.update(a,o),n&&n.update(a,t.getProgress())}handleMouseSeek(e){let t=this.getChild(`seekBar`);t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),this.enabled()&&(this.off([`mousedown`,`touchstart`],this.handleMouseDownHandler_),this.off(this.el_,[`mousemove`,`touchmove`],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass(`disabled`),this.enabled_=!1,this.player_.scrubbing())){let e=this.getChild(`seekBar`);this.player_.scrubbing(!1),e.videoWasPlaying&&qo(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),!this.enabled()&&(this.on([`mousedown`,`touchstart`],this.handleMouseDownHandler_),this.on(this.el_,[`mousemove`,`touchmove`],this.handleMouseMove),this.removeClass(`disabled`),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){let e=this.el_.ownerDocument;this.off(e,`mousemove`,this.throttledHandleMouseSeek),this.off(e,`touchmove`,this.throttledHandleMouseSeek),this.off(e,`mouseup`,this.handleMouseUpHandler_),this.off(e,`touchend`,this.handleMouseUpHandler_)}handleMouseDown(e){let t=this.el_.ownerDocument,n=this.getChild(`seekBar`);n&&n.handleMouseDown(e),this.on(t,`mousemove`,this.throttledHandleMouseSeek),this.on(t,`touchmove`,this.throttledHandleMouseSeek),this.on(t,`mouseup`,this.handleMouseUpHandler_),this.on(t,`touchend`,this.handleMouseUpHandler_)}handleMouseUp(e){let t=this.getChild(`seekBar`);t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}kc.prototype.options_={children:[`seekBar`]},q.registerComponent(`ProgressControl`,kc);class Ac extends lc{constructor(e,t){super(e,t),this.setIcon(`picture-in-picture-enter`),this.on(e,[`enterpictureinpicture`,`leavepictureinpicture`],e=>this.handlePictureInPictureChange(e)),this.on(e,[`disablepictureinpicturechanged`,`loadedmetadata`],e=>this.handlePictureInPictureEnabledChange(e)),this.on(e,[`loadedmetadata`,`audioonlymodechange`,`audiopostermodechange`],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){this.player_.currentType().substring(0,5)===`audio`||this.player_.audioPosterMode()||this.player_.audioOnlyMode()?(this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()):this.show()}handlePictureInPictureEnabledChange(){F.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&`documentPictureInPicture`in x?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon(`picture-in-picture-exit`),this.controlText(`Exit Picture-in-Picture`)):(this.setIcon(`picture-in-picture-enter`),this.controlText(`Picture-in-Picture`)),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof F.exitPictureInPicture==`function`&&super.show()}}Ac.prototype.controlText_=`Picture-in-Picture`,q.registerComponent(`PictureInPictureToggle`,Ac);class jc extends lc{constructor(e,t){super(e,t),this.setIcon(`fullscreen-enter`),this.on(e,`fullscreenchange`,e=>this.handleFullscreenChange(e)),F[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText(`Exit Fullscreen`),this.setIcon(`fullscreen-exit`)):(this.controlText(`Fullscreen`),this.setIcon(`fullscreen-enter`))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}jc.prototype.controlText_=`Fullscreen`,q.registerComponent(`FullscreenToggle`,jc);const Mc=function(e,t){t.tech_&&!t.tech_.featuresVolumeControl&&e.addClass(`vjs-hidden`),e.on(t,`loadstart`,function(){t.tech_.featuresVolumeControl?e.removeClass(`vjs-hidden`):e.addClass(`vjs-hidden`)})};class Nc extends q{createEl(){let e=super.createEl(`div`,{className:`vjs-volume-level`});return this.setIcon(`circle`,e),e.appendChild(super.createEl(`span`,{className:`vjs-control-text`})),e}}q.registerComponent(`VolumeLevel`,Nc);class Pc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-volume-tooltip`},{"aria-hidden":`true`})}update(e,t,n,r){if(!n){let n=ka(this.el_),r=ka(this.player_.el()),i=e.width*t;if(!r||!n)return;let a=e.left-r.left+i,o=e.width-i+(r.right-e.right),s=n.width/2;a<s?s+=s-a:o<s&&(s=o),s<0?s=0:s>n.width&&(s=n.width),this.el_.style.right=`-${s}px`}this.write(`${r}%`)}write(e){ga(this.el_,e)}updateVolume(e,t,n,r,i){this.requestNamedAnimationFrame(`VolumeLevelTooltip#updateVolume`,()=>{this.update(e,t,n,r.toFixed(0)),i&&i()})}}q.registerComponent(`VolumeLevelTooltip`,Pc);class Fc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-mouse-display`})}update(e,t,n){let r=100*t;this.getChild(`volumeLevelTooltip`).updateVolume(e,t,n,r,()=>{n?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}Fc.prototype.options_={children:[`volumeLevelTooltip`]},q.registerComponent(`MouseVolumeLevelDisplay`,Fc);class Ic extends Sc{constructor(e,t){super(e,t),this.on(`slideractive`,e=>this.updateLastVolume_(e)),this.on(e,`volumechange`,e=>this.updateARIAAttributes(e)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl(`div`,{className:`vjs-volume-bar vjs-slider-bar`},{"aria-label":this.localize(`Volume Level`),"aria-live":`polite`})}handleMouseDown(e){La(e)&&super.handleMouseDown(e)}handleMouseMove(e){let t=this.getChild(`mouseVolumeLevelDisplay`);if(t){let n=this.el(),r=ka(n),i=this.vertical(),a=ja(n,e);a=i?a.y:a.x,a=bc(a,0,1),t.update(r,a,i)}La(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){let t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute(`aria-valuenow`,t),this.el_.setAttribute(`aria-valuetext`,t+`%`)}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){let e=this.player_.volume();this.one(`sliderinactive`,()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}Ic.prototype.options_={children:[`volumeLevel`],barName:`volumeLevel`},!sa&&!Hi&&Ic.prototype.options_.children.splice(0,0,`mouseVolumeLevelDisplay`),Ic.prototype.playerEvent=`volumechange`,q.registerComponent(`VolumeBar`,Ic);class Lc extends q{constructor(e,t={}){t.vertical=t.vertical||!1,(t.volumeBar===void 0||Ii(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),Mc(this,e),this.throttledHandleMouseMove=fo(K(this,this.handleMouseMove),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.on(`mousedown`,e=>this.handleMouseDown(e)),this.on(`touchstart`,e=>this.handleMouseDown(e)),this.on(`mousemove`,e=>this.handleMouseMove(e)),this.on(this.volumeBar,[`focus`,`slideractive`],()=>{this.volumeBar.addClass(`vjs-slider-active`),this.addClass(`vjs-slider-active`),this.trigger(`slideractive`)}),this.on(this.volumeBar,[`blur`,`sliderinactive`],()=>{this.volumeBar.removeClass(`vjs-slider-active`),this.removeClass(`vjs-slider-active`),this.trigger(`sliderinactive`)})}createEl(){let e=`vjs-volume-horizontal`;return this.options_.vertical&&(e=`vjs-volume-vertical`),super.createEl(`div`,{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){let t=this.el_.ownerDocument;this.on(t,`mousemove`,this.throttledHandleMouseMove),this.on(t,`touchmove`,this.throttledHandleMouseMove),this.on(t,`mouseup`,this.handleMouseUpHandler_),this.on(t,`touchend`,this.handleMouseUpHandler_)}handleMouseUp(e){let t=this.el_.ownerDocument;this.off(t,`mousemove`,this.throttledHandleMouseMove),this.off(t,`touchmove`,this.throttledHandleMouseMove),this.off(t,`mouseup`,this.handleMouseUpHandler_),this.off(t,`touchend`,this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}Lc.prototype.options_={children:[`volumeBar`]},q.registerComponent(`VolumeControl`,Lc);const Rc=function(e,t){t.tech_&&!t.tech_.featuresMuteControl&&e.addClass(`vjs-hidden`),e.on(t,`loadstart`,function(){t.tech_.featuresMuteControl?e.removeClass(`vjs-hidden`):e.addClass(`vjs-hidden`)})};class zc extends lc{constructor(e,t){super(e,t),Rc(this,e),this.on(e,[`loadstart`,`volumechange`],e=>this.update(e))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){let t=this.player_.volume(),n=this.player_.lastVolume_();if(t===0){let e=n<.1?.1:n;this.player_.volume(e),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){let e=this.player_.volume(),t=3;this.setIcon(`volume-high`),sa&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon(`volume-mute`),t=0):e<.33?(this.setIcon(`volume-low`),t=1):e<.67&&(this.setIcon(`volume-medium`),t=2),ba(this.el_,[0,1,2,3].reduce((e,t)=>e+`${t?` `:``}vjs-vol-${t}`,``)),ya(this.el_,`vjs-vol-${t}`)}updateControlText_(){let e=this.player_.muted()||this.player_.volume()===0?`Unmute`:`Mute`;this.controlText()!==e&&this.controlText(e)}}zc.prototype.controlText_=`Mute`,q.registerComponent(`MuteToggle`,zc);class Bc extends q{constructor(e,t={}){t.inline=t.inline===void 0||t.inline,(t.volumeControl===void 0||Ii(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=e=>this.handleKeyPress(e),this.on(e,[`loadstart`],e=>this.volumePanelState_(e)),this.on(this.muteToggle,`keyup`,e=>this.handleKeyPress(e)),this.on(this.volumeControl,`keyup`,e=>this.handleVolumeControlKeyUp(e)),this.on(`keydown`,e=>this.handleKeyPress(e)),this.on(`mouseover`,e=>this.handleMouseOver(e)),this.on(`mouseout`,e=>this.handleMouseOut(e)),this.on(this.volumeControl,[`slideractive`],this.sliderActive_),this.on(this.volumeControl,[`sliderinactive`],this.sliderInactive_)}sliderActive_(){this.addClass(`vjs-slider-active`)}sliderInactive_(){this.removeClass(`vjs-slider-active`)}volumePanelState_(){this.volumeControl.hasClass(`vjs-hidden`)&&this.muteToggle.hasClass(`vjs-hidden`)&&this.addClass(`vjs-hidden`),this.volumeControl.hasClass(`vjs-hidden`)&&!this.muteToggle.hasClass(`vjs-hidden`)&&this.addClass(`vjs-mute-toggle-only`)}createEl(){let e=`vjs-volume-panel-horizontal`;return this.options_.inline||(e=`vjs-volume-panel-vertical`),super.createEl(`div`,{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key===`Escape`&&this.muteToggle.focus()}handleMouseOver(e){this.addClass(`vjs-hover`),ao(F,`keyup`,this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass(`vjs-hover`),oo(F,`keyup`,this.handleKeyPressHandler_)}handleKeyPress(e){e.key===`Escape`&&this.handleMouseOut()}}Bc.prototype.options_={children:[`muteToggle`,`volumeControl`]},q.registerComponent(`VolumePanel`,Bc);class Vc extends lc{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize(`Skip forward {1} seconds`,[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){let e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;let t=this.player_.currentTime(),n=this.player_.liveTracker,r=n&&n.isLive()?n.seekableEnd():this.player_.duration(),i;i=t+this.skipTime<=r?t+this.skipTime:r,this.player_.currentTime(i)}handleLanguagechange(){this.controlText(this.localize(`Skip forward {1} seconds`,[this.skipTime]))}}Vc.prototype.controlText_=`Skip Forward`,q.registerComponent(`SkipForward`,Vc);class Hc extends lc{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize(`Skip backward {1} seconds`,[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){let e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){let t=this.player_.currentTime(),n=this.player_.liveTracker,r=n&&n.isLive()&&n.seekableStart(),i;i=r&&t-this.skipTime<=r?r:t>=this.skipTime?t-this.skipTime:0,this.player_.currentTime(i)}handleLanguagechange(){this.controlText(this.localize(`Skip backward {1} seconds`,[this.skipTime]))}}Hc.prototype.controlText_=`Skip Backward`,q.registerComponent(`SkipBackward`,Hc);class Uc extends q{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on(`keydown`,e=>this.handleKeyDown(e)),this.boundHandleBlur_=e=>this.handleBlur(e),this.boundHandleTapClick_=e=>this.handleTapClick(e)}addEventListenerForItem(e){e instanceof q&&(this.on(e,`blur`,this.boundHandleBlur_),this.on(e,[`tap`,`click`],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof q&&(this.off(e,`blur`,this.boundHandleBlur_),this.off(e,[`tap`,`click`],this.boundHandleTapClick_))}removeChild(e){typeof e==`string`&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){let t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){let e=this.options_.contentElType||`ul`;this.contentEl_=G(e,{className:`vjs-menu-content`}),this.contentEl_.setAttribute(`role`,`menu`);let t=super.createEl(`div`,{append:this.contentEl_,className:`vjs-menu`});return t.appendChild(this.contentEl_),ao(t,`click`,function(e){e.preventDefault(),e.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){let t=e.relatedTarget||F.activeElement;if(!this.children().some(e=>e.el()===t)){let e=this.menuButton_;e&&e.buttonPressed_&&t!==e.el().firstChild&&e.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();let t=this.children();if(!Array.isArray(t))return;let n=t.filter(t=>t.el()===e.target)[0];if(!n)return;n.name()!==`CaptionSettingsMenuItem`&&this.menuButton_.focus()}}handleKeyDown(e){e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key===`ArrowRight`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){let t=this.children().slice();t.length&&t[0].hasClass(`vjs-menu-title`)&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}q.registerComponent(`Menu`,Uc);class Wc extends q{constructor(e,t={}){super(e,t),this.menuButton_=new lc(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute(`aria-haspopup`,`true`);let n=lc.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+` `+n,this.menuButton_.removeClass(`vjs-control`),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;let r=e=>this.handleClick(e);this.handleMenuKeyUp_=e=>this.handleMenuKeyUp(e),this.on(this.menuButton_,`tap`,r),this.on(this.menuButton_,`click`,r),this.on(this.menuButton_,`keydown`,e=>this.handleKeyDown(e)),this.on(this.menuButton_,`mouseenter`,()=>{this.addClass(`vjs-hover`),this.menu.show(),ao(F,`keyup`,this.handleMenuKeyUp_)}),this.on(`mouseleave`,e=>this.handleMouseLeave(e)),this.on(`keydown`,e=>this.handleSubmenuKeyDown(e))}update(){let e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute(`aria-expanded`,`false`),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute(`role`)):(this.show(),this.menu.contentEl_.setAttribute(`role`,`menu`))}createMenu(){let e=new Uc(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){let t=G(`li`,{className:`vjs-menu-title`,textContent:jo(this.options_.title),tabIndex:-1}),n=new q(this.player_,{el:t});e.addItem(n)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl(`div`,{className:this.buildWrapperCSSClass()},{})}setIcon(e){return super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e=`vjs-menu-button`;this.options_.inline===!0?e+=`-inline`:e+=`-popup`;let t=lc.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e=`vjs-menu-button`;return this.options_.inline===!0?e+=`-inline`:e+=`-popup`,`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass(`vjs-hover`),oo(F,`keyup`,this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key===`Escape`||e.key===`Tab`?(this.buttonPressed_&&this.unpressButton(),!e.key===`Tab`&&(e.preventDefault(),this.menuButton_.focus())):e.key!==`Up`&&(e.key!==`Down`||this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)||this.buttonPressed_||(e.preventDefault(),this.pressButton())}handleMenuKeyUp(e){(e.key===`Escape`||e.key===`Tab`)&&this.removeClass(`vjs-hover`)}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key===`Escape`||e.key===`Tab`)&&(this.buttonPressed_&&this.unpressButton(),!e.key===`Tab`&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute(`aria-expanded`,`true`),sa&&ma())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute(`aria-expanded`,`false`))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass(`vjs-disabled`),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass(`vjs-disabled`),this.menuButton_.enable()}}q.registerComponent(`MenuButton`,Wc);class Gc extends Wc{constructor(e,t){let n=t.tracks;super(e,t),this.items.length<=1&&this.hide(),n&&(this.updateHandler_=K(this,this.update),this.cleanupHandler_=K(this,this.cleanupTrackListeners_),n.addEventListener(`removetrack`,this.updateHandler_),n.addEventListener(`addtrack`,this.updateHandler_),n.addEventListener(`labelchange`,this.updateHandler_),this.player_.on(`ready`,this.updateHandler_),this.player_.on(`dispose`,this.cleanupHandler_))}cleanupTrackListeners_(){if(!this.updateHandler_)return;let e=this.options_.tracks;e&&(e.removeEventListener(`removetrack`,this.updateHandler_),e.removeEventListener(`addtrack`,this.updateHandler_),e.removeEventListener(`labelchange`,this.updateHandler_)),this.player_&&(this.player_.off(`ready`,this.updateHandler_),this.player_.off(`dispose`,this.cleanupHandler_)),this.updateHandler_=null,this.cleanupHandler_=null}dispose(){this.cleanupTrackListeners_(),super.dispose()}}q.registerComponent(`TrackButton`,Gc);class Kc extends $s{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute(`role`,`menuitemcheckbox`):this.el_.setAttribute(`role`,`menuitemradio`):this.el_.setAttribute(`role`,`menuitem`)}createEl(e,t,n){this.nonIconControl=!0;let r=super.createEl(`li`,Object.assign({className:`vjs-menu-item`,tabIndex:-1},t),n),i=G(`span`,{className:`vjs-menu-item-text`,textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?r.appendChild(i):r.replaceChild(i,r.querySelector(`.vjs-icon-placeholder`)),r}handleKeyDown(e){[`Tab`,`Escape`,`ArrowUp`,`ArrowLeft`,`ArrowRight`,`ArrowDown`].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass(`vjs-selected`),this.el_.setAttribute(`aria-checked`,`true`),this.controlText(`, selected`),this.isSelected_=!0):(this.removeClass(`vjs-selected`),this.el_.setAttribute(`aria-checked`,`false`),this.controlText(``),this.isSelected_=!1))}}q.registerComponent(`MenuItem`,Kc);class qc extends Kc{constructor(e,t){let n=t.track,r=e.textTracks();t.label=n.label||n.language||`Unknown`,t.selected=n.mode===`showing`,super(e,t),this.track=n,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);let i=(...e)=>{this.handleTracksChange.apply(this,e)},a=(...e)=>{this.handleSelectedLanguageChange.apply(this,e)};if(e.on([`loadstart`,`texttrackchange`],i),r.addEventListener(`change`,i),r.addEventListener(`selectedlanguagechange`,a),this.on(`dispose`,function(){e.off([`loadstart`,`texttrackchange`],i),r.removeEventListener(`change`,i),r.removeEventListener(`selectedlanguagechange`,a)}),r.onchange===void 0){let e;this.on([`tap`,`click`],function(){if(typeof x.Event!=`object`)try{e=new x.Event(`change`)}catch{}e||(e=F.createEvent(`Event`),e.initEvent(`change`,!0,!0)),r.dispatchEvent(e)})}this.handleTracksChange()}handleClick(e){let t=this.track,n=this.player_.textTracks();if(super.handleClick(e),n)for(let e=0;e<n.length;e++){let r=n[e];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!==`showing`&&(r.mode=`showing`):r.mode!==`disabled`&&(r.mode=`disabled`))}}handleTracksChange(e){let t=this.track.mode===`showing`;t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode===`showing`){let e=this.player_.cache_.selectedLanguage;if(e&&e.enabled&&e.language===this.track.language&&e.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}q.registerComponent(`TextTrackMenuItem`,qc);class Jc extends qc{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:`disabled`},t.kinds||=[t.kind],t.label?t.track.label=t.label:t.track.label=t.kinds.join(` and `)+` off`,t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){let t=this.player().textTracks(),n=!0;for(let e=0,r=t.length;e<r;e++){let r=t[e];if(this.options_.kinds.indexOf(r.kind)>-1&&r.mode===`showing`){n=!1;break}}n!==this.isSelected_&&this.selected(n)}handleSelectedLanguageChange(e){let t=this.player().textTracks(),n=!0;for(let e=0,r=t.length;e<r;e++){let r=t[e];if([`captions`,`descriptions`,`subtitles`].indexOf(r.kind)>-1&&r.mode===`showing`){n=!1;break}}n&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(`.vjs-menu-item-text`).textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}q.registerComponent(`OffTextTrackMenuItem`,Jc);class Yc extends Gc{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=qc){let n;this.label_&&(n=`${this.label_} off`),e.push(new Jc(this.player_,{kinds:this.kinds_,kind:this.kind_,label:n})),this.hideThreshold_+=1;let r=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let n=0;n<r.length;n++){let i=r[n];if(this.kinds_.indexOf(i.kind)>-1){let n=new t(this.player_,{track:i,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});n.addClass(`vjs-${i.kind}-menu-item`),e.push(n)}}return e}}q.registerComponent(`TextTrackButton`,Yc);class Xc extends Kc{constructor(e,t){let n=t.track,r=t.cue,i=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=r.text,t.selected=r.startTime<=i&&i<r.endTime,super(e,t),this.track=n,this.cue=r}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}q.registerComponent(`ChaptersTrackMenuItem`,Xc);class Zc extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`chapters`),this.selectCurrentItem_=()=>{this.items.forEach(e=>{e.selected(this.track_.activeCues[0]===e.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!==`chapters`)return;let t=this.findChaptersTrack();t===this.track_?(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update():(this.setTrack(t),super.update())}setTrack(e){if(this.track_!==e){if(this.updateHandler_||=this.update.bind(this),this.track_){let e=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);e&&e.removeEventListener(`load`,this.updateHandler_),this.track_.removeEventListener(`cuechange`,this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode=`hidden`;let e=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);e&&e.addEventListener(`load`,this.updateHandler_),this.track_.addEventListener(`cuechange`,this.selectCurrentItem_)}}}findChaptersTrack(){let e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===this.kind_)return n}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(jo(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){let e=[];if(!this.track_)return e;let t=this.track_.cues;if(!t)return e;for(let n=0,r=t.length;n<r;n++){let r=t[n],i=new Xc(this.player_,{track:this.track_,cue:r});e.push(i)}return e}}Zc.prototype.kind_=`chapters`,Zc.prototype.controlText_=`Chapters`,q.registerComponent(`ChaptersButton`,Zc);class Qc extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`audio-description`);let r=e.textTracks(),i=K(this,this.handleTracksChange);r.addEventListener(`change`,i),this.on(`dispose`,function(){r.removeEventListener(`change`,i)})}handleTracksChange(e){let t=this.player().textTracks(),n=!1;for(let e=0,r=t.length;e<r;e++){let r=t[e];if(r.kind!==this.kind_&&r.mode===`showing`){n=!0;break}}n?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}Qc.prototype.kind_=`descriptions`,Qc.prototype.controlText_=`Descriptions`,q.registerComponent(`DescriptionsButton`,Qc);class $c extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`subtitles`)}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}$c.prototype.kind_=`subtitles`,$c.prototype.controlText_=`Subtitles`,q.registerComponent(`SubtitlesButton`,$c);class el extends qc{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+` settings`,selectable:!1,default:!1,mode:`disabled`},t.selectable=!1,t.name=`CaptionSettingsMenuItem`,super(e,t),this.addClass(`vjs-texttrack-settings`),this.controlText(`, opens `+t.kind+` settings dialog`)}handleClick(e){this.player().getChild(`textTrackSettings`).open()}handleLanguagechange(){this.$(`.vjs-menu-item-text`).textContent=this.player_.localize(this.options_.kind+` settings`),super.handleLanguagechange()}}q.registerComponent(`CaptionSettingsMenuItem`,el);class tl extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`captions`)}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild(`textTrackSettings`)&&(e.push(new el(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}tl.prototype.kind_=`captions`,tl.prototype.controlText_=`Captions`,q.registerComponent(`CaptionsButton`,tl);class nl extends qc{createEl(e,t,n){let r=super.createEl(e,t,n),i=r.querySelector(`.vjs-menu-item-text`);return this.options_.track.kind===`captions`&&(this.player_.options_.experimentalSvgIcons?this.setIcon(`captions`,r):i.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),i.appendChild(G(`span`,{className:`vjs-control-text`,textContent:` ${this.localize(`Captions`)}`}))),r}}q.registerComponent(`SubsCapsMenuItem`,nl);class rl extends Yc{constructor(e,t={}){super(e,t),this.label_=`subtitles`,this.setIcon(`subtitles`),[`en`,`en-us`,`en-ca`,`fr-ca`].indexOf(this.player_.language_)>-1&&(this.label_=`captions`,this.setIcon(`captions`)),this.menuButton_.controlText(jo(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild(`textTrackSettings`)&&(e.push(new el(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,nl),e}}rl.prototype.kinds_=[`captions`,`subtitles`],rl.prototype.controlText_=`Subtitles`,q.registerComponent(`SubsCapsButton`,rl);class il extends Kc{constructor(e,t){let n=t.track,r=e.audioTracks();t.label=n.label||n.language||`Unknown`,t.selected=n.enabled,super(e,t),this.track=n,this.addClass(`vjs-${n.kind}-menu-item`);let i=(...e)=>{this.handleTracksChange.apply(this,e)};r.addEventListener(`change`,i),this.on(`dispose`,()=>{r.removeEventListener(`change`,i)})}createEl(e,t,n){let r=super.createEl(e,t,n),i=r.querySelector(`.vjs-menu-item-text`);return[`main-desc`,`descriptions`,`description`].indexOf(this.options_.track.kind)>=0&&(i.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),i.appendChild(G(`span`,{className:`vjs-control-text`,textContent:` `+this.localize(`Descriptions`)}))),r}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){let e=this.player_.audioTracks();for(let t=0;t<e.length;t++){let n=e[t];n!==this.track&&(n.enabled=n===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}q.registerComponent(`AudioTrackMenuItem`,il);class al extends Gc{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon(`audio`)}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;let t=this.player_.audioTracks();for(let n=0;n<t.length;n++){let r=t[n];e.push(new il(this.player_,{track:r,selectable:!0,multiSelectable:!1}))}return e}}al.prototype.controlText_=`Audio Track`,q.registerComponent(`AudioTrackButton`,al);class ol extends Kc{constructor(e,t){let n=t.rate,r=parseFloat(n,10);t.label=n,t.selected=r===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=n,this.rate=r,this.on(e,`ratechange`,e=>this.update(e))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ol.prototype.contentElType=`button`,q.registerComponent(`PlaybackRateMenuItem`,ol);class sl extends Wc{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute(`aria-describedby`,this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,`loadstart`,e=>this.updateVisibility(e)),this.on(e,`ratechange`,e=>this.updateLabel(e)),this.on(e,`playbackrateschange`,e=>this.handlePlaybackRateschange(e))}createEl(){let e=super.createEl();return this.labelElId_=`vjs-playback-rate-value-label-`+this.id_,this.labelEl_=G(`div`,{className:`vjs-playback-rate-value`,id:this.labelElId_,textContent:`1x`}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){let e=this.playbackRates(),t=[];for(let n=e.length-1;n>=0;n--)t.push(new ol(this.player(),{rate:e[n]+`x`}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){let e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass(`vjs-hidden`):this.addClass(`vjs-hidden`)}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+`x`)}}sl.prototype.controlText_=`Playback Rate`,q.registerComponent(`PlaybackRateMenuButton`,sl);class cl extends q{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e=`div`,t={},n={}){return t.className||=this.buildCSSClass(),super.createEl(e,t,n)}}q.registerComponent(`Spacer`,cl);class ll extends cl{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl(`div`,{className:this.buildCSSClass(),textContent:`\xA0`})}}q.registerComponent(`CustomControlSpacer`,ll);class ul extends q{createEl(){return super.createEl(`div`,{className:`vjs-control-bar`,dir:`ltr`})}}ul.prototype.options_={children:[`playToggle`,`skipBackward`,`skipForward`,`volumePanel`,`currentTimeDisplay`,`timeDivider`,`durationDisplay`,`progressControl`,`liveDisplay`,`seekToLive`,`remainingTimeDisplay`,`customControlSpacer`,`playbackRateMenuButton`,`chaptersButton`,`descriptionsButton`,`subsCapsButton`,`audioTrackButton`,`pictureInPictureToggle`,`fullscreenToggle`]},q.registerComponent(`ControlBar`,ul);class dl extends Zo{constructor(e,t){super(e,t),this.on(e,`error`,e=>{this.open(e)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){let e=this.player().error();return e?this.localize(e.message):``}}dl.prototype.options_=Object.assign({},Zo.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0}),q.registerComponent(`ErrorDisplay`,dl);class fl extends q{constructor(e,t={}){super(e,t),this.el_.setAttribute(`aria-labelledby`,this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(` `).trim(),G(`select`,{id:this.options_.id},{},this.options_.SelectOptions.map(e=>{let t=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${Qa()}`)+`-`+e[1].replace(/\W+/g,``),n=G(`option`,{id:t,value:this.localize(e[0]),textContent:this.localize(e[1])});return n.setAttribute(`aria-labelledby`,`${this.selectLabelledbyIds} ${t}`),n}))}}q.registerComponent(`TextTrackSelect`,fl);class pl extends q{constructor(e,t={}){super(e,t);let n=G(`legend`,{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(n);let r=this.options_.selects;for(let t of r){let n=this.options_.selectConfigs[t],r=n.className,i=n.id.replace(`%s`,this.options_.id_),a=null,o=`vjs_select_${Qa()}`;if(this.options_.type===`colors`){a=G(`span`,{className:r});let e=G(`label`,{id:i,className:`vjs-label`,textContent:this.localize(n.label)});e.setAttribute(`for`,o),a.appendChild(e)}let s=new fl(e,{SelectOptions:n.options,legendId:this.options_.legendId,id:o,labelId:i});this.addChild(s),this.options_.type===`colors`&&(a.appendChild(s.el()),this.el().appendChild(a))}}createEl(){return G(`fieldset`,{className:this.options_.className})}}q.registerComponent(`TextTrackFieldset`,pl);class ml extends q{constructor(e,t={}){super(e,t);let n=this.options_.textTrackComponentid,r=new pl(e,{id_:n,legendId:`captions-text-legend-${n}`,legendText:this.localize(`Text`),className:`vjs-fg vjs-track-setting`,selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:`colors`});this.addChild(r);let i=new pl(e,{id_:n,legendId:`captions-background-${n}`,legendText:this.localize(`Text Background`),className:`vjs-bg vjs-track-setting`,selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:`colors`});this.addChild(i);let a=new pl(e,{id_:n,legendId:`captions-window-${n}`,legendText:this.localize(`Caption Area Background`),className:`vjs-window vjs-track-setting`,selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:`colors`});this.addChild(a)}createEl(){return G(`div`,{className:`vjs-track-settings-colors`})}}q.registerComponent(`TextTrackSettingsColors`,ml);class hl extends q{constructor(e,t={}){super(e,t);let n=this.options_.textTrackComponentid,r=new pl(e,{id_:n,legendId:`captions-font-size-${n}`,legendText:`Font Size`,className:`vjs-font-percent vjs-track-setting`,selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:`font`});this.addChild(r);let i=new pl(e,{id_:n,legendId:`captions-edge-style-${n}`,legendText:this.localize(`Text Edge Style`),className:`vjs-edge-style vjs-track-setting`,selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:`font`});this.addChild(i);let a=new pl(e,{id_:n,legendId:`captions-font-family-${n}`,legendText:this.localize(`Font Family`),className:`vjs-font-family vjs-track-setting`,selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:`font`});this.addChild(a)}createEl(){return G(`div`,{className:`vjs-track-settings-font`})}}q.registerComponent(`TextTrackSettingsFont`,hl);class gl extends q{constructor(e,t={}){super(e,t);let n=new lc(e,{controlText:this.localize(`restore all settings to the default values`),className:`vjs-default-button`});n.el().classList.remove(`vjs-control`,`vjs-button`),n.el().textContent=this.localize(`Reset`),this.addChild(n);let r=this.localize(`Done`),i=new lc(e,{controlText:r,className:`vjs-done-button`});i.el().classList.remove(`vjs-control`,`vjs-button`),i.el().textContent=r,this.addChild(i)}createEl(){return G(`div`,{className:`vjs-track-settings-controls`})}}q.registerComponent(`TrackSettingsControls`,gl);const _l=`vjs-text-track-settings`,vl=[`#000`,`Black`],yl=[`#00F`,`Blue`],bl=[`#0FF`,`Cyan`],xl=[`#0F0`,`Green`],Sl=[`#F0F`,`Magenta`],Cl=[`#F00`,`Red`],wl=[`#FFF`,`White`],Tl=[`#FF0`,`Yellow`],El=[`1`,`Opaque`],Dl=[`0.5`,`Semi-Transparent`],Ol=[`0`,`Transparent`],kl={backgroundColor:{selector:`.vjs-bg-color > select`,id:`captions-background-color-%s`,label:`Color`,options:[vl,wl,Cl,xl,yl,Tl,Sl,bl],className:`vjs-bg-color`},backgroundOpacity:{selector:`.vjs-bg-opacity > select`,id:`captions-background-opacity-%s`,label:`Opacity`,options:[El,Dl,Ol],className:`vjs-bg-opacity vjs-opacity`},color:{selector:`.vjs-text-color > select`,id:`captions-foreground-color-%s`,label:`Color`,options:[wl,vl,Cl,xl,yl,Tl,Sl,bl],className:`vjs-text-color`},edgeStyle:{selector:`.vjs-edge-style > select`,id:``,label:`Text Edge Style`,options:[[`none`,`None`],[`raised`,`Raised`],[`depressed`,`Depressed`],[`uniform`,`Uniform`],[`dropshadow`,`Drop shadow`]]},fontFamily:{selector:`.vjs-font-family > select`,id:``,label:`Font Family`,options:[[`proportionalSansSerif`,`Proportional Sans-Serif`],[`monospaceSansSerif`,`Monospace Sans-Serif`],[`proportionalSerif`,`Proportional Serif`],[`monospaceSerif`,`Monospace Serif`],[`casual`,`Casual`],[`script`,`Script`],[`small-caps`,`Small Caps`]]},fontPercent:{selector:`.vjs-font-percent > select`,id:``,label:`Font Size`,options:[[`0.50`,`50%`],[`0.75`,`75%`],[`1.00`,`100%`],[`1.25`,`125%`],[`1.50`,`150%`],[`1.75`,`175%`],[`2.00`,`200%`],[`3.00`,`300%`],[`4.00`,`400%`]],default:2,parser:e=>e===`1.00`?null:Number(e)},textOpacity:{selector:`.vjs-text-opacity > select`,id:`captions-foreground-opacity-%s`,label:`Opacity`,options:[El,Dl],className:`vjs-text-opacity vjs-opacity`},windowColor:{selector:`.vjs-window-color > select`,id:`captions-window-color-%s`,label:`Color`,className:`vjs-window-color`},windowOpacity:{selector:`.vjs-window-opacity > select`,id:`captions-window-opacity-%s`,label:`Opacity`,options:[Ol,Dl,El],className:`vjs-window-opacity vjs-opacity`}};kl.windowColor.options=kl.backgroundColor.options;function Al(e,t){if(t&&(e=t(e)),e&&e!==`none`)return e}function jl(e,t){let n=e.options[e.options.selectedIndex].value;return Al(n,t)}function Ml(e,t,n){if(t){for(let r=0;r<e.options.length;r++)if(Al(e.options[r].value,n)===t){e.selectedIndex=r;break}}}class Nl extends Zo{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=G(`p`,{className:`vjs-control-text`,textContent:this.localize(`End of dialog window.`)}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){let t=new ml(e,{textTrackComponentid:this.id_,selectConfigs:kl,fieldSets:[[`color`,`textOpacity`],[`backgroundColor`,`backgroundOpacity`],[`windowColor`,`windowOpacity`]]});this.addChild(t);let n=new hl(e,{textTrackComponentid:this.id_,selectConfigs:kl,fieldSets:[[`fontPercent`],[`edgeStyle`],[`fontFamily`]]});this.addChild(n);let r=new gl(e);this.addChild(r)}bindFunctionsToSelectsAndButtons(){this.on(this.$(`.vjs-done-button`),[`click`,`tap`],()=>{this.saveSettings(),this.close()}),this.on(this.$(`.vjs-default-button`),[`click`,`tap`],()=>{this.setDefaults(),this.updateDisplay()}),Ni(kl,e=>{this.on(this.$(e.selector),`change`,this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize(`Caption Settings Dialog`)}description(){return this.localize(`Beginning of dialog window. Escape will cancel and close the window.`)}buildCSSClass(){return super.buildCSSClass()+` vjs-text-track-settings`}getValues(){return Pi(kl,(e,t,n)=>{let r=jl(this.$(t.selector),t.parser);return r!==void 0&&(e[n]=r),e},{})}setValues(e){Ni(kl,(t,n)=>{Ml(this.$(t.selector),e[n],t.parser)})}setDefaults(){Ni(kl,e=>{let t=e.hasOwnProperty(`default`)?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(x.localStorage.getItem(_l))}catch(e){U.warn(e)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;let e=this.getValues();try{Object.keys(e).length?x.localStorage.setItem(_l,JSON.stringify(e)):x.localStorage.removeItem(_l)}catch(e){U.warn(e)}}updateDisplay(){let e=this.player_.getChild(`textTrackDisplay`);e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}q.registerComponent(`TextTrackSettings`,Nl);class Pl extends q{constructor(e,t){let n=t.ResizeObserver||x.ResizeObserver;t.ResizeObserver===null&&(n=!1);let r=W({createEl:!n,reportTouchActivity:!1},t);super(e,r),this.ResizeObserver=t.ResizeObserver||x.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=po(()=>{this.resizeHandler()},100,!1,this),n?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;let e=this.debouncedHandler_,t=this.unloadListener_=function(){oo(this,`resize`,e),oo(this,`unload`,t),t=null};ao(this.el_.contentWindow,`unload`,t),ao(this.el_.contentWindow,`resize`,e)},this.one(`load`,this.loadListener_))}createEl(){return super.createEl(`iframe`,{className:`vjs-resize-manager`,tabIndex:-1,title:this.localize(`No content`)},{"aria-hidden":`true`})}resizeHandler(){this.player_&&this.player_.trigger&&this.player_.trigger(`playerresize`)}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off(`load`,this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}q.registerComponent(`ResizeManager`,Pl);const Fl={trackingThreshold:20,liveTolerance:15};class Il extends q{constructor(e,t){let n=W(Fl,t,{createEl:!1});super(e,n),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=e=>this.handlePlay(e),this.handleFirstTimeupdate_=e=>this.handleFirstTimeupdate(e),this.handleSeeked_=e=>this.handleSeeked(e),this.seekToLiveEdge_=e=>this.seekToLiveEdge(e),this.reset_(),this.on(this.player_,`durationchange`,e=>this.handleDurationchange(e)),this.on(this.player_,`canplay`,()=>this.toggleTracking())}trackLive_(){let e=this.player_.seekable();if(!e||!e.length)return;let t=Number(x.performance.now().toFixed(4)),n=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+n;let r=this.liveCurrentTime(),i=this.player_.currentTime(),a=this.player_.paused()||this.seekedBehindLive_||Math.abs(r-i)>this.options_.liveTolerance;this.timeupdateSeen_&&r!==1/0||(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger(`liveedgechange`))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass(`vjs-liveui`),this.startTracking()):(this.player_.removeClass(`vjs-liveui`),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||=this.player_.hasStarted(),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,30),this.trackLive_(),this.on(this.player_,[`play`,`pause`],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,`seeked`,this.handleSeeked_):(this.one(this.player_,`play`,this.handlePlay_),this.one(this.player_,`timeupdate`,this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,`seeked`,this.handleSeeked_)}handleSeeked(){let e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,`timeupdate`,this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,[`play`,`pause`],this.trackLiveHandler_),this.off(this.player_,`seeked`,this.handleSeeked_),this.off(this.player_,`play`,this.handlePlay_),this.off(this.player_,`timeupdate`,this.handleFirstTimeupdate_),this.off(this.player_,`timeupdate`,this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger(`liveedgechange`))}seekableEnd(){let e=this.player_.seekable(),t=[],n=e?e.length:0;for(;n--;)t.push(e.end(n));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){let e=this.player_.seekable(),t=[],n=e?e.length:0;for(;n--;)t.push(e.start(n));return t.length?t.sort()[0]:0}liveWindow(){let e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){let e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_==`number`}seekToLiveEdge(){this.seekedBehindLive_=!1,!this.atLiveEdge()&&(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}q.registerComponent(`LiveTracker`,Il);class Ll extends q{constructor(e,t){super(e,t),this.on(`statechanged`,e=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:G(`div`,{className:`vjs-title-bar-title`,id:`vjs-title-bar-title-${Qa()}`}),description:G(`div`,{className:`vjs-title-bar-description`,id:`vjs-title-bar-description-${Qa()}`})},G(`div`,{className:`vjs-title-bar`},{},Li(this.els))}updateDom_(){let e=this.player_.tech_,t=e&&e.el_,n={title:`aria-labelledby`,description:`aria-describedby`};[`title`,`description`].forEach(e=>{let r=this.state[e],i=this.els[e],a=n[e];Na(i),r&&ga(i,r),t&&(t.removeAttribute(a),r&&t.setAttribute(a,i.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){let e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute(`aria-labelledby`),t.removeAttribute(`aria-describedby`)),super.dispose(),this.els=null}}q.registerComponent(`TitleBar`,Ll);const Rl={initialDisplay:4e3,position:[],takeFocus:!1};class zl extends lc{constructor(e,t){t=W(Rl,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,[`useractive`,`userinactive`],e=>{this.removeClass(`force-display`)})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(` `)}`}createEl(){let e=G(`button`,{},{type:`button`,class:this.buildCSSClass()},G(`span`));return this.controlTextEl_=e.querySelector(`span`),e}show(){super.show(),this.addClass(`force-display`),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass(`force-display`)},this.options_.initialDisplay)}hide(){this.removeClass(`force-display`),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}q.registerComponent(`TransientButton`,zl);const Bl=e=>{let t=e.el();if(t.hasAttribute(`src`))return e.triggerSourceset(t.src),!0;let n=e.$$(`source`),r=[],i=``;if(!n.length)return!1;for(let e=0;e<n.length;e++){let t=n[e].src;t&&r.indexOf(t)===-1&&r.push(t)}return r.length?(r.length===1&&(i=r[0]),e.triggerSourceset(i),!0):!1},Vl=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(e){let t=F.createElement(this.nodeName.toLowerCase());t.innerHTML=e;let n=F.createDocumentFragment();for(;t.childNodes.length;)n.appendChild(t.childNodes[0]);return this.innerText=``,x.Element.prototype.appendChild.call(this,n),this.innerHTML}}),Hl=(e,t)=>{let n={};for(let r=0;r<e.length&&(n=Object.getOwnPropertyDescriptor(e[r],t),!(n&&n.set&&n.get));r++);return n.enumerable=!0,n.configurable=!0,n},Ul=e=>Hl([e.el(),x.HTMLMediaElement.prototype,x.Element.prototype,Vl],`innerHTML`),Wl=function(e){let t=e.el();if(t.resetSourceWatch_)return;let n={},r=Ul(e),i=n=>(...r)=>{let i=n.apply(t,r);return Bl(e),i};[`append`,`appendChild`,`insertAdjacentHTML`].forEach(e=>{t[e]&&(n[e]=t[e],t[e]=i(n[e]))}),Object.defineProperty(t,"innerHTML",W(r,{set:i(r.set)})),t.resetSourceWatch_=()=>{t.resetSourceWatch_=null,Object.keys(n).forEach(e=>{t[e]=n[e]}),Object.defineProperty(t,"innerHTML",r)},e.one(`sourceset`,t.resetSourceWatch_)},Gl=Object.defineProperty({},"src",{get(){return this.hasAttribute(`src`)?fs(x.Element.prototype.getAttribute.call(this,`src`)):``},set(e){return x.Element.prototype.setAttribute.call(this,`src`,e),e}}),Kl=e=>Hl([e.el(),x.HTMLMediaElement.prototype,Gl],`src`),ql=function(e){if(!e.featuresSourceset)return;let t=e.el();if(t.resetSourceset_)return;let n=Kl(e),r=t.setAttribute,i=t.load;Object.defineProperty(t,"src",W(n,{set:r=>{let i=n.set.call(t,r);return e.triggerSourceset(t.src),i}})),t.setAttribute=(n,i)=>{let a=r.call(t,n,i);return/src/i.test(n)&&e.triggerSourceset(t.src),a},t.load=()=>{let n=i.call(t);return Bl(e)||(e.triggerSourceset(``),Wl(e)),n},t.currentSrc?e.triggerSourceset(t.currentSrc):Bl(e)||Wl(e),t.resetSourceset_=()=>{t.resetSourceset_=null,t.load=i,t.setAttribute=r,Object.defineProperty(t,"src",n),t.resetSourceWatch_&&t.resetSourceWatch_()}};class Y extends J{constructor(e,t){super(e,t);let n=e.source,r=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName===`VIDEO`,n&&(this.el_.currentSrc!==n.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(n):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){let e=this.el_.childNodes,t=e.length,n=[];for(;t--;){let i=e[t];i.nodeName.toLowerCase()===`track`&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),this.textTracks().addTrack(i.track),!r&&!this.el_.hasAttribute(`crossorigin`)&&ms(i.src)&&(r=!0)):n.push(i))}for(let e=0;e<n.length;e++)this.el_.removeChild(n[e])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&r&&U.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
160
+ </svg>`;const Ys=na?10009:ra?461:8,Xs={codes:{play:415,pause:19,ff:417,rw:412,back:Ys},names:{415:`play`,19:`pause`,417:`ff`,412:`rw`,[Ys]:`back`},isEventKey(e,t){return t=t.toLowerCase(),!!(this.names[e.keyCode]&&this.names[e.keyCode]===t)},getEventName(e){if(this.names[e.keyCode])return this.names[e.keyCode];if(this.codes[e.code]){let t=this.codes[e.code];return this.names[t]}return null}};class Zs extends go{constructor(e){super(),this.player_=e,this.focusableComponents=[],this.isListening_=!1,this.isPaused_=!1,this.onKeyDown_=this.onKeyDown_.bind(this),this.lastFocusedComponent_=null}start(){this.isListening_||(this.player_.on(`keydown`,this.onKeyDown_),this.player_.on(`modalKeydown`,this.onKeyDown_),this.player_.on(`loadedmetadata`,()=>{this.focus(this.updateFocusableComponents()[0])}),this.player_.on(`modalclose`,()=>{this.refocusComponent()}),this.player_.on(`focusin`,this.handlePlayerFocus_.bind(this)),this.player_.on(`focusout`,this.handlePlayerBlur_.bind(this)),this.isListening_=!0,this.player_.errorDisplay&&this.player_.errorDisplay.on(`aftermodalfill`,()=>{this.updateFocusableComponents(),this.focusableComponents.length&&(this.focusableComponents.length>1?this.focusableComponents[1].focus():this.focusableComponents[0].focus())}))}stop(){this.player_.off(`keydown`,this.onKeyDown_),this.isListening_=!1}onKeyDown_(e){let t=e.originalEvent?e.originalEvent:e;if([`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`].includes(t.key)){if(this.isPaused_)return;t.preventDefault();let e=t.key.substring(5).toLowerCase();this.move(e)}else if(Xs.isEventKey(t,`play`)||Xs.isEventKey(t,`pause`)||Xs.isEventKey(t,`ff`)||Xs.isEventKey(t,`rw`)){t.preventDefault();let e=Xs.getEventName(t);this.performMediaAction_(e)}else Xs.isEventKey(t,`Back`)&&e.target&&typeof e.target.closeable==`function`&&e.target.closeable()&&(t.preventDefault(),e.target.close())}performMediaAction_(e){if(this.player_)switch(e){case`play`:this.player_.paused()&&this.player_.play();break;case`pause`:this.player_.paused()||this.player_.pause();break;case`ff`:this.userSeek_(this.player_.currentTime()+5);break;case`rw`:this.userSeek_(this.player_.currentTime()-5)}}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}pause(){this.isPaused_=!0}resume(){this.isPaused_=!1}handlePlayerBlur_(e){let t=e.relatedTarget,n=null,r=this.getCurrentComponent(e.target);t&&(n=!!t.closest(`.video-js`),t.classList.contains(`vjs-text-track-settings`)&&!this.isPaused_&&this.searchForTrackSelect_()),(e.currentTarget.contains(e.relatedTarget)||n)&&t||(r&&r.name()===`CloseButton`?this.refocusComponent():(this.pause(),r&&r.el()&&(this.lastFocusedComponent_=r)))}handlePlayerFocus_(){this.getCurrentComponent()&&this.getCurrentComponent().getIsFocusable()&&this.resume()}updateFocusableComponents(){let e=this.player_,t=[];function n(e){for(let r of e)r.hasOwnProperty(`el_`)&&r.getIsFocusable()&&r.getIsAvailableToBeFocused(r.el())&&t.push(r),r.hasOwnProperty(`children_`)&&r.children_.length>0&&n(r.children_)}return e.children_.forEach(e=>{if(e.hasOwnProperty(`el_`)){if(e.getIsFocusable&&e.getIsAvailableToBeFocused&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())){t.push(e);return}e.hasOwnProperty(`children_`)&&e.children_.length>0?n(e.children_):e.hasOwnProperty(`items`)&&e.items.length>0?n(e.items):this.findSuitableDOMChild(e)&&t.push(e)}if(e.name_===`ErrorDisplay`&&e.opened_){let n=e.el_.querySelector(`.vjs-errors-ok-button-container`);n&&n.querySelectorAll(`button`).forEach((e,n)=>{t.push({name:()=>`ModalButton`+(n+1),el:()=>e,getPositions:()=>{let t=e.getBoundingClientRect();return{boundingClientRect:{x:t.x,y:t.y,width:t.width,height:t.height,top:t.top,right:t.right,bottom:t.bottom,left:t.left},center:{x:t.left+t.width/2,y:t.top+t.height/2,width:0,height:0,top:t.top+t.height/2,right:t.left+t.width/2,bottom:t.top+t.height/2,left:t.left+t.width/2}}},getIsAvailableToBeFocused:()=>!0,getIsFocusable:e=>!0,focus:()=>e.focus()})})}}),this.focusableComponents=t,this.focusableComponents}findSuitableDOMChild(e){function t(n){if(e.getIsFocusable(n)&&e.getIsAvailableToBeFocused(n))return n;for(let e=0;e<n.children.length;e++){let r=n.children[e],i=t(r);if(i)return i}return null}return e.el()?t(e.el()):null}getCurrentComponent(e){this.updateFocusableComponents();let t=e||document.activeElement;if(this.focusableComponents.length){for(let e of this.focusableComponents)if(e.el()===t)return e}}add(e){let t=[...this.focusableComponents];e.hasOwnProperty(`el_`)&&e.getIsFocusable()&&e.getIsAvailableToBeFocused(e.el())&&t.push(e),this.focusableComponents=t,this.trigger({type:`focusableComponentsChanged`,focusableComponents:this.focusableComponents})}remove(e){for(let t=0;t<this.focusableComponents.length;t++)if(this.focusableComponents[t].name()===e.name()){this.focusableComponents.splice(t,1),this.trigger({type:`focusableComponentsChanged`,focusableComponents:this.focusableComponents});return}}clear(){this.focusableComponents.length>0&&(this.focusableComponents=[],this.trigger({type:`focusableComponentsChanged`,focusableComponents:this.focusableComponents}))}move(e){let t=this.getCurrentComponent();if(!t)return;let n=t.getPositions(),r=this.focusableComponents.filter(r=>r!==t&&this.isInDirection_(n.boundingClientRect,r.getPositions().boundingClientRect,e)),i=this.findBestCandidate_(n.center,r,e);i?this.focus(i):this.trigger({type:`endOfFocusableComponents`,direction:e,focusedComponent:t})}findBestCandidate_(e,t,n){let r=1/0,i=null;for(let a of t){let t=a.getPositions().center,o=this.calculateDistance_(e,t,n);o<r&&(r=o,i=a)}return i}isInDirection_(e,t,n){switch(n){case`right`:return t.left>=e.right;case`left`:return t.right<=e.left;case`down`:return t.top>=e.bottom;case`up`:return t.bottom<=e.top;default:return!1}}refocusComponent(){if(this.lastFocusedComponent_){this.player_.userActive()||this.player_.userActive(!0),this.updateFocusableComponents();for(let e=0;e<this.focusableComponents.length;e++)if(this.focusableComponents[e].name()===this.lastFocusedComponent_.name()){this.focus(this.focusableComponents[e]);return}}else this.focus(this.updateFocusableComponents()[0])}focus(e){typeof e==`object`&&(e.getIsAvailableToBeFocused(e.el())?e.focus():this.findSuitableDOMChild(e)&&this.findSuitableDOMChild(e).focus())}calculateDistance_(e,t,n){let r=Math.abs(e.x-t.x),i=Math.abs(e.y-t.y),a;switch(n){case`right`:case`left`:a=r+i*100;break;case`up`:a=i*2+r*.5;break;case`down`:a=i*5+r;break;default:a=r+i}return a}searchForTrackSelect_(){let e=this;for(let t of e.updateFocusableComponents())if(t.constructor.name===`TextTrackSelect`){e.focus(t);break}}}class Qs extends q{constructor(e,t,n){let r=W({createEl:!1},t);if(super(e,r,n),!t.playerOptions.sources||t.playerOptions.sources.length===0)for(let n=0,r=t.playerOptions.techOrder;n<r.length;n++){let t=jo(r[n]),i=J.getTech(t);if(t||(i=q.getComponent(t)),i&&i.isSupported()){e.loadTech_(t);break}}else e.src(t.playerOptions.sources)}}q.registerComponent(`MediaLoader`,Qs);class $s extends q{constructor(e,t){super(e,t),this.options_.controlText&&this.controlText(this.options_.controlText),this.handleMouseOver_=e=>this.handleMouseOver(e),this.handleMouseOut_=e=>this.handleMouseOut(e),this.handleClick_=e=>this.handleClick(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.emitTapEvents(),this.enable()}createEl(e=`div`,t={},n={}){t=Object.assign({className:this.buildCSSClass(),tabIndex:0},t),e===`button`&&U.error(`Creating a ClickableComponent with an HTML element of ${e} is not supported; use a Button instead.`),n=Object.assign({role:`button`},n),this.tabIndex_=t.tabIndex;let r=G(e,t,n);return this.player_.options_.experimentalSvgIcons||r.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),this.createControlTextEl(r),r}dispose(){this.controlTextEl_=null,super.dispose()}createControlTextEl(e){return this.controlTextEl_=G(`span`,{className:`vjs-control-text`},{"aria-live":`polite`}),e&&e.appendChild(this.controlTextEl_),this.controlText(this.controlText_,e),this.controlTextEl_}controlText(e,t=this.el()){if(e===void 0)return this.controlText_||`Need Text`;let n=this.localize(e);this.controlText_=e,ga(this.controlTextEl_,n),!this.nonIconControl&&!this.player_.options_.noUITitleAttributes&&t.setAttribute(`title`,n)}buildCSSClass(){return`vjs-control vjs-button ${super.buildCSSClass()}`}enable(){this.enabled_||(this.enabled_=!0,this.removeClass(`vjs-disabled`),this.el_.setAttribute(`aria-disabled`,`false`),this.tabIndex_!==void 0&&this.el_.setAttribute(`tabIndex`,this.tabIndex_),this.on([`tap`,`click`],this.handleClick_),this.on(`keydown`,this.handleKeyDown_))}disable(){this.enabled_=!1,this.addClass(`vjs-disabled`),this.el_.setAttribute(`aria-disabled`,`true`),this.tabIndex_!==void 0&&this.el_.removeAttribute(`tabIndex`),this.off(`mouseover`,this.handleMouseOver_),this.off(`mouseout`,this.handleMouseOut_),this.off([`tap`,`click`],this.handleClick_),this.off(`keydown`,this.handleKeyDown_)}handleLanguagechange(){this.controlText(this.controlText_)}handleClick(e){this.options_.clickHandler&&this.options_.clickHandler.call(this,arguments)}handleKeyDown(e){e.key===` `||e.key===`Enter`?(e.preventDefault(),e.stopPropagation(),this.trigger(`click`)):super.handleKeyDown(e)}}q.registerComponent(`ClickableComponent`,$s);class ec extends $s{constructor(e,t){super(e,t);let{mainContent:n}=t&&t.playerOptions||{};this.isMainContent=n,this.update(),this.update_=e=>this.update(e),e.on(`posterchange`,this.update_)}dispose(){this.player().off(`posterchange`,this.update_),super.dispose()}createEl(){return G(`div`,{className:`vjs-poster`})}crossOrigin(e){if(e===void 0)return this.$(`img`)?this.$(`img`).crossOrigin:this.player_.tech_&&this.player_.tech_.isReady_?this.player_.crossOrigin():this.player_.options_.crossOrigin||this.player_.options_.crossorigin||null;e!==null&&e!==`anonymous`&&e!==`use-credentials`?this.player_.log.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`):this.$(`img`)&&(this.$(`img`).crossOrigin=e)}update(e){let t=this.player().poster();this.setSrc(t),t?this.show():this.hide()}setSrc(e){e?(this.$(`img`)||this.el_.appendChild(G(`picture`,{className:`vjs-poster`,tabIndex:-1},{},G(`img`,{loading:this.isMainContent?`eager`:`lazy`,fetchPriority:this.isMainContent?`high`:`auto`,crossOrigin:this.crossOrigin()},{alt:``}))),this.$(`img`).src=e):this.el_.textContent=``}handleClick(e){if(!this.player_.controls())return;let t=this.player_.getChild(`controlBar`),n=t&&t.getChild(`playToggle`);Gi?(n||this.player_).focus():this.player_.tech(!0)&&this.player_.tech(!0).focus(),this.player_.paused()?qo(this.player_.play()):this.player_.pause()}}ec.prototype.crossorigin=ec.prototype.crossOrigin,q.registerComponent(`PosterImage`,ec);const tc=`#222`,nc=`#ccc`,rc={monospace:`monospace`,sansSerif:`sans-serif`,serif:`serif`,monospaceSansSerif:`"Andale Mono", "Lucida Console", monospace`,monospaceSerif:`"Courier New", monospace`,proportionalSansSerif:`sans-serif`,proportionalSerif:`serif`,casual:`"Comic Sans MS", Impact, fantasy`,script:`"Monotype Corsiva", cursive`,smallcaps:`"Andale Mono", "Lucida Console", monospace, sans-serif`};function ic(e,t){let n;if(e.length===4)n=e[1]+e[1]+e[2]+e[2]+e[3]+e[3];else if(e.length===7)n=e.slice(1);else throw Error(`Invalid color code provided, `+e+`; must be formatted as e.g. #f0e or #f604e2.`);return`rgba(`+parseInt(n.slice(0,2),16)+`,`+parseInt(n.slice(2,4),16)+`,`+parseInt(n.slice(4,6),16)+`,`+t+`)`}function ac(e,t,n){try{e.style[t]=n}catch{return}}function oc(e){return e?`${e}px`:``}class sc extends q{constructor(e,t,n){super(e,t,n);let r=e=>this.updateDisplay(e),i=e=>{this.updateDisplayOverlay(),this.updateDisplay(e)};e.on(`loadstart`,e=>this.toggleDisplay(e)),e.on(`useractive`,r),e.on(`userinactive`,r),e.on(`texttrackchange`,r),e.on(`loadedmetadata`,e=>{this.updateDisplayOverlay(),this.preselectTrack(e)}),e.ready(K(this,function(){if(e.tech_&&e.tech_.featuresNativeTextTracks){this.hide();return}e.on(`fullscreenchange`,i),e.on(`playerresize`,i);let t=x.screen.orientation||x,n=x.screen.orientation?`change`:`orientationchange`;t.addEventListener(n,i),e.on(`dispose`,()=>t.removeEventListener(n,i));let r=this.options_.playerOptions.tracks||[];for(let e=0;e<r.length;e++)this.player_.addRemoteTextTrack(r[e],!0);this.preselectTrack()}))}preselectTrack(){let e={captions:1,subtitles:1},t=this.player_.textTracks(),n=this.player_.cache_.selectedLanguage,r,i,a;for(let o=0;o<t.length;o++){let s=t[o];n&&n.enabled&&n.language&&n.language===s.language&&s.kind in e?s.kind===n.kind?a=s:a||=s:n&&!n.enabled?(a=null,r=null,i=null):s.default&&(s.kind===`descriptions`&&!r?r=s:s.kind in e&&!i&&(i=s))}a?a.mode=`showing`:i?i.mode=`showing`:r&&(r.mode=`showing`)}toggleDisplay(){this.player_.tech_&&this.player_.tech_.featuresNativeTextTracks?this.hide():this.show()}createEl(){return super.createEl(`div`,{className:`vjs-text-track-display`},{translate:`yes`,"aria-live":`off`,"aria-atomic":`true`})}clearDisplay(){typeof x.WebVTT==`function`&&x.WebVTT.processCues(x,[],this.el_)}updateDisplay(){let e=this.player_.textTracks(),t=this.options_.allowMultipleShowingTracks;if(this.clearDisplay(),t){let t=[];for(let n=0;n<e.length;++n){let r=e[n];r.mode===`showing`&&t.push(r)}this.updateForTrack(t);return}let n=null,r=null,i=e.length;for(;i--;){let t=e[i];t.mode===`showing`&&(t.kind===`descriptions`?n=t:r=t)}if(r?(this.getAttribute(`aria-live`)!==`off`&&this.setAttribute(`aria-live`,`off`),this.updateForTrack(r)):n&&(this.getAttribute(`aria-live`)!==`assertive`&&this.setAttribute(`aria-live`,`assertive`),this.updateForTrack(n)),!(x.CSS!==void 0&&x.CSS.supports(`inset`,`10px`))){let e=this.el_,t=e.querySelectorAll(`.vjs-text-track-cue`),n=this.player_.controlBar.el_.getBoundingClientRect().height,r=this.player_.el_.getBoundingClientRect().height;e.style=``,ac(e,`position`,`relative`),ac(e,`height`,r-n+`px`),ac(e,`top`,`unset`),ia?ac(e,`bottom`,r+`px`):ac(e,`bottom`,`0px`),t.length>0&&t.forEach(e=>{if(e.style.inset){let t=e.style.inset.split(` `);t.length===3&&Object.assign(e.style,{top:t[0],right:t[1],bottom:t[2],left:`unset`})}})}}updateDisplayOverlay(){if(!this.player_.videoHeight()||!(x.CSS!==void 0&&x.CSS.supports(`inset-inline: 10px`)))return;let e=this.player_.currentWidth(),t=this.player_.currentHeight(),n=e/t,r=this.player_.videoWidth()/this.player_.videoHeight(),i=0,a=0;Math.abs(n-r)>.1&&(n>r?i=Math.round((e-t*r)/2):a=Math.round((t-e/r)/2)),ac(this.el_,`insetInline`,oc(i)),ac(this.el_,`insetBlock`,oc(a))}updateDisplayState(e){let t=this.player_.textTrackSettings.getValues(),n=e.activeCues,r=n.length;for(;r--;){let e=n[r];if(!e)continue;let i=e.displayState;if(t.color&&(i.firstChild.style.color=t.color),t.textOpacity&&ac(i.firstChild,`color`,ic(t.color||`#fff`,t.textOpacity)),t.backgroundColor&&(i.firstChild.style.backgroundColor=t.backgroundColor),t.backgroundOpacity&&ac(i.firstChild,`backgroundColor`,ic(t.backgroundColor||`#000`,t.backgroundOpacity)),t.windowColor&&(t.windowOpacity?ac(i,`backgroundColor`,ic(t.windowColor,t.windowOpacity)):i.style.backgroundColor=t.windowColor),t.edgeStyle&&(t.edgeStyle===`dropshadow`?i.firstChild.style.textShadow=`2px 2px 3px ${tc}, 2px 2px 4px ${tc}, 2px 2px 5px ${tc}`:t.edgeStyle===`raised`?i.firstChild.style.textShadow=`1px 1px ${tc}, 2px 2px ${tc}, 3px 3px ${tc}`:t.edgeStyle===`depressed`?i.firstChild.style.textShadow=`1px 1px ${nc}, 0 1px ${nc}, -1px -1px ${tc}, 0 -1px ${tc}`:t.edgeStyle===`uniform`&&(i.firstChild.style.textShadow=`0 0 4px ${tc}, 0 0 4px ${tc}, 0 0 4px ${tc}, 0 0 4px ${tc}`)),t.fontPercent&&t.fontPercent!==1){let e=x.parseFloat(i.style.fontSize);i.style.fontSize=e*t.fontPercent+`px`,i.style.height=`auto`,i.style.top=`auto`}t.fontFamily&&t.fontFamily!=="default"&&(t.fontFamily===`small-caps`?i.firstChild.style.fontVariant=`small-caps`:i.firstChild.style.fontFamily=rc[t.fontFamily])}}updateForTrack(e){if(Array.isArray(e)||(e=[e]),typeof x.WebVTT!=`function`||e.every(e=>!e.activeCues))return;let t=[];for(let n=0;n<e.length;++n){let r=e[n];for(let e=0;e<r.activeCues.length;++e)t.push(r.activeCues[e])}x.WebVTT.processCues(x,t,this.el_);for(let t=0;t<e.length;++t){let n=e[t];for(let e=0;e<n.activeCues.length;++e){let r=n.activeCues[e].displayState;ya(r,`vjs-text-track-cue`,`vjs-text-track-cue-`+(n.language?n.language:t)),n.language&&Ta(r,`lang`,n.language)}this.player_.textTrackSettings&&this.updateDisplayState(n)}}}q.registerComponent(`TextTrackDisplay`,sc);class cc extends q{createEl(){let e=this.player_.isAudio(),t=this.localize(e?`Audio Player`:`Video Player`),n=G(`span`,{className:`vjs-control-text`,textContent:this.localize(`{1} is loading.`,[t])}),r=super.createEl(`div`,{className:`vjs-loading-spinner`,dir:`ltr`});return r.appendChild(n),r}handleLanguagechange(){this.$(`.vjs-control-text`).textContent=this.localize(`{1} is loading.`,[this.player_.isAudio()?`Audio Player`:`Video Player`])}}q.registerComponent(`LoadingSpinner`,cc);class lc extends $s{createEl(e,t={},n={}){e=`button`,t=Object.assign({className:this.buildCSSClass()},t),n=Object.assign({type:`button`},n);let r=G(e,t,n);return this.player_.options_.experimentalSvgIcons||r.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),this.createControlTextEl(r),r}addChild(e,t={}){let n=this.constructor.name;return U.warn(`Adding an actionable (user controllable) child to a Button (${n}) is not supported; use a ClickableComponent instead.`),q.prototype.addChild.call(this,e,t)}enable(){super.enable(),this.el_.removeAttribute(`disabled`)}disable(){super.disable(),this.el_.setAttribute(`disabled`,`disabled`)}handleKeyDown(e){e.key===` `||e.key===`Enter`?e.stopPropagation():super.handleKeyDown(e)}}q.registerComponent(`Button`,lc);class uc extends lc{constructor(e,t){super(e,t),this.mouseused_=!1,this.setIcon(`play`),this.on(`mousedown`,e=>this.handleMouseDown(e))}buildCSSClass(){return`vjs-big-play-button`}handleClick(e){let t=this.player_.play(),n=this.player_.getChild(`controlBar`),r=n&&n.getChild(`playToggle`);if(e.type===`tap`||this.mouseused_&&`clientX`in e&&`clientY`in e){qo(t),Gi?(r||this.player_).focus():this.player_.tech(!0)&&this.player_.tech(!0).focus();return}if(!r){this.player_.tech(!0).focus();return}let i=()=>r.focus();Ko(t)?t.then(i,()=>{}):this.setTimeout(i,1)}handleKeyDown(e){this.mouseused_=!1,super.handleKeyDown(e)}handleMouseDown(e){this.mouseused_=!0}}uc.prototype.controlText_=`Play Video`,q.registerComponent(`BigPlayButton`,uc);class dc extends lc{constructor(e,t){super(e,t),this.setIcon(`cancel`),this.controlText(t&&t.controlText||this.localize(`Close`))}buildCSSClass(){return`vjs-close-button ${super.buildCSSClass()}`}handleClick(e){this.trigger({type:`close`,bubbles:!1})}handleKeyDown(e){e.key===`Escape`?(e.preventDefault(),e.stopPropagation(),this.trigger(`click`)):super.handleKeyDown(e)}}q.registerComponent(`CloseButton`,dc);class fc extends lc{constructor(e,t={}){super(e,t),t.replay=t.replay===void 0||t.replay,this.setIcon(`play`),this.on(e,`play`,e=>this.handlePlay(e)),this.on(e,`pause`,e=>this.handlePause(e)),t.replay&&this.on(e,`ended`,e=>this.handleEnded(e))}buildCSSClass(){return`vjs-play-control ${super.buildCSSClass()}`}handleClick(e){this.player_.paused()?qo(this.player_.play()):this.player_.pause()}handleSeeked(e){this.removeClass(`vjs-ended`),this.player_.paused()?this.handlePause(e):this.handlePlay(e)}handlePlay(e){this.removeClass(`vjs-ended`,`vjs-paused`),this.addClass(`vjs-playing`),this.setIcon(`pause`),this.controlText(`Pause`)}handlePause(e){this.removeClass(`vjs-playing`),this.addClass(`vjs-paused`),this.setIcon(`play`),this.controlText(`Play`)}handleEnded(e){this.removeClass(`vjs-playing`),this.addClass(`vjs-ended`),this.setIcon(`replay`),this.controlText(`Replay`),this.one(this.player_,`seeked`,e=>this.handleSeeked(e))}}fc.prototype.controlText_=`Play`,q.registerComponent(`PlayToggle`,fc);class pc extends q{constructor(e,t){super(e,t),this.on(e,[`timeupdate`,`ended`,`seeking`],e=>this.update(e)),this.updateTextNode_()}createEl(){let e=this.buildCSSClass(),t=super.createEl(`div`,{className:`${e} vjs-time-control vjs-control`}),n=G(`span`,{className:`vjs-control-text`,textContent:`${this.localize(this.labelText_)}\u00a0`},{role:`presentation`});return t.appendChild(n),this.contentEl_=G(`span`,{className:`${e}-display`},{role:`presentation`}),t.appendChild(this.contentEl_),t}dispose(){this.contentEl_=null,this.textNode_=null,super.dispose()}update(e){(this.player_.options_.enableSmoothSeeking||e.type!==`seeking`)&&this.updateContent(e)}updateTextNode_(e=0){e=Ho(e),this.formattedTime_!==e&&(this.formattedTime_=e,this.requestNamedAnimationFrame(`TimeDisplay#updateTextNode_`,()=>{if(!this.contentEl_)return;let e=this.textNode_;e&&this.contentEl_.firstChild!==e&&(e=null,U.warn(`TimeDisplay#updateTextnode_: Prevented replacement of text node element since it was no longer a child of this node. Appending a new node instead.`)),this.textNode_=F.createTextNode(this.formattedTime_),this.textNode_&&(e?this.contentEl_.replaceChild(this.textNode_,e):this.contentEl_.appendChild(this.textNode_))}))}updateContent(e){}}pc.prototype.labelText_=`Time`,pc.prototype.controlText_=`Time`,q.registerComponent(`TimeDisplay`,pc);class mc extends pc{buildCSSClass(){return`vjs-current-time`}updateContent(e){let t;t=this.player_.ended()?this.player_.duration():e&&e.target&&typeof e.target.pendingSeekTime==`function`&&e.target.pendingSeekTime()!==null?e.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime(),this.updateTextNode_(t)}}mc.prototype.labelText_=`Current Time`,mc.prototype.controlText_=`Current Time`,q.registerComponent(`CurrentTimeDisplay`,mc);class hc extends pc{constructor(e,t){super(e,t);let n=e=>this.updateContent(e);this.on(e,`durationchange`,n),this.on(e,`loadstart`,n),this.on(e,`loadedmetadata`,n)}buildCSSClass(){return`vjs-duration`}updateContent(e){let t=this.player_.duration();this.updateTextNode_(t)}}hc.prototype.labelText_=`Duration`,hc.prototype.controlText_=`Duration`,q.registerComponent(`DurationDisplay`,hc);class gc extends q{createEl(){let e=super.createEl(`div`,{className:`vjs-time-control vjs-time-divider`},{"aria-hidden":!0}),t=super.createEl(`div`),n=super.createEl(`span`,{textContent:`/`});return t.appendChild(n),e.appendChild(t),e}}q.registerComponent(`TimeDivider`,gc);class _c extends pc{constructor(e,t){super(e,t),this.on(e,`durationchange`,e=>this.updateContent(e))}buildCSSClass(){return`vjs-remaining-time`}createEl(){let e=super.createEl();return this.options_.displayNegative!==!1&&e.insertBefore(G(`span`,{},{"aria-hidden":!0},`-`),this.contentEl_),e}updateContent(e){if(typeof this.player_.duration()!=`number`)return;let t;t=this.player_.ended()?0:this.player_.remainingTimeDisplay?this.player_.remainingTimeDisplay():this.player_.remainingTime(),this.updateTextNode_(t)}}_c.prototype.labelText_=`Remaining Time`,_c.prototype.controlText_=`Remaining Time`,q.registerComponent(`RemainingTimeDisplay`,_c);class vc extends q{constructor(e,t){super(e,t),this.updateShowing(),this.on(this.player(),`durationchange`,e=>this.updateShowing(e))}createEl(){let e=super.createEl(`div`,{className:`vjs-live-control vjs-control`});return this.contentEl_=G(`div`,{className:`vjs-live-display`},{"aria-live":`off`}),this.contentEl_.appendChild(G(`span`,{className:`vjs-control-text`,textContent:`${this.localize(`Stream Type`)}\u00a0`})),this.contentEl_.appendChild(F.createTextNode(this.localize(`LIVE`))),e.appendChild(this.contentEl_),e}dispose(){this.contentEl_=null,super.dispose()}updateShowing(e){this.player().duration()===1/0?this.show():this.hide()}}q.registerComponent(`LiveDisplay`,vc);class yc extends lc{constructor(e,t){super(e,t),this.updateLiveEdgeStatus(),this.player_.liveTracker&&(this.updateLiveEdgeStatusHandler_=e=>this.updateLiveEdgeStatus(e),this.on(this.player_.liveTracker,`liveedgechange`,this.updateLiveEdgeStatusHandler_))}createEl(){let e=super.createEl(`button`,{className:`vjs-seek-to-live-control vjs-control`});return this.setIcon(`circle`,e),this.textEl_=G(`span`,{className:`vjs-seek-to-live-text`,textContent:this.localize(`LIVE`)},{"aria-hidden":`true`}),e.appendChild(this.textEl_),e}updateLiveEdgeStatus(){!this.player_.liveTracker||this.player_.liveTracker.atLiveEdge()?(this.setAttribute(`aria-disabled`,!0),this.addClass(`vjs-at-live-edge`),this.controlText(`Seek to live, currently playing live`)):(this.setAttribute(`aria-disabled`,!1),this.removeClass(`vjs-at-live-edge`),this.controlText(`Seek to live, currently behind live`))}handleClick(){this.player_.liveTracker.seekToLiveEdge()}dispose(){this.player_.liveTracker&&this.off(this.player_.liveTracker,`liveedgechange`,this.updateLiveEdgeStatusHandler_),this.textEl_=null,super.dispose()}}yc.prototype.controlText_=`Seek to live, currently playing live`,q.registerComponent(`SeekToLive`,yc);function bc(e,t,n){return e=Number(e),Math.min(n,Math.max(t,isNaN(e)?t:e))}var xc=Object.freeze({__proto__:null,clamp:bc});class Sc extends q{constructor(e,t){super(e,t),this.handleMouseDown_=e=>this.handleMouseDown(e),this.handleMouseUp_=e=>this.handleMouseUp(e),this.handleKeyDown_=e=>this.handleKeyDown(e),this.handleClick_=e=>this.handleClick(e),this.handleMouseMove_=e=>this.handleMouseMove(e),this.update_=e=>this.update(e),this.bar=this.getChild(this.options_.barName),this.vertical(!!this.options_.vertical),this.enable()}enabled(){return this.enabled_}enable(){this.enabled()||(this.on(`mousedown`,this.handleMouseDown_),this.on(`touchstart`,this.handleMouseDown_),this.on(`keydown`,this.handleKeyDown_),this.on(`click`,this.handleClick_),this.on(this.player_,`controlsvisible`,this.update),this.playerEvent&&this.on(this.player_,this.playerEvent,this.update),this.removeClass(`disabled`),this.setAttribute(`tabindex`,0),this.enabled_=!0)}disable(){if(!this.enabled())return;let e=this.bar.el_.ownerDocument;this.off(`mousedown`,this.handleMouseDown_),this.off(`touchstart`,this.handleMouseDown_),this.off(`keydown`,this.handleKeyDown_),this.off(`click`,this.handleClick_),this.off(this.player_,`controlsvisible`,this.update_),this.off(e,`mousemove`,this.handleMouseMove_),this.off(e,`mouseup`,this.handleMouseUp_),this.off(e,`touchmove`,this.handleMouseMove_),this.off(e,`touchend`,this.handleMouseUp_),this.removeAttribute(`tabindex`),this.addClass(`disabled`),this.playerEvent&&this.off(this.player_,this.playerEvent,this.update),this.enabled_=!1}createEl(e,t={},n={}){return t.className+=` vjs-slider`,t=Object.assign({tabIndex:0},t),n=Object.assign({role:`slider`,"aria-valuenow":0,"aria-valuemin":0,"aria-valuemax":100},n),super.createEl(e,t,n)}handleMouseDown(e){let t=this.bar.el_.ownerDocument;e.type===`mousedown`&&e.preventDefault(),e.type===`touchstart`&&!qi&&e.preventDefault(),Da(),this.addClass(`vjs-sliding`),this.trigger(`slideractive`),this.on(t,`mousemove`,this.handleMouseMove_),this.on(t,`mouseup`,this.handleMouseUp_),this.on(t,`touchmove`,this.handleMouseMove_),this.on(t,`touchend`,this.handleMouseUp_),this.handleMouseMove(e,!0)}handleMouseMove(e){}handleMouseUp(e){let t=this.bar.el_.ownerDocument;Oa(),this.removeClass(`vjs-sliding`),this.trigger(`sliderinactive`),this.off(t,`mousemove`,this.handleMouseMove_),this.off(t,`mouseup`,this.handleMouseUp_),this.off(t,`touchmove`,this.handleMouseMove_),this.off(t,`touchend`,this.handleMouseUp_),this.update()}update(){if(!this.el_||!this.bar)return;let e=this.getProgress();return e===this.progress_||(this.progress_=e,this.requestNamedAnimationFrame(`Slider#update`,()=>{let t=this.vertical()?`height`:`width`;this.bar.el().style[t]=(e*100).toFixed(2)+`%`})),e}getProgress(){return Number(bc(this.getPercent(),0,1).toFixed(4))}calculateDistance(e){let t=ja(this.el_,e);return this.vertical()?t.y:t.x}handleKeyDown(e){let t=this.options_.playerOptions.spatialNavigation,n=t&&t.enabled,r=t&&t.horizontalSeek;n?r&&e.key===`ArrowLeft`||!r&&e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),this.stepBack()):r&&e.key===`ArrowRight`||!r&&e.key===`ArrowUp`?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(this.pendingSeekTime()&&(this.pendingSeekTime(null),this.userSeek_(this.player_.currentTime())),super.handleKeyDown(e)):e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),this.stepBack()):e.key===`ArrowUp`||e.key===`ArrowRight`?(e.preventDefault(),e.stopPropagation(),this.stepForward()):super.handleKeyDown(e)}handleClick(e){e.stopPropagation(),e.preventDefault()}vertical(e){if(e===void 0)return this.vertical_||!1;this.vertical_=!!e,this.vertical_?this.addClass(`vjs-slider-vertical`):this.addClass(`vjs-slider-horizontal`)}}q.registerComponent(`Slider`,Sc);const Cc=(e,t)=>bc(e/t*100,0,100).toFixed(2)+`%`;class wc extends q{constructor(e,t){super(e,t),this.partEls_=[],this.on(e,`progress`,e=>this.update(e))}createEl(){let e=super.createEl(`div`,{className:`vjs-load-progress`}),t=G(`span`,{className:`vjs-control-text`}),n=G(`span`,{textContent:this.localize(`Loaded`)}),r=F.createTextNode(`: `);return this.percentageEl_=G(`span`,{className:`vjs-control-text-loaded-percentage`,textContent:`0%`}),e.appendChild(t),t.appendChild(n),t.appendChild(r),t.appendChild(this.percentageEl_),e}dispose(){this.partEls_=null,this.percentageEl_=null,super.dispose()}update(e){this.requestNamedAnimationFrame(`LoadProgressBar#update`,()=>{let e=this.player_.liveTracker,t=this.player_.buffered(),n=e&&e.isLive()?e.seekableEnd():this.player_.duration(),r=this.player_.bufferedEnd(),i=this.partEls_,a=Cc(r,n);this.percent_!==a&&(this.el_.style.width=a,ga(this.percentageEl_,a),this.percent_=a);for(let e=0;e<t.length;e++){let n=t.start(e),a=t.end(e),o=i[e];o||(o=this.el_.appendChild(G()),i[e]=o),(o.dataset.start!==n||o.dataset.end!==a)&&(o.dataset.start=n,o.dataset.end=a,o.style.left=Cc(n,r),o.style.width=Cc(a-n,r))}for(let e=i.length;e>t.length;e--)this.el_.removeChild(i[e-1]);i.length=t.length})}}q.registerComponent(`LoadProgressBar`,wc);class Tc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-time-tooltip`},{"aria-hidden":`true`})}update(e,t,n){let r=Aa(this.el_),i=ka(this.player_.el()),a=e.width*t;if(!i||!r)return;let o=e.left-i.left+a,s=e.width-a+(i.right-e.right);s||(s=e.width-a,o=a);let c=r.width/2;o<c?c+=c-o:s<c&&(c=s),c<0?c=0:c>r.width&&(c=r.width),c=Math.round(c),this.el_.style.right=`-${c}px`,this.write(n)}write(e){ga(this.el_,e)}updateTime(e,t,n,r){this.requestNamedAnimationFrame(`TimeTooltip#updateTime`,()=>{let i,a=this.player_.duration();if(this.player_.liveTracker&&this.player_.liveTracker.isLive()){let e=this.player_.liveTracker.liveWindow(),n=e-t*e;i=(n<1?``:`-`)+Ho(n,e)}else i=Ho(n,a);this.update(e,t,i),r&&r()})}}q.registerComponent(`TimeTooltip`,Tc);class Ec extends q{constructor(e,t){super(e,t),this.setIcon(`circle`),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-play-progress vjs-slider-bar`},{"aria-hidden":`true`})}update(e,t,n){let r=this.getChild(`timeTooltip`);if(!r)return;let i=n&&n.target&&typeof n.target.pendingSeekTime==`function`?n.target.pendingSeekTime():this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime();r.updateTime(e,t,i)}}Ec.prototype.options_={children:[]},!sa&&!Hi&&Ec.prototype.options_.children.push(`timeTooltip`),q.registerComponent(`PlayProgressBar`,Ec);class Dc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-mouse-display`})}update(e,t){let n=t*this.player_.duration();this.getChild(`timeTooltip`).updateTime(e,t,n,()=>{this.el_.style.left=`${e.width*t}px`})}}Dc.prototype.options_={children:[`timeTooltip`]},q.registerComponent(`MouseTimeDisplay`,Dc);class Oc extends Sc{constructor(e,t){t=W(Oc.prototype.options_,t),t.children=[...t.children];let n=e.options_.disableSeekWhileScrubbingOnMobile&&(sa||Hi)||e.options_.disableSeekWhileScrubbingOnSTV;(!sa&&!Hi||n)&&t.children.splice(1,0,`mouseTimeDisplay`),super(e,t),this.shouldDisableSeekWhileScrubbing_=n,this.pendingSeekTime_=null,this.setEventHandlers_()}setEventHandlers_(){this.update_=K(this,this.update),this.update=fo(this.update_,30),this.on(this.player_,[`durationchange`,`timeupdate`],this.update),this.on(this.player_,[`ended`],this.update_),this.player_.liveTracker&&this.on(this.player_.liveTracker,`liveedgechange`,this.update),this.updateInterval=null,this.enableIntervalHandler_=e=>this.enableInterval_(e),this.disableIntervalHandler_=e=>this.disableInterval_(e),this.on(this.player_,[`playing`],this.enableIntervalHandler_),this.on(this.player_,[`ended`,`pause`,`waiting`],this.disableIntervalHandler_),`hidden`in F&&`visibilityState`in F&&this.on(F,`visibilitychange`,this.toggleVisibility_)}toggleVisibility_(e){F.visibilityState===`hidden`?(this.cancelNamedAnimationFrame(`SeekBar#update`),this.cancelNamedAnimationFrame(`Slider#update`),this.disableInterval_(e)):(!this.player_.ended()&&!this.player_.paused()&&this.enableInterval_(),this.update())}enableInterval_(){this.updateInterval||=this.setInterval(this.update,30)}disableInterval_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&e&&e.type!==`ended`||(this.updateInterval&&=(this.clearInterval(this.updateInterval),null))}createEl(){return super.createEl(`div`,{className:`vjs-progress-holder`},{"aria-label":this.localize(`Progress Bar`)})}update(e){if(F.visibilityState===`hidden`)return;let t=super.update();return this.requestNamedAnimationFrame(`SeekBar#update`,()=>{let n=this.player_.ended()?this.player_.duration():this.getCurrentTime_(),r=this.player_.liveTracker,i=this.player_.duration();r&&r.isLive()&&(i=this.player_.liveTracker.liveCurrentTime()),this.percent_!==t&&(this.el_.setAttribute(`aria-valuenow`,(t*100).toFixed(2)),this.percent_=t),(this.currentTime_!==n||this.duration_!==i)&&(this.el_.setAttribute(`aria-valuetext`,this.localize(`progress bar timing: currentTime={1} duration={2}`,[Ho(n,i),Ho(i,i)],`{1} of {2}`)),this.currentTime_=n,this.duration_=i),this.bar&&this.bar.update(ka(this.el()),this.getProgress(),e)}),t}userSeek_(e){this.player_.liveTracker&&this.player_.liveTracker.isLive()&&this.player_.liveTracker.nextSeekedFromUser(),this.player_.currentTime(e)}getCurrentTime_(){return this.player_.scrubbing()?this.player_.getCache().currentTime:this.player_.currentTime()}pendingSeekTime(e){if(e!==void 0){if(e!==null){let t=this.player_.duration();this.pendingSeekTime_=Math.max(0,Math.min(e,t))}else this.pendingSeekTime_=null}return this.pendingSeekTime_}getPercent(){if(this.pendingSeekTime()!==null)return this.pendingSeekTime()/this.player_.duration();let e=this.getCurrentTime_(),t,n=this.player_.liveTracker;return n&&n.isLive()?(t=(e-n.seekableStart())/n.liveWindow(),n.atLiveEdge()&&(t=1)):t=e/this.player_.duration(),t}handleMouseDown(e){La(e)&&(e.stopPropagation(),this.videoWasPlaying=!this.player_.paused(),this.shouldDisableSeekWhileScrubbing_||this.player_.pause(),super.handleMouseDown(e))}handleMouseMove(e,t=!1){if(!La(e)||isNaN(this.player_.duration()))return;!t&&!this.player_.scrubbing()&&this.player_.scrubbing(!0);let n,r=this.calculateDistance(e),i=this.player_.liveTracker;if(!i||!i.isLive())n=r*this.player_.duration(),n===this.player_.duration()&&(n-=.1);else{if(r>=.99){i.seekToLiveEdge();return}let e=i.seekableStart(),t=i.liveCurrentTime();if(n=e+r*i.liveWindow(),n>=t&&(n=t),n<=e&&(n=e+.1),n===1/0)return}this.shouldDisableSeekWhileScrubbing_?this.pendingSeekTime(n):this.userSeek_(n),this.player_.options_.enableSmoothSeeking&&this.update()}enable(){super.enable();let e=this.getChild(`mouseTimeDisplay`);e&&e.show()}disable(){super.disable();let e=this.getChild(`mouseTimeDisplay`);e&&e.hide()}handleMouseUp(e){super.handleMouseUp(e),e&&e.stopPropagation(),this.player_.scrubbing(!1),this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.trigger({type:`timeupdate`,target:this,manuallyTriggered:!0}),this.videoWasPlaying?qo(this.player_.play()):this.update_()}handlePendingSeek_(e){this.player_.paused()||this.player_.pause();let t=this.pendingSeekTime()===null?this.player_.currentTime():this.pendingSeekTime();this.pendingSeekTime(t+e),this.player_.trigger({type:`timeupdate`,target:this,manuallyTriggered:!0})}stepForward(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(this.options().stepSeconds):this.userSeek_(this.player_.currentTime()+this.options().stepSeconds)}stepBack(){this.shouldDisableSeekWhileScrubbing_?this.handlePendingSeek_(-this.options().stepSeconds):this.userSeek_(this.player_.currentTime()-this.options().stepSeconds)}handleAction(e){this.pendingSeekTime()!==null&&(this.userSeek_(this.pendingSeekTime()),this.pendingSeekTime(null)),this.player_.paused()?this.player_.play():this.player_.pause()}handleKeyDown(e){let t=this.player_.liveTracker;if(e.key===` `||e.key===`Enter`)e.preventDefault(),e.stopPropagation(),this.handleAction(e);else if(e.key===`Home`)e.preventDefault(),e.stopPropagation(),this.userSeek_(0);else if(e.key===`End`)e.preventDefault(),e.stopPropagation(),t&&t.isLive()?this.userSeek_(t.liveCurrentTime()):this.userSeek_(this.player_.duration());else if(/^[0-9]$/.test(e.key)){e.preventDefault(),e.stopPropagation();let n=parseInt(e.key,10)*.1;t&&t.isLive()?this.userSeek_(t.seekableStart()+t.liveWindow()*n):this.userSeek_(this.player_.duration()*n)}else e.key===`PageDown`?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()-this.options().stepSeconds*this.options().pageMultiplier)):e.key===`PageUp`?(e.preventDefault(),e.stopPropagation(),this.userSeek_(this.player_.currentTime()+this.options().stepSeconds*this.options().pageMultiplier)):super.handleKeyDown(e)}dispose(){this.disableInterval_(),this.off(this.player_,[`durationchange`,`timeupdate`],this.update),this.off(this.player_,[`ended`],this.update_),this.player_.liveTracker&&this.off(this.player_.liveTracker,`liveedgechange`,this.update),this.off(this.player_,[`playing`],this.enableIntervalHandler_),this.off(this.player_,[`ended`,`pause`,`waiting`],this.disableIntervalHandler_),`hidden`in F&&`visibilityState`in F&&this.off(F,`visibilitychange`,this.toggleVisibility_),super.dispose()}}Oc.prototype.options_={children:[`loadProgressBar`,`playProgressBar`],barName:`playProgressBar`,stepSeconds:5,pageMultiplier:12},q.registerComponent(`SeekBar`,Oc);class kc extends q{constructor(e,t){super(e,t),this.handleMouseMove=fo(K(this,this.handleMouseMove),30),this.throttledHandleMouseSeek=fo(K(this,this.handleMouseSeek),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.handleMouseDownHandler_=e=>this.handleMouseDown(e),this.enable()}createEl(){return super.createEl(`div`,{className:`vjs-progress-control vjs-control`})}handleMouseMove(e){let t=this.getChild(`seekBar`);if(!t)return;let n=t.getChild(`playProgressBar`),r=t.getChild(`mouseTimeDisplay`);if(!n&&!r)return;let i=t.el(),a=Aa(i),o=ja(i,e).x;o=bc(o,0,1),r&&r.update(a,o),n&&n.update(a,t.getProgress())}handleMouseSeek(e){let t=this.getChild(`seekBar`);t&&t.handleMouseMove(e)}enabled(){return this.enabled_}disable(){if(this.children().forEach(e=>e.disable&&e.disable()),this.enabled()&&(this.off([`mousedown`,`touchstart`],this.handleMouseDownHandler_),this.off(this.el_,[`mousemove`,`touchmove`],this.handleMouseMove),this.removeListenersAddedOnMousedownAndTouchstart(),this.addClass(`disabled`),this.enabled_=!1,this.player_.scrubbing())){let e=this.getChild(`seekBar`);this.player_.scrubbing(!1),e.videoWasPlaying&&qo(this.player_.play())}}enable(){this.children().forEach(e=>e.enable&&e.enable()),this.enabled()||(this.on([`mousedown`,`touchstart`],this.handleMouseDownHandler_),this.on(this.el_,[`mousemove`,`touchmove`],this.handleMouseMove),this.removeClass(`disabled`),this.enabled_=!0)}removeListenersAddedOnMousedownAndTouchstart(){let e=this.el_.ownerDocument;this.off(e,`mousemove`,this.throttledHandleMouseSeek),this.off(e,`touchmove`,this.throttledHandleMouseSeek),this.off(e,`mouseup`,this.handleMouseUpHandler_),this.off(e,`touchend`,this.handleMouseUpHandler_)}handleMouseDown(e){let t=this.el_.ownerDocument,n=this.getChild(`seekBar`);n&&n.handleMouseDown(e),this.on(t,`mousemove`,this.throttledHandleMouseSeek),this.on(t,`touchmove`,this.throttledHandleMouseSeek),this.on(t,`mouseup`,this.handleMouseUpHandler_),this.on(t,`touchend`,this.handleMouseUpHandler_)}handleMouseUp(e){let t=this.getChild(`seekBar`);t&&t.handleMouseUp(e),this.removeListenersAddedOnMousedownAndTouchstart()}}kc.prototype.options_={children:[`seekBar`]},q.registerComponent(`ProgressControl`,kc);class Ac extends lc{constructor(e,t){super(e,t),this.setIcon(`picture-in-picture-enter`),this.on(e,[`enterpictureinpicture`,`leavepictureinpicture`],e=>this.handlePictureInPictureChange(e)),this.on(e,[`disablepictureinpicturechanged`,`loadedmetadata`],e=>this.handlePictureInPictureEnabledChange(e)),this.on(e,[`loadedmetadata`,`audioonlymodechange`,`audiopostermodechange`],()=>this.handlePictureInPictureAudioModeChange()),this.disable()}buildCSSClass(){return`vjs-picture-in-picture-control vjs-hidden ${super.buildCSSClass()}`}handlePictureInPictureAudioModeChange(){this.player_.currentType().substring(0,5)===`audio`||this.player_.audioPosterMode()||this.player_.audioOnlyMode()?(this.player_.isInPictureInPicture()&&this.player_.exitPictureInPicture(),this.hide()):this.show()}handlePictureInPictureEnabledChange(){F.pictureInPictureEnabled&&this.player_.disablePictureInPicture()===!1||this.player_.options_.enableDocumentPictureInPicture&&`documentPictureInPicture`in x?this.enable():this.disable()}handlePictureInPictureChange(e){this.player_.isInPictureInPicture()?(this.setIcon(`picture-in-picture-exit`),this.controlText(`Exit Picture-in-Picture`)):(this.setIcon(`picture-in-picture-enter`),this.controlText(`Picture-in-Picture`)),this.handlePictureInPictureEnabledChange()}handleClick(e){this.player_.isInPictureInPicture()?this.player_.exitPictureInPicture():this.player_.requestPictureInPicture()}show(){typeof F.exitPictureInPicture==`function`&&super.show()}}Ac.prototype.controlText_=`Picture-in-Picture`,q.registerComponent(`PictureInPictureToggle`,Ac);class jc extends lc{constructor(e,t){super(e,t),this.setIcon(`fullscreen-enter`),this.on(e,`fullscreenchange`,e=>this.handleFullscreenChange(e)),F[e.fsApi_.fullscreenEnabled]===!1&&this.disable()}buildCSSClass(){return`vjs-fullscreen-control ${super.buildCSSClass()}`}handleFullscreenChange(e){this.player_.isFullscreen()?(this.controlText(`Exit Fullscreen`),this.setIcon(`fullscreen-exit`)):(this.controlText(`Fullscreen`),this.setIcon(`fullscreen-enter`))}handleClick(e){this.player_.isFullscreen()?this.player_.exitFullscreen():this.player_.requestFullscreen()}}jc.prototype.controlText_=`Fullscreen`,q.registerComponent(`FullscreenToggle`,jc);const Mc=function(e,t){t.tech_&&!t.tech_.featuresVolumeControl&&e.addClass(`vjs-hidden`),e.on(t,`loadstart`,function(){t.tech_.featuresVolumeControl?e.removeClass(`vjs-hidden`):e.addClass(`vjs-hidden`)})};class Nc extends q{createEl(){let e=super.createEl(`div`,{className:`vjs-volume-level`});return this.setIcon(`circle`,e),e.appendChild(super.createEl(`span`,{className:`vjs-control-text`})),e}}q.registerComponent(`VolumeLevel`,Nc);class Pc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-volume-tooltip`},{"aria-hidden":`true`})}update(e,t,n,r){if(!n){let n=ka(this.el_),r=ka(this.player_.el()),i=e.width*t;if(!r||!n)return;let a=e.left-r.left+i,o=e.width-i+(r.right-e.right),s=n.width/2;a<s?s+=s-a:o<s&&(s=o),s<0?s=0:s>n.width&&(s=n.width),this.el_.style.right=`-${s}px`}this.write(`${r}%`)}write(e){ga(this.el_,e)}updateVolume(e,t,n,r,i){this.requestNamedAnimationFrame(`VolumeLevelTooltip#updateVolume`,()=>{this.update(e,t,n,r.toFixed(0)),i&&i()})}}q.registerComponent(`VolumeLevelTooltip`,Pc);class Fc extends q{constructor(e,t){super(e,t),this.update=fo(K(this,this.update),30)}createEl(){return super.createEl(`div`,{className:`vjs-mouse-display`})}update(e,t,n){let r=100*t;this.getChild(`volumeLevelTooltip`).updateVolume(e,t,n,r,()=>{n?this.el_.style.bottom=`${e.height*t}px`:this.el_.style.left=`${e.width*t}px`})}}Fc.prototype.options_={children:[`volumeLevelTooltip`]},q.registerComponent(`MouseVolumeLevelDisplay`,Fc);class Ic extends Sc{constructor(e,t){super(e,t),this.on(`slideractive`,e=>this.updateLastVolume_(e)),this.on(e,`volumechange`,e=>this.updateARIAAttributes(e)),e.ready(()=>this.updateARIAAttributes())}createEl(){return super.createEl(`div`,{className:`vjs-volume-bar vjs-slider-bar`},{"aria-label":this.localize(`Volume Level`),"aria-live":`polite`})}handleMouseDown(e){La(e)&&super.handleMouseDown(e)}handleMouseMove(e){let t=this.getChild(`mouseVolumeLevelDisplay`);if(t){let n=this.el(),r=ka(n),i=this.vertical(),a=ja(n,e);a=i?a.y:a.x,a=bc(a,0,1),t.update(r,a,i)}La(e)&&(this.checkMuted(),this.player_.volume(this.calculateDistance(e)))}checkMuted(){this.player_.muted()&&this.player_.muted(!1)}getPercent(){return this.player_.muted()?0:this.player_.volume()}stepForward(){this.checkMuted(),this.player_.volume(this.player_.volume()+.1)}stepBack(){this.checkMuted(),this.player_.volume(this.player_.volume()-.1)}updateARIAAttributes(e){let t=this.player_.muted()?0:this.volumeAsPercentage_();this.el_.setAttribute(`aria-valuenow`,t),this.el_.setAttribute(`aria-valuetext`,t+`%`)}volumeAsPercentage_(){return Math.round(this.player_.volume()*100)}updateLastVolume_(){let e=this.player_.volume();this.one(`sliderinactive`,()=>{this.player_.volume()===0&&this.player_.lastVolume_(e)})}}Ic.prototype.options_={children:[`volumeLevel`],barName:`volumeLevel`},!sa&&!Hi&&Ic.prototype.options_.children.splice(0,0,`mouseVolumeLevelDisplay`),Ic.prototype.playerEvent=`volumechange`,q.registerComponent(`VolumeBar`,Ic);class Lc extends q{constructor(e,t={}){t.vertical=t.vertical||!1,(t.volumeBar===void 0||Ii(t.volumeBar))&&(t.volumeBar=t.volumeBar||{},t.volumeBar.vertical=t.vertical),super(e,t),Mc(this,e),this.throttledHandleMouseMove=fo(K(this,this.handleMouseMove),30),this.handleMouseUpHandler_=e=>this.handleMouseUp(e),this.on(`mousedown`,e=>this.handleMouseDown(e)),this.on(`touchstart`,e=>this.handleMouseDown(e)),this.on(`mousemove`,e=>this.handleMouseMove(e)),this.on(this.volumeBar,[`focus`,`slideractive`],()=>{this.volumeBar.addClass(`vjs-slider-active`),this.addClass(`vjs-slider-active`),this.trigger(`slideractive`)}),this.on(this.volumeBar,[`blur`,`sliderinactive`],()=>{this.volumeBar.removeClass(`vjs-slider-active`),this.removeClass(`vjs-slider-active`),this.trigger(`sliderinactive`)})}createEl(){let e=`vjs-volume-horizontal`;return this.options_.vertical&&(e=`vjs-volume-vertical`),super.createEl(`div`,{className:`vjs-volume-control vjs-control ${e}`})}handleMouseDown(e){let t=this.el_.ownerDocument;this.on(t,`mousemove`,this.throttledHandleMouseMove),this.on(t,`touchmove`,this.throttledHandleMouseMove),this.on(t,`mouseup`,this.handleMouseUpHandler_),this.on(t,`touchend`,this.handleMouseUpHandler_)}handleMouseUp(e){let t=this.el_.ownerDocument;this.off(t,`mousemove`,this.throttledHandleMouseMove),this.off(t,`touchmove`,this.throttledHandleMouseMove),this.off(t,`mouseup`,this.handleMouseUpHandler_),this.off(t,`touchend`,this.handleMouseUpHandler_)}handleMouseMove(e){this.volumeBar.handleMouseMove(e)}}Lc.prototype.options_={children:[`volumeBar`]},q.registerComponent(`VolumeControl`,Lc);const Rc=function(e,t){t.tech_&&!t.tech_.featuresMuteControl&&e.addClass(`vjs-hidden`),e.on(t,`loadstart`,function(){t.tech_.featuresMuteControl?e.removeClass(`vjs-hidden`):e.addClass(`vjs-hidden`)})};class zc extends lc{constructor(e,t){super(e,t),Rc(this,e),this.on(e,[`loadstart`,`volumechange`],e=>this.update(e))}buildCSSClass(){return`vjs-mute-control ${super.buildCSSClass()}`}handleClick(e){let t=this.player_.volume(),n=this.player_.lastVolume_();if(t===0){let e=n<.1?.1:n;this.player_.volume(e),this.player_.muted(!1)}else this.player_.muted(!this.player_.muted())}update(e){this.updateIcon_(),this.updateControlText_()}updateIcon_(){let e=this.player_.volume(),t=3;this.setIcon(`volume-high`),sa&&this.player_.tech_&&this.player_.tech_.el_&&this.player_.muted(this.player_.tech_.el_.muted),e===0||this.player_.muted()?(this.setIcon(`volume-mute`),t=0):e<.33?(this.setIcon(`volume-low`),t=1):e<.67&&(this.setIcon(`volume-medium`),t=2),ba(this.el_,[0,1,2,3].reduce((e,t)=>e+`${t?` `:``}vjs-vol-${t}`,``)),ya(this.el_,`vjs-vol-${t}`)}updateControlText_(){let e=this.player_.muted()||this.player_.volume()===0?`Unmute`:`Mute`;this.controlText()!==e&&this.controlText(e)}}zc.prototype.controlText_=`Mute`,q.registerComponent(`MuteToggle`,zc);class Bc extends q{constructor(e,t={}){t.inline=t.inline===void 0||t.inline,(t.volumeControl===void 0||Ii(t.volumeControl))&&(t.volumeControl=t.volumeControl||{},t.volumeControl.vertical=!t.inline),super(e,t),this.handleKeyPressHandler_=e=>this.handleKeyPress(e),this.on(e,[`loadstart`],e=>this.volumePanelState_(e)),this.on(this.muteToggle,`keyup`,e=>this.handleKeyPress(e)),this.on(this.volumeControl,`keyup`,e=>this.handleVolumeControlKeyUp(e)),this.on(`keydown`,e=>this.handleKeyPress(e)),this.on(`mouseover`,e=>this.handleMouseOver(e)),this.on(`mouseout`,e=>this.handleMouseOut(e)),this.on(this.volumeControl,[`slideractive`],this.sliderActive_),this.on(this.volumeControl,[`sliderinactive`],this.sliderInactive_)}sliderActive_(){this.addClass(`vjs-slider-active`)}sliderInactive_(){this.removeClass(`vjs-slider-active`)}volumePanelState_(){this.volumeControl.hasClass(`vjs-hidden`)&&this.muteToggle.hasClass(`vjs-hidden`)&&this.addClass(`vjs-hidden`),this.volumeControl.hasClass(`vjs-hidden`)&&!this.muteToggle.hasClass(`vjs-hidden`)&&this.addClass(`vjs-mute-toggle-only`)}createEl(){let e=`vjs-volume-panel-horizontal`;return this.options_.inline||(e=`vjs-volume-panel-vertical`),super.createEl(`div`,{className:`vjs-volume-panel vjs-control ${e}`})}dispose(){this.handleMouseOut(),super.dispose()}handleVolumeControlKeyUp(e){e.key===`Escape`&&this.muteToggle.focus()}handleMouseOver(e){this.addClass(`vjs-hover`),ao(F,`keyup`,this.handleKeyPressHandler_)}handleMouseOut(e){this.removeClass(`vjs-hover`),oo(F,`keyup`,this.handleKeyPressHandler_)}handleKeyPress(e){e.key===`Escape`&&this.handleMouseOut()}}Bc.prototype.options_={children:[`muteToggle`,`volumeControl`]},q.registerComponent(`VolumePanel`,Bc);class Vc extends lc{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipForwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`forward-${this.skipTime}`),this.controlText(this.localize(`Skip forward {1} seconds`,[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipForwardTime(){let e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.forward}buildCSSClass(){return`vjs-skip-forward-${this.getSkipForwardTime()} ${super.buildCSSClass()}`}handleClick(e){if(isNaN(this.player_.duration()))return;let t=this.player_.currentTime(),n=this.player_.liveTracker,r=n&&n.isLive()?n.seekableEnd():this.player_.duration(),i;i=t+this.skipTime<=r?t+this.skipTime:r,this.player_.currentTime(i)}handleLanguagechange(){this.controlText(this.localize(`Skip forward {1} seconds`,[this.skipTime]))}}Vc.prototype.controlText_=`Skip Forward`,q.registerComponent(`SkipForward`,Vc);class Hc extends lc{constructor(e,t){super(e,t),this.validOptions=[5,10,30],this.skipTime=this.getSkipBackwardTime(),this.skipTime&&this.validOptions.includes(this.skipTime)?(this.setIcon(`replay-${this.skipTime}`),this.controlText(this.localize(`Skip backward {1} seconds`,[this.skipTime.toLocaleString(e.language())])),this.show()):this.hide()}getSkipBackwardTime(){let e=this.options_.playerOptions;return e.controlBar&&e.controlBar.skipButtons&&e.controlBar.skipButtons.backward}buildCSSClass(){return`vjs-skip-backward-${this.getSkipBackwardTime()} ${super.buildCSSClass()}`}handleClick(e){let t=this.player_.currentTime(),n=this.player_.liveTracker,r=n&&n.isLive()&&n.seekableStart(),i;i=r&&t-this.skipTime<=r?r:t>=this.skipTime?t-this.skipTime:0,this.player_.currentTime(i)}handleLanguagechange(){this.controlText(this.localize(`Skip backward {1} seconds`,[this.skipTime]))}}Hc.prototype.controlText_=`Skip Backward`,q.registerComponent(`SkipBackward`,Hc);class Uc extends q{constructor(e,t){super(e,t),t&&(this.menuButton_=t.menuButton),this.focusedChild_=-1,this.on(`keydown`,e=>this.handleKeyDown(e)),this.boundHandleBlur_=e=>this.handleBlur(e),this.boundHandleTapClick_=e=>this.handleTapClick(e)}addEventListenerForItem(e){e instanceof q&&(this.on(e,`blur`,this.boundHandleBlur_),this.on(e,[`tap`,`click`],this.boundHandleTapClick_))}removeEventListenerForItem(e){e instanceof q&&(this.off(e,`blur`,this.boundHandleBlur_),this.off(e,[`tap`,`click`],this.boundHandleTapClick_))}removeChild(e){typeof e==`string`&&(e=this.getChild(e)),this.removeEventListenerForItem(e),super.removeChild(e)}addItem(e){let t=this.addChild(e);t&&this.addEventListenerForItem(t)}createEl(){let e=this.options_.contentElType||`ul`;this.contentEl_=G(e,{className:`vjs-menu-content`}),this.contentEl_.setAttribute(`role`,`menu`);let t=super.createEl(`div`,{append:this.contentEl_,className:`vjs-menu`});return t.appendChild(this.contentEl_),ao(t,`click`,function(e){e.preventDefault(),e.stopImmediatePropagation()}),t}dispose(){this.contentEl_=null,this.boundHandleBlur_=null,this.boundHandleTapClick_=null,super.dispose()}handleBlur(e){let t=e.relatedTarget||F.activeElement;if(!this.children().some(e=>e.el()===t)){let e=this.menuButton_;e&&e.buttonPressed_&&t!==e.el().firstChild&&e.unpressButton()}}handleTapClick(e){if(this.menuButton_){this.menuButton_.unpressButton();let t=this.children();if(!Array.isArray(t))return;let n=t.filter(t=>t.el()===e.target)[0];if(!n)return;n.name()!==`CaptionSettingsMenuItem`&&this.menuButton_.focus()}}handleKeyDown(e){e.key===`ArrowLeft`||e.key===`ArrowDown`?(e.preventDefault(),e.stopPropagation(),this.stepForward()):(e.key===`ArrowRight`||e.key===`ArrowUp`)&&(e.preventDefault(),e.stopPropagation(),this.stepBack())}stepForward(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_+1),this.focus(e)}stepBack(){let e=0;this.focusedChild_!==void 0&&(e=this.focusedChild_-1),this.focus(e)}focus(e=0){let t=this.children().slice();t.length&&t[0].hasClass(`vjs-menu-title`)&&t.shift(),t.length>0&&(e<0?e=0:e>=t.length&&(e=t.length-1),this.focusedChild_=e,t[e].el_.focus())}}q.registerComponent(`Menu`,Uc);class Wc extends q{constructor(e,t={}){super(e,t),this.menuButton_=new lc(e,t),this.menuButton_.controlText(this.controlText_),this.menuButton_.el_.setAttribute(`aria-haspopup`,`true`);let n=lc.prototype.buildCSSClass();this.menuButton_.el_.className=this.buildCSSClass()+` `+n,this.menuButton_.removeClass(`vjs-control`),this.addChild(this.menuButton_),this.update(),this.enabled_=!0;let r=e=>this.handleClick(e);this.handleMenuKeyUp_=e=>this.handleMenuKeyUp(e),this.on(this.menuButton_,`tap`,r),this.on(this.menuButton_,`click`,r),this.on(this.menuButton_,`keydown`,e=>this.handleKeyDown(e)),this.on(this.menuButton_,`mouseenter`,()=>{this.addClass(`vjs-hover`),this.menu.show(),ao(F,`keyup`,this.handleMenuKeyUp_)}),this.on(`mouseleave`,e=>this.handleMouseLeave(e)),this.on(`keydown`,e=>this.handleSubmenuKeyDown(e))}update(){let e=this.createMenu();this.menu&&(this.menu.dispose(),this.removeChild(this.menu)),this.menu=e,this.addChild(e),this.buttonPressed_=!1,this.menuButton_.el_.setAttribute(`aria-expanded`,`false`),this.items&&this.items.length<=this.hideThreshold_?(this.hide(),this.menu.contentEl_.removeAttribute(`role`)):(this.show(),this.menu.contentEl_.setAttribute(`role`,`menu`))}createMenu(){let e=new Uc(this.player_,{menuButton:this});if(this.hideThreshold_=0,this.options_.title){let t=G(`li`,{className:`vjs-menu-title`,textContent:jo(this.options_.title),tabIndex:-1}),n=new q(this.player_,{el:t});e.addItem(n)}if(this.items=this.createItems(),this.items)for(let t=0;t<this.items.length;t++)e.addItem(this.items[t]);return e}createItems(){}createEl(){return super.createEl(`div`,{className:this.buildWrapperCSSClass()},{})}setIcon(e){return super.setIcon(e,this.menuButton_.el_)}buildWrapperCSSClass(){let e=`vjs-menu-button`;this.options_.inline===!0?e+=`-inline`:e+=`-popup`;let t=lc.prototype.buildCSSClass();return`vjs-menu-button ${e} ${t} ${super.buildCSSClass()}`}buildCSSClass(){let e=`vjs-menu-button`;return this.options_.inline===!0?e+=`-inline`:e+=`-popup`,`vjs-menu-button ${e} ${super.buildCSSClass()}`}controlText(e,t=this.menuButton_.el()){return this.menuButton_.controlText(e,t)}dispose(){this.handleMouseLeave(),super.dispose()}handleClick(e){this.buttonPressed_?this.unpressButton():this.pressButton()}handleMouseLeave(e){this.removeClass(`vjs-hover`),oo(F,`keyup`,this.handleMenuKeyUp_)}focus(){this.menuButton_.focus()}blur(){this.menuButton_.blur()}handleKeyDown(e){e.key===`Escape`||e.key===`Tab`?(this.buttonPressed_&&this.unpressButton(),!e.key===`Tab`&&(e.preventDefault(),this.menuButton_.focus())):e.key!==`Up`&&(e.key!==`Down`||this.player_.options_.playerOptions.spatialNavigation&&this.player_.options_.playerOptions.spatialNavigation.enabled)||this.buttonPressed_||(e.preventDefault(),this.pressButton())}handleMenuKeyUp(e){(e.key===`Escape`||e.key===`Tab`)&&this.removeClass(`vjs-hover`)}handleSubmenuKeyPress(e){this.handleSubmenuKeyDown(e)}handleSubmenuKeyDown(e){(e.key===`Escape`||e.key===`Tab`)&&(this.buttonPressed_&&this.unpressButton(),!e.key===`Tab`&&(e.preventDefault(),this.menuButton_.focus()))}pressButton(){if(this.enabled_){if(this.buttonPressed_=!0,this.menu.show(),this.menu.lockShowing(),this.menuButton_.el_.setAttribute(`aria-expanded`,`true`),sa&&ma())return;this.menu.focus()}}unpressButton(){this.enabled_&&(this.buttonPressed_=!1,this.menu.unlockShowing(),this.menu.hide(),this.menuButton_.el_.setAttribute(`aria-expanded`,`false`))}disable(){this.unpressButton(),this.enabled_=!1,this.addClass(`vjs-disabled`),this.menuButton_.disable()}enable(){this.enabled_=!0,this.removeClass(`vjs-disabled`),this.menuButton_.enable()}}q.registerComponent(`MenuButton`,Wc);class Gc extends Wc{constructor(e,t){let n=t.tracks;super(e,t),this.items.length<=1&&this.hide(),n&&(this.updateHandler_=K(this,this.update),this.cleanupHandler_=K(this,this.cleanupTrackListeners_),n.addEventListener(`removetrack`,this.updateHandler_),n.addEventListener(`addtrack`,this.updateHandler_),n.addEventListener(`labelchange`,this.updateHandler_),this.player_.on(`ready`,this.updateHandler_),this.player_.on(`dispose`,this.cleanupHandler_))}cleanupTrackListeners_(){if(!this.updateHandler_)return;let e=this.options_.tracks;e&&(e.removeEventListener(`removetrack`,this.updateHandler_),e.removeEventListener(`addtrack`,this.updateHandler_),e.removeEventListener(`labelchange`,this.updateHandler_)),this.player_&&(this.player_.off(`ready`,this.updateHandler_),this.player_.off(`dispose`,this.cleanupHandler_)),this.updateHandler_=null,this.cleanupHandler_=null}dispose(){this.cleanupTrackListeners_(),super.dispose()}}q.registerComponent(`TrackButton`,Gc);class Kc extends $s{constructor(e,t){super(e,t),this.selectable=t.selectable,this.isSelected_=t.selected||!1,this.multiSelectable=t.multiSelectable,this.selected(this.isSelected_),this.selectable?this.multiSelectable?this.el_.setAttribute(`role`,`menuitemcheckbox`):this.el_.setAttribute(`role`,`menuitemradio`):this.el_.setAttribute(`role`,`menuitem`)}createEl(e,t,n){this.nonIconControl=!0;let r=super.createEl(`li`,Object.assign({className:`vjs-menu-item`,tabIndex:-1},t),n),i=G(`span`,{className:`vjs-menu-item-text`,textContent:this.localize(this.options_.label)});return this.player_.options_.experimentalSvgIcons?r.appendChild(i):r.replaceChild(i,r.querySelector(`.vjs-icon-placeholder`)),r}handleKeyDown(e){[`Tab`,`Escape`,`ArrowUp`,`ArrowLeft`,`ArrowRight`,`ArrowDown`].includes(e.key)||super.handleKeyDown(e)}handleClick(e){this.selected(!0)}selected(e){this.selectable&&(e?(this.addClass(`vjs-selected`),this.el_.setAttribute(`aria-checked`,`true`),this.controlText(`, selected`),this.isSelected_=!0):(this.removeClass(`vjs-selected`),this.el_.setAttribute(`aria-checked`,`false`),this.controlText(``),this.isSelected_=!1))}}q.registerComponent(`MenuItem`,Kc);class qc extends Kc{constructor(e,t){let n=t.track,r=e.textTracks();t.label=n.label||n.language||`Unknown`,t.selected=n.mode===`showing`,super(e,t),this.track=n,this.kinds=(t.kinds||[t.kind||this.track.kind]).filter(Boolean);let i=(...e)=>{this.handleTracksChange.apply(this,e)},a=(...e)=>{this.handleSelectedLanguageChange.apply(this,e)};if(e.on([`loadstart`,`texttrackchange`],i),r.addEventListener(`change`,i),r.addEventListener(`selectedlanguagechange`,a),this.on(`dispose`,function(){e.off([`loadstart`,`texttrackchange`],i),r.removeEventListener(`change`,i),r.removeEventListener(`selectedlanguagechange`,a)}),r.onchange===void 0){let e;this.on([`tap`,`click`],function(){if(typeof x.Event!=`object`)try{e=new x.Event(`change`)}catch{}e||(e=F.createEvent(`Event`),e.initEvent(`change`,!0,!0)),r.dispatchEvent(e)})}this.handleTracksChange()}handleClick(e){let t=this.track,n=this.player_.textTracks();if(super.handleClick(e),n)for(let e=0;e<n.length;e++){let r=n[e];this.kinds.indexOf(r.kind)!==-1&&(r===t?r.mode!==`showing`&&(r.mode=`showing`):r.mode!==`disabled`&&(r.mode=`disabled`))}}handleTracksChange(e){let t=this.track.mode===`showing`;t!==this.isSelected_&&this.selected(t)}handleSelectedLanguageChange(e){if(this.track.mode===`showing`){let e=this.player_.cache_.selectedLanguage;if(e&&e.enabled&&e.language===this.track.language&&e.kind!==this.track.kind)return;this.player_.cache_.selectedLanguage={enabled:!0,language:this.track.language,kind:this.track.kind}}}dispose(){this.track=null,super.dispose()}}q.registerComponent(`TextTrackMenuItem`,qc);class Jc extends qc{constructor(e,t){t.track={player:e,kind:t.kind,kinds:t.kinds,default:!1,mode:`disabled`},t.kinds||=[t.kind],t.label?t.track.label=t.label:t.track.label=t.kinds.join(` and `)+` off`,t.selectable=!0,t.multiSelectable=!1,super(e,t)}handleTracksChange(e){let t=this.player().textTracks(),n=!0;for(let e=0,r=t.length;e<r;e++){let r=t[e];if(this.options_.kinds.indexOf(r.kind)>-1&&r.mode===`showing`){n=!1;break}}n!==this.isSelected_&&this.selected(n)}handleSelectedLanguageChange(e){let t=this.player().textTracks(),n=!0;for(let e=0,r=t.length;e<r;e++){let r=t[e];if([`captions`,`descriptions`,`subtitles`].indexOf(r.kind)>-1&&r.mode===`showing`){n=!1;break}}n&&(this.player_.cache_.selectedLanguage={enabled:!1})}handleLanguagechange(){this.$(`.vjs-menu-item-text`).textContent=this.player_.localize(this.options_.label),super.handleLanguagechange()}}q.registerComponent(`OffTextTrackMenuItem`,Jc);class Yc extends Gc{constructor(e,t={}){t.tracks=e.textTracks(),super(e,t)}createItems(e=[],t=qc){let n;this.label_&&(n=`${this.label_} off`),e.push(new Jc(this.player_,{kinds:this.kinds_,kind:this.kind_,label:n})),this.hideThreshold_+=1;let r=this.player_.textTracks();Array.isArray(this.kinds_)||(this.kinds_=[this.kind_]);for(let n=0;n<r.length;n++){let i=r[n];if(this.kinds_.indexOf(i.kind)>-1){let n=new t(this.player_,{track:i,kinds:this.kinds_,kind:this.kind_,selectable:!0,multiSelectable:!1});n.addClass(`vjs-${i.kind}-menu-item`),e.push(n)}}return e}}q.registerComponent(`TextTrackButton`,Yc);class Xc extends Kc{constructor(e,t){let n=t.track,r=t.cue,i=e.currentTime();t.selectable=!0,t.multiSelectable=!1,t.label=r.text,t.selected=r.startTime<=i&&i<r.endTime,super(e,t),this.track=n,this.cue=r}handleClick(e){super.handleClick(),this.player_.currentTime(this.cue.startTime)}}q.registerComponent(`ChaptersTrackMenuItem`,Xc);class Zc extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`chapters`),this.selectCurrentItem_=()=>{this.items.forEach(e=>{e.selected(this.track_.activeCues[0]===e.cue)})}}buildCSSClass(){return`vjs-chapters-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-chapters-button ${super.buildWrapperCSSClass()}`}update(e){if(e&&e.track&&e.track.kind!==`chapters`)return;let t=this.findChaptersTrack();t===this.track_?(!this.items||t&&t.cues&&t.cues.length!==this.items.length)&&super.update():(this.setTrack(t),super.update())}setTrack(e){if(this.track_!==e){if(this.updateHandler_||=this.update.bind(this),this.track_){let e=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);e&&e.removeEventListener(`load`,this.updateHandler_),this.track_.removeEventListener(`cuechange`,this.selectCurrentItem_),this.track_=null}if(this.track_=e,this.track_){this.track_.mode=`hidden`;let e=this.player_.remoteTextTrackEls().getTrackElementByTrack_(this.track_);e&&e.addEventListener(`load`,this.updateHandler_),this.track_.addEventListener(`cuechange`,this.selectCurrentItem_)}}}findChaptersTrack(){let e=this.player_.textTracks()||[];for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.kind===this.kind_)return n}}getMenuCaption(){return this.track_&&this.track_.label?this.track_.label:this.localize(jo(this.kind_))}createMenu(){return this.options_.title=this.getMenuCaption(),super.createMenu()}createItems(){let e=[];if(!this.track_)return e;let t=this.track_.cues;if(!t)return e;for(let n=0,r=t.length;n<r;n++){let r=t[n],i=new Xc(this.player_,{track:this.track_,cue:r});e.push(i)}return e}}Zc.prototype.kind_=`chapters`,Zc.prototype.controlText_=`Chapters`,q.registerComponent(`ChaptersButton`,Zc);class Qc extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`audio-description`);let r=e.textTracks(),i=K(this,this.handleTracksChange);r.addEventListener(`change`,i),this.on(`dispose`,function(){r.removeEventListener(`change`,i)})}handleTracksChange(e){let t=this.player().textTracks(),n=!1;for(let e=0,r=t.length;e<r;e++){let r=t[e];if(r.kind!==this.kind_&&r.mode===`showing`){n=!0;break}}n?this.disable():this.enable()}buildCSSClass(){return`vjs-descriptions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-descriptions-button ${super.buildWrapperCSSClass()}`}}Qc.prototype.kind_=`descriptions`,Qc.prototype.controlText_=`Descriptions`,q.registerComponent(`DescriptionsButton`,Qc);class $c extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`subtitles`)}buildCSSClass(){return`vjs-subtitles-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subtitles-button ${super.buildWrapperCSSClass()}`}}$c.prototype.kind_=`subtitles`,$c.prototype.controlText_=`Subtitles`,q.registerComponent(`SubtitlesButton`,$c);class el extends qc{constructor(e,t){t.track={player:e,kind:t.kind,label:t.kind+` settings`,selectable:!1,default:!1,mode:`disabled`},t.selectable=!1,t.name=`CaptionSettingsMenuItem`,super(e,t),this.addClass(`vjs-texttrack-settings`),this.controlText(`, opens `+t.kind+` settings dialog`)}handleClick(e){this.player().getChild(`textTrackSettings`).open()}handleLanguagechange(){this.$(`.vjs-menu-item-text`).textContent=this.player_.localize(this.options_.kind+` settings`),super.handleLanguagechange()}}q.registerComponent(`CaptionSettingsMenuItem`,el);class tl extends Yc{constructor(e,t,n){super(e,t,n),this.setIcon(`captions`)}buildCSSClass(){return`vjs-captions-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-captions-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild(`textTrackSettings`)&&(e.push(new el(this.player_,{kind:this.kind_})),this.hideThreshold_+=1),super.createItems(e)}}tl.prototype.kind_=`captions`,tl.prototype.controlText_=`Captions`,q.registerComponent(`CaptionsButton`,tl);class nl extends qc{createEl(e,t,n){let r=super.createEl(e,t,n),i=r.querySelector(`.vjs-menu-item-text`);return this.options_.track.kind===`captions`&&(this.player_.options_.experimentalSvgIcons?this.setIcon(`captions`,r):i.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),i.appendChild(G(`span`,{className:`vjs-control-text`,textContent:` ${this.localize(`Captions`)}`}))),r}}q.registerComponent(`SubsCapsMenuItem`,nl);class rl extends Yc{constructor(e,t={}){super(e,t),this.label_=`subtitles`,this.setIcon(`subtitles`),[`en`,`en-us`,`en-ca`,`fr-ca`].indexOf(this.player_.language_)>-1&&(this.label_=`captions`,this.setIcon(`captions`)),this.menuButton_.controlText(jo(this.label_))}buildCSSClass(){return`vjs-subs-caps-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-subs-caps-button ${super.buildWrapperCSSClass()}`}createItems(){let e=[];return!(this.player().tech_&&this.player().tech_.featuresNativeTextTracks)&&this.player().getChild(`textTrackSettings`)&&(e.push(new el(this.player_,{kind:this.label_})),this.hideThreshold_+=1),e=super.createItems(e,nl),e}}rl.prototype.kinds_=[`captions`,`subtitles`],rl.prototype.controlText_=`Subtitles`,q.registerComponent(`SubsCapsButton`,rl);class il extends Kc{constructor(e,t){let n=t.track,r=e.audioTracks();t.label=n.label||n.language||`Unknown`,t.selected=n.enabled,super(e,t),this.track=n,this.addClass(`vjs-${n.kind}-menu-item`);let i=(...e)=>{this.handleTracksChange.apply(this,e)};r.addEventListener(`change`,i),this.on(`dispose`,()=>{r.removeEventListener(`change`,i)})}createEl(e,t,n){let r=super.createEl(e,t,n),i=r.querySelector(`.vjs-menu-item-text`);return[`main-desc`,`descriptions`,`description`].indexOf(this.options_.track.kind)>=0&&(i.appendChild(G(`span`,{className:`vjs-icon-placeholder`},{"aria-hidden":!0})),i.appendChild(G(`span`,{className:`vjs-control-text`,textContent:` `+this.localize(`Descriptions`)}))),r}handleClick(e){if(super.handleClick(e),this.track.enabled=!0,this.player_.tech_.featuresNativeAudioTracks){let e=this.player_.audioTracks();for(let t=0;t<e.length;t++){let n=e[t];n!==this.track&&(n.enabled=n===this.track)}}}handleTracksChange(e){this.selected(this.track.enabled)}}q.registerComponent(`AudioTrackMenuItem`,il);class al extends Gc{constructor(e,t={}){t.tracks=e.audioTracks(),super(e,t),this.setIcon(`audio`)}buildCSSClass(){return`vjs-audio-button ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-audio-button ${super.buildWrapperCSSClass()}`}createItems(e=[]){this.hideThreshold_=1;let t=this.player_.audioTracks();for(let n=0;n<t.length;n++){let r=t[n];e.push(new il(this.player_,{track:r,selectable:!0,multiSelectable:!1}))}return e}}al.prototype.controlText_=`Audio Track`,q.registerComponent(`AudioTrackButton`,al);class ol extends Kc{constructor(e,t){let n=t.rate,r=parseFloat(n,10);t.label=n,t.selected=r===e.playbackRate(),t.selectable=!0,t.multiSelectable=!1,super(e,t),this.label=n,this.rate=r,this.on(e,`ratechange`,e=>this.update(e))}handleClick(e){super.handleClick(),this.player().playbackRate(this.rate)}update(e){this.selected(this.player().playbackRate()===this.rate)}}ol.prototype.contentElType=`button`,q.registerComponent(`PlaybackRateMenuItem`,ol);class sl extends Wc{constructor(e,t){super(e,t),this.menuButton_.el_.setAttribute(`aria-describedby`,this.labelElId_),this.updateVisibility(),this.updateLabel(),this.on(e,`loadstart`,e=>this.updateVisibility(e)),this.on(e,`ratechange`,e=>this.updateLabel(e)),this.on(e,`playbackrateschange`,e=>this.handlePlaybackRateschange(e))}createEl(){let e=super.createEl();return this.labelElId_=`vjs-playback-rate-value-label-`+this.id_,this.labelEl_=G(`div`,{className:`vjs-playback-rate-value`,id:this.labelElId_,textContent:`1x`}),e.appendChild(this.labelEl_),e}dispose(){this.labelEl_=null,super.dispose()}buildCSSClass(){return`vjs-playback-rate ${super.buildCSSClass()}`}buildWrapperCSSClass(){return`vjs-playback-rate ${super.buildWrapperCSSClass()}`}createItems(){let e=this.playbackRates(),t=[];for(let n=e.length-1;n>=0;n--)t.push(new ol(this.player(),{rate:e[n]+`x`}));return t}handlePlaybackRateschange(e){this.update()}playbackRates(){let e=this.player();return e.playbackRates&&e.playbackRates()||[]}playbackRateSupported(){return this.player().tech_&&this.player().tech_.featuresPlaybackRate&&this.playbackRates()&&this.playbackRates().length>0}updateVisibility(e){this.playbackRateSupported()?this.removeClass(`vjs-hidden`):this.addClass(`vjs-hidden`)}updateLabel(e){this.playbackRateSupported()&&(this.labelEl_.textContent=this.player().playbackRate()+`x`)}}sl.prototype.controlText_=`Playback Rate`,q.registerComponent(`PlaybackRateMenuButton`,sl);class cl extends q{buildCSSClass(){return`vjs-spacer ${super.buildCSSClass()}`}createEl(e=`div`,t={},n={}){return t.className||=this.buildCSSClass(),super.createEl(e,t,n)}}q.registerComponent(`Spacer`,cl);class ll extends cl{buildCSSClass(){return`vjs-custom-control-spacer ${super.buildCSSClass()}`}createEl(){return super.createEl(`div`,{className:this.buildCSSClass(),textContent:`\xA0`})}}q.registerComponent(`CustomControlSpacer`,ll);class ul extends q{createEl(){return super.createEl(`div`,{className:`vjs-control-bar`,dir:`ltr`})}}ul.prototype.options_={children:[`playToggle`,`skipBackward`,`skipForward`,`volumePanel`,`currentTimeDisplay`,`timeDivider`,`durationDisplay`,`progressControl`,`liveDisplay`,`seekToLive`,`remainingTimeDisplay`,`customControlSpacer`,`playbackRateMenuButton`,`chaptersButton`,`descriptionsButton`,`subsCapsButton`,`audioTrackButton`,`pictureInPictureToggle`,`fullscreenToggle`]},q.registerComponent(`ControlBar`,ul);class dl extends Zo{constructor(e,t){super(e,t),this.on(e,`error`,e=>{this.open(e)})}buildCSSClass(){return`vjs-error-display ${super.buildCSSClass()}`}content(){let e=this.player().error();return e?this.localize(e.message):``}}dl.prototype.options_=Object.assign({},Zo.prototype.options_,{pauseOnOpen:!1,fillAlways:!0,temporary:!1,uncloseable:!0}),q.registerComponent(`ErrorDisplay`,dl);class fl extends q{constructor(e,t={}){super(e,t),this.el_.setAttribute(`aria-labelledby`,this.selectLabelledbyIds)}createEl(){return this.selectLabelledbyIds=[this.options_.legendId,this.options_.labelId].join(` `).trim(),G(`select`,{id:this.options_.id},{},this.options_.SelectOptions.map(e=>{let t=(this.options_.labelId?this.options_.labelId:`vjs-track-option-${Qa()}`)+`-`+e[1].replace(/\W+/g,``),n=G(`option`,{id:t,value:this.localize(e[0]),textContent:this.localize(e[1])});return n.setAttribute(`aria-labelledby`,`${this.selectLabelledbyIds} ${t}`),n}))}}q.registerComponent(`TextTrackSelect`,fl);class pl extends q{constructor(e,t={}){super(e,t);let n=G(`legend`,{textContent:this.localize(this.options_.legendText),id:this.options_.legendId});this.el().appendChild(n);let r=this.options_.selects;for(let t of r){let n=this.options_.selectConfigs[t],r=n.className,i=n.id.replace(`%s`,this.options_.id_),a=null,o=`vjs_select_${Qa()}`;if(this.options_.type===`colors`){a=G(`span`,{className:r});let e=G(`label`,{id:i,className:`vjs-label`,textContent:this.localize(n.label)});e.setAttribute(`for`,o),a.appendChild(e)}let s=new fl(e,{SelectOptions:n.options,legendId:this.options_.legendId,id:o,labelId:i});this.addChild(s),this.options_.type===`colors`&&(a.appendChild(s.el()),this.el().appendChild(a))}}createEl(){return G(`fieldset`,{className:this.options_.className})}}q.registerComponent(`TextTrackFieldset`,pl);class ml extends q{constructor(e,t={}){super(e,t);let n=this.options_.textTrackComponentid,r=new pl(e,{id_:n,legendId:`captions-text-legend-${n}`,legendText:this.localize(`Text`),className:`vjs-fg vjs-track-setting`,selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:`colors`});this.addChild(r);let i=new pl(e,{id_:n,legendId:`captions-background-${n}`,legendText:this.localize(`Text Background`),className:`vjs-bg vjs-track-setting`,selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:`colors`});this.addChild(i);let a=new pl(e,{id_:n,legendId:`captions-window-${n}`,legendText:this.localize(`Caption Area Background`),className:`vjs-window vjs-track-setting`,selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:`colors`});this.addChild(a)}createEl(){return G(`div`,{className:`vjs-track-settings-colors`})}}q.registerComponent(`TextTrackSettingsColors`,ml);class hl extends q{constructor(e,t={}){super(e,t);let n=this.options_.textTrackComponentid,r=new pl(e,{id_:n,legendId:`captions-font-size-${n}`,legendText:`Font Size`,className:`vjs-font-percent vjs-track-setting`,selects:this.options_.fieldSets[0],selectConfigs:this.options_.selectConfigs,type:`font`});this.addChild(r);let i=new pl(e,{id_:n,legendId:`captions-edge-style-${n}`,legendText:this.localize(`Text Edge Style`),className:`vjs-edge-style vjs-track-setting`,selects:this.options_.fieldSets[1],selectConfigs:this.options_.selectConfigs,type:`font`});this.addChild(i);let a=new pl(e,{id_:n,legendId:`captions-font-family-${n}`,legendText:this.localize(`Font Family`),className:`vjs-font-family vjs-track-setting`,selects:this.options_.fieldSets[2],selectConfigs:this.options_.selectConfigs,type:`font`});this.addChild(a)}createEl(){return G(`div`,{className:`vjs-track-settings-font`})}}q.registerComponent(`TextTrackSettingsFont`,hl);class gl extends q{constructor(e,t={}){super(e,t);let n=new lc(e,{controlText:this.localize(`restore all settings to the default values`),className:`vjs-default-button`});n.el().classList.remove(`vjs-control`,`vjs-button`),n.el().textContent=this.localize(`Reset`),this.addChild(n);let r=this.localize(`Done`),i=new lc(e,{controlText:r,className:`vjs-done-button`});i.el().classList.remove(`vjs-control`,`vjs-button`),i.el().textContent=r,this.addChild(i)}createEl(){return G(`div`,{className:`vjs-track-settings-controls`})}}q.registerComponent(`TrackSettingsControls`,gl);const _l=`vjs-text-track-settings`,vl=[`#000`,`Black`],yl=[`#00F`,`Blue`],bl=[`#0FF`,`Cyan`],xl=[`#0F0`,`Green`],Sl=[`#F0F`,`Magenta`],Cl=[`#F00`,`Red`],wl=[`#FFF`,`White`],Tl=[`#FF0`,`Yellow`],El=[`1`,`Opaque`],Dl=[`0.5`,`Semi-Transparent`],Ol=[`0`,`Transparent`],kl={backgroundColor:{selector:`.vjs-bg-color > select`,id:`captions-background-color-%s`,label:`Color`,options:[vl,wl,Cl,xl,yl,Tl,Sl,bl],className:`vjs-bg-color`},backgroundOpacity:{selector:`.vjs-bg-opacity > select`,id:`captions-background-opacity-%s`,label:`Opacity`,options:[El,Dl,Ol],className:`vjs-bg-opacity vjs-opacity`},color:{selector:`.vjs-text-color > select`,id:`captions-foreground-color-%s`,label:`Color`,options:[wl,vl,Cl,xl,yl,Tl,Sl,bl],className:`vjs-text-color`},edgeStyle:{selector:`.vjs-edge-style > select`,id:``,label:`Text Edge Style`,options:[[`none`,`None`],[`raised`,`Raised`],[`depressed`,`Depressed`],[`uniform`,`Uniform`],[`dropshadow`,`Drop shadow`]]},fontFamily:{selector:`.vjs-font-family > select`,id:``,label:`Font Family`,options:[[`proportionalSansSerif`,`Proportional Sans-Serif`],[`monospaceSansSerif`,`Monospace Sans-Serif`],[`proportionalSerif`,`Proportional Serif`],[`monospaceSerif`,`Monospace Serif`],[`casual`,`Casual`],[`script`,`Script`],[`small-caps`,`Small Caps`]]},fontPercent:{selector:`.vjs-font-percent > select`,id:``,label:`Font Size`,options:[[`0.50`,`50%`],[`0.75`,`75%`],[`1.00`,`100%`],[`1.25`,`125%`],[`1.50`,`150%`],[`1.75`,`175%`],[`2.00`,`200%`],[`3.00`,`300%`],[`4.00`,`400%`]],default:2,parser:e=>e===`1.00`?null:Number(e)},textOpacity:{selector:`.vjs-text-opacity > select`,id:`captions-foreground-opacity-%s`,label:`Opacity`,options:[El,Dl],className:`vjs-text-opacity vjs-opacity`},windowColor:{selector:`.vjs-window-color > select`,id:`captions-window-color-%s`,label:`Color`,className:`vjs-window-color`},windowOpacity:{selector:`.vjs-window-opacity > select`,id:`captions-window-opacity-%s`,label:`Opacity`,options:[Ol,Dl,El],className:`vjs-window-opacity vjs-opacity`}};kl.windowColor.options=kl.backgroundColor.options;function Al(e,t){if(t&&(e=t(e)),e&&e!==`none`)return e}function jl(e,t){let n=e.options[e.options.selectedIndex].value;return Al(n,t)}function Ml(e,t,n){if(t){for(let r=0;r<e.options.length;r++)if(Al(e.options[r].value,n)===t){e.selectedIndex=r;break}}}class Nl extends Zo{constructor(e,t){t.temporary=!1,super(e,t),this.updateDisplay=this.updateDisplay.bind(this),this.fill(),this.hasBeenOpened_=this.hasBeenFilled_=!0,this.renderModalComponents(e),this.endDialog=G(`p`,{className:`vjs-control-text`,textContent:this.localize(`End of dialog window.`)}),this.el().appendChild(this.endDialog),this.setDefaults(),t.persistTextTrackSettings===void 0&&(this.options_.persistTextTrackSettings=this.options_.playerOptions.persistTextTrackSettings),this.bindFunctionsToSelectsAndButtons(),this.options_.persistTextTrackSettings&&this.restoreSettings()}renderModalComponents(e){let t=new ml(e,{textTrackComponentid:this.id_,selectConfigs:kl,fieldSets:[[`color`,`textOpacity`],[`backgroundColor`,`backgroundOpacity`],[`windowColor`,`windowOpacity`]]});this.addChild(t);let n=new hl(e,{textTrackComponentid:this.id_,selectConfigs:kl,fieldSets:[[`fontPercent`],[`edgeStyle`],[`fontFamily`]]});this.addChild(n);let r=new gl(e);this.addChild(r)}bindFunctionsToSelectsAndButtons(){this.on(this.$(`.vjs-done-button`),[`click`,`tap`],()=>{this.saveSettings(),this.close()}),this.on(this.$(`.vjs-default-button`),[`click`,`tap`],()=>{this.setDefaults(),this.updateDisplay()}),Ni(kl,e=>{this.on(this.$(e.selector),`change`,this.updateDisplay)})}dispose(){this.endDialog=null,super.dispose()}label(){return this.localize(`Caption Settings Dialog`)}description(){return this.localize(`Beginning of dialog window. Escape will cancel and close the window.`)}buildCSSClass(){return super.buildCSSClass()+` vjs-text-track-settings`}getValues(){return Pi(kl,(e,t,n)=>{let r=jl(this.$(t.selector),t.parser);return r!==void 0&&(e[n]=r),e},{})}setValues(e){Ni(kl,(t,n)=>{Ml(this.$(t.selector),e[n],t.parser)})}setDefaults(){Ni(kl,e=>{let t=e.hasOwnProperty(`default`)?e.default:0;this.$(e.selector).selectedIndex=t})}restoreSettings(){let e;try{e=JSON.parse(x.localStorage.getItem(_l))}catch(e){U.warn(e)}e&&this.setValues(e)}saveSettings(){if(!this.options_.persistTextTrackSettings)return;let e=this.getValues();try{Object.keys(e).length?x.localStorage.setItem(_l,JSON.stringify(e)):x.localStorage.removeItem(_l)}catch(e){U.warn(e)}}updateDisplay(){let e=this.player_.getChild(`textTrackDisplay`);e&&e.updateDisplay()}handleLanguagechange(){this.fill(),this.renderModalComponents(this.player_),this.bindFunctionsToSelectsAndButtons()}}q.registerComponent(`TextTrackSettings`,Nl);class Pl extends q{constructor(e,t){let n=t.ResizeObserver||x.ResizeObserver;t.ResizeObserver===null&&(n=!1);let r=W({createEl:!n,reportTouchActivity:!1},t);super(e,r),this.ResizeObserver=t.ResizeObserver||x.ResizeObserver,this.loadListener_=null,this.resizeObserver_=null,this.debouncedHandler_=po(()=>{this.resizeHandler()},100,!1,this),n?(this.resizeObserver_=new this.ResizeObserver(this.debouncedHandler_),this.resizeObserver_.observe(e.el())):(this.loadListener_=()=>{if(!this.el_||!this.el_.contentWindow)return;let e=this.debouncedHandler_,t=this.unloadListener_=function(){oo(this,`resize`,e),oo(this,`unload`,t),t=null};ao(this.el_.contentWindow,`unload`,t),ao(this.el_.contentWindow,`resize`,e)},this.one(`load`,this.loadListener_))}createEl(){return super.createEl(`iframe`,{className:`vjs-resize-manager`,tabIndex:-1,title:this.localize(`No content`)},{"aria-hidden":`true`})}resizeHandler(){this.player_&&this.player_.trigger&&this.player_.trigger(`playerresize`)}dispose(){this.debouncedHandler_&&this.debouncedHandler_.cancel(),this.resizeObserver_&&(this.player_.el()&&this.resizeObserver_.unobserve(this.player_.el()),this.resizeObserver_.disconnect()),this.loadListener_&&this.off(`load`,this.loadListener_),this.el_&&this.el_.contentWindow&&this.unloadListener_&&this.unloadListener_.call(this.el_.contentWindow),this.ResizeObserver=null,this.resizeObserver=null,this.debouncedHandler_=null,this.loadListener_=null,super.dispose()}}q.registerComponent(`ResizeManager`,Pl);const Fl={trackingThreshold:20,liveTolerance:15};class Il extends q{constructor(e,t){let n=W(Fl,t,{createEl:!1});super(e,n),this.trackLiveHandler_=()=>this.trackLive_(),this.handlePlay_=e=>this.handlePlay(e),this.handleFirstTimeupdate_=e=>this.handleFirstTimeupdate(e),this.handleSeeked_=e=>this.handleSeeked(e),this.seekToLiveEdge_=e=>this.seekToLiveEdge(e),this.reset_(),this.on(this.player_,`durationchange`,e=>this.handleDurationchange(e)),this.on(this.player_,`canplay`,()=>this.toggleTracking())}trackLive_(){let e=this.player_.seekable();if(!e||!e.length)return;let t=Number(x.performance.now().toFixed(4)),n=this.lastTime_===-1?0:(t-this.lastTime_)/1e3;this.lastTime_=t,this.pastSeekEnd_=this.pastSeekEnd()+n;let r=this.liveCurrentTime(),i=this.player_.currentTime(),a=this.player_.paused()||this.seekedBehindLive_||Math.abs(r-i)>this.options_.liveTolerance;this.timeupdateSeen_&&r!==1/0||(a=!1),a!==this.behindLiveEdge_&&(this.behindLiveEdge_=a,this.trigger(`liveedgechange`))}handleDurationchange(){this.toggleTracking()}toggleTracking(){this.player_.duration()===1/0&&this.liveWindow()>=this.options_.trackingThreshold?(this.player_.options_.liveui&&this.player_.addClass(`vjs-liveui`),this.startTracking()):(this.player_.removeClass(`vjs-liveui`),this.stopTracking())}startTracking(){this.isTracking()||(this.timeupdateSeen_||=this.player_.hasStarted(),this.trackingInterval_=this.setInterval(this.trackLiveHandler_,30),this.trackLive_(),this.on(this.player_,[`play`,`pause`],this.trackLiveHandler_),this.timeupdateSeen_?this.on(this.player_,`seeked`,this.handleSeeked_):(this.one(this.player_,`play`,this.handlePlay_),this.one(this.player_,`timeupdate`,this.handleFirstTimeupdate_)))}handleFirstTimeupdate(){this.timeupdateSeen_=!0,this.on(this.player_,`seeked`,this.handleSeeked_)}handleSeeked(){let e=Math.abs(this.liveCurrentTime()-this.player_.currentTime());this.seekedBehindLive_=this.nextSeekedFromUser_&&e>2,this.nextSeekedFromUser_=!1,this.trackLive_()}handlePlay(){this.one(this.player_,`timeupdate`,this.seekToLiveEdge_)}reset_(){this.lastTime_=-1,this.pastSeekEnd_=0,this.lastSeekEnd_=-1,this.behindLiveEdge_=!0,this.timeupdateSeen_=!1,this.seekedBehindLive_=!1,this.nextSeekedFromUser_=!1,this.clearInterval(this.trackingInterval_),this.trackingInterval_=null,this.off(this.player_,[`play`,`pause`],this.trackLiveHandler_),this.off(this.player_,`seeked`,this.handleSeeked_),this.off(this.player_,`play`,this.handlePlay_),this.off(this.player_,`timeupdate`,this.handleFirstTimeupdate_),this.off(this.player_,`timeupdate`,this.seekToLiveEdge_)}nextSeekedFromUser(){this.nextSeekedFromUser_=!0}stopTracking(){this.isTracking()&&(this.reset_(),this.trigger(`liveedgechange`))}seekableEnd(){let e=this.player_.seekable(),t=[],n=e?e.length:0;for(;n--;)t.push(e.end(n));return t.length?t.sort()[t.length-1]:1/0}seekableStart(){let e=this.player_.seekable(),t=[],n=e?e.length:0;for(;n--;)t.push(e.start(n));return t.length?t.sort()[0]:0}liveWindow(){let e=this.liveCurrentTime();return e===1/0?0:e-this.seekableStart()}isLive(){return this.isTracking()}atLiveEdge(){return!this.behindLiveEdge()}liveCurrentTime(){return this.pastSeekEnd()+this.seekableEnd()}pastSeekEnd(){let e=this.seekableEnd();return this.lastSeekEnd_!==-1&&e!==this.lastSeekEnd_&&(this.pastSeekEnd_=0),this.lastSeekEnd_=e,this.pastSeekEnd_}behindLiveEdge(){return this.behindLiveEdge_}isTracking(){return typeof this.trackingInterval_==`number`}seekToLiveEdge(){this.seekedBehindLive_=!1,this.atLiveEdge()||(this.nextSeekedFromUser_=!1,this.player_.currentTime(this.liveCurrentTime()))}dispose(){this.stopTracking(),super.dispose()}}q.registerComponent(`LiveTracker`,Il);class Ll extends q{constructor(e,t){super(e,t),this.on(`statechanged`,e=>this.updateDom_()),this.updateDom_()}createEl(){return this.els={title:G(`div`,{className:`vjs-title-bar-title`,id:`vjs-title-bar-title-${Qa()}`}),description:G(`div`,{className:`vjs-title-bar-description`,id:`vjs-title-bar-description-${Qa()}`})},G(`div`,{className:`vjs-title-bar`},{},Li(this.els))}updateDom_(){let e=this.player_.tech_,t=e&&e.el_,n={title:`aria-labelledby`,description:`aria-describedby`};[`title`,`description`].forEach(e=>{let r=this.state[e],i=this.els[e],a=n[e];Na(i),r&&ga(i,r),t&&(t.removeAttribute(a),r&&t.setAttribute(a,i.id))}),this.state.title||this.state.description?this.show():this.hide()}update(e){this.setState(e)}dispose(){let e=this.player_.tech_,t=e&&e.el_;t&&(t.removeAttribute(`aria-labelledby`),t.removeAttribute(`aria-describedby`)),super.dispose(),this.els=null}}q.registerComponent(`TitleBar`,Ll);const Rl={initialDisplay:4e3,position:[],takeFocus:!1};class zl extends lc{constructor(e,t){t=W(Rl,t),super(e,t),this.controlText(t.controlText),this.hide(),this.on(this.player_,[`useractive`,`userinactive`],e=>{this.removeClass(`force-display`)})}buildCSSClass(){return`vjs-transient-button focus-visible ${this.options_.position.map(e=>`vjs-${e}`).join(` `)}`}createEl(){let e=G(`button`,{},{type:`button`,class:this.buildCSSClass()},G(`span`));return this.controlTextEl_=e.querySelector(`span`),e}show(){super.show(),this.addClass(`force-display`),this.options_.takeFocus&&this.el().focus({preventScroll:!0}),this.forceDisplayTimeout=this.player_.setTimeout(()=>{this.removeClass(`force-display`)},this.options_.initialDisplay)}hide(){this.removeClass(`force-display`),super.hide()}dispose(){this.player_.clearTimeout(this.forceDisplayTimeout),super.dispose()}}q.registerComponent(`TransientButton`,zl);const Bl=e=>{let t=e.el();if(t.hasAttribute(`src`))return e.triggerSourceset(t.src),!0;let n=e.$$(`source`),r=[],i=``;if(!n.length)return!1;for(let e=0;e<n.length;e++){let t=n[e].src;t&&r.indexOf(t)===-1&&r.push(t)}return r.length?(r.length===1&&(i=r[0]),e.triggerSourceset(i),!0):!1},Vl=Object.defineProperty({},"innerHTML",{get(){return this.cloneNode(!0).innerHTML},set(e){let t=F.createElement(this.nodeName.toLowerCase());t.innerHTML=e;let n=F.createDocumentFragment();for(;t.childNodes.length;)n.appendChild(t.childNodes[0]);return this.innerText=``,x.Element.prototype.appendChild.call(this,n),this.innerHTML}}),Hl=(e,t)=>{let n={};for(let r=0;r<e.length&&(n=Object.getOwnPropertyDescriptor(e[r],t),!(n&&n.set&&n.get));r++);return n.enumerable=!0,n.configurable=!0,n},Ul=e=>Hl([e.el(),x.HTMLMediaElement.prototype,x.Element.prototype,Vl],`innerHTML`),Wl=function(e){let t=e.el();if(t.resetSourceWatch_)return;let n={},r=Ul(e),i=n=>(...r)=>{let i=n.apply(t,r);return Bl(e),i};[`append`,`appendChild`,`insertAdjacentHTML`].forEach(e=>{t[e]&&(n[e]=t[e],t[e]=i(n[e]))}),Object.defineProperty(t,"innerHTML",W(r,{set:i(r.set)})),t.resetSourceWatch_=()=>{t.resetSourceWatch_=null,Object.keys(n).forEach(e=>{t[e]=n[e]}),Object.defineProperty(t,"innerHTML",r)},e.one(`sourceset`,t.resetSourceWatch_)},Gl=Object.defineProperty({},"src",{get(){return this.hasAttribute(`src`)?fs(x.Element.prototype.getAttribute.call(this,`src`)):``},set(e){return x.Element.prototype.setAttribute.call(this,`src`,e),e}}),Kl=e=>Hl([e.el(),x.HTMLMediaElement.prototype,Gl],`src`),ql=function(e){if(!e.featuresSourceset)return;let t=e.el();if(t.resetSourceset_)return;let n=Kl(e),r=t.setAttribute,i=t.load;Object.defineProperty(t,"src",W(n,{set:r=>{let i=n.set.call(t,r);return e.triggerSourceset(t.src),i}})),t.setAttribute=(n,i)=>{let a=r.call(t,n,i);return/src/i.test(n)&&e.triggerSourceset(t.src),a},t.load=()=>{let n=i.call(t);return Bl(e)||(e.triggerSourceset(``),Wl(e)),n},t.currentSrc?e.triggerSourceset(t.currentSrc):Bl(e)||Wl(e),t.resetSourceset_=()=>{t.resetSourceset_=null,t.load=i,t.setAttribute=r,Object.defineProperty(t,"src",n),t.resetSourceWatch_&&t.resetSourceWatch_()}};class Y extends J{constructor(e,t){super(e,t);let n=e.source,r=!1;if(this.featuresVideoFrameCallback=this.featuresVideoFrameCallback&&this.el_.tagName===`VIDEO`,n&&(this.el_.currentSrc!==n.src||e.tag&&e.tag.initNetworkState_===3)?this.setSource(n):this.handleLateInit_(this.el_),e.enableSourceset&&this.setupSourcesetHandling_(),this.isScrubbing_=!1,this.el_.hasChildNodes()){let e=this.el_.childNodes,t=e.length,n=[];for(;t--;){let i=e[t];i.nodeName.toLowerCase()===`track`&&(this.featuresNativeTextTracks?(this.remoteTextTrackEls().addTrackElement_(i),this.remoteTextTracks().addTrack(i.track),this.textTracks().addTrack(i.track),!r&&!this.el_.hasAttribute(`crossorigin`)&&ms(i.src)&&(r=!0)):n.push(i))}for(let e=0;e<n.length;e++)this.el_.removeChild(n[e])}this.proxyNativeTracks_(),this.featuresNativeTextTracks&&r&&U.warn(`Text Tracks are being loaded from another origin but the crossorigin attribute isn't used.
161
161
  This may prevent text tracks from loading.`),this.restoreMetadataTracksInIOSNativePlayer_(),(aa||ta)&&e.nativeControlsForTouch===!0&&this.setControls(!0),this.proxyWebkitFullscreen_(),this.triggerReady()}dispose(){this.el_&&this.el_.resetSourceset_&&this.el_.resetSourceset_(),Y.disposeMediaElement(this.el_),this.options_=null,super.dispose()}setupSourcesetHandling_(){ql(this)}restoreMetadataTracksInIOSNativePlayer_(){let e=this.textTracks(),t,n=()=>{t=[];for(let n=0;n<e.length;n++){let r=e[n];r.kind===`metadata`&&t.push({track:r,storedMode:r.mode})}};n(),e.addEventListener(`change`,n),this.on(`dispose`,()=>e.removeEventListener(`change`,n));let r=()=>{for(let e=0;e<t.length;e++){let n=t[e];n.track.mode===`disabled`&&n.track.mode!==n.storedMode&&(n.track.mode=n.storedMode)}e.removeEventListener(`change`,r)};this.on(`webkitbeginfullscreen`,()=>{e.removeEventListener(`change`,n),e.removeEventListener(`change`,r),e.addEventListener(`change`,r)}),this.on(`webkitendfullscreen`,()=>{e.removeEventListener(`change`,n),e.addEventListener(`change`,n),e.removeEventListener(`change`,r)})}overrideNative_(e,t){if(t!==this[`featuresNative${e}Tracks`])return;let n=e.toLowerCase();this[`${n}TracksListeners_`]&&Object.keys(this[`${n}TracksListeners_`]).forEach(e=>{this.el()[`${n}Tracks`].removeEventListener(e,this[`${n}TracksListeners_`][e])}),this[`featuresNative${e}Tracks`]=!t,this[`${n}TracksListeners_`]=null,this.proxyNativeTracksForType_(n)}overrideNativeAudioTracks(e){this.overrideNative_(`Audio`,e)}overrideNativeVideoTracks(e){this.overrideNative_(`Video`,e)}proxyNativeTracksForType_(e){let t=Ss[e],n=this.el()[t.getterName],r=this[t.getterName]();if(!this[`featuresNative${t.capitalName}Tracks`]||!n||!n.addEventListener)return;let i={change:t=>{let n={type:`change`,target:r,currentTarget:r,srcElement:r};r.trigger(n),e===`text`&&this[Cs.remoteText.getterName]().trigger(n)},addtrack(e){r.addTrack(e.track)},removetrack(e){r.removeTrack(e.track)}},a=function(){let e=[];for(let t=0;t<r.length;t++){let i=!1;for(let e=0;e<n.length;e++)if(n[e]===r[t]){i=!0;break}i||e.push(r[t])}for(;e.length;)r.removeTrack(e.shift())};this[t.getterName+`Listeners_`]=i,Object.keys(i).forEach(e=>{let t=i[e];n.addEventListener(e,t),this.on(`dispose`,r=>n.removeEventListener(e,t))}),this.on(`loadstart`,a),this.on(`dispose`,e=>this.off(`loadstart`,a))}proxyNativeTracks_(){Ss.names.forEach(e=>{this.proxyNativeTracksForType_(e)})}createEl(){let e=this.options_.tag;if(!e||!(this.options_.playerElIngest||this.movingMediaElementInDOM)){if(e){let t=e.cloneNode(!0);e.parentNode&&e.parentNode.insertBefore(t,e),Y.disposeMediaElement(e),e=t}else{e=F.createElement(`video`);let t=W({},this.options_.tag&&Ca(this.options_.tag));aa&&this.options_.nativeControlsForTouch===!0||delete t.controls,Sa(e,Object.assign(t,{id:this.options_.techId,class:`vjs-tech`}))}e.playerId=this.options_.playerId}this.options_.preload!==void 0&&Ta(e,`preload`,this.options_.preload),this.options_.disablePictureInPicture!==void 0&&(e.disablePictureInPicture=this.options_.disablePictureInPicture);let t=[`loop`,`muted`,`playsinline`,`autoplay`];for(let n=0;n<t.length;n++){let r=t[n],i=this.options_[r];i!==void 0&&(i?Ta(e,r,r):Ea(e,r),e[r]=i)}return e}handleLateInit_(e){if(e.networkState===0||e.networkState===3)return;if(e.readyState===0){let e=!1,t=function(){e=!0};this.on(`loadstart`,t);let n=function(){e||this.trigger(`loadstart`)};this.on(`loadedmetadata`,n),this.ready(function(){this.off(`loadstart`,t),this.off(`loadedmetadata`,n),e||this.trigger(`loadstart`)});return}let t=[`loadstart`];t.push(`loadedmetadata`),e.readyState>=2&&t.push(`loadeddata`),e.readyState>=3&&t.push(`canplay`),e.readyState>=4&&t.push(`canplaythrough`),this.ready(function(){t.forEach(function(e){this.trigger(e)},this)})}setScrubbing(e){this.isScrubbing_=e}scrubbing(){return this.isScrubbing_}setCurrentTime(e){try{this.isScrubbing_&&this.el_.fastSeek&&ca?this.el_.fastSeek(e):this.el_.currentTime=e}catch(e){U(e,`Video is not ready. (Video.js)`)}}duration(){if(this.el_.duration===1/0&&Hi&&qi&&this.el_.currentTime===0){let e=()=>{this.el_.currentTime>0&&(this.el_.duration===1/0&&this.trigger(`durationchange`),this.off(`timeupdate`,e))};return this.on(`timeupdate`,e),NaN}return this.el_.duration||NaN}width(){return this.el_.offsetWidth}height(){return this.el_.offsetHeight}proxyWebkitFullscreen_(){if(!(`webkitDisplayingFullscreen`in this.el_))return;let e=function(){this.trigger(`fullscreenchange`,{isFullscreen:!1}),this.el_.controls&&!this.options_.nativeControlsForTouch&&this.controls()&&(this.el_.controls=!1)},t=function(){`webkitPresentationMode`in this.el_&&this.el_.webkitPresentationMode!==`picture-in-picture`&&(this.one(`webkitendfullscreen`,e),this.trigger(`fullscreenchange`,{isFullscreen:!0,nativeIOSFullscreen:!0}))};this.on(`webkitbeginfullscreen`,t),this.on(`dispose`,()=>{this.off(`webkitbeginfullscreen`,t),this.off(`webkitendfullscreen`,e)})}supportsFullScreen(){return typeof this.el_.webkitEnterFullScreen==`function`}enterFullScreen(){let e=this.el_;if(e.paused&&e.networkState<=e.HAVE_METADATA)qo(this.el_.play()),this.setTimeout(function(){e.pause();try{e.webkitEnterFullScreen()}catch(e){this.trigger(`fullscreenerror`,e)}},0);else try{e.webkitEnterFullScreen()}catch(e){this.trigger(`fullscreenerror`,e)}}exitFullScreen(){this.el_.webkitDisplayingFullscreen?this.el_.webkitExitFullScreen():this.trigger(`fullscreenerror`,Error(`The video is not fullscreen`))}requestPictureInPicture(){return this.el_.requestPictureInPicture()}requestVideoFrameCallback(e){return this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.requestVideoFrameCallback(e):super.requestVideoFrameCallback(e)}cancelVideoFrameCallback(e){this.featuresVideoFrameCallback&&!this.el_.webkitKeys?this.el_.cancelVideoFrameCallback(e):super.cancelVideoFrameCallback(e)}src(e){if(e===void 0)return this.el_.src;this.setSrc(e)}addSourceElement(e,t){if(!e)return U.error(`Invalid source URL.`),!1;let n={src:e};t&&(n.type=t);let r=G(`source`,{},n);return this.el_.appendChild(r),!0}removeSourceElement(e){if(!e)return U.error(`Source URL is required to remove the source element.`),!1;let t=this.el_.querySelectorAll(`source`);for(let n of t)if(n.src===e)return this.el_.removeChild(n),!0;return U.warn(`No matching source element found with src: ${e}`),!1}reset(){Y.resetMediaElement(this.el_)}currentSrc(){return this.currentSource_?this.currentSource_.src:this.el_.currentSrc}setControls(e){this.el_.controls=!!e}addTextTrack(e,t,n){return this.featuresNativeTextTracks?this.el_.addTextTrack(e,t,n):super.addTextTrack(e,t,n)}createRemoteTextTrack(e){if(!this.featuresNativeTextTracks)return super.createRemoteTextTrack(e);let t=F.createElement(`track`);return e.kind&&(t.kind=e.kind),e.label&&(t.label=e.label),(e.language||e.srclang)&&(t.srclang=e.language||e.srclang),e.default&&(t.default=e.default),e.id&&(t.id=e.id),e.src&&(t.src=e.src),t}addRemoteTextTrack(e,t){let n=super.addRemoteTextTrack(e,t);return this.featuresNativeTextTracks&&this.el().appendChild(n),n}removeRemoteTextTrack(e){if(super.removeRemoteTextTrack(e),this.featuresNativeTextTracks){let t=this.$$(`track`),n=t.length;for(;n--;)(e===t[n]||e===t[n].track)&&this.el().removeChild(t[n])}}getVideoPlaybackQuality(){if(typeof this.el().getVideoPlaybackQuality==`function`)return this.el().getVideoPlaybackQuality();let e={};return this.el().webkitDroppedFrameCount!==void 0&&this.el().webkitDecodedFrameCount!==void 0&&(e.droppedVideoFrames=this.el().webkitDroppedFrameCount,e.totalVideoFrames=this.el().webkitDecodedFrameCount),x.performance&&(e.creationTime=x.performance.now()),e}}Ri(Y,`TEST_VID`,function(){if(!fa())return;let e=F.createElement(`video`),t=F.createElement(`track`);return t.kind=`captions`,t.srclang=`en`,t.label=`English`,e.appendChild(t),e}),Y.isSupported=function(){try{Y.TEST_VID.volume=.5}catch{return!1}return!!(Y.TEST_VID&&Y.TEST_VID.canPlayType)},Y.canPlayType=function(e){return Y.TEST_VID.canPlayType(e)},Y.canPlaySource=function(e,t){return Y.canPlayType(e.type)},Y.canControlVolume=function(){try{let e=Y.TEST_VID.volume;Y.TEST_VID.volume=e/2+.1;let t=e!==Y.TEST_VID.volume;return t&&sa?(x.setTimeout(()=>{Y&&Y.prototype&&(Y.prototype.featuresVolumeControl=e!==Y.TEST_VID.volume)}),!1):t}catch{return!1}},Y.canMuteVolume=function(){try{let e=Y.TEST_VID.muted;return Y.TEST_VID.muted=!e,Y.TEST_VID.muted?Ta(Y.TEST_VID,`muted`,`muted`):Ea(Y.TEST_VID,`muted`,`muted`),e!==Y.TEST_VID.muted}catch{return!1}},Y.canControlPlaybackRate=function(){if(Hi&&qi&&Yi<58)return!1;try{let e=Y.TEST_VID.playbackRate;return Y.TEST_VID.playbackRate=e/2+.1,e!==Y.TEST_VID.playbackRate}catch{return!1}},Y.canOverrideAttributes=function(){try{let e=()=>{};Object.defineProperty(F.createElement(`video`),"src",{get:e,set:e}),Object.defineProperty(F.createElement(`audio`),"src",{get:e,set:e}),Object.defineProperty(F.createElement(`video`),"innerHTML",{get:e,set:e}),Object.defineProperty(F.createElement(`audio`),"innerHTML",{get:e,set:e})}catch{return!1}return!0},Y.supportsNativeTextTracks=function(){return ca||sa&&qi},Y.supportsNativeVideoTracks=function(){return!!(Y.TEST_VID&&Y.TEST_VID.videoTracks)},Y.supportsNativeAudioTracks=function(){return!!(Y.TEST_VID&&Y.TEST_VID.audioTracks)},Y.Events=[`loadstart`,`suspend`,`abort`,`error`,`emptied`,`stalled`,`loadedmetadata`,`loadeddata`,`canplay`,`canplaythrough`,`playing`,`waiting`,`seeking`,`seeked`,`ended`,`durationchange`,`timeupdate`,`progress`,`play`,`pause`,`ratechange`,`resize`,`volumechange`],[[`featuresMuteControl`,`canMuteVolume`],[`featuresPlaybackRate`,`canControlPlaybackRate`],[`featuresSourceset`,`canOverrideAttributes`],[`featuresNativeTextTracks`,`supportsNativeTextTracks`],[`featuresNativeVideoTracks`,`supportsNativeVideoTracks`],[`featuresNativeAudioTracks`,`supportsNativeAudioTracks`]].forEach(function([e,t]){Ri(Y.prototype,e,()=>Y[t](),!0)}),Y.prototype.featuresVolumeControl=Y.canControlVolume(),Y.prototype.movingMediaElementInDOM=!sa,Y.prototype.featuresFullscreenResize=!0,Y.prototype.featuresProgressEvents=!0,Y.prototype.featuresTimeupdateEvents=!0,Y.prototype.featuresVideoFrameCallback=!!(Y.TEST_VID&&Y.TEST_VID.requestVideoFrameCallback),Y.disposeMediaElement=function(e){if(e){for(e.parentNode&&e.parentNode.removeChild(e);e.hasChildNodes();)e.removeChild(e.firstChild);e.removeAttribute(`src`),typeof e.load==`function`&&(function(){try{e.load()}catch{}})()}},Y.resetMediaElement=function(e){if(!e)return;let t=e.querySelectorAll(`source`),n=t.length;for(;n--;)e.removeChild(t[n]);e.removeAttribute(`src`),typeof e.load==`function`&&(function(){try{e.load()}catch{}})()},[`muted`,`defaultMuted`,`autoplay`,`controls`,`loop`,`playsinline`].forEach(function(e){Y.prototype[e]=function(){return this.el_[e]||this.el_.hasAttribute(e)}}),[`muted`,`defaultMuted`,`autoplay`,`loop`,`playsinline`].forEach(function(e){Y.prototype[`set`+jo(e)]=function(t){this.el_[e]=t,t?this.el_.setAttribute(e,e):this.el_.removeAttribute(e)}}),[`paused`,`currentTime`,`buffered`,`volume`,`poster`,`preload`,`error`,`seeking`,`seekable`,`ended`,`playbackRate`,`defaultPlaybackRate`,`disablePictureInPicture`,`played`,`networkState`,`readyState`,`videoWidth`,`videoHeight`,`crossOrigin`].forEach(function(e){Y.prototype[e]=function(){return this.el_[e]}}),[`volume`,`src`,`poster`,`preload`,`playbackRate`,`defaultPlaybackRate`,`disablePictureInPicture`,`crossOrigin`].forEach(function(e){Y.prototype[`set`+jo(e)]=function(t){this.el_[e]=t}}),[`pause`,`load`,`play`].forEach(function(e){Y.prototype[e]=function(){return this.el_[e]()}}),J.withSourceHandlers(Y),Y.nativeSourceHandler={},Y.nativeSourceHandler.canPlayType=function(e){try{return Y.TEST_VID.canPlayType(e)}catch{return``}},Y.nativeSourceHandler.canHandleSource=function(e,t){if(e.type)return Y.nativeSourceHandler.canPlayType(e.type);if(e.src){let t=ps(e.src);return Y.nativeSourceHandler.canPlayType(`video/${t}`)}return``},Y.nativeSourceHandler.handleSource=function(e,t,n){t.setSrc(e.src)},Y.nativeSourceHandler.dispose=function(){},Y.registerSourceHandler(Y.nativeSourceHandler),J.registerTech(`Html5`,Y);const Jl=[`progress`,`abort`,`suspend`,`emptied`,`stalled`,`loadedmetadata`,`loadeddata`,`timeupdate`,`resize`,`volumechange`,`texttrackchange`],Yl={canplay:`CanPlay`,canplaythrough:`CanPlayThrough`,playing:`Playing`,seeked:`Seeked`},Xl=[`tiny`,`xsmall`,`small`,`medium`,`large`,`xlarge`,`huge`],Zl={};Xl.forEach(e=>{let t=e.charAt(0)===`x`?`x-${e.substring(1)}`:e;Zl[e]=`vjs-layout-${t}`});const Ql={tiny:210,xsmall:320,small:425,medium:768,large:1440,xlarge:2560,huge:1/0};class X extends q{constructor(e,t,n){if(e.id=e.id||t.id||`vjs_video_${Qa()}`,t=Object.assign(X.getTagSettings(e),t),t.initChildren=!1,t.createEl=!1,t.evented=!1,t.reportTouchActivity=!1,!t.language){let n=e.closest(`[lang]`);n&&(t.language=n.getAttribute(`lang`))}if(super(null,t,n),this.boundDocumentFullscreenChange_=e=>this.documentFullscreenChange_(e),this.boundFullWindowOnEscKey_=e=>this.fullWindowOnEscKey(e),this.boundUpdateStyleEl_=e=>this.updateStyleEl_(e),this.boundApplyInitTime_=e=>this.applyInitTime_(e),this.boundUpdateCurrentBreakpoint_=e=>this.updateCurrentBreakpoint_(e),this.boundHandleTechClick_=e=>this.handleTechClick_(e),this.boundHandleTechDoubleClick_=e=>this.handleTechDoubleClick_(e),this.boundHandleTechTouchStart_=e=>this.handleTechTouchStart_(e),this.boundHandleTechTouchMove_=e=>this.handleTechTouchMove_(e),this.boundHandleTechTouchEnd_=e=>this.handleTechTouchEnd_(e),this.boundHandleTechTap_=e=>this.handleTechTap_(e),this.boundUpdatePlayerHeightOnAudioOnlyMode_=e=>this.updatePlayerHeightOnAudioOnlyMode_(e),this.isFullscreen_=!1,this.log=Ai(this.id_),this.fsApi_=Ci,this.isPosterFromTech_=!1,this.queuedCallbacks_=[],this.isReady_=!1,this.hasStarted_=!1,this.userActive_=!1,this.debugEnabled_=!1,this.audioOnlyMode_=!1,this.audioPosterMode_=!1,this.audioOnlyCache_={controlBarHeight:null,playerHeight:null,hiddenChildren:[]},!this.options_||!this.options_.techOrder||!this.options_.techOrder.length)throw Error(`No techOrder specified. Did you overwrite videojs.options instead of just changing the properties you want to override?`);if(this.tag=e,this.tagAttributes=e&&Ca(e),this.language(this.options_.language),t.languages){let e={};Object.getOwnPropertyNames(t.languages).forEach(function(n){e[n.toLowerCase()]=t.languages[n]}),this.languages_=e}else this.languages_=X.prototype.options_.languages;this.resetCache_(),this.poster_=t.poster||``,this.controls_=!!t.controls,e.controls=!1,e.removeAttribute(`controls`),this.changingSrc_=!1,this.playCallbacks_=[],this.playTerminatedQueue_=[],e.hasAttribute(`autoplay`)?this.autoplay(!0):this.autoplay(this.options_.autoplay),t.plugins&&Object.keys(t.plugins).forEach(e=>{if(typeof this[e]!=`function`)throw Error(`plugin "${e}" does not exist`)}),this.scrubbing_=!1,this.el_=this.createEl(),Do(this,{eventBusKey:`el_`}),this.fsApi_.requestFullscreen&&(ao(F,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),this.on(this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_)),this.fluid_&&this.on([`playerreset`,`resize`],this.boundUpdateStyleEl_);let r=W(this.options_);if(t.plugins&&Object.keys(t.plugins).forEach(e=>{this[e](t.plugins[e])}),t.debug&&this.debug(!0),this.options_.playerOptions=r,this.middleware_=[],this.playbackRates(t.playbackRates),t.experimentalSvgIcons){let e=new x.DOMParser().parseFromString(Js,`image/svg+xml`);if(e.querySelector(`parsererror`))U.warn(`Failed to load SVG Icons. Falling back to Font Icons.`),this.options_.experimentalSvgIcons=null;else{let t=e.documentElement;t.style.display=`none`,this.el_.appendChild(t),this.addClass(`vjs-svg-icons-enabled`)}}this.initChildren(),this.isAudio(e.nodeName.toLowerCase()===`audio`),this.controls()?this.addClass(`vjs-controls-enabled`):this.addClass(`vjs-controls-disabled`),this.el_.setAttribute(`role`,`region`),this.isAudio()?this.el_.setAttribute(`aria-label`,this.localize(`Audio Player`)):this.el_.setAttribute(`aria-label`,this.localize(`Video Player`)),this.isAudio()&&this.addClass(`vjs-audio`),t.spatialNavigation&&t.spatialNavigation.enabled&&(this.spatialNavigation=new Zs(this),this.addClass(`vjs-spatial-navigation-enabled`)),aa&&this.addClass(`vjs-touch-enabled`),sa||this.addClass(`vjs-workinghover`),X.players[this.id_]=this;let i=_i.split(`.`)[0];this.addClass(`vjs-v${i}`),this.userActive(!0),this.reportUserActivity(),this.one(`play`,e=>this.listenForUserActivity_(e)),this.on(`keydown`,e=>this.handleKeyDown(e)),this.on(`languagechange`,e=>this.handleLanguagechange(e)),this.breakpoints(this.options_.breakpoints),this.responsive(this.options_.responsive),this.on(`ready`,()=>{this.audioPosterMode(this.options_.audioPosterMode),this.audioOnlyMode(this.options_.audioOnlyMode)})}dispose(){this.trigger(`dispose`),this.off(`dispose`),oo(F,this.fsApi_.fullscreenchange,this.boundDocumentFullscreenChange_),oo(F,`keydown`,this.boundFullWindowOnEscKey_),this.styleEl_&&this.styleEl_.parentNode&&(this.styleEl_.parentNode.removeChild(this.styleEl_),this.styleEl_=null),X.players[this.id_]=null,this.tag&&this.tag.player&&(this.tag.player=null),this.el_&&this.el_.player&&(this.el_.player=null),this.tech_&&(this.tech_.dispose(),this.isPosterFromTech_=!1,this.poster_=``),this.playerElIngest_&&=null,this.tag&&=null,Bs(this),ws.names.forEach(e=>{let t=ws[e],n=this[t.getterName]();n&&n.off&&n.off()}),super.dispose({restoreEl:this.options_.restoreEl})}createEl(){let e=this.tag,t,n=this.playerElIngest_=e.parentNode&&e.parentNode.hasAttribute&&e.parentNode.hasAttribute(`data-vjs-player`),r=this.tag.tagName.toLowerCase()===`video-js`;n?t=this.el_=e.parentNode:r||(t=this.el_=super.createEl(`div`));let i=Ca(e);if(r){for(t=this.el_=e,e=this.tag=F.createElement(`video`);t.children.length;)e.appendChild(t.firstChild);va(t,`video-js`)||ya(t,`video-js`),t.appendChild(e),n=this.playerElIngest_=t,Object.keys(t).forEach(n=>{try{e[n]=t[n]}catch{}})}e.setAttribute(`tabindex`,`-1`),i.tabindex=`-1`,qi&&$i&&(e.setAttribute(`role`,`application`),i.role=`application`),e.removeAttribute(`width`),e.removeAttribute(`height`),`width`in i&&delete i.width,`height`in i&&delete i.height,Object.getOwnPropertyNames(i).forEach(function(n){r&&n===`class`||t.setAttribute(n,i[n]),r&&e.setAttribute(n,i[n])}),e.playerId=e.id,e.id+=`_html5_api`,e.className=`vjs-tech`,e.player=t.player=this,this.addClass(`vjs-paused`);let a=[`IS_SMART_TV`,`IS_TIZEN`,`IS_WEBOS`,`IS_ANDROID`,`IS_IPAD`,`IS_IPHONE`,`IS_CHROMECAST_RECEIVER`].filter(e=>la[e]).map(e=>`vjs-device-`+e.substring(3).toLowerCase().replace(/\_/g,`-`));if(this.addClass(...a),x.VIDEOJS_NO_DYNAMIC_STYLE!==!0){this.styleEl_=Ja(`vjs-styles-dimensions`);let e=Ra(`.vjs-styles-defaults`),t=Ra(`head`);t.insertBefore(this.styleEl_,e?e.nextSibling:t.firstChild)}this.fill_=!1,this.fluid_=!1,this.width(this.options_.width),this.height(this.options_.height),this.fill(this.options_.fill),this.fluid(this.options_.fluid),this.aspectRatio(this.options_.aspectRatio),this.crossOrigin(this.options_.crossOrigin||this.options_.crossorigin);let o=e.getElementsByTagName(`a`);for(let e=0;e<o.length;e++){let t=o.item(e);ya(t,`vjs-hidden`),t.setAttribute(`hidden`,`hidden`)}return e.initNetworkState_=e.networkState,e.parentNode&&!n&&e.parentNode.insertBefore(t,e),_a(e,t),this.children_.unshift(e),this.el_.setAttribute(`lang`,this.language_),this.el_.setAttribute(`translate`,`no`),this.el_=t,t}crossOrigin(e){if(e===void 0)return this.techGet_(`crossOrigin`);e!==null&&e!==`anonymous`&&e!==`use-credentials`?U.warn(`crossOrigin must be null, "anonymous" or "use-credentials", given "${e}"`):(this.techCall_(`setCrossOrigin`,e),this.posterImage&&this.posterImage.crossOrigin(e))}width(e){return this.dimension(`width`,e)}height(e){return this.dimension(`height`,e)}dimension(e,t){let n=e+`_`;if(t===void 0)return this[n]||0;if(t===``||t===`auto`){this[n]=void 0,this.updateStyleEl_();return}let r=parseFloat(t);isNaN(r)?U.error(`Improper value "${t}" supplied for for ${e}`):(this[n]=r,this.updateStyleEl_())}fluid(e){if(e===void 0)return!!this.fluid_;this.fluid_=!!e,vo(this)&&this.off([`playerreset`,`resize`],this.boundUpdateStyleEl_),e?(this.addClass(`vjs-fluid`),this.fill(!1),yo(this,()=>{this.on([`playerreset`,`resize`],this.boundUpdateStyleEl_)})):this.removeClass(`vjs-fluid`),this.updateStyleEl_()}fill(e){if(e===void 0)return!!this.fill_;this.fill_=!!e,e?(this.addClass(`vjs-fill`),this.fluid(!1)):this.removeClass(`vjs-fill`)}aspectRatio(e){if(e===void 0)return this.aspectRatio_;if(!/^\d+\:\d+$/.test(e))throw Error(`Improper value supplied for aspect ratio. The format should be width:height, for example 16:9.`);this.aspectRatio_=e,this.fluid(!0),this.updateStyleEl_()}updateStyleEl_(){if(x.VIDEOJS_NO_DYNAMIC_STYLE===!0){let e=typeof this.width_==`number`?this.width_:this.options_.width,t=typeof this.height_==`number`?this.height_:this.options_.height,n=this.tech_&&this.tech_.el();n&&(e>=0&&(n.width=e),t>=0&&(n.height=t));return}let e,t,n,r;n=this.aspectRatio_!==void 0&&this.aspectRatio_!==`auto`?this.aspectRatio_:this.videoWidth()>0?this.videoWidth()+`:`+this.videoHeight():`16:9`;let i=n.split(`:`),a=i[1]/i[0];e=this.width_===void 0?this.height_===void 0?this.videoWidth()||300:this.height_/a:this.width_,t=this.height_===void 0?e*a:this.height_,r=/^[^a-zA-Z]/.test(this.id())?`dimensions-`+this.id():this.id()+`-dimensions`,this.addClass(r),Ya(this.styleEl_,`
162
162
  .${r} {
163
163
  width: ${e}px;
@@ -184,7 +184,7 @@ See https://github.com/videojs/video.js/issues/2617 for more info.
184
184
  `+e},Ef=function(e){return e.toString().replace(/^function.+?{/,``).slice(0,-1)};var Df=wf(Tf(Ef(function(){var e=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},t=function(){this.init=function(){var e={};this.on=function(t,n){e[t]||(e[t]=[]),e[t]=e[t].concat(n)},this.off=function(t,n){var r;return e[t]?(r=e[t].indexOf(n),e[t]=e[t].slice(),e[t].splice(r,1),r>-1):!1},this.trigger=function(t){var n=e[t],r,i,a;if(n){if(arguments.length===2)for(i=n.length,r=0;r<i;++r)n[r].call(this,arguments[1]);else{for(a=[],r=arguments.length,r=1;r<arguments.length;++r)a.push(arguments[r]);for(i=n.length,r=0;r<i;++r)n[r].apply(this,a)}}},this.dispose=function(){e={}}}};t.prototype.pipe=function(e){return this.on(`data`,function(t){e.push(t)}),this.on(`done`,function(t){e.flush(t)}),this.on(`partialdone`,function(t){e.partialFlush(t)}),this.on(`endedtimeline`,function(t){e.endTimeline(t)}),this.on(`reset`,function(t){e.reset(t)}),e},t.prototype.push=function(e){this.trigger(`data`,e)},t.prototype.flush=function(e){this.trigger(`done`,e)},t.prototype.partialFlush=function(e){this.trigger(`partialdone`,e)},t.prototype.endTimeline=function(e){this.trigger(`endedtimeline`,e)},t.prototype.reset=function(e){this.trigger(`reset`,e)};var n=t,r=2**32,i={getUint64:function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),n;return t.getBigUint64?(n=t.getBigUint64(0),n<2**53-1?Number(n):n):t.getUint32(0)*r+t.getUint32(4)},MAX_UINT32:r},a=i.MAX_UINT32,o,s,c,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O,ee,k,A,te,ne,re,ie,j,ae,oe,se,ce,le;(function(){var e;if(O={avc1:[],avcC:[],btrt:[],dinf:[],dref:[],esds:[],ftyp:[],hdlr:[],mdat:[],mdhd:[],mdia:[],mfhd:[],minf:[],moof:[],moov:[],mp4a:[],mvex:[],mvhd:[],pasp:[],sdtp:[],smhd:[],stbl:[],stco:[],stsc:[],stsd:[],stsz:[],stts:[],styp:[],tfdt:[],tfhd:[],traf:[],trak:[],trun:[],trex:[],tkhd:[],vmhd:[]},typeof Uint8Array<`u`){for(e in O)O.hasOwnProperty(e)&&(O[e]=[e.charCodeAt(0),e.charCodeAt(1),e.charCodeAt(2),e.charCodeAt(3)]);ee=new Uint8Array([105,115,111,109]),A=new Uint8Array([97,118,99,49]),k=new Uint8Array([0,0,0,1]),te=new Uint8Array([0,0,0,0,0,0,0,0,118,105,100,101,0,0,0,0,0,0,0,0,0,0,0,0,86,105,100,101,111,72,97,110,100,108,101,114,0]),ne=new Uint8Array([0,0,0,0,0,0,0,0,115,111,117,110,0,0,0,0,0,0,0,0,0,0,0,0,83,111,117,110,100,72,97,110,100,108,101,114,0]),re={video:te,audio:ne},ae=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,12,117,114,108,32,0,0,0,1]),j=new Uint8Array([0,0,0,0,0,0,0,0]),oe=new Uint8Array([0,0,0,0,0,0,0,0]),se=oe,ce=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0]),le=oe,ie=new Uint8Array([0,0,0,1,0,0,0,0,0,0,0,0])}})(),o=function(e){for(var t=[],n=0,r=1,i,a;r<arguments.length;r++)t.push(arguments[r]);for(r=t.length;r--;)n+=t[r].byteLength;for(i=new Uint8Array(n+8),a=new DataView(i.buffer,i.byteOffset,i.byteLength),a.setUint32(0,i.byteLength),i.set(e,4),r=0,n=8;r<t.length;r++)i.set(t[r],n),n+=t[r].byteLength;return i},s=function(){return o(O.dinf,o(O.dref,ae))},c=function(e){return o(O.esds,new Uint8Array([0,0,0,0,3,25,0,0,0,4,17,64,21,0,6,0,0,0,218,192,0,0,218,192,5,2,e.audioobjecttype<<3|e.samplingfrequencyindex>>>1,e.samplingfrequencyindex<<7|e.channelcount<<3,6,1,2]))},l=function(){return o(O.ftyp,ee,k,ee,A)},x=function(e){return o(O.hdlr,re[e])},u=function(e){return o(O.mdat,e)},b=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,2,0,0,0,3,0,1,95,144,e.duration>>>24&255,e.duration>>>16&255,e.duration>>>8&255,e.duration&255,85,196,0,0]);return e.samplerate&&(t[12]=e.samplerate>>>24&255,t[13]=e.samplerate>>>16&255,t[14]=e.samplerate>>>8&255,t[15]=e.samplerate&255),o(O.mdhd,t)},y=function(e){return o(O.mdia,b(e),x(e.type),f(e))},d=function(e){return o(O.mfhd,new Uint8Array([0,0,0,0,(e&4278190080)>>24,(e&16711680)>>16,(e&65280)>>8,e&255]))},f=function(e){return o(O.minf,e.type===`video`?o(O.vmhd,ie):o(O.smhd,j),s(),C(e))},p=function(e,t){for(var n=[],r=t.length;r--;)n[r]=T(t[r]);return o.apply(null,[O.moof,d(e)].concat(n))},m=function(e){for(var t=e.length,n=[];t--;)n[t]=_(e[t]);return o.apply(null,[O.moov,g(4294967295)].concat(n,h(e)))},h=function(e){for(var t=e.length,n=[];t--;)n[t]=E(e[t]);return o.apply(null,[O.mvex].concat(n))},g=function(e){var t=new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,2,0,1,95,144,(e&4278190080)>>24,(e&16711680)>>16,(e&65280)>>8,e&255,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return o(O.mvhd,t)},S=function(e){for(var t=e.samples||[],n=new Uint8Array(4+t.length),r,i=0;i<t.length;i++)r=t[i].flags,n[i+4]=r.dependsOn<<4|r.isDependedOn<<2|r.hasRedundancy;return o(O.sdtp,n)},C=function(e){return o(O.stbl,w(e),o(O.stts,le),o(O.stsc,se),o(O.stsz,ce),o(O.stco,oe))},(function(){var e,t;w=function(n){return o(O.stsd,new Uint8Array([0,0,0,0,0,0,0,1]),n.type===`video`?e(n):t(n))},e=function(e){for(var t=e.sps||[],n=e.pps||[],r=[],i=[],a=0,s;a<t.length;a++)r.push((t[a].byteLength&65280)>>>8),r.push(t[a].byteLength&255),r=r.concat(Array.prototype.slice.call(t[a]));for(a=0;a<n.length;a++)i.push((n[a].byteLength&65280)>>>8),i.push(n[a].byteLength&255),i=i.concat(Array.prototype.slice.call(n[a]));if(s=[O.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(e.width&65280)>>8,e.width&255,(e.height&65280)>>8,e.height&255,0,72,0,0,0,72,0,0,0,0,0,0,0,1,19,118,105,100,101,111,106,115,45,99,111,110,116,114,105,98,45,104,108,115,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o(O.avcC,new Uint8Array([1,e.profileIdc,e.profileCompatibility,e.levelIdc,255,t.length].concat(r,[n.length],i))),o(O.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192]))],e.sarRatio){var c=e.sarRatio[0],l=e.sarRatio[1];s.push(o(O.pasp,new Uint8Array([(c&4278190080)>>24,(c&16711680)>>16,(c&65280)>>8,c&255,(l&4278190080)>>24,(l&16711680)>>16,(l&65280)>>8,l&255])))}return o.apply(null,s)},t=function(e){return o(O.mp4a,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,(e.channelcount&65280)>>8,e.channelcount&255,(e.samplesize&65280)>>8,e.samplesize&255,0,0,0,0,(e.samplerate&65280)>>8,e.samplerate&255,0,0]),c(e))}})(),v=function(e){var t=new Uint8Array([0,0,0,7,0,0,0,0,0,0,0,0,(e.id&4278190080)>>24,(e.id&16711680)>>16,(e.id&65280)>>8,e.id&255,0,0,0,0,(e.duration&4278190080)>>24,(e.duration&16711680)>>16,(e.duration&65280)>>8,e.duration&255,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,(e.width&65280)>>8,e.width&255,0,0,(e.height&65280)>>8,e.height&255,0,0]);return o(O.tkhd,t)},T=function(e){var t=o(O.tfhd,new Uint8Array([0,0,0,58,(e.id&4278190080)>>24,(e.id&16711680)>>16,(e.id&65280)>>8,e.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0])),n,r,i,s,c=Math.floor(e.baseMediaDecodeTime/a),l=Math.floor(e.baseMediaDecodeTime%a);return n=o(O.tfdt,new Uint8Array([1,0,0,0,c>>>24&255,c>>>16&255,c>>>8&255,c&255,l>>>24&255,l>>>16&255,l>>>8&255,l&255])),s=92,e.type===`audio`?(r=D(e,s),o(O.traf,t,n,r)):(i=S(e),r=D(e,i.length+s),o(O.traf,t,n,r,i))},_=function(e){return e.duration=e.duration||4294967295,o(O.trak,v(e),y(e))},E=function(e){var t=new Uint8Array([0,0,0,0,(e.id&4278190080)>>24,(e.id&16711680)>>16,(e.id&65280)>>8,e.id&255,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]);return e.type!==`video`&&(t[t.length-1]=0),o(O.trex,t)},(function(){var e,t,n=function(e,t){var n=0,r=0,i=0,a=0;return e.length&&(e[0].duration!==void 0&&(n=1),e[0].size!==void 0&&(r=2),e[0].flags!==void 0&&(i=4),e[0].compositionTimeOffset!==void 0&&(a=8)),[0,0,n|r|i|a,1,(e.length&4278190080)>>>24,(e.length&16711680)>>>16,(e.length&65280)>>>8,e.length&255,(t&4278190080)>>>24,(t&16711680)>>>16,(t&65280)>>>8,t&255]};t=function(e,t){var r,i,a,s=e.samples||[],c,l;for(t+=20+16*s.length,a=n(s,t),i=new Uint8Array(a.length+s.length*16),i.set(a),r=a.length,l=0;l<s.length;l++)c=s[l],i[r++]=(c.duration&4278190080)>>>24,i[r++]=(c.duration&16711680)>>>16,i[r++]=(c.duration&65280)>>>8,i[r++]=c.duration&255,i[r++]=(c.size&4278190080)>>>24,i[r++]=(c.size&16711680)>>>16,i[r++]=(c.size&65280)>>>8,i[r++]=c.size&255,i[r++]=c.flags.isLeading<<2|c.flags.dependsOn,i[r++]=c.flags.isDependedOn<<6|c.flags.hasRedundancy<<4|c.flags.paddingValue<<1|c.flags.isNonSyncSample,i[r++]=c.flags.degradationPriority&61440,i[r++]=c.flags.degradationPriority&15,i[r++]=(c.compositionTimeOffset&4278190080)>>>24,i[r++]=(c.compositionTimeOffset&16711680)>>>16,i[r++]=(c.compositionTimeOffset&65280)>>>8,i[r++]=c.compositionTimeOffset&255;return o(O.trun,i)},e=function(e,t){var r,i,a,s=e.samples||[],c,l;for(t+=20+8*s.length,a=n(s,t),r=new Uint8Array(a.length+s.length*8),r.set(a),i=a.length,l=0;l<s.length;l++)c=s[l],r[i++]=(c.duration&4278190080)>>>24,r[i++]=(c.duration&16711680)>>>16,r[i++]=(c.duration&65280)>>>8,r[i++]=c.duration&255,r[i++]=(c.size&4278190080)>>>24,r[i++]=(c.size&16711680)>>>16,r[i++]=(c.size&65280)>>>8,r[i++]=c.size&255;return o(O.trun,r)},D=function(n,r){return n.type===`audio`?e(n,r):t(n,r)}})();var M={ftyp:l,mdat:u,moof:p,moov:m,initSegment:function(e){var t=l(),n=m(e),r=new Uint8Array(t.byteLength+n.byteLength);return r.set(t),r.set(n,t.byteLength),r}},ue=function(e){var t,n,r=[],i=[];for(i.byteLength=0,i.nalCount=0,i.duration=0,r.byteLength=0,t=0;t<e.length;t++)n=e[t],n.nalUnitType===`access_unit_delimiter_rbsp`?(r.length&&(r.duration=n.dts-r.dts,i.byteLength+=r.byteLength,i.nalCount+=r.length,i.duration+=r.duration,i.push(r)),r=[n],r.byteLength=n.data.byteLength,r.pts=n.pts,r.dts=n.dts):(n.nalUnitType===`slice_layer_without_partitioning_rbsp_idr`&&(r.keyFrame=!0),r.duration=n.dts-r.dts,r.byteLength+=n.data.byteLength,r.push(n));return i.length&&(!r.duration||r.duration<=0)&&(r.duration=i[i.length-1].duration),i.byteLength+=r.byteLength,i.nalCount+=r.length,i.duration+=r.duration,i.push(r),i},de=function(e){var t,n,r=[],i=[];for(r.byteLength=0,r.nalCount=0,r.duration=0,r.pts=e[0].pts,r.dts=e[0].dts,i.byteLength=0,i.nalCount=0,i.duration=0,i.pts=e[0].pts,i.dts=e[0].dts,t=0;t<e.length;t++)n=e[t],n.keyFrame?(r.length&&(i.push(r),i.byteLength+=r.byteLength,i.nalCount+=r.nalCount,i.duration+=r.duration),r=[n],r.nalCount=n.length,r.byteLength=n.byteLength,r.pts=n.pts,r.dts=n.dts,r.duration=n.duration):(r.duration+=n.duration,r.nalCount+=n.length,r.byteLength+=n.byteLength,r.push(n));return i.length&&r.duration<=0&&(r.duration=i[i.length-1].duration),i.byteLength+=r.byteLength,i.nalCount+=r.nalCount,i.duration+=r.duration,i.push(r),i},fe=function(e){var t;return!e[0][0].keyFrame&&e.length>1&&(t=e.shift(),e.byteLength-=t.byteLength,e.nalCount-=t.nalCount,e[0][0].dts=t.dts,e[0][0].pts=t.pts,e[0][0].duration+=t.duration),e},pe=function(){return{size:0,flags:{isLeading:0,dependsOn:1,isDependedOn:0,hasRedundancy:0,degradationPriority:0,isNonSyncSample:1}}},me=function(e,t){var n=pe();return n.dataOffset=t,n.compositionTimeOffset=e.pts-e.dts,n.duration=e.duration,n.size=4*e.length,n.size+=e.byteLength,e.keyFrame&&(n.flags.dependsOn=2,n.flags.isNonSyncSample=0),n},he={groupNalsIntoFrames:ue,groupFramesIntoGops:de,extendFirstKeyFrame:fe,generateSampleTable:function(e,t){var n,r,i,a,o,s=t||0,c=[];for(n=0;n<e.length;n++)for(a=e[n],r=0;r<a.length;r++)o=a[r],i=me(o,s),s+=i.size,c.push(i);return c},concatenateNalData:function(e){var t,n,r,i,a,o,s=0,c=e.byteLength+4*e.nalCount,l=new Uint8Array(c),u=new DataView(l.buffer);for(t=0;t<e.length;t++)for(i=e[t],n=0;n<i.length;n++)for(a=i[n],r=0;r<a.length;r++)o=a[r],u.setUint32(s,o.data.byteLength),s+=4,l.set(o.data,s),s+=o.data.byteLength;return l},generateSampleTableForFrame:function(e,t){var n,r=t||0,i=[];return n=me(e,r),i.push(n),i},concatenateNalDataForFrame:function(e){var t,n,r=0,i=e.byteLength+4*e.length,a=new Uint8Array(i),o=new DataView(a.buffer);for(t=0;t<e.length;t++)n=e[t],o.setUint32(r,n.data.byteLength),r+=4,a.set(n.data,r),r+=n.data.byteLength;return a}},ge=[33,16,5,32,164,27],_e=[33,65,108,84,1,2,4,8,168,2,4,8,17,191,252],N=function(e){for(var t=[];e--;)t.push(0);return t},ve=function(e){return Object.keys(e).reduce(function(t,n){return t[n]=new Uint8Array(e[n].reduce(function(e,t){return e.concat(t)},[])),t},{})},ye,be=function(){return ye||=ve({96e3:[ge,[227,64],N(154),[56]],88200:[ge,[231],N(170),[56]],64e3:[ge,[248,192],N(240),[56]],48e3:[ge,[255,192],N(268),[55,148,128],N(54),[112]],44100:[ge,[255,192],N(268),[55,163,128],N(84),[112]],32e3:[ge,[255,192],N(268),[55,234],N(226),[112]],24e3:[ge,[255,192],N(268),[55,255,128],N(268),[111,112],N(126),[224]],16e3:[ge,[255,192],N(268),[55,255,128],N(268),[111,255],N(269),[223,108],N(195),[1,192]],12e3:[_e,N(268),[3,127,248],N(268),[6,255,240],N(268),[13,255,224],N(268),[27,253,128],N(259),[56]],11025:[_e,N(268),[3,127,248],N(268),[6,255,240],N(268),[13,255,224],N(268),[27,255,192],N(268),[55,175,128],N(108),[112]],8e3:[_e,N(268),[3,121,16],N(47),[7]]}),ye},xe=9e4,Se=function(e){return e*xe},Ce=function(e,t){return e*t},we=function(e){return e/xe},Te=function(e,t){return e/t},P={ONE_SECOND_IN_TS:xe,secondsToVideoTs:Se,secondsToAudioTs:Ce,videoTsToSeconds:we,audioTsToSeconds:Te,audioTsToVideoTs:function(e,t){return Se(Te(e,t))},videoTsToAudioTs:function(e,t){return Ce(we(e),t)},metadataTsToSeconds:function(e,t,n){return we(n?e:e-t)}},Ee=be,F=P,De=function(e){var t,n,r=0;for(t=0;t<e.length;t++)n=e[t],r+=n.data.byteLength;return r},Oe={prefixWithSilence:function(e,t,n,r){var i,a=0,o=0,s=0,c=0,l,u,d;if(t.length&&(i=F.audioTsToVideoTs(e.baseMediaDecodeTime,e.samplerate),a=Math.ceil(F.ONE_SECOND_IN_TS/(e.samplerate/1024)),n&&r&&(o=i-Math.max(n,r),s=Math.floor(o/a),c=s*a),!(s<1||c>F.ONE_SECOND_IN_TS/2))){for(l=Ee()[e.samplerate],l||=t[0].data,u=0;u<s;u++)d=t[0],t.splice(0,0,{data:l,dts:d.dts-a,pts:d.pts-a});return e.baseMediaDecodeTime-=Math.floor(F.videoTsToAudioTs(c,e.samplerate)),c}},trimAdtsFramesByEarliestDts:function(e,t,n){return t.minSegmentDts>=n?e:(t.minSegmentDts=1/0,e.filter(function(e){return e.dts>=n&&(t.minSegmentDts=Math.min(t.minSegmentDts,e.dts),t.minSegmentPts=t.minSegmentDts,!0)}))},generateSampleTable:function(e){var t,n,r=[];for(t=0;t<e.length;t++)n=e[t],r.push({size:n.data.byteLength,duration:1024});return r},concatenateFrameData:function(e){var t,n,r=0,i=new Uint8Array(De(e));for(t=0;t<e.length;t++)n=e[t],i.set(n.data,r),r+=n.data.byteLength;return i}},ke=P.ONE_SECOND_IN_TS,Ae={clearDtsInfo:function(e){delete e.minSegmentDts,delete e.maxSegmentDts,delete e.minSegmentPts,delete e.maxSegmentPts},calculateTrackBaseMediaDecodeTime:function(e,t){var n,r,i=e.minSegmentDts;return t||(i-=e.timelineStartInfo.dts),n=e.timelineStartInfo.baseMediaDecodeTime,n+=i,n=Math.max(0,n),e.type===`audio`&&(r=e.samplerate/ke,n*=r,n=Math.floor(n)),n},collectDtsInfo:function(e,t){typeof t.pts==`number`&&(e.timelineStartInfo.pts===void 0&&(e.timelineStartInfo.pts=t.pts),e.minSegmentPts=e.minSegmentPts===void 0?t.pts:Math.min(e.minSegmentPts,t.pts),e.maxSegmentPts=e.maxSegmentPts===void 0?t.pts:Math.max(e.maxSegmentPts,t.pts)),typeof t.dts==`number`&&(e.timelineStartInfo.dts===void 0&&(e.timelineStartInfo.dts=t.dts),e.minSegmentDts=e.minSegmentDts===void 0?t.dts:Math.min(e.minSegmentDts,t.dts),e.maxSegmentDts=e.maxSegmentDts===void 0?t.dts:Math.max(e.maxSegmentDts,t.dts))}},je=4,Me=128,Ne={parseSei:function(e){for(var t=0,n={payloadType:-1,payloadSize:0},r=0,i=0;t<e.byteLength&&e[t]!==Me;){for(;e[t]===255;)r+=255,t++;for(r+=e[t++];e[t]===255;)i+=255,t++;if(i+=e[t++],!n.payload&&r===je){if(String.fromCharCode(e[t+3],e[t+4],e[t+5],e[t+6])===`GA94`){n.payloadType=r,n.payloadSize=i,n.payload=e.subarray(t,t+i);break}n.payload=void 0}t+=i,r=0,i=0}return n},parseUserData:function(e){return e.payload[0]!==181||(e.payload[1]<<8|e.payload[2])!=49||String.fromCharCode(e.payload[3],e.payload[4],e.payload[5],e.payload[6])!==`GA94`||e.payload[7]!==3?null:e.payload.subarray(8,e.payload.length-1)},parseCaptionPackets:function(e,t){var n=[],r,i,a,o;if(!(t[0]&64))return n;for(i=t[0]&31,r=0;r<i;r++)a=r*3,o={type:t[a+2]&3,pts:e},t[a+2]&4&&(o.ccData=t[a+3]<<8|t[a+4],n.push(o));return n},discardEmulationPreventionBytes:function(e){for(var t=e.byteLength,n=[],r=1,i,a;r<t-2;)e[r]===0&&e[r+1]===0&&e[r+2]===3?(n.push(r+2),r+=2):r++;if(n.length===0)return e;i=t-n.length,a=new Uint8Array(i);var o=0;for(r=0;r<i;o++,r++)o===n[0]&&(o++,n.shift()),a[r]=e[o];return a},USER_DATA_REGISTERED_ITU_T_T35:je},Pe=n,Fe=Ne,Ie=function(e){e||={},Ie.prototype.init.call(this),this.parse708captions_=typeof e.parse708captions!=`boolean`||e.parse708captions,this.captionPackets_=[],this.ccStreams_=[new L(0,0),new L(0,1),new L(1,0),new L(1,1)],this.parse708captions_&&(this.cc708Stream_=new I({captionServices:e.captionServices})),this.reset(),this.ccStreams_.forEach(function(e){e.on(`data`,this.trigger.bind(this,`data`)),e.on(`partialdone`,this.trigger.bind(this,`partialdone`)),e.on(`done`,this.trigger.bind(this,`done`))},this),this.parse708captions_&&(this.cc708Stream_.on(`data`,this.trigger.bind(this,`data`)),this.cc708Stream_.on(`partialdone`,this.trigger.bind(this,`partialdone`)),this.cc708Stream_.on(`done`,this.trigger.bind(this,`done`)))};Ie.prototype=new Pe,Ie.prototype.push=function(e){var t,n,r;e.nalUnitType===`sei_rbsp`&&(t=Fe.parseSei(e.escapedRBSP),t.payload&&t.payloadType===Fe.USER_DATA_REGISTERED_ITU_T_T35&&(n=Fe.parseUserData(t),n&&(e.dts<this.latestDts_?this.ignoreNextEqualDts_=!0:e.dts===this.latestDts_&&this.ignoreNextEqualDts_?(this.numSameDts_--,this.numSameDts_||(this.ignoreNextEqualDts_=!1)):(r=Fe.parseCaptionPackets(e.pts,n),this.captionPackets_=this.captionPackets_.concat(r),this.latestDts_!==e.dts&&(this.numSameDts_=0),this.numSameDts_++,this.latestDts_=e.dts))))},Ie.prototype.flushCCStreams=function(e){this.ccStreams_.forEach(function(t){return e===`flush`?t.flush():t.partialFlush()},this)},Ie.prototype.flushStream=function(e){this.captionPackets_.length&&(this.captionPackets_.forEach(function(e,t){e.presortIndex=t}),this.captionPackets_.sort(function(e,t){return e.pts===t.pts?e.presortIndex-t.presortIndex:e.pts-t.pts}),this.captionPackets_.forEach(function(e){e.type<2?this.dispatchCea608Packet(e):this.dispatchCea708Packet(e)},this),this.captionPackets_.length=0),this.flushCCStreams(e)},Ie.prototype.flush=function(){return this.flushStream(`flush`)},Ie.prototype.partialFlush=function(){return this.flushStream(`partialFlush`)},Ie.prototype.reset=function(){this.latestDts_=null,this.ignoreNextEqualDts_=!1,this.numSameDts_=0,this.activeCea608Channel_=[null,null],this.ccStreams_.forEach(function(e){e.reset()})},Ie.prototype.dispatchCea608Packet=function(e){this.setsTextOrXDSActive(e)?this.activeCea608Channel_[e.type]=null:this.setsChannel1Active(e)?this.activeCea608Channel_[e.type]=0:this.setsChannel2Active(e)&&(this.activeCea608Channel_[e.type]=1),this.activeCea608Channel_[e.type]!==null&&this.ccStreams_[(e.type<<1)+this.activeCea608Channel_[e.type]].push(e)},Ie.prototype.setsChannel1Active=function(e){return(e.ccData&30720)==4096},Ie.prototype.setsChannel2Active=function(e){return(e.ccData&30720)==6144},Ie.prototype.setsTextOrXDSActive=function(e){return(e.ccData&28928)==256||(e.ccData&30974)==4138||(e.ccData&30974)==6186},Ie.prototype.dispatchCea708Packet=function(e){this.parse708captions_&&this.cc708Stream_.push(e)};var Le={127:9834,4128:32,4129:160,4133:8230,4138:352,4140:338,4144:9608,4145:8216,4146:8217,4147:8220,4148:8221,4149:8226,4153:8482,4154:353,4156:339,4157:8480,4159:376,4214:8539,4215:8540,4216:8541,4217:8542,4218:9168,4219:9124,4220:9123,4221:9135,4222:9126,4223:9121,4256:12600},Re=function(e){var t=Le[e]||e;return e&4096&&e===t?``:String.fromCharCode(t)},ze=function(e){return 32<=e&&e<=127||160<=e&&e<=255},Be=function(e){this.windowNum=e,this.reset()};Be.prototype.reset=function(){this.clearText(),this.pendingNewLine=!1,this.winAttr={},this.penAttr={},this.penLoc={},this.penColor={},this.visible=0,this.rowLock=0,this.columnLock=0,this.priority=0,this.relativePositioning=0,this.anchorVertical=0,this.anchorHorizontal=0,this.anchorPoint=0,this.rowCount=1,this.virtualRowCount=this.rowCount+1,this.columnCount=41,this.windowStyle=0,this.penStyle=0},Be.prototype.getText=function(){return this.rows.join(`
185
185
  `)},Be.prototype.clearText=function(){this.rows=[``],this.rowIdx=0},Be.prototype.newLine=function(e){for(this.rows.length>=this.virtualRowCount&&typeof this.beforeRowOverflow==`function`&&this.beforeRowOverflow(e),this.rows.length>0&&(this.rows.push(``),this.rowIdx++);this.rows.length>this.virtualRowCount;)this.rows.shift(),this.rowIdx--},Be.prototype.isEmpty=function(){return this.rows.length===0||this.rows.length===1&&this.rows[0]===``},Be.prototype.addText=function(e){this.rows[this.rowIdx]+=e},Be.prototype.backspace=function(){if(!this.isEmpty()){var e=this.rows[this.rowIdx];this.rows[this.rowIdx]=e.substr(0,e.length-1)}};var Ve=function(e,t,n){this.serviceNum=e,this.text=``,this.currentWindow=new Be(-1),this.windows=[],this.stream=n,typeof t==`string`&&this.createTextDecoder(t)};Ve.prototype.init=function(e,t){this.startPts=e;for(var n=0;n<8;n++)this.windows[n]=new Be(n),typeof t==`function`&&(this.windows[n].beforeRowOverflow=t)},Ve.prototype.setCurrentWindow=function(e){this.currentWindow=this.windows[e]},Ve.prototype.createTextDecoder=function(e){if(typeof TextDecoder>`u`)this.stream.trigger(`log`,{level:`warn`,message:"The `encoding` option is unsupported without TextDecoder support"});else try{this.textDecoder_=new TextDecoder(e)}catch(t){this.stream.trigger(`log`,{level:`warn`,message:`TextDecoder could not be created with `+e+` encoding. `+t})}};var I=function(e){e||={},I.prototype.init.call(this);var t=this,n=e.captionServices||{},r={},i;Object.keys(n).forEach(e=>{i=n[e],/^SERVICE/.test(e)&&(r[e]=i.encoding)}),this.serviceEncodings=r,this.current708Packet=null,this.services={},this.push=function(e){e.type===3?(t.new708Packet(),t.add708Bytes(e)):(t.current708Packet===null&&t.new708Packet(),t.add708Bytes(e))}};I.prototype=new Pe,I.prototype.new708Packet=function(){this.current708Packet!==null&&this.push708Packet(),this.current708Packet={data:[],ptsVals:[]}},I.prototype.add708Bytes=function(e){var t=e.ccData,n=t>>>8,r=t&255;this.current708Packet.ptsVals.push(e.pts),this.current708Packet.data.push(n),this.current708Packet.data.push(r)},I.prototype.push708Packet=function(){var e=this.current708Packet,t=e.data,n=null,r=null,i=0,a=t[i++];for(e.seq=a>>6,e.sizeCode=a&63;i<t.length;i++)a=t[i++],n=a>>5,r=a&31,n===7&&r>0&&(a=t[i++],n=a),this.pushServiceBlock(n,i,r),r>0&&(i+=r-1)},I.prototype.pushServiceBlock=function(e,t,n){var r,i=t,a=this.current708Packet.data,o=this.services[e];for(o||=this.initService(e,i);i<t+n&&i<a.length;i++)r=a[i],ze(r)?i=this.handleText(i,o):r===24?i=this.multiByteCharacter(i,o):r===16?i=this.extendedCommands(i,o):128<=r&&r<=135?i=this.setCurrentWindow(i,o):152<=r&&r<=159?i=this.defineWindow(i,o):r===136?i=this.clearWindows(i,o):r===140?i=this.deleteWindows(i,o):r===137?i=this.displayWindows(i,o):r===138?i=this.hideWindows(i,o):r===139?i=this.toggleWindows(i,o):r===151?i=this.setWindowAttributes(i,o):r===144?i=this.setPenAttributes(i,o):r===145?i=this.setPenColor(i,o):r===146?i=this.setPenLocation(i,o):r===143?o=this.reset(i,o):r===8?o.currentWindow.backspace():r===12?o.currentWindow.clearText():r===13?o.currentWindow.pendingNewLine=!0:r===14?o.currentWindow.clearText():r===141&&i++},I.prototype.extendedCommands=function(e,t){var n=this.current708Packet.data[++e];return ze(n)&&(e=this.handleText(e,t,{isExtended:!0})),e},I.prototype.getPts=function(e){return this.current708Packet.ptsVals[Math.floor(e/2)]},I.prototype.initService=function(e,t){var n=`SERVICE`+e,r=this,n,i;return n in this.serviceEncodings&&(i=this.serviceEncodings[n]),this.services[e]=new Ve(e,i,r),this.services[e].init(this.getPts(t),function(t){r.flushDisplayed(t,r.services[e])}),this.services[e]},I.prototype.handleText=function(e,t,n){var r=n&&n.isExtended,i=n&&n.isMultiByte,a=this.current708Packet.data,o=r?4096:0,s=a[e],c=a[e+1],l=t.currentWindow,u,d;function f(e){return e.map(e=>(`0`+(e&255).toString(16)).slice(-2)).join(``)}if(i?(d=[s,c],e++):d=[s],t.textDecoder_&&!r)u=t.textDecoder_.decode(new Uint8Array(d));else if(i){let e=f(d);u=String.fromCharCode(parseInt(e,16))}else u=Re(o|s);return l.pendingNewLine&&!l.isEmpty()&&l.newLine(this.getPts(e)),l.pendingNewLine=!1,l.addText(u),e},I.prototype.multiByteCharacter=function(e,t){var n=this.current708Packet.data,r=n[e+1],i=n[e+2];return ze(r)&&ze(i)&&(e=this.handleText(++e,t,{isMultiByte:!0})),e},I.prototype.setCurrentWindow=function(e,t){var n=this.current708Packet.data[e]&7;return t.setCurrentWindow(n),e},I.prototype.defineWindow=function(e,t){var n=this.current708Packet.data,r=n[e],i=r&7;t.setCurrentWindow(i);var a=t.currentWindow;return r=n[++e],a.visible=(r&32)>>5,a.rowLock=(r&16)>>4,a.columnLock=(r&8)>>3,a.priority=r&7,r=n[++e],a.relativePositioning=(r&128)>>7,a.anchorVertical=r&127,r=n[++e],a.anchorHorizontal=r,r=n[++e],a.anchorPoint=(r&240)>>4,a.rowCount=r&15,r=n[++e],a.columnCount=r&63,r=n[++e],a.windowStyle=(r&56)>>3,a.penStyle=r&7,a.virtualRowCount=a.rowCount+1,e},I.prototype.setWindowAttributes=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.winAttr;return r=n[++e],i.fillOpacity=(r&192)>>6,i.fillRed=(r&48)>>4,i.fillGreen=(r&12)>>2,i.fillBlue=r&3,r=n[++e],i.borderType=(r&192)>>6,i.borderRed=(r&48)>>4,i.borderGreen=(r&12)>>2,i.borderBlue=r&3,r=n[++e],i.borderType+=(r&128)>>5,i.wordWrap=(r&64)>>6,i.printDirection=(r&48)>>4,i.scrollDirection=(r&12)>>2,i.justify=r&3,r=n[++e],i.effectSpeed=(r&240)>>4,i.effectDirection=(r&12)>>2,i.displayEffect=r&3,e},I.prototype.flushDisplayed=function(e,t){for(var n=[],r=0;r<8;r++)t.windows[r].visible&&!t.windows[r].isEmpty()&&n.push(t.windows[r].getText());t.endPts=e,t.text=n.join(`
186
186
 
187
- `),this.pushCaption(t),t.startPts=e},I.prototype.pushCaption=function(e){e.text!==``&&(this.trigger(`data`,{startPts:e.startPts,endPts:e.endPts,text:e.text,stream:`cc708_`+e.serviceNum}),e.text=``,e.startPts=e.endPts)},I.prototype.displayWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&(t.windows[i].visible=1);return e},I.prototype.hideWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&(t.windows[i].visible=0);return e},I.prototype.toggleWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&(t.windows[i].visible^=1);return e},I.prototype.clearWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&t.windows[i].clearText();return e},I.prototype.deleteWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&t.windows[i].reset();return e},I.prototype.setPenAttributes=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.penAttr;return r=n[++e],i.textTag=(r&240)>>4,i.offset=(r&12)>>2,i.penSize=r&3,r=n[++e],i.italics=(r&128)>>7,i.underline=(r&64)>>6,i.edgeType=(r&56)>>3,i.fontStyle=r&7,e},I.prototype.setPenColor=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.penColor;return r=n[++e],i.fgOpacity=(r&192)>>6,i.fgRed=(r&48)>>4,i.fgGreen=(r&12)>>2,i.fgBlue=r&3,r=n[++e],i.bgOpacity=(r&192)>>6,i.bgRed=(r&48)>>4,i.bgGreen=(r&12)>>2,i.bgBlue=r&3,r=n[++e],i.edgeRed=(r&48)>>4,i.edgeGreen=(r&12)>>2,i.edgeBlue=r&3,e},I.prototype.setPenLocation=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.penLoc;return t.currentWindow.pendingNewLine=!0,r=n[++e],i.row=r&15,r=n[++e],i.column=r&63,e},I.prototype.reset=function(e,t){var n=this.getPts(e);return this.flushDisplayed(n,t),this.initService(t.serviceNum,e)};var He={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Ue=function(e){return e===null?``:(e=He[e]||e,String.fromCharCode(e))},We=14,Ge=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ke=function(){for(var e=[],t=We+1;t--;)e.push({text:``,indent:0,offset:0});return e},L=function(e,t){L.prototype.init.call(this),this.field_=e||0,this.dataChannel_=t||0,this.name_=`CC`+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(e){var t=e.ccData&32639,n,r,i,a;if(t===this.lastControlCode_)this.lastControlCode_=null;else if((t&61440)==4096?this.lastControlCode_=t:t!==this.PADDING_&&(this.lastControlCode_=null),r=t>>>8,i=t&255,t!==this.PADDING_){if(t===this.RESUME_CAPTION_LOADING_)this.mode_=`popOn`;else if(t===this.END_OF_CAPTION_)this.mode_=`popOn`,this.clearFormatting(e.pts),this.flushDisplayed(e.pts),n=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=n,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)this.mode_===`popOn`?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=Ke();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ke();else if(t===this.RESUME_DIRECT_CAPTIONING_)this.mode_!==`paintOn`&&(this.flushDisplayed(e.pts),this.displayed_=Ke()),this.mode_=`paintOn`,this.startPts_=e.pts;else if(this.isSpecialCharacter(r,i))r=(r&3)<<8,a=Ue(r|i),this[this.mode_](e.pts,a),this.column_++;else if(this.isExtCharacter(r,i))this.mode_===`popOn`?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),r=(r&3)<<8,a=Ue(r|i),this[this.mode_](e.pts,a),this.column_++;else if(this.isMidRowCode(r,i))this.clearFormatting(e.pts),this[this.mode_](e.pts,` `),this.column_++,(i&14)==14&&this.addFormatting(e.pts,[`i`]),(i&1)==1&&this.addFormatting(e.pts,[`u`]);else if(this.isOffsetControlCode(r,i)){let e=i&3;this.nonDisplayed_[this.row_].offset=e,this.column_+=e}else if(this.isPAC(r,i)){var o=Ge.indexOf(t&7968);if(this.mode_===`rollUp`&&(o-this.rollUpRows_+1<0&&(o=this.rollUpRows_-1),this.setRollUp(e.pts,o)),o!==this.row_&&o>=0&&o<=14&&(this.clearFormatting(e.pts),this.row_=o),i&1&&this.formatting_.indexOf(`u`)===-1&&this.addFormatting(e.pts,[`u`]),(t&16)==16){let e=(t&14)>>1;this.column_=e*4,this.nonDisplayed_[this.row_].indent+=e}this.isColorPAC(i)&&(i&14)==14&&this.addFormatting(e.pts,[`i`])}else this.isNormalChar(r)&&(i===0&&(i=null),a=Ue(r),a+=Ue(i),this[this.mode_](e.pts,a),this.column_+=a.length)}}};L.prototype=new Pe,L.prototype.flushDisplayed=function(e){let t=e=>{this.trigger(`log`,{level:`warn`,message:`Skipping a malformed 608 caption at index `+e+`.`})},n=[];this.displayed_.forEach((e,r)=>{if(e&&e.text&&e.text.length){try{e.text=e.text.trim()}catch{t(r)}e.text.length&&n.push({text:e.text,line:r+1,position:10+Math.min(70,e.indent*10)+e.offset*2.5})}else e??t(r)}),n.length&&this.trigger(`data`,{startPts:this.startPts_,endPts:e,content:n,stream:this.name_})},L.prototype.reset=function(){this.mode_=`popOn`,this.topRow_=0,this.startPts_=0,this.displayed_=Ke(),this.nonDisplayed_=Ke(),this.lastControlCode_=null,this.column_=0,this.row_=We,this.rollUpRows_=2,this.formatting_=[]},L.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},L.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},L.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},L.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},L.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},L.prototype.isPAC=function(e,t){return e>=this.BASE_&&e<this.BASE_+8&&t>=64&&t<=127},L.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},L.prototype.isNormalChar=function(e){return e>=32&&e<=127},L.prototype.setRollUp=function(e,t){if(this.mode_!==`rollUp`&&(this.row_=We,this.mode_=`rollUp`,this.flushDisplayed(e),this.nonDisplayed_=Ke(),this.displayed_=Ke()),t!==void 0&&t!==this.row_)for(var n=0;n<this.rollUpRows_;n++)this.displayed_[t-n]=this.displayed_[this.row_-n],this.displayed_[this.row_-n]={text:``,indent:0,offset:0};t===void 0&&(t=this.row_),this.topRow_=t-this.rollUpRows_+1},L.prototype.addFormatting=function(e,t){this.formatting_=this.formatting_.concat(t);var n=t.reduce(function(e,t){return e+`<`+t+`>`},``);this[this.mode_](e,n)},L.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce(function(e,t){return e+`</`+t+`>`},``);this.formatting_=[],this[this.mode_](e,t)}},L.prototype.popOn=function(e,t){var n=this.nonDisplayed_[this.row_].text;n+=t,this.nonDisplayed_[this.row_].text=n},L.prototype.rollUp=function(e,t){var n=this.displayed_[this.row_].text;n+=t,this.displayed_[this.row_].text=n},L.prototype.shiftRowsUp_=function(){for(var e=0;e<this.topRow_;e++)this.displayed_[e]={text:``,indent:0,offset:0};for(e=this.row_+1;e<We+1;e++)this.displayed_[e]={text:``,indent:0,offset:0};for(e=this.topRow_;e<this.row_;e++)this.displayed_[e]=this.displayed_[e+1];this.displayed_[this.row_]={text:``,indent:0,offset:0}},L.prototype.paintOn=function(e,t){var n=this.displayed_[this.row_].text;n+=t,this.displayed_[this.row_].text=n};var qe={CaptionStream:Ie,Cea608Stream:L,Cea708Stream:I},Je={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Ye=n,Xe=8589934592,Ze=4294967296,Qe=`shared`,$e=function(e,t){var n=1;for(e>t&&(n=-1);Math.abs(t-e)>Ze;)e+=n*Xe;return e},et=function(e){var t,n;et.prototype.init.call(this),this.type_=e||Qe,this.push=function(e){e.type===`metadata`?this.trigger(`data`,e):(this.type_===Qe||e.type===this.type_)&&(n===void 0&&(n=e.dts),e.dts=$e(e.dts,n),e.pts=$e(e.pts,n),t=e.dts,this.trigger(`data`,e))},this.flush=function(){n=t,this.trigger(`done`)},this.endTimeline=function(){this.flush(),this.trigger(`endedtimeline`)},this.discontinuity=function(){n=void 0,t=void 0},this.reset=function(){this.discontinuity(),this.trigger(`reset`)}};et.prototype=new Ye;var tt={TimestampRolloverStream:et,handleRollover:$e},nt={typedArrayIndexOf:(e,t,n)=>{if(!e)return-1;for(var r=n;r<e.length;r++)if(e[r]===t)return r;return-1}}.typedArrayIndexOf,rt={Utf8:3},it=function(e,t,n){var r,i=``;for(r=t;r<n;r++)i+=`%`+(`00`+e[r].toString(16)).slice(-2);return i},R=function(e,t,n){return decodeURIComponent(it(e,t,n))},at=function(e,t,n){return unescape(it(e,t,n))},ot=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},st={APIC:function(e){var t=1,n,r;e.data[0]===rt.Utf8&&(n=nt(e.data,0,t),!(n<0)&&(e.mimeType=at(e.data,t,n),t=n+1,e.pictureType=e.data[t],t++,r=nt(e.data,0,t),!(r<0)&&(e.description=R(e.data,t,r),t=r+1,e.mimeType===`-->`?e.url=at(e.data,t,e.data.length):e.pictureData=e.data.subarray(t,e.data.length))))},"T*":function(e){e.data[0]===rt.Utf8&&(e.value=R(e.data,1,e.data.length).replace(/\0*$/,``),e.values=e.value.split(`\0`))},TXXX:function(e){var t;e.data[0]===rt.Utf8&&(t=nt(e.data,0,1),t!==-1&&(e.description=R(e.data,1,t),e.value=R(e.data,t+1,e.data.length).replace(/\0*$/,``),e.data=e.value))},"W*":function(e){e.url=at(e.data,0,e.data.length).replace(/\0.*$/,``)},WXXX:function(e){var t;e.data[0]===rt.Utf8&&(t=nt(e.data,0,1),t!==-1&&(e.description=R(e.data,1,t),e.url=at(e.data,t+1,e.data.length).replace(/\0.*$/,``)))},PRIV:function(e){for(var t=0;t<e.data.length;t++)if(e.data[t]===0){e.owner=at(e.data,0,t);break}e.privateData=e.data.subarray(t+1),e.data=e.privateData}},ct={parseId3Frames:function(e){var t,n,r=10,i=0,a=[];if(!(e.length<10||e[0]!==73||e[1]!==68||e[2]!==51)){i=ot(e.subarray(6,10)),i+=10,e[5]&64&&(r+=4,r+=ot(e.subarray(10,14)),i-=ot(e.subarray(16,20)));do{if(t=ot(e.subarray(r+4,r+8)),t<1)break;n=String.fromCharCode(e[r],e[r+1],e[r+2],e[r+3]);var o={id:n,data:e.subarray(r+10,r+t+10)};o.key=o.id,st[o.id]?st[o.id](o):o.id[0]===`T`?st[`T*`](o):o.id[0]===`W`&&st[`W*`](o),a.push(o),r+=10,r+=t}while(r<i);return a}},parseSyncSafeInteger:ot,frameParsers:st},lt=n,ut=Je,dt=ct,ft=function(e){var t={descriptor:e&&e.descriptor},n=0,r=[],i=0,a;if(ft.prototype.init.call(this),this.dispatchType=ut.METADATA_STREAM_TYPE.toString(16),t.descriptor)for(a=0;a<t.descriptor.length;a++)this.dispatchType+=(`00`+t.descriptor[a].toString(16)).slice(-2);this.push=function(e){var t,a,o,s,c,l;if(e.type===`timed-metadata`){if(e.dataAlignmentIndicator&&(i=0,r.length=0),r.length===0&&(e.data.length<10||e.data[0]!==73||e.data[1]!==68||e.data[2]!==51))this.trigger(`log`,{level:`warn`,message:`Skipping unrecognized metadata packet`});else if(r.push(e),i+=e.data.byteLength,r.length===1&&(n=dt.parseSyncSafeInteger(e.data.subarray(6,10)),n+=10),!(i<n)){for(t={data:new Uint8Array(n),frames:[],pts:r[0].pts,dts:r[0].dts},c=0;c<n;)t.data.set(r[0].data.subarray(0,n-c),c),c+=r[0].data.byteLength,i-=r[0].data.byteLength,r.shift();a=10,t.data[5]&64&&(a+=4,a+=dt.parseSyncSafeInteger(t.data.subarray(10,14)),n-=dt.parseSyncSafeInteger(t.data.subarray(16,20)));do{if(o=dt.parseSyncSafeInteger(t.data.subarray(a+4,a+8)),o<1){this.trigger(`log`,{level:`warn`,message:`Malformed ID3 frame encountered. Skipping remaining metadata parsing.`});break}if(l=String.fromCharCode(t.data[a],t.data[a+1],t.data[a+2],t.data[a+3]),s={id:l,data:t.data.subarray(a+10,a+o+10)},s.key=s.id,dt.frameParsers[s.id]?dt.frameParsers[s.id](s):s.id[0]===`T`?dt.frameParsers[`T*`](s):s.id[0]===`W`&&dt.frameParsers[`W*`](s),s.owner===`com.apple.streaming.transportStreamTimestamp`){var u=s.data,d=(u[3]&1)<<30|u[4]<<22|u[5]<<14|u[6]<<6|u[7]>>>2;d*=4,d+=u[7]&3,s.timeStamp=d,t.pts===void 0&&t.dts===void 0&&(t.pts=s.timeStamp,t.dts=s.timeStamp),this.trigger(`timestamp`,s)}t.frames.push(s),a+=10,a+=o}while(a<n);this.trigger(`data`,t)}}}};ft.prototype=new lt;var pt=ft,mt=n,ht=qe,gt=Je,_t=tt.TimestampRolloverStream,vt,yt,bt,xt=188,St=71;vt=function(){var e=new Uint8Array(xt),t=0;vt.prototype.init.call(this),this.push=function(n){var r=0,i=xt,a;for(t?(a=new Uint8Array(n.byteLength+t),a.set(e.subarray(0,t)),a.set(n,t),t=0):a=n;i<a.byteLength;)a[r]===St&&a[i]===St?(this.trigger(`data`,a.subarray(r,i)),r+=xt,i+=xt):(r++,i++);r<a.byteLength&&(e.set(a.subarray(r),0),t=a.byteLength-r)},this.flush=function(){t===xt&&e[0]===St&&(this.trigger(`data`,e),t=0),this.trigger(`done`)},this.endTimeline=function(){this.flush(),this.trigger(`endedtimeline`)},this.reset=function(){t=0,this.trigger(`reset`)}},vt.prototype=new mt,yt=function(){var e,t,n,r;yt.prototype.init.call(this),r=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,e=function(e,r){var i=0;r.payloadUnitStartIndicator&&(i+=e[i]+1),r.type===`pat`?t(e.subarray(i),r):n(e.subarray(i),r)},t=function(e,t){t.section_number=e[7],t.last_section_number=e[8],r.pmtPid=(e[10]&31)<<8|e[11],t.pmtPid=r.pmtPid},n=function(e,t){var n,i,a,o;if(e[5]&1){for(r.programMapTable={video:null,audio:null,"timed-metadata":{}},n=(e[1]&15)<<8|e[2],i=3+n-4,a=(e[10]&15)<<8|e[11],o=12+a;o<i;){var s=e[o],c=(e[o+1]&31)<<8|e[o+2];s===gt.H264_STREAM_TYPE&&r.programMapTable.video===null?r.programMapTable.video=c:s===gt.ADTS_STREAM_TYPE&&r.programMapTable.audio===null?r.programMapTable.audio=c:s===gt.METADATA_STREAM_TYPE&&(r.programMapTable[`timed-metadata`][c]=s),o+=((e[o+3]&15)<<8|e[o+4])+5}t.programMapTable=r.programMapTable}},this.push=function(t){var n={},r=4;if(n.payloadUnitStartIndicator=!!(t[1]&64),n.pid=t[1]&31,n.pid<<=8,n.pid|=t[2],(t[3]&48)>>>4>1&&(r+=t[r]+1),n.pid===0)n.type=`pat`,e(t.subarray(r),n),this.trigger(`data`,n);else if(n.pid===this.pmtPid)for(n.type=`pmt`,e(t.subarray(r),n),this.trigger(`data`,n);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([t,r,n]):this.processPes_(t,r,n)},this.processPes_=function(e,t,n){n.streamType=n.pid===this.programMapTable.video?gt.H264_STREAM_TYPE:n.pid===this.programMapTable.audio?gt.ADTS_STREAM_TYPE:this.programMapTable[`timed-metadata`][n.pid],n.type=`pes`,n.data=e.subarray(t),this.trigger(`data`,n)}},yt.prototype=new mt,yt.STREAM_TYPES={h264:27,adts:15},bt=function(){var e=this,t=!1,n={data:[],size:0},r={data:[],size:0},i={data:[],size:0},a,o=function(e,t){var n;let r=e[0]<<16|e[1]<<8|e[2];t.data=new Uint8Array,r===1&&(t.packetLength=6+(e[4]<<8|e[5]),t.dataAlignmentIndicator=!!(e[6]&4),n=e[7],n&192&&(t.pts=(e[9]&14)<<27|(e[10]&255)<<20|(e[11]&254)<<12|(e[12]&255)<<5|(e[13]&254)>>>3,t.pts*=4,t.pts+=(e[13]&6)>>>1,t.dts=t.pts,n&64&&(t.dts=(e[14]&14)<<27|(e[15]&255)<<20|(e[16]&254)<<12|(e[17]&255)<<5|(e[18]&254)>>>3,t.dts*=4,t.dts+=(e[18]&6)>>>1)),t.data=e.subarray(9+e[8]))},s=function(t,n,r){var i=new Uint8Array(t.size),a={type:n},s=0,c=0,l=!1,u;if(!(!t.data.length||t.size<9)){for(a.trackId=t.data[0].pid,s=0;s<t.data.length;s++)u=t.data[s],i.set(u.data,c),c+=u.data.byteLength;o(i,a),l=n===`video`||a.packetLength<=t.size,(r||l)&&(t.size=0,t.data.length=0),l&&e.trigger(`data`,a)}};bt.prototype.init.call(this),this.push=function(o){({pat:function(){},pes:function(){var e,t;switch(o.streamType){case gt.H264_STREAM_TYPE:e=n,t=`video`;break;case gt.ADTS_STREAM_TYPE:e=r,t=`audio`;break;case gt.METADATA_STREAM_TYPE:e=i,t=`timed-metadata`;break;default:return}o.payloadUnitStartIndicator&&s(e,t,!0),e.data.push(o),e.size+=o.data.byteLength},pmt:function(){var n={type:`metadata`,tracks:[]};a=o.programMapTable,a.video!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.video,codec:`avc`,type:`video`}),a.audio!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.audio,codec:`adts`,type:`audio`}),t=!0,e.trigger(`data`,n)}})[o.type]()},this.reset=function(){n.size=0,n.data.length=0,r.size=0,r.data.length=0,this.trigger(`reset`)},this.flushStreams_=function(){s(n,`video`),s(r,`audio`),s(i,`timed-metadata`)},this.flush=function(){if(!t&&a){var n={type:`metadata`,tracks:[]};a.video!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.video,codec:`avc`,type:`video`}),a.audio!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.audio,codec:`adts`,type:`audio`}),e.trigger(`data`,n)}t=!1,this.flushStreams_(),this.trigger(`done`)}},bt.prototype=new mt;var Ct={PAT_PID:0,MP2T_PACKET_LENGTH:xt,TransportPacketStream:vt,TransportParseStream:yt,ElementaryStream:bt,TimestampRolloverStream:_t,CaptionStream:ht.CaptionStream,Cea608Stream:ht.Cea608Stream,Cea708Stream:ht.Cea708Stream,MetadataStream:pt};for(var wt in gt)gt.hasOwnProperty(wt)&&(Ct[wt]=gt[wt]);var Tt=Ct,Et=n,Dt=P.ONE_SECOND_IN_TS,Ot,kt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Ot=function(e){var t,n=0;Ot.prototype.init.call(this),this.skipWarn_=function(e,t){this.trigger(`log`,{level:`warn`,message:`adts skiping bytes ${e} to ${t} in frame ${n} outside syncword`})},this.push=function(r){var i=0,a,o,s,c,l;if(e||(n=0),r.type===`audio`){t&&t.length?(s=t,t=new Uint8Array(s.byteLength+r.data.byteLength),t.set(s),t.set(r.data,s.byteLength)):t=r.data;for(var u;i+7<t.length;)if(t[i]!==255||(t[i+1]&246)!=240)typeof u!=`number`&&(u=i),i++;else{if(typeof u==`number`&&(this.skipWarn_(u,i),u=null),o=(~t[i+1]&1)*2,a=(t[i+3]&3)<<11|t[i+4]<<3|(t[i+5]&224)>>5,c=((t[i+6]&3)+1)*1024,l=c*Dt/kt[(t[i+2]&60)>>>2],t.byteLength-i<a)break;this.trigger(`data`,{pts:r.pts+n*l,dts:r.dts+n*l,sampleCount:c,audioobjecttype:(t[i+2]>>>6&3)+1,channelcount:(t[i+2]&1)<<2|(t[i+3]&192)>>>6,samplerate:kt[(t[i+2]&60)>>>2],samplingfrequencyindex:(t[i+2]&60)>>>2,samplesize:16,data:t.subarray(i+7+o,i+a)}),n++,i+=a}typeof u==`number`&&(this.skipWarn_(u,i),u=null),t=t.subarray(i)}},this.flush=function(){n=0,this.trigger(`done`)},this.reset=function(){t=void 0,this.trigger(`reset`)},this.endTimeline=function(){t=void 0,this.trigger(`endedtimeline`)}},Ot.prototype=new Et;var At=Ot,jt=function(e){var t=e.byteLength,n=0,r=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+r},this.loadWord=function(){var i=e.byteLength-t,a=new Uint8Array(4),o=Math.min(4,t);if(o===0)throw Error(`no bytes available`);a.set(e.subarray(i,i+o)),n=new DataView(a.buffer).getUint32(0),r=o*8,t-=o},this.skipBits=function(e){var i;r>e?(n<<=e,r-=e):(e-=r,i=Math.floor(e/8),e-=i*8,t-=i,this.loadWord(),n<<=e,r-=e)},this.readBits=function(e){var i=Math.min(r,e),a=n>>>32-i;return r-=i,r>0?n<<=i:t>0&&this.loadWord(),i=e-i,i>0?a<<i|this.readBits(i):a},this.skipLeadingZeros=function(){for(var e=0;e<r;++e)if(n&2147483648>>>e)return n<<=e,r-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},Mt=n,Nt=jt,Pt,Ft=function(){var e=0,t,n;Ft.prototype.init.call(this),this.push=function(r){var i;n?(i=new Uint8Array(n.byteLength+r.data.byteLength),i.set(n),i.set(r.data,n.byteLength),n=i):n=r.data;for(var a=n.byteLength;e<a-3;e++)if(n[e+2]===1){t=e+5;break}for(;t<a;)switch(n[t]){case 0:if(n[t-1]!==0){t+=2;break}if(n[t-2]!==0){t++;break}e+3!==t-2&&this.trigger(`data`,n.subarray(e+3,t-2));do t++;while(n[t]!==1&&t<a);e=t-2,t+=3;break;case 1:if(n[t-1]!==0||n[t-2]!==0){t+=3;break}this.trigger(`data`,n.subarray(e+3,t-2)),e=t-2,t+=3;break;default:t+=3}n=n.subarray(e),t-=e,e=0},this.reset=function(){n=null,e=0,this.trigger(`reset`)},this.flush=function(){n&&n.byteLength>3&&this.trigger(`data`,n.subarray(e+3)),n=null,e=0,this.trigger(`done`)},this.endTimeline=function(){this.flush(),this.trigger(`endedtimeline`)}},It;Ft.prototype=new Mt,It={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Pt=function(){var e=new Ft,t,n,r,i,a,o,s;Pt.prototype.init.call(this),t=this,this.push=function(t){t.type===`video`&&(n=t.trackId,r=t.pts,i=t.dts,e.push(t))},e.on(`data`,function(e){var s={trackId:n,pts:r,dts:i,data:e,nalUnitTypeCode:e[0]&31};switch(s.nalUnitTypeCode){case 5:s.nalUnitType=`slice_layer_without_partitioning_rbsp_idr`;break;case 6:s.nalUnitType=`sei_rbsp`,s.escapedRBSP=a(e.subarray(1));break;case 7:s.nalUnitType=`seq_parameter_set_rbsp`,s.escapedRBSP=a(e.subarray(1)),s.config=o(s.escapedRBSP);break;case 8:s.nalUnitType=`pic_parameter_set_rbsp`;break;case 9:s.nalUnitType=`access_unit_delimiter_rbsp`}t.trigger(`data`,s)}),e.on(`done`,function(){t.trigger(`done`)}),e.on(`partialdone`,function(){t.trigger(`partialdone`)}),e.on(`reset`,function(){t.trigger(`reset`)}),e.on(`endedtimeline`,function(){t.trigger(`endedtimeline`)}),this.flush=function(){e.flush()},this.partialFlush=function(){e.partialFlush()},this.reset=function(){e.reset()},this.endTimeline=function(){e.endTimeline()},s=function(e,t){for(var n=8,r=8,i=0,a;i<e;i++)r!==0&&(a=t.readExpGolomb(),r=(n+a+256)%256),n=r===0?n:r},a=function(e){for(var t=e.byteLength,n=[],r=1,i,a;r<t-2;)e[r]===0&&e[r+1]===0&&e[r+2]===3?(n.push(r+2),r+=2):r++;if(n.length===0)return e;i=t-n.length,a=new Uint8Array(i);var o=0;for(r=0;r<i;o++,r++)o===n[0]&&(o++,n.shift()),a[r]=e[o];return a},o=function(e){var t=0,n=0,r=0,i=0,a,o,c,l,u,d,f,p,m,h,g,_=[1,1],v,y;if(a=new Nt(e),o=a.readUnsignedByte(),l=a.readUnsignedByte(),c=a.readUnsignedByte(),a.skipUnsignedExpGolomb(),It[o]&&(u=a.readUnsignedExpGolomb(),u===3&&a.skipBits(1),a.skipUnsignedExpGolomb(),a.skipUnsignedExpGolomb(),a.skipBits(1),a.readBoolean()))for(g=u===3?12:8,y=0;y<g;y++)a.readBoolean()&&s(y<6?16:64,a);if(a.skipUnsignedExpGolomb(),d=a.readUnsignedExpGolomb(),d===0)a.readUnsignedExpGolomb();else if(d===1)for(a.skipBits(1),a.skipExpGolomb(),a.skipExpGolomb(),f=a.readUnsignedExpGolomb(),y=0;y<f;y++)a.skipExpGolomb();if(a.skipUnsignedExpGolomb(),a.skipBits(1),p=a.readUnsignedExpGolomb(),m=a.readUnsignedExpGolomb(),h=a.readBits(1),h===0&&a.skipBits(1),a.skipBits(1),a.readBoolean()&&(t=a.readUnsignedExpGolomb(),n=a.readUnsignedExpGolomb(),r=a.readUnsignedExpGolomb(),i=a.readUnsignedExpGolomb()),a.readBoolean()&&a.readBoolean()){switch(v=a.readUnsignedByte(),v){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[a.readUnsignedByte()<<8|a.readUnsignedByte(),a.readUnsignedByte()<<8|a.readUnsignedByte()]}_&&_[0]/_[1]}return{profileIdc:o,levelIdc:c,profileCompatibility:l,width:(p+1)*16-t*2-n*2,height:(2-h)*(m+1)*16-r*2-i*2,sarRatio:_}}},Pt.prototype=new Mt;var Lt={H264Stream:Pt},Rt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],zt=function(e,t){var n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9],r=(e[t+5]&16)>>4;return n=n>=0?n:0,r?n+20:n+10},z=function(e,t){return e.length-t<10||e[t]!==73||e[t+1]!==68||e[t+2]!==51?t:(t+=zt(e,t),z(e,t))},Bt=function(e){var t=z(e,0);return e.length>=t+2&&(e[t]&255)==255&&(e[t+1]&240)==240&&(e[t+1]&22)==16},Vt=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},Ht=function(e,t,n){var r,i=``;for(r=t;r<n;r++)i+=`%`+(`00`+e[r].toString(16)).slice(-2);return i},Ut=function(e,t,n){return unescape(Ht(e,t,n))},Wt={isLikelyAacData:Bt,parseId3TagSize:zt,parseAdtsSize:function(e,t){var n=(e[t+5]&224)>>5,r=e[t+4]<<3;return e[t+3]&6144|r|n},parseType:function(e,t){return e[t]===73&&e[t+1]===68&&e[t+2]===51?`timed-metadata`:e[t]&!0&&(e[t+1]&240)==240?`audio`:null},parseSampleRate:function(e){for(var t=0;t+5<e.length;)if(e[t]!==255||(e[t+1]&246)!=240)t++;else return Rt[(e[t+2]&60)>>>2];return null},parseAacTimestamp:function(e){var t=10,n,r,i;e[5]&64&&(t+=4,t+=Vt(e.subarray(10,14)));do{if(n=Vt(e.subarray(t+4,t+8)),n<1)return null;if(i=String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3]),i===`PRIV`){r=e.subarray(t+10,t+n+10);for(var a=0;a<r.byteLength;a++)if(r[a]===0){if(Ut(r,0,a)===`com.apple.streaming.transportStreamTimestamp`){var o=r.subarray(a+1),s=(o[3]&1)<<30|o[4]<<22|o[5]<<14|o[6]<<6|o[7]>>>2;return s*=4,s+=o[7]&3,s}break}}t+=10,t+=n}while(t<e.byteLength);return null}},Gt=n,B=Wt,Kt=function(){var e=new Uint8Array,t=0;Kt.prototype.init.call(this),this.setTimestamp=function(e){t=e},this.push=function(n){var r=0,i=0,a,o,s,c;for(e.length?(c=e.length,e=new Uint8Array(n.byteLength+c),e.set(e.subarray(0,c)),e.set(n,c)):e=n;e.length-i>=3;)if(e[i]===73&&e[i+1]===68&&e[i+2]===51){if(e.length-i<10||(r=B.parseId3TagSize(e,i),i+r>e.length))break;o={type:`timed-metadata`,data:e.subarray(i,i+r)},this.trigger(`data`,o),i+=r}else if((e[i]&255)==255&&(e[i+1]&240)==240){if(e.length-i<7||(r=B.parseAdtsSize(e,i),i+r>e.length))break;s={type:`audio`,data:e.subarray(i,i+r),pts:t,dts:t},this.trigger(`data`,s),i+=r}else i++;a=e.length-i,e=a>0?e.subarray(i):new Uint8Array},this.reset=function(){e=new Uint8Array,this.trigger(`reset`)},this.endTimeline=function(){e=new Uint8Array,this.trigger(`endedtimeline`)}};Kt.prototype=new Gt;var qt=Kt,Jt=[`audioobjecttype`,`channelcount`,`samplerate`,`samplingfrequencyindex`,`samplesize`],Yt=[`width`,`height`,`profileIdc`,`levelIdc`,`profileCompatibility`,`sarRatio`],Xt=n,Zt=M,Qt=he,$t=Oe,en=Ae,tn=Tt,nn=P,rn=At,an=Lt.H264Stream,on=qt,sn=Wt.isLikelyAacData,cn=P.ONE_SECOND_IN_TS,ln=Jt,un=Yt,dn,fn,pn,mn,hn=function(e,t){t.stream=e,this.trigger(`log`,t)},gn=function(e,t){for(var n=Object.keys(t),r=0;r<n.length;r++){var i=n[r];i!==`headOfPipeline`&&t[i].on&&t[i].on(`log`,hn.bind(e,i))}},_n=function(e,t){var n;if(e.length!==t.length)return!1;for(n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},vn=function(e,t,n,r,i,a){var o=n-t,s=r-t,c=i-n;return{start:{dts:e,pts:e+o},end:{dts:e+s,pts:e+c},prependedContentDuration:a,baseMediaDecodeTime:e}};fn=function(e,t){var n=[],r,i=0,a=0,o=1/0;t||={},r=t.firstSequenceNumber||0,fn.prototype.init.call(this),this.push=function(t){en.collectDtsInfo(e,t),e&&ln.forEach(function(n){e[n]=t[n]}),n.push(t)},this.setEarliestDts=function(e){i=e},this.setVideoBaseMediaDecodeTime=function(e){o=e},this.setAudioAppendStart=function(e){a=e},this.flush=function(){var s,c,l,u,d,f,p;n.length===0||(s=$t.trimAdtsFramesByEarliestDts(n,e,i),e.baseMediaDecodeTime=en.calculateTrackBaseMediaDecodeTime(e,t.keepOriginalTimestamps),p=$t.prefixWithSilence(e,s,a,o),e.samples=$t.generateSampleTable(s),l=Zt.mdat($t.concatenateFrameData(s)),n=[],c=Zt.moof(r,[e]),u=new Uint8Array(c.byteLength+l.byteLength),r++,u.set(c),u.set(l,c.byteLength),en.clearDtsInfo(e),d=Math.ceil(cn*1024/e.samplerate),s.length&&(f=s.length*d,this.trigger(`segmentTimingInfo`,vn(nn.audioTsToVideoTs(e.baseMediaDecodeTime,e.samplerate),s[0].dts,s[0].pts,s[0].dts+f,s[0].pts+f,p||0)),this.trigger(`timingInfo`,{start:s[0].pts,end:s[0].pts+f})),this.trigger(`data`,{track:e,boxes:u})),this.trigger(`done`,`AudioSegmentStream`)},this.reset=function(){en.clearDtsInfo(e),n=[],this.trigger(`reset`)}},fn.prototype=new Xt,dn=function(e,t){var n,r=[],i=[],a,o;t||={},n=t.firstSequenceNumber||0,dn.prototype.init.call(this),delete e.minPTS,this.gopCache_=[],this.push=function(t){en.collectDtsInfo(e,t),t.nalUnitType===`seq_parameter_set_rbsp`&&!a&&(a=t.config,e.sps=[t.data],un.forEach(function(t){e[t]=a[t]},this)),t.nalUnitType===`pic_parameter_set_rbsp`&&!o&&(o=t.data,e.pps=[t.data]),r.push(t)},this.flush=function(){for(var a,o,s,c,l,u,d=0,f,p;r.length&&r[0].nalUnitType!==`access_unit_delimiter_rbsp`;)r.shift();if(r.length===0)this.resetStream_(),this.trigger(`done`,`VideoSegmentStream`);else{if(a=Qt.groupNalsIntoFrames(r),s=Qt.groupFramesIntoGops(a),s[0][0].keyFrame||(o=this.getGopForFusion_(r[0],e),o?(d=o.duration,s.unshift(o),s.byteLength+=o.byteLength,s.nalCount+=o.nalCount,s.pts=o.pts,s.dts=o.dts,s.duration+=o.duration):s=Qt.extendFirstKeyFrame(s)),i.length){var m=t.alignGopsAtEnd?this.alignGopsAtEnd_(s):this.alignGopsAtStart_(s);if(!m){this.gopCache_.unshift({gop:s.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),r=[],this.resetStream_(),this.trigger(`done`,`VideoSegmentStream`);return}en.clearDtsInfo(e),s=m}en.collectDtsInfo(e,s),e.samples=Qt.generateSampleTable(s),l=Zt.mdat(Qt.concatenateNalData(s)),e.baseMediaDecodeTime=en.calculateTrackBaseMediaDecodeTime(e,t.keepOriginalTimestamps),this.trigger(`processedGopsInfo`,s.map(function(e){return{pts:e.pts,dts:e.dts,byteLength:e.byteLength}})),f=s[0],p=s[s.length-1],this.trigger(`segmentTimingInfo`,vn(e.baseMediaDecodeTime,f.dts,f.pts,p.dts+p.duration,p.pts+p.duration,d)),this.trigger(`timingInfo`,{start:s[0].pts,end:s[s.length-1].pts+s[s.length-1].duration}),this.gopCache_.unshift({gop:s.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),r=[],this.trigger(`baseMediaDecodeTime`,e.baseMediaDecodeTime),this.trigger(`timelineStartInfo`,e.timelineStartInfo),c=Zt.moof(n,[e]),u=new Uint8Array(c.byteLength+l.byteLength),n++,u.set(c),u.set(l,c.byteLength),this.trigger(`data`,{track:e,boxes:u}),this.resetStream_(),this.trigger(`done`,`VideoSegmentStream`)}},this.reset=function(){this.resetStream_(),r=[],this.gopCache_.length=0,i.length=0,this.trigger(`reset`)},this.resetStream_=function(){en.clearDtsInfo(e),a=void 0,o=void 0},this.getGopForFusion_=function(t){for(var n=45e3,r=1/0,i,a,o,s,c=0;c<this.gopCache_.length;c++)s=this.gopCache_[c],o=s.gop,e.pps&&_n(e.pps[0],s.pps[0])&&e.sps&&_n(e.sps[0],s.sps[0])&&(o.dts<e.timelineStartInfo.dts||(i=t.dts-o.dts-o.duration,i>=-1e4&&i<=n&&(!a||r>i)&&(a=s,r=i)));return a?a.gop:null},this.alignGopsAtStart_=function(e){var t,n,r,a,o=e.byteLength,s=e.nalCount,c=e.duration,l;for(t=n=0;t<i.length&&n<e.length&&(r=i[t],a=e[n],r.pts!==a.pts);)a.pts>r.pts?t++:(n++,o-=a.byteLength,s-=a.nalCount,c-=a.duration);return n===0?e:n===e.length?null:(l=e.slice(n),l.byteLength=o,l.duration=c,l.nalCount=s,l.pts=l[0].pts,l.dts=l[0].dts,l)},this.alignGopsAtEnd_=function(e){for(var t=i.length-1,n=e.length-1,r,a,o=null,s=!1;t>=0&&n>=0;){if(r=i[t],a=e[n],r.pts===a.pts){s=!0;break}r.pts>a.pts?t--:(t===i.length-1&&(o=n),n--)}if(!s&&o===null)return null;var c=s?n:o;if(c===0)return e;var l=e.slice(c),u=l.reduce(function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e},{byteLength:0,duration:0,nalCount:0});return l.byteLength=u.byteLength,l.duration=u.duration,l.nalCount=u.nalCount,l.pts=l[0].pts,l.dts=l[0].dts,l},this.alignGopsWith=function(e){i=e}},dn.prototype=new Xt,mn=function(e,t){this.numberOfTracks=0,this.metadataStream=t,e||={},this.remuxTracks=e.remux===void 0||!!e.remux,this.keepOriginalTimestamps=typeof e.keepOriginalTimestamps==`boolean`&&e.keepOriginalTimestamps,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,mn.prototype.init.call(this),this.push=function(e){if(e.content||e.text)return this.pendingCaptions.push(e);if(e.frames)return this.pendingMetadata.push(e);this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,e.track.type===`video`&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),e.track.type===`audio`&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))}},mn.prototype=new Xt,mn.prototype.flush=function(e){var t=0,n={captions:[],captionStreams:{},metadata:[],info:{}},r,i,a,o=0,s;if(this.pendingTracks.length<this.numberOfTracks){if(e!==`VideoSegmentStream`&&e!==`AudioSegmentStream`||this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger(`done`),this.emittedTracks=0);return}}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,un.forEach(function(e){n.info[e]=this.videoTrack[e]},this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,ln.forEach(function(e){n.info[e]=this.audioTrack[e]},this)),this.videoTrack||this.audioTrack){for(n.type=this.pendingTracks.length===1?this.pendingTracks[0].type:`combined`,this.emittedTracks+=this.pendingTracks.length,a=Zt.initSegment(this.pendingTracks),n.initSegment=new Uint8Array(a.byteLength),n.initSegment.set(a),n.data=new Uint8Array(this.pendingBytes),s=0;s<this.pendingBoxes.length;s++)n.data.set(this.pendingBoxes[s],t),t+=this.pendingBoxes[s].byteLength;for(s=0;s<this.pendingCaptions.length;s++)r=this.pendingCaptions[s],r.startTime=nn.metadataTsToSeconds(r.startPts,o,this.keepOriginalTimestamps),r.endTime=nn.metadataTsToSeconds(r.endPts,o,this.keepOriginalTimestamps),n.captionStreams[r.stream]=!0,n.captions.push(r);for(s=0;s<this.pendingMetadata.length;s++)i=this.pendingMetadata[s],i.cueTime=nn.metadataTsToSeconds(i.pts,o,this.keepOriginalTimestamps),n.metadata.push(i);for(n.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger(`data`,n),s=0;s<n.captions.length;s++)r=n.captions[s],this.trigger(`caption`,r);for(s=0;s<n.metadata.length;s++)i=n.metadata[s],this.trigger(`id3Frame`,i)}this.emittedTracks>=this.numberOfTracks&&(this.trigger(`done`),this.emittedTracks=0)},mn.prototype.setRemux=function(e){this.remuxTracks=e},pn=function(e){var t=this,n=!0,r,i;pn.prototype.init.call(this),e||={},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var n={};this.transmuxPipeline_=n,n.type=`aac`,n.metadataStream=new tn.MetadataStream,n.aacStream=new on,n.audioTimestampRolloverStream=new tn.TimestampRolloverStream(`audio`),n.timedMetadataTimestampRolloverStream=new tn.TimestampRolloverStream(`timed-metadata`),n.adtsStream=new rn,n.coalesceStream=new mn(e,n.metadataStream),n.headOfPipeline=n.aacStream,n.aacStream.pipe(n.audioTimestampRolloverStream).pipe(n.adtsStream),n.aacStream.pipe(n.timedMetadataTimestampRolloverStream).pipe(n.metadataStream).pipe(n.coalesceStream),n.metadataStream.on(`timestamp`,function(e){n.aacStream.setTimestamp(e.timeStamp)}),n.aacStream.on(`data`,function(a){a.type!==`timed-metadata`&&a.type!==`audio`||n.audioSegmentStream||(i||={timelineStartInfo:{baseMediaDecodeTime:t.baseMediaDecodeTime},codec:`adts`,type:`audio`},n.coalesceStream.numberOfTracks++,n.audioSegmentStream=new fn(i,e),n.audioSegmentStream.on(`log`,t.getLogTrigger_(`audioSegmentStream`)),n.audioSegmentStream.on(`timingInfo`,t.trigger.bind(t,`audioTimingInfo`)),n.adtsStream.pipe(n.audioSegmentStream).pipe(n.coalesceStream),t.trigger(`trackinfo`,{hasAudio:!!i,hasVideo:!!r}))}),n.coalesceStream.on(`data`,this.trigger.bind(this,`data`)),n.coalesceStream.on(`done`,this.trigger.bind(this,`done`)),gn(this,n)},this.setupTsPipeline=function(){var n={};this.transmuxPipeline_=n,n.type=`ts`,n.metadataStream=new tn.MetadataStream,n.packetStream=new tn.TransportPacketStream,n.parseStream=new tn.TransportParseStream,n.elementaryStream=new tn.ElementaryStream,n.timestampRolloverStream=new tn.TimestampRolloverStream,n.adtsStream=new rn,n.h264Stream=new an,n.captionStream=new tn.CaptionStream(e),n.coalesceStream=new mn(e,n.metadataStream),n.headOfPipeline=n.packetStream,n.packetStream.pipe(n.parseStream).pipe(n.elementaryStream).pipe(n.timestampRolloverStream),n.timestampRolloverStream.pipe(n.h264Stream),n.timestampRolloverStream.pipe(n.adtsStream),n.timestampRolloverStream.pipe(n.metadataStream).pipe(n.coalesceStream),n.h264Stream.pipe(n.captionStream).pipe(n.coalesceStream),n.elementaryStream.on(`data`,function(a){var o;if(a.type===`metadata`){for(o=a.tracks.length;o--;)!r&&a.tracks[o].type===`video`?(r=a.tracks[o],r.timelineStartInfo.baseMediaDecodeTime=t.baseMediaDecodeTime):!i&&a.tracks[o].type===`audio`&&(i=a.tracks[o],i.timelineStartInfo.baseMediaDecodeTime=t.baseMediaDecodeTime);r&&!n.videoSegmentStream&&(n.coalesceStream.numberOfTracks++,n.videoSegmentStream=new dn(r,e),n.videoSegmentStream.on(`log`,t.getLogTrigger_(`videoSegmentStream`)),n.videoSegmentStream.on(`timelineStartInfo`,function(r){i&&!e.keepOriginalTimestamps&&(i.timelineStartInfo=r,n.audioSegmentStream.setEarliestDts(r.dts-t.baseMediaDecodeTime))}),n.videoSegmentStream.on(`processedGopsInfo`,t.trigger.bind(t,`gopInfo`)),n.videoSegmentStream.on(`segmentTimingInfo`,t.trigger.bind(t,`videoSegmentTimingInfo`)),n.videoSegmentStream.on(`baseMediaDecodeTime`,function(e){i&&n.audioSegmentStream.setVideoBaseMediaDecodeTime(e)}),n.videoSegmentStream.on(`timingInfo`,t.trigger.bind(t,`videoTimingInfo`)),n.h264Stream.pipe(n.videoSegmentStream).pipe(n.coalesceStream)),i&&!n.audioSegmentStream&&(n.coalesceStream.numberOfTracks++,n.audioSegmentStream=new fn(i,e),n.audioSegmentStream.on(`log`,t.getLogTrigger_(`audioSegmentStream`)),n.audioSegmentStream.on(`timingInfo`,t.trigger.bind(t,`audioTimingInfo`)),n.audioSegmentStream.on(`segmentTimingInfo`,t.trigger.bind(t,`audioSegmentTimingInfo`)),n.adtsStream.pipe(n.audioSegmentStream).pipe(n.coalesceStream)),t.trigger(`trackinfo`,{hasAudio:!!i,hasVideo:!!r})}}),n.coalesceStream.on(`data`,this.trigger.bind(this,`data`)),n.coalesceStream.on(`id3Frame`,function(e){e.dispatchType=n.metadataStream.dispatchType,t.trigger(`id3Frame`,e)}),n.coalesceStream.on(`caption`,this.trigger.bind(this,`caption`)),n.coalesceStream.on(`done`,this.trigger.bind(this,`done`)),gn(this,n)},this.setBaseMediaDecodeTime=function(t){var n=this.transmuxPipeline_;e.keepOriginalTimestamps||(this.baseMediaDecodeTime=t),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,en.clearDtsInfo(i),n.audioTimestampRolloverStream&&n.audioTimestampRolloverStream.discontinuity()),r&&(n.videoSegmentStream&&(n.videoSegmentStream.gopCache_=[]),r.timelineStartInfo.dts=void 0,r.timelineStartInfo.pts=void 0,en.clearDtsInfo(r),n.captionStream.reset()),n.timestampRolloverStream&&n.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(t){var n=this.transmuxPipeline_;e.remux=t,n&&n.coalesceStream&&n.coalesceStream.setRemux(t)},this.alignGopsWith=function(e){r&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.getLogTrigger_=function(e){var t=this;return function(n){n.stream=e,t.trigger(`log`,n)}},this.push=function(e){if(n){var t=sn(e);t&&this.transmuxPipeline_.type!==`aac`?this.setupAacPipeline():!t&&this.transmuxPipeline_.type!==`ts`&&this.setupTsPipeline(),n=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){n=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},pn.prototype=new Xt;var yn={Transmuxer:pn},bn={toUnsigned:function(e){return e>>>0},toHexString:function(e){return(`00`+e.toString(16)).slice(-2)}},xn=function(e){var t=``;return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),t+=String.fromCharCode(e[2]),t+=String.fromCharCode(e[3]),t},Sn=bn.toUnsigned,Cn=xn,wn=function(e,t){var n=[],r,i,a,o,s;if(!t.length)return null;for(r=0;r<e.byteLength;)i=Sn(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]),a=Cn(e.subarray(r+4,r+8)),o=i>1?r+i:e.byteLength,a===t[0]&&(t.length===1?n.push(e.subarray(r+8,o)):(s=wn(e.subarray(r+8,o),t.slice(1)),s.length&&(n=n.concat(s)))),r=o;return n},Tn=wn,En=bn.toUnsigned,Dn=i.getUint64,On=function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4))};return t.baseMediaDecodeTime=t.version===1?Dn(e.subarray(4)):En(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),t},kn=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:e[0],flags:new Uint8Array(e.subarray(1,4)),trackId:t.getUint32(4)},r=n.flags[2]&1,i=n.flags[2]&2,a=n.flags[2]&8,o=n.flags[2]&16,s=n.flags[2]&32,c=n.flags[0]&65536,l=n.flags[0]&131072,u=8;return r&&(u+=4,n.baseDataOffset=t.getUint32(12),u+=4),i&&(n.sampleDescriptionIndex=t.getUint32(u),u+=4),a&&(n.defaultSampleDuration=t.getUint32(u),u+=4),o&&(n.defaultSampleSize=t.getUint32(u),u+=4),s&&(n.defaultSampleFlags=t.getUint32(u)),c&&(n.durationIsEmpty=!0),!r&&l&&(n.baseDataOffsetIsMoof=!0),n},An=function(e){return{isLeading:(e[0]&12)>>>2,dependsOn:e[0]&3,isDependedOn:(e[1]&192)>>>6,hasRedundancy:(e[1]&48)>>>4,paddingValue:(e[1]&14)>>>1,isNonSyncSample:e[1]&1,degradationPriority:e[2]<<8|e[3]}},jn=function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=t.flags[2]&1,i=t.flags[2]&4,a=t.flags[1]&1,o=t.flags[1]&2,s=t.flags[1]&4,c=t.flags[1]&8,l=n.getUint32(4),u=8,d;for(r&&(t.dataOffset=n.getInt32(u),u+=4),i&&l&&(d={flags:An(e.subarray(u,u+4))},u+=4,a&&(d.duration=n.getUint32(u),u+=4),o&&(d.size=n.getUint32(u),u+=4),c&&(t.version===1?d.compositionTimeOffset=n.getInt32(u):d.compositionTimeOffset=n.getUint32(u),u+=4),t.samples.push(d),l--);l--;)d={},a&&(d.duration=n.getUint32(u),u+=4),o&&(d.size=n.getUint32(u),u+=4),s&&(d.flags=An(e.subarray(u,u+4)),u+=4),c&&(t.version===1?d.compositionTimeOffset=n.getInt32(u):d.compositionTimeOffset=n.getUint32(u),u+=4),t.samples.push(d);return t},Mn={tfdt:On,trun:jn},Nn={parseTfdt:Mn.tfdt,parseTrun:Mn.trun},Pn={uint8ToCString:function(e){for(var t=0,n=String.fromCharCode(e[t]),r=``;n!==`\0`;)r+=n,t++,n=String.fromCharCode(e[t]);return r+=n,r}}.uint8ToCString,Fn=i.getUint64,In=function(e){var t=4,n=e[0],r,i,a,o,s,c,l,u;if(n===0){r=Pn(e.subarray(t)),t+=r.length,i=Pn(e.subarray(t)),t+=i.length;var d=new DataView(e.buffer);a=d.getUint32(t),t+=4,s=d.getUint32(t),t+=4,c=d.getUint32(t),t+=4,l=d.getUint32(t),t+=4}else if(n===1){var d=new DataView(e.buffer);a=d.getUint32(t),t+=4,o=Fn(e.subarray(t)),t+=8,c=d.getUint32(t),t+=4,l=d.getUint32(t),t+=4,r=Pn(e.subarray(t)),t+=r.length,i=Pn(e.subarray(t)),t+=i.length}u=new Uint8Array(e.subarray(t,e.byteLength));var f={scheme_id_uri:r,value:i,timescale:a||1,presentation_time:o,presentation_time_delta:s,event_duration:c,id:l,message_data:u};return Rn(n,f)?f:void 0},Ln=function(e,t,n,r){return e||e===0?e/t:r+n/t},Rn=function(e,t){var n=t.scheme_id_uri!==`\0`,r=e===0&&zn(t.presentation_time_delta)&&n,i=e===1&&zn(t.presentation_time)&&n;return!(e>1)&&r||i},zn=function(e){return e!==void 0||e!==null},Bn={parseEmsgBox:In,scaleTime:Ln},Vn=typeof window<`u`?window:e===void 0?typeof self<`u`?self:{}:e,Hn=bn.toUnsigned,Un=bn.toHexString,Wn=Tn,Gn=xn,Kn=Bn,qn=kn,Jn=jn,Yn=On,Xn=i.getUint64,Zn,Qn,$n,er,tr,nr,rr,ir=Vn,ar=ct.parseId3Frames;Zn=function(e){return Wn(e,[`moov`,`trak`]).reduce(function(e,t){var n=Wn(t,[`tkhd`])[0],r,i,a,o;return!n||(r=n[0],i=r===0?12:20,a=Hn(n[i]<<24|n[i+1]<<16|n[i+2]<<8|n[i+3]),o=Wn(t,[`mdia`,`mdhd`])[0],!o)?null:(r=o[0],i=r===0?12:20,e[a]=Hn(o[i]<<24|o[i+1]<<16|o[i+2]<<8|o[i+3]),e)},{})},Qn=function(e,t){var n=Wn(t,[`moof`,`traf`]).reduce(function(t,n){var r=Wn(n,[`tfhd`])[0],i=e[Hn(r[4]<<24|r[5]<<16|r[6]<<8|r[7])]||9e4,a=Wn(n,[`tfdt`])[0],o=new DataView(a.buffer,a.byteOffset,a.byteLength),s=a[0]===1?Xn(a.subarray(4,12)):o.getUint32(4);let c;return typeof s==`bigint`?c=s/ir.BigInt(i):typeof s==`number`&&!isNaN(s)&&(c=s/i),c<2**53-1&&(c=Number(c)),c<t&&(t=c),t},1/0);return typeof n==`bigint`||isFinite(n)?n:0},$n=function(e,t){var n=Wn(t,[`moof`,`traf`]),r=0,i=0,a;if(n&&n.length){var o=Wn(n[0],[`tfhd`])[0],s=Wn(n[0],[`trun`])[0],c=Wn(n[0],[`tfdt`])[0];if(o&&(a=qn(o).trackId),c&&(r=Yn(c).baseMediaDecodeTime),s){var l=Jn(s);l.samples&&l.samples.length&&(i=l.samples[0].compositionTimeOffset||0)}}var u=e[a]||9e4;typeof r==`bigint`&&(i=ir.BigInt(i),u=ir.BigInt(u));var d=(r+i)/u;return typeof d==`bigint`&&d<2**53-1&&(d=Number(d)),d},er=function(e){var t=Wn(e,[`moov`,`trak`]),n=[];return t.forEach(function(e){var t=Wn(e,[`mdia`,`hdlr`]),r=Wn(e,[`tkhd`]);t.forEach(function(e,t){var i=Gn(e.subarray(8,12)),a=r[t],o,s,c;i===`vide`&&(o=new DataView(a.buffer,a.byteOffset,a.byteLength),s=o.getUint8(0),c=s===0?o.getUint32(12):o.getUint32(20),n.push(c))})}),n},nr=function(e){var t=e[0]===0?12:20;return Hn(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])},tr=function(e){var t=Wn(e,[`moov`,`trak`]),n=[];return t.forEach(function(e){var t={},r=Wn(e,[`tkhd`])[0],i,a;r&&(i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=i.getUint8(0),t.id=a===0?i.getUint32(12):i.getUint32(20));var o=Wn(e,[`mdia`,`hdlr`])[0];if(o){var s=Gn(o.subarray(8,12));t.type=s===`vide`?`video`:s===`soun`?`audio`:s}var c=Wn(e,[`mdia`,`minf`,`stbl`,`stsd`])[0];if(c){var l=c.subarray(8);t.codec=Gn(l.subarray(4,8));var u=Wn(l,[t.codec])[0],d,f;u&&(/^[asm]vc[1-9]$/i.test(t.codec)?(d=u.subarray(78),f=Gn(d.subarray(4,8)),f===`avcC`&&d.length>11?(t.codec+=`.`,t.codec+=Un(d[9]),t.codec+=Un(d[10]),t.codec+=Un(d[11])):t.codec=`avc1.4d400d`):/^mp4[a,v]$/i.test(t.codec)?(d=u.subarray(28),f=Gn(d.subarray(4,8)),f===`esds`&&d.length>20&&d[19]!==0?(t.codec+=`.`+Un(d[19]),t.codec+=`.`+Un(d[20]>>>2&63).replace(/^0/,``)):t.codec=`mp4a.40.2`):t.codec=t.codec.toLowerCase())}var p=Wn(e,[`mdia`,`mdhd`])[0];p&&(t.timescale=nr(p)),n.push(t)}),n},rr=function(e,t=0){return Wn(e,[`emsg`]).map(e=>{var n=Kn.parseEmsgBox(new Uint8Array(e)),r=ar(n.message_data);return{cueTime:Kn.scaleTime(n.presentation_time,n.timescale,n.presentation_time_delta,t),duration:Kn.scaleTime(n.event_duration,n.timescale),frames:r}})};var or={findBox:Wn,parseType:Gn,timescale:Zn,startTime:Qn,compositionStartTime:$n,videoTrackIds:er,tracks:tr,getTimescaleFromMediaHeader:nr,getEmsgID3:rr};let{parseTrun:sr}=Nn,{findBox:cr}=or;var lr=Vn,V={getMdatTrafPairs:function(e){var t=cr(e,[`moof`,`traf`]),n=cr(e,[`mdat`]),r=[];return n.forEach(function(e,n){var i=t[n];r.push({mdat:e,traf:i})}),r},parseSamples:function(e,t,n){var r=t,i=n.defaultSampleDuration||0,a=n.defaultSampleSize||0,o=n.trackId,s=[];return e.forEach(function(e){var t=sr(e).samples;t.forEach(function(e){e.duration===void 0&&(e.duration=i),e.size===void 0&&(e.size=a),e.trackId=o,e.dts=r,e.compositionTimeOffset===void 0&&(e.compositionTimeOffset=0),typeof r==`bigint`?(e.pts=r+lr.BigInt(e.compositionTimeOffset),r+=lr.BigInt(e.duration)):(e.pts=r+e.compositionTimeOffset,r+=e.duration)}),s=s.concat(t)}),s}},ur=Ne.discardEmulationPreventionBytes,dr=qe.CaptionStream,fr=Tn,pr=On,mr=kn,{getMdatTrafPairs:hr,parseSamples:gr}=V,_r=function(e,t){for(var n=e,r=0;r<t.length;r++){var i=t[r];if(n<i.size)return i;n-=i.size}return null},vr=function(e,t,n){for(var r=new DataView(e.buffer,e.byteOffset,e.byteLength),i={logs:[],seiNals:[]},a,o=0,s,c;o+4<e.length;o+=s)if(s=r.getUint32(o),o+=4,!(s<=0))switch(e[o]&31){case 6:var l=e.subarray(o+1,o+1+s),u=_r(o,t);if(a={nalUnitType:`sei_rbsp`,size:s,data:l,escapedRBSP:ur(l),trackId:n},u)a.pts=u.pts,a.dts=u.dts,c=u;else if(c)a.pts=c.pts,a.dts=c.dts;else{i.logs.push({level:`warn`,message:`We've encountered a nal unit without data at `+o+` for trackId `+n+`. See mux.js#223.`});break}i.seiNals.push(a)}return i},yr=function(e,t){var n={};return hr(e).forEach(function(e){var r=e.mdat,i=e.traf,a=mr(fr(i,[`tfhd`])[0]),o=a.trackId,s=fr(i,[`tfdt`]),c=s.length>0?pr(s[0]).baseMediaDecodeTime:0,l=fr(i,[`trun`]),u,d;t===o&&l.length>0&&(u=gr(l,c,a),d=vr(r,u,o),n[o]||(n[o]={seiNals:[],logs:[]}),n[o].seiNals=n[o].seiNals.concat(d.seiNals),n[o].logs=n[o].logs.concat(d.logs))}),n},br=function(e,t,n){var r;if(t===null)return null;r=yr(e,t);var i=r[t]||{};return{seiNals:i.seiNals,logs:i.logs,timescale:n}},xr=function(){var e=!1,t,n,r,i,a,o;this.isInitialized=function(){return e},this.init=function(n){t=new dr,e=!0,o=n?n.isPartial:!1,t.on(`data`,function(e){e.startTime=e.startPts/i,e.endTime=e.endPts/i,a.captions.push(e),a.captionStreams[e.stream]=!0}),t.on(`log`,function(e){a.logs.push(e)})},this.isNewInit=function(e,t){return e&&e.length===0||t&&typeof t==`object`&&Object.keys(t).length===0?!1:r!==e[0]||i!==t[r]},this.parse=function(e,t,o){var s;if(!this.isInitialized()||!t||!o)return null;if(this.isNewInit(t,o))r=t[0],i=o[r];else if(r===null||!i)return n.push(e),null;for(;n.length>0;){var c=n.shift();this.parse(c,t,o)}return s=br(e,r,i),s&&s.logs&&(a.logs=a.logs.concat(s.logs)),s===null||!s.seiNals?a.logs.length?{logs:a.logs,captions:[],captionStreams:[]}:null:(this.pushNals(s.seiNals),this.flushStream(),a)},this.pushNals=function(e){if(!this.isInitialized()||!e||e.length===0)return null;e.forEach(function(e){t.push(e)})},this.flushStream=function(){if(!this.isInitialized())return null;o?t.partialFlush():t.flush()},this.clearParsedCaptions=function(){a.captions=[],a.captionStreams={},a.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;t.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){n=[],r=null,i=null,a?this.clearParsedCaptions():a={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()};let{parseTfdt:Sr}=Nn,Cr=Tn,{getTimescaleFromMediaHeader:wr}=or,{parseSamples:Tr,getMdatTrafPairs:Er}=V;var Dr=function(){let e=9e4;this.init=function(t){let n=Cr(t,[`moov`,`trak`,`mdia`,`mdhd`])[0];n&&(e=wr(n))},this.parseSegment=function(t){let n=[],r=Er(t),i=0;return r.forEach(function(t){let r=t.mdat,a=t.traf,o=Cr(a,[`tfdt`])[0],s=Cr(a,[`tfhd`])[0],c=Cr(a,[`trun`]);if(o&&(i=Sr(o).baseMediaDecodeTime),c.length&&s){let t=Tr(c,i,s),a=0;t.forEach(function(t){let i=new TextDecoder(`utf-8`),o=r.slice(a,a+t.size);Cr(o,[`vtte`])[0]||Cr(o,[`vttc`]).forEach(function(r){let a=Cr(r,[`payl`])[0],o=Cr(r,[`sttg`])[0],s=t.pts/e,c=(t.pts+t.duration)/e,l,u;if(a)try{l=i.decode(a)}catch(e){console.error(e)}if(o)try{u=i.decode(o)}catch(e){console.error(e)}t.duration&&l&&n.push({cueText:l,start:s,end:c,settings:u})}),a+=t.size})}}),n}},Or=Je,kr=function(e){var t=e[1]&31;return t<<=8,t|=e[2],t},Ar=function(e){return!!(e[1]&64)},jr=function(e){var t=0;return(e[3]&48)>>>4>1&&(t+=e[4]+1),t},Mr=function(e,t){var n=kr(e);return n===0?`pat`:n===t?`pmt`:t?`pes`:null},Nr=function(e){var t=Ar(e),n=4+jr(e);return t&&(n+=e[n]+1),(e[n+10]&31)<<8|e[n+11]},Pr=function(e){var t={},n=Ar(e),r=4+jr(e);if(n&&(r+=e[r]+1),e[r+5]&1){for(var i=3+((e[r+1]&15)<<8|e[r+2])-4,a=12+((e[r+10]&15)<<8|e[r+11]);a<i;){var o=r+a;t[(e[o+1]&31)<<8|e[o+2]]=e[o],a+=((e[o+3]&15)<<8|e[o+4])+5}return t}},Fr=function(e,t){switch(t[kr(e)]){case Or.H264_STREAM_TYPE:return`video`;case Or.ADTS_STREAM_TYPE:return`audio`;case Or.METADATA_STREAM_TYPE:return`timed-metadata`;default:return null}},Ir=function(e){if(!Ar(e))return null;var t=4+jr(e);if(t>=e.byteLength)return null;var n=null,r=e[t+7];return r&192&&(n={},n.pts=(e[t+9]&14)<<27|(e[t+10]&255)<<20|(e[t+11]&254)<<12|(e[t+12]&255)<<5|(e[t+13]&254)>>>3,n.pts*=4,n.pts+=(e[t+13]&6)>>>1,n.dts=n.pts,r&64&&(n.dts=(e[t+14]&14)<<27|(e[t+15]&255)<<20|(e[t+16]&254)<<12|(e[t+17]&255)<<5|(e[t+18]&254)>>>3,n.dts*=4,n.dts+=(e[t+18]&6)>>>1)),n},Lr=function(e){switch(e){case 5:return`slice_layer_without_partitioning_rbsp_idr`;case 6:return`sei_rbsp`;case 7:return`seq_parameter_set_rbsp`;case 8:return`pic_parameter_set_rbsp`;case 9:return`access_unit_delimiter_rbsp`;default:return null}},Rr={parseType:Mr,parsePat:Nr,parsePmt:Pr,parsePayloadUnitStartIndicator:Ar,parsePesType:Fr,parsePesTime:Ir,videoPacketContainsKeyFrame:function(e){for(var t=4+jr(e),n=e.subarray(t),r=0,i=0,a=!1,o;i<n.byteLength-3;i++)if(n[i+2]===1){r=i+5;break}for(;r<n.byteLength;)switch(n[r]){case 0:if(n[r-1]!==0){r+=2;break}if(n[r-2]!==0){r++;break}i+3!==r-2&&(o=Lr(n[i+3]&31),o===`slice_layer_without_partitioning_rbsp_idr`&&(a=!0));do r++;while(n[r]!==1&&r<n.length);i=r-2,r+=3;break;case 1:if(n[r-1]!==0||n[r-2]!==0){r+=3;break}o=Lr(n[i+3]&31),o===`slice_layer_without_partitioning_rbsp_idr`&&(a=!0),i=r-2,r+=3;break;default:r+=3}return n=n.subarray(i),r-=i,i=0,n&&n.byteLength>3&&(o=Lr(n[i+3]&31),o===`slice_layer_without_partitioning_rbsp_idr`&&(a=!0)),a}},zr=Je,Br=tt.handleRollover,H={};H.ts=Rr,H.aac=Wt;var Vr=P.ONE_SECOND_IN_TS,Hr=188,Ur=71,Wr=function(e,t){for(var n=0,r=Hr,i,a;r<e.byteLength;)if(e[n]===Ur&&e[r]===Ur){switch(i=e.subarray(n,r),a=H.ts.parseType(i,t.pid),a){case`pat`:t.pid=H.ts.parsePat(i);break;case`pmt`:var o=H.ts.parsePmt(i);t.table=t.table||{},Object.keys(o).forEach(function(e){t.table[e]=o[e]})}n+=Hr,r+=Hr}else n++,r++},Gr=function(e,t,n){for(var r=0,i=Hr,a,o,s,c,l,u=!1;i<=e.byteLength;)if(e[r]===Ur&&(e[i]===Ur||i===e.byteLength)){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`audio`&&c&&(l=H.ts.parsePesTime(a),l&&(l.type=`audio`,n.audio.push(l),u=!0))),u)break;r+=Hr,i+=Hr}else r++,i++;for(i=e.byteLength,r=i-Hr,u=!1;r>=0;)if(e[r]===Ur&&(e[i]===Ur||i===e.byteLength)){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`audio`&&c&&(l=H.ts.parsePesTime(a),l&&(l.type=`audio`,n.audio.push(l),u=!0))),u)break;r-=Hr,i-=Hr}else r--,i--},Kr=function(e,t,n){for(var r=0,i=Hr,a,o,s,c,l,u,d,f,p=!1,m={data:[],size:0};i<e.byteLength;)if(e[r]===Ur&&e[i]===Ur){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`video`&&(c&&!p&&(l=H.ts.parsePesTime(a),l&&(l.type=`video`,n.video.push(l),p=!0)),!n.firstKeyFrame))){if(c&&m.size!==0){for(u=new Uint8Array(m.size),d=0;m.data.length;)f=m.data.shift(),u.set(f,d),d+=f.byteLength;if(H.ts.videoPacketContainsKeyFrame(u)){var h=H.ts.parsePesTime(u);h?(n.firstKeyFrame=h,n.firstKeyFrame.type=`video`):console.warn(`Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.`)}m.size=0}m.data.push(a),m.size+=a.byteLength}if(p&&n.firstKeyFrame)break;r+=Hr,i+=Hr}else r++,i++;for(i=e.byteLength,r=i-Hr,p=!1;r>=0;)if(e[r]===Ur&&e[i]===Ur){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`video`&&c&&(l=H.ts.parsePesTime(a),l&&(l.type=`video`,n.video.push(l),p=!0))),p)break;r-=Hr,i-=Hr}else r--,i--},qr=function(e,t){if(e.audio&&e.audio.length){var n=t;(n===void 0||isNaN(n))&&(n=e.audio[0].dts),e.audio.forEach(function(e){e.dts=Br(e.dts,n),e.pts=Br(e.pts,n),e.dtsTime=e.dts/Vr,e.ptsTime=e.pts/Vr})}if(e.video&&e.video.length){var r=t;if((r===void 0||isNaN(r))&&(r=e.video[0].dts),e.video.forEach(function(e){e.dts=Br(e.dts,r),e.pts=Br(e.pts,r),e.dtsTime=e.dts/Vr,e.ptsTime=e.pts/Vr}),e.firstKeyFrame){var i=e.firstKeyFrame;i.dts=Br(i.dts,r),i.pts=Br(i.pts,r),i.dtsTime=i.dts/Vr,i.ptsTime=i.pts/Vr}}},Jr=function(e){for(var t=!1,n=0,r=null,i=null,a=0,o=0,s;e.length-o>=3;){switch(H.aac.parseType(e,o)){case`timed-metadata`:if(e.length-o<10||(a=H.aac.parseId3TagSize(e,o),a>e.length)){t=!0;break}i===null&&(s=e.subarray(o,o+a),i=H.aac.parseAacTimestamp(s)),o+=a;break;case`audio`:if(e.length-o<7||(a=H.aac.parseAdtsSize(e,o),a>e.length)){t=!0;break}r===null&&(s=e.subarray(o,o+a),r=H.aac.parseSampleRate(s)),n++,o+=a;break;default:o++}if(t)return null}if(r===null||i===null)return null;var c=Vr/r;return{audio:[{type:`audio`,dts:i,pts:i},{type:`audio`,dts:i+n*1024*c,pts:i+n*1024*c}]}},Yr=function(e){var t={pid:null,table:null},n={};for(var r in Wr(e,t),t.table)if(t.table.hasOwnProperty(r))switch(t.table[r]){case zr.H264_STREAM_TYPE:n.video=[],Kr(e,t,n),n.video.length===0&&delete n.video;break;case zr.ADTS_STREAM_TYPE:n.audio=[],Gr(e,t,n),n.audio.length===0&&delete n.audio}return n},Xr={inspect:function(e,t){var n=H.aac.isLikelyAacData(e)?Jr(e):Yr(e);return!n||!n.audio&&!n.video?null:(qr(n,t),n)},parseAudioPes_:Gr};let Zr=function(e,t){t.on(`data`,function(t){let n=t.initSegment;t.initSegment={data:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength};let r=t.data;t.data=r.buffer,e.postMessage({action:`data`,segment:t,byteOffset:r.byteOffset,byteLength:r.byteLength},[t.data])}),t.on(`done`,function(t){e.postMessage({action:`done`})}),t.on(`gopInfo`,function(t){e.postMessage({action:`gopInfo`,gopInfo:t})}),t.on(`videoSegmentTimingInfo`,function(t){let n={start:{decode:P.videoTsToSeconds(t.start.dts),presentation:P.videoTsToSeconds(t.start.pts)},end:{decode:P.videoTsToSeconds(t.end.dts),presentation:P.videoTsToSeconds(t.end.pts)},baseMediaDecodeTime:P.videoTsToSeconds(t.baseMediaDecodeTime)};t.prependedContentDuration&&(n.prependedContentDuration=P.videoTsToSeconds(t.prependedContentDuration)),e.postMessage({action:`videoSegmentTimingInfo`,videoSegmentTimingInfo:n})}),t.on(`audioSegmentTimingInfo`,function(t){let n={start:{decode:P.videoTsToSeconds(t.start.dts),presentation:P.videoTsToSeconds(t.start.pts)},end:{decode:P.videoTsToSeconds(t.end.dts),presentation:P.videoTsToSeconds(t.end.pts)},baseMediaDecodeTime:P.videoTsToSeconds(t.baseMediaDecodeTime)};t.prependedContentDuration&&(n.prependedContentDuration=P.videoTsToSeconds(t.prependedContentDuration)),e.postMessage({action:`audioSegmentTimingInfo`,audioSegmentTimingInfo:n})}),t.on(`id3Frame`,function(t){e.postMessage({action:`id3Frame`,id3Frame:t})}),t.on(`caption`,function(t){e.postMessage({action:`caption`,caption:t})}),t.on(`trackinfo`,function(t){e.postMessage({action:`trackinfo`,trackInfo:t})}),t.on(`audioTimingInfo`,function(t){e.postMessage({action:`audioTimingInfo`,audioTimingInfo:{start:P.videoTsToSeconds(t.start),end:P.videoTsToSeconds(t.end)}})}),t.on(`videoTimingInfo`,function(t){e.postMessage({action:`videoTimingInfo`,videoTimingInfo:{start:P.videoTsToSeconds(t.start),end:P.videoTsToSeconds(t.end)}})}),t.on(`log`,function(t){e.postMessage({action:`log`,log:t})})};class Qr{constructor(e,t){this.options=t||{},this.self=e,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new yn.Transmuxer(this.options),Zr(this.self,this.transmuxer)}pushMp4Captions(e){this.captionParser||(this.captionParser=new xr,this.captionParser.init());let t=new Uint8Array(e.data,e.byteOffset,e.byteLength),n=this.captionParser.parse(t,e.trackIds,e.timescales);this.self.postMessage({action:`mp4Captions`,captions:n&&n.captions||[],logs:n&&n.logs||[],data:t.buffer},[t.buffer])}initMp4WebVttParser(e){this.webVttParser||=new Dr;let t=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.webVttParser.init(t)}getMp4WebVttText(e){this.webVttParser||=new Dr;let t=new Uint8Array(e.data,e.byteOffset,e.byteLength),n=this.webVttParser.parseSegment(t);this.self.postMessage({action:`getMp4WebVttText`,mp4VttCues:n||[],data:t.buffer},[t.buffer])}probeMp4StartTime({timescales:e,data:t}){let n=or.startTime(e,t);this.self.postMessage({action:`probeMp4StartTime`,startTime:n,data:t},[t.buffer])}probeMp4Tracks({data:e}){let t=or.tracks(e);this.self.postMessage({action:`probeMp4Tracks`,tracks:t,data:e},[e.buffer])}probeEmsgID3({data:e,offset:t}){let n=or.getEmsgID3(e,t);this.self.postMessage({action:`probeEmsgID3`,id3Frames:n,emsgData:e},[e.buffer])}probeTs({data:e,baseStartTime:t}){let n=typeof t==`number`&&!isNaN(t)?t*P.ONE_SECOND_IN_TS:void 0,r=Xr.inspect(e,n),i=null;r&&(i={hasVideo:r.video&&r.video.length===2||!1,hasAudio:r.audio&&r.audio.length===2||!1},i.hasVideo&&(i.videoStart=r.video[0].ptsTime),i.hasAudio&&(i.audioStart=r.audio[0].ptsTime)),this.self.postMessage({action:`probeTs`,result:i,data:e},[e.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(e){let t=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.transmuxer.push(t)}reset(){this.transmuxer.reset()}setTimestampOffset(e){let t=e.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(P.secondsToVideoTs(t)))}setAudioAppendStart(e){this.transmuxer.setAudioAppendStart(Math.ceil(P.secondsToVideoTs(e.appendStart)))}setRemux(e){this.transmuxer.setRemux(e.remux)}flush(e){this.transmuxer.flush(),self.postMessage({action:`done`,type:`transmuxed`})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:`endedtimeline`,type:`transmuxed`})}alignGopsWith(e){this.transmuxer.alignGopsWith(e.gopsToAlignWith.slice())}}self.onmessage=function(e){e.data.action===`init`&&e.data.options?this.messageHandlers=new Qr(self,e.data.options):(this.messageHandlers||=new Qr(self),e.data&&e.data.action&&e.data.action!==`init`&&this.messageHandlers[e.data.action]&&this.messageHandlers[e.data.action](e.data))}})));const Of=(e,t,n)=>{let{type:r,initSegment:i,captions:a,captionStreams:o,metadata:s,videoFrameDtsTime:c,videoFramePtsTime:l}=e.data.segment;t.buffer.push({captions:a,captionStreams:o,metadata:s});let u=e.data.segment.boxes||{data:e.data.segment.data},d={type:r,data:new Uint8Array(u.data,u.data.byteOffset,u.data.byteLength),initSegment:new Uint8Array(i.data,i.byteOffset,i.byteLength)};c!==void 0&&(d.videoFrameDtsTime=c),l!==void 0&&(d.videoFramePtsTime=l),n(d)},kf=({transmuxedData:e,callback:t})=>{e.buffer=[],t(e)},Af=(e,t)=>{t.gopInfo=e.data.gopInfo},jf=e=>{let{transmuxer:t,bytes:n,audioAppendStart:r,gopsToAlignWith:i,remux:a,onData:o,onTrackInfo:s,onAudioTimingInfo:c,onVideoTimingInfo:l,onVideoSegmentTimingInfo:u,onAudioSegmentTimingInfo:d,onId3:f,onCaptions:p,onDone:m,onEndedTimeline:h,onTransmuxerLog:g,isEndOfTimeline:_,segment:v,triggerSegmentEventFn:y}=e,b={buffer:[]},x=_;if(t.onmessage=n=>{t.currentTransmux===e&&(n.data.action===`data`&&Of(n,b,o),n.data.action===`trackinfo`&&s(n.data.trackInfo),n.data.action===`gopInfo`&&Af(n,b),n.data.action===`audioTimingInfo`&&c(n.data.audioTimingInfo),n.data.action===`videoTimingInfo`&&l(n.data.videoTimingInfo),n.data.action===`videoSegmentTimingInfo`&&u(n.data.videoSegmentTimingInfo),n.data.action===`audioSegmentTimingInfo`&&d(n.data.audioSegmentTimingInfo),n.data.action===`id3Frame`&&f([n.data.id3Frame],n.data.id3Frame.dispatchType),n.data.action===`caption`&&p(n.data.caption),n.data.action===`endedtimeline`&&(x=!1,h()),n.data.action===`log`&&g(n.data.log),n.data.type===`transmuxed`&&(x||(t.onmessage=null,kf({transmuxedData:b,callback:m}),Mf(t))))},t.onerror=()=>{let e={message:`Received an error message from the transmuxer worker`,metadata:{errorType:Z.Error.StreamingFailedToTransmuxSegment,segmentInfo:Jp({segment:v})}};m(null,e)},r&&t.postMessage({action:`setAudioAppendStart`,appendStart:r}),Array.isArray(i)&&t.postMessage({action:`alignGopsWith`,gopsToAlignWith:i}),a!==void 0&&t.postMessage({action:`setRemux`,remux:a}),n.byteLength){let e=n instanceof ArrayBuffer?n:n.buffer,r=n instanceof ArrayBuffer?0:n.byteOffset;y({type:`segmenttransmuxingstart`,segment:v}),t.postMessage({action:`push`,data:e,byteOffset:r,byteLength:n.byteLength},[e])}_&&t.postMessage({action:`endTimeline`}),t.postMessage({action:`flush`})},Mf=e=>{e.currentTransmux=null,e.transmuxQueue.length&&(e.currentTransmux=e.transmuxQueue.shift(),typeof e.currentTransmux==`function`?e.currentTransmux():jf(e.currentTransmux))},Nf=(e,t)=>{e.postMessage({action:t}),Mf(e)},Pf=(e,t)=>{t.currentTransmux?t.transmuxQueue.push(Nf.bind(null,t,e)):(t.currentTransmux=e,Nf(t,e))},Ff=e=>{Pf(`reset`,e)},If=e=>{Pf(`endTimeline`,e)},Lf=e=>{e.transmuxer.currentTransmux?e.transmuxer.transmuxQueue.push(e):(e.transmuxer.currentTransmux=e,jf(e))};var Rf={reset:Ff,endTimeline:If,transmux:Lf,createTransmuxer:e=>{let t=new Df;t.currentTransmux=null,t.transmuxQueue=[];let n=t.terminate;return t.terminate=()=>(t.currentTransmux=null,t.transmuxQueue.length=0,n.call(t)),t.postMessage({action:`init`,options:e}),t}};const zf=function(e){let t=e.transmuxer,n=e.endAction||e.action,r=e.callback,i=R({},e,{endAction:null,transmuxer:null,callback:null}),a=i=>{i.data.action===n&&(t.removeEventListener(`message`,a),i.data.data&&(i.data.data=new Uint8Array(i.data.data,e.byteOffset||0,e.byteLength||i.data.data.byteLength),e.data&&=i.data.data),r(i.data))};if(t.addEventListener(`message`,a),e.data){let n=e.data instanceof ArrayBuffer;i.byteOffset=n?0:e.data.byteOffset,i.byteLength=e.data.byteLength;let r=[n?e.data:e.data.buffer];t.postMessage(i,r)}else t.postMessage(i)},Bf={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Vf=`wvtt`,Hf=e=>{e.forEach(e=>{e.abort()})},Uf=e=>({bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}),Wf=e=>{let t=e.target,n={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return n.bytesReceived=e.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},Gf=(e,t)=>{let{requestType:n}=t,r=yd({requestType:n,request:t,error:e});return t.timedout?{status:t.status,message:`HLS request timed-out at URL: `+t.uri,code:Bf.TIMEOUT,xhr:t,metadata:r}:t.aborted?{status:t.status,message:`HLS request aborted at URL: `+t.uri,code:Bf.ABORTED,xhr:t,metadata:r}:e?{status:t.status,message:`HLS request errored at URL: `+t.uri,code:Bf.FAILURE,xhr:t,metadata:r}:t.responseType===`arraybuffer`&&t.response.byteLength===0?{status:t.status,message:`Empty HLS response at URL: `+t.uri,code:Bf.FAILURE,xhr:t,metadata:r}:null},Kf=(e,t,n,r)=>(i,a)=>{let o=a.response,s=Gf(i,a);if(s)return n(s,e);if(o.byteLength!==16)return n({status:a.status,message:`Invalid HLS key at URL: `+a.uri,code:Bf.FAILURE,xhr:a},e);let c=new DataView(o),l=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let e=0;e<t.length;e++)t[e].bytes=l;return r({type:`segmentkeyloadcomplete`,segment:e,keyInfo:{uri:a.uri}}),n(null,e)},qf=(e,t)=>{t===Vf&&e.transmuxer.postMessage({action:`initMp4WebVttParser`,data:e.map.bytes})},Jf=(e,t,n)=>{t===Vf&&zf({action:`getMp4WebVttText`,data:e.bytes,transmuxer:e.transmuxer,callback:({data:t,mp4VttCues:r})=>{e.bytes=t,n(null,e,{mp4VttCues:r})}})},Yf=(e,t)=>{let n=di(e.map.bytes);if(n!==`mp4`){let r=e.map.resolvedUri||e.map.uri,i=n||`unknown`;return t({internal:!0,message:`Found unsupported ${i} container for initialization segment at URL: ${r}`,code:Bf.FAILURE,metadata:{mediaType:i}})}zf({action:`probeMp4Tracks`,data:e.map.bytes,transmuxer:e.transmuxer,callback:({tracks:n,data:r})=>(e.map.bytes=r,n.forEach(function(t){e.map.tracks=e.map.tracks||{},!e.map.tracks[t.type]&&(e.map.tracks[t.type]=t,typeof t.id==`number`&&t.timescale&&(e.map.timescales=e.map.timescales||{},e.map.timescales[t.id]=t.timescale),t.type===`text`&&qf(e,t.codec))}),t(null))})},Xf=({segment:e,finishProcessingFn:t,triggerSegmentEventFn:n})=>(r,i)=>{let a=Gf(r,i);if(a)return t(a,e);let o=new Uint8Array(i.response);if(n({type:`segmentloaded`,segment:e}),e.map.key)return e.map.encryptedBytes=o,t(null,e);e.map.bytes=o,Yf(e,function(n){if(n)return n.xhr=i,n.status=i.status,t(n,e);t(null,e)})},Zf=({segment:e,finishProcessingFn:t,responseType:n,triggerSegmentEventFn:r})=>(i,a)=>{let o=Gf(i,a);if(o)return t(o,e);r({type:`segmentloaded`,segment:e});let s=n===`arraybuffer`||!a.responseText?a.response:xf(a.responseText.substring(e.lastReachedChar||0));return e.stats=Uf(a),e.key?e.encryptedBytes=new Uint8Array(s):e.bytes=new Uint8Array(s),t(null,e)},Qf=({segment:e,bytes:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{let m=e.map&&e.map.tracks||{},h=!!(m.audio&&m.video),g=r.bind(null,e,`audio`,`start`),_=r.bind(null,e,`audio`,`end`),v=r.bind(null,e,`video`,`start`),y=r.bind(null,e,`video`,`end`),b=()=>Lf({bytes:t,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,remux:h,onData:t=>{t.type=t.type===`combined`?`video`:t.type,u(e,t)},onTrackInfo:t=>{n&&(h&&(t.isMuxed=!0),n(e,t))},onAudioTimingInfo:e=>{g&&e.start!==void 0&&(g(e.start),g=null),_&&e.end!==void 0&&_(e.end)},onVideoTimingInfo:e=>{v&&e.start!==void 0&&(v(e.start),v=null),y&&e.end!==void 0&&y(e.end)},onVideoSegmentTimingInfo:t=>{p({type:`segmenttransmuxingtiminginfoavailable`,segment:e,timingInfo:{pts:{start:t.start.presentation,end:t.end.presentation},dts:{start:t.start.decode,end:t.end.decode}}}),i(t)},onAudioSegmentTimingInfo:t=>{p({type:`segmenttransmuxingtiminginfoavailable`,segment:e,timingInfo:{pts:{start:t.start.pts,end:t.end.pts},dts:{start:t.start.dts,end:t.end.dts}}}),a(t)},onId3:(t,n)=>{o(e,t,n)},onCaptions:t=>{s(e,[t])},isEndOfTimeline:c,onEndedTimeline:()=>{l()},onTransmuxerLog:f,onDone:(t,n)=>{d&&(t.type=t.type===`combined`?`video`:t.type,p({type:`segmenttransmuxingcomplete`,segment:e}),d(n,e,t))},segment:e,triggerSegmentEventFn:p});zf({action:`probeTs`,transmuxer:e.transmuxer,data:t,baseStartTime:e.baseStartTime,callback:r=>{e.bytes=t=r.data;let i=r.result;i&&(n(e,{hasAudio:i.hasAudio,hasVideo:i.hasVideo,isMuxed:h}),n=null),b()}})},$f=({segment:e,bytes:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{let m=new Uint8Array(t);if(fi(m)){e.isFmp4=!0;let{tracks:i}=e.map;if(i.text&&(!i.audio||!i.video)){u(e,{data:m,type:`text`}),Jf(e,i.text.codec,d);return}let a={isFmp4:!0,hasVideo:!!i.video,hasAudio:!!i.audio};i.audio&&i.audio.codec&&i.audio.codec!==`enca`&&(a.audioCodec=i.audio.codec),i.video&&i.video.codec&&i.video.codec!==`encv`&&(a.videoCodec=i.video.codec),i.video&&i.audio&&(a.isMuxed=!0),n(e,a);let c=(t,n)=>{u(e,{data:m,type:a.hasAudio&&!a.isMuxed?`audio`:`video`}),n&&n.length&&o(e,n),t&&t.length&&s(e,t),d(null,e,{})};zf({action:`probeMp4StartTime`,timescales:e.map.timescales,data:m,transmuxer:e.transmuxer,callback:({data:n,startTime:o})=>{t=n.buffer,e.bytes=m=n,a.hasAudio&&!a.isMuxed&&r(e,`audio`,`start`,o),a.hasVideo&&r(e,`video`,`start`,o),zf({action:`probeEmsgID3`,data:m,transmuxer:e.transmuxer,offset:o,callback:({emsgData:n,id3Frames:r})=>{t=n.buffer,e.bytes=m=n,!i.video||!n.byteLength||!e.transmuxer?c(void 0,r):zf({action:`pushMp4Captions`,endAction:`mp4Captions`,transmuxer:e.transmuxer,data:m,timescales:e.map.timescales,trackIds:[i.video.id],callback:n=>{t=n.data.buffer,e.bytes=m=n.data,n.logs.forEach(function(e){f(Q(e,{stream:`mp4CaptionParser`}))}),c(n.captions,r)}})}})}})}else e.transmuxer?(e.container===void 0&&(e.container=di(m)),e.container!==`ts`&&e.container!==`aac`?(n(e,{hasAudio:!1,hasVideo:!1}),d(null,e,{})):Qf({segment:e,bytes:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})):d(null,e,{})},ep=function({id:e,key:t,encryptedBytes:n,decryptionWorker:r,segment:i,doneFn:a},o){let s=t=>{if(t.data.source===e){r.removeEventListener(`message`,s);let e=t.data.decrypted;o(new Uint8Array(e.bytes,e.byteOffset,e.byteLength))}};r.onerror=()=>{let e=`An error occurred in the decryption worker`,t=Jp({segment:i});a({message:e,metadata:{error:Error(e),errorType:Z.Error.StreamingFailedToDecryptSegment,segmentInfo:t,keyInfo:{uri:i.key.resolvedUri||i.map.key.resolvedUri}}},i)},r.addEventListener(`message`,s);let c;c=t.bytes.slice?t.bytes.slice():new Uint32Array(Array.prototype.slice.call(t.bytes)),r.postMessage(qd({source:e,encrypted:n,key:c,iv:t.iv}),[n.buffer,c.buffer])},tp=({decryptionWorker:e,segment:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{p({type:`segmentdecryptionstart`}),ep({id:t.requestId,key:t.key,encryptedBytes:t.encryptedBytes,decryptionWorker:e,segment:t,doneFn:d},e=>{t.bytes=e,p({type:`segmentdecryptioncomplete`,segment:t}),$f({segment:t,bytes:t.bytes,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})})},np=({activeXhrs:e,decryptionWorker:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{let m=0,h=!1;return(g,_)=>{if(!h){if(g)return h=!0,Hf(e),d(g,_);if(m+=1,m===e.length){let m=function(){if(_.encryptedBytes)return tp({decryptionWorker:t,segment:_,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p});$f({segment:_,bytes:_.bytes,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})};if(_.endOfAllRequests=Date.now(),_.map&&_.map.encryptedBytes&&!_.map.bytes)return p({type:`segmentdecryptionstart`,segment:_}),ep({decryptionWorker:t,id:_.requestId+`-init`,encryptedBytes:_.map.encryptedBytes,key:_.map.key,segment:_,doneFn:d},t=>{_.map.bytes=t,p({type:`segmentdecryptioncomplete`,segment:_}),Yf(_,t=>{if(t)return Hf(e),d(t,_);m()})});m()}}}},rp=({loadendState:e,abortFn:t})=>n=>{n.target.aborted&&t&&!e.calledAbortFn&&(t(),e.calledAbortFn=!0)},ip=({segment:e,progressFn:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u})=>n=>{if(!n.target.aborted)return e.stats=Q(e.stats,Wf(n)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived&&(e.stats.firstBytesReceivedAt=Date.now()),t(n,e)},ap=({xhr:e,xhrOptions:t,decryptionWorker:n,segment:r,abortFn:i,progressFn:a,trackInfoFn:o,timingInfoFn:s,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:l,id3Fn:u,captionsFn:d,isEndOfTimeline:f,endedTimelineFn:p,dataFn:m,doneFn:h,onTransmuxerLog:g,triggerSegmentEventFn:_})=>{let v=[],y=np({activeXhrs:v,decryptionWorker:n,trackInfoFn:o,timingInfoFn:s,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:l,id3Fn:u,captionsFn:d,isEndOfTimeline:f,endedTimelineFn:p,dataFn:m,doneFn:h,onTransmuxerLog:g,triggerSegmentEventFn:_});if(r.key&&!r.key.bytes){let n=[r.key];r.map&&!r.map.bytes&&r.map.key&&r.map.key.resolvedUri===r.key.resolvedUri&&n.push(r.map.key);let i=Q(t,{uri:r.key.resolvedUri,responseType:`arraybuffer`,requestType:`segment-key`}),a=Kf(r,n,y,_);_({type:`segmentkeyloadstart`,segment:r,keyInfo:{uri:r.key.resolvedUri}});let o=e(i,a);v.push(o)}if(r.map&&!r.map.bytes){if(r.map.key&&(!r.key||r.key.resolvedUri!==r.map.key.resolvedUri)){let n=Q(t,{uri:r.map.key.resolvedUri,responseType:`arraybuffer`,requestType:`segment-key`}),i=Kf(r,[r.map.key],y,_);_({type:`segmentkeyloadstart`,segment:r,keyInfo:{uri:r.map.key.resolvedUri}});let a=e(n,i);v.push(a)}let n=Q(t,{uri:r.map.resolvedUri,responseType:`arraybuffer`,headers:Ud(r.map),requestType:`segment-media-initialization`}),i=Xf({segment:r,finishProcessingFn:y,triggerSegmentEventFn:_});_({type:`segmentloadstart`,segment:r});let a=e(n,i);v.push(a)}let b=Q(t,{uri:r.part&&r.part.resolvedUri||r.resolvedUri,responseType:`arraybuffer`,headers:Ud(r),requestType:`segment`}),x=Zf({segment:r,finishProcessingFn:y,responseType:b.responseType,triggerSegmentEventFn:_});_({type:`segmentloadstart`,segment:r});let S=e(b,x);S.addEventListener(`progress`,ip({segment:r,progressFn:a,trackInfoFn:o,timingInfoFn:s,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:l,id3Fn:u,captionsFn:d,isEndOfTimeline:f,endedTimelineFn:p,dataFn:m})),v.push(S);let C={};return v.forEach(e=>{e.addEventListener(`loadend`,rp({loadendState:C,abortFn:i}))}),()=>Hf(v)},op=xu(`PlaylistSelector`),sp=function(e){if(!e||!e.playlist)return;let t=e.playlist;return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||``})},cp=function(e,t){if(!e)return``;let n=x.getComputedStyle(e);return n?n[t]:``},lp=function(e,t){let n=e.slice();e.sort(function(e,r){let i=t(e,r);return i===0?n.indexOf(e)-n.indexOf(r):i})},up=function(e,t){let n,r;return e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n||=x.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(r=t.attributes.BANDWIDTH),r||=x.Number.MAX_VALUE,n-r},dp=function(e,t){let n,r;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n||=x.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(r=t.attributes.RESOLUTION.width),r||=x.Number.MAX_VALUE,n===r&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:n-r};let fp=function(e){let{main:t,bandwidth:n,playerWidth:r,playerHeight:i,playerObjectFit:a,limitRenditionByPlayerDimensions:o,playlistController:s}=e;if(!t)return;let c={bandwidth:n,width:r,height:i,limitRenditionByPlayerDimensions:o},l=t.playlists;sd.isAudioOnly(t)&&(l=s.getAudioTrackPlaylists_(),c.audioOnly=!0);let u=l.map(e=>{let t,n=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,r=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height;return t=e.attributes&&e.attributes.BANDWIDTH,t||=x.Number.MAX_VALUE,{bandwidth:t,width:n,height:r,playlist:e}});lp(u,(e,t)=>e.bandwidth-t.bandwidth),u=u.filter(e=>!sd.isIncompatible(e.playlist));let d=u.filter(e=>sd.isEnabled(e.playlist));d.length||(d=u.filter(e=>!sd.isDisabled(e.playlist)));let f=d.filter(e=>e.bandwidth*bf.BANDWIDTH_VARIANCE<n),p=f[f.length-1],m=f.filter(e=>e.bandwidth===p.bandwidth)[0];if(o===!1){let e=m||d[0]||u[0];if(e&&e.playlist){let t=`sortedPlaylistReps`;return m&&(t=`bandwidthBestRep`),d[0]&&(t=`enabledPlaylistReps`),op(`choosing ${sp(e)} using ${t} with options`,c),e.playlist}return op(`could not choose a playlist with options`,c),null}let h=f.filter(e=>e.width&&e.height);lp(h,(e,t)=>e.width-t.width);let g=h.filter(e=>e.width===r&&e.height===i);p=g[g.length-1];let _=g.filter(e=>e.bandwidth===p.bandwidth)[0],v,y,b;_||(v=h.filter(e=>a===`cover`?e.width>r&&e.height>i:e.width>r||e.height>i),y=v.filter(e=>e.width===v[0].width&&e.height===v[0].height),p=y[y.length-1],b=y.filter(e=>e.bandwidth===p.bandwidth)[0]);let S;if(s.leastPixelDiffSelector){let e=h.map(e=>(e.pixelDiff=Math.abs(e.width-r)+Math.abs(e.height-i),e));lp(e,(e,t)=>e.pixelDiff===t.pixelDiff?t.bandwidth-e.bandwidth:e.pixelDiff-t.pixelDiff),S=e[0]}let C=S||b||_||m||d[0]||u[0];if(C&&C.playlist){let e=`sortedPlaylistReps`;return S?e=`leastPixelDiffRep`:b?e=`resolutionPlusOneRep`:_?e=`resolutionBestRep`:m?e=`bandwidthBestRep`:d[0]&&(e=`enabledPlaylistReps`),op(`choosing ${sp(C)} using ${e} with options`,c),C.playlist}return op(`could not choose a playlist with options`,c),null};const pp=function(){let e=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(e=this.customPixelRatio),fp({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(cp(this.tech_.el(),`width`),10)*e,playerHeight:parseInt(cp(this.tech_.el(),`height`),10)*e,playerObjectFit:this.usePlayerObjectFit?cp(this.tech_.el(),`objectFit`):``,limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},mp=function(e){let t=-1,n=-1;if(e<0||e>1)throw Error(`Moving average bandwidth decay must be between 0 and 1.`);return function(){let r=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(r=this.customPixelRatio),t<0&&(t=this.systemBandwidth,n=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==n&&(t=e*this.systemBandwidth+(1-e)*t,n=this.systemBandwidth),fp({main:this.playlists.main,bandwidth:t,playerWidth:parseInt(cp(this.tech_.el(),`width`),10)*r,playerHeight:parseInt(cp(this.tech_.el(),`height`),10)*r,playerObjectFit:this.usePlayerObjectFit?cp(this.tech_.el(),`objectFit`):``,limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},hp=function(e){let{main:t,currentTime:n,bandwidth:r,duration:i,segmentDuration:a,timeUntilRebuffer:o,currentTimeline:s,syncController:c}=e,l=t.playlists.filter(e=>!sd.isIncompatible(e)),u=l.filter(sd.isEnabled);u.length||(u=l.filter(e=>!sd.isDisabled(e)));let d=u.filter(sd.hasAttribute.bind(null,`BANDWIDTH`)).map(e=>{let t=c.getSyncPoint(e,i,s,n)?1:2;return{playlist:e,rebufferingImpact:sd.estimateSegmentRequestTime(a,r,e)*t-o}}),f=d.filter(e=>e.rebufferingImpact<=0);return lp(f,(e,t)=>up(t.playlist,e.playlist)),f.length?f[0]:(lp(d,(e,t)=>e.rebufferingImpact-t.rebufferingImpact),d[0]||null)},gp=function(){let e=this.playlists.main.playlists.filter(sd.isEnabled);return lp(e,(e,t)=>up(e,t)),e.filter(e=>!!Ed(this.playlists.main,e).video)[0]||null},_p=e=>{let t=0,n;return e.bytes&&(n=new Uint8Array(e.bytes),e.segments.forEach(e=>{n.set(e,t),t+=e.byteLength})),n};function vp(e){try{return new URL(e).pathname.split(`/`).slice(-2).join(`/`)}catch{return``}}const yp=function(e,t,n){if(!e[n]){t.trigger({type:`usage`,name:`vhs-608`});let r=n;/^cc708_/.test(n)&&(r=`SERVICE`+n.split(`_`)[1]);let i=t.textTracks().getTrackById(r);if(i)e[n]=i;else{let i=t.options_.vhs&&t.options_.vhs.captionServices||{},a=n,o=n,s=!1,c=i[r];c&&(a=c.label,o=c.language,s=c.default),e[n]=t.addRemoteTextTrack({kind:`captions`,id:r,default:s,label:a,language:o},!1).track}}},bp=function({inbandTextTracks:e,captionArray:t,timestampOffset:n}){if(!t)return;let r=x.WebKitDataCue||x.VTTCue;t.forEach(t=>{let i=t.stream;t.content?t.content.forEach(a=>{let o=new r(t.startTime+n,t.endTime+n,a.text);o.line=a.line,o.align=`left`,o.position=a.position,o.positionAlign=`line-left`,e[i].addCue(o)}):e[i].addCue(new r(t.startTime+n,t.endTime+n,t.text))})},xp=function(e){Object.defineProperties(e.frame,{id:{get(){return Z.log.warn(`cue.frame.id is deprecated. Use cue.value.key instead.`),e.value.key}},value:{get(){return Z.log.warn(`cue.frame.value is deprecated. Use cue.value.data instead.`),e.value.data}},privateData:{get(){return Z.log.warn(`cue.frame.privateData is deprecated. Use cue.value.data instead.`),e.value.data}}})},Sp=({inbandTextTracks:e,metadataArray:t,timestampOffset:n,videoDuration:r})=>{if(!t)return;let i=x.WebKitDataCue||x.VTTCue,a=e.metadataTrack_;if(!a||(t.forEach(e=>{let t=e.cueTime+n;typeof t!=`number`||x.isNaN(t)||t<0||!(t<1/0)||e.frames&&e.frames.length&&e.frames.forEach(e=>{let n=new i(t,t,e.value||e.url||e.data||``);n.frame=e,n.value=e,xp(n),a.addCue(n)})}),!a.cues||!a.cues.length))return;let o=a.cues,s=[];for(let e=0;e<o.length;e++)o[e]&&s.push(o[e]);let c=s.reduce((e,t)=>{let n=e[t.startTime]||[];return n.push(t),e[t.startTime]=n,e},{}),l=Object.keys(c).sort((e,t)=>Number(e)-Number(t));l.forEach((e,t)=>{let n=c[e],i=isFinite(r)?r:e,a=Number(l[t+1])||i;n.forEach(e=>{e.endTime=a})})},Cp={id:`ID`,class:`CLASS`,startDate:`START-DATE`,duration:`DURATION`,endDate:`END-DATE`,endOnNext:`END-ON-NEXT`,plannedDuration:`PLANNED-DURATION`,scte35Out:`SCTE35-OUT`,scte35In:`SCTE35-IN`},wp=new Set([`id`,`class`,`startDate`,`duration`,`endDate`,`endOnNext`,`startTime`,`endTime`,`processDateRange`]),Tp=({inbandTextTracks:e,dateRanges:t})=>{let n=e.metadataTrack_;if(!n)return;let r=x.WebKitDataCue||x.VTTCue;t.forEach(e=>{for(let t of Object.keys(e)){if(wp.has(t))continue;let i=new r(e.startTime,e.endTime,``);i.id=e.id,i.type=`com.apple.quicktime.HLS`,i.value={key:Cp[t],data:e[t]},(t===`scte35Out`||t===`scte35In`)&&(i.value.data=new Uint8Array(i.value.data.match(/[\da-f]{2}/gi)).buffer),n.addCue(i)}e.processDateRange()})},Ep=(e,t,n)=>{e.metadataTrack_||(e.metadataTrack_=n.addRemoteTextTrack({kind:`metadata`,label:`Timed Metadata`},!1).track,Z.browser.IS_ANY_SAFARI||(e.metadataTrack_.inBandMetadataTrackDispatchType=t))},Dp=function(e,t,n){let r,i;if(n&&n.cues)for(r=n.cues.length;r--;)i=n.cues[r],i.startTime>=e&&i.endTime<=t&&n.removeCue(i)},Op=function(e){let t=e.cues;if(!t)return;let n={};for(let r=t.length-1;r>=0;r--){let i=t[r],a=`${i.startTime}-${i.endTime}-${i.text}`;n[a]?e.removeCue(i):n[a]=i}},kp=(e,t,n)=>{if(t==null||!e.length)return[];let r=Math.ceil((t-n+3)*gi.ONE_SECOND_IN_TS),i=0;for(;i<e.length&&!(e[i].pts>r);i++);return e.slice(i)},Ap=(e,t,n)=>{if(!t.length)return e;if(n)return t.slice();let r=t[0].pts,i=0;for(;i<e.length&&!(e[i].pts>=r);i++);return e.slice(0,i).concat(t)},jp=(e,t,n,r)=>{let i=Math.ceil((t-r)*gi.ONE_SECOND_IN_TS),a=Math.ceil((n-r)*gi.ONE_SECOND_IN_TS),o=e.slice(),s=e.length;for(;s--&&!(e[s].pts<=a););if(s===-1)return o;let c=s+1;for(;c--&&!(e[c].pts<=i););return c=Math.max(c,0),o.splice(c,s-c+1),o},Mp=function(e,t){if(!e&&!t||!e&&t||e&&!t)return!1;if(e===t)return!0;let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++){let a=n[i];if(a!==r[i]||e[a]!==t[a])return!1}return!0},Np=function(e,t,n){t||=[];let r=[],i=0;for(let a=0;a<t.length;a++){let o=t[a];if(e===o.timeline&&(r.push(a),i+=o.duration,i>n))return a}return r.length===0?0:r[r.length-1]},Pp=e=>typeof e==`number`&&isFinite(e),Fp=1/60,Ip=(e,t,n)=>e!==`main`||!t||!n?null:!n.hasAudio&&!n.hasVideo?`Neither audio nor video found in segment.`:t.hasVideo&&!n.hasVideo?`Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.`:!t.hasVideo&&n.hasVideo?`Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.`:null,Lp=(e,t,n)=>{let r=t-bf.BACK_BUFFER_LENGTH;e.length&&(r=Math.max(r,e.start(0)));let i=t-n;return Math.min(i,r)},Rp=e=>{let{startOfSegment:t,duration:n,segment:r,part:i,playlist:{mediaSequence:a,id:o,segments:s=[]},mediaIndex:c,partIndex:l,timeline:u}=e,d=s.length-1,f=`mediaIndex/partIndex increment`;e.getMediaInfoForTime?f=`getMediaInfoForTime (${e.getMediaInfoForTime})`:e.isSyncRequest&&(f=`getSyncSegmentCandidate (isSyncRequest)`),e.independent&&(f+=` with independent ${e.independent}`);let p=typeof l==`number`,m=e.segment.uri?`segment`:`pre-segment`,h=p?Bu({preloadSegment:r})-1:0;return`${m} [${a+c}/${a+d}]`+(p?` part [${l}/${h}]`:``)+` segment start/end [${r.start} => ${r.end}]`+(p?` part start/end [${i.start} => ${i.end}]`:``)+` startOfSegment [${t}] duration [${n}] timeline [${u}] selected by [${f}] playlist [${o}]`},zp=e=>`${e}TimingInfo`,Bp=({segmentTimeline:e,currentTimeline:t,startOfSegment:n,buffered:r,overrideCheck:i})=>!i&&e===t?null:e<t?n:r.length?r.end(r.length-1):n,Vp=({timelineChangeController:e,currentTimeline:t,segmentTimeline:n,loaderType:r,audioDisabled:i})=>{if(t===n)return!1;if(r===`audio`){let t=e.lastTimelineChange({type:`main`});return!t||t.to!==n}if(r===`main`&&i){let t=e.pendingTimelineChange({type:`audio`});return!(t&&t.to===n)}return!1},Hp=e=>{if(!e)return!1;let t=e.pendingTimelineChange({type:`audio`}),n=e.pendingTimelineChange({type:`main`}),r=t&&n,i=r&&t.to!==n.to;return!!(r&&t.from!==-1&&n.from!==-1&&i)},Up=e=>{let t=e.timelineChangeController_.pendingTimelineChange({type:`audio`}),n=e.timelineChangeController_.pendingTimelineChange({type:`main`});return t&&n&&t.to<n.to},Wp=e=>{let t=e.pendingSegment_;if(t&&Vp({timelineChangeController:e.timelineChangeController_,currentTimeline:e.currentTimeline_,segmentTimeline:t.timeline,loaderType:e.loaderType_,audioDisabled:e.audioDisabled_})&&Hp(e.timelineChangeController_)){if(Up(e)){e.timelineChangeController_.trigger(`audioTimelineBehind`);return}e.timelineChangeController_.trigger(`fixBadTimelineChange`)}},Gp=e=>{let t=0;return[`video`,`audio`].forEach(function(n){let r=e[`${n}TimingInfo`];if(!r)return;let{start:i,end:a}=r,o;typeof i==`bigint`||typeof a==`bigint`?o=x.BigInt(a)-x.BigInt(i):typeof i==`number`&&typeof a==`number`&&(o=a-i),o!==void 0&&o>t&&(t=o)}),typeof t==`bigint`&&t<2**53-1&&(t=Number(t)),t},Kp=({segmentDuration:e,maxDuration:t})=>e?Math.round(e)>t+wu:!1,qp=(e,t)=>{if(t!==`hls`)return null;let n=Gp({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo});if(!n)return null;let r=e.playlist.targetDuration,i=Kp({segmentDuration:n,maxDuration:r*2}),a=Kp({segmentDuration:n,maxDuration:r}),o=`Segment with index ${e.mediaIndex} from playlist ${e.playlist.id} has a duration of ${n} when the reported duration is ${e.duration} and the target duration is ${r}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return i||a?{severity:i?`warn`:`info`,message:o}:null},Jp=({type:e,segment:t})=>{if(!t)return;let n=!!(t.key||t.map&&t.map.ke),r=!(!t.map||t.map.bytes),i=t.startOfSegment===void 0?t.start:t.startOfSegment;return{type:e||t.type,uri:t.resolvedUri||t.uri,start:i,duration:t.duration,isEncrypted:n,isMediaInitialization:r}};class Yp extends Z.EventTarget{constructor(e,t={}){if(super(),!e)throw TypeError(`Initialization settings are required`);if(typeof e.currentTime!=`function`)throw TypeError(`No currentTime getter specified`);if(!e.mediaSource)throw TypeError(`No MediaSource specified`);this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_=`INIT`,this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger(`syncinfoupdate`),this.syncController_.on(`syncinfoupdate`,this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener(`sourceopen`,()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=xu(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(e){e!==this.state_&&(this.logger_(`${this.state_} -> ${e}`),this.state_=e,this.trigger(`statechange`))}}),this.sourceUpdater_.on(`ready`,()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)}),this.sourceUpdater_.on(`codecschange`,e=>{this.trigger(R({type:`codecschange`},e))}),this.loaderType_===`main`&&this.timelineChangeController_.on(`pendingtimelinechange`,()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)}),this.loaderType_===`audio`&&this.timelineChangeController_.on(`timelinechange`,e=>{this.trigger(R({type:`timelinechange`},e)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():Wp(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Rf.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger(`dispose`),this.state=`DISPOSED`,this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off(`syncinfoupdate`,this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){this.state===`WAITING`?(this.abort_(),this.state=`READY`,this.paused()||this.monitorBuffer_()):(this.pendingSegment_&&=null,this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_))}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,x.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state===`APPENDING`&&!this.pendingSegment_?(this.state=`READY`,!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return e!==void 0&&(this.logger_(`error occurred:`,e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Rf.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger(`ended`)}buffered_(){let e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return Su();if(this.loaderType_===`main`){let{hasAudio:t,hasVideo:n,isMuxed:r}=e;if(n&&t&&!this.audioDisabled_&&!r)return this.sourceUpdater_.buffered();if(n)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;let n=Jd(e),r=this.initSegments_[n];return t&&!r&&e.bytes&&(this.initSegments_[n]=r={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),r||e}segmentKey(e,t=!1){if(!e)return null;let n=Yd(e),r=this.keyCache_[n];this.cacheEncryptionKeys_&&t&&!r&&e.bytes&&(this.keyCache_[n]=r={resolvedUri:e.resolvedUri,bytes:e.bytes});let i={resolvedUri:(r||e).resolvedUri};return r&&(i.bytes=r.bytes),i}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),this.playlist_){if(this.state===`INIT`&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!==`READY`&&this.state!==`INIT`||(this.state=`READY`)}}init_(){return this.state=`READY`,this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;let n=this.playlist_,r=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state===`INIT`&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_===`main`&&this.syncController_.setDateTimeMappingForStart(e));let i=null;if(n&&(n.id?i=n.id:n.uri&&(i=n.uri)),this.logger_(`playlist update [${i} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
187
+ `),this.pushCaption(t),t.startPts=e},I.prototype.pushCaption=function(e){e.text!==``&&(this.trigger(`data`,{startPts:e.startPts,endPts:e.endPts,text:e.text,stream:`cc708_`+e.serviceNum}),e.text=``,e.startPts=e.endPts)},I.prototype.displayWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&(t.windows[i].visible=1);return e},I.prototype.hideWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&(t.windows[i].visible=0);return e},I.prototype.toggleWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&(t.windows[i].visible^=1);return e},I.prototype.clearWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&t.windows[i].clearText();return e},I.prototype.deleteWindows=function(e,t){var n=this.current708Packet.data[++e],r=this.getPts(e);this.flushDisplayed(r,t);for(var i=0;i<8;i++)n&1<<i&&t.windows[i].reset();return e},I.prototype.setPenAttributes=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.penAttr;return r=n[++e],i.textTag=(r&240)>>4,i.offset=(r&12)>>2,i.penSize=r&3,r=n[++e],i.italics=(r&128)>>7,i.underline=(r&64)>>6,i.edgeType=(r&56)>>3,i.fontStyle=r&7,e},I.prototype.setPenColor=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.penColor;return r=n[++e],i.fgOpacity=(r&192)>>6,i.fgRed=(r&48)>>4,i.fgGreen=(r&12)>>2,i.fgBlue=r&3,r=n[++e],i.bgOpacity=(r&192)>>6,i.bgRed=(r&48)>>4,i.bgGreen=(r&12)>>2,i.bgBlue=r&3,r=n[++e],i.edgeRed=(r&48)>>4,i.edgeGreen=(r&12)>>2,i.edgeBlue=r&3,e},I.prototype.setPenLocation=function(e,t){var n=this.current708Packet.data,r=n[e],i=t.currentWindow.penLoc;return t.currentWindow.pendingNewLine=!0,r=n[++e],i.row=r&15,r=n[++e],i.column=r&63,e},I.prototype.reset=function(e,t){var n=this.getPts(e);return this.flushDisplayed(n,t),this.initService(t.serviceNum,e)};var He={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,304:174,305:176,306:189,307:191,308:8482,309:162,310:163,311:9834,312:224,313:160,314:232,315:226,316:234,317:238,318:244,319:251,544:193,545:201,546:211,547:218,548:220,549:252,550:8216,551:161,552:42,553:39,554:8212,555:169,556:8480,557:8226,558:8220,559:8221,560:192,561:194,562:199,563:200,564:202,565:203,566:235,567:206,568:207,569:239,570:212,571:217,572:249,573:219,574:171,575:187,800:195,801:227,802:205,803:204,804:236,805:210,806:242,807:213,808:245,809:123,810:125,811:92,812:94,813:95,814:124,815:126,816:196,817:228,818:214,819:246,820:223,821:165,822:164,823:9474,824:197,825:229,826:216,827:248,828:9484,829:9488,830:9492,831:9496},Ue=function(e){return e===null?``:(e=He[e]||e,String.fromCharCode(e))},We=14,Ge=[4352,4384,4608,4640,5376,5408,5632,5664,5888,5920,4096,4864,4896,5120,5152],Ke=function(){for(var e=[],t=We+1;t--;)e.push({text:``,indent:0,offset:0});return e},L=function(e,t){L.prototype.init.call(this),this.field_=e||0,this.dataChannel_=t||0,this.name_=`CC`+((this.field_<<1|this.dataChannel_)+1),this.setConstants(),this.reset(),this.push=function(e){var t=e.ccData&32639,n,r,i,a;if(t===this.lastControlCode_)this.lastControlCode_=null;else if((t&61440)==4096?this.lastControlCode_=t:t!==this.PADDING_&&(this.lastControlCode_=null),r=t>>>8,i=t&255,t!==this.PADDING_){if(t===this.RESUME_CAPTION_LOADING_)this.mode_=`popOn`;else if(t===this.END_OF_CAPTION_)this.mode_=`popOn`,this.clearFormatting(e.pts),this.flushDisplayed(e.pts),n=this.displayed_,this.displayed_=this.nonDisplayed_,this.nonDisplayed_=n,this.startPts_=e.pts;else if(t===this.ROLL_UP_2_ROWS_)this.rollUpRows_=2,this.setRollUp(e.pts);else if(t===this.ROLL_UP_3_ROWS_)this.rollUpRows_=3,this.setRollUp(e.pts);else if(t===this.ROLL_UP_4_ROWS_)this.rollUpRows_=4,this.setRollUp(e.pts);else if(t===this.CARRIAGE_RETURN_)this.clearFormatting(e.pts),this.flushDisplayed(e.pts),this.shiftRowsUp_(),this.startPts_=e.pts;else if(t===this.BACKSPACE_)this.mode_===`popOn`?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1);else if(t===this.ERASE_DISPLAYED_MEMORY_)this.flushDisplayed(e.pts),this.displayed_=Ke();else if(t===this.ERASE_NON_DISPLAYED_MEMORY_)this.nonDisplayed_=Ke();else if(t===this.RESUME_DIRECT_CAPTIONING_)this.mode_!==`paintOn`&&(this.flushDisplayed(e.pts),this.displayed_=Ke()),this.mode_=`paintOn`,this.startPts_=e.pts;else if(this.isSpecialCharacter(r,i))r=(r&3)<<8,a=Ue(r|i),this[this.mode_](e.pts,a),this.column_++;else if(this.isExtCharacter(r,i))this.mode_===`popOn`?this.nonDisplayed_[this.row_].text=this.nonDisplayed_[this.row_].text.slice(0,-1):this.displayed_[this.row_].text=this.displayed_[this.row_].text.slice(0,-1),r=(r&3)<<8,a=Ue(r|i),this[this.mode_](e.pts,a),this.column_++;else if(this.isMidRowCode(r,i))this.clearFormatting(e.pts),this[this.mode_](e.pts,` `),this.column_++,(i&14)==14&&this.addFormatting(e.pts,[`i`]),(i&1)==1&&this.addFormatting(e.pts,[`u`]);else if(this.isOffsetControlCode(r,i)){let e=i&3;this.nonDisplayed_[this.row_].offset=e,this.column_+=e}else if(this.isPAC(r,i)){var o=Ge.indexOf(t&7968);if(this.mode_===`rollUp`&&(o-this.rollUpRows_+1<0&&(o=this.rollUpRows_-1),this.setRollUp(e.pts,o)),o!==this.row_&&o>=0&&o<=14&&(this.clearFormatting(e.pts),this.row_=o),i&1&&this.formatting_.indexOf(`u`)===-1&&this.addFormatting(e.pts,[`u`]),(t&16)==16){let e=(t&14)>>1;this.column_=e*4,this.nonDisplayed_[this.row_].indent+=e}this.isColorPAC(i)&&(i&14)==14&&this.addFormatting(e.pts,[`i`])}else this.isNormalChar(r)&&(i===0&&(i=null),a=Ue(r),a+=Ue(i),this[this.mode_](e.pts,a),this.column_+=a.length)}}};L.prototype=new Pe,L.prototype.flushDisplayed=function(e){let t=e=>{this.trigger(`log`,{level:`warn`,message:`Skipping a malformed 608 caption at index `+e+`.`})},n=[];this.displayed_.forEach((e,r)=>{if(e&&e.text&&e.text.length){try{e.text=e.text.trim()}catch{t(r)}e.text.length&&n.push({text:e.text,line:r+1,position:10+Math.min(70,e.indent*10)+e.offset*2.5})}else e??t(r)}),n.length&&this.trigger(`data`,{startPts:this.startPts_,endPts:e,content:n,stream:this.name_})},L.prototype.reset=function(){this.mode_=`popOn`,this.topRow_=0,this.startPts_=0,this.displayed_=Ke(),this.nonDisplayed_=Ke(),this.lastControlCode_=null,this.column_=0,this.row_=We,this.rollUpRows_=2,this.formatting_=[]},L.prototype.setConstants=function(){this.dataChannel_===0?(this.BASE_=16,this.EXT_=17,this.CONTROL_=(20|this.field_)<<8,this.OFFSET_=23):this.dataChannel_===1&&(this.BASE_=24,this.EXT_=25,this.CONTROL_=(28|this.field_)<<8,this.OFFSET_=31),this.PADDING_=0,this.RESUME_CAPTION_LOADING_=this.CONTROL_|32,this.END_OF_CAPTION_=this.CONTROL_|47,this.ROLL_UP_2_ROWS_=this.CONTROL_|37,this.ROLL_UP_3_ROWS_=this.CONTROL_|38,this.ROLL_UP_4_ROWS_=this.CONTROL_|39,this.CARRIAGE_RETURN_=this.CONTROL_|45,this.RESUME_DIRECT_CAPTIONING_=this.CONTROL_|41,this.BACKSPACE_=this.CONTROL_|33,this.ERASE_DISPLAYED_MEMORY_=this.CONTROL_|44,this.ERASE_NON_DISPLAYED_MEMORY_=this.CONTROL_|46},L.prototype.isSpecialCharacter=function(e,t){return e===this.EXT_&&t>=48&&t<=63},L.prototype.isExtCharacter=function(e,t){return(e===this.EXT_+1||e===this.EXT_+2)&&t>=32&&t<=63},L.prototype.isMidRowCode=function(e,t){return e===this.EXT_&&t>=32&&t<=47},L.prototype.isOffsetControlCode=function(e,t){return e===this.OFFSET_&&t>=33&&t<=35},L.prototype.isPAC=function(e,t){return e>=this.BASE_&&e<this.BASE_+8&&t>=64&&t<=127},L.prototype.isColorPAC=function(e){return e>=64&&e<=79||e>=96&&e<=127},L.prototype.isNormalChar=function(e){return e>=32&&e<=127},L.prototype.setRollUp=function(e,t){if(this.mode_!==`rollUp`&&(this.row_=We,this.mode_=`rollUp`,this.flushDisplayed(e),this.nonDisplayed_=Ke(),this.displayed_=Ke()),t!==void 0&&t!==this.row_)for(var n=0;n<this.rollUpRows_;n++)this.displayed_[t-n]=this.displayed_[this.row_-n],this.displayed_[this.row_-n]={text:``,indent:0,offset:0};t===void 0&&(t=this.row_),this.topRow_=t-this.rollUpRows_+1},L.prototype.addFormatting=function(e,t){this.formatting_=this.formatting_.concat(t);var n=t.reduce(function(e,t){return e+`<`+t+`>`},``);this[this.mode_](e,n)},L.prototype.clearFormatting=function(e){if(this.formatting_.length){var t=this.formatting_.reverse().reduce(function(e,t){return e+`</`+t+`>`},``);this.formatting_=[],this[this.mode_](e,t)}},L.prototype.popOn=function(e,t){var n=this.nonDisplayed_[this.row_].text;n+=t,this.nonDisplayed_[this.row_].text=n},L.prototype.rollUp=function(e,t){var n=this.displayed_[this.row_].text;n+=t,this.displayed_[this.row_].text=n},L.prototype.shiftRowsUp_=function(){for(var e=0;e<this.topRow_;e++)this.displayed_[e]={text:``,indent:0,offset:0};for(e=this.row_+1;e<We+1;e++)this.displayed_[e]={text:``,indent:0,offset:0};for(e=this.topRow_;e<this.row_;e++)this.displayed_[e]=this.displayed_[e+1];this.displayed_[this.row_]={text:``,indent:0,offset:0}},L.prototype.paintOn=function(e,t){var n=this.displayed_[this.row_].text;n+=t,this.displayed_[this.row_].text=n};var qe={CaptionStream:Ie,Cea608Stream:L,Cea708Stream:I},Je={H264_STREAM_TYPE:27,ADTS_STREAM_TYPE:15,METADATA_STREAM_TYPE:21},Ye=n,Xe=8589934592,Ze=4294967296,Qe=`shared`,$e=function(e,t){var n=1;for(e>t&&(n=-1);Math.abs(t-e)>Ze;)e+=n*Xe;return e},et=function(e){var t,n;et.prototype.init.call(this),this.type_=e||Qe,this.push=function(e){e.type===`metadata`?this.trigger(`data`,e):(this.type_===Qe||e.type===this.type_)&&(n===void 0&&(n=e.dts),e.dts=$e(e.dts,n),e.pts=$e(e.pts,n),t=e.dts,this.trigger(`data`,e))},this.flush=function(){n=t,this.trigger(`done`)},this.endTimeline=function(){this.flush(),this.trigger(`endedtimeline`)},this.discontinuity=function(){n=void 0,t=void 0},this.reset=function(){this.discontinuity(),this.trigger(`reset`)}};et.prototype=new Ye;var tt={TimestampRolloverStream:et,handleRollover:$e},nt={typedArrayIndexOf:(e,t,n)=>{if(!e)return-1;for(var r=n;r<e.length;r++)if(e[r]===t)return r;return-1}}.typedArrayIndexOf,rt={Utf8:3},it=function(e,t,n){var r,i=``;for(r=t;r<n;r++)i+=`%`+(`00`+e[r].toString(16)).slice(-2);return i},R=function(e,t,n){return decodeURIComponent(it(e,t,n))},at=function(e,t,n){return unescape(it(e,t,n))},ot=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},st={APIC:function(e){var t=1,n,r;e.data[0]===rt.Utf8&&(n=nt(e.data,0,t),n<0||(e.mimeType=at(e.data,t,n),t=n+1,e.pictureType=e.data[t],t++,r=nt(e.data,0,t),r<0||(e.description=R(e.data,t,r),t=r+1,e.mimeType===`-->`?e.url=at(e.data,t,e.data.length):e.pictureData=e.data.subarray(t,e.data.length))))},"T*":function(e){e.data[0]===rt.Utf8&&(e.value=R(e.data,1,e.data.length).replace(/\0*$/,``),e.values=e.value.split(`\0`))},TXXX:function(e){var t;e.data[0]===rt.Utf8&&(t=nt(e.data,0,1),t!==-1&&(e.description=R(e.data,1,t),e.value=R(e.data,t+1,e.data.length).replace(/\0*$/,``),e.data=e.value))},"W*":function(e){e.url=at(e.data,0,e.data.length).replace(/\0.*$/,``)},WXXX:function(e){var t;e.data[0]===rt.Utf8&&(t=nt(e.data,0,1),t!==-1&&(e.description=R(e.data,1,t),e.url=at(e.data,t+1,e.data.length).replace(/\0.*$/,``)))},PRIV:function(e){for(var t=0;t<e.data.length;t++)if(e.data[t]===0){e.owner=at(e.data,0,t);break}e.privateData=e.data.subarray(t+1),e.data=e.privateData}},ct={parseId3Frames:function(e){var t,n,r=10,i=0,a=[];if(!(e.length<10||e[0]!==73||e[1]!==68||e[2]!==51)){i=ot(e.subarray(6,10)),i+=10,e[5]&64&&(r+=4,r+=ot(e.subarray(10,14)),i-=ot(e.subarray(16,20)));do{if(t=ot(e.subarray(r+4,r+8)),t<1)break;n=String.fromCharCode(e[r],e[r+1],e[r+2],e[r+3]);var o={id:n,data:e.subarray(r+10,r+t+10)};o.key=o.id,st[o.id]?st[o.id](o):o.id[0]===`T`?st[`T*`](o):o.id[0]===`W`&&st[`W*`](o),a.push(o),r+=10,r+=t}while(r<i);return a}},parseSyncSafeInteger:ot,frameParsers:st},lt=n,ut=Je,dt=ct,ft=function(e){var t={descriptor:e&&e.descriptor},n=0,r=[],i=0,a;if(ft.prototype.init.call(this),this.dispatchType=ut.METADATA_STREAM_TYPE.toString(16),t.descriptor)for(a=0;a<t.descriptor.length;a++)this.dispatchType+=(`00`+t.descriptor[a].toString(16)).slice(-2);this.push=function(e){var t,a,o,s,c,l;if(e.type===`timed-metadata`){if(e.dataAlignmentIndicator&&(i=0,r.length=0),r.length===0&&(e.data.length<10||e.data[0]!==73||e.data[1]!==68||e.data[2]!==51))this.trigger(`log`,{level:`warn`,message:`Skipping unrecognized metadata packet`});else if(r.push(e),i+=e.data.byteLength,r.length===1&&(n=dt.parseSyncSafeInteger(e.data.subarray(6,10)),n+=10),!(i<n)){for(t={data:new Uint8Array(n),frames:[],pts:r[0].pts,dts:r[0].dts},c=0;c<n;)t.data.set(r[0].data.subarray(0,n-c),c),c+=r[0].data.byteLength,i-=r[0].data.byteLength,r.shift();a=10,t.data[5]&64&&(a+=4,a+=dt.parseSyncSafeInteger(t.data.subarray(10,14)),n-=dt.parseSyncSafeInteger(t.data.subarray(16,20)));do{if(o=dt.parseSyncSafeInteger(t.data.subarray(a+4,a+8)),o<1){this.trigger(`log`,{level:`warn`,message:`Malformed ID3 frame encountered. Skipping remaining metadata parsing.`});break}if(l=String.fromCharCode(t.data[a],t.data[a+1],t.data[a+2],t.data[a+3]),s={id:l,data:t.data.subarray(a+10,a+o+10)},s.key=s.id,dt.frameParsers[s.id]?dt.frameParsers[s.id](s):s.id[0]===`T`?dt.frameParsers[`T*`](s):s.id[0]===`W`&&dt.frameParsers[`W*`](s),s.owner===`com.apple.streaming.transportStreamTimestamp`){var u=s.data,d=(u[3]&1)<<30|u[4]<<22|u[5]<<14|u[6]<<6|u[7]>>>2;d*=4,d+=u[7]&3,s.timeStamp=d,t.pts===void 0&&t.dts===void 0&&(t.pts=s.timeStamp,t.dts=s.timeStamp),this.trigger(`timestamp`,s)}t.frames.push(s),a+=10,a+=o}while(a<n);this.trigger(`data`,t)}}}};ft.prototype=new lt;var pt=ft,mt=n,ht=qe,gt=Je,_t=tt.TimestampRolloverStream,vt,yt,bt,xt=188,St=71;vt=function(){var e=new Uint8Array(xt),t=0;vt.prototype.init.call(this),this.push=function(n){var r=0,i=xt,a;for(t?(a=new Uint8Array(n.byteLength+t),a.set(e.subarray(0,t)),a.set(n,t),t=0):a=n;i<a.byteLength;)a[r]===St&&a[i]===St?(this.trigger(`data`,a.subarray(r,i)),r+=xt,i+=xt):(r++,i++);r<a.byteLength&&(e.set(a.subarray(r),0),t=a.byteLength-r)},this.flush=function(){t===xt&&e[0]===St&&(this.trigger(`data`,e),t=0),this.trigger(`done`)},this.endTimeline=function(){this.flush(),this.trigger(`endedtimeline`)},this.reset=function(){t=0,this.trigger(`reset`)}},vt.prototype=new mt,yt=function(){var e,t,n,r;yt.prototype.init.call(this),r=this,this.packetsWaitingForPmt=[],this.programMapTable=void 0,e=function(e,r){var i=0;r.payloadUnitStartIndicator&&(i+=e[i]+1),r.type===`pat`?t(e.subarray(i),r):n(e.subarray(i),r)},t=function(e,t){t.section_number=e[7],t.last_section_number=e[8],r.pmtPid=(e[10]&31)<<8|e[11],t.pmtPid=r.pmtPid},n=function(e,t){var n,i,a,o;if(e[5]&1){for(r.programMapTable={video:null,audio:null,"timed-metadata":{}},n=(e[1]&15)<<8|e[2],i=3+n-4,a=(e[10]&15)<<8|e[11],o=12+a;o<i;){var s=e[o],c=(e[o+1]&31)<<8|e[o+2];s===gt.H264_STREAM_TYPE&&r.programMapTable.video===null?r.programMapTable.video=c:s===gt.ADTS_STREAM_TYPE&&r.programMapTable.audio===null?r.programMapTable.audio=c:s===gt.METADATA_STREAM_TYPE&&(r.programMapTable[`timed-metadata`][c]=s),o+=((e[o+3]&15)<<8|e[o+4])+5}t.programMapTable=r.programMapTable}},this.push=function(t){var n={},r=4;if(n.payloadUnitStartIndicator=!!(t[1]&64),n.pid=t[1]&31,n.pid<<=8,n.pid|=t[2],(t[3]&48)>>>4>1&&(r+=t[r]+1),n.pid===0)n.type=`pat`,e(t.subarray(r),n),this.trigger(`data`,n);else if(n.pid===this.pmtPid)for(n.type=`pmt`,e(t.subarray(r),n),this.trigger(`data`,n);this.packetsWaitingForPmt.length;)this.processPes_.apply(this,this.packetsWaitingForPmt.shift());else this.programMapTable===void 0?this.packetsWaitingForPmt.push([t,r,n]):this.processPes_(t,r,n)},this.processPes_=function(e,t,n){n.streamType=n.pid===this.programMapTable.video?gt.H264_STREAM_TYPE:n.pid===this.programMapTable.audio?gt.ADTS_STREAM_TYPE:this.programMapTable[`timed-metadata`][n.pid],n.type=`pes`,n.data=e.subarray(t),this.trigger(`data`,n)}},yt.prototype=new mt,yt.STREAM_TYPES={h264:27,adts:15},bt=function(){var e=this,t=!1,n={data:[],size:0},r={data:[],size:0},i={data:[],size:0},a,o=function(e,t){var n;let r=e[0]<<16|e[1]<<8|e[2];t.data=new Uint8Array,r===1&&(t.packetLength=6+(e[4]<<8|e[5]),t.dataAlignmentIndicator=!!(e[6]&4),n=e[7],n&192&&(t.pts=(e[9]&14)<<27|(e[10]&255)<<20|(e[11]&254)<<12|(e[12]&255)<<5|(e[13]&254)>>>3,t.pts*=4,t.pts+=(e[13]&6)>>>1,t.dts=t.pts,n&64&&(t.dts=(e[14]&14)<<27|(e[15]&255)<<20|(e[16]&254)<<12|(e[17]&255)<<5|(e[18]&254)>>>3,t.dts*=4,t.dts+=(e[18]&6)>>>1)),t.data=e.subarray(9+e[8]))},s=function(t,n,r){var i=new Uint8Array(t.size),a={type:n},s=0,c=0,l=!1,u;if(!(!t.data.length||t.size<9)){for(a.trackId=t.data[0].pid,s=0;s<t.data.length;s++)u=t.data[s],i.set(u.data,c),c+=u.data.byteLength;o(i,a),l=n===`video`||a.packetLength<=t.size,(r||l)&&(t.size=0,t.data.length=0),l&&e.trigger(`data`,a)}};bt.prototype.init.call(this),this.push=function(o){({pat:function(){},pes:function(){var e,t;switch(o.streamType){case gt.H264_STREAM_TYPE:e=n,t=`video`;break;case gt.ADTS_STREAM_TYPE:e=r,t=`audio`;break;case gt.METADATA_STREAM_TYPE:e=i,t=`timed-metadata`;break;default:return}o.payloadUnitStartIndicator&&s(e,t,!0),e.data.push(o),e.size+=o.data.byteLength},pmt:function(){var n={type:`metadata`,tracks:[]};a=o.programMapTable,a.video!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.video,codec:`avc`,type:`video`}),a.audio!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.audio,codec:`adts`,type:`audio`}),t=!0,e.trigger(`data`,n)}})[o.type]()},this.reset=function(){n.size=0,n.data.length=0,r.size=0,r.data.length=0,this.trigger(`reset`)},this.flushStreams_=function(){s(n,`video`),s(r,`audio`),s(i,`timed-metadata`)},this.flush=function(){if(!t&&a){var n={type:`metadata`,tracks:[]};a.video!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.video,codec:`avc`,type:`video`}),a.audio!==null&&n.tracks.push({timelineStartInfo:{baseMediaDecodeTime:0},id:+a.audio,codec:`adts`,type:`audio`}),e.trigger(`data`,n)}t=!1,this.flushStreams_(),this.trigger(`done`)}},bt.prototype=new mt;var Ct={PAT_PID:0,MP2T_PACKET_LENGTH:xt,TransportPacketStream:vt,TransportParseStream:yt,ElementaryStream:bt,TimestampRolloverStream:_t,CaptionStream:ht.CaptionStream,Cea608Stream:ht.Cea608Stream,Cea708Stream:ht.Cea708Stream,MetadataStream:pt};for(var wt in gt)gt.hasOwnProperty(wt)&&(Ct[wt]=gt[wt]);var Tt=Ct,Et=n,Dt=P.ONE_SECOND_IN_TS,Ot,kt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];Ot=function(e){var t,n=0;Ot.prototype.init.call(this),this.skipWarn_=function(e,t){this.trigger(`log`,{level:`warn`,message:`adts skiping bytes ${e} to ${t} in frame ${n} outside syncword`})},this.push=function(r){var i=0,a,o,s,c,l;if(e||(n=0),r.type===`audio`){t&&t.length?(s=t,t=new Uint8Array(s.byteLength+r.data.byteLength),t.set(s),t.set(r.data,s.byteLength)):t=r.data;for(var u;i+7<t.length;)if(t[i]!==255||(t[i+1]&246)!=240)typeof u!=`number`&&(u=i),i++;else{if(typeof u==`number`&&(this.skipWarn_(u,i),u=null),o=(~t[i+1]&1)*2,a=(t[i+3]&3)<<11|t[i+4]<<3|(t[i+5]&224)>>5,c=((t[i+6]&3)+1)*1024,l=c*Dt/kt[(t[i+2]&60)>>>2],t.byteLength-i<a)break;this.trigger(`data`,{pts:r.pts+n*l,dts:r.dts+n*l,sampleCount:c,audioobjecttype:(t[i+2]>>>6&3)+1,channelcount:(t[i+2]&1)<<2|(t[i+3]&192)>>>6,samplerate:kt[(t[i+2]&60)>>>2],samplingfrequencyindex:(t[i+2]&60)>>>2,samplesize:16,data:t.subarray(i+7+o,i+a)}),n++,i+=a}typeof u==`number`&&(this.skipWarn_(u,i),u=null),t=t.subarray(i)}},this.flush=function(){n=0,this.trigger(`done`)},this.reset=function(){t=void 0,this.trigger(`reset`)},this.endTimeline=function(){t=void 0,this.trigger(`endedtimeline`)}},Ot.prototype=new Et;var At=Ot,jt=function(e){var t=e.byteLength,n=0,r=0;this.length=function(){return 8*t},this.bitsAvailable=function(){return 8*t+r},this.loadWord=function(){var i=e.byteLength-t,a=new Uint8Array(4),o=Math.min(4,t);if(o===0)throw Error(`no bytes available`);a.set(e.subarray(i,i+o)),n=new DataView(a.buffer).getUint32(0),r=o*8,t-=o},this.skipBits=function(e){var i;r>e?(n<<=e,r-=e):(e-=r,i=Math.floor(e/8),e-=i*8,t-=i,this.loadWord(),n<<=e,r-=e)},this.readBits=function(e){var i=Math.min(r,e),a=n>>>32-i;return r-=i,r>0?n<<=i:t>0&&this.loadWord(),i=e-i,i>0?a<<i|this.readBits(i):a},this.skipLeadingZeros=function(){for(var e=0;e<r;++e)if(n&2147483648>>>e)return n<<=e,r-=e,e;return this.loadWord(),e+this.skipLeadingZeros()},this.skipUnsignedExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.skipExpGolomb=function(){this.skipBits(1+this.skipLeadingZeros())},this.readUnsignedExpGolomb=function(){var e=this.skipLeadingZeros();return this.readBits(e+1)-1},this.readExpGolomb=function(){var e=this.readUnsignedExpGolomb();return 1&e?1+e>>>1:-1*(e>>>1)},this.readBoolean=function(){return this.readBits(1)===1},this.readUnsignedByte=function(){return this.readBits(8)},this.loadWord()},Mt=n,Nt=jt,Pt,Ft=function(){var e=0,t,n;Ft.prototype.init.call(this),this.push=function(r){var i;n?(i=new Uint8Array(n.byteLength+r.data.byteLength),i.set(n),i.set(r.data,n.byteLength),n=i):n=r.data;for(var a=n.byteLength;e<a-3;e++)if(n[e+2]===1){t=e+5;break}for(;t<a;)switch(n[t]){case 0:if(n[t-1]!==0){t+=2;break}if(n[t-2]!==0){t++;break}e+3!==t-2&&this.trigger(`data`,n.subarray(e+3,t-2));do t++;while(n[t]!==1&&t<a);e=t-2,t+=3;break;case 1:if(n[t-1]!==0||n[t-2]!==0){t+=3;break}this.trigger(`data`,n.subarray(e+3,t-2)),e=t-2,t+=3;break;default:t+=3}n=n.subarray(e),t-=e,e=0},this.reset=function(){n=null,e=0,this.trigger(`reset`)},this.flush=function(){n&&n.byteLength>3&&this.trigger(`data`,n.subarray(e+3)),n=null,e=0,this.trigger(`done`)},this.endTimeline=function(){this.flush(),this.trigger(`endedtimeline`)}},It;Ft.prototype=new Mt,It={100:!0,110:!0,122:!0,244:!0,44:!0,83:!0,86:!0,118:!0,128:!0,138:!0,139:!0,134:!0},Pt=function(){var e=new Ft,t,n,r,i,a,o,s;Pt.prototype.init.call(this),t=this,this.push=function(t){t.type===`video`&&(n=t.trackId,r=t.pts,i=t.dts,e.push(t))},e.on(`data`,function(e){var s={trackId:n,pts:r,dts:i,data:e,nalUnitTypeCode:e[0]&31};switch(s.nalUnitTypeCode){case 5:s.nalUnitType=`slice_layer_without_partitioning_rbsp_idr`;break;case 6:s.nalUnitType=`sei_rbsp`,s.escapedRBSP=a(e.subarray(1));break;case 7:s.nalUnitType=`seq_parameter_set_rbsp`,s.escapedRBSP=a(e.subarray(1)),s.config=o(s.escapedRBSP);break;case 8:s.nalUnitType=`pic_parameter_set_rbsp`;break;case 9:s.nalUnitType=`access_unit_delimiter_rbsp`}t.trigger(`data`,s)}),e.on(`done`,function(){t.trigger(`done`)}),e.on(`partialdone`,function(){t.trigger(`partialdone`)}),e.on(`reset`,function(){t.trigger(`reset`)}),e.on(`endedtimeline`,function(){t.trigger(`endedtimeline`)}),this.flush=function(){e.flush()},this.partialFlush=function(){e.partialFlush()},this.reset=function(){e.reset()},this.endTimeline=function(){e.endTimeline()},s=function(e,t){for(var n=8,r=8,i=0,a;i<e;i++)r!==0&&(a=t.readExpGolomb(),r=(n+a+256)%256),n=r===0?n:r},a=function(e){for(var t=e.byteLength,n=[],r=1,i,a;r<t-2;)e[r]===0&&e[r+1]===0&&e[r+2]===3?(n.push(r+2),r+=2):r++;if(n.length===0)return e;i=t-n.length,a=new Uint8Array(i);var o=0;for(r=0;r<i;o++,r++)o===n[0]&&(o++,n.shift()),a[r]=e[o];return a},o=function(e){var t=0,n=0,r=0,i=0,a,o,c,l,u,d,f,p,m,h,g,_=[1,1],v,y;if(a=new Nt(e),o=a.readUnsignedByte(),l=a.readUnsignedByte(),c=a.readUnsignedByte(),a.skipUnsignedExpGolomb(),It[o]&&(u=a.readUnsignedExpGolomb(),u===3&&a.skipBits(1),a.skipUnsignedExpGolomb(),a.skipUnsignedExpGolomb(),a.skipBits(1),a.readBoolean()))for(g=u===3?12:8,y=0;y<g;y++)a.readBoolean()&&s(y<6?16:64,a);if(a.skipUnsignedExpGolomb(),d=a.readUnsignedExpGolomb(),d===0)a.readUnsignedExpGolomb();else if(d===1)for(a.skipBits(1),a.skipExpGolomb(),a.skipExpGolomb(),f=a.readUnsignedExpGolomb(),y=0;y<f;y++)a.skipExpGolomb();if(a.skipUnsignedExpGolomb(),a.skipBits(1),p=a.readUnsignedExpGolomb(),m=a.readUnsignedExpGolomb(),h=a.readBits(1),h===0&&a.skipBits(1),a.skipBits(1),a.readBoolean()&&(t=a.readUnsignedExpGolomb(),n=a.readUnsignedExpGolomb(),r=a.readUnsignedExpGolomb(),i=a.readUnsignedExpGolomb()),a.readBoolean()&&a.readBoolean()){switch(v=a.readUnsignedByte(),v){case 1:_=[1,1];break;case 2:_=[12,11];break;case 3:_=[10,11];break;case 4:_=[16,11];break;case 5:_=[40,33];break;case 6:_=[24,11];break;case 7:_=[20,11];break;case 8:_=[32,11];break;case 9:_=[80,33];break;case 10:_=[18,11];break;case 11:_=[15,11];break;case 12:_=[64,33];break;case 13:_=[160,99];break;case 14:_=[4,3];break;case 15:_=[3,2];break;case 16:_=[2,1];break;case 255:_=[a.readUnsignedByte()<<8|a.readUnsignedByte(),a.readUnsignedByte()<<8|a.readUnsignedByte()]}_&&_[0]/_[1]}return{profileIdc:o,levelIdc:c,profileCompatibility:l,width:(p+1)*16-t*2-n*2,height:(2-h)*(m+1)*16-r*2-i*2,sarRatio:_}}},Pt.prototype=new Mt;var Lt={H264Stream:Pt},Rt=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],zt=function(e,t){var n=e[t+6]<<21|e[t+7]<<14|e[t+8]<<7|e[t+9],r=(e[t+5]&16)>>4;return n=n>=0?n:0,r?n+20:n+10},z=function(e,t){return e.length-t<10||e[t]!==73||e[t+1]!==68||e[t+2]!==51?t:(t+=zt(e,t),z(e,t))},Bt=function(e){var t=z(e,0);return e.length>=t+2&&(e[t]&255)==255&&(e[t+1]&240)==240&&(e[t+1]&22)==16},Vt=function(e){return e[0]<<21|e[1]<<14|e[2]<<7|e[3]},Ht=function(e,t,n){var r,i=``;for(r=t;r<n;r++)i+=`%`+(`00`+e[r].toString(16)).slice(-2);return i},Ut=function(e,t,n){return unescape(Ht(e,t,n))},Wt={isLikelyAacData:Bt,parseId3TagSize:zt,parseAdtsSize:function(e,t){var n=(e[t+5]&224)>>5,r=e[t+4]<<3;return e[t+3]&6144|r|n},parseType:function(e,t){return e[t]===73&&e[t+1]===68&&e[t+2]===51?`timed-metadata`:e[t]&!0&&(e[t+1]&240)==240?`audio`:null},parseSampleRate:function(e){for(var t=0;t+5<e.length;)if(e[t]!==255||(e[t+1]&246)!=240)t++;else return Rt[(e[t+2]&60)>>>2];return null},parseAacTimestamp:function(e){var t=10,n,r,i;e[5]&64&&(t+=4,t+=Vt(e.subarray(10,14)));do{if(n=Vt(e.subarray(t+4,t+8)),n<1)return null;if(i=String.fromCharCode(e[t],e[t+1],e[t+2],e[t+3]),i===`PRIV`){r=e.subarray(t+10,t+n+10);for(var a=0;a<r.byteLength;a++)if(r[a]===0){if(Ut(r,0,a)===`com.apple.streaming.transportStreamTimestamp`){var o=r.subarray(a+1),s=(o[3]&1)<<30|o[4]<<22|o[5]<<14|o[6]<<6|o[7]>>>2;return s*=4,s+=o[7]&3,s}break}}t+=10,t+=n}while(t<e.byteLength);return null}},Gt=n,B=Wt,Kt=function(){var e=new Uint8Array,t=0;Kt.prototype.init.call(this),this.setTimestamp=function(e){t=e},this.push=function(n){var r=0,i=0,a,o,s,c;for(e.length?(c=e.length,e=new Uint8Array(n.byteLength+c),e.set(e.subarray(0,c)),e.set(n,c)):e=n;e.length-i>=3;)if(e[i]===73&&e[i+1]===68&&e[i+2]===51){if(e.length-i<10||(r=B.parseId3TagSize(e,i),i+r>e.length))break;o={type:`timed-metadata`,data:e.subarray(i,i+r)},this.trigger(`data`,o),i+=r}else if((e[i]&255)==255&&(e[i+1]&240)==240){if(e.length-i<7||(r=B.parseAdtsSize(e,i),i+r>e.length))break;s={type:`audio`,data:e.subarray(i,i+r),pts:t,dts:t},this.trigger(`data`,s),i+=r}else i++;a=e.length-i,e=a>0?e.subarray(i):new Uint8Array},this.reset=function(){e=new Uint8Array,this.trigger(`reset`)},this.endTimeline=function(){e=new Uint8Array,this.trigger(`endedtimeline`)}};Kt.prototype=new Gt;var qt=Kt,Jt=[`audioobjecttype`,`channelcount`,`samplerate`,`samplingfrequencyindex`,`samplesize`],Yt=[`width`,`height`,`profileIdc`,`levelIdc`,`profileCompatibility`,`sarRatio`],Xt=n,Zt=M,Qt=he,$t=Oe,en=Ae,tn=Tt,nn=P,rn=At,an=Lt.H264Stream,on=qt,sn=Wt.isLikelyAacData,cn=P.ONE_SECOND_IN_TS,ln=Jt,un=Yt,dn,fn,pn,mn,hn=function(e,t){t.stream=e,this.trigger(`log`,t)},gn=function(e,t){for(var n=Object.keys(t),r=0;r<n.length;r++){var i=n[r];i!==`headOfPipeline`&&t[i].on&&t[i].on(`log`,hn.bind(e,i))}},_n=function(e,t){var n;if(e.length!==t.length)return!1;for(n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0},vn=function(e,t,n,r,i,a){var o=n-t,s=r-t,c=i-n;return{start:{dts:e,pts:e+o},end:{dts:e+s,pts:e+c},prependedContentDuration:a,baseMediaDecodeTime:e}};fn=function(e,t){var n=[],r,i=0,a=0,o=1/0;t||={},r=t.firstSequenceNumber||0,fn.prototype.init.call(this),this.push=function(t){en.collectDtsInfo(e,t),e&&ln.forEach(function(n){e[n]=t[n]}),n.push(t)},this.setEarliestDts=function(e){i=e},this.setVideoBaseMediaDecodeTime=function(e){o=e},this.setAudioAppendStart=function(e){a=e},this.flush=function(){var s,c,l,u,d,f,p;n.length===0||(s=$t.trimAdtsFramesByEarliestDts(n,e,i),e.baseMediaDecodeTime=en.calculateTrackBaseMediaDecodeTime(e,t.keepOriginalTimestamps),p=$t.prefixWithSilence(e,s,a,o),e.samples=$t.generateSampleTable(s),l=Zt.mdat($t.concatenateFrameData(s)),n=[],c=Zt.moof(r,[e]),u=new Uint8Array(c.byteLength+l.byteLength),r++,u.set(c),u.set(l,c.byteLength),en.clearDtsInfo(e),d=Math.ceil(cn*1024/e.samplerate),s.length&&(f=s.length*d,this.trigger(`segmentTimingInfo`,vn(nn.audioTsToVideoTs(e.baseMediaDecodeTime,e.samplerate),s[0].dts,s[0].pts,s[0].dts+f,s[0].pts+f,p||0)),this.trigger(`timingInfo`,{start:s[0].pts,end:s[0].pts+f})),this.trigger(`data`,{track:e,boxes:u})),this.trigger(`done`,`AudioSegmentStream`)},this.reset=function(){en.clearDtsInfo(e),n=[],this.trigger(`reset`)}},fn.prototype=new Xt,dn=function(e,t){var n,r=[],i=[],a,o;t||={},n=t.firstSequenceNumber||0,dn.prototype.init.call(this),delete e.minPTS,this.gopCache_=[],this.push=function(t){en.collectDtsInfo(e,t),t.nalUnitType===`seq_parameter_set_rbsp`&&!a&&(a=t.config,e.sps=[t.data],un.forEach(function(t){e[t]=a[t]},this)),t.nalUnitType===`pic_parameter_set_rbsp`&&!o&&(o=t.data,e.pps=[t.data]),r.push(t)},this.flush=function(){for(var a,o,s,c,l,u,d=0,f,p;r.length&&r[0].nalUnitType!==`access_unit_delimiter_rbsp`;)r.shift();if(r.length===0)this.resetStream_(),this.trigger(`done`,`VideoSegmentStream`);else{if(a=Qt.groupNalsIntoFrames(r),s=Qt.groupFramesIntoGops(a),s[0][0].keyFrame||(o=this.getGopForFusion_(r[0],e),o?(d=o.duration,s.unshift(o),s.byteLength+=o.byteLength,s.nalCount+=o.nalCount,s.pts=o.pts,s.dts=o.dts,s.duration+=o.duration):s=Qt.extendFirstKeyFrame(s)),i.length){var m=t.alignGopsAtEnd?this.alignGopsAtEnd_(s):this.alignGopsAtStart_(s);if(!m){this.gopCache_.unshift({gop:s.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),r=[],this.resetStream_(),this.trigger(`done`,`VideoSegmentStream`);return}en.clearDtsInfo(e),s=m}en.collectDtsInfo(e,s),e.samples=Qt.generateSampleTable(s),l=Zt.mdat(Qt.concatenateNalData(s)),e.baseMediaDecodeTime=en.calculateTrackBaseMediaDecodeTime(e,t.keepOriginalTimestamps),this.trigger(`processedGopsInfo`,s.map(function(e){return{pts:e.pts,dts:e.dts,byteLength:e.byteLength}})),f=s[0],p=s[s.length-1],this.trigger(`segmentTimingInfo`,vn(e.baseMediaDecodeTime,f.dts,f.pts,p.dts+p.duration,p.pts+p.duration,d)),this.trigger(`timingInfo`,{start:s[0].pts,end:s[s.length-1].pts+s[s.length-1].duration}),this.gopCache_.unshift({gop:s.pop(),pps:e.pps,sps:e.sps}),this.gopCache_.length=Math.min(6,this.gopCache_.length),r=[],this.trigger(`baseMediaDecodeTime`,e.baseMediaDecodeTime),this.trigger(`timelineStartInfo`,e.timelineStartInfo),c=Zt.moof(n,[e]),u=new Uint8Array(c.byteLength+l.byteLength),n++,u.set(c),u.set(l,c.byteLength),this.trigger(`data`,{track:e,boxes:u}),this.resetStream_(),this.trigger(`done`,`VideoSegmentStream`)}},this.reset=function(){this.resetStream_(),r=[],this.gopCache_.length=0,i.length=0,this.trigger(`reset`)},this.resetStream_=function(){en.clearDtsInfo(e),a=void 0,o=void 0},this.getGopForFusion_=function(t){for(var n=45e3,r=1/0,i,a,o,s,c=0;c<this.gopCache_.length;c++)s=this.gopCache_[c],o=s.gop,e.pps&&_n(e.pps[0],s.pps[0])&&e.sps&&_n(e.sps[0],s.sps[0])&&(o.dts<e.timelineStartInfo.dts||(i=t.dts-o.dts-o.duration,i>=-1e4&&i<=n&&(!a||r>i)&&(a=s,r=i)));return a?a.gop:null},this.alignGopsAtStart_=function(e){var t,n,r,a,o=e.byteLength,s=e.nalCount,c=e.duration,l;for(t=n=0;t<i.length&&n<e.length&&(r=i[t],a=e[n],r.pts!==a.pts);)a.pts>r.pts?t++:(n++,o-=a.byteLength,s-=a.nalCount,c-=a.duration);return n===0?e:n===e.length?null:(l=e.slice(n),l.byteLength=o,l.duration=c,l.nalCount=s,l.pts=l[0].pts,l.dts=l[0].dts,l)},this.alignGopsAtEnd_=function(e){for(var t=i.length-1,n=e.length-1,r,a,o=null,s=!1;t>=0&&n>=0;){if(r=i[t],a=e[n],r.pts===a.pts){s=!0;break}r.pts>a.pts?t--:(t===i.length-1&&(o=n),n--)}if(!s&&o===null)return null;var c=s?n:o;if(c===0)return e;var l=e.slice(c),u=l.reduce(function(e,t){return e.byteLength+=t.byteLength,e.duration+=t.duration,e.nalCount+=t.nalCount,e},{byteLength:0,duration:0,nalCount:0});return l.byteLength=u.byteLength,l.duration=u.duration,l.nalCount=u.nalCount,l.pts=l[0].pts,l.dts=l[0].dts,l},this.alignGopsWith=function(e){i=e}},dn.prototype=new Xt,mn=function(e,t){this.numberOfTracks=0,this.metadataStream=t,e||={},this.remuxTracks=e.remux===void 0||!!e.remux,this.keepOriginalTimestamps=typeof e.keepOriginalTimestamps==`boolean`&&e.keepOriginalTimestamps,this.pendingTracks=[],this.videoTrack=null,this.pendingBoxes=[],this.pendingCaptions=[],this.pendingMetadata=[],this.pendingBytes=0,this.emittedTracks=0,mn.prototype.init.call(this),this.push=function(e){if(e.content||e.text)return this.pendingCaptions.push(e);if(e.frames)return this.pendingMetadata.push(e);this.pendingTracks.push(e.track),this.pendingBytes+=e.boxes.byteLength,e.track.type===`video`&&(this.videoTrack=e.track,this.pendingBoxes.push(e.boxes)),e.track.type===`audio`&&(this.audioTrack=e.track,this.pendingBoxes.unshift(e.boxes))}},mn.prototype=new Xt,mn.prototype.flush=function(e){var t=0,n={captions:[],captionStreams:{},metadata:[],info:{}},r,i,a,o=0,s;if(this.pendingTracks.length<this.numberOfTracks){if(e!==`VideoSegmentStream`&&e!==`AudioSegmentStream`||this.remuxTracks)return;if(this.pendingTracks.length===0){this.emittedTracks++,this.emittedTracks>=this.numberOfTracks&&(this.trigger(`done`),this.emittedTracks=0);return}}if(this.videoTrack?(o=this.videoTrack.timelineStartInfo.pts,un.forEach(function(e){n.info[e]=this.videoTrack[e]},this)):this.audioTrack&&(o=this.audioTrack.timelineStartInfo.pts,ln.forEach(function(e){n.info[e]=this.audioTrack[e]},this)),this.videoTrack||this.audioTrack){for(n.type=this.pendingTracks.length===1?this.pendingTracks[0].type:`combined`,this.emittedTracks+=this.pendingTracks.length,a=Zt.initSegment(this.pendingTracks),n.initSegment=new Uint8Array(a.byteLength),n.initSegment.set(a),n.data=new Uint8Array(this.pendingBytes),s=0;s<this.pendingBoxes.length;s++)n.data.set(this.pendingBoxes[s],t),t+=this.pendingBoxes[s].byteLength;for(s=0;s<this.pendingCaptions.length;s++)r=this.pendingCaptions[s],r.startTime=nn.metadataTsToSeconds(r.startPts,o,this.keepOriginalTimestamps),r.endTime=nn.metadataTsToSeconds(r.endPts,o,this.keepOriginalTimestamps),n.captionStreams[r.stream]=!0,n.captions.push(r);for(s=0;s<this.pendingMetadata.length;s++)i=this.pendingMetadata[s],i.cueTime=nn.metadataTsToSeconds(i.pts,o,this.keepOriginalTimestamps),n.metadata.push(i);for(n.metadata.dispatchType=this.metadataStream.dispatchType,this.pendingTracks.length=0,this.videoTrack=null,this.pendingBoxes.length=0,this.pendingCaptions.length=0,this.pendingBytes=0,this.pendingMetadata.length=0,this.trigger(`data`,n),s=0;s<n.captions.length;s++)r=n.captions[s],this.trigger(`caption`,r);for(s=0;s<n.metadata.length;s++)i=n.metadata[s],this.trigger(`id3Frame`,i)}this.emittedTracks>=this.numberOfTracks&&(this.trigger(`done`),this.emittedTracks=0)},mn.prototype.setRemux=function(e){this.remuxTracks=e},pn=function(e){var t=this,n=!0,r,i;pn.prototype.init.call(this),e||={},this.baseMediaDecodeTime=e.baseMediaDecodeTime||0,this.transmuxPipeline_={},this.setupAacPipeline=function(){var n={};this.transmuxPipeline_=n,n.type=`aac`,n.metadataStream=new tn.MetadataStream,n.aacStream=new on,n.audioTimestampRolloverStream=new tn.TimestampRolloverStream(`audio`),n.timedMetadataTimestampRolloverStream=new tn.TimestampRolloverStream(`timed-metadata`),n.adtsStream=new rn,n.coalesceStream=new mn(e,n.metadataStream),n.headOfPipeline=n.aacStream,n.aacStream.pipe(n.audioTimestampRolloverStream).pipe(n.adtsStream),n.aacStream.pipe(n.timedMetadataTimestampRolloverStream).pipe(n.metadataStream).pipe(n.coalesceStream),n.metadataStream.on(`timestamp`,function(e){n.aacStream.setTimestamp(e.timeStamp)}),n.aacStream.on(`data`,function(a){a.type!==`timed-metadata`&&a.type!==`audio`||n.audioSegmentStream||(i||={timelineStartInfo:{baseMediaDecodeTime:t.baseMediaDecodeTime},codec:`adts`,type:`audio`},n.coalesceStream.numberOfTracks++,n.audioSegmentStream=new fn(i,e),n.audioSegmentStream.on(`log`,t.getLogTrigger_(`audioSegmentStream`)),n.audioSegmentStream.on(`timingInfo`,t.trigger.bind(t,`audioTimingInfo`)),n.adtsStream.pipe(n.audioSegmentStream).pipe(n.coalesceStream),t.trigger(`trackinfo`,{hasAudio:!!i,hasVideo:!!r}))}),n.coalesceStream.on(`data`,this.trigger.bind(this,`data`)),n.coalesceStream.on(`done`,this.trigger.bind(this,`done`)),gn(this,n)},this.setupTsPipeline=function(){var n={};this.transmuxPipeline_=n,n.type=`ts`,n.metadataStream=new tn.MetadataStream,n.packetStream=new tn.TransportPacketStream,n.parseStream=new tn.TransportParseStream,n.elementaryStream=new tn.ElementaryStream,n.timestampRolloverStream=new tn.TimestampRolloverStream,n.adtsStream=new rn,n.h264Stream=new an,n.captionStream=new tn.CaptionStream(e),n.coalesceStream=new mn(e,n.metadataStream),n.headOfPipeline=n.packetStream,n.packetStream.pipe(n.parseStream).pipe(n.elementaryStream).pipe(n.timestampRolloverStream),n.timestampRolloverStream.pipe(n.h264Stream),n.timestampRolloverStream.pipe(n.adtsStream),n.timestampRolloverStream.pipe(n.metadataStream).pipe(n.coalesceStream),n.h264Stream.pipe(n.captionStream).pipe(n.coalesceStream),n.elementaryStream.on(`data`,function(a){var o;if(a.type===`metadata`){for(o=a.tracks.length;o--;)!r&&a.tracks[o].type===`video`?(r=a.tracks[o],r.timelineStartInfo.baseMediaDecodeTime=t.baseMediaDecodeTime):!i&&a.tracks[o].type===`audio`&&(i=a.tracks[o],i.timelineStartInfo.baseMediaDecodeTime=t.baseMediaDecodeTime);r&&!n.videoSegmentStream&&(n.coalesceStream.numberOfTracks++,n.videoSegmentStream=new dn(r,e),n.videoSegmentStream.on(`log`,t.getLogTrigger_(`videoSegmentStream`)),n.videoSegmentStream.on(`timelineStartInfo`,function(r){i&&!e.keepOriginalTimestamps&&(i.timelineStartInfo=r,n.audioSegmentStream.setEarliestDts(r.dts-t.baseMediaDecodeTime))}),n.videoSegmentStream.on(`processedGopsInfo`,t.trigger.bind(t,`gopInfo`)),n.videoSegmentStream.on(`segmentTimingInfo`,t.trigger.bind(t,`videoSegmentTimingInfo`)),n.videoSegmentStream.on(`baseMediaDecodeTime`,function(e){i&&n.audioSegmentStream.setVideoBaseMediaDecodeTime(e)}),n.videoSegmentStream.on(`timingInfo`,t.trigger.bind(t,`videoTimingInfo`)),n.h264Stream.pipe(n.videoSegmentStream).pipe(n.coalesceStream)),i&&!n.audioSegmentStream&&(n.coalesceStream.numberOfTracks++,n.audioSegmentStream=new fn(i,e),n.audioSegmentStream.on(`log`,t.getLogTrigger_(`audioSegmentStream`)),n.audioSegmentStream.on(`timingInfo`,t.trigger.bind(t,`audioTimingInfo`)),n.audioSegmentStream.on(`segmentTimingInfo`,t.trigger.bind(t,`audioSegmentTimingInfo`)),n.adtsStream.pipe(n.audioSegmentStream).pipe(n.coalesceStream)),t.trigger(`trackinfo`,{hasAudio:!!i,hasVideo:!!r})}}),n.coalesceStream.on(`data`,this.trigger.bind(this,`data`)),n.coalesceStream.on(`id3Frame`,function(e){e.dispatchType=n.metadataStream.dispatchType,t.trigger(`id3Frame`,e)}),n.coalesceStream.on(`caption`,this.trigger.bind(this,`caption`)),n.coalesceStream.on(`done`,this.trigger.bind(this,`done`)),gn(this,n)},this.setBaseMediaDecodeTime=function(t){var n=this.transmuxPipeline_;e.keepOriginalTimestamps||(this.baseMediaDecodeTime=t),i&&(i.timelineStartInfo.dts=void 0,i.timelineStartInfo.pts=void 0,en.clearDtsInfo(i),n.audioTimestampRolloverStream&&n.audioTimestampRolloverStream.discontinuity()),r&&(n.videoSegmentStream&&(n.videoSegmentStream.gopCache_=[]),r.timelineStartInfo.dts=void 0,r.timelineStartInfo.pts=void 0,en.clearDtsInfo(r),n.captionStream.reset()),n.timestampRolloverStream&&n.timestampRolloverStream.discontinuity()},this.setAudioAppendStart=function(e){i&&this.transmuxPipeline_.audioSegmentStream.setAudioAppendStart(e)},this.setRemux=function(t){var n=this.transmuxPipeline_;e.remux=t,n&&n.coalesceStream&&n.coalesceStream.setRemux(t)},this.alignGopsWith=function(e){r&&this.transmuxPipeline_.videoSegmentStream&&this.transmuxPipeline_.videoSegmentStream.alignGopsWith(e)},this.getLogTrigger_=function(e){var t=this;return function(n){n.stream=e,t.trigger(`log`,n)}},this.push=function(e){if(n){var t=sn(e);t&&this.transmuxPipeline_.type!==`aac`?this.setupAacPipeline():!t&&this.transmuxPipeline_.type!==`ts`&&this.setupTsPipeline(),n=!1}this.transmuxPipeline_.headOfPipeline.push(e)},this.flush=function(){n=!0,this.transmuxPipeline_.headOfPipeline.flush()},this.endTimeline=function(){this.transmuxPipeline_.headOfPipeline.endTimeline()},this.reset=function(){this.transmuxPipeline_.headOfPipeline&&this.transmuxPipeline_.headOfPipeline.reset()},this.resetCaptions=function(){this.transmuxPipeline_.captionStream&&this.transmuxPipeline_.captionStream.reset()}},pn.prototype=new Xt;var yn={Transmuxer:pn},bn={toUnsigned:function(e){return e>>>0},toHexString:function(e){return(`00`+e.toString(16)).slice(-2)}},xn=function(e){var t=``;return t+=String.fromCharCode(e[0]),t+=String.fromCharCode(e[1]),t+=String.fromCharCode(e[2]),t+=String.fromCharCode(e[3]),t},Sn=bn.toUnsigned,Cn=xn,wn=function(e,t){var n=[],r,i,a,o,s;if(!t.length)return null;for(r=0;r<e.byteLength;)i=Sn(e[r]<<24|e[r+1]<<16|e[r+2]<<8|e[r+3]),a=Cn(e.subarray(r+4,r+8)),o=i>1?r+i:e.byteLength,a===t[0]&&(t.length===1?n.push(e.subarray(r+8,o)):(s=wn(e.subarray(r+8,o),t.slice(1)),s.length&&(n=n.concat(s)))),r=o;return n},Tn=wn,En=bn.toUnsigned,Dn=i.getUint64,On=function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4))};return t.baseMediaDecodeTime=t.version===1?Dn(e.subarray(4)):En(e[4]<<24|e[5]<<16|e[6]<<8|e[7]),t},kn=function(e){var t=new DataView(e.buffer,e.byteOffset,e.byteLength),n={version:e[0],flags:new Uint8Array(e.subarray(1,4)),trackId:t.getUint32(4)},r=n.flags[2]&1,i=n.flags[2]&2,a=n.flags[2]&8,o=n.flags[2]&16,s=n.flags[2]&32,c=n.flags[0]&65536,l=n.flags[0]&131072,u=8;return r&&(u+=4,n.baseDataOffset=t.getUint32(12),u+=4),i&&(n.sampleDescriptionIndex=t.getUint32(u),u+=4),a&&(n.defaultSampleDuration=t.getUint32(u),u+=4),o&&(n.defaultSampleSize=t.getUint32(u),u+=4),s&&(n.defaultSampleFlags=t.getUint32(u)),c&&(n.durationIsEmpty=!0),!r&&l&&(n.baseDataOffsetIsMoof=!0),n},An=function(e){return{isLeading:(e[0]&12)>>>2,dependsOn:e[0]&3,isDependedOn:(e[1]&192)>>>6,hasRedundancy:(e[1]&48)>>>4,paddingValue:(e[1]&14)>>>1,isNonSyncSample:e[1]&1,degradationPriority:e[2]<<8|e[3]}},jn=function(e){var t={version:e[0],flags:new Uint8Array(e.subarray(1,4)),samples:[]},n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=t.flags[2]&1,i=t.flags[2]&4,a=t.flags[1]&1,o=t.flags[1]&2,s=t.flags[1]&4,c=t.flags[1]&8,l=n.getUint32(4),u=8,d;for(r&&(t.dataOffset=n.getInt32(u),u+=4),i&&l&&(d={flags:An(e.subarray(u,u+4))},u+=4,a&&(d.duration=n.getUint32(u),u+=4),o&&(d.size=n.getUint32(u),u+=4),c&&(t.version===1?d.compositionTimeOffset=n.getInt32(u):d.compositionTimeOffset=n.getUint32(u),u+=4),t.samples.push(d),l--);l--;)d={},a&&(d.duration=n.getUint32(u),u+=4),o&&(d.size=n.getUint32(u),u+=4),s&&(d.flags=An(e.subarray(u,u+4)),u+=4),c&&(t.version===1?d.compositionTimeOffset=n.getInt32(u):d.compositionTimeOffset=n.getUint32(u),u+=4),t.samples.push(d);return t},Mn={tfdt:On,trun:jn},Nn={parseTfdt:Mn.tfdt,parseTrun:Mn.trun},Pn={uint8ToCString:function(e){for(var t=0,n=String.fromCharCode(e[t]),r=``;n!==`\0`;)r+=n,t++,n=String.fromCharCode(e[t]);return r+=n,r}}.uint8ToCString,Fn=i.getUint64,In=function(e){var t=4,n=e[0],r,i,a,o,s,c,l,u;if(n===0){r=Pn(e.subarray(t)),t+=r.length,i=Pn(e.subarray(t)),t+=i.length;var d=new DataView(e.buffer);a=d.getUint32(t),t+=4,s=d.getUint32(t),t+=4,c=d.getUint32(t),t+=4,l=d.getUint32(t),t+=4}else if(n===1){var d=new DataView(e.buffer);a=d.getUint32(t),t+=4,o=Fn(e.subarray(t)),t+=8,c=d.getUint32(t),t+=4,l=d.getUint32(t),t+=4,r=Pn(e.subarray(t)),t+=r.length,i=Pn(e.subarray(t)),t+=i.length}u=new Uint8Array(e.subarray(t,e.byteLength));var f={scheme_id_uri:r,value:i,timescale:a||1,presentation_time:o,presentation_time_delta:s,event_duration:c,id:l,message_data:u};return Rn(n,f)?f:void 0},Ln=function(e,t,n,r){return e||e===0?e/t:r+n/t},Rn=function(e,t){var n=t.scheme_id_uri!==`\0`,r=e===0&&zn(t.presentation_time_delta)&&n,i=e===1&&zn(t.presentation_time)&&n;return!(e>1)&&r||i},zn=function(e){return e!==void 0||e!==null},Bn={parseEmsgBox:In,scaleTime:Ln},Vn=typeof window<`u`?window:e===void 0?typeof self<`u`?self:{}:e,Hn=bn.toUnsigned,Un=bn.toHexString,Wn=Tn,Gn=xn,Kn=Bn,qn=kn,Jn=jn,Yn=On,Xn=i.getUint64,Zn,Qn,$n,er,tr,nr,rr,ir=Vn,ar=ct.parseId3Frames;Zn=function(e){return Wn(e,[`moov`,`trak`]).reduce(function(e,t){var n=Wn(t,[`tkhd`])[0],r,i,a,o;return!n||(r=n[0],i=r===0?12:20,a=Hn(n[i]<<24|n[i+1]<<16|n[i+2]<<8|n[i+3]),o=Wn(t,[`mdia`,`mdhd`])[0],!o)?null:(r=o[0],i=r===0?12:20,e[a]=Hn(o[i]<<24|o[i+1]<<16|o[i+2]<<8|o[i+3]),e)},{})},Qn=function(e,t){var n=Wn(t,[`moof`,`traf`]).reduce(function(t,n){var r=Wn(n,[`tfhd`])[0],i=e[Hn(r[4]<<24|r[5]<<16|r[6]<<8|r[7])]||9e4,a=Wn(n,[`tfdt`])[0],o=new DataView(a.buffer,a.byteOffset,a.byteLength),s=a[0]===1?Xn(a.subarray(4,12)):o.getUint32(4);let c;return typeof s==`bigint`?c=s/ir.BigInt(i):typeof s==`number`&&!isNaN(s)&&(c=s/i),c<2**53-1&&(c=Number(c)),c<t&&(t=c),t},1/0);return typeof n==`bigint`||isFinite(n)?n:0},$n=function(e,t){var n=Wn(t,[`moof`,`traf`]),r=0,i=0,a;if(n&&n.length){var o=Wn(n[0],[`tfhd`])[0],s=Wn(n[0],[`trun`])[0],c=Wn(n[0],[`tfdt`])[0];if(o&&(a=qn(o).trackId),c&&(r=Yn(c).baseMediaDecodeTime),s){var l=Jn(s);l.samples&&l.samples.length&&(i=l.samples[0].compositionTimeOffset||0)}}var u=e[a]||9e4;typeof r==`bigint`&&(i=ir.BigInt(i),u=ir.BigInt(u));var d=(r+i)/u;return typeof d==`bigint`&&d<2**53-1&&(d=Number(d)),d},er=function(e){var t=Wn(e,[`moov`,`trak`]),n=[];return t.forEach(function(e){var t=Wn(e,[`mdia`,`hdlr`]),r=Wn(e,[`tkhd`]);t.forEach(function(e,t){var i=Gn(e.subarray(8,12)),a=r[t],o,s,c;i===`vide`&&(o=new DataView(a.buffer,a.byteOffset,a.byteLength),s=o.getUint8(0),c=s===0?o.getUint32(12):o.getUint32(20),n.push(c))})}),n},nr=function(e){var t=e[0]===0?12:20;return Hn(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])},tr=function(e){var t=Wn(e,[`moov`,`trak`]),n=[];return t.forEach(function(e){var t={},r=Wn(e,[`tkhd`])[0],i,a;r&&(i=new DataView(r.buffer,r.byteOffset,r.byteLength),a=i.getUint8(0),t.id=a===0?i.getUint32(12):i.getUint32(20));var o=Wn(e,[`mdia`,`hdlr`])[0];if(o){var s=Gn(o.subarray(8,12));t.type=s===`vide`?`video`:s===`soun`?`audio`:s}var c=Wn(e,[`mdia`,`minf`,`stbl`,`stsd`])[0];if(c){var l=c.subarray(8);t.codec=Gn(l.subarray(4,8));var u=Wn(l,[t.codec])[0],d,f;u&&(/^[asm]vc[1-9]$/i.test(t.codec)?(d=u.subarray(78),f=Gn(d.subarray(4,8)),f===`avcC`&&d.length>11?(t.codec+=`.`,t.codec+=Un(d[9]),t.codec+=Un(d[10]),t.codec+=Un(d[11])):t.codec=`avc1.4d400d`):/^mp4[a,v]$/i.test(t.codec)?(d=u.subarray(28),f=Gn(d.subarray(4,8)),f===`esds`&&d.length>20&&d[19]!==0?(t.codec+=`.`+Un(d[19]),t.codec+=`.`+Un(d[20]>>>2&63).replace(/^0/,``)):t.codec=`mp4a.40.2`):t.codec=t.codec.toLowerCase())}var p=Wn(e,[`mdia`,`mdhd`])[0];p&&(t.timescale=nr(p)),n.push(t)}),n},rr=function(e,t=0){return Wn(e,[`emsg`]).map(e=>{var n=Kn.parseEmsgBox(new Uint8Array(e)),r=ar(n.message_data);return{cueTime:Kn.scaleTime(n.presentation_time,n.timescale,n.presentation_time_delta,t),duration:Kn.scaleTime(n.event_duration,n.timescale),frames:r}})};var or={findBox:Wn,parseType:Gn,timescale:Zn,startTime:Qn,compositionStartTime:$n,videoTrackIds:er,tracks:tr,getTimescaleFromMediaHeader:nr,getEmsgID3:rr};let{parseTrun:sr}=Nn,{findBox:cr}=or;var lr=Vn,V={getMdatTrafPairs:function(e){var t=cr(e,[`moof`,`traf`]),n=cr(e,[`mdat`]),r=[];return n.forEach(function(e,n){var i=t[n];r.push({mdat:e,traf:i})}),r},parseSamples:function(e,t,n){var r=t,i=n.defaultSampleDuration||0,a=n.defaultSampleSize||0,o=n.trackId,s=[];return e.forEach(function(e){var t=sr(e).samples;t.forEach(function(e){e.duration===void 0&&(e.duration=i),e.size===void 0&&(e.size=a),e.trackId=o,e.dts=r,e.compositionTimeOffset===void 0&&(e.compositionTimeOffset=0),typeof r==`bigint`?(e.pts=r+lr.BigInt(e.compositionTimeOffset),r+=lr.BigInt(e.duration)):(e.pts=r+e.compositionTimeOffset,r+=e.duration)}),s=s.concat(t)}),s}},ur=Ne.discardEmulationPreventionBytes,dr=qe.CaptionStream,fr=Tn,pr=On,mr=kn,{getMdatTrafPairs:hr,parseSamples:gr}=V,_r=function(e,t){for(var n=e,r=0;r<t.length;r++){var i=t[r];if(n<i.size)return i;n-=i.size}return null},vr=function(e,t,n){for(var r=new DataView(e.buffer,e.byteOffset,e.byteLength),i={logs:[],seiNals:[]},a,o=0,s,c;o+4<e.length;o+=s)if(s=r.getUint32(o),o+=4,!(s<=0))switch(e[o]&31){case 6:var l=e.subarray(o+1,o+1+s),u=_r(o,t);if(a={nalUnitType:`sei_rbsp`,size:s,data:l,escapedRBSP:ur(l),trackId:n},u)a.pts=u.pts,a.dts=u.dts,c=u;else if(c)a.pts=c.pts,a.dts=c.dts;else{i.logs.push({level:`warn`,message:`We've encountered a nal unit without data at `+o+` for trackId `+n+`. See mux.js#223.`});break}i.seiNals.push(a)}return i},yr=function(e,t){var n={};return hr(e).forEach(function(e){var r=e.mdat,i=e.traf,a=mr(fr(i,[`tfhd`])[0]),o=a.trackId,s=fr(i,[`tfdt`]),c=s.length>0?pr(s[0]).baseMediaDecodeTime:0,l=fr(i,[`trun`]),u,d;t===o&&l.length>0&&(u=gr(l,c,a),d=vr(r,u,o),n[o]||(n[o]={seiNals:[],logs:[]}),n[o].seiNals=n[o].seiNals.concat(d.seiNals),n[o].logs=n[o].logs.concat(d.logs))}),n},br=function(e,t,n){var r;if(t===null)return null;r=yr(e,t);var i=r[t]||{};return{seiNals:i.seiNals,logs:i.logs,timescale:n}},xr=function(){var e=!1,t,n,r,i,a,o;this.isInitialized=function(){return e},this.init=function(n){t=new dr,e=!0,o=n?n.isPartial:!1,t.on(`data`,function(e){e.startTime=e.startPts/i,e.endTime=e.endPts/i,a.captions.push(e),a.captionStreams[e.stream]=!0}),t.on(`log`,function(e){a.logs.push(e)})},this.isNewInit=function(e,t){return e&&e.length===0||t&&typeof t==`object`&&Object.keys(t).length===0?!1:r!==e[0]||i!==t[r]},this.parse=function(e,t,o){var s;if(!this.isInitialized()||!t||!o)return null;if(this.isNewInit(t,o))r=t[0],i=o[r];else if(r===null||!i)return n.push(e),null;for(;n.length>0;){var c=n.shift();this.parse(c,t,o)}return s=br(e,r,i),s&&s.logs&&(a.logs=a.logs.concat(s.logs)),s===null||!s.seiNals?a.logs.length?{logs:a.logs,captions:[],captionStreams:[]}:null:(this.pushNals(s.seiNals),this.flushStream(),a)},this.pushNals=function(e){if(!this.isInitialized()||!e||e.length===0)return null;e.forEach(function(e){t.push(e)})},this.flushStream=function(){if(!this.isInitialized())return null;o?t.partialFlush():t.flush()},this.clearParsedCaptions=function(){a.captions=[],a.captionStreams={},a.logs=[]},this.resetCaptionStream=function(){if(!this.isInitialized())return null;t.reset()},this.clearAllCaptions=function(){this.clearParsedCaptions(),this.resetCaptionStream()},this.reset=function(){n=[],r=null,i=null,a?this.clearParsedCaptions():a={captions:[],captionStreams:{},logs:[]},this.resetCaptionStream()},this.reset()};let{parseTfdt:Sr}=Nn,Cr=Tn,{getTimescaleFromMediaHeader:wr}=or,{parseSamples:Tr,getMdatTrafPairs:Er}=V;var Dr=function(){let e=9e4;this.init=function(t){let n=Cr(t,[`moov`,`trak`,`mdia`,`mdhd`])[0];n&&(e=wr(n))},this.parseSegment=function(t){let n=[],r=Er(t),i=0;return r.forEach(function(t){let r=t.mdat,a=t.traf,o=Cr(a,[`tfdt`])[0],s=Cr(a,[`tfhd`])[0],c=Cr(a,[`trun`]);if(o&&(i=Sr(o).baseMediaDecodeTime),c.length&&s){let t=Tr(c,i,s),a=0;t.forEach(function(t){let i=new TextDecoder(`utf-8`),o=r.slice(a,a+t.size);Cr(o,[`vtte`])[0]||Cr(o,[`vttc`]).forEach(function(r){let a=Cr(r,[`payl`])[0],o=Cr(r,[`sttg`])[0],s=t.pts/e,c=(t.pts+t.duration)/e,l,u;if(a)try{l=i.decode(a)}catch(e){console.error(e)}if(o)try{u=i.decode(o)}catch(e){console.error(e)}t.duration&&l&&n.push({cueText:l,start:s,end:c,settings:u})}),a+=t.size})}}),n}},Or=Je,kr=function(e){var t=e[1]&31;return t<<=8,t|=e[2],t},Ar=function(e){return!!(e[1]&64)},jr=function(e){var t=0;return(e[3]&48)>>>4>1&&(t+=e[4]+1),t},Mr=function(e,t){var n=kr(e);return n===0?`pat`:n===t?`pmt`:t?`pes`:null},Nr=function(e){var t=Ar(e),n=4+jr(e);return t&&(n+=e[n]+1),(e[n+10]&31)<<8|e[n+11]},Pr=function(e){var t={},n=Ar(e),r=4+jr(e);if(n&&(r+=e[r]+1),e[r+5]&1){for(var i=3+((e[r+1]&15)<<8|e[r+2])-4,a=12+((e[r+10]&15)<<8|e[r+11]);a<i;){var o=r+a;t[(e[o+1]&31)<<8|e[o+2]]=e[o],a+=((e[o+3]&15)<<8|e[o+4])+5}return t}},Fr=function(e,t){switch(t[kr(e)]){case Or.H264_STREAM_TYPE:return`video`;case Or.ADTS_STREAM_TYPE:return`audio`;case Or.METADATA_STREAM_TYPE:return`timed-metadata`;default:return null}},Ir=function(e){if(!Ar(e))return null;var t=4+jr(e);if(t>=e.byteLength)return null;var n=null,r=e[t+7];return r&192&&(n={},n.pts=(e[t+9]&14)<<27|(e[t+10]&255)<<20|(e[t+11]&254)<<12|(e[t+12]&255)<<5|(e[t+13]&254)>>>3,n.pts*=4,n.pts+=(e[t+13]&6)>>>1,n.dts=n.pts,r&64&&(n.dts=(e[t+14]&14)<<27|(e[t+15]&255)<<20|(e[t+16]&254)<<12|(e[t+17]&255)<<5|(e[t+18]&254)>>>3,n.dts*=4,n.dts+=(e[t+18]&6)>>>1)),n},Lr=function(e){switch(e){case 5:return`slice_layer_without_partitioning_rbsp_idr`;case 6:return`sei_rbsp`;case 7:return`seq_parameter_set_rbsp`;case 8:return`pic_parameter_set_rbsp`;case 9:return`access_unit_delimiter_rbsp`;default:return null}},Rr={parseType:Mr,parsePat:Nr,parsePmt:Pr,parsePayloadUnitStartIndicator:Ar,parsePesType:Fr,parsePesTime:Ir,videoPacketContainsKeyFrame:function(e){for(var t=4+jr(e),n=e.subarray(t),r=0,i=0,a=!1,o;i<n.byteLength-3;i++)if(n[i+2]===1){r=i+5;break}for(;r<n.byteLength;)switch(n[r]){case 0:if(n[r-1]!==0){r+=2;break}if(n[r-2]!==0){r++;break}i+3!==r-2&&(o=Lr(n[i+3]&31),o===`slice_layer_without_partitioning_rbsp_idr`&&(a=!0));do r++;while(n[r]!==1&&r<n.length);i=r-2,r+=3;break;case 1:if(n[r-1]!==0||n[r-2]!==0){r+=3;break}o=Lr(n[i+3]&31),o===`slice_layer_without_partitioning_rbsp_idr`&&(a=!0),i=r-2,r+=3;break;default:r+=3}return n=n.subarray(i),r-=i,i=0,n&&n.byteLength>3&&(o=Lr(n[i+3]&31),o===`slice_layer_without_partitioning_rbsp_idr`&&(a=!0)),a}},zr=Je,Br=tt.handleRollover,H={};H.ts=Rr,H.aac=Wt;var Vr=P.ONE_SECOND_IN_TS,Hr=188,Ur=71,Wr=function(e,t){for(var n=0,r=Hr,i,a;r<e.byteLength;)if(e[n]===Ur&&e[r]===Ur){switch(i=e.subarray(n,r),a=H.ts.parseType(i,t.pid),a){case`pat`:t.pid=H.ts.parsePat(i);break;case`pmt`:var o=H.ts.parsePmt(i);t.table=t.table||{},Object.keys(o).forEach(function(e){t.table[e]=o[e]})}n+=Hr,r+=Hr}else n++,r++},Gr=function(e,t,n){for(var r=0,i=Hr,a,o,s,c,l,u=!1;i<=e.byteLength;)if(e[r]===Ur&&(e[i]===Ur||i===e.byteLength)){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`audio`&&c&&(l=H.ts.parsePesTime(a),l&&(l.type=`audio`,n.audio.push(l),u=!0))),u)break;r+=Hr,i+=Hr}else r++,i++;for(i=e.byteLength,r=i-Hr,u=!1;r>=0;)if(e[r]===Ur&&(e[i]===Ur||i===e.byteLength)){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`audio`&&c&&(l=H.ts.parsePesTime(a),l&&(l.type=`audio`,n.audio.push(l),u=!0))),u)break;r-=Hr,i-=Hr}else r--,i--},Kr=function(e,t,n){for(var r=0,i=Hr,a,o,s,c,l,u,d,f,p=!1,m={data:[],size:0};i<e.byteLength;)if(e[r]===Ur&&e[i]===Ur){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`video`&&(c&&!p&&(l=H.ts.parsePesTime(a),l&&(l.type=`video`,n.video.push(l),p=!0)),!n.firstKeyFrame))){if(c&&m.size!==0){for(u=new Uint8Array(m.size),d=0;m.data.length;)f=m.data.shift(),u.set(f,d),d+=f.byteLength;if(H.ts.videoPacketContainsKeyFrame(u)){var h=H.ts.parsePesTime(u);h?(n.firstKeyFrame=h,n.firstKeyFrame.type=`video`):console.warn(`Failed to extract PTS/DTS from PES at first keyframe. This could be an unusual TS segment, or else mux.js did not parse your TS segment correctly. If you know your TS segments do contain PTS/DTS on keyframes please file a bug report! You can try ffprobe to double check for yourself.`)}m.size=0}m.data.push(a),m.size+=a.byteLength}if(p&&n.firstKeyFrame)break;r+=Hr,i+=Hr}else r++,i++;for(i=e.byteLength,r=i-Hr,p=!1;r>=0;)if(e[r]===Ur&&e[i]===Ur){if(a=e.subarray(r,i),o=H.ts.parseType(a,t.pid),o===`pes`&&(s=H.ts.parsePesType(a,t.table),c=H.ts.parsePayloadUnitStartIndicator(a),s===`video`&&c&&(l=H.ts.parsePesTime(a),l&&(l.type=`video`,n.video.push(l),p=!0))),p)break;r-=Hr,i-=Hr}else r--,i--},qr=function(e,t){if(e.audio&&e.audio.length){var n=t;(n===void 0||isNaN(n))&&(n=e.audio[0].dts),e.audio.forEach(function(e){e.dts=Br(e.dts,n),e.pts=Br(e.pts,n),e.dtsTime=e.dts/Vr,e.ptsTime=e.pts/Vr})}if(e.video&&e.video.length){var r=t;if((r===void 0||isNaN(r))&&(r=e.video[0].dts),e.video.forEach(function(e){e.dts=Br(e.dts,r),e.pts=Br(e.pts,r),e.dtsTime=e.dts/Vr,e.ptsTime=e.pts/Vr}),e.firstKeyFrame){var i=e.firstKeyFrame;i.dts=Br(i.dts,r),i.pts=Br(i.pts,r),i.dtsTime=i.dts/Vr,i.ptsTime=i.pts/Vr}}},Jr=function(e){for(var t=!1,n=0,r=null,i=null,a=0,o=0,s;e.length-o>=3;){switch(H.aac.parseType(e,o)){case`timed-metadata`:if(e.length-o<10||(a=H.aac.parseId3TagSize(e,o),a>e.length)){t=!0;break}i===null&&(s=e.subarray(o,o+a),i=H.aac.parseAacTimestamp(s)),o+=a;break;case`audio`:if(e.length-o<7||(a=H.aac.parseAdtsSize(e,o),a>e.length)){t=!0;break}r===null&&(s=e.subarray(o,o+a),r=H.aac.parseSampleRate(s)),n++,o+=a;break;default:o++}if(t)return null}if(r===null||i===null)return null;var c=Vr/r;return{audio:[{type:`audio`,dts:i,pts:i},{type:`audio`,dts:i+n*1024*c,pts:i+n*1024*c}]}},Yr=function(e){var t={pid:null,table:null},n={};for(var r in Wr(e,t),t.table)if(t.table.hasOwnProperty(r))switch(t.table[r]){case zr.H264_STREAM_TYPE:n.video=[],Kr(e,t,n),n.video.length===0&&delete n.video;break;case zr.ADTS_STREAM_TYPE:n.audio=[],Gr(e,t,n),n.audio.length===0&&delete n.audio}return n},Xr={inspect:function(e,t){var n=H.aac.isLikelyAacData(e)?Jr(e):Yr(e);return!n||!n.audio&&!n.video?null:(qr(n,t),n)},parseAudioPes_:Gr};let Zr=function(e,t){t.on(`data`,function(t){let n=t.initSegment;t.initSegment={data:n.buffer,byteOffset:n.byteOffset,byteLength:n.byteLength};let r=t.data;t.data=r.buffer,e.postMessage({action:`data`,segment:t,byteOffset:r.byteOffset,byteLength:r.byteLength},[t.data])}),t.on(`done`,function(t){e.postMessage({action:`done`})}),t.on(`gopInfo`,function(t){e.postMessage({action:`gopInfo`,gopInfo:t})}),t.on(`videoSegmentTimingInfo`,function(t){let n={start:{decode:P.videoTsToSeconds(t.start.dts),presentation:P.videoTsToSeconds(t.start.pts)},end:{decode:P.videoTsToSeconds(t.end.dts),presentation:P.videoTsToSeconds(t.end.pts)},baseMediaDecodeTime:P.videoTsToSeconds(t.baseMediaDecodeTime)};t.prependedContentDuration&&(n.prependedContentDuration=P.videoTsToSeconds(t.prependedContentDuration)),e.postMessage({action:`videoSegmentTimingInfo`,videoSegmentTimingInfo:n})}),t.on(`audioSegmentTimingInfo`,function(t){let n={start:{decode:P.videoTsToSeconds(t.start.dts),presentation:P.videoTsToSeconds(t.start.pts)},end:{decode:P.videoTsToSeconds(t.end.dts),presentation:P.videoTsToSeconds(t.end.pts)},baseMediaDecodeTime:P.videoTsToSeconds(t.baseMediaDecodeTime)};t.prependedContentDuration&&(n.prependedContentDuration=P.videoTsToSeconds(t.prependedContentDuration)),e.postMessage({action:`audioSegmentTimingInfo`,audioSegmentTimingInfo:n})}),t.on(`id3Frame`,function(t){e.postMessage({action:`id3Frame`,id3Frame:t})}),t.on(`caption`,function(t){e.postMessage({action:`caption`,caption:t})}),t.on(`trackinfo`,function(t){e.postMessage({action:`trackinfo`,trackInfo:t})}),t.on(`audioTimingInfo`,function(t){e.postMessage({action:`audioTimingInfo`,audioTimingInfo:{start:P.videoTsToSeconds(t.start),end:P.videoTsToSeconds(t.end)}})}),t.on(`videoTimingInfo`,function(t){e.postMessage({action:`videoTimingInfo`,videoTimingInfo:{start:P.videoTsToSeconds(t.start),end:P.videoTsToSeconds(t.end)}})}),t.on(`log`,function(t){e.postMessage({action:`log`,log:t})})};class Qr{constructor(e,t){this.options=t||{},this.self=e,this.init()}init(){this.transmuxer&&this.transmuxer.dispose(),this.transmuxer=new yn.Transmuxer(this.options),Zr(this.self,this.transmuxer)}pushMp4Captions(e){this.captionParser||(this.captionParser=new xr,this.captionParser.init());let t=new Uint8Array(e.data,e.byteOffset,e.byteLength),n=this.captionParser.parse(t,e.trackIds,e.timescales);this.self.postMessage({action:`mp4Captions`,captions:n&&n.captions||[],logs:n&&n.logs||[],data:t.buffer},[t.buffer])}initMp4WebVttParser(e){this.webVttParser||=new Dr;let t=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.webVttParser.init(t)}getMp4WebVttText(e){this.webVttParser||=new Dr;let t=new Uint8Array(e.data,e.byteOffset,e.byteLength),n=this.webVttParser.parseSegment(t);this.self.postMessage({action:`getMp4WebVttText`,mp4VttCues:n||[],data:t.buffer},[t.buffer])}probeMp4StartTime({timescales:e,data:t}){let n=or.startTime(e,t);this.self.postMessage({action:`probeMp4StartTime`,startTime:n,data:t},[t.buffer])}probeMp4Tracks({data:e}){let t=or.tracks(e);this.self.postMessage({action:`probeMp4Tracks`,tracks:t,data:e},[e.buffer])}probeEmsgID3({data:e,offset:t}){let n=or.getEmsgID3(e,t);this.self.postMessage({action:`probeEmsgID3`,id3Frames:n,emsgData:e},[e.buffer])}probeTs({data:e,baseStartTime:t}){let n=typeof t==`number`&&!isNaN(t)?t*P.ONE_SECOND_IN_TS:void 0,r=Xr.inspect(e,n),i=null;r&&(i={hasVideo:r.video&&r.video.length===2||!1,hasAudio:r.audio&&r.audio.length===2||!1},i.hasVideo&&(i.videoStart=r.video[0].ptsTime),i.hasAudio&&(i.audioStart=r.audio[0].ptsTime)),this.self.postMessage({action:`probeTs`,result:i,data:e},[e.buffer])}clearAllMp4Captions(){this.captionParser&&this.captionParser.clearAllCaptions()}clearParsedMp4Captions(){this.captionParser&&this.captionParser.clearParsedCaptions()}push(e){let t=new Uint8Array(e.data,e.byteOffset,e.byteLength);this.transmuxer.push(t)}reset(){this.transmuxer.reset()}setTimestampOffset(e){let t=e.timestampOffset||0;this.transmuxer.setBaseMediaDecodeTime(Math.round(P.secondsToVideoTs(t)))}setAudioAppendStart(e){this.transmuxer.setAudioAppendStart(Math.ceil(P.secondsToVideoTs(e.appendStart)))}setRemux(e){this.transmuxer.setRemux(e.remux)}flush(e){this.transmuxer.flush(),self.postMessage({action:`done`,type:`transmuxed`})}endTimeline(){this.transmuxer.endTimeline(),self.postMessage({action:`endedtimeline`,type:`transmuxed`})}alignGopsWith(e){this.transmuxer.alignGopsWith(e.gopsToAlignWith.slice())}}self.onmessage=function(e){e.data.action===`init`&&e.data.options?this.messageHandlers=new Qr(self,e.data.options):(this.messageHandlers||=new Qr(self),e.data&&e.data.action&&e.data.action!==`init`&&this.messageHandlers[e.data.action]&&this.messageHandlers[e.data.action](e.data))}})));const Of=(e,t,n)=>{let{type:r,initSegment:i,captions:a,captionStreams:o,metadata:s,videoFrameDtsTime:c,videoFramePtsTime:l}=e.data.segment;t.buffer.push({captions:a,captionStreams:o,metadata:s});let u=e.data.segment.boxes||{data:e.data.segment.data},d={type:r,data:new Uint8Array(u.data,u.data.byteOffset,u.data.byteLength),initSegment:new Uint8Array(i.data,i.byteOffset,i.byteLength)};c!==void 0&&(d.videoFrameDtsTime=c),l!==void 0&&(d.videoFramePtsTime=l),n(d)},kf=({transmuxedData:e,callback:t})=>{e.buffer=[],t(e)},Af=(e,t)=>{t.gopInfo=e.data.gopInfo},jf=e=>{let{transmuxer:t,bytes:n,audioAppendStart:r,gopsToAlignWith:i,remux:a,onData:o,onTrackInfo:s,onAudioTimingInfo:c,onVideoTimingInfo:l,onVideoSegmentTimingInfo:u,onAudioSegmentTimingInfo:d,onId3:f,onCaptions:p,onDone:m,onEndedTimeline:h,onTransmuxerLog:g,isEndOfTimeline:_,segment:v,triggerSegmentEventFn:y}=e,b={buffer:[]},x=_;if(t.onmessage=n=>{t.currentTransmux===e&&(n.data.action===`data`&&Of(n,b,o),n.data.action===`trackinfo`&&s(n.data.trackInfo),n.data.action===`gopInfo`&&Af(n,b),n.data.action===`audioTimingInfo`&&c(n.data.audioTimingInfo),n.data.action===`videoTimingInfo`&&l(n.data.videoTimingInfo),n.data.action===`videoSegmentTimingInfo`&&u(n.data.videoSegmentTimingInfo),n.data.action===`audioSegmentTimingInfo`&&d(n.data.audioSegmentTimingInfo),n.data.action===`id3Frame`&&f([n.data.id3Frame],n.data.id3Frame.dispatchType),n.data.action===`caption`&&p(n.data.caption),n.data.action===`endedtimeline`&&(x=!1,h()),n.data.action===`log`&&g(n.data.log),n.data.type===`transmuxed`&&(x||(t.onmessage=null,kf({transmuxedData:b,callback:m}),Mf(t))))},t.onerror=()=>{let e={message:`Received an error message from the transmuxer worker`,metadata:{errorType:Z.Error.StreamingFailedToTransmuxSegment,segmentInfo:Jp({segment:v})}};m(null,e)},r&&t.postMessage({action:`setAudioAppendStart`,appendStart:r}),Array.isArray(i)&&t.postMessage({action:`alignGopsWith`,gopsToAlignWith:i}),a!==void 0&&t.postMessage({action:`setRemux`,remux:a}),n.byteLength){let e=n instanceof ArrayBuffer?n:n.buffer,r=n instanceof ArrayBuffer?0:n.byteOffset;y({type:`segmenttransmuxingstart`,segment:v}),t.postMessage({action:`push`,data:e,byteOffset:r,byteLength:n.byteLength},[e])}_&&t.postMessage({action:`endTimeline`}),t.postMessage({action:`flush`})},Mf=e=>{e.currentTransmux=null,e.transmuxQueue.length&&(e.currentTransmux=e.transmuxQueue.shift(),typeof e.currentTransmux==`function`?e.currentTransmux():jf(e.currentTransmux))},Nf=(e,t)=>{e.postMessage({action:t}),Mf(e)},Pf=(e,t)=>{t.currentTransmux?t.transmuxQueue.push(Nf.bind(null,t,e)):(t.currentTransmux=e,Nf(t,e))},Ff=e=>{Pf(`reset`,e)},If=e=>{Pf(`endTimeline`,e)},Lf=e=>{e.transmuxer.currentTransmux?e.transmuxer.transmuxQueue.push(e):(e.transmuxer.currentTransmux=e,jf(e))};var Rf={reset:Ff,endTimeline:If,transmux:Lf,createTransmuxer:e=>{let t=new Df;t.currentTransmux=null,t.transmuxQueue=[];let n=t.terminate;return t.terminate=()=>(t.currentTransmux=null,t.transmuxQueue.length=0,n.call(t)),t.postMessage({action:`init`,options:e}),t}};const zf=function(e){let t=e.transmuxer,n=e.endAction||e.action,r=e.callback,i=R({},e,{endAction:null,transmuxer:null,callback:null}),a=i=>{i.data.action===n&&(t.removeEventListener(`message`,a),i.data.data&&(i.data.data=new Uint8Array(i.data.data,e.byteOffset||0,e.byteLength||i.data.data.byteLength),e.data&&=i.data.data),r(i.data))};if(t.addEventListener(`message`,a),e.data){let n=e.data instanceof ArrayBuffer;i.byteOffset=n?0:e.data.byteOffset,i.byteLength=e.data.byteLength;let r=[n?e.data:e.data.buffer];t.postMessage(i,r)}else t.postMessage(i)},Bf={FAILURE:2,TIMEOUT:-101,ABORTED:-102},Vf=`wvtt`,Hf=e=>{e.forEach(e=>{e.abort()})},Uf=e=>({bandwidth:e.bandwidth,bytesReceived:e.bytesReceived||0,roundTripTime:e.roundTripTime||0}),Wf=e=>{let t=e.target,n={bandwidth:1/0,bytesReceived:0,roundTripTime:Date.now()-t.requestTime||0};return n.bytesReceived=e.loaded,n.bandwidth=Math.floor(n.bytesReceived/n.roundTripTime*8*1e3),n},Gf=(e,t)=>{let{requestType:n}=t,r=yd({requestType:n,request:t,error:e});return t.timedout?{status:t.status,message:`HLS request timed-out at URL: `+t.uri,code:Bf.TIMEOUT,xhr:t,metadata:r}:t.aborted?{status:t.status,message:`HLS request aborted at URL: `+t.uri,code:Bf.ABORTED,xhr:t,metadata:r}:e?{status:t.status,message:`HLS request errored at URL: `+t.uri,code:Bf.FAILURE,xhr:t,metadata:r}:t.responseType===`arraybuffer`&&t.response.byteLength===0?{status:t.status,message:`Empty HLS response at URL: `+t.uri,code:Bf.FAILURE,xhr:t,metadata:r}:null},Kf=(e,t,n,r)=>(i,a)=>{let o=a.response,s=Gf(i,a);if(s)return n(s,e);if(o.byteLength!==16)return n({status:a.status,message:`Invalid HLS key at URL: `+a.uri,code:Bf.FAILURE,xhr:a},e);let c=new DataView(o),l=new Uint32Array([c.getUint32(0),c.getUint32(4),c.getUint32(8),c.getUint32(12)]);for(let e=0;e<t.length;e++)t[e].bytes=l;return r({type:`segmentkeyloadcomplete`,segment:e,keyInfo:{uri:a.uri}}),n(null,e)},qf=(e,t)=>{t===Vf&&e.transmuxer.postMessage({action:`initMp4WebVttParser`,data:e.map.bytes})},Jf=(e,t,n)=>{t===Vf&&zf({action:`getMp4WebVttText`,data:e.bytes,transmuxer:e.transmuxer,callback:({data:t,mp4VttCues:r})=>{e.bytes=t,n(null,e,{mp4VttCues:r})}})},Yf=(e,t)=>{let n=di(e.map.bytes);if(n!==`mp4`){let r=e.map.resolvedUri||e.map.uri,i=n||`unknown`;return t({internal:!0,message:`Found unsupported ${i} container for initialization segment at URL: ${r}`,code:Bf.FAILURE,metadata:{mediaType:i}})}zf({action:`probeMp4Tracks`,data:e.map.bytes,transmuxer:e.transmuxer,callback:({tracks:n,data:r})=>(e.map.bytes=r,n.forEach(function(t){e.map.tracks=e.map.tracks||{},e.map.tracks[t.type]||(e.map.tracks[t.type]=t,typeof t.id==`number`&&t.timescale&&(e.map.timescales=e.map.timescales||{},e.map.timescales[t.id]=t.timescale),t.type===`text`&&qf(e,t.codec))}),t(null))})},Xf=({segment:e,finishProcessingFn:t,triggerSegmentEventFn:n})=>(r,i)=>{let a=Gf(r,i);if(a)return t(a,e);let o=new Uint8Array(i.response);if(n({type:`segmentloaded`,segment:e}),e.map.key)return e.map.encryptedBytes=o,t(null,e);e.map.bytes=o,Yf(e,function(n){if(n)return n.xhr=i,n.status=i.status,t(n,e);t(null,e)})},Zf=({segment:e,finishProcessingFn:t,responseType:n,triggerSegmentEventFn:r})=>(i,a)=>{let o=Gf(i,a);if(o)return t(o,e);r({type:`segmentloaded`,segment:e});let s=n===`arraybuffer`||!a.responseText?a.response:xf(a.responseText.substring(e.lastReachedChar||0));return e.stats=Uf(a),e.key?e.encryptedBytes=new Uint8Array(s):e.bytes=new Uint8Array(s),t(null,e)},Qf=({segment:e,bytes:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{let m=e.map&&e.map.tracks||{},h=!!(m.audio&&m.video),g=r.bind(null,e,`audio`,`start`),_=r.bind(null,e,`audio`,`end`),v=r.bind(null,e,`video`,`start`),y=r.bind(null,e,`video`,`end`),b=()=>Lf({bytes:t,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,remux:h,onData:t=>{t.type=t.type===`combined`?`video`:t.type,u(e,t)},onTrackInfo:t=>{n&&(h&&(t.isMuxed=!0),n(e,t))},onAudioTimingInfo:e=>{g&&e.start!==void 0&&(g(e.start),g=null),_&&e.end!==void 0&&_(e.end)},onVideoTimingInfo:e=>{v&&e.start!==void 0&&(v(e.start),v=null),y&&e.end!==void 0&&y(e.end)},onVideoSegmentTimingInfo:t=>{p({type:`segmenttransmuxingtiminginfoavailable`,segment:e,timingInfo:{pts:{start:t.start.presentation,end:t.end.presentation},dts:{start:t.start.decode,end:t.end.decode}}}),i(t)},onAudioSegmentTimingInfo:t=>{p({type:`segmenttransmuxingtiminginfoavailable`,segment:e,timingInfo:{pts:{start:t.start.pts,end:t.end.pts},dts:{start:t.start.dts,end:t.end.dts}}}),a(t)},onId3:(t,n)=>{o(e,t,n)},onCaptions:t=>{s(e,[t])},isEndOfTimeline:c,onEndedTimeline:()=>{l()},onTransmuxerLog:f,onDone:(t,n)=>{d&&(t.type=t.type===`combined`?`video`:t.type,p({type:`segmenttransmuxingcomplete`,segment:e}),d(n,e,t))},segment:e,triggerSegmentEventFn:p});zf({action:`probeTs`,transmuxer:e.transmuxer,data:t,baseStartTime:e.baseStartTime,callback:r=>{e.bytes=t=r.data;let i=r.result;i&&(n(e,{hasAudio:i.hasAudio,hasVideo:i.hasVideo,isMuxed:h}),n=null),b()}})},$f=({segment:e,bytes:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{let m=new Uint8Array(t);if(fi(m)){e.isFmp4=!0;let{tracks:i}=e.map;if(i.text&&(!i.audio||!i.video)){u(e,{data:m,type:`text`}),Jf(e,i.text.codec,d);return}let a={isFmp4:!0,hasVideo:!!i.video,hasAudio:!!i.audio};i.audio&&i.audio.codec&&i.audio.codec!==`enca`&&(a.audioCodec=i.audio.codec),i.video&&i.video.codec&&i.video.codec!==`encv`&&(a.videoCodec=i.video.codec),i.video&&i.audio&&(a.isMuxed=!0),n(e,a);let c=(t,n)=>{u(e,{data:m,type:a.hasAudio&&!a.isMuxed?`audio`:`video`}),n&&n.length&&o(e,n),t&&t.length&&s(e,t),d(null,e,{})};zf({action:`probeMp4StartTime`,timescales:e.map.timescales,data:m,transmuxer:e.transmuxer,callback:({data:n,startTime:o})=>{t=n.buffer,e.bytes=m=n,a.hasAudio&&!a.isMuxed&&r(e,`audio`,`start`,o),a.hasVideo&&r(e,`video`,`start`,o),zf({action:`probeEmsgID3`,data:m,transmuxer:e.transmuxer,offset:o,callback:({emsgData:n,id3Frames:r})=>{t=n.buffer,e.bytes=m=n,!i.video||!n.byteLength||!e.transmuxer?c(void 0,r):zf({action:`pushMp4Captions`,endAction:`mp4Captions`,transmuxer:e.transmuxer,data:m,timescales:e.map.timescales,trackIds:[i.video.id],callback:n=>{t=n.data.buffer,e.bytes=m=n.data,n.logs.forEach(function(e){f(Q(e,{stream:`mp4CaptionParser`}))}),c(n.captions,r)}})}})}})}else e.transmuxer?(e.container===void 0&&(e.container=di(m)),e.container!==`ts`&&e.container!==`aac`?(n(e,{hasAudio:!1,hasVideo:!1}),d(null,e,{})):Qf({segment:e,bytes:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})):d(null,e,{})},ep=function({id:e,key:t,encryptedBytes:n,decryptionWorker:r,segment:i,doneFn:a},o){let s=t=>{if(t.data.source===e){r.removeEventListener(`message`,s);let e=t.data.decrypted;o(new Uint8Array(e.bytes,e.byteOffset,e.byteLength))}};r.onerror=()=>{let e=`An error occurred in the decryption worker`,t=Jp({segment:i});a({message:e,metadata:{error:Error(e),errorType:Z.Error.StreamingFailedToDecryptSegment,segmentInfo:t,keyInfo:{uri:i.key.resolvedUri||i.map.key.resolvedUri}}},i)},r.addEventListener(`message`,s);let c;c=t.bytes.slice?t.bytes.slice():new Uint32Array(Array.prototype.slice.call(t.bytes)),r.postMessage(qd({source:e,encrypted:n,key:c,iv:t.iv}),[n.buffer,c.buffer])},tp=({decryptionWorker:e,segment:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{p({type:`segmentdecryptionstart`}),ep({id:t.requestId,key:t.key,encryptedBytes:t.encryptedBytes,decryptionWorker:e,segment:t,doneFn:d},e=>{t.bytes=e,p({type:`segmentdecryptioncomplete`,segment:t}),$f({segment:t,bytes:t.bytes,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})})},np=({activeXhrs:e,decryptionWorker:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})=>{let m=0,h=!1;return(g,_)=>{if(!h){if(g)return h=!0,Hf(e),d(g,_);if(m+=1,m===e.length){let m=function(){if(_.encryptedBytes)return tp({decryptionWorker:t,segment:_,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p});$f({segment:_,bytes:_.bytes,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u,doneFn:d,onTransmuxerLog:f,triggerSegmentEventFn:p})};if(_.endOfAllRequests=Date.now(),_.map&&_.map.encryptedBytes&&!_.map.bytes)return p({type:`segmentdecryptionstart`,segment:_}),ep({decryptionWorker:t,id:_.requestId+`-init`,encryptedBytes:_.map.encryptedBytes,key:_.map.key,segment:_,doneFn:d},t=>{_.map.bytes=t,p({type:`segmentdecryptioncomplete`,segment:_}),Yf(_,t=>{if(t)return Hf(e),d(t,_);m()})});m()}}}},rp=({loadendState:e,abortFn:t})=>n=>{n.target.aborted&&t&&!e.calledAbortFn&&(t(),e.calledAbortFn=!0)},ip=({segment:e,progressFn:t,trackInfoFn:n,timingInfoFn:r,videoSegmentTimingInfoFn:i,audioSegmentTimingInfoFn:a,id3Fn:o,captionsFn:s,isEndOfTimeline:c,endedTimelineFn:l,dataFn:u})=>n=>{if(!n.target.aborted)return e.stats=Q(e.stats,Wf(n)),!e.stats.firstBytesReceivedAt&&e.stats.bytesReceived&&(e.stats.firstBytesReceivedAt=Date.now()),t(n,e)},ap=({xhr:e,xhrOptions:t,decryptionWorker:n,segment:r,abortFn:i,progressFn:a,trackInfoFn:o,timingInfoFn:s,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:l,id3Fn:u,captionsFn:d,isEndOfTimeline:f,endedTimelineFn:p,dataFn:m,doneFn:h,onTransmuxerLog:g,triggerSegmentEventFn:_})=>{let v=[],y=np({activeXhrs:v,decryptionWorker:n,trackInfoFn:o,timingInfoFn:s,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:l,id3Fn:u,captionsFn:d,isEndOfTimeline:f,endedTimelineFn:p,dataFn:m,doneFn:h,onTransmuxerLog:g,triggerSegmentEventFn:_});if(r.key&&!r.key.bytes){let n=[r.key];r.map&&!r.map.bytes&&r.map.key&&r.map.key.resolvedUri===r.key.resolvedUri&&n.push(r.map.key);let i=Q(t,{uri:r.key.resolvedUri,responseType:`arraybuffer`,requestType:`segment-key`}),a=Kf(r,n,y,_);_({type:`segmentkeyloadstart`,segment:r,keyInfo:{uri:r.key.resolvedUri}});let o=e(i,a);v.push(o)}if(r.map&&!r.map.bytes){if(r.map.key&&(!r.key||r.key.resolvedUri!==r.map.key.resolvedUri)){let n=Q(t,{uri:r.map.key.resolvedUri,responseType:`arraybuffer`,requestType:`segment-key`}),i=Kf(r,[r.map.key],y,_);_({type:`segmentkeyloadstart`,segment:r,keyInfo:{uri:r.map.key.resolvedUri}});let a=e(n,i);v.push(a)}let n=Q(t,{uri:r.map.resolvedUri,responseType:`arraybuffer`,headers:Ud(r.map),requestType:`segment-media-initialization`}),i=Xf({segment:r,finishProcessingFn:y,triggerSegmentEventFn:_});_({type:`segmentloadstart`,segment:r});let a=e(n,i);v.push(a)}let b=Q(t,{uri:r.part&&r.part.resolvedUri||r.resolvedUri,responseType:`arraybuffer`,headers:Ud(r),requestType:`segment`}),x=Zf({segment:r,finishProcessingFn:y,responseType:b.responseType,triggerSegmentEventFn:_});_({type:`segmentloadstart`,segment:r});let S=e(b,x);S.addEventListener(`progress`,ip({segment:r,progressFn:a,trackInfoFn:o,timingInfoFn:s,videoSegmentTimingInfoFn:c,audioSegmentTimingInfoFn:l,id3Fn:u,captionsFn:d,isEndOfTimeline:f,endedTimelineFn:p,dataFn:m})),v.push(S);let C={};return v.forEach(e=>{e.addEventListener(`loadend`,rp({loadendState:C,abortFn:i}))}),()=>Hf(v)},op=xu(`PlaylistSelector`),sp=function(e){if(!e||!e.playlist)return;let t=e.playlist;return JSON.stringify({id:t.id,bandwidth:e.bandwidth,width:e.width,height:e.height,codecs:t.attributes&&t.attributes.CODECS||``})},cp=function(e,t){if(!e)return``;let n=x.getComputedStyle(e);return n?n[t]:``},lp=function(e,t){let n=e.slice();e.sort(function(e,r){let i=t(e,r);return i===0?n.indexOf(e)-n.indexOf(r):i})},up=function(e,t){let n,r;return e.attributes.BANDWIDTH&&(n=e.attributes.BANDWIDTH),n||=x.Number.MAX_VALUE,t.attributes.BANDWIDTH&&(r=t.attributes.BANDWIDTH),r||=x.Number.MAX_VALUE,n-r},dp=function(e,t){let n,r;return e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width&&(n=e.attributes.RESOLUTION.width),n||=x.Number.MAX_VALUE,t.attributes.RESOLUTION&&t.attributes.RESOLUTION.width&&(r=t.attributes.RESOLUTION.width),r||=x.Number.MAX_VALUE,n===r&&e.attributes.BANDWIDTH&&t.attributes.BANDWIDTH?e.attributes.BANDWIDTH-t.attributes.BANDWIDTH:n-r};let fp=function(e){let{main:t,bandwidth:n,playerWidth:r,playerHeight:i,playerObjectFit:a,limitRenditionByPlayerDimensions:o,playlistController:s}=e;if(!t)return;let c={bandwidth:n,width:r,height:i,limitRenditionByPlayerDimensions:o},l=t.playlists;sd.isAudioOnly(t)&&(l=s.getAudioTrackPlaylists_(),c.audioOnly=!0);let u=l.map(e=>{let t,n=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.width,r=e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height;return t=e.attributes&&e.attributes.BANDWIDTH,t||=x.Number.MAX_VALUE,{bandwidth:t,width:n,height:r,playlist:e}});lp(u,(e,t)=>e.bandwidth-t.bandwidth),u=u.filter(e=>!sd.isIncompatible(e.playlist));let d=u.filter(e=>sd.isEnabled(e.playlist));d.length||(d=u.filter(e=>!sd.isDisabled(e.playlist)));let f=d.filter(e=>e.bandwidth*bf.BANDWIDTH_VARIANCE<n),p=f[f.length-1],m=f.filter(e=>e.bandwidth===p.bandwidth)[0];if(o===!1){let e=m||d[0]||u[0];if(e&&e.playlist){let t=`sortedPlaylistReps`;return m&&(t=`bandwidthBestRep`),d[0]&&(t=`enabledPlaylistReps`),op(`choosing ${sp(e)} using ${t} with options`,c),e.playlist}return op(`could not choose a playlist with options`,c),null}let h=f.filter(e=>e.width&&e.height);lp(h,(e,t)=>e.width-t.width);let g=h.filter(e=>e.width===r&&e.height===i);p=g[g.length-1];let _=g.filter(e=>e.bandwidth===p.bandwidth)[0],v,y,b;_||(v=h.filter(e=>a===`cover`?e.width>r&&e.height>i:e.width>r||e.height>i),y=v.filter(e=>e.width===v[0].width&&e.height===v[0].height),p=y[y.length-1],b=y.filter(e=>e.bandwidth===p.bandwidth)[0]);let S;if(s.leastPixelDiffSelector){let e=h.map(e=>(e.pixelDiff=Math.abs(e.width-r)+Math.abs(e.height-i),e));lp(e,(e,t)=>e.pixelDiff===t.pixelDiff?t.bandwidth-e.bandwidth:e.pixelDiff-t.pixelDiff),S=e[0]}let C=S||b||_||m||d[0]||u[0];if(C&&C.playlist){let e=`sortedPlaylistReps`;return S?e=`leastPixelDiffRep`:b?e=`resolutionPlusOneRep`:_?e=`resolutionBestRep`:m?e=`bandwidthBestRep`:d[0]&&(e=`enabledPlaylistReps`),op(`choosing ${sp(C)} using ${e} with options`,c),C.playlist}return op(`could not choose a playlist with options`,c),null};const pp=function(){let e=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(e=this.customPixelRatio),fp({main:this.playlists.main,bandwidth:this.systemBandwidth,playerWidth:parseInt(cp(this.tech_.el(),`width`),10)*e,playerHeight:parseInt(cp(this.tech_.el(),`height`),10)*e,playerObjectFit:this.usePlayerObjectFit?cp(this.tech_.el(),`objectFit`):``,limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})},mp=function(e){let t=-1,n=-1;if(e<0||e>1)throw Error(`Moving average bandwidth decay must be between 0 and 1.`);return function(){let r=this.useDevicePixelRatio&&x.devicePixelRatio||1;return isNaN(this.customPixelRatio)||(r=this.customPixelRatio),t<0&&(t=this.systemBandwidth,n=this.systemBandwidth),this.systemBandwidth>0&&this.systemBandwidth!==n&&(t=e*this.systemBandwidth+(1-e)*t,n=this.systemBandwidth),fp({main:this.playlists.main,bandwidth:t,playerWidth:parseInt(cp(this.tech_.el(),`width`),10)*r,playerHeight:parseInt(cp(this.tech_.el(),`height`),10)*r,playerObjectFit:this.usePlayerObjectFit?cp(this.tech_.el(),`objectFit`):``,limitRenditionByPlayerDimensions:this.limitRenditionByPlayerDimensions,playlistController:this.playlistController_})}},hp=function(e){let{main:t,currentTime:n,bandwidth:r,duration:i,segmentDuration:a,timeUntilRebuffer:o,currentTimeline:s,syncController:c}=e,l=t.playlists.filter(e=>!sd.isIncompatible(e)),u=l.filter(sd.isEnabled);u.length||(u=l.filter(e=>!sd.isDisabled(e)));let d=u.filter(sd.hasAttribute.bind(null,`BANDWIDTH`)).map(e=>{let t=c.getSyncPoint(e,i,s,n)?1:2;return{playlist:e,rebufferingImpact:sd.estimateSegmentRequestTime(a,r,e)*t-o}}),f=d.filter(e=>e.rebufferingImpact<=0);return lp(f,(e,t)=>up(t.playlist,e.playlist)),f.length?f[0]:(lp(d,(e,t)=>e.rebufferingImpact-t.rebufferingImpact),d[0]||null)},gp=function(){let e=this.playlists.main.playlists.filter(sd.isEnabled);return lp(e,(e,t)=>up(e,t)),e.filter(e=>!!Ed(this.playlists.main,e).video)[0]||null},_p=e=>{let t=0,n;return e.bytes&&(n=new Uint8Array(e.bytes),e.segments.forEach(e=>{n.set(e,t),t+=e.byteLength})),n};function vp(e){try{return new URL(e).pathname.split(`/`).slice(-2).join(`/`)}catch{return``}}const yp=function(e,t,n){if(!e[n]){t.trigger({type:`usage`,name:`vhs-608`});let r=n;/^cc708_/.test(n)&&(r=`SERVICE`+n.split(`_`)[1]);let i=t.textTracks().getTrackById(r);if(i)e[n]=i;else{let i=t.options_.vhs&&t.options_.vhs.captionServices||{},a=n,o=n,s=!1,c=i[r];c&&(a=c.label,o=c.language,s=c.default),e[n]=t.addRemoteTextTrack({kind:`captions`,id:r,default:s,label:a,language:o},!1).track}}},bp=function({inbandTextTracks:e,captionArray:t,timestampOffset:n}){if(!t)return;let r=x.WebKitDataCue||x.VTTCue;t.forEach(t=>{let i=t.stream;t.content?t.content.forEach(a=>{let o=new r(t.startTime+n,t.endTime+n,a.text);o.line=a.line,o.align=`left`,o.position=a.position,o.positionAlign=`line-left`,e[i].addCue(o)}):e[i].addCue(new r(t.startTime+n,t.endTime+n,t.text))})},xp=function(e){Object.defineProperties(e.frame,{id:{get(){return Z.log.warn(`cue.frame.id is deprecated. Use cue.value.key instead.`),e.value.key}},value:{get(){return Z.log.warn(`cue.frame.value is deprecated. Use cue.value.data instead.`),e.value.data}},privateData:{get(){return Z.log.warn(`cue.frame.privateData is deprecated. Use cue.value.data instead.`),e.value.data}}})},Sp=({inbandTextTracks:e,metadataArray:t,timestampOffset:n,videoDuration:r})=>{if(!t)return;let i=x.WebKitDataCue||x.VTTCue,a=e.metadataTrack_;if(!a||(t.forEach(e=>{let t=e.cueTime+n;typeof t!=`number`||x.isNaN(t)||t<0||!(t<1/0)||e.frames&&e.frames.length&&e.frames.forEach(e=>{let n=new i(t,t,e.value||e.url||e.data||``);n.frame=e,n.value=e,xp(n),a.addCue(n)})}),!a.cues||!a.cues.length))return;let o=a.cues,s=[];for(let e=0;e<o.length;e++)o[e]&&s.push(o[e]);let c=s.reduce((e,t)=>{let n=e[t.startTime]||[];return n.push(t),e[t.startTime]=n,e},{}),l=Object.keys(c).sort((e,t)=>Number(e)-Number(t));l.forEach((e,t)=>{let n=c[e],i=isFinite(r)?r:e,a=Number(l[t+1])||i;n.forEach(e=>{e.endTime=a})})},Cp={id:`ID`,class:`CLASS`,startDate:`START-DATE`,duration:`DURATION`,endDate:`END-DATE`,endOnNext:`END-ON-NEXT`,plannedDuration:`PLANNED-DURATION`,scte35Out:`SCTE35-OUT`,scte35In:`SCTE35-IN`},wp=new Set([`id`,`class`,`startDate`,`duration`,`endDate`,`endOnNext`,`startTime`,`endTime`,`processDateRange`]),Tp=({inbandTextTracks:e,dateRanges:t})=>{let n=e.metadataTrack_;if(!n)return;let r=x.WebKitDataCue||x.VTTCue;t.forEach(e=>{for(let t of Object.keys(e)){if(wp.has(t))continue;let i=new r(e.startTime,e.endTime,``);i.id=e.id,i.type=`com.apple.quicktime.HLS`,i.value={key:Cp[t],data:e[t]},(t===`scte35Out`||t===`scte35In`)&&(i.value.data=new Uint8Array(i.value.data.match(/[\da-f]{2}/gi)).buffer),n.addCue(i)}e.processDateRange()})},Ep=(e,t,n)=>{e.metadataTrack_||(e.metadataTrack_=n.addRemoteTextTrack({kind:`metadata`,label:`Timed Metadata`},!1).track,Z.browser.IS_ANY_SAFARI||(e.metadataTrack_.inBandMetadataTrackDispatchType=t))},Dp=function(e,t,n){let r,i;if(n&&n.cues)for(r=n.cues.length;r--;)i=n.cues[r],i.startTime>=e&&i.endTime<=t&&n.removeCue(i)},Op=function(e){let t=e.cues;if(!t)return;let n={};for(let r=t.length-1;r>=0;r--){let i=t[r],a=`${i.startTime}-${i.endTime}-${i.text}`;n[a]?e.removeCue(i):n[a]=i}},kp=(e,t,n)=>{if(t==null||!e.length)return[];let r=Math.ceil((t-n+3)*gi.ONE_SECOND_IN_TS),i=0;for(;i<e.length&&!(e[i].pts>r);i++);return e.slice(i)},Ap=(e,t,n)=>{if(!t.length)return e;if(n)return t.slice();let r=t[0].pts,i=0;for(;i<e.length&&!(e[i].pts>=r);i++);return e.slice(0,i).concat(t)},jp=(e,t,n,r)=>{let i=Math.ceil((t-r)*gi.ONE_SECOND_IN_TS),a=Math.ceil((n-r)*gi.ONE_SECOND_IN_TS),o=e.slice(),s=e.length;for(;s--&&!(e[s].pts<=a););if(s===-1)return o;let c=s+1;for(;c--&&!(e[c].pts<=i););return c=Math.max(c,0),o.splice(c,s-c+1),o},Mp=function(e,t){if(!e&&!t||!e&&t||e&&!t)return!1;if(e===t)return!0;let n=Object.keys(e).sort(),r=Object.keys(t).sort();if(n.length!==r.length)return!1;for(let i=0;i<n.length;i++){let a=n[i];if(a!==r[i]||e[a]!==t[a])return!1}return!0},Np=function(e,t,n){t||=[];let r=[],i=0;for(let a=0;a<t.length;a++){let o=t[a];if(e===o.timeline&&(r.push(a),i+=o.duration,i>n))return a}return r.length===0?0:r[r.length-1]},Pp=e=>typeof e==`number`&&isFinite(e),Fp=1/60,Ip=(e,t,n)=>e!==`main`||!t||!n?null:!n.hasAudio&&!n.hasVideo?`Neither audio nor video found in segment.`:t.hasVideo&&!n.hasVideo?`Only audio found in segment when we expected video. We can't switch to audio only from a stream that had video. To get rid of this message, please add codec information to the manifest.`:!t.hasVideo&&n.hasVideo?`Video found in segment when we expected only audio. We can't switch to a stream with video from an audio only stream. To get rid of this message, please add codec information to the manifest.`:null,Lp=(e,t,n)=>{let r=t-bf.BACK_BUFFER_LENGTH;e.length&&(r=Math.max(r,e.start(0)));let i=t-n;return Math.min(i,r)},Rp=e=>{let{startOfSegment:t,duration:n,segment:r,part:i,playlist:{mediaSequence:a,id:o,segments:s=[]},mediaIndex:c,partIndex:l,timeline:u}=e,d=s.length-1,f=`mediaIndex/partIndex increment`;e.getMediaInfoForTime?f=`getMediaInfoForTime (${e.getMediaInfoForTime})`:e.isSyncRequest&&(f=`getSyncSegmentCandidate (isSyncRequest)`),e.independent&&(f+=` with independent ${e.independent}`);let p=typeof l==`number`,m=e.segment.uri?`segment`:`pre-segment`,h=p?Bu({preloadSegment:r})-1:0;return`${m} [${a+c}/${a+d}]`+(p?` part [${l}/${h}]`:``)+` segment start/end [${r.start} => ${r.end}]`+(p?` part start/end [${i.start} => ${i.end}]`:``)+` startOfSegment [${t}] duration [${n}] timeline [${u}] selected by [${f}] playlist [${o}]`},zp=e=>`${e}TimingInfo`,Bp=({segmentTimeline:e,currentTimeline:t,startOfSegment:n,buffered:r,overrideCheck:i})=>!i&&e===t?null:e<t?n:r.length?r.end(r.length-1):n,Vp=({timelineChangeController:e,currentTimeline:t,segmentTimeline:n,loaderType:r,audioDisabled:i})=>{if(t===n)return!1;if(r===`audio`){let t=e.lastTimelineChange({type:`main`});return!t||t.to!==n}if(r===`main`&&i){let t=e.pendingTimelineChange({type:`audio`});return!(t&&t.to===n)}return!1},Hp=e=>{if(!e)return!1;let t=e.pendingTimelineChange({type:`audio`}),n=e.pendingTimelineChange({type:`main`}),r=t&&n,i=r&&t.to!==n.to;return!!(r&&t.from!==-1&&n.from!==-1&&i)},Up=e=>{let t=e.timelineChangeController_.pendingTimelineChange({type:`audio`}),n=e.timelineChangeController_.pendingTimelineChange({type:`main`});return t&&n&&t.to<n.to},Wp=e=>{let t=e.pendingSegment_;if(t&&Vp({timelineChangeController:e.timelineChangeController_,currentTimeline:e.currentTimeline_,segmentTimeline:t.timeline,loaderType:e.loaderType_,audioDisabled:e.audioDisabled_})&&Hp(e.timelineChangeController_)){if(Up(e)){e.timelineChangeController_.trigger(`audioTimelineBehind`);return}e.timelineChangeController_.trigger(`fixBadTimelineChange`)}},Gp=e=>{let t=0;return[`video`,`audio`].forEach(function(n){let r=e[`${n}TimingInfo`];if(!r)return;let{start:i,end:a}=r,o;typeof i==`bigint`||typeof a==`bigint`?o=x.BigInt(a)-x.BigInt(i):typeof i==`number`&&typeof a==`number`&&(o=a-i),o!==void 0&&o>t&&(t=o)}),typeof t==`bigint`&&t<2**53-1&&(t=Number(t)),t},Kp=({segmentDuration:e,maxDuration:t})=>e?Math.round(e)>t+wu:!1,qp=(e,t)=>{if(t!==`hls`)return null;let n=Gp({audioTimingInfo:e.audioTimingInfo,videoTimingInfo:e.videoTimingInfo});if(!n)return null;let r=e.playlist.targetDuration,i=Kp({segmentDuration:n,maxDuration:r*2}),a=Kp({segmentDuration:n,maxDuration:r}),o=`Segment with index ${e.mediaIndex} from playlist ${e.playlist.id} has a duration of ${n} when the reported duration is ${e.duration} and the target duration is ${r}. For HLS content, a duration in excess of the target duration may result in playback issues. See the HLS specification section on EXT-X-TARGETDURATION for more details: https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.3.1`;return i||a?{severity:i?`warn`:`info`,message:o}:null},Jp=({type:e,segment:t})=>{if(!t)return;let n=!!(t.key||t.map&&t.map.ke),r=!(!t.map||t.map.bytes),i=t.startOfSegment===void 0?t.start:t.startOfSegment;return{type:e||t.type,uri:t.resolvedUri||t.uri,start:i,duration:t.duration,isEncrypted:n,isMediaInitialization:r}};class Yp extends Z.EventTarget{constructor(e,t={}){if(super(),!e)throw TypeError(`Initialization settings are required`);if(typeof e.currentTime!=`function`)throw TypeError(`No currentTime getter specified`);if(!e.mediaSource)throw TypeError(`No MediaSource specified`);this.bandwidth=e.bandwidth,this.throughput={rate:0,count:0},this.roundTrip=NaN,this.resetStats_(),this.mediaIndex=null,this.partIndex=null,this.hasPlayed_=e.hasPlayed,this.currentTime_=e.currentTime,this.seekable_=e.seekable,this.seeking_=e.seeking,this.duration_=e.duration,this.mediaSource_=e.mediaSource,this.vhs_=e.vhs,this.loaderType_=e.loaderType,this.currentMediaInfo_=void 0,this.startingMediaInfo_=void 0,this.segmentMetadataTrack_=e.segmentMetadataTrack,this.goalBufferLength_=e.goalBufferLength,this.sourceType_=e.sourceType,this.sourceUpdater_=e.sourceUpdater,this.inbandTextTracks_=e.inbandTextTracks,this.state_=`INIT`,this.timelineChangeController_=e.timelineChangeController,this.shouldSaveSegmentTimingInfo_=!0,this.parse708captions_=e.parse708captions,this.useDtsForTimestampOffset_=e.useDtsForTimestampOffset,this.captionServices_=e.captionServices,this.exactManifestTimings=e.exactManifestTimings,this.addMetadataToTextTrack=e.addMetadataToTextTrack,this.checkBufferTimeout_=null,this.error_=void 0,this.currentTimeline_=-1,this.shouldForceTimestampOffsetAfterResync_=!1,this.pendingSegment_=null,this.xhrOptions_=null,this.pendingSegments_=[],this.audioDisabled_=!1,this.isPendingTimestampOffset_=!1,this.gopBuffer_=[],this.timeMapping_=0,this.safeAppend_=!1,this.appendInitSegment_={audio:!0,video:!0},this.playlistOfLastInitSegment_={audio:null,video:null},this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_={id3:[],caption:[]},this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=null,this.activeInitSegmentId_=null,this.initSegments_={},this.cacheEncryptionKeys_=e.cacheEncryptionKeys,this.keyCache_={},this.decrypter_=e.decrypter,this.syncController_=e.syncController,this.syncPoint_={segmentIndex:0,time:0},this.transmuxer_=this.createTransmuxer_(),this.triggerSyncInfoUpdate_=()=>this.trigger(`syncinfoupdate`),this.syncController_.on(`syncinfoupdate`,this.triggerSyncInfoUpdate_),this.mediaSource_.addEventListener(`sourceopen`,()=>{this.isEndOfStream_()||(this.ended_=!1)}),this.fetchAtBuffer_=!1,this.logger_=xu(`SegmentLoader[${this.loaderType_}]`),Object.defineProperty(this,"state",{get(){return this.state_},set(e){e!==this.state_&&(this.logger_(`${this.state_} -> ${e}`),this.state_=e,this.trigger(`statechange`))}}),this.sourceUpdater_.on(`ready`,()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)}),this.sourceUpdater_.on(`codecschange`,e=>{this.trigger(R({type:`codecschange`},e))}),this.loaderType_===`main`&&this.timelineChangeController_.on(`pendingtimelinechange`,()=>{this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)}),this.loaderType_===`audio`&&this.timelineChangeController_.on(`timelinechange`,e=>{this.trigger(R({type:`timelinechange`},e)),this.hasEnoughInfoToLoad_()?this.processLoadQueue_():Wp(this),this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)})}get mediaSequenceSync_(){return this.syncController_.getMediaSequenceSync(this.loaderType_)}createTransmuxer_(){return Rf.createTransmuxer({remux:!1,alignGopsAtEnd:this.safeAppend_,keepOriginalTimestamps:!0,parse708captions:this.parse708captions_,captionServices:this.captionServices_})}resetStats_(){this.mediaBytesTransferred=0,this.mediaRequests=0,this.mediaRequestsAborted=0,this.mediaRequestsTimedout=0,this.mediaRequestsErrored=0,this.mediaTransferDuration=0,this.mediaSecondsLoaded=0,this.mediaAppends=0}dispose(){this.trigger(`dispose`),this.state=`DISPOSED`,this.pause(),this.abort_(),this.transmuxer_&&this.transmuxer_.terminate(),this.resetStats_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.syncController_&&this.triggerSyncInfoUpdate_&&this.syncController_.off(`syncinfoupdate`,this.triggerSyncInfoUpdate_),this.off()}setAudio(e){this.audioDisabled_=!e,e?this.appendInitSegment_.audio=!0:this.sourceUpdater_.removeAudio(0,this.duration_())}abort(){this.state===`WAITING`?(this.abort_(),this.state=`READY`,this.paused()||this.monitorBuffer_()):(this.pendingSegment_&&=null,this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_))}abort_(){this.pendingSegment_&&this.pendingSegment_.abortRequests&&this.pendingSegment_.abortRequests(),this.pendingSegment_=null,this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.timelineChangeController_.clearPendingTimelineChange(this.loaderType_),this.waitingOnRemove_=!1,x.clearTimeout(this.quotaExceededErrorRetryTimeout_),this.quotaExceededErrorRetryTimeout_=null}checkForAbort_(e){return this.state===`APPENDING`&&!this.pendingSegment_?(this.state=`READY`,!0):!this.pendingSegment_||this.pendingSegment_.requestId!==e}error(e){return e!==void 0&&(this.logger_(`error occurred:`,e),this.error_=e),this.pendingSegment_=null,this.error_}endOfStream(){this.ended_=!0,this.transmuxer_&&Rf.reset(this.transmuxer_),this.gopBuffer_.length=0,this.pause(),this.trigger(`ended`)}buffered_(){let e=this.getMediaInfo_();if(!this.sourceUpdater_||!e)return Su();if(this.loaderType_===`main`){let{hasAudio:t,hasVideo:n,isMuxed:r}=e;if(n&&t&&!this.audioDisabled_&&!r)return this.sourceUpdater_.buffered();if(n)return this.sourceUpdater_.videoBuffered()}return this.sourceUpdater_.audioBuffered()}initSegmentForMap(e,t=!1){if(!e)return null;let n=Jd(e),r=this.initSegments_[n];return t&&!r&&e.bytes&&(this.initSegments_[n]=r={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:e.bytes,tracks:e.tracks,timescales:e.timescales}),r||e}segmentKey(e,t=!1){if(!e)return null;let n=Yd(e),r=this.keyCache_[n];this.cacheEncryptionKeys_&&t&&!r&&e.bytes&&(this.keyCache_[n]=r={resolvedUri:e.resolvedUri,bytes:e.bytes});let i={resolvedUri:(r||e).resolvedUri};return r&&(i.bytes=r.bytes),i}couldBeginLoading_(){return this.playlist_&&!this.paused()}load(){if(this.monitorBuffer_(),this.playlist_){if(this.state===`INIT`&&this.couldBeginLoading_())return this.init_();!this.couldBeginLoading_()||this.state!==`READY`&&this.state!==`INIT`||(this.state=`READY`)}}init_(){return this.state=`READY`,this.resetEverything(),this.monitorBuffer_()}playlist(e,t={}){if(!e||this.playlist_&&this.playlist_.endList&&e.endList&&this.playlist_.uri===e.uri)return;let n=this.playlist_,r=this.pendingSegment_;this.playlist_=e,this.xhrOptions_=t,this.state===`INIT`&&(e.syncInfo={mediaSequence:e.mediaSequence,time:0},this.loaderType_===`main`&&this.syncController_.setDateTimeMappingForStart(e));let i=null;if(n&&(n.id?i=n.id:n.uri&&(i=n.uri)),this.logger_(`playlist update [${i} => ${e.id||e.uri}]`),this.mediaSequenceSync_&&(this.mediaSequenceSync_.update(e,this.currentTime_()),this.logger_(`Playlist update:
188
188
  currentTime: ${this.currentTime_()}
189
189
  bufferedEnd: ${Fu(this.buffered_())}
190
190
  `,this.mediaSequenceSync_.diagnostics)),this.trigger(`syncinfoupdate`),this.state===`INIT`&&this.couldBeginLoading_())return this.init_();if(!n||n.uri!==e.uri){this.mediaIndex!==null&&(!e.endList&&typeof e.partTargetDuration==`number`?this.resetLoader():this.resyncLoader()),this.currentMediaInfo_=void 0,this.trigger(`playlistupdate`);return}let a=e.mediaSequence-n.mediaSequence;if(this.logger_(`live window shift [${a}]`),this.mediaIndex!==null){if(this.mediaIndex-=a,this.mediaIndex<0)this.mediaIndex=null,this.partIndex=null;else{let e=this.playlist_.segments[this.mediaIndex];if(this.partIndex&&(!e.parts||!e.parts.length||!e.parts[this.partIndex])){let e=this.mediaIndex;this.logger_(`currently processing part (index ${this.partIndex}) no longer exists.`),this.resetLoader(),this.mediaIndex=e}}}r&&(r.mediaIndex-=a,r.mediaIndex<0?(r.mediaIndex=null,r.partIndex=null):(r.mediaIndex>=0&&(r.segment=e.segments[r.mediaIndex]),r.partIndex>=0&&r.segment.parts&&(r.part=r.segment.parts[r.partIndex]))),this.syncController_.saveExpiredSegmentInfo(n,e)}pause(){this.checkBufferTimeout_&&=(x.clearTimeout(this.checkBufferTimeout_),null)}paused(){return this.checkBufferTimeout_===null}resetEverything(e){this.ended_=!1,this.activeInitSegmentId_=null,this.appendInitSegment_={audio:!0,video:!0},this.resetLoader(),this.remove(0,1/0,e),this.transmuxer_&&(this.transmuxer_.postMessage({action:`clearAllMp4Captions`}),this.transmuxer_.postMessage({action:`reset`}))}resetLoader(){this.fetchAtBuffer_=!1,this.mediaSequenceSync_&&this.mediaSequenceSync_.resetAppendedStatus(),this.resyncLoader()}resyncLoader(){this.transmuxer_&&Rf.reset(this.transmuxer_),this.mediaIndex=null,this.partIndex=null,this.syncPoint_=null,this.isPendingTimestampOffset_=!1;let e=this.currentMediaInfo_&&this.currentMediaInfo_.isFmp4;this.sourceType_===`hls`&&!e&&(this.shouldForceTimestampOffsetAfterResync_=!0),this.callQueue_=[],this.loadQueue_=[],this.metadataQueue_.id3=[],this.metadataQueue_.caption=[],this.abort(),this.transmuxer_&&this.transmuxer_.postMessage({action:`clearParsedMp4Captions`})}remove(e,t,n=()=>{},r=!1){if(t===1/0&&(t=this.duration_()),t<=e){this.logger_("skipping remove because end ${end} is <= start ${start}");return}if(!this.sourceUpdater_||!this.getMediaInfo_()){this.logger_(`skipping remove because no source updater or starting media info`);return}let i=1,a=()=>{i--,i===0&&n()};(r||!this.audioDisabled_)&&(i++,this.sourceUpdater_.removeAudio(e,t,a)),(r||this.loaderType_===`main`)&&(this.gopBuffer_=jp(this.gopBuffer_,e,t,this.timeMapping_),i++,this.sourceUpdater_.removeVideo(e,t,a));for(let n in this.inbandTextTracks_)Dp(e,t,this.inbandTextTracks_[n]);Dp(e,t,this.segmentMetadataTrack_),a()}monitorBuffer_(){this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),1)}monitorBufferTick_(){this.state===`READY`&&this.fillBuffer_(),this.checkBufferTimeout_&&x.clearTimeout(this.checkBufferTimeout_),this.checkBufferTimeout_=x.setTimeout(this.monitorBufferTick_.bind(this),500)}fillBuffer_(){if(this.sourceUpdater_.updating())return;let e=this.chooseNextRequest_();if(!e)return;let t={segmentInfo:Jp({type:this.loaderType_,segment:e})};this.trigger({type:`segmentselected`,metadata:t}),typeof e.timestampOffset==`number`&&(this.isPendingTimestampOffset_=!1,this.timelineChangeController_.pendingTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline})),this.loadSegment_(e)}isEndOfStream_(e=this.mediaIndex,t=this.playlist_,n=this.partIndex){if(!t||!this.mediaSource_)return!1;let r=typeof e==`number`&&t.segments[e],i=e+1===t.segments.length,a=!r||!r.parts||n+1===r.parts.length;return t.endList&&this.mediaSource_.readyState===`open`&&i&&a}chooseNextRequest_(){let e=this.buffered_(),t=Fu(e)||0,n=Iu(e,this.currentTime_()),r=!this.hasPlayed_()&&n>=1,i=n>=this.goalBufferLength_(),a=this.playlist_.segments;if(!a.length||r||i)return null;this.syncPoint_=this.syncPoint_||this.syncController_.getSyncPoint(this.playlist_,this.duration_(),this.currentTimeline_,this.currentTime_(),this.loaderType_);let o={partIndex:null,mediaIndex:null,startOfSegment:null,playlist:this.playlist_,isSyncRequest:!this.syncPoint_};if(o.isSyncRequest)o.mediaIndex=Np(this.currentTimeline_,a,t),this.logger_(`choose next request. Can not find sync point. Fallback to media Index: ${o.mediaIndex}`);else if(this.mediaIndex!==null){let e=a[this.mediaIndex],n=typeof this.partIndex==`number`?this.partIndex:-1;o.startOfSegment=e.end?e.end:t,e.parts&&e.parts[n+1]?(o.mediaIndex=this.mediaIndex,o.partIndex=n+1):o.mediaIndex=this.mediaIndex+1}else{let e,n,r,i=this.fetchAtBuffer_?t:this.currentTime_();if(this.mediaSequenceSync_&&this.logger_(`chooseNextRequest_ request after Quality Switch:
@@ -192,9 +192,9 @@ For TargetTime: ${i}.
192
192
  CurrentTime: ${this.currentTime_()}
193
193
  BufferedEnd: ${t}
194
194
  Fetch At Buffer: ${this.fetchAtBuffer_}
195
- `,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){let t=this.getSyncInfoFromMediaSequenceSync_(i);if(!t){let e=`No sync info found while using media sequence sync`;return this.error({message:e,metadata:{errorType:Z.Error.StreamingFailedToSelectNextSegment,error:Error(e)}}),this.logger_(`chooseNextRequest_ - no sync info found using media sequence sync`),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${t.start} --> ${t.end})`),e=t.segmentIndex,n=t.partIndex,r=t.start}else{this.logger_(`chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.`);let t=sd.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:i,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});e=t.segmentIndex,n=t.partIndex,r=t.startTime}o.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${i}`:`currentTime ${i}`,o.mediaIndex=e,o.startOfSegment=r,o.partIndex=n,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${o.mediaIndex} `)}let s=a[o.mediaIndex],c=s&&typeof o.partIndex==`number`&&s.parts&&s.parts[o.partIndex];if(!s||typeof o.partIndex==`number`&&!c)return null;typeof o.partIndex!=`number`&&s.parts&&(o.partIndex=0,c=s.parts[0]);let l=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!n&&c&&!l&&!c.independent){if(o.partIndex===0){let e=a[o.mediaIndex-1],t=e.parts&&e.parts.length&&e.parts[e.parts.length-1];t&&t.independent&&(--o.mediaIndex,o.partIndex=e.parts.length-1,o.independent=`previous segment`)}else s.parts[o.partIndex-1].independent&&(--o.partIndex,o.independent=`previous part`)}let u=this.mediaSource_&&this.mediaSource_.readyState===`ended`;return o.mediaIndex>=a.length-1&&u&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,o.forceTimestampOffset=!0,this.logger_(`choose next request. Force timestamp offset after loader resync`)),this.generateSegmentInfo_(o))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;let t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);let n=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!n)return null;if(!n.isAppended)return n;let r=this.mediaSequenceSync_.getSyncInfoForTime(n.end);return r?(r.isAppended&&this.logger_(`getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!`),r):null}generateSegmentInfo_(e){let{independent:t,playlist:n,mediaIndex:r,startOfSegment:i,isSyncRequest:a,partIndex:o,forceTimestampOffset:s,getMediaInfoForTime:c}=e,l=n.segments[r],u=typeof o==`number`&&l.parts[o],d={requestId:`segment-loader-`+Math.random(),uri:u&&u.resolvedUri||l.resolvedUri,mediaIndex:r,partIndex:u?o:null,isSyncRequest:a,startOfSegment:i,playlist:n,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:l.timeline,duration:u&&u.duration||l.duration,segment:l,part:u,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:c,independent:t},f=s===void 0?this.isPendingTimestampOffset_:s;d.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:l.timeline,currentTimeline:this.currentTimeline_,startOfSegment:i,buffered:this.buffered_(),overrideCheck:f});let p=Fu(this.sourceUpdater_.audioBuffered());return typeof p==`number`&&(d.audioAppendStart=p-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(d.gopsToAlignWith=kp(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),d}timestampOffsetForSegment_(e){return Bp(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;let t=this.currentTime_(),n=e.bandwidth,r=this.pendingSegment_.duration,i=sd.estimateSegmentRequestTime(r,n,this.playlist_,e.bytesReceived),a=Mu(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(i<=a)return;let o=hp({main:this.vhs_.playlists.main,currentTime:t,bandwidth:n,duration:this.duration_(),segmentDuration:r,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!o)return;let s=i-a-o.rebufferingImpact,c=.5;a<=wu&&(c=1),!(!o.playlist||o.playlist.uri===this.playlist_.uri||s<c)&&(this.bandwidth=o.playlist.attributes.BANDWIDTH*bf.BANDWIDTH_VARIANCE+1,this.trigger(`earlyabort`))}handleAbort_(e){this.logger_(`Aborting ${Rp(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),!this.checkForAbort_(t.requestId)&&this.trigger(`progress`)}handleTrackInfo_(e,t){let{hasAudio:n,hasVideo:r}=t,i={segmentInfo:Jp({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:n,hasVideo:r}};this.trigger({type:`segmenttransmuxingtrackinfoavailable`,metadata:i}),this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||this.checkForIllegalMediaSwitch(t)||(t||={},Mp(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_(`trackinfo update`,t),this.trigger(`trackinfo`)),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)))}handleTimingInfo_(e,t,n,r){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;let i=this.pendingSegment_,a=zp(t);i[a]=i[a]||{},i[a][n]=r,this.logger_(`timinginfo: ${t} - ${n} - ${r}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_(`SegmentLoader received no captions from a caption event`);return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}let n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r={};t.forEach(e=>{r[e.stream]=r[e.stream]||{startTime:1/0,captions:[],endTime:0};let t=r[e.stream];t.startTime=Math.min(t.startTime,e.startTime+n),t.endTime=Math.max(t.endTime,e.endTime+n),t.captions.push(e)}),Object.keys(r).forEach(e=>{let{startTime:t,endTime:i,captions:a}=r[e],o=this.inbandTextTracks_;this.logger_(`adding cues from ${t} -> ${i} for ${e}`),yp(o,this.vhs_.tech_,e),Dp(t,i,o[e]),bp({captionArray:a,inbandTextTracks:o,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:`clearParsedMp4Captions`})}handleId3_(e,t,n){this.earlyAbortWhenNeeded_(e.stats),!this.checkForAbort_(e.requestId)&&(this.pendingSegment_.hasAppendedData_?this.addMetadataToTextTrack(n,t,this.duration_()):this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,n)))}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){let e=this.callQueue_;this.callQueue_=[],e.forEach(e=>e())}processLoadQueue_(){let e=this.loadQueue_;this.loadQueue_=[],e.forEach(e=>e())}hasEnoughInfoToLoad_(){if(this.loaderType_!==`audio`)return!0;let e=this.pendingSegment_;return e?!this.getCurrentMediaInfo_()||!Vp({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;let e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;let{hasAudio:n,hasVideo:r,isMuxed:i}=t;return!(r&&!e.videoTimingInfo||n&&!this.audioDisabled_&&!i&&!e.audioTimingInfo||Vp({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){Wp(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}let n=this.pendingSegment_;if(this.setTimeMapping_(n.timeline),this.updateMediaSecondsLoaded_(n.part||n.segment),this.mediaSource_.readyState!==`closed`){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),n.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),n.isFmp4=e.isFmp4,n.timingInfo=n.timingInfo||{},n.isFmp4)this.trigger(`fmp4`),n.timingInfo.start=n[zp(t.type)].start;else{let e=this.getCurrentMediaInfo_(),t=this.loaderType_===`main`&&e&&e.hasVideo,r;t&&(r=n.videoTimingInfo.start),n.timingInfo.start=this.trueSegmentStart_({currentStart:n.timingInfo.start,playlist:n.playlist,mediaIndex:n.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:t,firstVideoFrameTimeForData:r,videoTimingInfo:n.videoTimingInfo,audioTimingInfo:n.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(n,t.type),this.updateSourceBufferTimestampOffset_(n),n.isSyncRequest){this.updateTimingInfoEnd_(n),this.syncController_.saveSegmentTimingInfo({segmentInfo:n,shouldSaveTimelineMapping:this.loaderType_===`main`});let e=this.chooseNextRequest_();if(e.mediaIndex!==n.mediaIndex||e.partIndex!==n.partIndex){this.logger_(`sync segment was incorrect, not appending`);return}this.logger_(`sync segment was correct, appending`)}n.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(n,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_===`main`&&typeof e.timestampOffset==`number`&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:n,playlist:r}){if(n){let e=Jd(n);if(this.activeInitSegmentId_===e)return null;t=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=e}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=r,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n},r){let i=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();i.length>1&&this.logger_(`On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: `+Nu(i).join(`, `)),a.length>1&&this.logger_(`On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: `+Nu(a).join(`, `));let o=i.length?i.start(0):0,s=i.length?i.end(i.length-1):0,c=a.length?a.start(0):0,l=a.length?a.end(a.length-1):0;if(s-o<=1&&l-c<=1){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${n.byteLength}, audio buffer: ${Nu(i).join(`, `)}, video buffer: ${Nu(a).join(`, `)}, `),this.error({message:`Quota exceeded error with append of a single segment of content`,excludeUntil:1/0}),this.trigger(`error`);return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:n}));let u=this.currentTime_()-1;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${u}`),this.remove(0,u,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in 1s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=x.setTimeout(()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, re-processing call queue`),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:n},r){r&&(r.code===22?this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n}):(this.logger_(`Received non QUOTA_EXCEEDED_ERR on append`,r),this.error({message:`${t} append of ${n.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:Z.Error.StreamingFailedToAppendSegment}}),this.trigger(`appenderror`)))}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:n,data:r,bytes:i}){if(!i){let e=[r],t=r.byteLength;n&&(e.unshift(n),t+=n.byteLength),i=_p({bytes:t,segments:e})}let a={segmentInfo:Jp({type:this.loaderType_,segment:e})};this.trigger({type:`segmentappendstart`,metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:i},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:i}))}handleSegmentTimingInfo_(e,t,n){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;let r=this.pendingSegment_.segment,i=`${e}TimingInfo`;r[i]||(r[i]={}),r[i].transmuxerPrependedSeconds=n.prependedContentDuration||0,r[i].transmuxedPresentationStart=n.start.presentation,r[i].transmuxedDecodeStart=n.start.decode,r[i].transmuxedPresentationEnd=n.end.presentation,r[i].transmuxedDecodeEnd=n.end.decode,r[i].baseMediaDecodeTime=n.baseMediaDecodeTime}appendData_(e,t){let{type:n,data:r}=t;if(!r||!r.byteLength||n===`audio`&&this.audioDisabled_)return;let i=this.getInitSegmentAndUpdateState_({type:n,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:n,initSegment:i,data:r})}loadSegment_(e){this.state=`WAITING`,this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset==`number`&&this.transmuxer_&&this.transmuxer_.postMessage({action:`clearAllMp4Captions`}),this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(e):(Wp(this),this.loadQueue_.push(()=>{let t=R({},e,{forceTimestampOffset:!0});R(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)}))}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:`reset`}),this.transmuxer_.postMessage({action:`setTimestampOffset`,timestampOffset:e.timestampOffset}));let t=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),r=this.mediaIndex!==null,i=e.timeline!==this.currentTimeline_&&e.timeline>0,a=n||r&&i;this.logger_(`Requesting
195
+ `,this.mediaSequenceSync_.diagnostics),this.mediaSequenceSync_&&this.mediaSequenceSync_.isReliable){let t=this.getSyncInfoFromMediaSequenceSync_(i);if(!t){let e=`No sync info found while using media sequence sync`;return this.error({message:e,metadata:{errorType:Z.Error.StreamingFailedToSelectNextSegment,error:Error(e)}}),this.logger_(`chooseNextRequest_ - no sync info found using media sequence sync`),null}this.logger_(`chooseNextRequest_ mediaSequence syncInfo (${t.start} --> ${t.end})`),e=t.segmentIndex,n=t.partIndex,r=t.start}else{this.logger_(`chooseNextRequest_ - fallback to a regular segment selection algorithm, based on a syncPoint.`);let t=sd.getMediaInfoForTime({exactManifestTimings:this.exactManifestTimings,playlist:this.playlist_,currentTime:i,startingPartIndex:this.syncPoint_.partIndex,startingSegmentIndex:this.syncPoint_.segmentIndex,startTime:this.syncPoint_.time});e=t.segmentIndex,n=t.partIndex,r=t.startTime}o.getMediaInfoForTime=this.fetchAtBuffer_?`bufferedEnd ${i}`:`currentTime ${i}`,o.mediaIndex=e,o.startOfSegment=r,o.partIndex=n,this.logger_(`choose next request. Playlist switched and we have a sync point. Media Index: ${o.mediaIndex} `)}let s=a[o.mediaIndex],c=s&&typeof o.partIndex==`number`&&s.parts&&s.parts[o.partIndex];if(!s||typeof o.partIndex==`number`&&!c)return null;typeof o.partIndex!=`number`&&s.parts&&(o.partIndex=0,c=s.parts[0]);let l=this.vhs_.playlists&&this.vhs_.playlists.main&&this.vhs_.playlists.main.independentSegments||this.playlist_.independentSegments;if(!n&&c&&!l&&!c.independent){if(o.partIndex===0){let e=a[o.mediaIndex-1],t=e.parts&&e.parts.length&&e.parts[e.parts.length-1];t&&t.independent&&(--o.mediaIndex,o.partIndex=e.parts.length-1,o.independent=`previous segment`)}else s.parts[o.partIndex-1].independent&&(--o.partIndex,o.independent=`previous part`)}let u=this.mediaSource_&&this.mediaSource_.readyState===`ended`;return o.mediaIndex>=a.length-1&&u&&!this.seeking_()?null:(this.shouldForceTimestampOffsetAfterResync_&&(this.shouldForceTimestampOffsetAfterResync_=!1,o.forceTimestampOffset=!0,this.logger_(`choose next request. Force timestamp offset after loader resync`)),this.generateSegmentInfo_(o))}getSyncInfoFromMediaSequenceSync_(e){if(!this.mediaSequenceSync_)return null;let t=Math.max(e,this.mediaSequenceSync_.start);e!==t&&this.logger_(`getSyncInfoFromMediaSequenceSync_. Pulled target time from ${e} to ${t}`);let n=this.mediaSequenceSync_.getSyncInfoForTime(t);if(!n)return null;if(!n.isAppended)return n;let r=this.mediaSequenceSync_.getSyncInfoForTime(n.end);return r?(r.isAppended&&this.logger_(`getSyncInfoFromMediaSequenceSync_: We encounter unexpected scenario where next media sequence sync info is also appended!`),r):null}generateSegmentInfo_(e){let{independent:t,playlist:n,mediaIndex:r,startOfSegment:i,isSyncRequest:a,partIndex:o,forceTimestampOffset:s,getMediaInfoForTime:c}=e,l=n.segments[r],u=typeof o==`number`&&l.parts[o],d={requestId:`segment-loader-`+Math.random(),uri:u&&u.resolvedUri||l.resolvedUri,mediaIndex:r,partIndex:u?o:null,isSyncRequest:a,startOfSegment:i,playlist:n,bytes:null,encryptedBytes:null,timestampOffset:null,timeline:l.timeline,duration:u&&u.duration||l.duration,segment:l,part:u,byteLength:0,transmuxer:this.transmuxer_,getMediaInfoForTime:c,independent:t},f=s===void 0?this.isPendingTimestampOffset_:s;d.timestampOffset=this.timestampOffsetForSegment_({segmentTimeline:l.timeline,currentTimeline:this.currentTimeline_,startOfSegment:i,buffered:this.buffered_(),overrideCheck:f});let p=Fu(this.sourceUpdater_.audioBuffered());return typeof p==`number`&&(d.audioAppendStart=p-this.sourceUpdater_.audioTimestampOffset()),this.sourceUpdater_.videoBuffered().length&&(d.gopsToAlignWith=kp(this.gopBuffer_,this.currentTime_()-this.sourceUpdater_.videoTimestampOffset(),this.timeMapping_)),d}timestampOffsetForSegment_(e){return Bp(e)}earlyAbortWhenNeeded_(e){if(this.vhs_.tech_.paused()||!this.xhrOptions_.timeout||!this.playlist_.attributes.BANDWIDTH||Date.now()-(e.firstBytesReceivedAt||Date.now())<1e3)return;let t=this.currentTime_(),n=e.bandwidth,r=this.pendingSegment_.duration,i=sd.estimateSegmentRequestTime(r,n,this.playlist_,e.bytesReceived),a=Mu(this.buffered_(),t,this.vhs_.tech_.playbackRate())-1;if(i<=a)return;let o=hp({main:this.vhs_.playlists.main,currentTime:t,bandwidth:n,duration:this.duration_(),segmentDuration:r,timeUntilRebuffer:a,currentTimeline:this.currentTimeline_,syncController:this.syncController_});if(!o)return;let s=i-a-o.rebufferingImpact,c=.5;a<=wu&&(c=1),!o.playlist||o.playlist.uri===this.playlist_.uri||s<c||(this.bandwidth=o.playlist.attributes.BANDWIDTH*bf.BANDWIDTH_VARIANCE+1,this.trigger(`earlyabort`))}handleAbort_(e){this.logger_(`Aborting ${Rp(e)}`),this.mediaRequestsAborted+=1}handleProgress_(e,t){this.earlyAbortWhenNeeded_(t.stats),this.checkForAbort_(t.requestId)||this.trigger(`progress`)}handleTrackInfo_(e,t){let{hasAudio:n,hasVideo:r}=t,i={segmentInfo:Jp({type:this.loaderType_,segment:e}),trackInfo:{hasAudio:n,hasVideo:r}};this.trigger({type:`segmenttransmuxingtrackinfoavailable`,metadata:i}),this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||this.checkForIllegalMediaSwitch(t)||(t||={},Mp(this.currentMediaInfo_,t)||(this.appendInitSegment_={audio:!0,video:!0},this.startingMediaInfo_=t,this.currentMediaInfo_=t,this.logger_(`trackinfo update`,t),this.trigger(`trackinfo`)),this.checkForAbort_(e.requestId)||(this.pendingSegment_.trackInfo=t,this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)))}handleTimingInfo_(e,t,n,r){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;let i=this.pendingSegment_,a=zp(t);i[a]=i[a]||{},i[a][n]=r,this.logger_(`timinginfo: ${t} - ${n} - ${r}`),this.hasEnoughInfoToAppend_()?this.processCallQueue_():Wp(this)}handleCaptions_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(t.length===0){this.logger_(`SegmentLoader received no captions from a caption event`);return}if(!this.pendingSegment_.hasAppendedData_){this.metadataQueue_.caption.push(this.handleCaptions_.bind(this,e,t));return}let n=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset(),r={};t.forEach(e=>{r[e.stream]=r[e.stream]||{startTime:1/0,captions:[],endTime:0};let t=r[e.stream];t.startTime=Math.min(t.startTime,e.startTime+n),t.endTime=Math.max(t.endTime,e.endTime+n),t.captions.push(e)}),Object.keys(r).forEach(e=>{let{startTime:t,endTime:i,captions:a}=r[e],o=this.inbandTextTracks_;this.logger_(`adding cues from ${t} -> ${i} for ${e}`),yp(o,this.vhs_.tech_,e),Dp(t,i,o[e]),bp({captionArray:a,inbandTextTracks:o,timestampOffset:n})}),this.transmuxer_&&this.transmuxer_.postMessage({action:`clearParsedMp4Captions`})}handleId3_(e,t,n){this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId)||(this.pendingSegment_.hasAppendedData_?this.addMetadataToTextTrack(n,t,this.duration_()):this.metadataQueue_.id3.push(this.handleId3_.bind(this,e,t,n)))}processMetadataQueue_(){this.metadataQueue_.id3.forEach(e=>e()),this.metadataQueue_.caption.forEach(e=>e()),this.metadataQueue_.id3=[],this.metadataQueue_.caption=[]}processCallQueue_(){let e=this.callQueue_;this.callQueue_=[],e.forEach(e=>e())}processLoadQueue_(){let e=this.loadQueue_;this.loadQueue_=[],e.forEach(e=>e())}hasEnoughInfoToLoad_(){if(this.loaderType_!==`audio`)return!0;let e=this.pendingSegment_;return e?!this.getCurrentMediaInfo_()||!Vp({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}):!1}getCurrentMediaInfo_(e=this.pendingSegment_){return e&&e.trackInfo||this.currentMediaInfo_}getMediaInfo_(e=this.pendingSegment_){return this.getCurrentMediaInfo_(e)||this.startingMediaInfo_}getPendingSegmentPlaylist(){return this.pendingSegment_?this.pendingSegment_.playlist:null}hasEnoughInfoToAppend_(){if(!this.sourceUpdater_.ready()||this.waitingOnRemove_||this.quotaExceededErrorRetryTimeout_)return!1;let e=this.pendingSegment_,t=this.getCurrentMediaInfo_();if(!e||!t)return!1;let{hasAudio:n,hasVideo:r,isMuxed:i}=t;return!(r&&!e.videoTimingInfo||n&&!this.audioDisabled_&&!i&&!e.audioTimingInfo||Vp({timelineChangeController:this.timelineChangeController_,currentTimeline:this.currentTimeline_,segmentTimeline:e.timeline,loaderType:this.loaderType_,audioDisabled:this.audioDisabled_}))}handleData_(e,t){if(this.earlyAbortWhenNeeded_(e.stats),this.checkForAbort_(e.requestId))return;if(this.callQueue_.length||!this.hasEnoughInfoToAppend_()){Wp(this),this.callQueue_.push(this.handleData_.bind(this,e,t));return}let n=this.pendingSegment_;if(this.setTimeMapping_(n.timeline),this.updateMediaSecondsLoaded_(n.part||n.segment),this.mediaSource_.readyState!==`closed`){if(e.map&&(e.map=this.initSegmentForMap(e.map,!0),n.segment.map=e.map),e.key&&this.segmentKey(e.key,!0),n.isFmp4=e.isFmp4,n.timingInfo=n.timingInfo||{},n.isFmp4)this.trigger(`fmp4`),n.timingInfo.start=n[zp(t.type)].start;else{let e=this.getCurrentMediaInfo_(),t=this.loaderType_===`main`&&e&&e.hasVideo,r;t&&(r=n.videoTimingInfo.start),n.timingInfo.start=this.trueSegmentStart_({currentStart:n.timingInfo.start,playlist:n.playlist,mediaIndex:n.mediaIndex,currentVideoTimestampOffset:this.sourceUpdater_.videoTimestampOffset(),useVideoTimingInfo:t,firstVideoFrameTimeForData:r,videoTimingInfo:n.videoTimingInfo,audioTimingInfo:n.audioTimingInfo})}if(this.updateAppendInitSegmentStatus(n,t.type),this.updateSourceBufferTimestampOffset_(n),n.isSyncRequest){this.updateTimingInfoEnd_(n),this.syncController_.saveSegmentTimingInfo({segmentInfo:n,shouldSaveTimelineMapping:this.loaderType_===`main`});let e=this.chooseNextRequest_();if(e.mediaIndex!==n.mediaIndex||e.partIndex!==n.partIndex){this.logger_(`sync segment was incorrect, not appending`);return}this.logger_(`sync segment was correct, appending`)}n.hasAppendedData_=!0,this.processMetadataQueue_(),this.appendData_(n,t)}}updateAppendInitSegmentStatus(e,t){this.loaderType_===`main`&&typeof e.timestampOffset==`number`&&!e.changedTimestampOffset&&(this.appendInitSegment_={audio:!0,video:!0}),this.playlistOfLastInitSegment_[t]!==e.playlist&&(this.appendInitSegment_[t]=!0)}getInitSegmentAndUpdateState_({type:e,initSegment:t,map:n,playlist:r}){if(n){let e=Jd(n);if(this.activeInitSegmentId_===e)return null;t=this.initSegmentForMap(n,!0).bytes,this.activeInitSegmentId_=e}return t&&this.appendInitSegment_[e]?(this.playlistOfLastInitSegment_[e]=r,this.appendInitSegment_[e]=!1,this.activeInitSegmentId_=null,t):null}handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n},r){let i=this.sourceUpdater_.audioBuffered(),a=this.sourceUpdater_.videoBuffered();i.length>1&&this.logger_(`On QUOTA_EXCEEDED_ERR, found gaps in the audio buffer: `+Nu(i).join(`, `)),a.length>1&&this.logger_(`On QUOTA_EXCEEDED_ERR, found gaps in the video buffer: `+Nu(a).join(`, `));let o=i.length?i.start(0):0,s=i.length?i.end(i.length-1):0,c=a.length?a.start(0):0,l=a.length?a.end(a.length-1):0;if(s-o<=1&&l-c<=1){this.logger_(`On QUOTA_EXCEEDED_ERR, single segment too large to append to buffer, triggering an error. Appended byte length: ${n.byteLength}, audio buffer: ${Nu(i).join(`, `)}, video buffer: ${Nu(a).join(`, `)}, `),this.error({message:`Quota exceeded error with append of a single segment of content`,excludeUntil:1/0}),this.trigger(`error`);return}this.waitingOnRemove_=!0,this.callQueue_.push(this.appendToSourceBuffer_.bind(this,{segmentInfo:e,type:t,bytes:n}));let u=this.currentTime_()-1;this.logger_(`On QUOTA_EXCEEDED_ERR, removing audio/video from 0 to ${u}`),this.remove(0,u,()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, retrying append in 1s`),this.waitingOnRemove_=!1,this.quotaExceededErrorRetryTimeout_=x.setTimeout(()=>{this.logger_(`On QUOTA_EXCEEDED_ERR, re-processing call queue`),this.quotaExceededErrorRetryTimeout_=null,this.processCallQueue_()},1e3)},!0)}handleAppendError_({segmentInfo:e,type:t,bytes:n},r){r&&(r.code===22?this.handleQuotaExceededError_({segmentInfo:e,type:t,bytes:n}):(this.logger_(`Received non QUOTA_EXCEEDED_ERR on append`,r),this.error({message:`${t} append of ${n.length}b failed for segment #${e.mediaIndex} in playlist ${e.playlist.id}`,metadata:{errorType:Z.Error.StreamingFailedToAppendSegment}}),this.trigger(`appenderror`)))}appendToSourceBuffer_({segmentInfo:e,type:t,initSegment:n,data:r,bytes:i}){if(!i){let e=[r],t=r.byteLength;n&&(e.unshift(n),t+=n.byteLength),i=_p({bytes:t,segments:e})}let a={segmentInfo:Jp({type:this.loaderType_,segment:e})};this.trigger({type:`segmentappendstart`,metadata:a}),this.sourceUpdater_.appendBuffer({segmentInfo:e,type:t,bytes:i},this.handleAppendError_.bind(this,{segmentInfo:e,type:t,bytes:i}))}handleSegmentTimingInfo_(e,t,n){if(!this.pendingSegment_||t!==this.pendingSegment_.requestId)return;let r=this.pendingSegment_.segment,i=`${e}TimingInfo`;r[i]||(r[i]={}),r[i].transmuxerPrependedSeconds=n.prependedContentDuration||0,r[i].transmuxedPresentationStart=n.start.presentation,r[i].transmuxedDecodeStart=n.start.decode,r[i].transmuxedPresentationEnd=n.end.presentation,r[i].transmuxedDecodeEnd=n.end.decode,r[i].baseMediaDecodeTime=n.baseMediaDecodeTime}appendData_(e,t){let{type:n,data:r}=t;if(!r||!r.byteLength||n===`audio`&&this.audioDisabled_)return;let i=this.getInitSegmentAndUpdateState_({type:n,initSegment:t.initSegment,playlist:e.playlist,map:e.isFmp4?e.segment.map:null});this.appendToSourceBuffer_({segmentInfo:e,type:n,initSegment:i,data:r})}loadSegment_(e){this.state=`WAITING`,this.pendingSegment_=e,this.trimBackBuffer_(e),typeof e.timestampOffset==`number`&&this.transmuxer_&&this.transmuxer_.postMessage({action:`clearAllMp4Captions`}),this.hasEnoughInfoToLoad_()?this.updateTransmuxerAndRequestSegment_(e):(Wp(this),this.loadQueue_.push(()=>{let t=R({},e,{forceTimestampOffset:!0});R(e,this.generateSegmentInfo_(t)),this.isPendingTimestampOffset_=!1,this.updateTransmuxerAndRequestSegment_(e)}))}updateTransmuxerAndRequestSegment_(e){this.shouldUpdateTransmuxerTimestampOffset_(e.timestampOffset)&&(this.gopBuffer_.length=0,e.gopsToAlignWith=[],this.timeMapping_=0,this.transmuxer_.postMessage({action:`reset`}),this.transmuxer_.postMessage({action:`setTimestampOffset`,timestampOffset:e.timestampOffset}));let t=this.createSimplifiedSegmentObj_(e),n=this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex),r=this.mediaIndex!==null,i=e.timeline!==this.currentTimeline_&&e.timeline>0,a=n||r&&i;this.logger_(`Requesting
196
196
  ${vp(e.uri)}
197
- ${Rp(e)}`),t.map&&!t.map.bytes&&(this.logger_(`going to request init segment.`),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=ap({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,`video`,e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,`audio`,e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_(`received endedtimeline callback`)},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:t,level:n,stream:r})=>{this.logger_(`${Rp(e)} logged from transmuxer stream ${r} as a ${n}: ${t}`)},triggerSegmentEventFn:({type:e,segment:t,keyInfo:n,trackInfo:r,timingInfo:i})=>{let a={segmentInfo:Jp({segment:t})};n&&(a.keyInfo=n),r&&(a.trackInfo=r),i&&(a.timingInfo=i),this.trigger({type:e,metadata:a})}})}trimBackBuffer_(e){let t=Lp(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){let t=e.segment,n=e.part,r=e.segment.key||e.segment.map&&e.segment.map.key,i=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:n?n.resolvedUri:t.resolvedUri,byterange:n?n.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:r,isMediaInitialization:i},o=e.playlist.segments[e.mediaIndex-1];if(o&&o.timeline===t.timeline&&(o.videoTimingInfo?a.baseStartTime=o.videoTimingInfo.transmuxedDecodeEnd:o.audioTimingInfo&&(a.baseStartTime=o.audioTimingInfo.transmuxedDecodeEnd)),t.key){let n=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=n}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<Fp){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${Fp}`);return}let n={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:`bandwidthupdated`,metadata:n}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger(`bandwidthupdate`),this.trigger(`timeout`)}segmentRequestFinished_(e,t,n){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,n));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state=`READY`,e.code===Bf.ABORTED)return;if(this.pause(),e.code===Bf.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger(`error`);return}let r=this.pendingSegment_;this.saveBandwidthRelatedStats_(r.duration,t.stats),r.endOfAllRequests=t.endOfAllRequests,n.gopInfo&&(this.gopBuffer_=Ap(this.gopBuffer_,n.gopInfo,this.safeAppend_)),this.state=`APPENDING`,this.trigger(`appending`),this.waitForAppendsToComplete_(r)}setTimeMapping_(e){let t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start==`number`&&typeof e.end==`number`?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_===`main`&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:n,firstVideoFrameTimeForData:r,currentVideoTimestampOffset:i,useVideoTimingInfo:a,videoTimingInfo:o,audioTimingInfo:s}){if(e!==void 0)return e;if(!a)return s.start;let c=t.segments[n-1];return n===0||!c||c.start===void 0||c.end!==r+i?r:o.start}waitForAppendsToComplete_(e){let t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:`No starting media returned, likely due to an unsupported media format.`,playlistExclusionDuration:1/0}),this.trigger(`error`);return}let{hasAudio:n,hasVideo:r,isMuxed:i}=t,a=this.loaderType_===`main`&&r,o=!this.audioDisabled_&&n&&!i;e.waitingOnAppends=0,e.hasAppendedData_?(a&&e.waitingOnAppends++,o&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),o&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))):(!e.timingInfo&&typeof e.timestampOffset==`number`&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){let t=Ip(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger(`error`),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!=`number`||e.changedTimestampOffset||this.loaderType_!==`main`)return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger(`timestampoffset`)}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:n}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart==`number`?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart==`number`?t.transmuxedDecodeStart:n.start:n.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};let t=this.getMediaInfo_(),n=this.loaderType_===`main`&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end==`number`?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){let e={segmentInfo:Jp({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:`appendsdone`,metadata:e})}if(!this.pendingSegment_){this.state=`READY`,this.paused()||this.monitorBuffer_();return}let e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_===`main`});let t=qp(e,this.sourceType_);if(t&&(t.severity===`warn`?Z.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state=`READY`,e.isSyncRequest&&(this.trigger(`syncinfoupdate`),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${Rp(e)}`);return}this.logger_(`Appended ${Rp(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_===`main`&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:`audio`,from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger(`syncinfoupdate`);let n=e.segment,r=e.part,i=n.end&&this.currentTime_()-n.end>e.playlist.targetDuration*3,a=r&&r.end&&this.currentTime_()-r.end>e.playlist.partTargetDuration*3;i||a?(this.logger_(`bad ${i?`segment`:`part`} ${Rp(e)}`),this.resetEverything()):(this.mediaIndex!==null&&this.trigger(`bandwidthupdate`),this.trigger(`progress`),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger(`appended`),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_())}recordThroughput_(e){if(e.duration<Fp){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${Fp}`);return}let t=this.throughput.rate,n=Date.now()-e.endOfAllRequests+1,r=Math.floor(e.byteLength/n*8*1e3);this.throughput.rate+=(r-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;let t=e.segment,n=t.start,r=t.end;if(!Pp(n)||!Pp(r))return;Dp(n,r,this.segmentMetadataTrack_);let i=x.WebKitDataCue||x.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:n,end:r},o=new i(n,r,JSON.stringify(a));o.value=a,this.segmentMetadataTrack_.addCue(o)}}function Xp(){}const Zp=function(e){return typeof e==`string`?e.replace(/./,e=>e.toUpperCase()):e},Qp=[`video`,`audio`],$p=(e,t)=>{let n=t[`${e}Buffer`];return n&&n.updating||t.queuePending[e]},em=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(r.type===`mediaSource`)return null;if(r.type===e)return n}return null},tm=(e,t)=>{if(t.queue.length===0)return;let n=0,r=t.queue[n];if(r.type===`mediaSource`)!t.updating()&&t.mediaSource.readyState!==`closed`&&(t.queue.shift(),r.action(t),r.doneFn&&r.doneFn(),tm(`audio`,t),tm(`video`,t));else if(e!==`mediaSource`&&t.ready()&&t.mediaSource.readyState!==`closed`&&!$p(e,t)){if(r.type!==e){if(n=em(e,t.queue),n===null)return;r=t.queue[n]}t.queue.splice(n,1),t.queuePending[e]=r,r.action(e,t),!r.doneFn&&(t.queuePending[e]=null,tm(e,t))}},nm=(e,t)=>{let n=t[`${e}Buffer`],r=Zp(e);n&&(n.removeEventListener(`updateend`,t[`on${r}UpdateEnd_`]),n.removeEventListener(`error`,t[`on${r}Error_`]),t.codecs[e]=null,t[`${e}Buffer`]=null)},rm=(e,t)=>e&&t&&Array.prototype.indexOf.call(e.sourceBuffers,t)!==-1,im={appendBuffer:(e,t,n)=>(r,i)=>{let a=i[`${r}Buffer`];if(rm(i.mediaSource,a)){i.logger_(`Appending segment ${t.mediaIndex}'s ${e.length} bytes to ${r}Buffer`);try{a.appendBuffer(e)}catch(e){i.logger_(`Error with code ${e.code} `+(e.code===22?`(QUOTA_EXCEEDED_ERR) `:``)+`when appending segment ${t.mediaIndex} to ${r}Buffer`),i.queuePending[r]=null,n(e)}}},remove:(e,t)=>(n,r)=>{let i=r[`${n}Buffer`];if(rm(r.mediaSource,i)){r.logger_(`Removing ${e} to ${t} from ${n}Buffer`);try{i.remove(e,t)}catch{r.logger_(`Remove ${e} to ${t} from ${n}Buffer failed`)}}},timestampOffset:e=>(t,n)=>{let r=n[`${t}Buffer`];rm(n.mediaSource,r)&&(n.logger_(`Setting ${t}timestampOffset to ${e}`),r.timestampOffset=e)},callback:e=>(t,n)=>{e()},endOfStream:e=>t=>{if(t.mediaSource.readyState===`open`){t.logger_(`Calling mediaSource endOfStream(${e||``})`);try{t.mediaSource.endOfStream(e)}catch(e){Z.log.warn(`Failed to call media source endOfStream`,e)}}},duration:e=>t=>{t.logger_(`Setting mediaSource duration to ${e}`);try{t.mediaSource.duration=e}catch(e){Z.log.warn(`Failed to set media source duration`,e)}},abort:()=>(e,t)=>{if(t.mediaSource.readyState!==`open`)return;let n=t[`${e}Buffer`];if(rm(t.mediaSource,n)){t.logger_(`calling abort on ${e}Buffer`);try{n.abort()}catch(t){Z.log.warn(`Failed to abort on ${e}Buffer`,t)}}},addSourceBuffer:(e,t)=>n=>{let r=Zp(e),i=Ot(t);n.logger_(`Adding ${e}Buffer with codec ${t} to mediaSource`);let a=n.mediaSource.addSourceBuffer(i);a.addEventListener(`updateend`,n[`on${r}UpdateEnd_`]),a.addEventListener(`error`,n[`on${r}Error_`]),n.codecs[e]=t,n[`${e}Buffer`]=a},removeSourceBuffer:e=>t=>{let n=t[`${e}Buffer`];if(nm(e,t),rm(t.mediaSource,n)){t.logger_(`Removing ${e}Buffer with codec ${t.codecs[e]} from mediaSource`);try{t.mediaSource.removeSourceBuffer(n)}catch(t){Z.log.warn(`Failed to removeSourceBuffer ${e}Buffer`,t)}}},changeType:e=>(t,n)=>{let r=n[`${t}Buffer`],i=Ot(e);if(!rm(n.mediaSource,r))return;let a=e.substring(0,e.indexOf(`.`)),o=n.codecs[t];if(o.substring(0,o.indexOf(`.`))===a)return;let s={codecsChangeInfo:{from:o,to:e}};n.trigger({type:`codecschange`,metadata:s}),n.logger_(`changing ${t}Buffer codec from ${o} to ${e}`);try{r.changeType(i),n.codecs[t]=e}catch(e){s.errorType=Z.Error.StreamingCodecsChangeError,s.error=e,e.metadata=s,n.error_=e,n.trigger(`error`),Z.log.warn(`Failed to changeType on ${t}Buffer`,e)}}},am=({type:e,sourceUpdater:t,action:n,doneFn:r,name:i})=>{t.queue.push({type:e,action:n,doneFn:r,name:i}),tm(e,t)},om=(e,t)=>n=>{let r=Cu(t[`${e}Buffered`]());if(t.logger_(`received "updateend" event for ${e} Source Buffer: `,r),t.queuePending[e]){let n=t.queuePending[e].doneFn;t.queuePending[e]=null,n&&n(t[`${e}Error_`])}tm(e,t)};class sm extends Z.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>tm(`mediaSource`,this),this.mediaSource.addEventListener(`sourceopen`,this.sourceopenListener_),this.logger_=xu(`SourceUpdater`),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=om(`video`,this),this.onAudioUpdateEnd_=om(`audio`,this),this.onVideoError_=e=>{this.videoError_=e},this.onAudioError_=e=>{this.audioError_=e},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger(`createdsourcebuffers`),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger(`ready`))}addSourceBuffer(e,t){am({type:`mediaSource`,sourceUpdater:this,action:im.addSourceBuffer(e,t),name:`addSourceBuffer`})}abort(e){am({type:e,sourceUpdater:this,action:im.abort(),name:`abort`})}removeSourceBuffer(e){this.canRemoveSourceBuffer()?am({type:`mediaSource`,sourceUpdater:this,action:im.removeSourceBuffer(e),name:`removeSourceBuffer`}):Z.log.error(`removeSourceBuffer is not supported!`)}canRemoveSourceBuffer(){return!Z.browser.IS_FIREFOX&&x.MediaSource&&x.MediaSource.prototype&&typeof x.MediaSource.prototype.removeSourceBuffer==`function`}static canChangeType(){return x.SourceBuffer&&x.SourceBuffer.prototype&&typeof x.SourceBuffer.prototype.changeType==`function`}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){this.canChangeType()?am({type:e,sourceUpdater:this,action:im.changeType(t),name:`changeType`}):Z.log.error(`changeType is not supported!`)}addOrChangeSourceBuffers(e){if(!e||typeof e!=`object`||Object.keys(e).length===0)throw Error(`Cannot addOrChangeSourceBuffers to undefined codecs`);Object.keys(e).forEach(t=>{let n=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,n);this.canChangeType()&&this.changeType(t,n)})}appendBuffer(e,t){let{segmentInfo:n,type:r,bytes:i}=e;if(this.processedAppend_=!0,r===`audio`&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${i.length} until video append`);return}let a=t;if(am({type:r,sourceUpdater:this,action:im.appendBuffer(i,n||{mediaIndex:-1},a),doneFn:t,name:`appendBuffer`}),r===`video`){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;let e=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${e.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,e.forEach(e=>{this.appendBuffer.apply(this,e)})}}audioBuffered(){return rm(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:Su()}videoBuffered(){return rm(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:Su()}buffered(){let e=rm(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=rm(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():Au(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=Xp){am({type:`mediaSource`,sourceUpdater:this,action:im.duration(e),name:`duration`,doneFn:t})}endOfStream(e=null,t=Xp){typeof e!=`string`&&(e=void 0),am({type:`mediaSource`,sourceUpdater:this,action:im.endOfStream(e),name:`endOfStream`,doneFn:t})}removeAudio(e,t,n=Xp){!this.audioBuffered().length||this.audioBuffered().end(0)===0?n():am({type:`audio`,sourceUpdater:this,action:im.remove(e,t),doneFn:n,name:`remove`})}removeVideo(e,t,n=Xp){!this.videoBuffered().length||this.videoBuffered().end(0)===0?n():am({type:`video`,sourceUpdater:this,action:im.remove(e,t),doneFn:n,name:`remove`})}updating(){return!!($p(`audio`,this)||$p(`video`,this))}audioTimestampOffset(e){return e!==void 0&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(am({type:`audio`,sourceUpdater:this,action:im.timestampOffset(e),name:`timestampOffset`}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return e!==void 0&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(am({type:`video`,sourceUpdater:this,action:im.timestampOffset(e),name:`timestampOffset`}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&am({type:`audio`,sourceUpdater:this,action:im.callback(e),name:`callback`})}videoQueueCallback(e){this.videoBuffer&&am({type:`video`,sourceUpdater:this,action:im.callback(e),name:`callback`})}dispose(){this.trigger(`dispose`),Qp.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>nm(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener(`sourceopen`,this.sourceopenListener_),this.off()}}const cm=e=>decodeURIComponent(escape(String.fromCharCode.apply(null,e))),lm=e=>{let t=new Uint8Array(e);return Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``)},um=new Uint8Array(`
197
+ ${Rp(e)}`),t.map&&!t.map.bytes&&(this.logger_(`going to request init segment.`),this.appendInitSegment_={video:!0,audio:!0}),e.abortRequests=ap({xhr:this.vhs_.xhr,xhrOptions:this.xhrOptions_,decryptionWorker:this.decrypter_,segment:t,abortFn:this.handleAbort_.bind(this,e),progressFn:this.handleProgress_.bind(this),trackInfoFn:this.handleTrackInfo_.bind(this),timingInfoFn:this.handleTimingInfo_.bind(this),videoSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,`video`,e.requestId),audioSegmentTimingInfoFn:this.handleSegmentTimingInfo_.bind(this,`audio`,e.requestId),captionsFn:this.handleCaptions_.bind(this),isEndOfTimeline:a,endedTimelineFn:()=>{this.logger_(`received endedtimeline callback`)},id3Fn:this.handleId3_.bind(this),dataFn:this.handleData_.bind(this),doneFn:this.segmentRequestFinished_.bind(this),onTransmuxerLog:({message:t,level:n,stream:r})=>{this.logger_(`${Rp(e)} logged from transmuxer stream ${r} as a ${n}: ${t}`)},triggerSegmentEventFn:({type:e,segment:t,keyInfo:n,trackInfo:r,timingInfo:i})=>{let a={segmentInfo:Jp({segment:t})};n&&(a.keyInfo=n),r&&(a.trackInfo=r),i&&(a.timingInfo=i),this.trigger({type:e,metadata:a})}})}trimBackBuffer_(e){let t=Lp(this.seekable_(),this.currentTime_(),this.playlist_.targetDuration||10);t>0&&this.remove(0,t)}createSimplifiedSegmentObj_(e){let t=e.segment,n=e.part,r=e.segment.key||e.segment.map&&e.segment.map.key,i=e.segment.map&&!e.segment.map.bytes,a={resolvedUri:n?n.resolvedUri:t.resolvedUri,byterange:n?n.byterange:t.byterange,requestId:e.requestId,transmuxer:e.transmuxer,audioAppendStart:e.audioAppendStart,gopsToAlignWith:e.gopsToAlignWith,part:e.part,type:this.loaderType_,start:e.startOfSegment,duration:e.duration,isEncrypted:r,isMediaInitialization:i},o=e.playlist.segments[e.mediaIndex-1];if(o&&o.timeline===t.timeline&&(o.videoTimingInfo?a.baseStartTime=o.videoTimingInfo.transmuxedDecodeEnd:o.audioTimingInfo&&(a.baseStartTime=o.audioTimingInfo.transmuxedDecodeEnd)),t.key){let n=t.key.iv||new Uint32Array([0,0,0,e.mediaIndex+e.playlist.mediaSequence]);a.key=this.segmentKey(t.key),a.key.iv=n}return t.map&&(a.map=this.initSegmentForMap(t.map)),a}saveTransferStats_(e){this.mediaRequests+=1,e&&(this.mediaBytesTransferred+=e.bytesReceived,this.mediaTransferDuration+=e.roundTripTime)}saveBandwidthRelatedStats_(e,t){if(this.pendingSegment_.byteLength=t.bytesReceived,e<Fp){this.logger_(`Ignoring segment's bandwidth because its duration of ${e} is less than the min to record ${Fp}`);return}let n={bandwidthInfo:{from:this.bandwidth,to:t.bandwidth}};this.trigger({type:`bandwidthupdated`,metadata:n}),this.bandwidth=t.bandwidth,this.roundTrip=t.roundTripTime}handleTimeout_(){this.mediaRequestsTimedout+=1,this.bandwidth=1,this.roundTrip=NaN,this.trigger(`bandwidthupdate`),this.trigger(`timeout`)}segmentRequestFinished_(e,t,n){if(this.callQueue_.length){this.callQueue_.push(this.segmentRequestFinished_.bind(this,e,t,n));return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_||t.requestId!==this.pendingSegment_.requestId)return;if(e){if(this.pendingSegment_=null,this.state=`READY`,e.code===Bf.ABORTED)return;if(this.pause(),e.code===Bf.TIMEOUT){this.handleTimeout_();return}this.mediaRequestsErrored+=1,this.error(e),this.trigger(`error`);return}let r=this.pendingSegment_;this.saveBandwidthRelatedStats_(r.duration,t.stats),r.endOfAllRequests=t.endOfAllRequests,n.gopInfo&&(this.gopBuffer_=Ap(this.gopBuffer_,n.gopInfo,this.safeAppend_)),this.state=`APPENDING`,this.trigger(`appending`),this.waitForAppendsToComplete_(r)}setTimeMapping_(e){let t=this.syncController_.mappingForTimeline(e);t!==null&&(this.timeMapping_=t)}updateMediaSecondsLoaded_(e){typeof e.start==`number`&&typeof e.end==`number`?this.mediaSecondsLoaded+=e.end-e.start:this.mediaSecondsLoaded+=e.duration}shouldUpdateTransmuxerTimestampOffset_(e){return e===null?!1:this.loaderType_===`main`&&e!==this.sourceUpdater_.videoTimestampOffset()||!this.audioDisabled_&&e!==this.sourceUpdater_.audioTimestampOffset()}trueSegmentStart_({currentStart:e,playlist:t,mediaIndex:n,firstVideoFrameTimeForData:r,currentVideoTimestampOffset:i,useVideoTimingInfo:a,videoTimingInfo:o,audioTimingInfo:s}){if(e!==void 0)return e;if(!a)return s.start;let c=t.segments[n-1];return n===0||!c||c.start===void 0||c.end!==r+i?r:o.start}waitForAppendsToComplete_(e){let t=this.getCurrentMediaInfo_(e);if(!t){this.error({message:`No starting media returned, likely due to an unsupported media format.`,playlistExclusionDuration:1/0}),this.trigger(`error`);return}let{hasAudio:n,hasVideo:r,isMuxed:i}=t,a=this.loaderType_===`main`&&r,o=!this.audioDisabled_&&n&&!i;e.waitingOnAppends=0,e.hasAppendedData_?(a&&e.waitingOnAppends++,o&&e.waitingOnAppends++,a&&this.sourceUpdater_.videoQueueCallback(this.checkAppendsDone_.bind(this,e)),o&&this.sourceUpdater_.audioQueueCallback(this.checkAppendsDone_.bind(this,e))):(!e.timingInfo&&typeof e.timestampOffset==`number`&&(this.isPendingTimestampOffset_=!0),e.timingInfo={start:0},e.waitingOnAppends++,this.isPendingTimestampOffset_||(this.updateSourceBufferTimestampOffset_(e),this.processMetadataQueue_()),this.checkAppendsDone_(e))}checkAppendsDone_(e){this.checkForAbort_(e.requestId)||(e.waitingOnAppends--,e.waitingOnAppends===0&&this.handleAppendsDone_())}checkForIllegalMediaSwitch(e){let t=Ip(this.loaderType_,this.getCurrentMediaInfo_(),e);return t?(this.error({message:t,playlistExclusionDuration:1/0}),this.trigger(`error`),!0):!1}updateSourceBufferTimestampOffset_(e){if(e.timestampOffset===null||typeof e.timingInfo.start!=`number`||e.changedTimestampOffset||this.loaderType_!==`main`)return;let t=!1;e.timestampOffset-=this.getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e.segment.videoTimingInfo,audioTimingInfo:e.segment.audioTimingInfo,timingInfo:e.timingInfo}),e.changedTimestampOffset=!0,e.timestampOffset!==this.sourceUpdater_.videoTimestampOffset()&&(this.sourceUpdater_.videoTimestampOffset(e.timestampOffset),t=!0),e.timestampOffset!==this.sourceUpdater_.audioTimestampOffset()&&(this.sourceUpdater_.audioTimestampOffset(e.timestampOffset),t=!0),t&&this.trigger(`timestampoffset`)}getSegmentStartTimeForTimestampOffsetCalculation_({videoTimingInfo:e,audioTimingInfo:t,timingInfo:n}){return this.useDtsForTimestampOffset_?e&&typeof e.transmuxedDecodeStart==`number`?e.transmuxedDecodeStart:t&&typeof t.transmuxedDecodeStart==`number`?t.transmuxedDecodeStart:n.start:n.start}updateTimingInfoEnd_(e){e.timingInfo=e.timingInfo||{};let t=this.getMediaInfo_(),n=this.loaderType_===`main`&&t&&t.hasVideo&&e.videoTimingInfo?e.videoTimingInfo:e.audioTimingInfo;n&&(e.timingInfo.end=typeof n.end==`number`?n.end:n.start+e.duration)}handleAppendsDone_(){if(this.pendingSegment_){let e={segmentInfo:Jp({type:this.loaderType_,segment:this.pendingSegment_})};this.trigger({type:`appendsdone`,metadata:e})}if(!this.pendingSegment_){this.state=`READY`,this.paused()||this.monitorBuffer_();return}let e=this.pendingSegment_;e.part&&e.part.syncInfo?e.part.syncInfo.markAppended():e.segment.syncInfo&&e.segment.syncInfo.markAppended(),this.updateTimingInfoEnd_(e),this.shouldSaveSegmentTimingInfo_&&this.syncController_.saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:this.loaderType_===`main`});let t=qp(e,this.sourceType_);if(t&&(t.severity===`warn`?Z.log.warn(t.message):this.logger_(t.message)),this.recordThroughput_(e),this.pendingSegment_=null,this.state=`READY`,e.isSyncRequest&&(this.trigger(`syncinfoupdate`),!e.hasAppendedData_)){this.logger_(`Throwing away un-appended sync request ${Rp(e)}`);return}this.logger_(`Appended ${Rp(e)}`),this.addSegmentMetadataCue_(e),this.fetchAtBuffer_=!0,this.currentTimeline_!==e.timeline&&(this.timelineChangeController_.lastTimelineChange({type:this.loaderType_,from:this.currentTimeline_,to:e.timeline}),this.loaderType_===`main`&&!this.audioDisabled_&&this.timelineChangeController_.lastTimelineChange({type:`audio`,from:this.currentTimeline_,to:e.timeline})),this.currentTimeline_=e.timeline,this.trigger(`syncinfoupdate`);let n=e.segment,r=e.part,i=n.end&&this.currentTime_()-n.end>e.playlist.targetDuration*3,a=r&&r.end&&this.currentTime_()-r.end>e.playlist.partTargetDuration*3;i||a?(this.logger_(`bad ${i?`segment`:`part`} ${Rp(e)}`),this.resetEverything()):(this.mediaIndex!==null&&this.trigger(`bandwidthupdate`),this.trigger(`progress`),this.mediaIndex=e.mediaIndex,this.partIndex=e.partIndex,this.isEndOfStream_(e.mediaIndex,e.playlist,e.partIndex)&&this.endOfStream(),this.trigger(`appended`),e.hasAppendedData_&&this.mediaAppends++,this.paused()||this.monitorBuffer_())}recordThroughput_(e){if(e.duration<Fp){this.logger_(`Ignoring segment's throughput because its duration of ${e.duration} is less than the min to record ${Fp}`);return}let t=this.throughput.rate,n=Date.now()-e.endOfAllRequests+1,r=Math.floor(e.byteLength/n*8*1e3);this.throughput.rate+=(r-t)/++this.throughput.count}addSegmentMetadataCue_(e){if(!this.segmentMetadataTrack_)return;let t=e.segment,n=t.start,r=t.end;if(!Pp(n)||!Pp(r))return;Dp(n,r,this.segmentMetadataTrack_);let i=x.WebKitDataCue||x.VTTCue,a={custom:t.custom,dateTimeObject:t.dateTimeObject,dateTimeString:t.dateTimeString,programDateTime:t.programDateTime,bandwidth:e.playlist.attributes.BANDWIDTH,resolution:e.playlist.attributes.RESOLUTION,codecs:e.playlist.attributes.CODECS,byteLength:e.byteLength,uri:e.uri,timeline:e.timeline,playlist:e.playlist.id,start:n,end:r},o=new i(n,r,JSON.stringify(a));o.value=a,this.segmentMetadataTrack_.addCue(o)}}function Xp(){}const Zp=function(e){return typeof e==`string`?e.replace(/./,e=>e.toUpperCase()):e},Qp=[`video`,`audio`],$p=(e,t)=>{let n=t[`${e}Buffer`];return n&&n.updating||t.queuePending[e]},em=(e,t)=>{for(let n=0;n<t.length;n++){let r=t[n];if(r.type===`mediaSource`)return null;if(r.type===e)return n}return null},tm=(e,t)=>{if(t.queue.length===0)return;let n=0,r=t.queue[n];if(r.type===`mediaSource`)!t.updating()&&t.mediaSource.readyState!==`closed`&&(t.queue.shift(),r.action(t),r.doneFn&&r.doneFn(),tm(`audio`,t),tm(`video`,t));else if(e!==`mediaSource`&&t.ready()&&t.mediaSource.readyState!==`closed`&&!$p(e,t)){if(r.type!==e){if(n=em(e,t.queue),n===null)return;r=t.queue[n]}t.queue.splice(n,1),t.queuePending[e]=r,r.action(e,t),r.doneFn||(t.queuePending[e]=null,tm(e,t))}},nm=(e,t)=>{let n=t[`${e}Buffer`],r=Zp(e);n&&(n.removeEventListener(`updateend`,t[`on${r}UpdateEnd_`]),n.removeEventListener(`error`,t[`on${r}Error_`]),t.codecs[e]=null,t[`${e}Buffer`]=null)},rm=(e,t)=>e&&t&&Array.prototype.indexOf.call(e.sourceBuffers,t)!==-1,im={appendBuffer:(e,t,n)=>(r,i)=>{let a=i[`${r}Buffer`];if(rm(i.mediaSource,a)){i.logger_(`Appending segment ${t.mediaIndex}'s ${e.length} bytes to ${r}Buffer`);try{a.appendBuffer(e)}catch(e){i.logger_(`Error with code ${e.code} `+(e.code===22?`(QUOTA_EXCEEDED_ERR) `:``)+`when appending segment ${t.mediaIndex} to ${r}Buffer`),i.queuePending[r]=null,n(e)}}},remove:(e,t)=>(n,r)=>{let i=r[`${n}Buffer`];if(rm(r.mediaSource,i)){r.logger_(`Removing ${e} to ${t} from ${n}Buffer`);try{i.remove(e,t)}catch{r.logger_(`Remove ${e} to ${t} from ${n}Buffer failed`)}}},timestampOffset:e=>(t,n)=>{let r=n[`${t}Buffer`];rm(n.mediaSource,r)&&(n.logger_(`Setting ${t}timestampOffset to ${e}`),r.timestampOffset=e)},callback:e=>(t,n)=>{e()},endOfStream:e=>t=>{if(t.mediaSource.readyState===`open`){t.logger_(`Calling mediaSource endOfStream(${e||``})`);try{t.mediaSource.endOfStream(e)}catch(e){Z.log.warn(`Failed to call media source endOfStream`,e)}}},duration:e=>t=>{t.logger_(`Setting mediaSource duration to ${e}`);try{t.mediaSource.duration=e}catch(e){Z.log.warn(`Failed to set media source duration`,e)}},abort:()=>(e,t)=>{if(t.mediaSource.readyState!==`open`)return;let n=t[`${e}Buffer`];if(rm(t.mediaSource,n)){t.logger_(`calling abort on ${e}Buffer`);try{n.abort()}catch(t){Z.log.warn(`Failed to abort on ${e}Buffer`,t)}}},addSourceBuffer:(e,t)=>n=>{let r=Zp(e),i=Ot(t);n.logger_(`Adding ${e}Buffer with codec ${t} to mediaSource`);let a=n.mediaSource.addSourceBuffer(i);a.addEventListener(`updateend`,n[`on${r}UpdateEnd_`]),a.addEventListener(`error`,n[`on${r}Error_`]),n.codecs[e]=t,n[`${e}Buffer`]=a},removeSourceBuffer:e=>t=>{let n=t[`${e}Buffer`];if(nm(e,t),rm(t.mediaSource,n)){t.logger_(`Removing ${e}Buffer with codec ${t.codecs[e]} from mediaSource`);try{t.mediaSource.removeSourceBuffer(n)}catch(t){Z.log.warn(`Failed to removeSourceBuffer ${e}Buffer`,t)}}},changeType:e=>(t,n)=>{let r=n[`${t}Buffer`],i=Ot(e);if(!rm(n.mediaSource,r))return;let a=e.substring(0,e.indexOf(`.`)),o=n.codecs[t];if(o.substring(0,o.indexOf(`.`))===a)return;let s={codecsChangeInfo:{from:o,to:e}};n.trigger({type:`codecschange`,metadata:s}),n.logger_(`changing ${t}Buffer codec from ${o} to ${e}`);try{r.changeType(i),n.codecs[t]=e}catch(e){s.errorType=Z.Error.StreamingCodecsChangeError,s.error=e,e.metadata=s,n.error_=e,n.trigger(`error`),Z.log.warn(`Failed to changeType on ${t}Buffer`,e)}}},am=({type:e,sourceUpdater:t,action:n,doneFn:r,name:i})=>{t.queue.push({type:e,action:n,doneFn:r,name:i}),tm(e,t)},om=(e,t)=>n=>{let r=Cu(t[`${e}Buffered`]());if(t.logger_(`received "updateend" event for ${e} Source Buffer: `,r),t.queuePending[e]){let n=t.queuePending[e].doneFn;t.queuePending[e]=null,n&&n(t[`${e}Error_`])}tm(e,t)};class sm extends Z.EventTarget{constructor(e){super(),this.mediaSource=e,this.sourceopenListener_=()=>tm(`mediaSource`,this),this.mediaSource.addEventListener(`sourceopen`,this.sourceopenListener_),this.logger_=xu(`SourceUpdater`),this.audioTimestampOffset_=0,this.videoTimestampOffset_=0,this.queue=[],this.queuePending={audio:null,video:null},this.delayedAudioAppendQueue_=[],this.videoAppendQueued_=!1,this.codecs={},this.onVideoUpdateEnd_=om(`video`,this),this.onAudioUpdateEnd_=om(`audio`,this),this.onVideoError_=e=>{this.videoError_=e},this.onAudioError_=e=>{this.audioError_=e},this.createdSourceBuffers_=!1,this.initializedEme_=!1,this.triggeredReady_=!1}initializedEme(){this.initializedEme_=!0,this.triggerReady()}hasCreatedSourceBuffers(){return this.createdSourceBuffers_}hasInitializedAnyEme(){return this.initializedEme_}ready(){return this.hasCreatedSourceBuffers()&&this.hasInitializedAnyEme()}createSourceBuffers(e){this.hasCreatedSourceBuffers()||(this.addOrChangeSourceBuffers(e),this.createdSourceBuffers_=!0,this.trigger(`createdsourcebuffers`),this.triggerReady())}triggerReady(){this.ready()&&!this.triggeredReady_&&(this.triggeredReady_=!0,this.trigger(`ready`))}addSourceBuffer(e,t){am({type:`mediaSource`,sourceUpdater:this,action:im.addSourceBuffer(e,t),name:`addSourceBuffer`})}abort(e){am({type:e,sourceUpdater:this,action:im.abort(),name:`abort`})}removeSourceBuffer(e){this.canRemoveSourceBuffer()?am({type:`mediaSource`,sourceUpdater:this,action:im.removeSourceBuffer(e),name:`removeSourceBuffer`}):Z.log.error(`removeSourceBuffer is not supported!`)}canRemoveSourceBuffer(){return!Z.browser.IS_FIREFOX&&x.MediaSource&&x.MediaSource.prototype&&typeof x.MediaSource.prototype.removeSourceBuffer==`function`}static canChangeType(){return x.SourceBuffer&&x.SourceBuffer.prototype&&typeof x.SourceBuffer.prototype.changeType==`function`}canChangeType(){return this.constructor.canChangeType()}changeType(e,t){this.canChangeType()?am({type:e,sourceUpdater:this,action:im.changeType(t),name:`changeType`}):Z.log.error(`changeType is not supported!`)}addOrChangeSourceBuffers(e){if(!e||typeof e!=`object`||Object.keys(e).length===0)throw Error(`Cannot addOrChangeSourceBuffers to undefined codecs`);Object.keys(e).forEach(t=>{let n=e[t];if(!this.hasCreatedSourceBuffers())return this.addSourceBuffer(t,n);this.canChangeType()&&this.changeType(t,n)})}appendBuffer(e,t){let{segmentInfo:n,type:r,bytes:i}=e;if(this.processedAppend_=!0,r===`audio`&&this.videoBuffer&&!this.videoAppendQueued_){this.delayedAudioAppendQueue_.push([e,t]),this.logger_(`delayed audio append of ${i.length} until video append`);return}let a=t;if(am({type:r,sourceUpdater:this,action:im.appendBuffer(i,n||{mediaIndex:-1},a),doneFn:t,name:`appendBuffer`}),r===`video`){if(this.videoAppendQueued_=!0,!this.delayedAudioAppendQueue_.length)return;let e=this.delayedAudioAppendQueue_.slice();this.logger_(`queuing delayed audio ${e.length} appendBuffers`),this.delayedAudioAppendQueue_.length=0,e.forEach(e=>{this.appendBuffer.apply(this,e)})}}audioBuffered(){return rm(this.mediaSource,this.audioBuffer)&&this.audioBuffer.buffered?this.audioBuffer.buffered:Su()}videoBuffered(){return rm(this.mediaSource,this.videoBuffer)&&this.videoBuffer.buffered?this.videoBuffer.buffered:Su()}buffered(){let e=rm(this.mediaSource,this.videoBuffer)?this.videoBuffer:null,t=rm(this.mediaSource,this.audioBuffer)?this.audioBuffer:null;return t&&!e?this.audioBuffered():e&&!t?this.videoBuffered():Au(this.audioBuffered(),this.videoBuffered())}setDuration(e,t=Xp){am({type:`mediaSource`,sourceUpdater:this,action:im.duration(e),name:`duration`,doneFn:t})}endOfStream(e=null,t=Xp){typeof e!=`string`&&(e=void 0),am({type:`mediaSource`,sourceUpdater:this,action:im.endOfStream(e),name:`endOfStream`,doneFn:t})}removeAudio(e,t,n=Xp){!this.audioBuffered().length||this.audioBuffered().end(0)===0?n():am({type:`audio`,sourceUpdater:this,action:im.remove(e,t),doneFn:n,name:`remove`})}removeVideo(e,t,n=Xp){!this.videoBuffered().length||this.videoBuffered().end(0)===0?n():am({type:`video`,sourceUpdater:this,action:im.remove(e,t),doneFn:n,name:`remove`})}updating(){return!!($p(`audio`,this)||$p(`video`,this))}audioTimestampOffset(e){return e!==void 0&&this.audioBuffer&&this.audioTimestampOffset_!==e&&(am({type:`audio`,sourceUpdater:this,action:im.timestampOffset(e),name:`timestampOffset`}),this.audioTimestampOffset_=e),this.audioTimestampOffset_}videoTimestampOffset(e){return e!==void 0&&this.videoBuffer&&this.videoTimestampOffset_!==e&&(am({type:`video`,sourceUpdater:this,action:im.timestampOffset(e),name:`timestampOffset`}),this.videoTimestampOffset_=e),this.videoTimestampOffset_}audioQueueCallback(e){this.audioBuffer&&am({type:`audio`,sourceUpdater:this,action:im.callback(e),name:`callback`})}videoQueueCallback(e){this.videoBuffer&&am({type:`video`,sourceUpdater:this,action:im.callback(e),name:`callback`})}dispose(){this.trigger(`dispose`),Qp.forEach(e=>{this.abort(e),this.canRemoveSourceBuffer()?this.removeSourceBuffer(e):this[`${e}QueueCallback`](()=>nm(e,this))}),this.videoAppendQueued_=!1,this.delayedAudioAppendQueue_.length=0,this.sourceopenListener_&&this.mediaSource.removeEventListener(`sourceopen`,this.sourceopenListener_),this.off()}}const cm=e=>decodeURIComponent(escape(String.fromCharCode.apply(null,e))),lm=e=>{let t=new Uint8Array(e);return Array.from(t).map(e=>e.toString(16).padStart(2,`0`)).join(``)},um=new Uint8Array(`
198
198
 
199
199
  `.split(``).map(e=>e.charCodeAt(0)));class dm extends Error{constructor(){super(`Trying to parse received VTT cues, but there is no WebVTT. Make sure vtt.js is loaded.`)}}class fm extends Yp{constructor(e,t={}){super(e,t),this.mediaSource_=null,this.subtitlesTrack_=null,this.featuresNativeTextTracks_=e.featuresNativeTextTracks,this.loadVttJs=e.loadVttJs,this.shouldSaveSegmentTimingInfo_=!1}buffered_(){if(!this.subtitlesTrack_||!this.subtitlesTrack_.cues||!this.subtitlesTrack_.cues.length)return Su();let e=this.subtitlesTrack_.cues,t=e[0].startTime,n=e[e.length-1].startTime;return Su([[t,n]])}initSegmentForMap(e,t=!1){if(!e)return null;let n=Jd(e),r=this.initSegments_[n];if(t&&!r&&e.bytes){let t=um.byteLength+e.bytes.byteLength,i=new Uint8Array(t);i.set(e.bytes),i.set(um,e.bytes.byteLength),this.initSegments_[n]=r={resolvedUri:e.resolvedUri,byterange:e.byterange,bytes:i}}return r||e}couldBeginLoading_(){return this.playlist_&&this.subtitlesTrack_&&!this.paused()}init_(){return this.state=`READY`,this.resetEverything(),this.monitorBuffer_()}track(e){return e===void 0||(this.subtitlesTrack_=e,this.state===`INIT`&&this.couldBeginLoading_()&&this.init_()),this.subtitlesTrack_}remove(e,t){Dp(e,t,this.subtitlesTrack_)}fillBuffer_(){let e=this.chooseNextRequest_();e&&(this.syncController_.timestampOffsetForTimeline(e.timeline)===null?(this.syncController_.one(`timestampoffset`,()=>{this.state=`READY`,this.paused()||this.monitorBuffer_()}),this.state=`WAITING_ON_TIMELINE`):this.loadSegment_(e))}timestampOffsetForSegment_(){return null}chooseNextRequest_(){return this.skipEmptySegments_(super.chooseNextRequest_())}skipEmptySegments_(e){for(;e&&e.segment.empty;){if(e.mediaIndex+1>=e.playlist.segments.length){e=null;break}e=this.generateSegmentInfo_({playlist:e.playlist,mediaIndex:e.mediaIndex+1,startOfSegment:e.startOfSegment+e.duration,isSyncRequest:e.isSyncRequest})}return e}stopForError(e){this.error(e),this.state=`READY`,this.pause(),this.trigger(`error`)}segmentRequestFinished_(e,t,n){if(!this.subtitlesTrack_){this.state=`READY`;return}if(this.saveTransferStats_(t.stats),!this.pendingSegment_){this.state=`READY`,this.mediaRequestsAborted+=1;return}if(e){e.code===Bf.TIMEOUT&&this.handleTimeout_(),e.code===Bf.ABORTED?this.mediaRequestsAborted+=1:this.mediaRequestsErrored+=1,this.stopForError(e);return}let r=this.pendingSegment_,i=n.mp4VttCues&&n.mp4VttCues.length;i&&(r.mp4VttCues=n.mp4VttCues),this.saveBandwidthRelatedStats_(r.duration,t.stats),t.key&&this.segmentKey(t.key,!0),this.state=`APPENDING`,this.trigger(`appending`);let a=r.segment;if(a.map&&(a.map.bytes=t.map.bytes),r.bytes=t.bytes,typeof x.WebVTT!=`function`&&typeof this.loadVttJs==`function`)this.state=`WAITING_ON_VTTJS`,this.loadVttJs().then(()=>this.segmentRequestFinished_(e,t,n),()=>this.stopForError({message:`Error loading vtt.js`}));else{a.requested=!0;try{this.parseVTTCues_(r)}catch(e){this.stopForError({message:e.message,metadata:{errorType:Z.Error.StreamingVttParserError,error:e}});return}i||this.updateTimeMapping_(r,this.syncController_.timelines[r.timeline],this.playlist_),r.timingInfo=r.cues.length?{start:r.cues[0].startTime,end:r.cues[r.cues.length-1].endTime}:{start:r.startOfSegment,end:r.startOfSegment+r.duration},r.isSyncRequest?(this.trigger(`syncinfoupdate`),this.pendingSegment_=null,this.state=`READY`):(r.byteLength=r.bytes.byteLength,this.mediaSecondsLoaded+=a.duration,r.cues.forEach(e=>{this.subtitlesTrack_.addCue(this.featuresNativeTextTracks_?new x.VTTCue(e.startTime,e.endTime,e.text):e)}),Op(this.subtitlesTrack_),this.handleAppendsDone_())}}handleData_(e,t){let n=e&&e.type===`vtt`,r=t&&t.type===`text`;n&&r&&super.handleData_(e,t)}updateTimingInfoEnd_(){}parseMp4VttCues_(e){let t=this.sourceUpdater_.videoTimestampOffset()===null?this.sourceUpdater_.audioTimestampOffset():this.sourceUpdater_.videoTimestampOffset();e.mp4VttCues.forEach(n=>{let r=n.start+t,i=n.end+t,a=new x.VTTCue(r,i,n.cueText);n.settings&&n.settings.split(` `).forEach(e=>{let t=e.split(`:`),n=t[0],r=t[1];a[n]=isNaN(r)?r:Number(r)}),e.cues.push(a)})}parseVTTCues_(e){let t,n=!1;if(typeof x.WebVTT!=`function`)throw new dm;if(e.cues=[],e.timestampmap={MPEGTS:0,LOCAL:0},e.mp4VttCues){this.parseMp4VttCues_(e);return}typeof x.TextDecoder==`function`?t=new x.TextDecoder(`utf8`):(t=x.WebVTT.StringDecoder(),n=!0);let r=new x.WebVTT.Parser(x,x.vttjs,t);if(r.oncue=e.cues.push.bind(e.cues),r.ontimestampmap=t=>{e.timestampmap=t},r.onparsingerror=e=>{Z.log.warn(`Error encountered when parsing cues: `+e.message)},e.segment.map){let t=e.segment.map.bytes;n&&(t=cm(t)),r.parse(t)}let i=e.bytes;n&&(i=cm(i)),r.parse(i),r.flush()}updateTimeMapping_(e,t,n){let r=e.segment;if(!t)return;if(!e.cues.length){r.empty=!0;return}let{MPEGTS:i,LOCAL:a}=e.timestampmap,o=i/gi.ONE_SECOND_IN_TS-a+t.mapping;if(e.cues.forEach(e=>{let n=e.endTime-e.startTime,r=this.handleRollover_(e.startTime+o,t.time);e.startTime=Math.max(r,0),e.endTime=Math.max(r+n,0)}),!n.syncInfo){let t=e.cues[0].startTime,i=e.cues[e.cues.length-1].startTime;n.syncInfo={mediaSequence:n.mediaSequence+e.mediaIndex,time:Math.min(t,i-r.duration)}}}handleRollover_(e,t){if(t===null)return e;let n=e*gi.ONE_SECOND_IN_TS,r=t*gi.ONE_SECOND_IN_TS,i;for(i=r<n?-8589934592:8589934592;Math.abs(n-r)>4294967296;)n+=i;return n/gi.ONE_SECOND_IN_TS}}const pm=function(e,t){let n=e.cues;for(let e=0;e<n.length;e++){let r=n[e];if(t>=r.adStartTime&&t<=r.adEndTime)return r}return null},mm=function(e,t,n=0){if(!e.segments)return;let r=n,i;for(let n=0;n<e.segments.length;n++){let a=e.segments[n];if(i||=pm(t,r+a.duration/2),i){if(`cueIn`in a){i.endTime=r,i.adEndTime=r,r+=a.duration,i=null;continue}if(r<i.endTime){r+=a.duration;continue}i.endTime+=a.duration}else if(`cueOut`in a&&(i=new x.VTTCue(r,r+a.duration,a.cueOut),i.adStartTime=r,i.adEndTime=r+parseFloat(a.cueOut),t.addCue(i)),`cueOutCont`in a){let[e,n]=a.cueOutCont.split(`/`).map(parseFloat);i=new x.VTTCue(r,r+a.duration,``),i.adStartTime=r-e,i.adEndTime=i.adStartTime+n,t.addCue(i)}r+=a.duration}};class hm{constructor({start:e,end:t,segmentIndex:n,partIndex:r=null,appended:i=!1}){this.start_=e,this.end_=t,this.segmentIndex_=n,this.partIndex_=r,this.appended_=i}isInRange(e){return e>=this.start&&e<this.end}markAppended(){this.appended_=!0}resetAppendedStatus(){this.appended_=!1}get isAppended(){return this.appended_}get start(){return this.start_}get end(){return this.end_}get segmentIndex(){return this.segmentIndex_}get partIndex(){return this.partIndex_}}class gm{constructor(e,t=[]){this.segmentSyncInfo_=e,this.partsSyncInfo_=t}get segmentSyncInfo(){return this.segmentSyncInfo_}get partsSyncInfo(){return this.partsSyncInfo_}get hasPartsSyncInfo(){return this.partsSyncInfo_.length>0}resetAppendStatus(){this.segmentSyncInfo_.resetAppendedStatus(),this.partsSyncInfo_.forEach(e=>e.resetAppendedStatus())}}class _m{constructor(){this.storage_=new Map,this.diagnostics_=``,this.isReliable_=!1,this.start_=-1/0,this.end_=1/0}get start(){return this.start_}get end(){return this.end_}get diagnostics(){return this.diagnostics_}get isReliable(){return this.isReliable_}resetAppendedStatus(){this.storage_.forEach(e=>e.resetAppendStatus())}update(e,t){let{mediaSequence:n,segments:r}=e;if(this.isReliable_=this.isReliablePlaylist_(n,r),this.isReliable_)return this.updateStorage_(r,n,this.calculateBaseTime_(n,r,t))}getSyncInfoForTime(e){for(let{segmentSyncInfo:t,partsSyncInfo:n}of this.storage_.values())if(n.length){for(let t of n)if(t.isInRange(e))return t}else if(t.isInRange(e))return t;return null}getSyncInfoForMediaSequence(e){return this.storage_.get(e)}updateStorage_(e,t,n){let r=new Map,i=`
200
- `,a=n,o=t;this.start_=a,e.forEach((e,t)=>{let n=this.storage_.get(o),s=a,c=s+e.duration,l=!!(n&&n.segmentSyncInfo&&n.segmentSyncInfo.isAppended),u=new hm({start:s,end:c,appended:l,segmentIndex:t});e.syncInfo=u;let d=a,f=(e.parts||[]).map((e,r)=>{let a=d,s=d+e.duration,c=!!(n&&n.partsSyncInfo&&n.partsSyncInfo[r]&&n.partsSyncInfo[r].isAppended),l=new hm({start:a,end:s,appended:c,segmentIndex:t,partIndex:r});return d=s,i+=`Media Sequence: ${o}.${r} | Range: ${a} --> ${s} | Appended: ${c}\n`,e.syncInfo=l,l});r.set(o,new gm(u,f)),i+=`${vp(e.resolvedUri)} | Media Sequence: ${o} | Range: ${s} --> ${c} | Appended: ${l}\n`,o++,a=c}),this.end_=a,this.storage_=r,this.diagnostics_=i}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;let r=Math.min(...this.storage_.keys());if(e<r){let n=r-e,i=this.storage_.get(r).segmentSyncInfo.start;for(let e=0;e<n;e++){let n=t[e];i-=n.duration}return i}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class vm extends _m{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){let t=this.parent_.getSyncInfoForMediaSequence(e);return t?t.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const ym=[{name:`VOD`,run:(e,t,n,r,i)=>n===1/0?null:{time:0,segmentIndex:0,partIndex:null}},{name:`MediaSequence`,run:(e,t,n,r,i,a)=>{let o=e.getMediaSequenceSync(a);if(!o||!o.isReliable)return null;let s=o.getSyncInfoForTime(i);return s?{time:s.start,partIndex:s.partIndex,segmentIndex:s.segmentIndex}:null}},{name:`ProgramDateTime`,run:(e,t,n,r,i)=>{if(!Object.keys(e.timelineToDatetimeMappings).length)return null;let a=null,o=null,s=Ru(t);i||=0;for(let n=0;n<s.length;n++){let r=s[t.endList||i===0?n:s.length-(n+1)],c=r.segment,l=e.timelineToDatetimeMappings[c.timeline];if(!l||!c.dateTimeObject)continue;let u=c.dateTimeObject.getTime()/1e3+l;if(c.parts&&typeof r.partIndex==`number`)for(let e=0;e<r.partIndex;e++)u+=c.parts[e].duration;let d=Math.abs(i-u);if(o!==null&&(d===0||o<d))break;o=d,a={time:u,segmentIndex:r.segmentIndex,partIndex:r.partIndex}}return a}},{name:`Segment`,run:(e,t,n,r,i)=>{let a=null,o=null;i||=0;let s=Ru(t);for(let e=0;e<s.length;e++){let n=s[t.endList||i===0?e:s.length-(e+1)],c=n.segment,l=n.part&&n.part.start||c&&c.start;if(c.timeline===r&&l!==void 0){let e=Math.abs(i-l);if(o!==null&&o<e)break;(!a||o===null||o>=e)&&(o=e,a={time:l,segmentIndex:n.segmentIndex,partIndex:n.partIndex})}}return a}},{name:`Discontinuity`,run:(e,t,n,r,i)=>{let a=null;if(i||=0,t.discontinuityStarts&&t.discontinuityStarts.length){let n=null;for(let r=0;r<t.discontinuityStarts.length;r++){let o=t.discontinuityStarts[r],s=t.discontinuitySequence+r+1,c=e.discontinuities[s];if(c){let e=Math.abs(i-c.time);if(n!==null&&n<e)break;(!a||n===null||n>=e)&&(n=e,a={time:c.time,segmentIndex:o,partIndex:null})}}}return a}},{name:`Playlist`,run:(e,t,n,r,i)=>t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence,partIndex:null}:null}];class bm extends Z.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};let t=new _m,n=new vm(t),r=new vm(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:r},this.logger_=xu(`SyncController`)}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,r,i){if(t!==1/0)return ym.find(({name:e})=>e===`VOD`).run(this,e,t);let a=this.runStrategies_(e,t,n,r,i);if(!a.length)return null;for(let t of a){let{syncPoint:n,strategy:i}=t,{segmentIndex:a,time:o}=n;if(a<0)continue;let s=e.segments[a],c=o,l=c+s.duration;if(this.logger_(`Strategy: ${i}. Current time: ${r}. selected segment: ${a}. Time: [${c} -> ${l}]}`),r>=c&&r<l)return this.logger_(`Found sync point with exact match: `,n),n}return this.selectSyncPoint_(a,{key:`time`,value:r})}getExpiredTime(e,t){if(!e||!e.segments)return null;let n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;let r=this.selectSyncPoint_(n,{key:`segmentIndex`,value:0});return r.segmentIndex>0&&(r.time*=-1),Math.abs(r.time+Ku({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:r.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,r,i){let a=[];for(let o=0;o<ym.length;o++){let s=ym[o],c=s.run(this,e,t,n,r,i);c&&(c.strategy=s.name,a.push({strategy:s.name,syncPoint:c}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,r=Math.abs(e[0].syncPoint[t.key]-t.value),i=e[0].strategy;for(let a=1;a<e.length;a++){let o=Math.abs(e[a].syncPoint[t.key]-t.value);o<r&&(r=o,n=e[a].syncPoint,i=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${i}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex==`number`?`,partIndex:${n.partIndex}`:``)+`]`),n}saveExpiredSegmentInfo(e,t){let n=t.mediaSequence-e.mediaSequence;if(n>86400)Z.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);else for(let r=n-1;r>=0;r--){let n=e.segments[r];if(n&&n.start!==void 0){t.syncInfo={mediaSequence:e.mediaSequence+r,time:n.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger(`syncinfoupdate`);break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){let t=e.segments[0],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){let n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),r=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:r.start}));let i=r.dateTimeObject;r.discontinuity&&t&&i&&(this.timelineToDatetimeMappings[r.timeline]=-(i.getTime()/1e3))}timestampOffsetForTimeline(e){return this.timelines[e]===void 0?null:this.timelines[e].time}mappingForTimeline(e){return this.timelines[e]===void 0?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,n){let r=e.segment,i=e.part,a=this.timelines[e.timeline],o,s;if(typeof e.timestampOffset==`number`)a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger(`timestampoffset`),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),o=e.startOfSegment,s=t.end+a.mapping;else if(a)o=t.start+a.mapping,s=t.end+a.mapping;else return!1;return i&&(i.start=o,i.end=s),(!r.start||o<r.start)&&(r.start=o),r.end=s,!0}saveDiscontinuitySyncInfo_(e){let t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let r=0;r<t.discontinuityStarts.length;r++){let i=t.discontinuityStarts[r],a=t.discontinuitySequence+r+1,o=i-e.mediaIndex,s=Math.abs(o);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>s){let r;r=o<0?n.start-Ku({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:i}):n.end+Ku({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:i}),this.discontinuities[a]={time:r,accuracy:s}}}}dispose(){this.trigger(`dispose`),this.off()}}class xm extends Z.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger(`pendingtimelinechange`)}pendingTimelineChange({type:e,from:t,to:n}){return typeof t==`number`&&typeof n==`number`&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger(`pendingtimelinechange`)),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t==`number`&&typeof n==`number`){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];let r={timelineChangeInfo:{from:t,to:n}};this.trigger({type:`timelinechange`,metadata:r})}return this.lastTimelineChanges_[e]}dispose(){this.trigger(`dispose`),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}var Sm=wf(Tf(Ef(function(){var e=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var n=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(n,1),n>-1},t.trigger=function(e){var t=this.listeners[e];if(t){if(arguments.length===2)for(var n=t.length,r=0;r<n;++r)t[r].call(this,arguments[1]);else for(var i=Array.prototype.slice.call(arguments,1),a=t.length,o=0;o<a;++o)t[o].apply(this,i)}},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on(`data`,function(t){e.push(t)})},e}();function t(e){return e.subarray(0,e.byteLength-e[e.byteLength-1])}let n=function(){let e=[[[],[],[],[],[]],[[],[],[],[],[]]],t=e[0],n=e[1],r=t[4],i=n[4],a,o,s,c=[],l=[],u,d,f,p,m,h;for(a=0;a<256;a++)l[(c[a]=a<<1^(a>>7)*283)^a]=a;for(o=s=0;!r[o];o^=u||1,s=l[s]||1)for(p=s^s<<1^s<<2^s<<3^s<<4,p=p>>8^p&255^99,r[o]=p,i[p]=o,f=c[d=c[u=c[o]]],h=f*16843009^d*65537^u*257^o*16843008,m=c[p]*257^p*16843008,a=0;a<4;a++)t[a][o]=m=m<<24^m>>>8,n[a][p]=h=h<<24^h>>>8;for(a=0;a<5;a++)t[a]=t[a].slice(0),n[a]=n[a].slice(0);return e},r=null;class i{constructor(e){r||=n(),this._tables=[[r[0][0].slice(),r[0][1].slice(),r[0][2].slice(),r[0][3].slice(),r[0][4].slice()],[r[1][0].slice(),r[1][1].slice(),r[1][2].slice(),r[1][3].slice(),r[1][4].slice()]];let t,i,a,o=this._tables[0][4],s=this._tables[1],c=e.length,l=1;if(c!==4&&c!==6&&c!==8)throw Error(`Invalid aes key size`);let u=e.slice(0),d=[];for(this._key=[u,d],t=c;t<4*c+28;t++)a=u[t-1],(t%c===0||c===8&&t%c===4)&&(a=o[a>>>24]<<24^o[a>>16&255]<<16^o[a>>8&255]<<8^o[a&255],t%c===0&&(a=a<<8^a>>>24^l<<24,l=l<<1^(l>>7)*283)),u[t]=u[t-c]^a;for(i=0;t;i++,t--)a=u[i&3?t:t-4],t<=4||i<4?d[i]=a:d[i]=s[0][o[a>>>24]]^s[1][o[a>>16&255]]^s[2][o[a>>8&255]]^s[3][o[a&255]]}decrypt(e,t,n,r,i,a){let o=this._key[1],s=e^o[0],c=r^o[1],l=n^o[2],u=t^o[3],d,f,p,m=o.length/4-2,h,g=4,_=this._tables[1],v=_[0],y=_[1],b=_[2],x=_[3],S=_[4];for(h=0;h<m;h++)d=v[s>>>24]^y[c>>16&255]^b[l>>8&255]^x[u&255]^o[g],f=v[c>>>24]^y[l>>16&255]^b[u>>8&255]^x[s&255]^o[g+1],p=v[l>>>24]^y[u>>16&255]^b[s>>8&255]^x[c&255]^o[g+2],u=v[u>>>24]^y[s>>16&255]^b[c>>8&255]^x[l&255]^o[g+3],g+=4,s=d,c=f,l=p;for(h=0;h<4;h++)i[(3&-h)+a]=S[s>>>24]<<24^S[c>>16&255]<<16^S[l>>8&255]<<8^S[u&255]^o[g++],d=s,s=c,c=l,l=u,u=d}}class a extends e{constructor(){super(e),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.timeout_=this.jobs.length?setTimeout(this.processJob_.bind(this),this.delay):null}push(e){this.jobs.push(e),this.timeout_||=setTimeout(this.processJob_.bind(this),this.delay)}}let o=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},s=function(e,t,n){let r=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),a=new i(Array.prototype.slice.call(t)),s=new Uint8Array(e.byteLength),c=new Int32Array(s.buffer),l,u,d,f,p,m,h,g,_;for(l=n[0],u=n[1],d=n[2],f=n[3],_=0;_<r.length;_+=4)p=o(r[_]),m=o(r[_+1]),h=o(r[_+2]),g=o(r[_+3]),a.decrypt(p,m,h,g,c,_),c[_]=o(c[_]^l),c[_+1]=o(c[_+1]^u),c[_+2]=o(c[_+2]^d),c[_+3]=o(c[_+3]^f),l=p,u=m,d=h,f=g;return s};class c{constructor(e,n,r,i){let s=c.STEP,l=new Int32Array(e.buffer),u=new Uint8Array(e.byteLength),d=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(l.subarray(d,d+s),n,r,u)),d=s;d<l.length;d+=s)r=new Uint32Array([o(l[d-4]),o(l[d-3]),o(l[d-2]),o(l[d-1])]),this.asyncStream_.push(this.decryptChunk_(l.subarray(d,d+s),n,r,u));this.asyncStream_.push(function(){i(null,t(u))})}static get STEP(){return 32e3}decryptChunk_(e,t,n,r){return function(){let i=s(e,t,n);r.set(i,e.byteOffset)}}}var l=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},u=typeof window<`u`?window:l===void 0?typeof self<`u`?self:{}:l,d=function(e){return ArrayBuffer.isView===`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},f=u.BigInt||Number;f(`0x1`),f(`0x100`),f(`0x10000`),f(`0x1000000`),f(`0x100000000`),f(`0x10000000000`),f(`0x1000000000000`),f(`0x100000000000000`),f(`0x10000000000000000`),(function(){var e=new Uint16Array([65484]),t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return t[0]===255?`big`:t[0]===204?`little`:`unknown`})();let p=function(e){let t={};return Object.keys(e).forEach(n=>{let r=e[n];d(r)?t[n]={bytes:r.buffer,byteOffset:r.byteOffset,byteLength:r.byteLength}:t[n]=r}),t};self.onmessage=function(e){let t=e.data,n=new Uint8Array(t.encrypted.bytes,t.encrypted.byteOffset,t.encrypted.byteLength),r=new Uint32Array(t.key.bytes,t.key.byteOffset,t.key.byteLength/4),i=new Uint32Array(t.iv.bytes,t.iv.byteOffset,t.iv.byteLength/4);new c(n,r,i,function(e,n){self.postMessage(p({source:t.source,decrypted:n}),[n.buffer])})}})));const Cm=e=>{let t=e.default?`main`:`alternative`;return e.characteristics&&e.characteristics.indexOf(`public.accessibility.describes-video`)>=0&&(t=`main-desc`),t},wm=(e,t)=>{e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},Tm=(e,t)=>{t.activePlaylistLoader=e,e.load()},Em=(e,t)=>()=>{let{segmentLoaders:{[e]:n,main:r},mediaTypes:{[e]:i}}=t,a=i.activeTrack(),o=i.getActiveGroup(),s=i.activePlaylistLoader,c=i.lastGroup_;o&&c&&o.id===c.id||(i.lastGroup_=o,i.lastTrack_=a,wm(n,i),o&&!o.isMainPlaylist&&(o.playlistLoader?(n.resyncLoader(),Tm(o.playlistLoader,i)):s&&r.resetEverything()))},Dm=(e,t)=>()=>{let{segmentLoaders:{[e]:n},mediaTypes:{[e]:r}}=t;r.lastGroup_=null,n.abort(),n.pause()},Om=(e,t)=>()=>{let{mainPlaylistLoader:n,segmentLoaders:{[e]:r,main:i},mediaTypes:{[e]:a}}=t,o=a.activeTrack(),s=a.getActiveGroup(),c=a.activePlaylistLoader,l=a.lastTrack_;if(!(l&&o&&l.id===o.id)&&(a.lastGroup_=s,a.lastTrack_=o,wm(r,a),s)){if(s.isMainPlaylist){if(!o||!l||o.id===l.id)return;let e=t.vhs.playlistController_,r=e.selectPlaylist();if(e.media()===r)return;a.logger_(`track change. Switching main audio from ${l.id} to ${o.id}`),n.pause(),i.resetEverything(),e.fastQualityChange_(r)}else{if(e===`AUDIO`){if(!s.playlistLoader){i.setAudio(!0),i.resetEverything();return}r.setAudio(!0),i.setAudio(!1)}c===s.playlistLoader||(r.track&&r.track(o),r.resetEverything()),Tm(s.playlistLoader,a)}}},km={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:n},excludePlaylist:r}=t,i=n.activeTrack(),a=n.activeGroup(),o=(a.filter(e=>e.default)[0]||a[0]).id,s=n.tracks[o];if(i===s)r({error:{message:`Problem encountered loading the default audio track.`}});else{Z.log.warn(`Problem encountered loading the alternate audio track.Switching back to default.`);for(let e in n.tracks)n.tracks[e].enabled=n.tracks[e]===s;n.onTrackChanged()}},SUBTITLES:(e,t)=>()=>{let{mediaTypes:{[e]:n}}=t;Z.log.warn(`Problem encountered loading the subtitle track.Disabling subtitle track.`);let r=n.activeTrack();r&&(r.mode=`disabled`),n.onTrackChanged()}},Am={AUDIO:(e,t,n)=>{if(!t)return;let{tech:r,requestOptions:i,segmentLoaders:{[e]:a}}=n;t.on(`loadedmetadata`,()=>{let e=t.media();a.playlist(e,i),(!r.paused()||e.endList&&r.preload()!==`none`)&&a.load()}),t.on(`loadedplaylist`,()=>{a.playlist(t.media(),i),r.paused()||a.load()}),t.on(`error`,km[e](e,n))},SUBTITLES:(e,t,n)=>{let{tech:r,requestOptions:i,segmentLoaders:{[e]:a},mediaTypes:{[e]:o}}=n;t.on(`loadedmetadata`,()=>{let e=t.media();a.playlist(e,i),a.track(o.activeTrack()),(!r.paused()||e.endList&&r.preload()!==`none`)&&a.load()}),t.on(`loadedplaylist`,()=>{a.playlist(t.media(),i),r.paused()||a.load()}),t.on(`error`,km[e](e,n))}},jm={AUDIO:(e,t)=>{let{vhs:n,sourceType:r,segmentLoaders:{[e]:i},requestOptions:a,main:{mediaGroups:o},mediaTypes:{[e]:{groups:s,tracks:c,logger_:l}},mainPlaylistLoader:u}=t,d=od(u.main);o[e]&&Object.keys(o[e]).length!==0||(o[e]={main:{default:{default:!0}}},d&&(o[e].main.default.playlists=u.main.playlists));for(let i in o[e]){s[i]||(s[i]=[]);for(let f in o[e][i]){let p=o[e][i][f],m;d?(l(`AUDIO group '${i}' label '${f}' is a main playlist`),p.isMainPlaylist=!0,m=null):m=r===`vhs-json`&&p.playlists?new Ld(p.playlists[0],n,a):p.resolvedUri?new Ld(p.resolvedUri,n,a):p.playlists&&r===`dash`?new yf(p.playlists[0],n,a,u):null,p=Q({id:f,playlistLoader:m},p),Am[e](e,p.playlistLoader,t),s[i].push(p),c[f]===void 0&&(c[f]=new Z.AudioTrack({id:f,kind:Cm(p),enabled:!1,language:p.language,default:p.default,label:f}))}}i.on(`error`,km[e](e,t))},SUBTITLES:(e,t)=>{let{tech:n,vhs:r,sourceType:i,segmentLoaders:{[e]:a},requestOptions:o,main:{mediaGroups:s},mediaTypes:{[e]:{groups:c,tracks:l}},mainPlaylistLoader:u}=t;for(let a in s[e]){c[a]||(c[a]=[]);for(let d in s[e][a]){if(!r.options_.useForcedSubtitles&&s[e][a][d].forced)continue;let f=s[e][a][d],p;if(i===`hls`)p=new Ld(f.resolvedUri,r,o);else if(i===`dash`){if(!f.playlists.filter(e=>e.excludeUntil!==1/0).length)return;p=new yf(f.playlists[0],r,o,u)}else i===`vhs-json`&&(p=new Ld(f.playlists?f.playlists[0]:f.resolvedUri,r,o));f=Q({id:d,playlistLoader:p},f),Am[e](e,f.playlistLoader,t),c[a].push(f),l[d]===void 0&&(l[d]=n.addRemoteTextTrack({id:d,kind:`subtitles`,default:f.default&&f.autoselect,language:f.language,label:d},!1).track)}}a.on(`error`,km[e](e,t))},"CLOSED-CAPTIONS":(e,t)=>{let{tech:n,main:{mediaGroups:r},mediaTypes:{[e]:{groups:i,tracks:a}}}=t;for(let t in r[e]){i[t]||(i[t]=[]);for(let o in r[e][t]){let s=r[e][t][o];if(!/^(?:CC|SERVICE)/.test(s.instreamId))continue;let c=n.options_.vhs&&n.options_.vhs.captionServices||{},l={label:o,language:s.language,instreamId:s.instreamId,default:s.default&&s.autoselect};c[l.instreamId]&&(l=Q(l,c[l.instreamId])),l.default===void 0&&delete l.default,i[t].push(Q({id:o},s)),a[o]===void 0&&(a[o]=n.addRemoteTextTrack({id:l.instreamId,kind:`captions`,default:l.default,language:l.language,label:l.label},!1).track)}}}},Mm=(e,t)=>{for(let n=0;n<e.length;n++)if(id(t,e[n])||e[n].playlists&&Mm(e[n].playlists,t))return!0;return!1},Nm=(e,t)=>n=>{let{mainPlaylistLoader:r,mediaTypes:{[e]:{groups:i}}}=t,a=r.media();if(!a)return null;let o=null;a.attributes[e]&&(o=i[a.attributes[e]]);let s=Object.keys(i);if(!o){if(e===`AUDIO`&&s.length>1&&od(t.main))for(let e=0;e<s.length;e++){let t=i[s[e]];if(Mm(t,a)){o=t;break}}else i.main?o=i.main:s.length===1&&(o=i[s[0]])}return n===void 0?o:n===null||!o?null:o.filter(e=>e.id===n.id)[0]||null},Pm={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:{tracks:n}}}=t;for(let e in n)if(n[e].enabled)return n[e];return null},SUBTITLES:(e,t)=>()=>{let{mediaTypes:{[e]:{tracks:n}}}=t;for(let e in n)if(n[e].mode===`showing`||n[e].mode===`hidden`)return n[e];return null}},Fm=(e,{mediaTypes:t})=>()=>{let n=t[e].activeTrack();return n?t[e].activeGroup(n):null},Im=e=>{[`AUDIO`,`SUBTITLES`,`CLOSED-CAPTIONS`].forEach(t=>{jm[t](t,e)});let{mediaTypes:t,mainPlaylistLoader:n,tech:r,vhs:i,segmentLoaders:{AUDIO:a,main:o}}=e;[`AUDIO`,`SUBTITLES`].forEach(n=>{t[n].activeGroup=Nm(n,e),t[n].activeTrack=Pm[n](n,e),t[n].onGroupChanged=Em(n,e),t[n].onGroupChanging=Dm(n,e),t[n].onTrackChanged=Om(n,e),t[n].getActiveGroup=Fm(n,e)});let s=t.AUDIO.activeGroup();if(s){let e=(s.filter(e=>e.default)[0]||s[0]).id;t.AUDIO.tracks[e].enabled=!0,t.AUDIO.onGroupChanged(),t.AUDIO.onTrackChanged(),t.AUDIO.getActiveGroup().playlistLoader?(o.setAudio(!1),a.setAudio(!0)):o.setAudio(!0)}n.on(`mediachange`,()=>{[`AUDIO`,`SUBTITLES`].forEach(e=>t[e].onGroupChanged())}),n.on(`mediachanging`,()=>{[`AUDIO`,`SUBTITLES`].forEach(e=>t[e].onGroupChanging())});let c=()=>{t.AUDIO.onTrackChanged(),r.trigger({type:`usage`,name:`vhs-audio-change`})};r.audioTracks().addEventListener(`change`,c),r.remoteTextTracks().addEventListener(`change`,t.SUBTITLES.onTrackChanged),i.on(`dispose`,()=>{r.audioTracks().removeEventListener(`change`,c),r.remoteTextTracks().removeEventListener(`change`,t.SUBTITLES.onTrackChanged)}),r.clearTracks(`audio`);for(let e in t.AUDIO.tracks)r.audioTracks().addTrack(t.AUDIO.tracks[e])},Lm=()=>{let e={};return[`AUDIO`,`SUBTITLES`,`CLOSED-CAPTIONS`].forEach(t=>{e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Xp,activeTrack:Xp,getActiveGroup:Xp,onGroupChanged:Xp,onTrackChanged:Xp,lastTrack_:null,logger_:xu(`MediaGroups[${t}]`)}}),e};class Rm{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=yu(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(e=>[e.ID,e])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class zm extends Z.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new Rm,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=xu(`Content Steering`),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?`HLS`:`DASH`;let n=t.serverUri||t.serverURL;n?n.startsWith(`data:`)?this.decodeDataUriManifest_(n.substring(n.indexOf(`,`)+1)):(this.steeringManifest.reloadUri=yu(e,n),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger(`content-steering`)):(this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger(`error`))}requestSteeringManifest(e){let t=this.steeringManifest.reloadUri;if(!t)return;let n=e?t:this.getRequestURI(t);if(!n){this.logger_(`No valid content steering manifest URIs. Stopping content steering.`),this.trigger(`error`),this.dispose();return}let r={contentSteeringInfo:{uri:n}};this.trigger({type:`contentsteeringloadstart`,metadata:r}),this.request_=this.xhr_({uri:n,requestType:`content-steering-manifest`},(e,t)=>{if(e){if(t.status===410){this.logger_(`manifest request 410 ${e}.`),this.logger_(`There will be no more content steering requests to ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(t.status===429){let n=t.responseHeaders[`retry-after`];this.logger_(`manifest request 429 ${e}.`),this.logger_(`content steering will retry in ${n} seconds.`),this.startTTLTimeout_(parseInt(n,10));return}this.logger_(`manifest failed to load ${e}.`),this.startTTLTimeout_();return}this.trigger({type:`contentsteeringloadcomplete`,metadata:r});let i;try{i=JSON.parse(this.request_.responseText)}catch(e){let t={errorType:Z.Error.StreamingContentSteeringParserError,error:e};this.trigger({type:`error`,metadata:t})}this.assignSteeringProperties_(i);let a={contentSteeringInfo:r.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:`contentsteeringparsed`,metadata:a}),this.startTTLTimeout_()})}setProxyServerUrl_(e){let t=new x.URL(e),n=new x.URL(this.proxyServerUrl_);return n.searchParams.set(`url`,encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){let t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){let t=new x.URL(e),n=this.getPathway(),r=this.getBandwidth_();if(n){let e=`_${this.manifestType_}_pathway`;t.searchParams.set(e,n)}if(r){let e=`_${this.manifestType_}_throughput`;t.searchParams.set(e,r)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger(`error`);return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e[`RELOAD-URI`],this.steeringManifest.priority=e[`PATHWAY-PRIORITY`]||e[`SERVICE-LOCATION-PRIORITY`],this.steeringManifest.pathwayClones=e[`PATHWAY-CLONES`],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_(`There are no available pathways for content steering. Ending content steering.`),this.trigger(`error`),this.dispose());let t=(e=>{for(let t of e)if(this.availablePathways_.has(t))return t;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger(`content-steering`))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;let t=e=>this.excludedSteeringManifestURLs.has(e);if(this.proxyServerUrl_){let n=this.setProxyServerUrl_(e);if(!t(n))return n}let n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){let t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off(`content-steering`),this.off(`error`),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new Rm}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(yu(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const Bm=(e,t)=>{let n=null;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(null,r)},t)}};let Vm;const Hm=[`mediaRequests`,`mediaRequestsAborted`,`mediaRequestsTimedout`,`mediaRequestsErrored`,`mediaTransferDuration`,`mediaBytesTransferred`,`mediaAppends`],Um=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},Wm=function({currentPlaylist:e,buffered:t,currentTime:n,nextPlaylist:r,bufferLowWaterLine:i,bufferHighWaterLine:a,duration:o,bufferBasedABR:s,log:c}){if(!r)return Z.log.warn(`We received no playlist to switch to. Please check your stream.`),!1;let l=`allowing switch ${e&&e.id||`null`} -> ${r.id}`;if(!e)return c(`${l} as current playlist is not set`),!0;if(r.id===e.id)return!1;let u=!!Du(t,n).length;if(!e.endList)return!u&&typeof e.partTargetDuration==`number`?(c(`not ${l} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${l} as current playlist is live`),!0);let d=Iu(t,n),f=s?bf.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:bf.MAX_BUFFER_LOW_WATER_LINE;if(o<f)return c(`${l} as duration < max low water line (${o} < ${f})`),!0;let p=r.attributes.BANDWIDTH,m=e.attributes.BANDWIDTH;if(p<m&&(!s||d<a)){let e=`${l} as next bandwidth < current bandwidth (${p} < ${m})`;return s&&(e+=` and forwardBuffer < bufferHighWaterLine (${d} < ${a})`),c(e),!0}if((!s||p>m)&&d>=i){let e=`${l} as forwardBuffer >= bufferLowWaterLine (${d} >= ${i})`;return s&&(e+=` and next bandwidth > current bandwidth (${p} > ${m})`),c(e),!0}return c(`not ${l} as no switching criteria met`),!1};class Gm extends Z.EventTarget{constructor(e){super(),this.fastQualityChange_=Bm(this.fastQualityChange_.bind(this),100);let{src:t,withCredentials:n,tech:r,bandwidth:i,externVhs:a,useCueTags:o,playlistExclusionDuration:s,enableLowInitialPlaylist:c,sourceType:l,cacheEncryptionKeys:u,bufferBasedABR:d,leastPixelDiffSelector:f,captionServices:p,experimentalUseMMS:m}=e;if(!t)throw Error(`A non-empty playlist URL or JSON manifest string is required`);let{maxPlaylistRetries:h}=e;h??=1/0,Vm=a,this.bufferBasedABR=!!d,this.leastPixelDiffSelector=!!f,this.withCredentials=n,this.tech_=r,this.vhs_=r.vhs,this.player_=e.player_,this.sourceType_=l,this.useCueTags_=o,this.playlistExclusionDuration=s,this.maxPlaylistRetries=h,this.enableLowInitialPlaylist=c,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack(`metadata`,`ad-cues`),this.cueTagsTrack_.inBandMetadataTrackDispatchType=``),this.requestOptions_={withCredentials:n,maxPlaylistRetries:h,timeout:null},this.on(`error`,this.pauseLoading),this.mediaTypes_=Lm(),m&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,Z.log(`Using ManagedMediaSource`)):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener(`durationchange`,this.handleDurationChange_),this.mediaSource.addEventListener(`sourceopen`,this.handleSourceOpen_),this.mediaSource.addEventListener(`sourceended`,this.handleSourceEnded_),this.mediaSource.addEventListener(`startstreaming`,this.load),this.mediaSource.addEventListener(`endstreaming`,this.pause),this.seekable_=Su(),this.hasPlayed_=!1,this.syncController_=new bm(e),this.segmentMetadataTrack_=r.addRemoteTextTrack({kind:`metadata`,label:`segment-metadata`},!1).track,this.segmentMetadataTrack_.mode=`hidden`,this.decrypter_=new Sm,this.sourceUpdater_=new sm(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new xm,this.keyStatusMap_=new Map;let g={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:p,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:i,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:u,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_===`dash`?new yf(t,this.vhs_,Q(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Ld(t,this.vhs_,Q(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Yp(Q(g,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:`main`}),e),this.audioSegmentLoader_=new Yp(Q(g,{loaderType:`audio`}),e),this.subtitleSegmentLoader_=new fm(Q(g,{loaderType:`vtt`,featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((e,t)=>{function n(){r.off(`vttjserror`,i),e()}function i(){r.off(`vttjsloaded`,n),t()}r.one(`vttjsloaded`,n),r.one(`vttjserror`,i),r.addWebVttScript_()})}),e);let _=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new zm(this.vhs_.xhr,_),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one(`loadedplaylist`,()=>this.startABRTimer_()),this.tech_.on(`pause`,()=>this.stopABRTimer_()),this.tech_.on(`play`,()=>this.startABRTimer_())),Hm.forEach(e=>{this[e+`_`]=Um.bind(this,e)}),this.logger_=xu(`pc`),this.triggeredFmp4Usage=!1,this.tech_.preload()===`none`?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one(`play`,this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;let v=this.tech_.preload()===`none`?`play`:`loadstart`;this.tech_.one(v,()=>{let e=Date.now();this.tech_.one(`loadeddata`,()=>{this.timeToLoadedData__=Date.now()-e,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){let e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e=`abr`){let t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,n){let r=this.media(),i=r&&(r.id||r.uri),a=e&&(e.id||e.uri);if(i&&i!==a){this.logger_(`switch media ${i} -> ${a} from ${t}`);let n={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:`renditionselected`,metadata:n}),this.tech_.trigger({type:`usage`,name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){[`AUDIO`,`SUBTITLES`,`CLOSED-CAPTIONS`].forEach(e=>{let t=this.mediaTypes_[e],n=t?t.activeGroup():null,r=this.contentSteeringController_.getPathway();if(n&&r){let t=(n.length?n[0].playlists:n.playlists).filter(e=>e.attributes.serviceLocation===r);t.length&&this.mediaTypes_[e].activePlaylistLoader.media(t[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){let e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;let n=e.mediaGroups.AUDIO,r=Object.keys(n),i;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)i=this.mediaTypes_.AUDIO.activeTrack();else{let e=n.main||r.length&&n[r[0]];for(let t in e)if(e[t].default){i={label:t};break}}if(!i)return t;let a=[];for(let t in n)if(n[t][i.label]){let r=n[t][i.label];if(r.playlists&&r.playlists.length)a.push.apply(a,r.playlists);else if(r.uri)a.push(r);else if(e.playlists.length)for(let n=0;n<e.playlists.length;n++){let r=e.playlists[n];r.attributes&&r.attributes.AUDIO&&r.attributes.AUDIO===t&&a.push(r)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on(`loadedmetadata`,()=>{let e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;rd(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!==`none`&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),Im({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger(`selectedinitialmedia`):this.mediaTypes_.AUDIO.activePlaylistLoader.one(`loadedmetadata`,()=>{this.trigger(`selectedinitialmedia`)})}),this.mainPlaylistLoader_.on(`loadedplaylist`,()=>{this.loadOnPlay_&&this.tech_.off(`play`,this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||=this.selectPlaylist(),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,`initial`),!(this.sourceType_===`vhs-json`&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on(`error`,()=>{let e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on(`mediachanging`,()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on(`mediachange`,()=>{let e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;rd(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_===`dash`&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:`mediachange`,bubbles:!0})}),this.mainPlaylistLoader_.on(`playlistunchanged`,()=>{let e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!==`playlist-unchanged`&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:`Playlist no longer updating.`,reason:`playlist-unchanged`}}),this.tech_.trigger(`playliststuck`))}),this.mainPlaylistLoader_.on(`renditiondisabled`,()=>{this.tech_.trigger({type:`usage`,name:`vhs-rendition-disabled`})}),this.mainPlaylistLoader_.on(`renditionenabled`,()=>{this.tech_.trigger({type:`usage`,name:`vhs-rendition-enabled`})}),[`manifestrequeststart`,`manifestrequestcomplete`,`manifestparsestart`,`manifestparsecomplete`,`playlistrequeststart`,`playlistrequestcomplete`,`playlistparsestart`,`playlistparsecomplete`,`renditiondisabled`,`renditionenabled`].forEach(e=>{this.mainPlaylistLoader_.on(e,e=>{this.player_.trigger(R({},e))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){let n=e.mediaGroups||{},r=!0,i=Object.keys(n.AUDIO);for(let e in n.AUDIO)for(let t in n.AUDIO[e])n.AUDIO[e][t].uri||(r=!1);r&&this.tech_.trigger({type:`usage`,name:`vhs-demuxed`}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:`usage`,name:`vhs-webvtt`}),Vm.Playlist.isAes(t)&&this.tech_.trigger({type:`usage`,name:`vhs-aes`}),i.length&&Object.keys(n.AUDIO[i[0]]).length>1&&this.tech_.trigger({type:`usage`,name:`vhs-alternate-audio`}),this.useCueTags_&&this.tech_.trigger({type:`usage`,name:`vhs-playlist-cue-tags`})}shouldSwitchToMedia_(e){let t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,n=this.tech_.currentTime(),r=this.bufferLowWaterLine(),i=this.bufferHighWaterLine(),a=this.tech_.buffered();return Wm({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:r,bufferHighWaterLine:i,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on(`bandwidthupdate`,()=>{this.checkABR_(`bandwidthupdate`),this.tech_.trigger(`bandwidthupdate`)}),this.mainSegmentLoader_.on(`timeout`,()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on(`progress`,()=>{this.trigger(`progress`)}),this.mainSegmentLoader_.on(`error`,()=>{let e=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainSegmentLoader_.on(`appenderror`,()=>{this.error=this.mainSegmentLoader_.error_,this.trigger(`error`)}),this.mainSegmentLoader_.on(`syncinfoupdate`,()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on(`timestampoffset`,()=>{this.tech_.trigger({type:`usage`,name:`vhs-timestamp-offset`})}),this.audioSegmentLoader_.on(`syncinfoupdate`,()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on(`appenderror`,()=>{this.error=this.audioSegmentLoader_.error_,this.trigger(`error`)}),this.mainSegmentLoader_.on(`ended`,()=>{this.logger_(`main segment loader ended`),this.onEndOfStream()}),this.timelineChangeController_.on(`audioTimelineBehind`,()=>{let e=this.audioSegmentLoader_.pendingSegment_;if(!e||!e.segment||!e.segment.syncInfo)return;let t=e.segment.syncInfo.end+.01;this.tech_.setCurrentTime(t)}),this.timelineChangeController_.on(`fixBadTimelineChange`,()=>{this.logger_(`Fix bad timeline change. Restarting al segment loaders...`),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on(`earlyabort`,e=>{this.bufferBasedABR||(this.delegateLoaders_(`all`,[`abort`]),this.excludePlaylist({error:{message:`Aborted early because there isn't enough bandwidth to complete the request without rebuffering.`},playlistExclusionDuration:10}))});let e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();let e=this.getCodecsOrExclude_();e&&this.sourceUpdater_.addOrChangeSourceBuffers(e)};this.mainSegmentLoader_.on(`trackinfo`,e),this.audioSegmentLoader_.on(`trackinfo`,e),this.mainSegmentLoader_.on(`fmp4`,()=>{this.triggeredFmp4Usage||=(this.tech_.trigger({type:`usage`,name:`vhs-fmp4`}),!0)}),this.audioSegmentLoader_.on(`fmp4`,()=>{this.triggeredFmp4Usage||=(this.tech_.trigger({type:`usage`,name:`vhs-fmp4`}),!0)}),this.audioSegmentLoader_.on(`ended`,()=>{this.logger_(`audioSegmentLoader ended`),this.onEndOfStream()}),[`segmentselected`,`segmentloadstart`,`segmentloaded`,`segmentkeyloadstart`,`segmentkeyloadcomplete`,`segmentdecryptionstart`,`segmentdecryptioncomplete`,`segmenttransmuxingstart`,`segmenttransmuxingcomplete`,`segmenttransmuxingtrackinfoavailable`,`segmenttransmuxingtiminginfoavailable`,`segmentappendstart`,`appendsdone`,`bandwidthupdated`,`timelinechange`,`codecschange`].forEach(e=>{this.mainSegmentLoader_.on(e,e=>{this.player_.trigger(R({},e))}),this.audioSegmentLoader_.on(e,e=>{this.player_.trigger(R({},e))}),this.subtitleSegmentLoader_.on(e,e=>{this.player_.trigger(R({},e))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){e&&e===this.mainPlaylistLoader_.media()?this.logger_(`skipping fastQualityChange because new media is same as old`):(this.switchMedia_(e,`fast-quality`),this.waitingForFastQualityPlaylistReceived_=!0)}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();let e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){let e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){let t=this.seekable();if(!t.length)return!1;let n=t.end(0),r=n;if(e.start){let i=e.start.timeOffset;if(i<0){let a=this.mainPlaylistLoader_.main,o=n+Vm.Playlist.liveEdgeDelay(a,e);r=Math.max(Math.min(o+i,n),t.start(0))}else r=Math.min(n,i)}this.trigger(`firstplay`),this.tech_.setCurrentTime(r)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){let e=this.tech_.play();e!==void 0&&typeof e.then==`function`&&e.then(null,e=>{})}this.trigger(`sourceopen`)}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;let e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;let t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger(`durationchange`)}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){let t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e&&=this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;let t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;let n=Vm.Playlist.playlistEnd(e,t),r=this.tech_.currentTime(),i=this.tech_.buffered();if(!i.length)return n-r<=Tu;let a=i.end(i.length-1);return a-r<=Tu&&n-a<=Tu}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e||=this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState===`open`?this.sourceUpdater_.endOfStream(`network`):this.trigger(`error`);return}e.playlistErrors_++;let r=this.mainPlaylistLoader_.main.playlists,i=r.filter(Qu),a=i.length===1&&i[0]===e;if(r.length===1&&n!==1/0)return Z.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger(`retryplaylist`),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){let t=this.pathwayAttribute_(e),n=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(t),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(t)},n);return}let t=!1;r.forEach(n=>{if(n===e)return;let r=n.excludeUntil;r!==void 0&&r!==1/0&&(t=!0,delete n.excludeUntil)}),t&&(Z.log.warn(`Removing other playlists from the exclusion list because the last rendition is about to be excluded.`),this.tech_.trigger(`retryplaylist`))}let o;o=e.playlistErrors_>this.maxPlaylistRetries?1/0:Date.now()+n*1e3,e.excludeUntil=o,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger(`excludeplaylist`),this.tech_.trigger({type:`usage`,name:`vhs-rendition-excluded`});let s=this.selectPlaylist();if(!s){this.error=`Playback cannot continue. No available working or supported playlists.`,this.trigger(`error`);return}let c=t.internal?this.logger_:Z.log.warn,l=t.message?` `+t.message:``;c(`${t.internal?`Internal problem`:`Problem`} encountered with playlist ${e.id}.${l} Switching to playlist ${s.id}.`),s.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_(`audio`,[`abort`,`pause`]),s.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_(`subtitle`,[`abort`,`pause`]),this.delegateLoaders_(`main`,[`abort`,`pause`]);let u=s.targetDuration/2*1e3||5e3,d=typeof s.lastRequest==`number`&&Date.now()-s.lastRequest<=u;return this.switchMedia_(s,`exclude`,a||d)}pauseLoading(){this.delegateLoaders_(`all`,[`abort`,`pause`]),this.stopABRTimer_()}delegateLoaders_(e,t){let n=[],r=e===`all`;(r||e===`main`)&&n.push(this.mainPlaylistLoader_);let i=[];(r||e===`audio`)&&i.push(`AUDIO`),(r||e===`subtitle`)&&(i.push(`CLOSED-CAPTIONS`),i.push(`SUBTITLES`)),i.forEach(e=>{let t=this.mediaTypes_[e]&&this.mediaTypes_[e].activePlaylistLoader;t&&n.push(t)}),[`main`,`audio`,`subtitle`].forEach(t=>{let r=this[`${t}SegmentLoader_`];r&&(e===t||e===`all`)&&n.push(r)}),n.forEach(e=>t.forEach(t=>{typeof e[t]==`function`&&e[t]()}))}setCurrentTime(e){let t=Du(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;let e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Vm.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){let n=e.media();if(!n)return null;let r=this.syncController_.getMediaSequenceSync(t);if(r&&r.isReliable){let e=r.start,t=r.end;if(!isFinite(e)||!isFinite(t))return null;let i=Vm.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n);return Su([[e,Math.max(e,t-i)]])}let i=this.syncController_.getExpiredTime(n,this.duration());if(i===null)return null;let a=Vm.Playlist.seekable(n,i,Vm.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;let n=e.start(0),r=e.end(0),i=t.start(0),a=t.end(0);return i>r||n>a?e:Su([[Math.max(n,i),Math.min(r,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;let e=this.getSeekableRange_(this.mainPlaylistLoader_,`main`);if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,`audio`),!t))return;let n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${ju(this.seekable_)}]`);let r={seekableRanges:this.seekable_};this.trigger({type:`seekablerangeschanged`,metadata:r}),this.tech_.trigger(`seekablechanged`)}updateDuration(e){if(this.updateDuration_&&=(this.mediaSource.removeEventListener(`sourceopen`,this.updateDuration_),null),this.mediaSource.readyState!==`open`){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener(`sourceopen`,this.updateDuration_);return}if(e){let e=this.seekable();if(!e.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<e.end(e.length-1))&&this.sourceUpdater_.setDuration(e.end(e.length-1));return}let t=this.tech_.buffered(),n=Vm.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}dispose(){this.trigger(`dispose`),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off(`play`,this.loadOnPlay_),[`AUDIO`,`SUBTITLES`].forEach(e=>{let t=this.mediaTypes_[e].groups;for(let e in t)t[e].forEach(e=>{e.playlistLoader&&e.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener(`sourceopen`,this.updateDuration_),this.mediaSource.removeEventListener(`durationchange`,this.handleDurationChange_),this.mediaSource.removeEventListener(`sourceopen`,this.handleSourceOpen_),this.mediaSource.removeEventListener(`sourceended`,this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){let e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),n=!e||!!this.audioSegmentLoader_.getCurrentMediaInfo_();return!(!t||!n)}getCodecsOrExclude_(){let e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;let n=Ed(this.main(),t),r={},i=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(r.video=n.video||e.main.videoCodec||Mt),e.main.isMuxed&&(r.video+=`,${n.audio||e.main.audioCodec||jt}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||i)&&(r.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||jt,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!r.audio&&!r.video){this.excludePlaylist({playlistToExclude:t,error:{message:`Could not determine codecs for playlist.`},playlistExclusionDuration:1/0});return}let a=(e,t)=>e?kt(t,this.usingManagedMediaSource_):At(t),o={},s;if([`video`,`audio`].forEach(function(t){if(r.hasOwnProperty(t)&&!a(e[t].isFmp4,r[t])){let n=e[t].isFmp4?`browser`:`muxer`;o[n]=o[n]||[],o[n].push(r[t]),t===`audio`&&(s=n)}}),i&&s&&t.attributes.AUDIO){let e=t.attributes.AUDIO;this.main().playlists.forEach(n=>{(n.attributes&&n.attributes.AUDIO)===e&&n!==t&&(n.excludeUntil=1/0)}),this.logger_(`excluding audio group ${e} as ${s} does not support codec(s): "${r.audio}"`)}if(Object.keys(o).length){let e=Object.keys(o).reduce((e,t)=>(e&&(e+=`, `),e+=`${t} does not support codec(s): "${o[t].join(`,`)}"`,e),``)+`.`;this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:e},playlistExclusionDuration:1/0})}else{if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){let e=[];if([`video`,`audio`].forEach(t=>{let n=(wt(this.sourceUpdater_.codecs[t]||``)[0]||{}).type,i=(wt(r[t]||``)[0]||{}).type;n&&i&&n.toLowerCase()!==i.toLowerCase()&&e.push(`"${this.sourceUpdater_.codecs[t]}" -> "${r[t]}"`)}),e.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${e.join(`, `)}.`,internal:!0},playlistExclusionDuration:1/0});return}}return r}}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!==`open`||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;let e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);let t=[e.video,e.audio].filter(Boolean).join(`,`);this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){let e=this.main().playlists,t=[];Object.keys(e).forEach(n=>{let r=e[n];if(t.indexOf(r.id)!==-1)return;t.push(r.id);let i=Ed(this.main,r),a=[];i.audio&&!At(i.audio)&&!kt(i.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${i.audio}`),i.video&&!At(i.video)&&!kt(i.video,this.usingManagedMediaSource_)&&a.push(`video codec ${i.video}`),i.text&&i.text===`stpp.ttml.im1t`&&a.push(`text codec ${i.text}`),a.length&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id} for unsupported: ${a.join(`, `)}`))})}excludeIncompatibleVariants_(e){let t=[],n=this.main().playlists,r=wd(wt(e)),i=Td(r),a=r.video&&wt(r.video)[0]||null,o=r.audio&&wt(r.audio)[0]||null;Object.keys(n).forEach(e=>{let r=n[e];if(t.indexOf(r.id)!==-1||r.excludeUntil===1/0)return;t.push(r.id);let s=[],c=Ed(this.mainPlaylistLoader_.main,r),l=Td(c);if(c.audio||c.video){if(l!==i&&s.push(`codec count "${l}" !== "${i}"`),!this.sourceUpdater_.canChangeType()){let e=c.video&&wt(c.video)[0]||null,t=c.audio&&wt(c.audio)[0]||null;e&&a&&e.type.toLowerCase()!==a.type.toLowerCase()&&s.push(`video codec "${e.type}" !== "${a.type}"`),t&&o&&t.type.toLowerCase()!==o.type.toLowerCase()&&s.push(`audio codec "${t.type}" !== "${o.type}"`)}s.length&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id}: ${s.join(` && `)}`))}})}updateAdCues_(e){let t=0,n=this.seekable();n.length&&(t=n.start(0)),mm(e,this.cueTagsTrack_,t)}goalBufferLength(){let e=this.tech_.currentTime(),t=bf.GOAL_BUFFER_LENGTH,n=bf.GOAL_BUFFER_LENGTH_RATE,r=Math.max(t,bf.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,r)}bufferLowWaterLine(){let e=this.tech_.currentTime(),t=bf.BUFFER_LOW_WATER_LINE,n=bf.BUFFER_LOW_WATER_LINE_RATE,r=Math.max(t,bf.MAX_BUFFER_LOW_WATER_LINE),i=Math.max(t,bf.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?i:r)}bufferHighWaterLine(){return bf.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){Ep(this.inbandTextTracks_,`com.apple.streaming`,this.tech_),Tp({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){let r=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();Ep(this.inbandTextTracks_,e,this.tech_),Sp({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:r,videoDuration:n})}pathwayAttribute_(e){return e.attributes[`PATHWAY-ID`]||e.attributes.serviceLocation}initContentSteeringController_(){let e=this.main();if(e.contentSteering){for(let t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart?this.contentSteeringController_.requestSteeringManifest(!0):this.tech_.one(`canplay`,()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on(`content-steering`,this.excludeThenChangePathway_.bind(this)),[`contentsteeringloadstart`,`contentsteeringloadcomplete`,`contentsteeringparsed`].forEach(e=>{this.contentSteeringController_.on(e,e=>{this.trigger(R({},e))})}),this.sourceType_===`dash`&&this.mainPlaylistLoader_.on(`loadedplaylist`,()=>{let e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{let t=this.contentSteeringController_.getAvailablePathways(),n=[];for(let r of e.playlists){let e=r.attributes.serviceLocation;if(e&&(n.push(e),!t.has(e)))return!0}return!(n.length||!t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){let e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();let t=this.main().playlists,n=new Set,r=!1;Object.keys(t).forEach(i=>{let a=t[i],o=this.pathwayAttribute_(a),s=o&&e!==o;a.excludeUntil===1/0&&a.lastExcludeReason_===`content-steering`&&!s&&(delete a.excludeUntil,delete a.lastExcludeReason_,r=!0);let c=!a.excludeUntil&&a.excludeUntil!==1/0;!n.has(a.id)&&s&&c&&(n.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_=`content-steering`,this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_===`DASH`&&Object.keys(this.mediaTypes_).forEach(t=>{let n=this.mediaTypes_[t];if(n.activePlaylistLoader){let t=n.activePlaylistLoader.media_;t&&t.attributes.serviceLocation!==e&&(r=!0)}}),r&&this.changeSegmentPathway_()}handlePathwayClones_(){let e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||n&&n.size){for(let[e,r]of t.entries())n.get(e)||(this.mainPlaylistLoader_.updateOrDeleteClone(r),this.contentSteeringController_.excludePathway(e));for(let[r,i]of n.entries()){let n=t.get(r);n?this.equalPathwayClones_(n,i)||(this.mainPlaylistLoader_.updateOrDeleteClone(i,!0),this.contentSteeringController_.addAvailablePathway(r)):(e.filter(e=>e.attributes[`PATHWAY-ID`]===i[`BASE-ID`]).forEach(e=>{this.mainPlaylistLoader_.addClonePathway(i,e)}),this.contentSteeringController_.addAvailablePathway(r))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e[`BASE-ID`]!==t[`BASE-ID`]||e.ID!==t.ID||e[`URI-REPLACEMENT`].HOST!==t[`URI-REPLACEMENT`].HOST)return!1;let n=e[`URI-REPLACEMENT`].PARAMS,r=t[`URI-REPLACEMENT`].PARAMS;for(let e in n)if(n[e]!==r[e])return!1;for(let e in r)if(n[e]!==r[e])return!1;return!0}changeSegmentPathway_(){let e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_===`DASH`&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,`content-steering`)}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0,t=`non-usable`;this.mainPlaylistLoader_.main.playlists.forEach(n=>{let r=this.mainPlaylistLoader_.getKeyIdSet(n);r&&r.size&&r.forEach(r=>{let i=`usable`,a=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===i,o=n.lastExcludeReason_===t&&n.excludeUntil===1/0;a?a&&o&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${r} is ${i}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${i}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(e=>{let n=e&&e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height<720,r=e.excludeUntil===1/0&&e.lastExcludeReason_===t;n&&r&&(delete e.excludeUntil,Z.log.warn(`enabling non-HD playlist ${e.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){let n=(typeof e==`string`?e:lm(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${n} added to the keyStatusMap`),this.keyStatusMap_.set(n,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off(`loadedplaylist`,this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on(`loadedplaylist`,this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const Km=(e,t,n)=>r=>{let i=e.main.playlists[t],a=Zu(i),o=Qu(i);if(r===void 0)return o;r?delete i.disabled:i.disabled=!0;let s={renditionInfo:{id:t,bandwidth:i.attributes.BANDWIDTH,resolution:i.attributes.RESOLUTION,codecs:i.attributes.CODECS},cause:`fast-quality`};return r!==o&&!a&&(r?(n(i),e.trigger({type:`renditionenabled`,metadata:s})):e.trigger({type:`renditiondisabled`,metadata:s})),r};class qm{constructor(e,t,n){let{playlistController_:r}=e,i=r.fastQualityChange_.bind(r);if(t.attributes){let e=t.attributes.RESOLUTION;this.width=e&&e.width,this.height=e&&e.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes[`FRAME-RATE`]}this.codecs=Ed(r.main(),t),this.playlist=t,this.id=n,this.enabled=Km(e.playlists,t.id,i)}}const Jm=function(e){e.representations=()=>{let t=e.playlistController_.main(),n=od(t)?e.playlistController_.getAudioTrackPlaylists_():t.playlists;return n?n.filter(e=>!Zu(e)).map((t,n)=>new qm(e,t,t.id)):[]}},Ym=[`seeking`,`seeked`,`pause`,`playing`,`error`];class Xm extends Z.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=xu(`PlaybackWatcher`),this.logger_(`initialize`);let t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),r=()=>this.techWaiting_(),i=()=>this.resetTimeUpdate_(),a=this.playlistController_,o=[`main`,`subtitle`,`audio`],s={};o.forEach(e=>{s[e]={reset:()=>this.resetSegmentDownloads_(e),updateend:()=>this.checkSegmentDownloads_(e)},a[`${e}SegmentLoader_`].on(`appendsdone`,s[e].updateend),a[`${e}SegmentLoader_`].on(`playlistupdate`,s[e].reset),this.tech_.on([`seeked`,`seeking`],s[e].reset)});let c=e=>{[`main`,`audio`].forEach(t=>{a[`${t}SegmentLoader_`][e](`appended`,this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),c(`off`))},this.clearSeekingAppendCheck_=()=>c(`off`),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),c(`on`)},this.tech_.on(`seeked`,this.clearSeekingAppendCheck_),this.tech_.on(`seeking`,this.watchForBadSeeking_),this.tech_.on(`waiting`,r),this.tech_.on(Ym,i),this.tech_.on(`canplay`,n),this.tech_.one(`play`,t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_(`dispose`),this.tech_.off(`waiting`,r),this.tech_.off(Ym,i),this.tech_.off(`canplay`,n),this.tech_.off(`play`,t),this.tech_.off(`seeking`,this.watchForBadSeeking_),this.tech_.off(`seeked`,this.clearSeekingAppendCheck_),o.forEach(e=>{a[`${e}SegmentLoader_`].off(`appendsdone`,s[e].updateend),a[`${e}SegmentLoader_`].off(`playlistupdate`,s[e].reset),this.tech_.off([`seeked`,`seeking`],s[e].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){let t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){let t=this.playlistController_,n=t[`${e}SegmentLoader_`],r=n.buffered_(),i=Pu(this[`${e}Buffered_`],r);if(this[`${e}Buffered_`]=r,i){let n={bufferedRanges:r};t.trigger({type:`bufferedrangeschanged`,metadata:n}),this.resetSegmentDownloads_(e)}else this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:n.playlist_&&n.playlist_.id,buffered:Nu(r)}),!(this[`${e}StalledDownloads_`]<10)&&(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:`usage`,name:`vhs-${e}-download-exclusion`}),e!==`subtitle`&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;let e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Tu>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(Su([this.lastRecordedTime,e]));let t={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:`playedrangeschanged`,metadata:t}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;let e=this.seekable(),t=this.tech_.currentTime(),n=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow),r;if(n&&(r=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){let t=e.start(0);r=t+(t===e.end(0)?0:Tu)}if(r!==void 0)return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${ju(e)}. Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0;let i=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),o=i.audioBuffer?i.audioBuffered():null,s=i.videoBuffer?i.videoBuffered():null,c=this.media(),l=c.partTargetDuration?c.partTargetDuration:(c.targetDuration-wu)*2,u=[o,s];for(let e=0;e<u.length;e++)if(u[e]&&Iu(u[e],t)<l)return!1;let d=Ou(a,t);return d.length!==0&&(r=d.start(0)+Tu,this.logger_(`Buffered region starts (${d.start(0)}) just beyond seek point (${t}). Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0)}waiting_(){if(this.techWaiting_())return;let e=this.tech_.currentTime(),t=this.tech_.buffered(),n=Du(t,e);n.length&&e+3<=n.end(0)&&(this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:`usage`,name:`vhs-unknown-waiting`}))}techWaiting_(){let e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){let n=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${n}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(n),this.tech_.trigger({type:`usage`,name:`vhs-live-resync`}),!0}let n=this.tech_.vhs.playlistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:`usage`,name:`vhs-video-underflow`}),!0;let i=Ou(r,t);return i.length>0&&(this.logger_(`Stopped at ${t} and seeking to ${i.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0)}afterSeekableWindow_(e,t,n,r=!1){if(!e.length)return!1;let i=e.end(e.length-1)+Tu,a=!n.endList,o=typeof n.partTargetDuration==`number`;return a&&(o||r)&&(i=e.end(e.length-1)+n.targetDuration*3),t>i}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:n}){if(!e)return;let r;if(e.length&&t.length){let i=Du(e,n-3),a=Du(e,n),o=Du(t,n);o.length&&!a.length&&i.length&&(r={start:i.end(0),end:o.end(0)})}else Ou(e,n).length||(r=this.gapFromVideoUnderflow_(e,n));return r?(this.logger_(`Encountered a gap in video from ${r.start} to ${r.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){let t=this.tech_.buffered(),n=this.tech_.currentTime(),r=Ou(t,n);if(this.resetTimeUpdate_(),r.length===0||n!==e)return;this.logger_(`skipTheGap_:`,`currentTime:`,n,`scheduled currentTime:`,e,`nextRange start:`,r.start(0)),this.tech_.setCurrentTime(r.start(0)+wu);let i={gapInfo:{from:n,to:r.start(0)}};this.playlistController_.trigger({type:`gapjumped`,metadata:i}),this.tech_.trigger({type:`usage`,name:`vhs-gap-skip`})}gapFromVideoUnderflow_(e,t){let n=ku(e);for(let e=0;e<n.length;e++){let r=n.start(e),i=n.end(e);if(t-r<4&&t-r>2)return{start:r,end:i}}return null}}const Zm={errorInterval:30,getSource(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},Qm=function(e,t){let n=0,r=0,i=Q(Zm,t);e.ready(()=>{e.trigger({type:`usage`,name:`vhs-error-reload-initialized`})});let a=function(){r&&e.currentTime(r)},o=function(t){t!=null&&(r=e.duration()!==1/0&&e.currentTime()||0,e.one(`loadedmetadata`,a),e.src(t),e.trigger({type:`usage`,name:`vhs-error-reload`}),e.play())},s=function(){if(Date.now()-n<i.errorInterval*1e3)e.trigger({type:`usage`,name:`vhs-error-reload-canceled`});else if(!i.getSource||typeof i.getSource!=`function`)Z.log.error(`ERROR: reloadSourceOnError - The option getSource must be a function!`);else return n=Date.now(),i.getSource.call(e,o)},c=function(){e.off(`loadedmetadata`,a),e.off(`error`,s),e.off(`dispose`,c)};e.on(`error`,s),e.on(`dispose`,c),e.reloadSourceOnError=function(t){c(),Qm(e,t)}},$m=function(e){Qm(this,e)};var eh=`3.17.5`,th=`7.1.0`,nh=`1.4.0`,rh=`7.2.0`,ih=`4.0.2`;const ah={PlaylistLoader:Ld,Playlist:sd,utils:Zd,STANDARD_PLAYLIST_SELECTOR:pp,INITIAL_PLAYLIST_SELECTOR:gp,lastBandwidthSelector:pp,movingAverageBandwidthSelector:mp,comparePlaylistBandwidth:up,comparePlaylistResolution:dp,xhr:Vd()};Object.keys(bf).forEach(e=>{Object.defineProperty(ah,e,{get(){return Z.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),bf[e]},set(t){Z.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),typeof t!=`number`||t<0?Z.log.warn(`value of Vhs.${e} must be greater than or equal to 0`):bf[e]=t}})});const oh=`videojs-vhs`,sh=function(e,t){let n=t.media(),r=-1;for(let t=0;t<e.length;t++)if(e[t].id===n.id){r=t;break}e.selectedIndex_=r,e.trigger({selectedIndex:r,type:`change`})},ch=function(e,t){t.representations().forEach(t=>{e.addQualityLevel(t)}),sh(e,t.playlists)};ah.canPlaySource=function(){return Z.log.warn(`VHS is no longer a tech. Please remove it from your player's techOrder.`)};const lh=(e,t,n)=>{if(!e)return e;let r={};t&&t.attributes&&t.attributes.CODECS&&(r=wd(wt(t.attributes.CODECS))),n&&n.attributes&&n.attributes.CODECS&&(r.audio=n.attributes.CODECS);let i=Ot(r.video),a=Ot(r.audio),o={};for(let n in e)o[n]={},a&&(o[n].audioContentType=a),i&&(o[n].videoContentType=i),t.contentProtection&&t.contentProtection[n]&&t.contentProtection[n].pssh&&(o[n].pssh=t.contentProtection[n].pssh),typeof e[n]==`string`&&(o[n].url=e[n]);return Q(e,o)},uh=(e,t)=>e.reduce((e,n)=>{if(!n.contentProtection)return e;let r=t.reduce((e,t)=>{let r=n.contentProtection[t];return r&&r.pssh&&(e[t]={pssh:r.pssh}),e},{});return Object.keys(r).length&&e.push(r),e},[]),dh=({player:e,sourceKeySystems:t,audioMedia:n,mainPlaylists:r})=>{if(!e.eme.initializeMediaKeys)return Promise.resolve();let i=n?r.concat([n]):r,a=uh(i,Object.keys(t)),o=[],s=[];return a.forEach(t=>{s.push(new Promise((t,n)=>{e.tech_.one(`keysessioncreated`,t)})),o.push(new Promise((n,r)=>{e.eme.initializeMediaKeys({keySystems:t},e=>{e?r(e):n()})}))}),Promise.race([Promise.all(o),Promise.race(s)])},fh=({player:e,sourceKeySystems:t,media:n,audioMedia:r})=>{let i=lh(t,n,r);return i?(e.currentSource().keySystems=i,i&&!e.eme?(Z.log.warn(`DRM encrypted source cannot be decrypted without a DRM plugin`),!1):!0):!1},ph=()=>{if(!x.localStorage)return null;let e=x.localStorage.getItem(oh);if(!e)return null;try{return JSON.parse(e)}catch{return null}},mh=e=>{if(!x.localStorage)return!1;let t=ph();t=t?Q(t,e):e;try{x.localStorage.setItem(oh,JSON.stringify(t))}catch{return!1}return t},hh=e=>e.toLowerCase().indexOf(`data:application/vnd.videojs.vhs+json,`)===0?JSON.parse(e.substring(e.indexOf(`,`)+1)):e,gh=(e,t)=>{e._requestCallbackSet||=new Set,e._requestCallbackSet.add(t)},_h=(e,t)=>{e._responseCallbackSet||=new Set,e._responseCallbackSet.add(t)},vh=(e,t)=>{e._requestCallbackSet&&(e._requestCallbackSet.delete(t),e._requestCallbackSet.size||delete e._requestCallbackSet)},yh=(e,t)=>{e._responseCallbackSet&&(e._responseCallbackSet.delete(t),e._responseCallbackSet.size||delete e._responseCallbackSet)};ah.supportsNativeHls=function(){if(!F||!F.createElement)return!1;let e=F.createElement(`video`);return Z.getTech(`Html5`).isSupported()?[`application/vnd.apple.mpegurl`,`audio/mpegurl`,`audio/x-mpegurl`,`application/x-mpegurl`,`video/x-mpegurl`,`video/mpegurl`,`application/mpegurl`].some(function(t){return/maybe|probably/i.test(e.canPlayType(t))}):!1}(),ah.supportsNativeDash=function(){return!F||!F.createElement||!Z.getTech(`Html5`).isSupported()?!1:/maybe|probably/i.test(F.createElement(`video`).canPlayType(`application/dash+xml`))}(),ah.supportsTypeNatively=e=>e===`hls`?ah.supportsNativeHls:e===`dash`&&ah.supportsNativeDash,ah.isSupported=function(){return Z.log.warn(`VHS is no longer a tech. Please remove it from your player's techOrder.`)},ah.xhr.onRequest=function(e){gh(ah.xhr,e)},ah.xhr.onResponse=function(e){_h(ah.xhr,e)},ah.xhr.offRequest=function(e){vh(ah.xhr,e)},ah.xhr.offResponse=function(e){yh(ah.xhr,e)};const bh=Z.getComponent(`Component`);class xh extends bh{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth==`number`&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=xu(`VhsHandler`),t.options_&&t.options_.playerId){let e=Z.getPlayer(t.options_.playerId);this.player_=e}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw Error(`Overriding native VHS requires emulated tracks. See https://git.io/vMpjB`);this.on(F,[`fullscreenchange`,`webkitfullscreenchange`,`mozfullscreenchange`,`MSFullscreenChange`],e=>{let t=F.fullscreenElement||F.webkitFullscreenElement||F.mozFullScreenElement||F.msFullscreenElement;t&&t.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,`seeking`,function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,`error`,function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,`play`,this.play)}setOptions_(e={}){if(this.options_=Q(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!1,this.options_.useBandwidthFromLocalStorage=this.source_.useBandwidthFromLocalStorage===void 0?this.options_.useBandwidthFromLocalStorage||!1:this.source_.useBandwidthFromLocalStorage,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi===void 0||this.options_.useNetworkInformationApi,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!=`number`&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!=`number`&&this.options_.useBandwidthFromLocalStorage){let e=ph();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:`usage`,name:`vhs-bandwidth-from-local-storage`})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:`usage`,name:`vhs-throughput-from-local-storage`}))}typeof this.options_.bandwidth!=`number`&&(this.options_.bandwidth=bf.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===bf.INITIAL_BANDWIDTH,[`withCredentials`,`useDevicePixelRatio`,`usePlayerObjectFit`,`customPixelRatio`,`limitRenditionByPlayerDimensions`,`bandwidth`,`customTagParsers`,`customTagMappers`,`cacheEncryptionKeys`,`playlistSelector`,`initialPlaylistSelector`,`bufferBasedABR`,`liveRangeSafeTimeDelta`,`llhls`,`useForcedSubtitles`,`useNetworkInformationApi`,`useDtsForTimestampOffset`,`exactManifestTimings`,`leastPixelDiffSelector`].forEach(e=>{this.source_[e]!==void 0&&(this.options_[e]=this.source_[e])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;let t=this.options_.customPixelRatio;typeof t==`number`&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=hh(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=ah,this.options_.sourceType=Ft(t),this.options_.seekTo=e=>{this.tech_.setCurrentTime(e)},this.options_.player_=this.player_,this.playlistController_=new Gm(this.options_);let n=Q({liveRangeSafeTimeDelta:Tu},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new Xm(n),this.attachStreamingEventListeners_(),this.playlistController_.on(`error`,()=>{let e=Z.players[this.tech_.options_.playerId],t=this.playlistController_.error;typeof t==`object`&&!t.code?t.code=3:typeof t==`string`&&(t={message:t,code:3}),e.error(t)});let r=this.options_.bufferBasedABR?ah.movingAverageBandwidthSelector(.55):ah.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.playlistController_.selectInitialPlaylist=ah.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(e){this.playlistController_.selectPlaylist=e.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(e){this.playlistController_.mainSegmentLoader_.throughput.rate=e,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let e=this.playlistController_.mainSegmentLoader_.bandwidth,t=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,n=1e7;if(this.options_.useNetworkInformationApi&&t){let r=t.downlink*1e3*1e3;e=r>=n&&e>=n?Math.max(e,r):r}return e},set(e){this.playlistController_.mainSegmentLoader_.bandwidth=e,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){let e=1/(this.bandwidth||1),t;return t=this.throughput>0?1/this.throughput:0,Math.floor(1/(e+t))},set(){Z.log.error(`The "systemBandwidth" property is read-only`)}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Nu(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Nu(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one(`canplay`,this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on(`bandwidthupdate`,()=>{this.options_.useBandwidthFromLocalStorage&&mh({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on(`selectedinitialmedia`,()=>{Jm(this)}),this.playlistController_.sourceUpdater_.on(`createdsourcebuffers`,()=>{this.setupEme_()}),this.on(this.playlistController_,`progress`,function(){this.tech_.trigger(`progress`)}),this.on(this.playlistController_,`firstplay`,function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(Z.browser.IS_ANY_SAFARI||Z.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType===`hls`&&typeof this.tech_.addSourceElement==`function`?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){let e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_(`waiting for EME key session creation`),dh({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_(`created EME key session`),this.playlistController_.sourceUpdater_.initializedEme()}).catch(e=>{this.logger_(`error while creating EME key session`,e),this.player_.error({message:`Failed to initialize media keys for EME`,code:3})})}handleWaitingForKey_(){this.logger_(`waitingforkey fired, attempting to create any new key sessions`),this.createKeySessions_()}setupEme_(){let e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=fh({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});this.player_.tech_.on(`keystatuschange`,e=>{this.playlistController_.updatePlaylistByKeyStatus(e.keyId,e.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on(`waitingforkey`,this.handleWaitingForKey_),t?this.createKeySessions_():this.playlistController_.sourceUpdater_.initializedEme()}setupQualityLevels_(){let e=Z.players[this.tech_.options_.playerId];e&&e.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on(`selectedinitialmedia`,()=>{ch(this.qualityLevels_,this)}),this.playlists.on(`mediachange`,()=>{sh(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":eh,"mux.js":th,"mpd-parser":nh,"m3u8-parser":rh,"aes-decrypter":ih}}version(){return this.constructor.version()}canChangeType(){return sm.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off(`waitingforkey`,this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return of({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,r=2){return sf({programTime:e,playlist:this.playlistController_.media(),retryCount:r,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{gh(this.xhr,e)},this.xhr.onResponse=e=>{_h(this.xhr,e)},this.xhr.offRequest=e=>{vh(this.xhr,e)},this.xhr.offResponse=e=>{yh(this.xhr,e)},this.player_.trigger(`xhr-hooks-ready`)}attachStreamingEventListeners_(){[`seekablerangeschanged`,`bufferedrangeschanged`,`contentsteeringloadstart`,`contentsteeringloadcomplete`,`contentsteeringparsed`].forEach(e=>{this.playlistController_.on(e,e=>{this.player_.trigger(R({},e))})}),[`gapjumped`,`playedrangeschanged`].forEach(e=>{this.playbackWatcher_.on(e,e=>{this.player_.trigger(R({},e))})})}}const Sh={name:`videojs-http-streaming`,VERSION:eh,canHandleSource(e,t={}){let n=Q(Z.options,t);return!n.vhs.experimentalUseMMS&&!kt(`avc1.4d400d,mp4a.40.2`,!1)?!1:Sh.canPlayType(e.type,n)},handleSource(e,t,n={}){let r=Q(Z.options,n);return t.vhs=new xh(e,t,r),t.vhs.xhr=Vd(),t.vhs.setupXhrHooks_(),t.vhs.src(e.src,e.type),t.vhs},canPlayType(e,t){let n=Ft(e);if(!n)return``;let r=Sh.getOverrideNative(t);return!ah.supportsTypeNatively(n)||r?`maybe`:``},getOverrideNative(e={}){let{vhs:t={}}=e,n=!(Z.browser.IS_ANY_SAFARI||Z.browser.IS_IOS),{overrideNative:r=n}=t;return r}};kt(`avc1.4d400d,mp4a.40.2`,!0)&&Z.getTech(`Html5`).registerSourceHandler(Sh,0),Z.VhsHandler=xh,Z.VhsSourceHandler=Sh,Z.Vhs=ah,Z.use||Z.registerComponent(`Vhs`,ah),Z.options.vhs=Z.options.vhs||{},Z.getPlugin&&Z.getPlugin(`reloadSourceOnError`)||Z.registerPlugin(`reloadSourceOnError`,$m);let $=class extends t{constructor(){super(...arguments),this._controllerConfigs={autoplay:!1,autoSetup:!1,controls:!1,defaultVolume:.3,disablePictureInPicture:!0,enableDocumentPictureInPicture:!1,enableSmoothSeeking:!0,html5:{nativeAudioTracks:!1,nativeVideoTracks:!1,vhs:{llhls:!0,overrideNative:!0}},inactivityTimeout:0,liveTracker:{liveTolerance:10,trackingThreshold:15},loop:!1,muted:!1,nativeControlsForTouch:!1,normalizeAutoplay:!0,preload:`auto`},this._prevPlayingState=!1,this._retryCount=0,this._qualityLevels=[],this.autoplay=!1,this.currentMetadata=null,this.element=null,this.isLive=!1,this.mimeType=null,this.sensorModel=null,this.started=!1,this.state=`not-ready`,this.waitingTimestamp=null,this._initController=async()=>{if(!this._controller&&this.playerUrl)try{let e={...this._controllerConfigs};this.element=document.createElement(`video`),Z.log.level(`off`),this._controller=Z(this.element,e),this._controller.muted(this.muted),this._controller.loop(this.loop),this._controller.playbackRate(this.rate),this._controller.qualityLevels().on(`addqualitylevel`,e=>this._handleQualityLevel(e)),this._controller.ready(this._handleReady),this._controller.one(`play`,this._handleFirstPlay),this._controller.on(`canplay`,this._handleCanPlay),this._controller.on(`durationchange`,this._handleDurationChange),this._controller.on(`ended`,this._handleEnded),this._controller.on(`error`,this._handleError),this._controller.on(`loadeddata`,this._handleDataLoaded),this._controller.on(`loadedmetadata`,this._handleLoadedMetadata),this._controller.on(`loadstart`,this._handleLoadStart),this._controller.on(`play`,this._handlePlay),this._controller.on(`playing`,this._handlePlaying),this._controller.on(`stalled`,this._handleStalled),this._controller.on(`timeupdate`,this._handleTimeUpdate),this._controller.on(`waiting`,this._handleWaiting),this._controller.on(`xhr-hooks-ready`,this._handleXHRhooksReady),this._controller?.liveTracker.on(`seekableendchange`,()=>this.notifyChange(`livestreamStatus`)),this._controller?.liveTracker.on(`liveedgechange`,()=>this.notifyChange(`livestreamStatus`))}catch{r.getLogger(this).error(`Unable to initialize the player.`),this._controller&&this._controller.dispose()}},this._handleQualityLevel=e=>{if(!e?.qualityLevel)return;let t=e.qualityLevel;this._qualityLevels.push(t),t?.enabled&&(this._set(`videoWidth`,t?.width??0),this._set(`videoHeight`,t?.height??0))},this._handleReady=()=>{this.state=`ready`},this._handleFirstPlay=()=>{this._set(`started`,!0)},this._handleCanPlay=async()=>{if(this._prevPlayingState=this.state===`playing`,this.state=`can-play`,this.autoplay&&!this.started)try{this.muted=!0,await this.play()}catch{r.getLogger(this).info(`Unable to auto start playback. Blocked by the browser.`)}},this._handleCueChange=()=>{if(!this.subtitleTrack?.activeCues?.length)return;let e=this.subtitleTrack?.activeCues,t=f(e);if(!t?.length)return;let n=new Map;for(let e of t)Array.isArray(e.value)?e.tagId===90064?n.set(e.tagId,e):e.value.forEach(e=>{n.set(e.tagId,e)}):n.set(e.tagId,e);n.set(p.EsriVideoWidth,{name:`Video Width`,tagId:p.EsriVideoWidth,value:this._controller?.videoWidth()}),n.set(p.EsriVideoHeight,{name:`Video Height`,tagId:p.EsriVideoHeight,value:this._controller?.videoHeight()}),this.currentMetadata=new Map(n)},this._handleDataLoaded=()=>{this._set(`videoWidth`,this._controller?.videoWidth()),this._set(`videoHeight`,this._controller?.videoHeight())},this._handleDurationChange=()=>{this._controller?.duration()!==0&&(this.notifyChange(`duration`),this.isLive=this._controller?.duration()===1/0||!1,this._setLivestreamStatus(),this.started&&this._controller?.duration()===this._controller?.currentTime()&&this._controller?.trigger(`ended`))},this._handleEnded=()=>{this._controller?.ended()&&this.notifyChange(`ended`)},this._handleError=()=>{let e=this._controller?.error()??null;if(typeof e?.code==`number`&&e?.code<3&&this._retryCount===0)this._retryCount++,setTimeout(()=>{this._controller?.src({type:this.mimeType,src:this.playerUrl}),this._controller?.load()},2e3);else{let t=new n(`Media Error`,e?.message??``);r.getLogger(this).error(t),this.reset()}},this._handleLoadStart=()=>{this.state=`can-play`},this._handleLoadedMetadata=()=>{this.state=`can-play`,this.notifyChange(`buffered`),this.notifyChange(`subtitleTrack`)},this._handlePlay=()=>{this.notifyChange(`ended`)},this._handlePlaying=()=>{this.state=`playing`,this._retryCount=0,this.notifyChange(`ended`)},this._handleStalled=()=>{r.getLogger(this).warn(`Playback is stalled and awaiting data`)},this._handleTimeUpdate=()=>{this._setLivestreamStatus(),this.notifyChange(`currentTime`),this.notifyChange(`buffered`),this.notifyChange(`bufferedPercent`),this._set(`videoWidth`,this._controller?.videoWidth()),this._set(`videoHeight`,this._controller?.videoHeight())},this._handleWaiting=()=>{this.waitingTimestamp=this._controller?.currentTime(),this.state=`waiting`},this._handleXHRhooksReady=()=>{this._controller?.tech(!0)?.vhs.xhr.onRequest(e=>(e.xhr=new c,e))},this._updateSensorModel=()=>{this.currentMetadata?.size&&(this.sensorModel?this.sensorModel.updateSensorModel(this.currentMetadata):this.sensorModel=new d({videoMetadata:this.currentMetadata}))},this._setLivestreamStatus=()=>{if(!this.isLive){this.livestreamStatus=null;return}this._controller?.liveTracker.isTracking()||this._controller?.liveTracker.startTracking();let e={atLiveEdge:this._controller?.liveTracker.atLiveEdge()??null,behindLiveEdge:this._controller?.liveTracker.behindLiveEdge()??null,liveCurrentTime:this._controller?.liveTracker?.liveCurrentTime()??null,liveWindow:this._controller?.liveTracker?.liveWindow()??null,pastSeekEnd:this._controller?.liveTracker?.pastSeekEnd()??null,seekableEnd:this._controller?.liveTracker?.seekableEnd()??null,seekableStart:this._controller?.liveTracker?.seekableStart()??null};this.livestreamStatus={...e},this.notifyChange(`livestreamStatus`),this._controller?.liveTracker.handlePlay(),this._controller?.liveTracker.handleFirstTimeupdate()}}initialize(){this.addHandles([a(()=>this.playerUrl,e=>{e&&this._initController().then(()=>{this.mimeType=m(e),this._controller?.src({src:this.playerUrl,type:this.mimeType})})},o),a(()=>this.subtitleTrack,()=>{this.subtitleTrack&&(this.subtitleTrack.mode=`showing`)},o),a(()=>this.isLive,async e=>{e&&(this._controller?.liveTracker.startTracking(),this.autoplay&&(this.muted=!0,await this.play()))}),a(()=>this.currentMetadata,()=>this._updateSensorModel())]),this.addHandles(s(()=>this.subtitleTrack,`cuechange`,this._handleCueChange),o)}destroy(){this.removeAllHandles(),this._controller?.dispose()}get buffered(){return this._controller?.bufferedEnd()??0}get bufferedPercent(){return this._controller?.bufferedPercent()??0}get crossOrigin(){return this._controller?.crossOrigin()??this._get(`crossOrigin`)}set crossOrigin(e){this._controller?.crossOrigin(e),this._set(`crossOrigin`,e)}get currentTime(){return this._controller?.currentTime()??0}get duration(){return this._controller?.duration()??0}get ended(){return this._controller?.ended()??this._get(`ended`)??!0}set ended(e){this._controller?.trigger(`ended`),this._set(`ended`,e)}get loop(){return this._controller?.loop()??this._get(`loop`)??!1}set loop(e){this._controller?.loop(e),this._set(`loop`,e)}get muted(){return this._controller?.muted()??this._get(`muted`)??!1}set muted(e){this._controller?.muted(e),this._set(`muted`,e)}get playerUrl(){return this._controller?.src()||``}set playerUrl(e){this._set(`playerUrl`,e)}get playing(){return this.ended?!1:this.state===`can-play`?this._prevPlayingState:this.state===`playing`}get playsInline(){return this._controller?.playsinline()??this._get(`playsInline`)??!1}set playsInline(e){this._controller?.playsinline(e),this._set(`playsInline`,e)}get rate(){return this._controller?.playbackRate()??this._get(`rate`)??1}set rate(e){this._controller?.playbackRate(e),this._set(`rate`,e)}get startMode(){return this._controller?.preload()??this._get(`startMode`)??`auto`}set startMode(e){this._controller?.preload(e),this._set(`startMode`,e)}get subtitleTrack(){let e=this._controller?.textTracks();return e?.length?Array.from(e).find(e=>e.kind===`subtitles`):null}get volume(){return this._controller?.volume()??0}set volume(e){let t=i(e,0,1);isNaN(t)||this._controller?.volume(t)}get waiting(){return this.waitingTimestamp?!1:this.waitingTimestamp===this.currentTime||(this.waitingTimestamp=null,!1)}pause(){this._controller?.pause(),this.state=`paused`}async play(){try{!this.started&&this.isLive&&this._controller?.muted(!0),await this._controller?.play(),this.state=`playing`}catch{}}reset(){this._controller&&(this._prevPlayingState=!1,this._retryCount=0,this._set(`started`,!1),this.setCurrentTime(0),this.notifyChange(`buffered`),this.notifyChange(`currentTime`),this.notifyChange(`duration`),this.notifyChange(`waiting`),this._controller?.trigger(`can-play`),this.autoplay||this._controller?.pause())}seekToLiveEdge(){this.isLive?this.state===`playing`&&this._controller?.liveTracker.isTracking()&&this._controller?.liveTracker.seekToLiveEdge():r.getLogger(this).info(`seekToLiveEdge method is only available for livestream playback.`)}setCurrentTime(e){let t=i(e,0,this.duration);this._controller?.currentTime(t),this.notifyChange(`currentTime`)}};e([l()],$.prototype,`autoplay`,void 0),e([l()],$.prototype,`buffered`,null),e([l()],$.prototype,`bufferedPercent`,null),e([l()],$.prototype,`crossOrigin`,null),e([l({readOnly:!0})],$.prototype,`currentTime`,null),e([l()],$.prototype,`currentMetadata`,void 0),e([l({readOnly:!0})],$.prototype,`duration`,null),e([l()],$.prototype,`element`,void 0),e([l({readOnly:!0})],$.prototype,`ended`,null),e([l()],$.prototype,`isLive`,void 0),e([l()],$.prototype,`livestreamStatus`,void 0),e([l()],$.prototype,`loop`,null),e([l()],$.prototype,`mimeType`,void 0),e([l()],$.prototype,`muted`,null),e([l()],$.prototype,`playerUrl`,null),e([l({readOnly:!0})],$.prototype,`playing`,null),e([l()],$.prototype,`playsInline`,null),e([l()],$.prototype,`rate`,null),e([l()],$.prototype,`sensorModel`,void 0),e([l({readOnly:!0})],$.prototype,`started`,void 0),e([l()],$.prototype,`startMode`,null),e([l()],$.prototype,`state`,void 0),e([l()],$.prototype,`subtitleTrack`,null),e([l({readOnly:!0})],$.prototype,`videoHeight`,void 0),e([l({readOnly:!0})],$.prototype,`videoWidth`,void 0),e([l()],$.prototype,`volume`,null),e([l({readOnly:!0})],$.prototype,`waiting`,null),e([l()],$.prototype,`waitingTimestamp`,void 0),$=e([u(`esri.layers.video.VideoController`)],$);export{$ as default};
200
+ `,a=n,o=t;this.start_=a,e.forEach((e,t)=>{let n=this.storage_.get(o),s=a,c=s+e.duration,l=!!(n&&n.segmentSyncInfo&&n.segmentSyncInfo.isAppended),u=new hm({start:s,end:c,appended:l,segmentIndex:t});e.syncInfo=u;let d=a,f=(e.parts||[]).map((e,r)=>{let a=d,s=d+e.duration,c=!!(n&&n.partsSyncInfo&&n.partsSyncInfo[r]&&n.partsSyncInfo[r].isAppended),l=new hm({start:a,end:s,appended:c,segmentIndex:t,partIndex:r});return d=s,i+=`Media Sequence: ${o}.${r} | Range: ${a} --> ${s} | Appended: ${c}\n`,e.syncInfo=l,l});r.set(o,new gm(u,f)),i+=`${vp(e.resolvedUri)} | Media Sequence: ${o} | Range: ${s} --> ${c} | Appended: ${l}\n`,o++,a=c}),this.end_=a,this.storage_=r,this.diagnostics_=i}calculateBaseTime_(e,t,n){if(!this.storage_.size)return 0;if(this.storage_.has(e))return this.storage_.get(e).segmentSyncInfo.start;let r=Math.min(...this.storage_.keys());if(e<r){let n=r-e,i=this.storage_.get(r).segmentSyncInfo.start;for(let e=0;e<n;e++){let n=t[e];i-=n.duration}return i}return n}isReliablePlaylist_(e,t){return e!=null&&Array.isArray(t)&&t.length}}class vm extends _m{constructor(e){super(),this.parent_=e}calculateBaseTime_(e,t,n){if(!this.storage_.size){let t=this.parent_.getSyncInfoForMediaSequence(e);return t?t.segmentSyncInfo.start:0}return super.calculateBaseTime_(e,t,n)}}const ym=[{name:`VOD`,run:(e,t,n,r,i)=>n===1/0?null:{time:0,segmentIndex:0,partIndex:null}},{name:`MediaSequence`,run:(e,t,n,r,i,a)=>{let o=e.getMediaSequenceSync(a);if(!o||!o.isReliable)return null;let s=o.getSyncInfoForTime(i);return s?{time:s.start,partIndex:s.partIndex,segmentIndex:s.segmentIndex}:null}},{name:`ProgramDateTime`,run:(e,t,n,r,i)=>{if(!Object.keys(e.timelineToDatetimeMappings).length)return null;let a=null,o=null,s=Ru(t);i||=0;for(let n=0;n<s.length;n++){let r=s[t.endList||i===0?n:s.length-(n+1)],c=r.segment,l=e.timelineToDatetimeMappings[c.timeline];if(!l||!c.dateTimeObject)continue;let u=c.dateTimeObject.getTime()/1e3+l;if(c.parts&&typeof r.partIndex==`number`)for(let e=0;e<r.partIndex;e++)u+=c.parts[e].duration;let d=Math.abs(i-u);if(o!==null&&(d===0||o<d))break;o=d,a={time:u,segmentIndex:r.segmentIndex,partIndex:r.partIndex}}return a}},{name:`Segment`,run:(e,t,n,r,i)=>{let a=null,o=null;i||=0;let s=Ru(t);for(let e=0;e<s.length;e++){let n=s[t.endList||i===0?e:s.length-(e+1)],c=n.segment,l=n.part&&n.part.start||c&&c.start;if(c.timeline===r&&l!==void 0){let e=Math.abs(i-l);if(o!==null&&o<e)break;(!a||o===null||o>=e)&&(o=e,a={time:l,segmentIndex:n.segmentIndex,partIndex:n.partIndex})}}return a}},{name:`Discontinuity`,run:(e,t,n,r,i)=>{let a=null;if(i||=0,t.discontinuityStarts&&t.discontinuityStarts.length){let n=null;for(let r=0;r<t.discontinuityStarts.length;r++){let o=t.discontinuityStarts[r],s=t.discontinuitySequence+r+1,c=e.discontinuities[s];if(c){let e=Math.abs(i-c.time);if(n!==null&&n<e)break;(!a||n===null||n>=e)&&(n=e,a={time:c.time,segmentIndex:o,partIndex:null})}}}return a}},{name:`Playlist`,run:(e,t,n,r,i)=>t.syncInfo?{time:t.syncInfo.time,segmentIndex:t.syncInfo.mediaSequence-t.mediaSequence,partIndex:null}:null}];class bm extends Z.EventTarget{constructor(e={}){super(),this.timelines=[],this.discontinuities=[],this.timelineToDatetimeMappings={};let t=new _m,n=new vm(t),r=new vm(t);this.mediaSequenceStorage_={main:t,audio:n,vtt:r},this.logger_=xu(`SyncController`)}getMediaSequenceSync(e){return this.mediaSequenceStorage_[e]||null}getSyncPoint(e,t,n,r,i){if(t!==1/0)return ym.find(({name:e})=>e===`VOD`).run(this,e,t);let a=this.runStrategies_(e,t,n,r,i);if(!a.length)return null;for(let t of a){let{syncPoint:n,strategy:i}=t,{segmentIndex:a,time:o}=n;if(a<0)continue;let s=e.segments[a],c=o,l=c+s.duration;if(this.logger_(`Strategy: ${i}. Current time: ${r}. selected segment: ${a}. Time: [${c} -> ${l}]}`),r>=c&&r<l)return this.logger_(`Found sync point with exact match: `,n),n}return this.selectSyncPoint_(a,{key:`time`,value:r})}getExpiredTime(e,t){if(!e||!e.segments)return null;let n=this.runStrategies_(e,t,e.discontinuitySequence,0);if(!n.length)return null;let r=this.selectSyncPoint_(n,{key:`segmentIndex`,value:0});return r.segmentIndex>0&&(r.time*=-1),Math.abs(r.time+Ku({defaultDuration:e.targetDuration,durationList:e.segments,startIndex:r.segmentIndex,endIndex:0}))}runStrategies_(e,t,n,r,i){let a=[];for(let o=0;o<ym.length;o++){let s=ym[o],c=s.run(this,e,t,n,r,i);c&&(c.strategy=s.name,a.push({strategy:s.name,syncPoint:c}))}return a}selectSyncPoint_(e,t){let n=e[0].syncPoint,r=Math.abs(e[0].syncPoint[t.key]-t.value),i=e[0].strategy;for(let a=1;a<e.length;a++){let o=Math.abs(e[a].syncPoint[t.key]-t.value);o<r&&(r=o,n=e[a].syncPoint,i=e[a].strategy)}return this.logger_(`syncPoint for [${t.key}: ${t.value}] chosen with strategy [${i}]: [time:${n.time}, segmentIndex:${n.segmentIndex}`+(typeof n.partIndex==`number`?`,partIndex:${n.partIndex}`:``)+`]`),n}saveExpiredSegmentInfo(e,t){let n=t.mediaSequence-e.mediaSequence;if(n>86400)Z.log.warn(`Not saving expired segment info. Media sequence gap ${n} is too large.`);else for(let r=n-1;r>=0;r--){let n=e.segments[r];if(n&&n.start!==void 0){t.syncInfo={mediaSequence:e.mediaSequence+r,time:n.start},this.logger_(`playlist refresh sync: [time:${t.syncInfo.time}, mediaSequence: ${t.syncInfo.mediaSequence}]`),this.trigger(`syncinfoupdate`);break}}}setDateTimeMappingForStart(e){if(this.timelineToDatetimeMappings={},e.segments&&e.segments.length&&e.segments[0].dateTimeObject){let t=e.segments[0],n=t.dateTimeObject.getTime()/1e3;this.timelineToDatetimeMappings[t.timeline]=-n}}saveSegmentTimingInfo({segmentInfo:e,shouldSaveTimelineMapping:t}){let n=this.calculateSegmentTimeMapping_(e,e.timingInfo,t),r=e.segment;n&&(this.saveDiscontinuitySyncInfo_(e),e.playlist.syncInfo||(e.playlist.syncInfo={mediaSequence:e.playlist.mediaSequence+e.mediaIndex,time:r.start}));let i=r.dateTimeObject;r.discontinuity&&t&&i&&(this.timelineToDatetimeMappings[r.timeline]=-(i.getTime()/1e3))}timestampOffsetForTimeline(e){return this.timelines[e]===void 0?null:this.timelines[e].time}mappingForTimeline(e){return this.timelines[e]===void 0?null:this.timelines[e].mapping}calculateSegmentTimeMapping_(e,t,n){let r=e.segment,i=e.part,a=this.timelines[e.timeline],o,s;if(typeof e.timestampOffset==`number`)a={time:e.startOfSegment,mapping:e.startOfSegment-t.start},n&&(this.timelines[e.timeline]=a,this.trigger(`timestampoffset`),this.logger_(`time mapping for timeline ${e.timeline}: [time: ${a.time}] [mapping: ${a.mapping}]`)),o=e.startOfSegment,s=t.end+a.mapping;else if(a)o=t.start+a.mapping,s=t.end+a.mapping;else return!1;return i&&(i.start=o,i.end=s),(!r.start||o<r.start)&&(r.start=o),r.end=s,!0}saveDiscontinuitySyncInfo_(e){let t=e.playlist,n=e.segment;if(n.discontinuity)this.discontinuities[n.timeline]={time:n.start,accuracy:0};else if(t.discontinuityStarts&&t.discontinuityStarts.length)for(let r=0;r<t.discontinuityStarts.length;r++){let i=t.discontinuityStarts[r],a=t.discontinuitySequence+r+1,o=i-e.mediaIndex,s=Math.abs(o);if(!this.discontinuities[a]||this.discontinuities[a].accuracy>s){let r;r=o<0?n.start-Ku({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex,endIndex:i}):n.end+Ku({defaultDuration:t.targetDuration,durationList:t.segments,startIndex:e.mediaIndex+1,endIndex:i}),this.discontinuities[a]={time:r,accuracy:s}}}}dispose(){this.trigger(`dispose`),this.off()}}class xm extends Z.EventTarget{constructor(){super(),this.pendingTimelineChanges_={},this.lastTimelineChanges_={}}clearPendingTimelineChange(e){this.pendingTimelineChanges_[e]=null,this.trigger(`pendingtimelinechange`)}pendingTimelineChange({type:e,from:t,to:n}){return typeof t==`number`&&typeof n==`number`&&(this.pendingTimelineChanges_[e]={type:e,from:t,to:n},this.trigger(`pendingtimelinechange`)),this.pendingTimelineChanges_[e]}lastTimelineChange({type:e,from:t,to:n}){if(typeof t==`number`&&typeof n==`number`){this.lastTimelineChanges_[e]={type:e,from:t,to:n},delete this.pendingTimelineChanges_[e];let r={timelineChangeInfo:{from:t,to:n}};this.trigger({type:`timelinechange`,metadata:r})}return this.lastTimelineChanges_[e]}dispose(){this.trigger(`dispose`),this.pendingTimelineChanges_={},this.lastTimelineChanges_={},this.off()}}var Sm=wf(Tf(Ef(function(){var e=function(){function e(){this.listeners={}}var t=e.prototype;return t.on=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},t.off=function(e,t){if(!this.listeners[e])return!1;var n=this.listeners[e].indexOf(t);return this.listeners[e]=this.listeners[e].slice(0),this.listeners[e].splice(n,1),n>-1},t.trigger=function(e){var t=this.listeners[e];if(t){if(arguments.length===2)for(var n=t.length,r=0;r<n;++r)t[r].call(this,arguments[1]);else for(var i=Array.prototype.slice.call(arguments,1),a=t.length,o=0;o<a;++o)t[o].apply(this,i)}},t.dispose=function(){this.listeners={}},t.pipe=function(e){this.on(`data`,function(t){e.push(t)})},e}();function t(e){return e.subarray(0,e.byteLength-e[e.byteLength-1])}let n=function(){let e=[[[],[],[],[],[]],[[],[],[],[],[]]],t=e[0],n=e[1],r=t[4],i=n[4],a,o,s,c=[],l=[],u,d,f,p,m,h;for(a=0;a<256;a++)l[(c[a]=a<<1^(a>>7)*283)^a]=a;for(o=s=0;!r[o];o^=u||1,s=l[s]||1)for(p=s^s<<1^s<<2^s<<3^s<<4,p=p>>8^p&255^99,r[o]=p,i[p]=o,f=c[d=c[u=c[o]]],h=f*16843009^d*65537^u*257^o*16843008,m=c[p]*257^p*16843008,a=0;a<4;a++)t[a][o]=m=m<<24^m>>>8,n[a][p]=h=h<<24^h>>>8;for(a=0;a<5;a++)t[a]=t[a].slice(0),n[a]=n[a].slice(0);return e},r=null;class i{constructor(e){r||=n(),this._tables=[[r[0][0].slice(),r[0][1].slice(),r[0][2].slice(),r[0][3].slice(),r[0][4].slice()],[r[1][0].slice(),r[1][1].slice(),r[1][2].slice(),r[1][3].slice(),r[1][4].slice()]];let t,i,a,o=this._tables[0][4],s=this._tables[1],c=e.length,l=1;if(c!==4&&c!==6&&c!==8)throw Error(`Invalid aes key size`);let u=e.slice(0),d=[];for(this._key=[u,d],t=c;t<4*c+28;t++)a=u[t-1],(t%c===0||c===8&&t%c===4)&&(a=o[a>>>24]<<24^o[a>>16&255]<<16^o[a>>8&255]<<8^o[a&255],t%c===0&&(a=a<<8^a>>>24^l<<24,l=l<<1^(l>>7)*283)),u[t]=u[t-c]^a;for(i=0;t;i++,t--)a=u[i&3?t:t-4],t<=4||i<4?d[i]=a:d[i]=s[0][o[a>>>24]]^s[1][o[a>>16&255]]^s[2][o[a>>8&255]]^s[3][o[a&255]]}decrypt(e,t,n,r,i,a){let o=this._key[1],s=e^o[0],c=r^o[1],l=n^o[2],u=t^o[3],d,f,p,m=o.length/4-2,h,g=4,_=this._tables[1],v=_[0],y=_[1],b=_[2],x=_[3],S=_[4];for(h=0;h<m;h++)d=v[s>>>24]^y[c>>16&255]^b[l>>8&255]^x[u&255]^o[g],f=v[c>>>24]^y[l>>16&255]^b[u>>8&255]^x[s&255]^o[g+1],p=v[l>>>24]^y[u>>16&255]^b[s>>8&255]^x[c&255]^o[g+2],u=v[u>>>24]^y[s>>16&255]^b[c>>8&255]^x[l&255]^o[g+3],g+=4,s=d,c=f,l=p;for(h=0;h<4;h++)i[(3&-h)+a]=S[s>>>24]<<24^S[c>>16&255]<<16^S[l>>8&255]<<8^S[u&255]^o[g++],d=s,s=c,c=l,l=u,u=d}}class a extends e{constructor(){super(e),this.jobs=[],this.delay=1,this.timeout_=null}processJob_(){this.jobs.shift()(),this.timeout_=this.jobs.length?setTimeout(this.processJob_.bind(this),this.delay):null}push(e){this.jobs.push(e),this.timeout_||=setTimeout(this.processJob_.bind(this),this.delay)}}let o=function(e){return e<<24|(e&65280)<<8|(e&16711680)>>8|e>>>24},s=function(e,t,n){let r=new Int32Array(e.buffer,e.byteOffset,e.byteLength>>2),a=new i(Array.prototype.slice.call(t)),s=new Uint8Array(e.byteLength),c=new Int32Array(s.buffer),l,u,d,f,p,m,h,g,_;for(l=n[0],u=n[1],d=n[2],f=n[3],_=0;_<r.length;_+=4)p=o(r[_]),m=o(r[_+1]),h=o(r[_+2]),g=o(r[_+3]),a.decrypt(p,m,h,g,c,_),c[_]=o(c[_]^l),c[_+1]=o(c[_+1]^u),c[_+2]=o(c[_+2]^d),c[_+3]=o(c[_+3]^f),l=p,u=m,d=h,f=g;return s};class c{constructor(e,n,r,i){let s=c.STEP,l=new Int32Array(e.buffer),u=new Uint8Array(e.byteLength),d=0;for(this.asyncStream_=new a,this.asyncStream_.push(this.decryptChunk_(l.subarray(d,d+s),n,r,u)),d=s;d<l.length;d+=s)r=new Uint32Array([o(l[d-4]),o(l[d-3]),o(l[d-2]),o(l[d-1])]),this.asyncStream_.push(this.decryptChunk_(l.subarray(d,d+s),n,r,u));this.asyncStream_.push(function(){i(null,t(u))})}static get STEP(){return 32e3}decryptChunk_(e,t,n,r){return function(){let i=s(e,t,n);r.set(i,e.byteOffset)}}}var l=typeof globalThis<`u`?globalThis:typeof window<`u`?window:typeof global<`u`?global:typeof self<`u`?self:{},u=typeof window<`u`?window:l===void 0?typeof self<`u`?self:{}:l,d=function(e){return ArrayBuffer.isView===`function`?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer},f=u.BigInt||Number;f(`0x1`),f(`0x100`),f(`0x10000`),f(`0x1000000`),f(`0x100000000`),f(`0x10000000000`),f(`0x1000000000000`),f(`0x100000000000000`),f(`0x10000000000000000`),(function(){var e=new Uint16Array([65484]),t=new Uint8Array(e.buffer,e.byteOffset,e.byteLength);return t[0]===255?`big`:t[0]===204?`little`:`unknown`})();let p=function(e){let t={};return Object.keys(e).forEach(n=>{let r=e[n];d(r)?t[n]={bytes:r.buffer,byteOffset:r.byteOffset,byteLength:r.byteLength}:t[n]=r}),t};self.onmessage=function(e){let t=e.data,n=new Uint8Array(t.encrypted.bytes,t.encrypted.byteOffset,t.encrypted.byteLength),r=new Uint32Array(t.key.bytes,t.key.byteOffset,t.key.byteLength/4),i=new Uint32Array(t.iv.bytes,t.iv.byteOffset,t.iv.byteLength/4);new c(n,r,i,function(e,n){self.postMessage(p({source:t.source,decrypted:n}),[n.buffer])})}})));const Cm=e=>{let t=e.default?`main`:`alternative`;return e.characteristics&&e.characteristics.indexOf(`public.accessibility.describes-video`)>=0&&(t=`main-desc`),t},wm=(e,t)=>{e.abort(),e.pause(),t&&t.activePlaylistLoader&&(t.activePlaylistLoader.pause(),t.activePlaylistLoader=null)},Tm=(e,t)=>{t.activePlaylistLoader=e,e.load()},Em=(e,t)=>()=>{let{segmentLoaders:{[e]:n,main:r},mediaTypes:{[e]:i}}=t,a=i.activeTrack(),o=i.getActiveGroup(),s=i.activePlaylistLoader,c=i.lastGroup_;o&&c&&o.id===c.id||(i.lastGroup_=o,i.lastTrack_=a,wm(n,i),o&&!o.isMainPlaylist&&(o.playlistLoader?(n.resyncLoader(),Tm(o.playlistLoader,i)):s&&r.resetEverything()))},Dm=(e,t)=>()=>{let{segmentLoaders:{[e]:n},mediaTypes:{[e]:r}}=t;r.lastGroup_=null,n.abort(),n.pause()},Om=(e,t)=>()=>{let{mainPlaylistLoader:n,segmentLoaders:{[e]:r,main:i},mediaTypes:{[e]:a}}=t,o=a.activeTrack(),s=a.getActiveGroup(),c=a.activePlaylistLoader,l=a.lastTrack_;if(!(l&&o&&l.id===o.id)&&(a.lastGroup_=s,a.lastTrack_=o,wm(r,a),s)){if(s.isMainPlaylist){if(!o||!l||o.id===l.id)return;let e=t.vhs.playlistController_,r=e.selectPlaylist();if(e.media()===r)return;a.logger_(`track change. Switching main audio from ${l.id} to ${o.id}`),n.pause(),i.resetEverything(),e.fastQualityChange_(r)}else{if(e===`AUDIO`){if(!s.playlistLoader){i.setAudio(!0),i.resetEverything();return}r.setAudio(!0),i.setAudio(!1)}c===s.playlistLoader||(r.track&&r.track(o),r.resetEverything()),Tm(s.playlistLoader,a)}}},km={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:n},excludePlaylist:r}=t,i=n.activeTrack(),a=n.activeGroup(),o=(a.filter(e=>e.default)[0]||a[0]).id,s=n.tracks[o];if(i===s)r({error:{message:`Problem encountered loading the default audio track.`}});else{Z.log.warn(`Problem encountered loading the alternate audio track.Switching back to default.`);for(let e in n.tracks)n.tracks[e].enabled=n.tracks[e]===s;n.onTrackChanged()}},SUBTITLES:(e,t)=>()=>{let{mediaTypes:{[e]:n}}=t;Z.log.warn(`Problem encountered loading the subtitle track.Disabling subtitle track.`);let r=n.activeTrack();r&&(r.mode=`disabled`),n.onTrackChanged()}},Am={AUDIO:(e,t,n)=>{if(!t)return;let{tech:r,requestOptions:i,segmentLoaders:{[e]:a}}=n;t.on(`loadedmetadata`,()=>{let e=t.media();a.playlist(e,i),(!r.paused()||e.endList&&r.preload()!==`none`)&&a.load()}),t.on(`loadedplaylist`,()=>{a.playlist(t.media(),i),r.paused()||a.load()}),t.on(`error`,km[e](e,n))},SUBTITLES:(e,t,n)=>{let{tech:r,requestOptions:i,segmentLoaders:{[e]:a},mediaTypes:{[e]:o}}=n;t.on(`loadedmetadata`,()=>{let e=t.media();a.playlist(e,i),a.track(o.activeTrack()),(!r.paused()||e.endList&&r.preload()!==`none`)&&a.load()}),t.on(`loadedplaylist`,()=>{a.playlist(t.media(),i),r.paused()||a.load()}),t.on(`error`,km[e](e,n))}},jm={AUDIO:(e,t)=>{let{vhs:n,sourceType:r,segmentLoaders:{[e]:i},requestOptions:a,main:{mediaGroups:o},mediaTypes:{[e]:{groups:s,tracks:c,logger_:l}},mainPlaylistLoader:u}=t,d=od(u.main);o[e]&&Object.keys(o[e]).length!==0||(o[e]={main:{default:{default:!0}}},d&&(o[e].main.default.playlists=u.main.playlists));for(let i in o[e]){s[i]||(s[i]=[]);for(let f in o[e][i]){let p=o[e][i][f],m;d?(l(`AUDIO group '${i}' label '${f}' is a main playlist`),p.isMainPlaylist=!0,m=null):m=r===`vhs-json`&&p.playlists?new Ld(p.playlists[0],n,a):p.resolvedUri?new Ld(p.resolvedUri,n,a):p.playlists&&r===`dash`?new yf(p.playlists[0],n,a,u):null,p=Q({id:f,playlistLoader:m},p),Am[e](e,p.playlistLoader,t),s[i].push(p),c[f]===void 0&&(c[f]=new Z.AudioTrack({id:f,kind:Cm(p),enabled:!1,language:p.language,default:p.default,label:f}))}}i.on(`error`,km[e](e,t))},SUBTITLES:(e,t)=>{let{tech:n,vhs:r,sourceType:i,segmentLoaders:{[e]:a},requestOptions:o,main:{mediaGroups:s},mediaTypes:{[e]:{groups:c,tracks:l}},mainPlaylistLoader:u}=t;for(let a in s[e]){c[a]||(c[a]=[]);for(let d in s[e][a]){if(!r.options_.useForcedSubtitles&&s[e][a][d].forced)continue;let f=s[e][a][d],p;if(i===`hls`)p=new Ld(f.resolvedUri,r,o);else if(i===`dash`){if(!f.playlists.filter(e=>e.excludeUntil!==1/0).length)return;p=new yf(f.playlists[0],r,o,u)}else i===`vhs-json`&&(p=new Ld(f.playlists?f.playlists[0]:f.resolvedUri,r,o));f=Q({id:d,playlistLoader:p},f),Am[e](e,f.playlistLoader,t),c[a].push(f),l[d]===void 0&&(l[d]=n.addRemoteTextTrack({id:d,kind:`subtitles`,default:f.default&&f.autoselect,language:f.language,label:d},!1).track)}}a.on(`error`,km[e](e,t))},"CLOSED-CAPTIONS":(e,t)=>{let{tech:n,main:{mediaGroups:r},mediaTypes:{[e]:{groups:i,tracks:a}}}=t;for(let t in r[e]){i[t]||(i[t]=[]);for(let o in r[e][t]){let s=r[e][t][o];if(!/^(?:CC|SERVICE)/.test(s.instreamId))continue;let c=n.options_.vhs&&n.options_.vhs.captionServices||{},l={label:o,language:s.language,instreamId:s.instreamId,default:s.default&&s.autoselect};c[l.instreamId]&&(l=Q(l,c[l.instreamId])),l.default===void 0&&delete l.default,i[t].push(Q({id:o},s)),a[o]===void 0&&(a[o]=n.addRemoteTextTrack({id:l.instreamId,kind:`captions`,default:l.default,language:l.language,label:l.label},!1).track)}}}},Mm=(e,t)=>{for(let n=0;n<e.length;n++)if(id(t,e[n])||e[n].playlists&&Mm(e[n].playlists,t))return!0;return!1},Nm=(e,t)=>n=>{let{mainPlaylistLoader:r,mediaTypes:{[e]:{groups:i}}}=t,a=r.media();if(!a)return null;let o=null;a.attributes[e]&&(o=i[a.attributes[e]]);let s=Object.keys(i);if(!o){if(e===`AUDIO`&&s.length>1&&od(t.main))for(let e=0;e<s.length;e++){let t=i[s[e]];if(Mm(t,a)){o=t;break}}else i.main?o=i.main:s.length===1&&(o=i[s[0]])}return n===void 0?o:n===null||!o?null:o.filter(e=>e.id===n.id)[0]||null},Pm={AUDIO:(e,t)=>()=>{let{mediaTypes:{[e]:{tracks:n}}}=t;for(let e in n)if(n[e].enabled)return n[e];return null},SUBTITLES:(e,t)=>()=>{let{mediaTypes:{[e]:{tracks:n}}}=t;for(let e in n)if(n[e].mode===`showing`||n[e].mode===`hidden`)return n[e];return null}},Fm=(e,{mediaTypes:t})=>()=>{let n=t[e].activeTrack();return n?t[e].activeGroup(n):null},Im=e=>{[`AUDIO`,`SUBTITLES`,`CLOSED-CAPTIONS`].forEach(t=>{jm[t](t,e)});let{mediaTypes:t,mainPlaylistLoader:n,tech:r,vhs:i,segmentLoaders:{AUDIO:a,main:o}}=e;[`AUDIO`,`SUBTITLES`].forEach(n=>{t[n].activeGroup=Nm(n,e),t[n].activeTrack=Pm[n](n,e),t[n].onGroupChanged=Em(n,e),t[n].onGroupChanging=Dm(n,e),t[n].onTrackChanged=Om(n,e),t[n].getActiveGroup=Fm(n,e)});let s=t.AUDIO.activeGroup();if(s){let e=(s.filter(e=>e.default)[0]||s[0]).id;t.AUDIO.tracks[e].enabled=!0,t.AUDIO.onGroupChanged(),t.AUDIO.onTrackChanged(),t.AUDIO.getActiveGroup().playlistLoader?(o.setAudio(!1),a.setAudio(!0)):o.setAudio(!0)}n.on(`mediachange`,()=>{[`AUDIO`,`SUBTITLES`].forEach(e=>t[e].onGroupChanged())}),n.on(`mediachanging`,()=>{[`AUDIO`,`SUBTITLES`].forEach(e=>t[e].onGroupChanging())});let c=()=>{t.AUDIO.onTrackChanged(),r.trigger({type:`usage`,name:`vhs-audio-change`})};r.audioTracks().addEventListener(`change`,c),r.remoteTextTracks().addEventListener(`change`,t.SUBTITLES.onTrackChanged),i.on(`dispose`,()=>{r.audioTracks().removeEventListener(`change`,c),r.remoteTextTracks().removeEventListener(`change`,t.SUBTITLES.onTrackChanged)}),r.clearTracks(`audio`);for(let e in t.AUDIO.tracks)r.audioTracks().addTrack(t.AUDIO.tracks[e])},Lm=()=>{let e={};return[`AUDIO`,`SUBTITLES`,`CLOSED-CAPTIONS`].forEach(t=>{e[t]={groups:{},tracks:{},activePlaylistLoader:null,activeGroup:Xp,activeTrack:Xp,getActiveGroup:Xp,onGroupChanged:Xp,onTrackChanged:Xp,lastTrack_:null,logger_:xu(`MediaGroups[${t}]`)}}),e};class Rm{constructor(){this.priority_=[],this.pathwayClones_=new Map}set version(e){e===1&&(this.version_=e)}set ttl(e){this.ttl_=e||300}set reloadUri(e){e&&(this.reloadUri_=yu(this.reloadUri_,e))}set priority(e){e&&e.length&&(this.priority_=e)}set pathwayClones(e){e&&e.length&&(this.pathwayClones_=new Map(e.map(e=>[e.ID,e])))}get version(){return this.version_}get ttl(){return this.ttl_}get reloadUri(){return this.reloadUri_}get priority(){return this.priority_}get pathwayClones(){return this.pathwayClones_}}class zm extends Z.EventTarget{constructor(e,t){super(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=!1,this.availablePathways_=new Set,this.steeringManifest=new Rm,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.currentPathwayClones=new Map,this.nextPathwayClones=new Map,this.excludedSteeringManifestURLs=new Set,this.logger_=xu(`Content Steering`),this.xhr_=e,this.getBandwidth_=t}assignTagProperties(e,t){this.manifestType_=t.serverUri?`HLS`:`DASH`;let n=t.serverUri||t.serverURL;n?n.startsWith(`data:`)?this.decodeDataUriManifest_(n.substring(n.indexOf(`,`)+1)):(this.steeringManifest.reloadUri=yu(e,n),this.defaultPathway=t.pathwayId||t.defaultServiceLocation,this.queryBeforeStart=t.queryBeforeStart,this.proxyServerUrl_=t.proxyServerURL,this.defaultPathway&&!this.queryBeforeStart&&this.trigger(`content-steering`)):(this.logger_(`steering manifest URL is ${n}, cannot request steering manifest.`),this.trigger(`error`))}requestSteeringManifest(e){let t=this.steeringManifest.reloadUri;if(!t)return;let n=e?t:this.getRequestURI(t);if(!n){this.logger_(`No valid content steering manifest URIs. Stopping content steering.`),this.trigger(`error`),this.dispose();return}let r={contentSteeringInfo:{uri:n}};this.trigger({type:`contentsteeringloadstart`,metadata:r}),this.request_=this.xhr_({uri:n,requestType:`content-steering-manifest`},(e,t)=>{if(e){if(t.status===410){this.logger_(`manifest request 410 ${e}.`),this.logger_(`There will be no more content steering requests to ${n} this session.`),this.excludedSteeringManifestURLs.add(n);return}if(t.status===429){let n=t.responseHeaders[`retry-after`];this.logger_(`manifest request 429 ${e}.`),this.logger_(`content steering will retry in ${n} seconds.`),this.startTTLTimeout_(parseInt(n,10));return}this.logger_(`manifest failed to load ${e}.`),this.startTTLTimeout_();return}this.trigger({type:`contentsteeringloadcomplete`,metadata:r});let i;try{i=JSON.parse(this.request_.responseText)}catch(e){let t={errorType:Z.Error.StreamingContentSteeringParserError,error:e};this.trigger({type:`error`,metadata:t})}this.assignSteeringProperties_(i);let a={contentSteeringInfo:r.contentSteeringInfo,contentSteeringManifest:{version:this.steeringManifest.version,reloadUri:this.steeringManifest.reloadUri,priority:this.steeringManifest.priority}};this.trigger({type:`contentsteeringparsed`,metadata:a}),this.startTTLTimeout_()})}setProxyServerUrl_(e){let t=new x.URL(e),n=new x.URL(this.proxyServerUrl_);return n.searchParams.set(`url`,encodeURI(t.toString())),this.setSteeringParams_(n.toString())}decodeDataUriManifest_(e){let t=JSON.parse(x.atob(e));this.assignSteeringProperties_(t)}setSteeringParams_(e){let t=new x.URL(e),n=this.getPathway(),r=this.getBandwidth_();if(n){let e=`_${this.manifestType_}_pathway`;t.searchParams.set(e,n)}if(r){let e=`_${this.manifestType_}_throughput`;t.searchParams.set(e,r)}return t.toString()}assignSteeringProperties_(e){if(this.steeringManifest.version=e.VERSION,!this.steeringManifest.version){this.logger_(`manifest version is ${e.VERSION}, which is not supported.`),this.trigger(`error`);return}this.steeringManifest.ttl=e.TTL,this.steeringManifest.reloadUri=e[`RELOAD-URI`],this.steeringManifest.priority=e[`PATHWAY-PRIORITY`]||e[`SERVICE-LOCATION-PRIORITY`],this.steeringManifest.pathwayClones=e[`PATHWAY-CLONES`],this.nextPathwayClones=this.steeringManifest.pathwayClones,this.availablePathways_.size||(this.logger_(`There are no available pathways for content steering. Ending content steering.`),this.trigger(`error`),this.dispose());let t=(e=>{for(let t of e)if(this.availablePathways_.has(t))return t;return[...this.availablePathways_][0]})(this.steeringManifest.priority);this.currentPathway!==t&&(this.currentPathway=t,this.trigger(`content-steering`))}getPathway(){return this.currentPathway||this.defaultPathway}getRequestURI(e){if(!e)return null;let t=e=>this.excludedSteeringManifestURLs.has(e);if(this.proxyServerUrl_){let n=this.setProxyServerUrl_(e);if(!t(n))return n}let n=this.setSteeringParams_(e);return t(n)?null:n}startTTLTimeout_(e=this.steeringManifest.ttl){let t=e*1e3;this.ttlTimeout_=x.setTimeout(()=>{this.requestSteeringManifest()},t)}clearTTLTimeout_(){x.clearTimeout(this.ttlTimeout_),this.ttlTimeout_=null}abort(){this.request_&&this.request_.abort(),this.request_=null}dispose(){this.off(`content-steering`),this.off(`error`),this.abort(),this.clearTTLTimeout_(),this.currentPathway=null,this.defaultPathway=null,this.queryBeforeStart=null,this.proxyServerUrl_=null,this.manifestType_=null,this.ttlTimeout_=null,this.request_=null,this.excludedSteeringManifestURLs=new Set,this.availablePathways_=new Set,this.steeringManifest=new Rm}addAvailablePathway(e){e&&this.availablePathways_.add(e)}clearAvailablePathways(){this.availablePathways_.clear()}excludePathway(e){return this.availablePathways_.delete(e)}didDASHTagChange(e,t){return!t&&this.steeringManifest.reloadUri||t&&(yu(e,t.serverURL)!==this.steeringManifest.reloadUri||t.defaultServiceLocation!==this.defaultPathway||t.queryBeforeStart!==this.queryBeforeStart||t.proxyServerURL!==this.proxyServerUrl_)}getAvailablePathways(){return this.availablePathways_}}const Bm=(e,t)=>{let n=null;return(...r)=>{clearTimeout(n),n=setTimeout(()=>{e.apply(null,r)},t)}};let Vm;const Hm=[`mediaRequests`,`mediaRequestsAborted`,`mediaRequestsTimedout`,`mediaRequestsErrored`,`mediaTransferDuration`,`mediaBytesTransferred`,`mediaAppends`],Um=function(e){return this.audioSegmentLoader_[e]+this.mainSegmentLoader_[e]},Wm=function({currentPlaylist:e,buffered:t,currentTime:n,nextPlaylist:r,bufferLowWaterLine:i,bufferHighWaterLine:a,duration:o,bufferBasedABR:s,log:c}){if(!r)return Z.log.warn(`We received no playlist to switch to. Please check your stream.`),!1;let l=`allowing switch ${e&&e.id||`null`} -> ${r.id}`;if(!e)return c(`${l} as current playlist is not set`),!0;if(r.id===e.id)return!1;let u=!!Du(t,n).length;if(!e.endList)return!u&&typeof e.partTargetDuration==`number`?(c(`not ${l} as current playlist is live llhls, but currentTime isn't in buffered.`),!1):(c(`${l} as current playlist is live`),!0);let d=Iu(t,n),f=s?bf.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE:bf.MAX_BUFFER_LOW_WATER_LINE;if(o<f)return c(`${l} as duration < max low water line (${o} < ${f})`),!0;let p=r.attributes.BANDWIDTH,m=e.attributes.BANDWIDTH;if(p<m&&(!s||d<a)){let e=`${l} as next bandwidth < current bandwidth (${p} < ${m})`;return s&&(e+=` and forwardBuffer < bufferHighWaterLine (${d} < ${a})`),c(e),!0}if((!s||p>m)&&d>=i){let e=`${l} as forwardBuffer >= bufferLowWaterLine (${d} >= ${i})`;return s&&(e+=` and next bandwidth > current bandwidth (${p} > ${m})`),c(e),!0}return c(`not ${l} as no switching criteria met`),!1};class Gm extends Z.EventTarget{constructor(e){super(),this.fastQualityChange_=Bm(this.fastQualityChange_.bind(this),100);let{src:t,withCredentials:n,tech:r,bandwidth:i,externVhs:a,useCueTags:o,playlistExclusionDuration:s,enableLowInitialPlaylist:c,sourceType:l,cacheEncryptionKeys:u,bufferBasedABR:d,leastPixelDiffSelector:f,captionServices:p,experimentalUseMMS:m}=e;if(!t)throw Error(`A non-empty playlist URL or JSON manifest string is required`);let{maxPlaylistRetries:h}=e;h??=1/0,Vm=a,this.bufferBasedABR=!!d,this.leastPixelDiffSelector=!!f,this.withCredentials=n,this.tech_=r,this.vhs_=r.vhs,this.player_=e.player_,this.sourceType_=l,this.useCueTags_=o,this.playlistExclusionDuration=s,this.maxPlaylistRetries=h,this.enableLowInitialPlaylist=c,this.usingManagedMediaSource_=!1,this.useCueTags_&&(this.cueTagsTrack_=this.tech_.addTextTrack(`metadata`,`ad-cues`),this.cueTagsTrack_.inBandMetadataTrackDispatchType=``),this.requestOptions_={withCredentials:n,maxPlaylistRetries:h,timeout:null},this.on(`error`,this.pauseLoading),this.mediaTypes_=Lm(),m&&x.ManagedMediaSource?(this.tech_.el_.disableRemotePlayback=!0,this.mediaSource=new x.ManagedMediaSource,this.usingManagedMediaSource_=!0,Z.log(`Using ManagedMediaSource`)):x.MediaSource&&(this.mediaSource=new x.MediaSource),this.handleDurationChange_=this.handleDurationChange_.bind(this),this.handleSourceOpen_=this.handleSourceOpen_.bind(this),this.handleSourceEnded_=this.handleSourceEnded_.bind(this),this.load=this.load.bind(this),this.pause=this.pause.bind(this),this.mediaSource.addEventListener(`durationchange`,this.handleDurationChange_),this.mediaSource.addEventListener(`sourceopen`,this.handleSourceOpen_),this.mediaSource.addEventListener(`sourceended`,this.handleSourceEnded_),this.mediaSource.addEventListener(`startstreaming`,this.load),this.mediaSource.addEventListener(`endstreaming`,this.pause),this.seekable_=Su(),this.hasPlayed_=!1,this.syncController_=new bm(e),this.segmentMetadataTrack_=r.addRemoteTextTrack({kind:`metadata`,label:`segment-metadata`},!1).track,this.segmentMetadataTrack_.mode=`hidden`,this.decrypter_=new Sm,this.sourceUpdater_=new sm(this.mediaSource),this.inbandTextTracks_={},this.timelineChangeController_=new xm,this.keyStatusMap_=new Map;let g={vhs:this.vhs_,parse708captions:e.parse708captions,useDtsForTimestampOffset:e.useDtsForTimestampOffset,captionServices:p,mediaSource:this.mediaSource,currentTime:this.tech_.currentTime.bind(this.tech_),seekable:()=>this.seekable(),seeking:()=>this.tech_.seeking(),duration:()=>this.duration(),hasPlayed:()=>this.hasPlayed_,goalBufferLength:()=>this.goalBufferLength(),bandwidth:i,syncController:this.syncController_,decrypter:this.decrypter_,sourceType:this.sourceType_,inbandTextTracks:this.inbandTextTracks_,cacheEncryptionKeys:u,sourceUpdater:this.sourceUpdater_,timelineChangeController:this.timelineChangeController_,exactManifestTimings:e.exactManifestTimings,addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)};this.mainPlaylistLoader_=this.sourceType_===`dash`?new yf(t,this.vhs_,Q(this.requestOptions_,{addMetadataToTextTrack:this.addMetadataToTextTrack.bind(this)})):new Ld(t,this.vhs_,Q(this.requestOptions_,{addDateRangesToTextTrack:this.addDateRangesToTextTrack_.bind(this)})),this.setupMainPlaylistLoaderListeners_(),this.mainSegmentLoader_=new Yp(Q(g,{segmentMetadataTrack:this.segmentMetadataTrack_,loaderType:`main`}),e),this.audioSegmentLoader_=new Yp(Q(g,{loaderType:`audio`}),e),this.subtitleSegmentLoader_=new fm(Q(g,{loaderType:`vtt`,featuresNativeTextTracks:this.tech_.featuresNativeTextTracks,loadVttJs:()=>new Promise((e,t)=>{function n(){r.off(`vttjserror`,i),e()}function i(){r.off(`vttjsloaded`,n),t()}r.one(`vttjsloaded`,n),r.one(`vttjserror`,i),r.addWebVttScript_()})}),e);let _=()=>this.mainSegmentLoader_.bandwidth;this.contentSteeringController_=new zm(this.vhs_.xhr,_),this.setupSegmentLoaderListeners_(),this.bufferBasedABR&&(this.mainPlaylistLoader_.one(`loadedplaylist`,()=>this.startABRTimer_()),this.tech_.on(`pause`,()=>this.stopABRTimer_()),this.tech_.on(`play`,()=>this.startABRTimer_())),Hm.forEach(e=>{this[e+`_`]=Um.bind(this,e)}),this.logger_=xu(`pc`),this.triggeredFmp4Usage=!1,this.tech_.preload()===`none`?(this.loadOnPlay_=()=>{this.loadOnPlay_=null,this.mainPlaylistLoader_.load()},this.tech_.one(`play`,this.loadOnPlay_)):this.mainPlaylistLoader_.load(),this.timeToLoadedData__=-1,this.mainAppendsToLoadedData__=-1,this.audioAppendsToLoadedData__=-1;let v=this.tech_.preload()===`none`?`play`:`loadstart`;this.tech_.one(v,()=>{let e=Date.now();this.tech_.one(`loadeddata`,()=>{this.timeToLoadedData__=Date.now()-e,this.mainAppendsToLoadedData__=this.mainSegmentLoader_.mediaAppends,this.audioAppendsToLoadedData__=this.audioSegmentLoader_.mediaAppends})})}mainAppendsToLoadedData_(){return this.mainAppendsToLoadedData__}audioAppendsToLoadedData_(){return this.audioAppendsToLoadedData__}appendsToLoadedData_(){let e=this.mainAppendsToLoadedData_(),t=this.audioAppendsToLoadedData_();return e===-1||t===-1?-1:e+t}timeToLoadedData_(){return this.timeToLoadedData__}checkABR_(e=`abr`){let t=this.selectPlaylist();t&&this.shouldSwitchToMedia_(t)&&this.switchMedia_(t,e)}switchMedia_(e,t,n){let r=this.media(),i=r&&(r.id||r.uri),a=e&&(e.id||e.uri);if(i&&i!==a){this.logger_(`switch media ${i} -> ${a} from ${t}`);let n={renditionInfo:{id:a,bandwidth:e.attributes.BANDWIDTH,resolution:e.attributes.RESOLUTION,codecs:e.attributes.CODECS},cause:t};this.trigger({type:`renditionselected`,metadata:n}),this.tech_.trigger({type:`usage`,name:`vhs-rendition-change-${t}`})}this.mainPlaylistLoader_.media(e,n)}switchMediaForDASHContentSteering_(){[`AUDIO`,`SUBTITLES`,`CLOSED-CAPTIONS`].forEach(e=>{let t=this.mediaTypes_[e],n=t?t.activeGroup():null,r=this.contentSteeringController_.getPathway();if(n&&r){let t=(n.length?n[0].playlists:n.playlists).filter(e=>e.attributes.serviceLocation===r);t.length&&this.mediaTypes_[e].activePlaylistLoader.media(t[0])}})}startABRTimer_(){this.stopABRTimer_(),this.abrTimer_=x.setInterval(()=>this.checkABR_(),250)}stopABRTimer_(){this.tech_.scrubbing&&this.tech_.scrubbing()||(x.clearInterval(this.abrTimer_),this.abrTimer_=null)}getAudioTrackPlaylists_(){let e=this.main(),t=e&&e.playlists||[];if(!e||!e.mediaGroups||!e.mediaGroups.AUDIO)return t;let n=e.mediaGroups.AUDIO,r=Object.keys(n),i;if(Object.keys(this.mediaTypes_.AUDIO.groups).length)i=this.mediaTypes_.AUDIO.activeTrack();else{let e=n.main||r.length&&n[r[0]];for(let t in e)if(e[t].default){i={label:t};break}}if(!i)return t;let a=[];for(let t in n)if(n[t][i.label]){let r=n[t][i.label];if(r.playlists&&r.playlists.length)a.push.apply(a,r.playlists);else if(r.uri)a.push(r);else if(e.playlists.length)for(let n=0;n<e.playlists.length;n++){let r=e.playlists[n];r.attributes&&r.attributes.AUDIO&&r.attributes.AUDIO===t&&a.push(r)}}return a.length?a:t}setupMainPlaylistLoaderListeners_(){this.mainPlaylistLoader_.on(`loadedmetadata`,()=>{let e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;rd(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,e.endList&&this.tech_.preload()!==`none`&&(this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.mainSegmentLoader_.load()),Im({sourceType:this.sourceType_,segmentLoaders:{AUDIO:this.audioSegmentLoader_,SUBTITLES:this.subtitleSegmentLoader_,main:this.mainSegmentLoader_},tech:this.tech_,requestOptions:this.requestOptions_,mainPlaylistLoader:this.mainPlaylistLoader_,vhs:this.vhs_,main:this.main(),mediaTypes:this.mediaTypes_,excludePlaylist:this.excludePlaylist.bind(this)}),this.triggerPresenceUsage_(this.main(),e),this.setupFirstPlay(),!this.mediaTypes_.AUDIO.activePlaylistLoader||this.mediaTypes_.AUDIO.activePlaylistLoader.media()?this.trigger(`selectedinitialmedia`):this.mediaTypes_.AUDIO.activePlaylistLoader.one(`loadedmetadata`,()=>{this.trigger(`selectedinitialmedia`)})}),this.mainPlaylistLoader_.on(`loadedplaylist`,()=>{this.loadOnPlay_&&this.tech_.off(`play`,this.loadOnPlay_);let e=this.mainPlaylistLoader_.media();if(!e){this.attachContentSteeringListeners_(),this.initContentSteeringController_(),this.excludeUnsupportedVariants_();let t;if(this.enableLowInitialPlaylist&&(t=this.selectInitialPlaylist()),t||=this.selectPlaylist(),!t||!this.shouldSwitchToMedia_(t)||(this.initialMedia_=t,this.switchMedia_(this.initialMedia_,`initial`),!(this.sourceType_===`vhs-json`&&this.initialMedia_.segments)))return;e=this.initialMedia_}this.handleUpdatedMediaPlaylist(e)}),this.mainPlaylistLoader_.on(`error`,()=>{let e=this.mainPlaylistLoader_.error;this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainPlaylistLoader_.on(`mediachanging`,()=>{this.mainSegmentLoader_.abort(),this.mainSegmentLoader_.pause()}),this.mainPlaylistLoader_.on(`mediachange`,()=>{let e=this.mainPlaylistLoader_.media(),t=e.targetDuration*1.5*1e3;rd(this.mainPlaylistLoader_.main,this.mainPlaylistLoader_.media())?this.requestOptions_.timeout=0:this.requestOptions_.timeout=t,this.sourceType_===`dash`&&this.mainPlaylistLoader_.isPaused&&this.mainPlaylistLoader_.load(),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_?this.runFastQualitySwitch_():this.mainSegmentLoader_.load(),this.tech_.trigger({type:`mediachange`,bubbles:!0})}),this.mainPlaylistLoader_.on(`playlistunchanged`,()=>{let e=this.mainPlaylistLoader_.media();e.lastExcludeReason_!==`playlist-unchanged`&&this.stuckAtPlaylistEnd_(e)&&(this.excludePlaylist({error:{message:`Playlist no longer updating.`,reason:`playlist-unchanged`}}),this.tech_.trigger(`playliststuck`))}),this.mainPlaylistLoader_.on(`renditiondisabled`,()=>{this.tech_.trigger({type:`usage`,name:`vhs-rendition-disabled`})}),this.mainPlaylistLoader_.on(`renditionenabled`,()=>{this.tech_.trigger({type:`usage`,name:`vhs-rendition-enabled`})}),[`manifestrequeststart`,`manifestrequestcomplete`,`manifestparsestart`,`manifestparsecomplete`,`playlistrequeststart`,`playlistrequestcomplete`,`playlistparsestart`,`playlistparsecomplete`,`renditiondisabled`,`renditionenabled`].forEach(e=>{this.mainPlaylistLoader_.on(e,e=>{this.player_.trigger(R({},e))})})}handleUpdatedMediaPlaylist(e){this.useCueTags_&&this.updateAdCues_(e),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.playlist(e,this.requestOptions_),this.waitingForFastQualityPlaylistReceived_&&this.runFastQualitySwitch_(),this.updateDuration(!e.endList),this.tech_.paused()||(this.mainSegmentLoader_.load(),this.audioSegmentLoader_&&this.audioSegmentLoader_.load())}triggerPresenceUsage_(e,t){let n=e.mediaGroups||{},r=!0,i=Object.keys(n.AUDIO);for(let e in n.AUDIO)for(let t in n.AUDIO[e])n.AUDIO[e][t].uri||(r=!1);r&&this.tech_.trigger({type:`usage`,name:`vhs-demuxed`}),Object.keys(n.SUBTITLES).length&&this.tech_.trigger({type:`usage`,name:`vhs-webvtt`}),Vm.Playlist.isAes(t)&&this.tech_.trigger({type:`usage`,name:`vhs-aes`}),i.length&&Object.keys(n.AUDIO[i[0]]).length>1&&this.tech_.trigger({type:`usage`,name:`vhs-alternate-audio`}),this.useCueTags_&&this.tech_.trigger({type:`usage`,name:`vhs-playlist-cue-tags`})}shouldSwitchToMedia_(e){let t=this.mainPlaylistLoader_.media()||this.mainPlaylistLoader_.pendingMedia_,n=this.tech_.currentTime(),r=this.bufferLowWaterLine(),i=this.bufferHighWaterLine(),a=this.tech_.buffered();return Wm({buffered:a,currentTime:n,currentPlaylist:t,nextPlaylist:e,bufferLowWaterLine:r,bufferHighWaterLine:i,duration:this.duration(),bufferBasedABR:this.bufferBasedABR,log:this.logger_})}setupSegmentLoaderListeners_(){this.mainSegmentLoader_.on(`bandwidthupdate`,()=>{this.checkABR_(`bandwidthupdate`),this.tech_.trigger(`bandwidthupdate`)}),this.mainSegmentLoader_.on(`timeout`,()=>{this.bufferBasedABR&&this.mainSegmentLoader_.load()}),this.bufferBasedABR||this.mainSegmentLoader_.on(`progress`,()=>{this.trigger(`progress`)}),this.mainSegmentLoader_.on(`error`,()=>{let e=this.mainSegmentLoader_.error();this.excludePlaylist({playlistToExclude:e.playlist,error:e})}),this.mainSegmentLoader_.on(`appenderror`,()=>{this.error=this.mainSegmentLoader_.error_,this.trigger(`error`)}),this.mainSegmentLoader_.on(`syncinfoupdate`,()=>{this.onSyncInfoUpdate_()}),this.mainSegmentLoader_.on(`timestampoffset`,()=>{this.tech_.trigger({type:`usage`,name:`vhs-timestamp-offset`})}),this.audioSegmentLoader_.on(`syncinfoupdate`,()=>{this.onSyncInfoUpdate_()}),this.audioSegmentLoader_.on(`appenderror`,()=>{this.error=this.audioSegmentLoader_.error_,this.trigger(`error`)}),this.mainSegmentLoader_.on(`ended`,()=>{this.logger_(`main segment loader ended`),this.onEndOfStream()}),this.timelineChangeController_.on(`audioTimelineBehind`,()=>{let e=this.audioSegmentLoader_.pendingSegment_;if(!e||!e.segment||!e.segment.syncInfo)return;let t=e.segment.syncInfo.end+.01;this.tech_.setCurrentTime(t)}),this.timelineChangeController_.on(`fixBadTimelineChange`,()=>{this.logger_(`Fix bad timeline change. Restarting al segment loaders...`),this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}),this.mainSegmentLoader_.on(`earlyabort`,e=>{this.bufferBasedABR||(this.delegateLoaders_(`all`,[`abort`]),this.excludePlaylist({error:{message:`Aborted early because there isn't enough bandwidth to complete the request without rebuffering.`},playlistExclusionDuration:10}))});let e=()=>{if(!this.sourceUpdater_.hasCreatedSourceBuffers())return this.tryToCreateSourceBuffers_();let e=this.getCodecsOrExclude_();e&&this.sourceUpdater_.addOrChangeSourceBuffers(e)};this.mainSegmentLoader_.on(`trackinfo`,e),this.audioSegmentLoader_.on(`trackinfo`,e),this.mainSegmentLoader_.on(`fmp4`,()=>{this.triggeredFmp4Usage||=(this.tech_.trigger({type:`usage`,name:`vhs-fmp4`}),!0)}),this.audioSegmentLoader_.on(`fmp4`,()=>{this.triggeredFmp4Usage||=(this.tech_.trigger({type:`usage`,name:`vhs-fmp4`}),!0)}),this.audioSegmentLoader_.on(`ended`,()=>{this.logger_(`audioSegmentLoader ended`),this.onEndOfStream()}),[`segmentselected`,`segmentloadstart`,`segmentloaded`,`segmentkeyloadstart`,`segmentkeyloadcomplete`,`segmentdecryptionstart`,`segmentdecryptioncomplete`,`segmenttransmuxingstart`,`segmenttransmuxingcomplete`,`segmenttransmuxingtrackinfoavailable`,`segmenttransmuxingtiminginfoavailable`,`segmentappendstart`,`appendsdone`,`bandwidthupdated`,`timelinechange`,`codecschange`].forEach(e=>{this.mainSegmentLoader_.on(e,e=>{this.player_.trigger(R({},e))}),this.audioSegmentLoader_.on(e,e=>{this.player_.trigger(R({},e))}),this.subtitleSegmentLoader_.on(e,e=>{this.player_.trigger(R({},e))})})}mediaSecondsLoaded_(){return Math.max(this.audioSegmentLoader_.mediaSecondsLoaded+this.mainSegmentLoader_.mediaSecondsLoaded)}load(){this.mainSegmentLoader_.load(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.load(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.load()}pause(){this.mainSegmentLoader_.pause(),this.mediaTypes_.AUDIO.activePlaylistLoader&&this.audioSegmentLoader_.pause(),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&this.subtitleSegmentLoader_.pause()}fastQualityChange_(e=this.selectPlaylist()){e&&e===this.mainPlaylistLoader_.media()?this.logger_(`skipping fastQualityChange because new media is same as old`):(this.switchMedia_(e,`fast-quality`),this.waitingForFastQualityPlaylistReceived_=!0)}runFastQualitySwitch_(){this.waitingForFastQualityPlaylistReceived_=!1,this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}play(){if(this.setupFirstPlay())return;this.tech_.ended()&&this.tech_.setCurrentTime(0),this.hasPlayed_&&this.load();let e=this.tech_.seekable();if(this.tech_.duration()===1/0&&this.tech_.currentTime()<e.start(0))return this.tech_.setCurrentTime(e.end(e.length-1))}setupFirstPlay(){let e=this.mainPlaylistLoader_.media();if(!e||this.tech_.paused()||this.hasPlayed_)return!1;if(!e.endList||e.start){let t=this.seekable();if(!t.length)return!1;let n=t.end(0),r=n;if(e.start){let i=e.start.timeOffset;if(i<0){let a=this.mainPlaylistLoader_.main,o=n+Vm.Playlist.liveEdgeDelay(a,e);r=Math.max(Math.min(o+i,n),t.start(0))}else r=Math.min(n,i)}this.trigger(`firstplay`),this.tech_.setCurrentTime(r)}return this.hasPlayed_=!0,this.load(),!0}handleSourceOpen_(){if(this.tryToCreateSourceBuffers_(),this.tech_.autoplay()){let e=this.tech_.play();e!==void 0&&typeof e.then==`function`&&e.then(null,e=>{})}this.trigger(`sourceopen`)}handleSourceEnded_(){if(!this.inbandTextTracks_.metadataTrack_)return;let e=this.inbandTextTracks_.metadataTrack_.cues;if(!e||!e.length)return;let t=this.duration();e[e.length-1].endTime=isNaN(t)||Math.abs(t)===1/0?Number.MAX_VALUE:t}handleDurationChange_(){this.tech_.trigger(`durationchange`)}onEndOfStream(){let e=this.mainSegmentLoader_.ended_;if(this.mediaTypes_.AUDIO.activePlaylistLoader){let t=this.mainSegmentLoader_.getCurrentMediaInfo_();!t||t.hasVideo?e&&=this.audioSegmentLoader_.ended_:e=this.audioSegmentLoader_.ended_}e&&(this.stopABRTimer_(),this.sourceUpdater_.endOfStream())}stuckAtPlaylistEnd_(e){if(!this.seekable().length)return!1;let t=this.syncController_.getExpiredTime(e,this.duration());if(t===null)return!1;let n=Vm.Playlist.playlistEnd(e,t),r=this.tech_.currentTime(),i=this.tech_.buffered();if(!i.length)return n-r<=Tu;let a=i.end(i.length-1);return a-r<=Tu&&n-a<=Tu}excludePlaylist({playlistToExclude:e=this.mainPlaylistLoader_.media(),error:t={},playlistExclusionDuration:n}){if(e||=this.mainPlaylistLoader_.media(),n=n||t.playlistExclusionDuration||this.playlistExclusionDuration,!e){this.error=t,this.mediaSource.readyState===`open`?this.sourceUpdater_.endOfStream(`network`):this.trigger(`error`);return}e.playlistErrors_++;let r=this.mainPlaylistLoader_.main.playlists,i=r.filter(Qu),a=i.length===1&&i[0]===e;if(r.length===1&&n!==1/0)return Z.log.warn(`Problem encountered with playlist ${e.id}. Trying again since it is the only playlist.`),this.tech_.trigger(`retryplaylist`),this.mainPlaylistLoader_.load(a);if(a){if(this.main().contentSteering){let t=this.pathwayAttribute_(e),n=this.contentSteeringController_.steeringManifest.ttl*1e3;this.contentSteeringController_.excludePathway(t),this.excludeThenChangePathway_(),setTimeout(()=>{this.contentSteeringController_.addAvailablePathway(t)},n);return}let t=!1;r.forEach(n=>{if(n===e)return;let r=n.excludeUntil;r!==void 0&&r!==1/0&&(t=!0,delete n.excludeUntil)}),t&&(Z.log.warn(`Removing other playlists from the exclusion list because the last rendition is about to be excluded.`),this.tech_.trigger(`retryplaylist`))}let o;o=e.playlistErrors_>this.maxPlaylistRetries?1/0:Date.now()+n*1e3,e.excludeUntil=o,t.reason&&(e.lastExcludeReason_=t.reason),this.tech_.trigger(`excludeplaylist`),this.tech_.trigger({type:`usage`,name:`vhs-rendition-excluded`});let s=this.selectPlaylist();if(!s){this.error=`Playback cannot continue. No available working or supported playlists.`,this.trigger(`error`);return}let c=t.internal?this.logger_:Z.log.warn,l=t.message?` `+t.message:``;c(`${t.internal?`Internal problem`:`Problem`} encountered with playlist ${e.id}.${l} Switching to playlist ${s.id}.`),s.attributes.AUDIO!==e.attributes.AUDIO&&this.delegateLoaders_(`audio`,[`abort`,`pause`]),s.attributes.SUBTITLES!==e.attributes.SUBTITLES&&this.delegateLoaders_(`subtitle`,[`abort`,`pause`]),this.delegateLoaders_(`main`,[`abort`,`pause`]);let u=s.targetDuration/2*1e3||5e3,d=typeof s.lastRequest==`number`&&Date.now()-s.lastRequest<=u;return this.switchMedia_(s,`exclude`,a||d)}pauseLoading(){this.delegateLoaders_(`all`,[`abort`,`pause`]),this.stopABRTimer_()}delegateLoaders_(e,t){let n=[],r=e===`all`;(r||e===`main`)&&n.push(this.mainPlaylistLoader_);let i=[];(r||e===`audio`)&&i.push(`AUDIO`),(r||e===`subtitle`)&&(i.push(`CLOSED-CAPTIONS`),i.push(`SUBTITLES`)),i.forEach(e=>{let t=this.mediaTypes_[e]&&this.mediaTypes_[e].activePlaylistLoader;t&&n.push(t)}),[`main`,`audio`,`subtitle`].forEach(t=>{let r=this[`${t}SegmentLoader_`];r&&(e===t||e===`all`)&&n.push(r)}),n.forEach(e=>t.forEach(t=>{typeof e[t]==`function`&&e[t]()}))}setCurrentTime(e){let t=Du(this.tech_.buffered(),e);if(!(this.mainPlaylistLoader_&&this.mainPlaylistLoader_.media())||!this.mainPlaylistLoader_.media().segments)return 0;if(t&&t.length)return e;this.mainSegmentLoader_.pause(),this.mainSegmentLoader_.resetEverything(),this.mediaTypes_.AUDIO.activePlaylistLoader&&(this.audioSegmentLoader_.pause(),this.audioSegmentLoader_.resetEverything()),this.mediaTypes_.SUBTITLES.activePlaylistLoader&&(this.subtitleSegmentLoader_.pause(),this.subtitleSegmentLoader_.resetEverything()),this.load()}duration(){if(!this.mainPlaylistLoader_)return 0;let e=this.mainPlaylistLoader_.media();return e?e.endList?this.mediaSource?this.mediaSource.duration:Vm.Playlist.duration(e):1/0:0}seekable(){return this.seekable_}getSeekableRange_(e,t){let n=e.media();if(!n)return null;let r=this.syncController_.getMediaSequenceSync(t);if(r&&r.isReliable){let e=r.start,t=r.end;if(!isFinite(e)||!isFinite(t))return null;let i=Vm.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n);return Su([[e,Math.max(e,t-i)]])}let i=this.syncController_.getExpiredTime(n,this.duration());if(i===null)return null;let a=Vm.Playlist.seekable(n,i,Vm.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main,n));return a.length?a:null}computeFinalSeekable_(e,t){if(!t)return e;let n=e.start(0),r=e.end(0),i=t.start(0),a=t.end(0);return i>r||n>a?e:Su([[Math.max(n,i),Math.min(r,a)]])}onSyncInfoUpdate_(){if(!this.mainPlaylistLoader_)return;let e=this.getSeekableRange_(this.mainPlaylistLoader_,`main`);if(!e)return;let t;if(this.mediaTypes_.AUDIO.activePlaylistLoader&&(t=this.getSeekableRange_(this.mediaTypes_.AUDIO.activePlaylistLoader,`audio`),!t))return;let n=this.seekable_;if(this.seekable_=this.computeFinalSeekable_(e,t),!this.seekable_||n&&n.length&&this.seekable_.length&&n.start(0)===this.seekable_.start(0)&&n.end(0)===this.seekable_.end(0))return;this.logger_(`seekable updated [${ju(this.seekable_)}]`);let r={seekableRanges:this.seekable_};this.trigger({type:`seekablerangeschanged`,metadata:r}),this.tech_.trigger(`seekablechanged`)}updateDuration(e){if(this.updateDuration_&&=(this.mediaSource.removeEventListener(`sourceopen`,this.updateDuration_),null),this.mediaSource.readyState!==`open`){this.updateDuration_=this.updateDuration.bind(this,e),this.mediaSource.addEventListener(`sourceopen`,this.updateDuration_);return}if(e){let e=this.seekable();if(!e.length)return;(isNaN(this.mediaSource.duration)||this.mediaSource.duration<e.end(e.length-1))&&this.sourceUpdater_.setDuration(e.end(e.length-1));return}let t=this.tech_.buffered(),n=Vm.Playlist.duration(this.mainPlaylistLoader_.media());t.length>0&&(n=Math.max(n,t.end(t.length-1))),this.mediaSource.duration!==n&&this.sourceUpdater_.setDuration(n)}dispose(){this.trigger(`dispose`),this.decrypter_.terminate(),this.mainPlaylistLoader_.dispose(),this.mainSegmentLoader_.dispose(),this.contentSteeringController_.dispose(),this.keyStatusMap_.clear(),this.loadOnPlay_&&this.tech_.off(`play`,this.loadOnPlay_),[`AUDIO`,`SUBTITLES`].forEach(e=>{let t=this.mediaTypes_[e].groups;for(let e in t)t[e].forEach(e=>{e.playlistLoader&&e.playlistLoader.dispose()})}),this.audioSegmentLoader_.dispose(),this.subtitleSegmentLoader_.dispose(),this.sourceUpdater_.dispose(),this.timelineChangeController_.dispose(),this.stopABRTimer_(),this.updateDuration_&&this.mediaSource.removeEventListener(`sourceopen`,this.updateDuration_),this.mediaSource.removeEventListener(`durationchange`,this.handleDurationChange_),this.mediaSource.removeEventListener(`sourceopen`,this.handleSourceOpen_),this.mediaSource.removeEventListener(`sourceended`,this.handleSourceEnded_),this.off()}main(){return this.mainPlaylistLoader_.main}media(){return this.mainPlaylistLoader_.media()||this.initialMedia_}areMediaTypesKnown_(){let e=!!this.mediaTypes_.AUDIO.activePlaylistLoader,t=!!this.mainSegmentLoader_.getCurrentMediaInfo_(),n=!e||!!this.audioSegmentLoader_.getCurrentMediaInfo_();return!(!t||!n)}getCodecsOrExclude_(){let e={main:this.mainSegmentLoader_.getCurrentMediaInfo_()||{},audio:this.audioSegmentLoader_.getCurrentMediaInfo_()||{}},t=this.mainSegmentLoader_.getPendingSegmentPlaylist()||this.media();e.video=e.main;let n=Ed(this.main(),t),r={},i=!!this.mediaTypes_.AUDIO.activePlaylistLoader;if(e.main.hasVideo&&(r.video=n.video||e.main.videoCodec||Mt),e.main.isMuxed&&(r.video+=`,${n.audio||e.main.audioCodec||jt}`),(e.main.hasAudio&&!e.main.isMuxed||e.audio.hasAudio||i)&&(r.audio=n.audio||e.main.audioCodec||e.audio.audioCodec||jt,e.audio.isFmp4=e.main.hasAudio&&!e.main.isMuxed?e.main.isFmp4:e.audio.isFmp4),!r.audio&&!r.video){this.excludePlaylist({playlistToExclude:t,error:{message:`Could not determine codecs for playlist.`},playlistExclusionDuration:1/0});return}let a=(e,t)=>e?kt(t,this.usingManagedMediaSource_):At(t),o={},s;if([`video`,`audio`].forEach(function(t){if(r.hasOwnProperty(t)&&!a(e[t].isFmp4,r[t])){let n=e[t].isFmp4?`browser`:`muxer`;o[n]=o[n]||[],o[n].push(r[t]),t===`audio`&&(s=n)}}),i&&s&&t.attributes.AUDIO){let e=t.attributes.AUDIO;this.main().playlists.forEach(n=>{(n.attributes&&n.attributes.AUDIO)===e&&n!==t&&(n.excludeUntil=1/0)}),this.logger_(`excluding audio group ${e} as ${s} does not support codec(s): "${r.audio}"`)}if(Object.keys(o).length){let e=Object.keys(o).reduce((e,t)=>(e&&(e+=`, `),e+=`${t} does not support codec(s): "${o[t].join(`,`)}"`,e),``)+`.`;this.excludePlaylist({playlistToExclude:t,error:{internal:!0,message:e},playlistExclusionDuration:1/0})}else{if(this.sourceUpdater_.hasCreatedSourceBuffers()&&!this.sourceUpdater_.canChangeType()){let e=[];if([`video`,`audio`].forEach(t=>{let n=(wt(this.sourceUpdater_.codecs[t]||``)[0]||{}).type,i=(wt(r[t]||``)[0]||{}).type;n&&i&&n.toLowerCase()!==i.toLowerCase()&&e.push(`"${this.sourceUpdater_.codecs[t]}" -> "${r[t]}"`)}),e.length){this.excludePlaylist({playlistToExclude:t,error:{message:`Codec switching not supported: ${e.join(`, `)}.`,internal:!0},playlistExclusionDuration:1/0});return}}return r}}tryToCreateSourceBuffers_(){if(this.mediaSource.readyState!==`open`||this.sourceUpdater_.hasCreatedSourceBuffers()||!this.areMediaTypesKnown_())return;let e=this.getCodecsOrExclude_();if(!e)return;this.sourceUpdater_.createSourceBuffers(e);let t=[e.video,e.audio].filter(Boolean).join(`,`);this.excludeIncompatibleVariants_(t)}excludeUnsupportedVariants_(){let e=this.main().playlists,t=[];Object.keys(e).forEach(n=>{let r=e[n];if(t.indexOf(r.id)!==-1)return;t.push(r.id);let i=Ed(this.main,r),a=[];i.audio&&!At(i.audio)&&!kt(i.audio,this.usingManagedMediaSource_)&&a.push(`audio codec ${i.audio}`),i.video&&!At(i.video)&&!kt(i.video,this.usingManagedMediaSource_)&&a.push(`video codec ${i.video}`),i.text&&i.text===`stpp.ttml.im1t`&&a.push(`text codec ${i.text}`),a.length&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id} for unsupported: ${a.join(`, `)}`))})}excludeIncompatibleVariants_(e){let t=[],n=this.main().playlists,r=wd(wt(e)),i=Td(r),a=r.video&&wt(r.video)[0]||null,o=r.audio&&wt(r.audio)[0]||null;Object.keys(n).forEach(e=>{let r=n[e];if(t.indexOf(r.id)!==-1||r.excludeUntil===1/0)return;t.push(r.id);let s=[],c=Ed(this.mainPlaylistLoader_.main,r),l=Td(c);if(c.audio||c.video){if(l!==i&&s.push(`codec count "${l}" !== "${i}"`),!this.sourceUpdater_.canChangeType()){let e=c.video&&wt(c.video)[0]||null,t=c.audio&&wt(c.audio)[0]||null;e&&a&&e.type.toLowerCase()!==a.type.toLowerCase()&&s.push(`video codec "${e.type}" !== "${a.type}"`),t&&o&&t.type.toLowerCase()!==o.type.toLowerCase()&&s.push(`audio codec "${t.type}" !== "${o.type}"`)}s.length&&(r.excludeUntil=1/0,this.logger_(`excluding ${r.id}: ${s.join(` && `)}`))}})}updateAdCues_(e){let t=0,n=this.seekable();n.length&&(t=n.start(0)),mm(e,this.cueTagsTrack_,t)}goalBufferLength(){let e=this.tech_.currentTime(),t=bf.GOAL_BUFFER_LENGTH,n=bf.GOAL_BUFFER_LENGTH_RATE,r=Math.max(t,bf.MAX_GOAL_BUFFER_LENGTH);return Math.min(t+e*n,r)}bufferLowWaterLine(){let e=this.tech_.currentTime(),t=bf.BUFFER_LOW_WATER_LINE,n=bf.BUFFER_LOW_WATER_LINE_RATE,r=Math.max(t,bf.MAX_BUFFER_LOW_WATER_LINE),i=Math.max(t,bf.EXPERIMENTAL_MAX_BUFFER_LOW_WATER_LINE);return Math.min(t+e*n,this.bufferBasedABR?i:r)}bufferHighWaterLine(){return bf.BUFFER_HIGH_WATER_LINE}addDateRangesToTextTrack_(e){Ep(this.inbandTextTracks_,`com.apple.streaming`,this.tech_),Tp({inbandTextTracks:this.inbandTextTracks_,dateRanges:e})}addMetadataToTextTrack(e,t,n){let r=this.sourceUpdater_.videoBuffer?this.sourceUpdater_.videoTimestampOffset():this.sourceUpdater_.audioTimestampOffset();Ep(this.inbandTextTracks_,e,this.tech_),Sp({inbandTextTracks:this.inbandTextTracks_,metadataArray:t,timestampOffset:r,videoDuration:n})}pathwayAttribute_(e){return e.attributes[`PATHWAY-ID`]||e.attributes.serviceLocation}initContentSteeringController_(){let e=this.main();if(e.contentSteering){for(let t of e.playlists)this.contentSteeringController_.addAvailablePathway(this.pathwayAttribute_(t));this.contentSteeringController_.assignTagProperties(e.uri,e.contentSteering),this.contentSteeringController_.queryBeforeStart?this.contentSteeringController_.requestSteeringManifest(!0):this.tech_.one(`canplay`,()=>{this.contentSteeringController_.requestSteeringManifest()})}}resetContentSteeringController_(){this.contentSteeringController_.clearAvailablePathways(),this.contentSteeringController_.dispose(),this.initContentSteeringController_()}attachContentSteeringListeners_(){this.contentSteeringController_.on(`content-steering`,this.excludeThenChangePathway_.bind(this)),[`contentsteeringloadstart`,`contentsteeringloadcomplete`,`contentsteeringparsed`].forEach(e=>{this.contentSteeringController_.on(e,e=>{this.trigger(R({},e))})}),this.sourceType_===`dash`&&this.mainPlaylistLoader_.on(`loadedplaylist`,()=>{let e=this.main();(this.contentSteeringController_.didDASHTagChange(e.uri,e.contentSteering)||(()=>{let t=this.contentSteeringController_.getAvailablePathways(),n=[];for(let r of e.playlists){let e=r.attributes.serviceLocation;if(e&&(n.push(e),!t.has(e)))return!0}return!(n.length||!t.size)})())&&this.resetContentSteeringController_()})}excludeThenChangePathway_(){let e=this.contentSteeringController_.getPathway();if(!e)return;this.handlePathwayClones_();let t=this.main().playlists,n=new Set,r=!1;Object.keys(t).forEach(i=>{let a=t[i],o=this.pathwayAttribute_(a),s=o&&e!==o;a.excludeUntil===1/0&&a.lastExcludeReason_===`content-steering`&&!s&&(delete a.excludeUntil,delete a.lastExcludeReason_,r=!0);let c=!a.excludeUntil&&a.excludeUntil!==1/0;!n.has(a.id)&&s&&c&&(n.add(a.id),a.excludeUntil=1/0,a.lastExcludeReason_=`content-steering`,this.logger_(`excluding ${a.id} for ${a.lastExcludeReason_}`))}),this.contentSteeringController_.manifestType_===`DASH`&&Object.keys(this.mediaTypes_).forEach(t=>{let n=this.mediaTypes_[t];if(n.activePlaylistLoader){let t=n.activePlaylistLoader.media_;t&&t.attributes.serviceLocation!==e&&(r=!0)}}),r&&this.changeSegmentPathway_()}handlePathwayClones_(){let e=this.main().playlists,t=this.contentSteeringController_.currentPathwayClones,n=this.contentSteeringController_.nextPathwayClones;if(t&&t.size||n&&n.size){for(let[e,r]of t.entries())n.get(e)||(this.mainPlaylistLoader_.updateOrDeleteClone(r),this.contentSteeringController_.excludePathway(e));for(let[r,i]of n.entries()){let n=t.get(r);n?this.equalPathwayClones_(n,i)||(this.mainPlaylistLoader_.updateOrDeleteClone(i,!0),this.contentSteeringController_.addAvailablePathway(r)):(e.filter(e=>e.attributes[`PATHWAY-ID`]===i[`BASE-ID`]).forEach(e=>{this.mainPlaylistLoader_.addClonePathway(i,e)}),this.contentSteeringController_.addAvailablePathway(r))}this.contentSteeringController_.currentPathwayClones=new Map(JSON.parse(JSON.stringify([...n])))}}equalPathwayClones_(e,t){if(e[`BASE-ID`]!==t[`BASE-ID`]||e.ID!==t.ID||e[`URI-REPLACEMENT`].HOST!==t[`URI-REPLACEMENT`].HOST)return!1;let n=e[`URI-REPLACEMENT`].PARAMS,r=t[`URI-REPLACEMENT`].PARAMS;for(let e in n)if(n[e]!==r[e])return!1;for(let e in r)if(n[e]!==r[e])return!1;return!0}changeSegmentPathway_(){let e=this.selectPlaylist();this.pauseLoading(),this.contentSteeringController_.manifestType_===`DASH`&&this.switchMediaForDASHContentSteering_(),this.switchMedia_(e,`content-steering`)}excludeNonUsablePlaylistsByKeyId_(){if(!this.mainPlaylistLoader_||!this.mainPlaylistLoader_.main)return;let e=0,t=`non-usable`;this.mainPlaylistLoader_.main.playlists.forEach(n=>{let r=this.mainPlaylistLoader_.getKeyIdSet(n);r&&r.size&&r.forEach(r=>{let i=`usable`,a=this.keyStatusMap_.has(r)&&this.keyStatusMap_.get(r)===i,o=n.lastExcludeReason_===t&&n.excludeUntil===1/0;a?a&&o&&(delete n.excludeUntil,delete n.lastExcludeReason_,this.logger_(`enabling playlist ${n.id} because key ID ${r} is ${i}`)):(n.excludeUntil!==1/0&&n.lastExcludeReason_!==t&&(n.excludeUntil=1/0,n.lastExcludeReason_=t,this.logger_(`excluding playlist ${n.id} because the key ID ${r} doesn't exist in the keyStatusMap or is not ${i}`)),e++)})}),e>=this.mainPlaylistLoader_.main.playlists.length&&this.mainPlaylistLoader_.main.playlists.forEach(e=>{let n=e&&e.attributes&&e.attributes.RESOLUTION&&e.attributes.RESOLUTION.height<720,r=e.excludeUntil===1/0&&e.lastExcludeReason_===t;n&&r&&(delete e.excludeUntil,Z.log.warn(`enabling non-HD playlist ${e.id} because all playlists were excluded due to ${t} key IDs`))})}addKeyStatus_(e,t){let n=(typeof e==`string`?e:lm(e)).slice(0,32).toLowerCase();this.logger_(`KeyStatus '${t}' with key ID ${n} added to the keyStatusMap`),this.keyStatusMap_.set(n,t)}updatePlaylistByKeyStatus(e,t){this.addKeyStatus_(e,t),this.waitingForFastQualityPlaylistReceived_||this.excludeNonUsableThenChangePlaylist_(),this.mainPlaylistLoader_.off(`loadedplaylist`,this.excludeNonUsableThenChangePlaylist_.bind(this)),this.mainPlaylistLoader_.on(`loadedplaylist`,this.excludeNonUsableThenChangePlaylist_.bind(this))}excludeNonUsableThenChangePlaylist_(){this.excludeNonUsablePlaylistsByKeyId_(),this.fastQualityChange_()}}const Km=(e,t,n)=>r=>{let i=e.main.playlists[t],a=Zu(i),o=Qu(i);if(r===void 0)return o;r?delete i.disabled:i.disabled=!0;let s={renditionInfo:{id:t,bandwidth:i.attributes.BANDWIDTH,resolution:i.attributes.RESOLUTION,codecs:i.attributes.CODECS},cause:`fast-quality`};return r!==o&&!a&&(r?(n(i),e.trigger({type:`renditionenabled`,metadata:s})):e.trigger({type:`renditiondisabled`,metadata:s})),r};class qm{constructor(e,t,n){let{playlistController_:r}=e,i=r.fastQualityChange_.bind(r);if(t.attributes){let e=t.attributes.RESOLUTION;this.width=e&&e.width,this.height=e&&e.height,this.bandwidth=t.attributes.BANDWIDTH,this.frameRate=t.attributes[`FRAME-RATE`]}this.codecs=Ed(r.main(),t),this.playlist=t,this.id=n,this.enabled=Km(e.playlists,t.id,i)}}const Jm=function(e){e.representations=()=>{let t=e.playlistController_.main(),n=od(t)?e.playlistController_.getAudioTrackPlaylists_():t.playlists;return n?n.filter(e=>!Zu(e)).map((t,n)=>new qm(e,t,t.id)):[]}},Ym=[`seeking`,`seeked`,`pause`,`playing`,`error`];class Xm extends Z.EventTarget{constructor(e){super(),this.playlistController_=e.playlistController,this.tech_=e.tech,this.seekable=e.seekable,this.allowSeeksWithinUnsafeLiveWindow=e.allowSeeksWithinUnsafeLiveWindow,this.liveRangeSafeTimeDelta=e.liveRangeSafeTimeDelta,this.media=e.media,this.playedRanges_=[],this.consecutiveUpdates=0,this.lastRecordedTime=null,this.checkCurrentTimeTimeout_=null,this.logger_=xu(`PlaybackWatcher`),this.logger_(`initialize`);let t=()=>this.monitorCurrentTime_(),n=()=>this.monitorCurrentTime_(),r=()=>this.techWaiting_(),i=()=>this.resetTimeUpdate_(),a=this.playlistController_,o=[`main`,`subtitle`,`audio`],s={};o.forEach(e=>{s[e]={reset:()=>this.resetSegmentDownloads_(e),updateend:()=>this.checkSegmentDownloads_(e)},a[`${e}SegmentLoader_`].on(`appendsdone`,s[e].updateend),a[`${e}SegmentLoader_`].on(`playlistupdate`,s[e].reset),this.tech_.on([`seeked`,`seeking`],s[e].reset)});let c=e=>{[`main`,`audio`].forEach(t=>{a[`${t}SegmentLoader_`][e](`appended`,this.seekingAppendCheck_)})};this.seekingAppendCheck_=()=>{this.fixesBadSeeks_()&&(this.consecutiveUpdates=0,this.lastRecordedTime=this.tech_.currentTime(),c(`off`))},this.clearSeekingAppendCheck_=()=>c(`off`),this.watchForBadSeeking_=()=>{this.clearSeekingAppendCheck_(),c(`on`)},this.tech_.on(`seeked`,this.clearSeekingAppendCheck_),this.tech_.on(`seeking`,this.watchForBadSeeking_),this.tech_.on(`waiting`,r),this.tech_.on(Ym,i),this.tech_.on(`canplay`,n),this.tech_.one(`play`,t),this.dispose=()=>{this.clearSeekingAppendCheck_(),this.logger_(`dispose`),this.tech_.off(`waiting`,r),this.tech_.off(Ym,i),this.tech_.off(`canplay`,n),this.tech_.off(`play`,t),this.tech_.off(`seeking`,this.watchForBadSeeking_),this.tech_.off(`seeked`,this.clearSeekingAppendCheck_),o.forEach(e=>{a[`${e}SegmentLoader_`].off(`appendsdone`,s[e].updateend),a[`${e}SegmentLoader_`].off(`playlistupdate`,s[e].reset),this.tech_.off([`seeked`,`seeking`],s[e].reset)}),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.resetTimeUpdate_()}}monitorCurrentTime_(){this.checkCurrentTime_(),this.checkCurrentTimeTimeout_&&x.clearTimeout(this.checkCurrentTimeTimeout_),this.checkCurrentTimeTimeout_=x.setTimeout(this.monitorCurrentTime_.bind(this),250)}resetSegmentDownloads_(e){let t=this.playlistController_[`${e}SegmentLoader_`];this[`${e}StalledDownloads_`]>0&&this.logger_(`resetting possible stalled download count for ${e} loader`),this[`${e}StalledDownloads_`]=0,this[`${e}Buffered_`]=t.buffered_()}checkSegmentDownloads_(e){let t=this.playlistController_,n=t[`${e}SegmentLoader_`],r=n.buffered_(),i=Pu(this[`${e}Buffered_`],r);if(this[`${e}Buffered_`]=r,i){let n={bufferedRanges:r};t.trigger({type:`bufferedrangeschanged`,metadata:n}),this.resetSegmentDownloads_(e)}else this[`${e}StalledDownloads_`]++,this.logger_(`found #${this[`${e}StalledDownloads_`]} ${e} appends that did not increase buffer (possible stalled download)`,{playlistId:n.playlist_&&n.playlist_.id,buffered:Nu(r)}),this[`${e}StalledDownloads_`]<10||(this.logger_(`${e} loader stalled download exclusion`),this.resetSegmentDownloads_(e),this.tech_.trigger({type:`usage`,name:`vhs-${e}-download-exclusion`}),e!==`subtitle`&&t.excludePlaylist({error:{message:`Excessive ${e} segment downloading detected.`},playlistExclusionDuration:1/0}))}checkCurrentTime_(){if(this.tech_.paused()||this.tech_.seeking())return;let e=this.tech_.currentTime(),t=this.tech_.buffered();if(this.lastRecordedTime===e&&(!t.length||e+Tu>=t.end(t.length-1)))return this.techWaiting_();if(this.consecutiveUpdates>=5&&e===this.lastRecordedTime)this.consecutiveUpdates++,this.waiting_();else if(e===this.lastRecordedTime)this.consecutiveUpdates++;else{this.playedRanges_.push(Su([this.lastRecordedTime,e]));let t={playedRanges:this.playedRanges_};this.playlistController_.trigger({type:`playedrangeschanged`,metadata:t}),this.consecutiveUpdates=0,this.lastRecordedTime=e}}resetTimeUpdate_(){this.consecutiveUpdates=0}fixesBadSeeks_(){if(!this.tech_.seeking())return!1;let e=this.seekable(),t=this.tech_.currentTime(),n=this.afterSeekableWindow_(e,t,this.media(),this.allowSeeksWithinUnsafeLiveWindow),r;if(n&&(r=e.end(e.length-1)),this.beforeSeekableWindow_(e,t)){let t=e.start(0);r=t+(t===e.end(0)?0:Tu)}if(r!==void 0)return this.logger_(`Trying to seek outside of seekable at time ${t} with seekable range ${ju(e)}. Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0;let i=this.playlistController_.sourceUpdater_,a=this.tech_.buffered(),o=i.audioBuffer?i.audioBuffered():null,s=i.videoBuffer?i.videoBuffered():null,c=this.media(),l=c.partTargetDuration?c.partTargetDuration:(c.targetDuration-wu)*2,u=[o,s];for(let e=0;e<u.length;e++)if(u[e]&&Iu(u[e],t)<l)return!1;let d=Ou(a,t);return d.length!==0&&(r=d.start(0)+Tu,this.logger_(`Buffered region starts (${d.start(0)}) just beyond seek point (${t}). Seeking to ${r}.`),this.tech_.setCurrentTime(r),!0)}waiting_(){if(this.techWaiting_())return;let e=this.tech_.currentTime(),t=this.tech_.buffered(),n=Du(t,e);n.length&&e+3<=n.end(0)&&(this.resetTimeUpdate_(),this.tech_.setCurrentTime(e),this.logger_(`Stopped at ${e} while inside a buffered region [${n.start(0)} -> ${n.end(0)}]. Attempting to resume playback by seeking to the current time.`),this.tech_.trigger({type:`usage`,name:`vhs-unknown-waiting`}))}techWaiting_(){let e=this.seekable(),t=this.tech_.currentTime();if(this.tech_.seeking())return!0;if(this.beforeSeekableWindow_(e,t)){let n=e.end(e.length-1);return this.logger_(`Fell out of live window at time ${t}. Seeking to live point (seekable end) ${n}`),this.resetTimeUpdate_(),this.tech_.setCurrentTime(n),this.tech_.trigger({type:`usage`,name:`vhs-live-resync`}),!0}let n=this.tech_.vhs.playlistController_.sourceUpdater_,r=this.tech_.buffered();if(this.videoUnderflow_({audioBuffered:n.audioBuffered(),videoBuffered:n.videoBuffered(),currentTime:t}))return this.resetTimeUpdate_(),this.tech_.setCurrentTime(t),this.tech_.trigger({type:`usage`,name:`vhs-video-underflow`}),!0;let i=Ou(r,t);return i.length>0&&(this.logger_(`Stopped at ${t} and seeking to ${i.start(0)}`),this.resetTimeUpdate_(),this.skipTheGap_(t),!0)}afterSeekableWindow_(e,t,n,r=!1){if(!e.length)return!1;let i=e.end(e.length-1)+Tu,a=!n.endList,o=typeof n.partTargetDuration==`number`;return a&&(o||r)&&(i=e.end(e.length-1)+n.targetDuration*3),t>i}beforeSeekableWindow_(e,t){return!!(e.length&&e.start(0)>0&&t<e.start(0)-this.liveRangeSafeTimeDelta)}videoUnderflow_({videoBuffered:e,audioBuffered:t,currentTime:n}){if(!e)return;let r;if(e.length&&t.length){let i=Du(e,n-3),a=Du(e,n),o=Du(t,n);o.length&&!a.length&&i.length&&(r={start:i.end(0),end:o.end(0)})}else Ou(e,n).length||(r=this.gapFromVideoUnderflow_(e,n));return r?(this.logger_(`Encountered a gap in video from ${r.start} to ${r.end}. Seeking to current time ${n}`),!0):!1}skipTheGap_(e){let t=this.tech_.buffered(),n=this.tech_.currentTime(),r=Ou(t,n);if(this.resetTimeUpdate_(),r.length===0||n!==e)return;this.logger_(`skipTheGap_:`,`currentTime:`,n,`scheduled currentTime:`,e,`nextRange start:`,r.start(0)),this.tech_.setCurrentTime(r.start(0)+wu);let i={gapInfo:{from:n,to:r.start(0)}};this.playlistController_.trigger({type:`gapjumped`,metadata:i}),this.tech_.trigger({type:`usage`,name:`vhs-gap-skip`})}gapFromVideoUnderflow_(e,t){let n=ku(e);for(let e=0;e<n.length;e++){let r=n.start(e),i=n.end(e);if(t-r<4&&t-r>2)return{start:r,end:i}}return null}}const Zm={errorInterval:30,getSource(e){return e(this.tech({IWillNotUseThisInPlugins:!0}).currentSource_||this.currentSource())}},Qm=function(e,t){let n=0,r=0,i=Q(Zm,t);e.ready(()=>{e.trigger({type:`usage`,name:`vhs-error-reload-initialized`})});let a=function(){r&&e.currentTime(r)},o=function(t){t!=null&&(r=e.duration()!==1/0&&e.currentTime()||0,e.one(`loadedmetadata`,a),e.src(t),e.trigger({type:`usage`,name:`vhs-error-reload`}),e.play())},s=function(){if(Date.now()-n<i.errorInterval*1e3)e.trigger({type:`usage`,name:`vhs-error-reload-canceled`});else if(!i.getSource||typeof i.getSource!=`function`)Z.log.error(`ERROR: reloadSourceOnError - The option getSource must be a function!`);else return n=Date.now(),i.getSource.call(e,o)},c=function(){e.off(`loadedmetadata`,a),e.off(`error`,s),e.off(`dispose`,c)};e.on(`error`,s),e.on(`dispose`,c),e.reloadSourceOnError=function(t){c(),Qm(e,t)}},$m=function(e){Qm(this,e)};var eh=`3.17.5`,th=`7.1.0`,nh=`1.4.0`,rh=`7.2.0`,ih=`4.0.2`;const ah={PlaylistLoader:Ld,Playlist:sd,utils:Zd,STANDARD_PLAYLIST_SELECTOR:pp,INITIAL_PLAYLIST_SELECTOR:gp,lastBandwidthSelector:pp,movingAverageBandwidthSelector:mp,comparePlaylistBandwidth:up,comparePlaylistResolution:dp,xhr:Vd()};Object.keys(bf).forEach(e=>{Object.defineProperty(ah,e,{get(){return Z.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),bf[e]},set(t){Z.log.warn(`using Vhs.${e} is UNSAFE be sure you know what you are doing`),typeof t!=`number`||t<0?Z.log.warn(`value of Vhs.${e} must be greater than or equal to 0`):bf[e]=t}})});const oh=`videojs-vhs`,sh=function(e,t){let n=t.media(),r=-1;for(let t=0;t<e.length;t++)if(e[t].id===n.id){r=t;break}e.selectedIndex_=r,e.trigger({selectedIndex:r,type:`change`})},ch=function(e,t){t.representations().forEach(t=>{e.addQualityLevel(t)}),sh(e,t.playlists)};ah.canPlaySource=function(){return Z.log.warn(`VHS is no longer a tech. Please remove it from your player's techOrder.`)};const lh=(e,t,n)=>{if(!e)return e;let r={};t&&t.attributes&&t.attributes.CODECS&&(r=wd(wt(t.attributes.CODECS))),n&&n.attributes&&n.attributes.CODECS&&(r.audio=n.attributes.CODECS);let i=Ot(r.video),a=Ot(r.audio),o={};for(let n in e)o[n]={},a&&(o[n].audioContentType=a),i&&(o[n].videoContentType=i),t.contentProtection&&t.contentProtection[n]&&t.contentProtection[n].pssh&&(o[n].pssh=t.contentProtection[n].pssh),typeof e[n]==`string`&&(o[n].url=e[n]);return Q(e,o)},uh=(e,t)=>e.reduce((e,n)=>{if(!n.contentProtection)return e;let r=t.reduce((e,t)=>{let r=n.contentProtection[t];return r&&r.pssh&&(e[t]={pssh:r.pssh}),e},{});return Object.keys(r).length&&e.push(r),e},[]),dh=({player:e,sourceKeySystems:t,audioMedia:n,mainPlaylists:r})=>{if(!e.eme.initializeMediaKeys)return Promise.resolve();let i=n?r.concat([n]):r,a=uh(i,Object.keys(t)),o=[],s=[];return a.forEach(t=>{s.push(new Promise((t,n)=>{e.tech_.one(`keysessioncreated`,t)})),o.push(new Promise((n,r)=>{e.eme.initializeMediaKeys({keySystems:t},e=>{e?r(e):n()})}))}),Promise.race([Promise.all(o),Promise.race(s)])},fh=({player:e,sourceKeySystems:t,media:n,audioMedia:r})=>{let i=lh(t,n,r);return i?(e.currentSource().keySystems=i,i&&!e.eme?(Z.log.warn(`DRM encrypted source cannot be decrypted without a DRM plugin`),!1):!0):!1},ph=()=>{if(!x.localStorage)return null;let e=x.localStorage.getItem(oh);if(!e)return null;try{return JSON.parse(e)}catch{return null}},mh=e=>{if(!x.localStorage)return!1;let t=ph();t=t?Q(t,e):e;try{x.localStorage.setItem(oh,JSON.stringify(t))}catch{return!1}return t},hh=e=>e.toLowerCase().indexOf(`data:application/vnd.videojs.vhs+json,`)===0?JSON.parse(e.substring(e.indexOf(`,`)+1)):e,gh=(e,t)=>{e._requestCallbackSet||=new Set,e._requestCallbackSet.add(t)},_h=(e,t)=>{e._responseCallbackSet||=new Set,e._responseCallbackSet.add(t)},vh=(e,t)=>{e._requestCallbackSet&&(e._requestCallbackSet.delete(t),e._requestCallbackSet.size||delete e._requestCallbackSet)},yh=(e,t)=>{e._responseCallbackSet&&(e._responseCallbackSet.delete(t),e._responseCallbackSet.size||delete e._responseCallbackSet)};ah.supportsNativeHls=function(){if(!F||!F.createElement)return!1;let e=F.createElement(`video`);return Z.getTech(`Html5`).isSupported()?[`application/vnd.apple.mpegurl`,`audio/mpegurl`,`audio/x-mpegurl`,`application/x-mpegurl`,`video/x-mpegurl`,`video/mpegurl`,`application/mpegurl`].some(function(t){return/maybe|probably/i.test(e.canPlayType(t))}):!1}(),ah.supportsNativeDash=function(){return!F||!F.createElement||!Z.getTech(`Html5`).isSupported()?!1:/maybe|probably/i.test(F.createElement(`video`).canPlayType(`application/dash+xml`))}(),ah.supportsTypeNatively=e=>e===`hls`?ah.supportsNativeHls:e===`dash`&&ah.supportsNativeDash,ah.isSupported=function(){return Z.log.warn(`VHS is no longer a tech. Please remove it from your player's techOrder.`)},ah.xhr.onRequest=function(e){gh(ah.xhr,e)},ah.xhr.onResponse=function(e){_h(ah.xhr,e)},ah.xhr.offRequest=function(e){vh(ah.xhr,e)},ah.xhr.offResponse=function(e){yh(ah.xhr,e)};const bh=Z.getComponent(`Component`);class xh extends bh{constructor(e,t,n){if(super(t,n.vhs),typeof n.initialBandwidth==`number`&&(this.options_.bandwidth=n.initialBandwidth),this.logger_=xu(`VhsHandler`),t.options_&&t.options_.playerId){let e=Z.getPlayer(t.options_.playerId);this.player_=e}if(this.tech_=t,this.source_=e,this.stats={},this.ignoreNextSeekingEvent_=!1,this.setOptions_(),this.options_.overrideNative&&t.overrideNativeAudioTracks&&t.overrideNativeVideoTracks)t.overrideNativeAudioTracks(!0),t.overrideNativeVideoTracks(!0);else if(this.options_.overrideNative&&(t.featuresNativeVideoTracks||t.featuresNativeAudioTracks))throw Error(`Overriding native VHS requires emulated tracks. See https://git.io/vMpjB`);this.on(F,[`fullscreenchange`,`webkitfullscreenchange`,`mozfullscreenchange`,`MSFullscreenChange`],e=>{let t=F.fullscreenElement||F.webkitFullscreenElement||F.mozFullScreenElement||F.msFullscreenElement;t&&t.contains(this.tech_.el())?this.playlistController_.fastQualityChange_():this.playlistController_.checkABR_()}),this.on(this.tech_,`seeking`,function(){this.ignoreNextSeekingEvent_?this.ignoreNextSeekingEvent_=!1:this.setCurrentTime(this.tech_.currentTime())}),this.on(this.tech_,`error`,function(){this.tech_.error()&&this.playlistController_&&this.playlistController_.pauseLoading()}),this.on(this.tech_,`play`,this.play)}setOptions_(e={}){if(this.options_=Q(this.options_,e),this.options_.withCredentials=this.options_.withCredentials||!1,this.options_.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions!==!1,this.options_.useDevicePixelRatio=this.options_.useDevicePixelRatio||!1,this.options_.usePlayerObjectFit=this.options_.usePlayerObjectFit||!1,this.options_.useBandwidthFromLocalStorage=this.source_.useBandwidthFromLocalStorage===void 0?this.options_.useBandwidthFromLocalStorage||!1:this.source_.useBandwidthFromLocalStorage,this.options_.useForcedSubtitles=this.options_.useForcedSubtitles||!1,this.options_.useNetworkInformationApi=this.options_.useNetworkInformationApi===void 0||this.options_.useNetworkInformationApi,this.options_.useDtsForTimestampOffset=this.options_.useDtsForTimestampOffset||!1,this.options_.customTagParsers=this.options_.customTagParsers||[],this.options_.customTagMappers=this.options_.customTagMappers||[],this.options_.cacheEncryptionKeys=this.options_.cacheEncryptionKeys||!1,this.options_.llhls=this.options_.llhls!==!1,this.options_.bufferBasedABR=this.options_.bufferBasedABR||!1,typeof this.options_.playlistExclusionDuration!=`number`&&(this.options_.playlistExclusionDuration=60),typeof this.options_.bandwidth!=`number`&&this.options_.useBandwidthFromLocalStorage){let e=ph();e&&e.bandwidth&&(this.options_.bandwidth=e.bandwidth,this.tech_.trigger({type:`usage`,name:`vhs-bandwidth-from-local-storage`})),e&&e.throughput&&(this.options_.throughput=e.throughput,this.tech_.trigger({type:`usage`,name:`vhs-throughput-from-local-storage`}))}typeof this.options_.bandwidth!=`number`&&(this.options_.bandwidth=bf.INITIAL_BANDWIDTH),this.options_.enableLowInitialPlaylist=this.options_.enableLowInitialPlaylist&&this.options_.bandwidth===bf.INITIAL_BANDWIDTH,[`withCredentials`,`useDevicePixelRatio`,`usePlayerObjectFit`,`customPixelRatio`,`limitRenditionByPlayerDimensions`,`bandwidth`,`customTagParsers`,`customTagMappers`,`cacheEncryptionKeys`,`playlistSelector`,`initialPlaylistSelector`,`bufferBasedABR`,`liveRangeSafeTimeDelta`,`llhls`,`useForcedSubtitles`,`useNetworkInformationApi`,`useDtsForTimestampOffset`,`exactManifestTimings`,`leastPixelDiffSelector`].forEach(e=>{this.source_[e]!==void 0&&(this.options_[e]=this.source_[e])}),this.limitRenditionByPlayerDimensions=this.options_.limitRenditionByPlayerDimensions,this.useDevicePixelRatio=this.options_.useDevicePixelRatio,this.usePlayerObjectFit=this.options_.usePlayerObjectFit;let t=this.options_.customPixelRatio;typeof t==`number`&&t>=0&&(this.customPixelRatio=t)}setOptions(e={}){this.setOptions_(e)}src(e,t){if(!e)return;this.setOptions_(),this.options_.src=hh(this.source_.src),this.options_.tech=this.tech_,this.options_.externVhs=ah,this.options_.sourceType=Ft(t),this.options_.seekTo=e=>{this.tech_.setCurrentTime(e)},this.options_.player_=this.player_,this.playlistController_=new Gm(this.options_);let n=Q({liveRangeSafeTimeDelta:Tu},this.options_,{seekable:()=>this.seekable(),media:()=>this.playlistController_.media(),playlistController:this.playlistController_});this.playbackWatcher_=new Xm(n),this.attachStreamingEventListeners_(),this.playlistController_.on(`error`,()=>{let e=Z.players[this.tech_.options_.playerId],t=this.playlistController_.error;typeof t==`object`&&!t.code?t.code=3:typeof t==`string`&&(t={message:t,code:3}),e.error(t)});let r=this.options_.bufferBasedABR?ah.movingAverageBandwidthSelector(.55):ah.STANDARD_PLAYLIST_SELECTOR;this.playlistController_.selectPlaylist=this.selectPlaylist?this.selectPlaylist.bind(this):r.bind(this),this.playlistController_.selectInitialPlaylist=ah.INITIAL_PLAYLIST_SELECTOR.bind(this),this.playlists=this.playlistController_.mainPlaylistLoader_,this.mediaSource=this.playlistController_.mediaSource,Object.defineProperties(this,{selectPlaylist:{get(){return this.playlistController_.selectPlaylist},set(e){this.playlistController_.selectPlaylist=e.bind(this)}},throughput:{get(){return this.playlistController_.mainSegmentLoader_.throughput.rate},set(e){this.playlistController_.mainSegmentLoader_.throughput.rate=e,this.playlistController_.mainSegmentLoader_.throughput.count=1}},bandwidth:{get(){let e=this.playlistController_.mainSegmentLoader_.bandwidth,t=x.navigator.connection||x.navigator.mozConnection||x.navigator.webkitConnection,n=1e7;if(this.options_.useNetworkInformationApi&&t){let r=t.downlink*1e3*1e3;e=r>=n&&e>=n?Math.max(e,r):r}return e},set(e){this.playlistController_.mainSegmentLoader_.bandwidth=e,this.playlistController_.mainSegmentLoader_.throughput={rate:0,count:0}}},systemBandwidth:{get(){let e=1/(this.bandwidth||1),t;return t=this.throughput>0?1/this.throughput:0,Math.floor(1/(e+t))},set(){Z.log.error(`The "systemBandwidth" property is read-only`)}}}),this.options_.bandwidth&&(this.bandwidth=this.options_.bandwidth),this.options_.throughput&&(this.throughput=this.options_.throughput),Object.defineProperties(this.stats,{bandwidth:{get:()=>this.bandwidth||0,enumerable:!0},mediaRequests:{get:()=>this.playlistController_.mediaRequests_()||0,enumerable:!0},mediaRequestsAborted:{get:()=>this.playlistController_.mediaRequestsAborted_()||0,enumerable:!0},mediaRequestsTimedout:{get:()=>this.playlistController_.mediaRequestsTimedout_()||0,enumerable:!0},mediaRequestsErrored:{get:()=>this.playlistController_.mediaRequestsErrored_()||0,enumerable:!0},mediaTransferDuration:{get:()=>this.playlistController_.mediaTransferDuration_()||0,enumerable:!0},mediaBytesTransferred:{get:()=>this.playlistController_.mediaBytesTransferred_()||0,enumerable:!0},mediaSecondsLoaded:{get:()=>this.playlistController_.mediaSecondsLoaded_()||0,enumerable:!0},mediaAppends:{get:()=>this.playlistController_.mediaAppends_()||0,enumerable:!0},mainAppendsToLoadedData:{get:()=>this.playlistController_.mainAppendsToLoadedData_()||0,enumerable:!0},audioAppendsToLoadedData:{get:()=>this.playlistController_.audioAppendsToLoadedData_()||0,enumerable:!0},appendsToLoadedData:{get:()=>this.playlistController_.appendsToLoadedData_()||0,enumerable:!0},timeToLoadedData:{get:()=>this.playlistController_.timeToLoadedData_()||0,enumerable:!0},buffered:{get:()=>Nu(this.tech_.buffered()),enumerable:!0},currentTime:{get:()=>this.tech_.currentTime(),enumerable:!0},currentSource:{get:()=>this.tech_.currentSource_,enumerable:!0},currentTech:{get:()=>this.tech_.name_,enumerable:!0},duration:{get:()=>this.tech_.duration(),enumerable:!0},main:{get:()=>this.playlists.main,enumerable:!0},playerDimensions:{get:()=>this.tech_.currentDimensions(),enumerable:!0},seekable:{get:()=>Nu(this.tech_.seekable()),enumerable:!0},timestamp:{get:()=>Date.now(),enumerable:!0},videoPlaybackQuality:{get:()=>this.tech_.getVideoPlaybackQuality(),enumerable:!0}}),this.tech_.one(`canplay`,this.playlistController_.setupFirstPlay.bind(this.playlistController_)),this.tech_.on(`bandwidthupdate`,()=>{this.options_.useBandwidthFromLocalStorage&&mh({bandwidth:this.bandwidth,throughput:Math.round(this.throughput)})}),this.playlistController_.on(`selectedinitialmedia`,()=>{Jm(this)}),this.playlistController_.sourceUpdater_.on(`createdsourcebuffers`,()=>{this.setupEme_()}),this.on(this.playlistController_,`progress`,function(){this.tech_.trigger(`progress`)}),this.on(this.playlistController_,`firstplay`,function(){this.ignoreNextSeekingEvent_=!0}),this.setupQualityLevels_(),this.tech_.el()&&(this.mediaSourceUrl_=x.URL.createObjectURL(this.playlistController_.mediaSource),(Z.browser.IS_ANY_SAFARI||Z.browser.IS_IOS)&&this.options_.overrideNative&&this.options_.sourceType===`hls`&&typeof this.tech_.addSourceElement==`function`?(this.tech_.addSourceElement(this.mediaSourceUrl_),this.tech_.addSourceElement(this.source_.src)):this.tech_.src(this.mediaSourceUrl_))}createKeySessions_(){let e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader;this.logger_(`waiting for EME key session creation`),dh({player:this.player_,sourceKeySystems:this.source_.keySystems,audioMedia:e&&e.media(),mainPlaylists:this.playlists.main.playlists}).then(()=>{this.logger_(`created EME key session`),this.playlistController_.sourceUpdater_.initializedEme()}).catch(e=>{this.logger_(`error while creating EME key session`,e),this.player_.error({message:`Failed to initialize media keys for EME`,code:3})})}handleWaitingForKey_(){this.logger_(`waitingforkey fired, attempting to create any new key sessions`),this.createKeySessions_()}setupEme_(){let e=this.playlistController_.mediaTypes_.AUDIO.activePlaylistLoader,t=fh({player:this.player_,sourceKeySystems:this.source_.keySystems,media:this.playlists.media(),audioMedia:e&&e.media()});this.player_.tech_.on(`keystatuschange`,e=>{this.playlistController_.updatePlaylistByKeyStatus(e.keyId,e.status)}),this.handleWaitingForKey_=this.handleWaitingForKey_.bind(this),this.player_.tech_.on(`waitingforkey`,this.handleWaitingForKey_),t?this.createKeySessions_():this.playlistController_.sourceUpdater_.initializedEme()}setupQualityLevels_(){let e=Z.players[this.tech_.options_.playerId];e&&e.qualityLevels&&!this.qualityLevels_&&(this.qualityLevels_=e.qualityLevels(),this.playlistController_.on(`selectedinitialmedia`,()=>{ch(this.qualityLevels_,this)}),this.playlists.on(`mediachange`,()=>{sh(this.qualityLevels_,this.playlists)}))}static version(){return{"@videojs/http-streaming":eh,"mux.js":th,"mpd-parser":nh,"m3u8-parser":rh,"aes-decrypter":ih}}version(){return this.constructor.version()}canChangeType(){return sm.canChangeType()}play(){this.playlistController_.play()}setCurrentTime(e){this.playlistController_.setCurrentTime(e)}duration(){return this.playlistController_.duration()}seekable(){return this.playlistController_.seekable()}dispose(){this.playbackWatcher_&&this.playbackWatcher_.dispose(),this.playlistController_&&this.playlistController_.dispose(),this.qualityLevels_&&this.qualityLevels_.dispose(),this.tech_&&this.tech_.vhs&&delete this.tech_.vhs,this.mediaSourceUrl_&&x.URL.revokeObjectURL&&(x.URL.revokeObjectURL(this.mediaSourceUrl_),this.mediaSourceUrl_=null),this.tech_&&this.tech_.off(`waitingforkey`,this.handleWaitingForKey_),super.dispose()}convertToProgramTime(e,t){return of({playlist:this.playlistController_.media(),time:e,callback:t})}seekToProgramTime(e,t,n=!0,r=2){return sf({programTime:e,playlist:this.playlistController_.media(),retryCount:r,pauseAfterSeek:n,seekTo:this.options_.seekTo,tech:this.options_.tech,callback:t})}setupXhrHooks_(){this.xhr.onRequest=e=>{gh(this.xhr,e)},this.xhr.onResponse=e=>{_h(this.xhr,e)},this.xhr.offRequest=e=>{vh(this.xhr,e)},this.xhr.offResponse=e=>{yh(this.xhr,e)},this.player_.trigger(`xhr-hooks-ready`)}attachStreamingEventListeners_(){[`seekablerangeschanged`,`bufferedrangeschanged`,`contentsteeringloadstart`,`contentsteeringloadcomplete`,`contentsteeringparsed`].forEach(e=>{this.playlistController_.on(e,e=>{this.player_.trigger(R({},e))})}),[`gapjumped`,`playedrangeschanged`].forEach(e=>{this.playbackWatcher_.on(e,e=>{this.player_.trigger(R({},e))})})}}const Sh={name:`videojs-http-streaming`,VERSION:eh,canHandleSource(e,t={}){let n=Q(Z.options,t);return!n.vhs.experimentalUseMMS&&!kt(`avc1.4d400d,mp4a.40.2`,!1)?!1:Sh.canPlayType(e.type,n)},handleSource(e,t,n={}){let r=Q(Z.options,n);return t.vhs=new xh(e,t,r),t.vhs.xhr=Vd(),t.vhs.setupXhrHooks_(),t.vhs.src(e.src,e.type),t.vhs},canPlayType(e,t){let n=Ft(e);if(!n)return``;let r=Sh.getOverrideNative(t);return!ah.supportsTypeNatively(n)||r?`maybe`:``},getOverrideNative(e={}){let{vhs:t={}}=e,n=!(Z.browser.IS_ANY_SAFARI||Z.browser.IS_IOS),{overrideNative:r=n}=t;return r}};kt(`avc1.4d400d,mp4a.40.2`,!0)&&Z.getTech(`Html5`).registerSourceHandler(Sh,0),Z.VhsHandler=xh,Z.VhsSourceHandler=Sh,Z.Vhs=ah,Z.use||Z.registerComponent(`Vhs`,ah),Z.options.vhs=Z.options.vhs||{},Z.getPlugin&&Z.getPlugin(`reloadSourceOnError`)||Z.registerPlugin(`reloadSourceOnError`,$m);let $=class extends t{constructor(){super(...arguments),this._controllerConfigs={autoplay:!1,autoSetup:!1,controls:!1,defaultVolume:.3,disablePictureInPicture:!0,enableDocumentPictureInPicture:!1,enableSmoothSeeking:!0,html5:{nativeAudioTracks:!1,nativeVideoTracks:!1,vhs:{llhls:!0,overrideNative:!0}},inactivityTimeout:0,liveTracker:{liveTolerance:10,trackingThreshold:15},loop:!1,muted:!1,nativeControlsForTouch:!1,normalizeAutoplay:!0,preload:`auto`},this._prevPlayingState=!1,this._retryCount=0,this._qualityLevels=[],this.autoplay=!1,this.currentMetadata=null,this.element=null,this.isLive=!1,this.mimeType=null,this.sensorModel=null,this.started=!1,this.state=`not-ready`,this.waitingTimestamp=null,this._initController=async()=>{if(!this._controller&&this.playerUrl)try{let e={...this._controllerConfigs};this.element=document.createElement(`video`),Z.log.level(`off`),this._controller=Z(this.element,e),this._controller.muted(this.muted),this._controller.loop(this.loop),this._controller.playbackRate(this.rate),this._controller.qualityLevels().on(`addqualitylevel`,e=>this._handleQualityLevel(e)),this._controller.ready(this._handleReady),this._controller.one(`play`,this._handleFirstPlay),this._controller.on(`canplay`,this._handleCanPlay),this._controller.on(`durationchange`,this._handleDurationChange),this._controller.on(`ended`,this._handleEnded),this._controller.on(`error`,this._handleError),this._controller.on(`loadeddata`,this._handleDataLoaded),this._controller.on(`loadedmetadata`,this._handleLoadedMetadata),this._controller.on(`loadstart`,this._handleLoadStart),this._controller.on(`play`,this._handlePlay),this._controller.on(`playing`,this._handlePlaying),this._controller.on(`stalled`,this._handleStalled),this._controller.on(`timeupdate`,this._handleTimeUpdate),this._controller.on(`waiting`,this._handleWaiting),this._controller.on(`xhr-hooks-ready`,this._handleXHRhooksReady),this._controller?.liveTracker.on(`seekableendchange`,()=>this.notifyChange(`livestreamStatus`)),this._controller?.liveTracker.on(`liveedgechange`,()=>this.notifyChange(`livestreamStatus`))}catch{r.getLogger(this).error(`Unable to initialize the player.`),this._controller&&this._controller.dispose()}},this._handleQualityLevel=e=>{if(!e?.qualityLevel)return;let t=e.qualityLevel;this._qualityLevels.push(t),t?.enabled&&(this._set(`videoWidth`,t?.width??0),this._set(`videoHeight`,t?.height??0))},this._handleReady=()=>{this.state=`ready`},this._handleFirstPlay=()=>{this._set(`started`,!0)},this._handleCanPlay=async()=>{if(this._prevPlayingState=this.state===`playing`,this.state=`can-play`,this.autoplay&&!this.started)try{this.muted=!0,await this.play()}catch{r.getLogger(this).info(`Unable to auto start playback. Blocked by the browser.`)}},this._handleCueChange=()=>{if(!this.subtitleTrack?.activeCues?.length)return;let e=this.subtitleTrack?.activeCues,t=f(e);if(!t?.length)return;let n=new Map;for(let e of t)Array.isArray(e.value)?e.tagId===90064?n.set(e.tagId,e):e.value.forEach(e=>{n.set(e.tagId,e)}):n.set(e.tagId,e);n.set(p.EsriVideoWidth,{name:`Video Width`,tagId:p.EsriVideoWidth,value:this._controller?.videoWidth()}),n.set(p.EsriVideoHeight,{name:`Video Height`,tagId:p.EsriVideoHeight,value:this._controller?.videoHeight()}),this.currentMetadata=new Map(n)},this._handleDataLoaded=()=>{this._set(`videoWidth`,this._controller?.videoWidth()),this._set(`videoHeight`,this._controller?.videoHeight())},this._handleDurationChange=()=>{this._controller?.duration()!==0&&(this.notifyChange(`duration`),this.isLive=this._controller?.duration()===1/0||!1,this._setLivestreamStatus(),this.started&&this._controller?.duration()===this._controller?.currentTime()&&this._controller?.trigger(`ended`))},this._handleEnded=()=>{this._controller?.ended()&&this.notifyChange(`ended`)},this._handleError=()=>{let e=this._controller?.error()??null;if(typeof e?.code==`number`&&e?.code<3&&this._retryCount===0)this._retryCount++,setTimeout(()=>{this._controller?.src({type:this.mimeType,src:this.playerUrl}),this._controller?.load()},2e3);else{let t=new n(`Media Error`,e?.message??``);r.getLogger(this).error(t),this.reset()}},this._handleLoadStart=()=>{this.state=`can-play`},this._handleLoadedMetadata=()=>{this.state=`can-play`,this.notifyChange(`buffered`),this.notifyChange(`subtitleTrack`)},this._handlePlay=()=>{this.notifyChange(`ended`)},this._handlePlaying=()=>{this.state=`playing`,this._retryCount=0,this.notifyChange(`ended`)},this._handleStalled=()=>{r.getLogger(this).warn(`Playback is stalled and awaiting data`)},this._handleTimeUpdate=()=>{this._setLivestreamStatus(),this.notifyChange(`currentTime`),this.notifyChange(`buffered`),this.notifyChange(`bufferedPercent`),this._set(`videoWidth`,this._controller?.videoWidth()),this._set(`videoHeight`,this._controller?.videoHeight())},this._handleWaiting=()=>{this.waitingTimestamp=this._controller?.currentTime(),this.state=`waiting`},this._handleXHRhooksReady=()=>{this._controller?.tech(!0)?.vhs.xhr.onRequest(e=>(e.xhr=new c,e))},this._updateSensorModel=()=>{this.currentMetadata?.size&&(this.sensorModel?this.sensorModel.updateSensorModel(this.currentMetadata):this.sensorModel=new d({videoMetadata:this.currentMetadata}))},this._setLivestreamStatus=()=>{if(!this.isLive){this.livestreamStatus=null;return}this._controller?.liveTracker.isTracking()||this._controller?.liveTracker.startTracking();let e={atLiveEdge:this._controller?.liveTracker.atLiveEdge()??null,behindLiveEdge:this._controller?.liveTracker.behindLiveEdge()??null,liveCurrentTime:this._controller?.liveTracker?.liveCurrentTime()??null,liveWindow:this._controller?.liveTracker?.liveWindow()??null,pastSeekEnd:this._controller?.liveTracker?.pastSeekEnd()??null,seekableEnd:this._controller?.liveTracker?.seekableEnd()??null,seekableStart:this._controller?.liveTracker?.seekableStart()??null};this.livestreamStatus={...e},this.notifyChange(`livestreamStatus`),this._controller?.liveTracker.handlePlay(),this._controller?.liveTracker.handleFirstTimeupdate()}}initialize(){this.addHandles([a(()=>this.playerUrl,e=>{e&&this._initController().then(()=>{this.mimeType=m(e),this._controller?.src({src:this.playerUrl,type:this.mimeType})})},o),a(()=>this.subtitleTrack,()=>{this.subtitleTrack&&(this.subtitleTrack.mode=`showing`)},o),a(()=>this.isLive,async e=>{e&&(this._controller?.liveTracker.startTracking(),this.autoplay&&(this.muted=!0,await this.play()))}),a(()=>this.currentMetadata,()=>this._updateSensorModel())]),this.addHandles(s(()=>this.subtitleTrack,`cuechange`,this._handleCueChange),o)}destroy(){this.removeAllHandles(),this._controller?.dispose()}get buffered(){return this._controller?.bufferedEnd()??0}get bufferedPercent(){return this._controller?.bufferedPercent()??0}get crossOrigin(){return this._controller?.crossOrigin()??this._get(`crossOrigin`)}set crossOrigin(e){this._controller?.crossOrigin(e),this._set(`crossOrigin`,e)}get currentTime(){return this._controller?.currentTime()??0}get duration(){return this._controller?.duration()??0}get ended(){return this._controller?.ended()??this._get(`ended`)??!0}set ended(e){this._controller?.trigger(`ended`),this._set(`ended`,e)}get loop(){return this._controller?.loop()??this._get(`loop`)??!1}set loop(e){this._controller?.loop(e),this._set(`loop`,e)}get muted(){return this._controller?.muted()??this._get(`muted`)??!1}set muted(e){this._controller?.muted(e),this._set(`muted`,e)}get playerUrl(){return this._controller?.src()||``}set playerUrl(e){this._set(`playerUrl`,e)}get playing(){return this.ended?!1:this.state===`can-play`?this._prevPlayingState:this.state===`playing`}get playsInline(){return this._controller?.playsinline()??this._get(`playsInline`)??!1}set playsInline(e){this._controller?.playsinline(e),this._set(`playsInline`,e)}get rate(){return this._controller?.playbackRate()??this._get(`rate`)??1}set rate(e){this._controller?.playbackRate(e),this._set(`rate`,e)}get startMode(){return this._controller?.preload()??this._get(`startMode`)??`auto`}set startMode(e){this._controller?.preload(e),this._set(`startMode`,e)}get subtitleTrack(){let e=this._controller?.textTracks();return e?.length?Array.from(e).find(e=>e.kind===`subtitles`):null}get volume(){return this._controller?.volume()??0}set volume(e){let t=i(e,0,1);isNaN(t)||this._controller?.volume(t)}get waiting(){return this.waitingTimestamp?!1:this.waitingTimestamp===this.currentTime||(this.waitingTimestamp=null,!1)}pause(){this._controller?.pause(),this.state=`paused`}async play(){try{!this.started&&this.isLive&&this._controller?.muted(!0),await this._controller?.play(),this.state=`playing`}catch{}}reset(){this._controller&&(this._prevPlayingState=!1,this._retryCount=0,this._set(`started`,!1),this.setCurrentTime(0),this.notifyChange(`buffered`),this.notifyChange(`currentTime`),this.notifyChange(`duration`),this.notifyChange(`waiting`),this._controller?.trigger(`can-play`),this.autoplay||this._controller?.pause())}seekToLiveEdge(){this.isLive?this.state===`playing`&&this._controller?.liveTracker.isTracking()&&this._controller?.liveTracker.seekToLiveEdge():r.getLogger(this).info(`seekToLiveEdge method is only available for livestream playback.`)}setCurrentTime(e){let t=i(e,0,this.duration);this._controller?.currentTime(t),this.notifyChange(`currentTime`)}};e([l()],$.prototype,`autoplay`,void 0),e([l()],$.prototype,`buffered`,null),e([l()],$.prototype,`bufferedPercent`,null),e([l()],$.prototype,`crossOrigin`,null),e([l({readOnly:!0})],$.prototype,`currentTime`,null),e([l()],$.prototype,`currentMetadata`,void 0),e([l({readOnly:!0})],$.prototype,`duration`,null),e([l()],$.prototype,`element`,void 0),e([l({readOnly:!0})],$.prototype,`ended`,null),e([l()],$.prototype,`isLive`,void 0),e([l()],$.prototype,`livestreamStatus`,void 0),e([l()],$.prototype,`loop`,null),e([l()],$.prototype,`mimeType`,void 0),e([l()],$.prototype,`muted`,null),e([l()],$.prototype,`playerUrl`,null),e([l({readOnly:!0})],$.prototype,`playing`,null),e([l()],$.prototype,`playsInline`,null),e([l()],$.prototype,`rate`,null),e([l()],$.prototype,`sensorModel`,void 0),e([l({readOnly:!0})],$.prototype,`started`,void 0),e([l()],$.prototype,`startMode`,null),e([l()],$.prototype,`state`,void 0),e([l()],$.prototype,`subtitleTrack`,null),e([l({readOnly:!0})],$.prototype,`videoHeight`,void 0),e([l({readOnly:!0})],$.prototype,`videoWidth`,void 0),e([l()],$.prototype,`volume`,null),e([l({readOnly:!0})],$.prototype,`waiting`,null),e([l()],$.prototype,`waitingTimestamp`,void 0),$=e([u(`esri.layers.video.VideoController`)],$);export{$ as default};