@blockcast/mmt-container 0.3.0 → 0.4.0-main.1e94b11199ea

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 (606) hide show
  1. package/README.md +33 -16
  2. package/dist/browser-runtime.js +14816 -14254
  3. package/dist/browser-runtime.js.map +4 -4
  4. package/dist/carp-catalog.d.ts +24 -19
  5. package/dist/carp-catalog.d.ts.map +1 -1
  6. package/dist/carp-catalog.js +32 -14
  7. package/dist/carp-catalog.js.map +4 -4
  8. package/dist/catalog-fec-params.d.ts +88 -28
  9. package/dist/catalog-fec-params.d.ts.map +1 -1
  10. package/dist/catalog-fec-params.js +60 -23
  11. package/dist/catalog-fec-params.js.map +4 -4
  12. package/dist/catalog-network-source.js +1 -7
  13. package/dist/catalog-network-source.js.map +4 -4
  14. package/dist/cmaf-block-assembler.d.ts +0 -2
  15. package/dist/cmaf-block-assembler.d.ts.map +1 -1
  16. package/dist/cmaf-block-assembler.js +0 -1
  17. package/dist/cmaf-block-assembler.js.map +2 -2
  18. package/dist/cmcd-producer.d.ts.map +1 -1
  19. package/dist/cmcd-producer.js +0 -4
  20. package/dist/cmcd-producer.js.map +2 -2
  21. package/dist/delivery-catalog.d.ts +124 -0
  22. package/dist/delivery-catalog.d.ts.map +1 -0
  23. package/dist/delivery-catalog.js +1857 -0
  24. package/dist/delivery-catalog.js.map +7 -0
  25. package/dist/delta-fallback-config.d.ts +42 -0
  26. package/dist/delta-fallback-config.d.ts.map +1 -0
  27. package/dist/delta-fallback-config.js +59 -0
  28. package/dist/delta-fallback-config.js.map +7 -0
  29. package/dist/fec-manager.d.ts +52 -30
  30. package/dist/fec-manager.d.ts.map +1 -1
  31. package/dist/fec-manager.js +338 -293
  32. package/dist/fec-manager.js.map +4 -4
  33. package/dist/fec-state.d.ts +19 -31
  34. package/dist/fec-state.d.ts.map +1 -1
  35. package/dist/fec-state.js +4 -10
  36. package/dist/fec-state.js.map +4 -4
  37. package/dist/fec-worker-setup.d.ts +18 -14
  38. package/dist/fec-worker-setup.d.ts.map +1 -1
  39. package/dist/fec-worker-setup.js +81 -96
  40. package/dist/fec-worker-setup.js.map +4 -4
  41. package/dist/index.d.ts +5 -3
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +16 -0
  44. package/dist/index.js.map +2 -2
  45. package/dist/iso-block-locator.js +1 -7
  46. package/dist/iso-block-locator.js.map +4 -4
  47. package/dist/media-router.d.ts +20 -8
  48. package/dist/media-router.d.ts.map +1 -1
  49. package/dist/media-router.js +46 -21
  50. package/dist/media-router.js.map +2 -2
  51. package/dist/mfu-reassembler.js +24 -30
  52. package/dist/mfu-reassembler.js.map +4 -4
  53. package/dist/mmtp-container-parser.d.ts +14 -11
  54. package/dist/mmtp-container-parser.d.ts.map +1 -1
  55. package/dist/mmtp-container-parser.js +126 -99
  56. package/dist/mmtp-container-parser.js.map +4 -4
  57. package/dist/mmtp-container-parser.no-modules.js +154 -108
  58. package/dist/mmtp-container-parser.no-modules.js.map +4 -4
  59. package/dist/mmtp-decode-pipeline.js +126 -99
  60. package/dist/mmtp-decode-pipeline.js.map +4 -4
  61. package/dist/mmtp-router.d.ts +51 -29
  62. package/dist/mmtp-router.d.ts.map +1 -1
  63. package/dist/mmtp-router.js +260 -326
  64. package/dist/mmtp-router.js.map +4 -4
  65. package/dist/multicast-input.js +1 -7
  66. package/dist/multicast-input.js.map +4 -4
  67. package/dist/multicast-manager.d.ts +72 -6
  68. package/dist/multicast-manager.d.ts.map +1 -1
  69. package/dist/multicast-manager.js +882 -673
  70. package/dist/multicast-manager.js.map +4 -4
  71. package/dist/multicast-transport.d.ts +1 -1
  72. package/dist/multicast-transport.d.ts.map +1 -1
  73. package/dist/multicast-transport.js +44 -26
  74. package/dist/multicast-transport.js.map +4 -4
  75. package/dist/multicast-unwrap.js +29 -35
  76. package/dist/multicast-unwrap.js.map +4 -4
  77. package/dist/no-modules.js +150 -106
  78. package/dist/no-modules.js.map +4 -4
  79. package/dist/repair-fetch.d.ts +116 -21
  80. package/dist/repair-fetch.d.ts.map +1 -1
  81. package/dist/repair-fetch.js +114 -34
  82. package/dist/repair-fetch.js.map +4 -4
  83. package/dist/repair-layers.d.ts +18 -7
  84. package/dist/repair-layers.d.ts.map +1 -1
  85. package/dist/repair-layers.js +12 -10
  86. package/dist/repair-layers.js.map +4 -4
  87. package/dist/signaling.js +2 -11
  88. package/dist/signaling.js.map +4 -4
  89. package/dist/timestamp-codec.js +24 -30
  90. package/dist/timestamp-codec.js.map +4 -4
  91. package/dist/track-session.d.ts +7 -0
  92. package/dist/track-session.d.ts.map +1 -1
  93. package/dist/track-session.js +15 -8
  94. package/dist/track-session.js.map +2 -2
  95. package/dist/wasm-mfu-reassembler.js +1 -7
  96. package/dist/wasm-mfu-reassembler.js.map +4 -4
  97. package/dist/wasm-mmtp-container-parser.js +126 -99
  98. package/dist/wasm-mmtp-container-parser.js.map +4 -4
  99. package/package.json +7 -14
  100. package/schemas/catalog.schema.json +3 -3
  101. package/src/carp-catalog.ts +51 -24
  102. package/src/catalog-fec-params.ts +173 -64
  103. package/src/cmaf-block-assembler.ts +1 -4
  104. package/src/cmcd-producer.ts +0 -6
  105. package/src/delivery-catalog.ts +498 -0
  106. package/src/delta-fallback-config.ts +72 -0
  107. package/src/fec-manager.ts +457 -334
  108. package/src/fec-state.ts +20 -32
  109. package/src/fec-worker-setup.ts +109 -90
  110. package/src/index.ts +32 -0
  111. package/src/media-router.ts +59 -21
  112. package/src/mmtp-container-parser.ts +106 -20
  113. package/src/mmtp-router.ts +189 -330
  114. package/src/multicast-manager.ts +265 -86
  115. package/src/multicast-transport.ts +16 -9
  116. package/src/repair-fetch.ts +273 -43
  117. package/src/repair-layers.ts +28 -8
  118. package/src/track-session.ts +28 -9
  119. package/test-vectors/catalog/README.md +44 -18
  120. package/test-vectors/catalog/negative/fec-block-profile-retired.json +52 -0
  121. package/test-vectors/catalog/negative/fec-enhancement-repair-removed.json +1 -1
  122. package/test-vectors/catalog/negative/fec-repair-layer-geometry.json +1 -1
  123. package/test-vectors/catalog/negative/fec-repair-layer-missing-symbols.json +1 -1
  124. package/test-vectors/catalog/negative/fec-repair-multiple-depends.json +1 -1
  125. package/test-vectors/catalog/negative/fec-repair-overlay-with-layer.json +1 -1
  126. package/test-vectors/catalog/negative/fec-repair-priority-out-of-band.json +1 -1
  127. package/test-vectors/catalog/negative/fec-repair-source-symbols-without-scope.json +1 -1
  128. package/test-vectors/catalog/negative/multicast-endpoint-relay-address.json +39 -0
  129. package/test-vectors/catalog/negative/multicast-network-source-empty.json +1 -1
  130. package/test-vectors/catalog/negative/raptorq-source-symbols-over-max.json +1 -1
  131. package/test-vectors/catalog/negative/raptorq-unaligned-symbol.json +2 -1
  132. package/test-vectors/catalog/positive/fec-layered-repair.json +2 -2
  133. package/test-vectors/catalog/positive/fec-multicast.json +2 -1
  134. package/test-vectors/catalog/positive/multicast-amt-manual-relay.json +38 -0
  135. package/test-vectors/catalog/positive/multicast-native-ssm-no-network-source.json +2 -1
  136. package/test-vectors/catalog/section-codes.json +33 -0
  137. package/test-vectors/catalog-timing.json +356 -0
  138. package/test-vectors/catalog-validation.json +40 -5
  139. package/test-vectors/delivery-catalog/README.md +11 -0
  140. package/test-vectors/delivery-catalog/negative/missing-block-profile.json +58 -0
  141. package/test-vectors/delivery-catalog/negative/packet-id-signaling.json +59 -0
  142. package/test-vectors/delivery-catalog/negative/retired-k-padded-block-profile.json +59 -0
  143. package/test-vectors/delivery-catalog/positive/dash.json +56 -0
  144. package/test-vectors/delivery-catalog/positive/mmtp-source-only.json +43 -0
  145. package/node_modules/@blockcast/fec-worker/README.md +0 -223
  146. package/node_modules/@blockcast/fec-worker/dist/.build-stamp +0 -0
  147. package/node_modules/@blockcast/fec-worker/dist/block-order.d.ts +0 -38
  148. package/node_modules/@blockcast/fec-worker/dist/block-order.d.ts.map +0 -1
  149. package/node_modules/@blockcast/fec-worker/dist/block-order.js +0 -78
  150. package/node_modules/@blockcast/fec-worker/dist/block-order.js.map +0 -1
  151. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts +0 -93
  152. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.d.ts.map +0 -1
  153. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js +0 -346
  154. package/node_modules/@blockcast/fec-worker/dist/fec-worker-client.js.map +0 -1
  155. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts +0 -380
  156. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.d.ts.map +0 -1
  157. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js +0 -11
  158. package/node_modules/@blockcast/fec-worker/dist/fec-worker-types.js.map +0 -1
  159. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts +0 -14
  160. package/node_modules/@blockcast/fec-worker/dist/fec-worker.d.ts.map +0 -1
  161. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js +0 -859
  162. package/node_modules/@blockcast/fec-worker/dist/fec-worker.js.map +0 -7
  163. package/node_modules/@blockcast/fec-worker/dist/index.d.ts +0 -10
  164. package/node_modules/@blockcast/fec-worker/dist/index.d.ts.map +0 -1
  165. package/node_modules/@blockcast/fec-worker/dist/index.js +0 -8
  166. package/node_modules/@blockcast/fec-worker/dist/index.js.map +0 -1
  167. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts +0 -20
  168. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.d.ts.map +0 -1
  169. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js +0 -370
  170. package/node_modules/@blockcast/fec-worker/dist/shred-fec-worker.js.map +0 -7
  171. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts +0 -104
  172. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.d.ts.map +0 -1
  173. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js +0 -181
  174. package/node_modules/@blockcast/fec-worker/dist/shred-worker-client.js.map +0 -1
  175. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts +0 -194
  176. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.d.ts.map +0 -1
  177. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js +0 -62
  178. package/node_modules/@blockcast/fec-worker/dist/shred-worker-types.js.map +0 -1
  179. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts +0 -9
  180. package/node_modules/@blockcast/fec-worker/dist/transfer.d.ts.map +0 -1
  181. package/node_modules/@blockcast/fec-worker/dist/transfer.js +0 -13
  182. package/node_modules/@blockcast/fec-worker/dist/transfer.js.map +0 -1
  183. package/node_modules/@blockcast/fec-worker/package.json +0 -59
  184. package/node_modules/@blockcast/fec-worker/src/block-order.ts +0 -93
  185. package/node_modules/@blockcast/fec-worker/src/fec-worker-client.ts +0 -392
  186. package/node_modules/@blockcast/fec-worker/src/fec-worker-types.ts +0 -399
  187. package/node_modules/@blockcast/fec-worker/src/fec-worker.ts +0 -1502
  188. package/node_modules/@blockcast/fec-worker/src/index.ts +0 -35
  189. package/node_modules/@blockcast/fec-worker/src/shred-fec-worker.ts +0 -589
  190. package/node_modules/@blockcast/fec-worker/src/shred-worker-client.ts +0 -222
  191. package/node_modules/@blockcast/fec-worker/src/shred-worker-types.ts +0 -209
  192. package/node_modules/@blockcast/fec-worker/src/transfer.ts +0 -12
  193. package/node_modules/@blockcast/mmt-alta-parse/README.md +0 -181
  194. package/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  195. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +0 -57
  196. package/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +0 -1
  197. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js +0 -115
  198. package/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +0 -1
  199. package/node_modules/@blockcast/mmt-alta-parse/package.json +0 -50
  200. package/node_modules/@blockcast/mmt-alta-parse/src/index.ts +0 -136
  201. package/node_modules/@blockcast/mmt-base/README.md +0 -134
  202. package/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  203. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts +0 -55
  204. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts.map +0 -1
  205. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js +0 -128
  206. package/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js.map +0 -1
  207. package/node_modules/@blockcast/mmt-base/dist/index.d.ts +0 -7
  208. package/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +0 -1
  209. package/node_modules/@blockcast/mmt-base/dist/index.js +0 -7
  210. package/node_modules/@blockcast/mmt-base/dist/index.js.map +0 -1
  211. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +0 -292
  212. package/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +0 -1
  213. package/node_modules/@blockcast/mmt-base/dist/mmtp.js +0 -612
  214. package/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +0 -1
  215. package/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts +0 -18
  216. package/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts.map +0 -1
  217. package/node_modules/@blockcast/mmt-base/dist/net-constants.js +0 -18
  218. package/node_modules/@blockcast/mmt-base/dist/net-constants.js.map +0 -1
  219. package/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts +0 -47
  220. package/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts.map +0 -1
  221. package/node_modules/@blockcast/mmt-base/dist/ntp-short.js +0 -54
  222. package/node_modules/@blockcast/mmt-base/dist/ntp-short.js.map +0 -1
  223. package/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts +0 -57
  224. package/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts.map +0 -1
  225. package/node_modules/@blockcast/mmt-base/dist/serial-number.js +0 -98
  226. package/node_modules/@blockcast/mmt-base/dist/serial-number.js.map +0 -1
  227. package/node_modules/@blockcast/mmt-base/dist/signalling.d.ts +0 -312
  228. package/node_modules/@blockcast/mmt-base/dist/signalling.d.ts.map +0 -1
  229. package/node_modules/@blockcast/mmt-base/dist/signalling.js +0 -637
  230. package/node_modules/@blockcast/mmt-base/dist/signalling.js.map +0 -1
  231. package/node_modules/@blockcast/mmt-base/package.json +0 -49
  232. package/node_modules/@blockcast/mmt-base/src/fec-block-profile.ts +0 -145
  233. package/node_modules/@blockcast/mmt-base/src/index.ts +0 -6
  234. package/node_modules/@blockcast/mmt-base/src/mmtp.ts +0 -892
  235. package/node_modules/@blockcast/mmt-base/src/net-constants.ts +0 -17
  236. package/node_modules/@blockcast/mmt-base/src/ntp-short.ts +0 -67
  237. package/node_modules/@blockcast/mmt-base/src/serial-number.ts +0 -107
  238. package/node_modules/@blockcast/mmt-base/src/signalling.ts +0 -862
  239. package/node_modules/@blockcast/mmt-fec/README.md +0 -271
  240. package/node_modules/@blockcast/mmt-fec/dist/.build-stamp +0 -0
  241. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts +0 -82
  242. package/node_modules/@blockcast/mmt-fec/dist/block-manager.d.ts.map +0 -1
  243. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js +0 -296
  244. package/node_modules/@blockcast/mmt-fec/dist/block-manager.js.map +0 -1
  245. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts +0 -106
  246. package/node_modules/@blockcast/mmt-fec/dist/block-processor.d.ts.map +0 -1
  247. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js +0 -288
  248. package/node_modules/@blockcast/mmt-fec/dist/block-processor.js.map +0 -1
  249. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts +0 -46
  250. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.d.ts.map +0 -1
  251. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js +0 -96
  252. package/node_modules/@blockcast/mmt-fec/dist/cmaf-recovery.js.map +0 -1
  253. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts +0 -33
  254. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.d.ts.map +0 -1
  255. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js +0 -57
  256. package/node_modules/@blockcast/mmt-fec/dist/cmaf-symbols.js.map +0 -1
  257. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts +0 -205
  258. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.d.ts.map +0 -1
  259. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js +0 -240
  260. package/node_modules/@blockcast/mmt-fec/dist/fec-block-mapper.js.map +0 -1
  261. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts +0 -28
  262. package/node_modules/@blockcast/mmt-fec/dist/index.d.ts.map +0 -1
  263. package/node_modules/@blockcast/mmt-fec/dist/index.js +0 -28
  264. package/node_modules/@blockcast/mmt-fec/dist/index.js.map +0 -1
  265. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts +0 -20
  266. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.d.ts.map +0 -1
  267. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js +0 -28
  268. package/node_modules/@blockcast/mmt-fec/dist/loc-symbols.js.map +0 -1
  269. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts +0 -258
  270. package/node_modules/@blockcast/mmt-fec/dist/oti.d.ts.map +0 -1
  271. package/node_modules/@blockcast/mmt-fec/dist/oti.js +0 -382
  272. package/node_modules/@blockcast/mmt-fec/dist/oti.js.map +0 -1
  273. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts +0 -41
  274. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.d.ts.map +0 -1
  275. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js +0 -81
  276. package/node_modules/@blockcast/mmt-fec/dist/reorder-buffer.js.map +0 -1
  277. package/node_modules/@blockcast/mmt-fec/dist/repair-group.d.ts +0 -82
  278. package/node_modules/@blockcast/mmt-fec/dist/repair-group.d.ts.map +0 -1
  279. package/node_modules/@blockcast/mmt-fec/dist/repair-group.js +0 -170
  280. package/node_modules/@blockcast/mmt-fec/dist/repair-group.js.map +0 -1
  281. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/README.md +0 -181
  282. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/.build-stamp +0 -0
  283. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts +0 -57
  284. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.d.ts.map +0 -1
  285. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js +0 -115
  286. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/dist/index.js.map +0 -1
  287. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/package.json +0 -50
  288. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-alta-parse/src/index.ts +0 -136
  289. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/README.md +0 -134
  290. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/.build-stamp +0 -0
  291. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts +0 -55
  292. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.d.ts.map +0 -1
  293. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js +0 -128
  294. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/fec-block-profile.js.map +0 -1
  295. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts +0 -7
  296. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.d.ts.map +0 -1
  297. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js +0 -7
  298. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/index.js.map +0 -1
  299. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts +0 -292
  300. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.d.ts.map +0 -1
  301. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js +0 -612
  302. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/mmtp.js.map +0 -1
  303. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts +0 -18
  304. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.d.ts.map +0 -1
  305. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.js +0 -18
  306. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/net-constants.js.map +0 -1
  307. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts +0 -47
  308. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.d.ts.map +0 -1
  309. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.js +0 -54
  310. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/ntp-short.js.map +0 -1
  311. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts +0 -57
  312. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.d.ts.map +0 -1
  313. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.js +0 -98
  314. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/serial-number.js.map +0 -1
  315. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.d.ts +0 -312
  316. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.d.ts.map +0 -1
  317. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.js +0 -637
  318. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/dist/signalling.js.map +0 -1
  319. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/package.json +0 -49
  320. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/fec-block-profile.ts +0 -145
  321. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/index.ts +0 -6
  322. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/mmtp.ts +0 -892
  323. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/net-constants.ts +0 -17
  324. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/ntp-short.ts +0 -67
  325. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/serial-number.ts +0 -107
  326. package/node_modules/@blockcast/mmt-fec/node_modules/@blockcast/mmt-base/src/signalling.ts +0 -862
  327. package/node_modules/@blockcast/mmt-fec/package.json +0 -79
  328. package/node_modules/@blockcast/mmt-fec/src/block-manager.ts +0 -371
  329. package/node_modules/@blockcast/mmt-fec/src/block-processor.ts +0 -439
  330. package/node_modules/@blockcast/mmt-fec/src/cmaf-recovery.ts +0 -127
  331. package/node_modules/@blockcast/mmt-fec/src/cmaf-symbols.ts +0 -68
  332. package/node_modules/@blockcast/mmt-fec/src/fec-block-mapper.ts +0 -310
  333. package/node_modules/@blockcast/mmt-fec/src/index.ts +0 -94
  334. package/node_modules/@blockcast/mmt-fec/src/loc-symbols.ts +0 -34
  335. package/node_modules/@blockcast/mmt-fec/src/oti.ts +0 -463
  336. package/node_modules/@blockcast/mmt-fec/src/reorder-buffer.ts +0 -101
  337. package/node_modules/@blockcast/mmt-fec/src/repair-group.ts +0 -195
  338. package/node_modules/@blockcast/mmt-manifest-verify/dist/.build-stamp +0 -0
  339. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts +0 -28
  340. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.d.ts.map +0 -1
  341. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js +0 -128
  342. package/node_modules/@blockcast/mmt-manifest-verify/dist/admission.js.map +0 -1
  343. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts +0 -4
  344. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.d.ts.map +0 -1
  345. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js +0 -4
  346. package/node_modules/@blockcast/mmt-manifest-verify/dist/index.js.map +0 -1
  347. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts +0 -37
  348. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.d.ts.map +0 -1
  349. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js +0 -179
  350. package/node_modules/@blockcast/mmt-manifest-verify/dist/source-auth.js.map +0 -1
  351. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts +0 -99
  352. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.d.ts.map +0 -1
  353. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js +0 -492
  354. package/node_modules/@blockcast/mmt-manifest-verify/dist/verifier.js.map +0 -1
  355. package/node_modules/@blockcast/mmt-manifest-verify/package.json +0 -45
  356. package/node_modules/@blockcast/mmt-manifest-verify/src/admission.ts +0 -171
  357. package/node_modules/@blockcast/mmt-manifest-verify/src/index.ts +0 -3
  358. package/node_modules/@blockcast/mmt-manifest-verify/src/source-auth.ts +0 -230
  359. package/node_modules/@blockcast/mmt-manifest-verify/src/verifier.ts +0 -669
  360. package/node_modules/@noble/hashes/LICENSE +0 -21
  361. package/node_modules/@noble/hashes/README.md +0 -521
  362. package/node_modules/@noble/hashes/_assert.d.ts +0 -17
  363. package/node_modules/@noble/hashes/_assert.d.ts.map +0 -1
  364. package/node_modules/@noble/hashes/_assert.js +0 -18
  365. package/node_modules/@noble/hashes/_assert.js.map +0 -1
  366. package/node_modules/@noble/hashes/_blake.d.ts +0 -14
  367. package/node_modules/@noble/hashes/_blake.d.ts.map +0 -1
  368. package/node_modules/@noble/hashes/_blake.js +0 -50
  369. package/node_modules/@noble/hashes/_blake.js.map +0 -1
  370. package/node_modules/@noble/hashes/_md.d.ts +0 -51
  371. package/node_modules/@noble/hashes/_md.d.ts.map +0 -1
  372. package/node_modules/@noble/hashes/_md.js +0 -162
  373. package/node_modules/@noble/hashes/_md.js.map +0 -1
  374. package/node_modules/@noble/hashes/_u64.d.ts +0 -55
  375. package/node_modules/@noble/hashes/_u64.d.ts.map +0 -1
  376. package/node_modules/@noble/hashes/_u64.js +0 -90
  377. package/node_modules/@noble/hashes/_u64.js.map +0 -1
  378. package/node_modules/@noble/hashes/argon2.d.ts +0 -32
  379. package/node_modules/@noble/hashes/argon2.d.ts.map +0 -1
  380. package/node_modules/@noble/hashes/argon2.js +0 -401
  381. package/node_modules/@noble/hashes/argon2.js.map +0 -1
  382. package/node_modules/@noble/hashes/blake1.d.ts +0 -106
  383. package/node_modules/@noble/hashes/blake1.d.ts.map +0 -1
  384. package/node_modules/@noble/hashes/blake1.js +0 -459
  385. package/node_modules/@noble/hashes/blake1.js.map +0 -1
  386. package/node_modules/@noble/hashes/blake2.d.ts +0 -116
  387. package/node_modules/@noble/hashes/blake2.d.ts.map +0 -1
  388. package/node_modules/@noble/hashes/blake2.js +0 -420
  389. package/node_modules/@noble/hashes/blake2.js.map +0 -1
  390. package/node_modules/@noble/hashes/blake2b.d.ts +0 -11
  391. package/node_modules/@noble/hashes/blake2b.d.ts.map +0 -1
  392. package/node_modules/@noble/hashes/blake2b.js +0 -14
  393. package/node_modules/@noble/hashes/blake2b.js.map +0 -1
  394. package/node_modules/@noble/hashes/blake2s.d.ts +0 -20
  395. package/node_modules/@noble/hashes/blake2s.d.ts.map +0 -1
  396. package/node_modules/@noble/hashes/blake2s.js +0 -24
  397. package/node_modules/@noble/hashes/blake2s.js.map +0 -1
  398. package/node_modules/@noble/hashes/blake3.d.ts +0 -54
  399. package/node_modules/@noble/hashes/blake3.d.ts.map +0 -1
  400. package/node_modules/@noble/hashes/blake3.js +0 -255
  401. package/node_modules/@noble/hashes/blake3.js.map +0 -1
  402. package/node_modules/@noble/hashes/crypto.d.ts +0 -2
  403. package/node_modules/@noble/hashes/crypto.d.ts.map +0 -1
  404. package/node_modules/@noble/hashes/crypto.js +0 -5
  405. package/node_modules/@noble/hashes/crypto.js.map +0 -1
  406. package/node_modules/@noble/hashes/cryptoNode.d.ts +0 -2
  407. package/node_modules/@noble/hashes/cryptoNode.d.ts.map +0 -1
  408. package/node_modules/@noble/hashes/cryptoNode.js +0 -18
  409. package/node_modules/@noble/hashes/cryptoNode.js.map +0 -1
  410. package/node_modules/@noble/hashes/eskdf.d.ts +0 -47
  411. package/node_modules/@noble/hashes/eskdf.d.ts.map +0 -1
  412. package/node_modules/@noble/hashes/eskdf.js +0 -166
  413. package/node_modules/@noble/hashes/eskdf.js.map +0 -1
  414. package/node_modules/@noble/hashes/esm/_assert.d.ts +0 -17
  415. package/node_modules/@noble/hashes/esm/_assert.d.ts.map +0 -1
  416. package/node_modules/@noble/hashes/esm/_assert.js +0 -15
  417. package/node_modules/@noble/hashes/esm/_assert.js.map +0 -1
  418. package/node_modules/@noble/hashes/esm/_blake.d.ts +0 -14
  419. package/node_modules/@noble/hashes/esm/_blake.d.ts.map +0 -1
  420. package/node_modules/@noble/hashes/esm/_blake.js +0 -45
  421. package/node_modules/@noble/hashes/esm/_blake.js.map +0 -1
  422. package/node_modules/@noble/hashes/esm/_md.d.ts +0 -51
  423. package/node_modules/@noble/hashes/esm/_md.d.ts.map +0 -1
  424. package/node_modules/@noble/hashes/esm/_md.js +0 -155
  425. package/node_modules/@noble/hashes/esm/_md.js.map +0 -1
  426. package/node_modules/@noble/hashes/esm/_u64.d.ts +0 -55
  427. package/node_modules/@noble/hashes/esm/_u64.d.ts.map +0 -1
  428. package/node_modules/@noble/hashes/esm/_u64.js +0 -67
  429. package/node_modules/@noble/hashes/esm/_u64.js.map +0 -1
  430. package/node_modules/@noble/hashes/esm/argon2.d.ts +0 -32
  431. package/node_modules/@noble/hashes/esm/argon2.d.ts.map +0 -1
  432. package/node_modules/@noble/hashes/esm/argon2.js +0 -392
  433. package/node_modules/@noble/hashes/esm/argon2.js.map +0 -1
  434. package/node_modules/@noble/hashes/esm/blake1.d.ts +0 -106
  435. package/node_modules/@noble/hashes/esm/blake1.d.ts.map +0 -1
  436. package/node_modules/@noble/hashes/esm/blake1.js +0 -452
  437. package/node_modules/@noble/hashes/esm/blake1.js.map +0 -1
  438. package/node_modules/@noble/hashes/esm/blake2.d.ts +0 -116
  439. package/node_modules/@noble/hashes/esm/blake2.d.ts.map +0 -1
  440. package/node_modules/@noble/hashes/esm/blake2.js +0 -413
  441. package/node_modules/@noble/hashes/esm/blake2.js.map +0 -1
  442. package/node_modules/@noble/hashes/esm/blake2b.d.ts +0 -11
  443. package/node_modules/@noble/hashes/esm/blake2b.d.ts.map +0 -1
  444. package/node_modules/@noble/hashes/esm/blake2b.js +0 -11
  445. package/node_modules/@noble/hashes/esm/blake2b.js.map +0 -1
  446. package/node_modules/@noble/hashes/esm/blake2s.d.ts +0 -20
  447. package/node_modules/@noble/hashes/esm/blake2s.d.ts.map +0 -1
  448. package/node_modules/@noble/hashes/esm/blake2s.js +0 -21
  449. package/node_modules/@noble/hashes/esm/blake2s.js.map +0 -1
  450. package/node_modules/@noble/hashes/esm/blake3.d.ts +0 -54
  451. package/node_modules/@noble/hashes/esm/blake3.d.ts.map +0 -1
  452. package/node_modules/@noble/hashes/esm/blake3.js +0 -251
  453. package/node_modules/@noble/hashes/esm/blake3.js.map +0 -1
  454. package/node_modules/@noble/hashes/esm/crypto.d.ts +0 -2
  455. package/node_modules/@noble/hashes/esm/crypto.d.ts.map +0 -1
  456. package/node_modules/@noble/hashes/esm/crypto.js +0 -2
  457. package/node_modules/@noble/hashes/esm/crypto.js.map +0 -1
  458. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts +0 -2
  459. package/node_modules/@noble/hashes/esm/cryptoNode.d.ts.map +0 -1
  460. package/node_modules/@noble/hashes/esm/cryptoNode.js +0 -15
  461. package/node_modules/@noble/hashes/esm/cryptoNode.js.map +0 -1
  462. package/node_modules/@noble/hashes/esm/eskdf.d.ts +0 -47
  463. package/node_modules/@noble/hashes/esm/eskdf.d.ts.map +0 -1
  464. package/node_modules/@noble/hashes/esm/eskdf.js +0 -160
  465. package/node_modules/@noble/hashes/esm/eskdf.js.map +0 -1
  466. package/node_modules/@noble/hashes/esm/hkdf.d.ts +0 -36
  467. package/node_modules/@noble/hashes/esm/hkdf.d.ts.map +0 -1
  468. package/node_modules/@noble/hashes/esm/hkdf.js +0 -82
  469. package/node_modules/@noble/hashes/esm/hkdf.js.map +0 -1
  470. package/node_modules/@noble/hashes/esm/hmac.d.ts +0 -35
  471. package/node_modules/@noble/hashes/esm/hmac.d.ts.map +0 -1
  472. package/node_modules/@noble/hashes/esm/hmac.js +0 -86
  473. package/node_modules/@noble/hashes/esm/hmac.js.map +0 -1
  474. package/node_modules/@noble/hashes/esm/index.d.ts +0 -2
  475. package/node_modules/@noble/hashes/esm/index.d.ts.map +0 -1
  476. package/node_modules/@noble/hashes/esm/index.js +0 -33
  477. package/node_modules/@noble/hashes/esm/index.js.map +0 -1
  478. package/node_modules/@noble/hashes/esm/legacy.d.ts +0 -71
  479. package/node_modules/@noble/hashes/esm/legacy.d.ts.map +0 -1
  480. package/node_modules/@noble/hashes/esm/legacy.js +0 -281
  481. package/node_modules/@noble/hashes/esm/legacy.js.map +0 -1
  482. package/node_modules/@noble/hashes/esm/package.json +0 -10
  483. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts +0 -23
  484. package/node_modules/@noble/hashes/esm/pbkdf2.d.ts.map +0 -1
  485. package/node_modules/@noble/hashes/esm/pbkdf2.js +0 -97
  486. package/node_modules/@noble/hashes/esm/pbkdf2.js.map +0 -1
  487. package/node_modules/@noble/hashes/esm/ripemd160.d.ts +0 -13
  488. package/node_modules/@noble/hashes/esm/ripemd160.d.ts.map +0 -1
  489. package/node_modules/@noble/hashes/esm/ripemd160.js +0 -13
  490. package/node_modules/@noble/hashes/esm/ripemd160.js.map +0 -1
  491. package/node_modules/@noble/hashes/esm/scrypt.d.ts +0 -34
  492. package/node_modules/@noble/hashes/esm/scrypt.d.ts.map +0 -1
  493. package/node_modules/@noble/hashes/esm/scrypt.js +0 -228
  494. package/node_modules/@noble/hashes/esm/scrypt.js.map +0 -1
  495. package/node_modules/@noble/hashes/esm/sha1.d.ts +0 -11
  496. package/node_modules/@noble/hashes/esm/sha1.d.ts.map +0 -1
  497. package/node_modules/@noble/hashes/esm/sha1.js +0 -11
  498. package/node_modules/@noble/hashes/esm/sha1.js.map +0 -1
  499. package/node_modules/@noble/hashes/esm/sha2.d.ts +0 -159
  500. package/node_modules/@noble/hashes/esm/sha2.d.ts.map +0 -1
  501. package/node_modules/@noble/hashes/esm/sha2.js +0 -375
  502. package/node_modules/@noble/hashes/esm/sha2.js.map +0 -1
  503. package/node_modules/@noble/hashes/esm/sha256.d.ts +0 -20
  504. package/node_modules/@noble/hashes/esm/sha256.d.ts.map +0 -1
  505. package/node_modules/@noble/hashes/esm/sha256.js +0 -20
  506. package/node_modules/@noble/hashes/esm/sha256.js.map +0 -1
  507. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts +0 -142
  508. package/node_modules/@noble/hashes/esm/sha3-addons.d.ts.map +0 -1
  509. package/node_modules/@noble/hashes/esm/sha3-addons.js +0 -393
  510. package/node_modules/@noble/hashes/esm/sha3-addons.js.map +0 -1
  511. package/node_modules/@noble/hashes/esm/sha3.d.ts +0 -53
  512. package/node_modules/@noble/hashes/esm/sha3.d.ts.map +0 -1
  513. package/node_modules/@noble/hashes/esm/sha3.js +0 -234
  514. package/node_modules/@noble/hashes/esm/sha3.js.map +0 -1
  515. package/node_modules/@noble/hashes/esm/sha512.d.ts +0 -26
  516. package/node_modules/@noble/hashes/esm/sha512.d.ts.map +0 -1
  517. package/node_modules/@noble/hashes/esm/sha512.js +0 -26
  518. package/node_modules/@noble/hashes/esm/sha512.js.map +0 -1
  519. package/node_modules/@noble/hashes/esm/utils.d.ts +0 -161
  520. package/node_modules/@noble/hashes/esm/utils.d.ts.map +0 -1
  521. package/node_modules/@noble/hashes/esm/utils.js +0 -281
  522. package/node_modules/@noble/hashes/esm/utils.js.map +0 -1
  523. package/node_modules/@noble/hashes/hkdf.d.ts +0 -36
  524. package/node_modules/@noble/hashes/hkdf.d.ts.map +0 -1
  525. package/node_modules/@noble/hashes/hkdf.js +0 -88
  526. package/node_modules/@noble/hashes/hkdf.js.map +0 -1
  527. package/node_modules/@noble/hashes/hmac.d.ts +0 -35
  528. package/node_modules/@noble/hashes/hmac.d.ts.map +0 -1
  529. package/node_modules/@noble/hashes/hmac.js +0 -91
  530. package/node_modules/@noble/hashes/hmac.js.map +0 -1
  531. package/node_modules/@noble/hashes/index.d.ts +0 -1
  532. package/node_modules/@noble/hashes/index.d.ts.map +0 -1
  533. package/node_modules/@noble/hashes/index.js +0 -33
  534. package/node_modules/@noble/hashes/index.js.map +0 -1
  535. package/node_modules/@noble/hashes/legacy.d.ts +0 -71
  536. package/node_modules/@noble/hashes/legacy.d.ts.map +0 -1
  537. package/node_modules/@noble/hashes/legacy.js +0 -287
  538. package/node_modules/@noble/hashes/legacy.js.map +0 -1
  539. package/node_modules/@noble/hashes/package.json +0 -266
  540. package/node_modules/@noble/hashes/pbkdf2.d.ts +0 -23
  541. package/node_modules/@noble/hashes/pbkdf2.d.ts.map +0 -1
  542. package/node_modules/@noble/hashes/pbkdf2.js +0 -101
  543. package/node_modules/@noble/hashes/pbkdf2.js.map +0 -1
  544. package/node_modules/@noble/hashes/ripemd160.d.ts +0 -13
  545. package/node_modules/@noble/hashes/ripemd160.d.ts.map +0 -1
  546. package/node_modules/@noble/hashes/ripemd160.js +0 -16
  547. package/node_modules/@noble/hashes/ripemd160.js.map +0 -1
  548. package/node_modules/@noble/hashes/scrypt.d.ts +0 -34
  549. package/node_modules/@noble/hashes/scrypt.d.ts.map +0 -1
  550. package/node_modules/@noble/hashes/scrypt.js +0 -232
  551. package/node_modules/@noble/hashes/scrypt.js.map +0 -1
  552. package/node_modules/@noble/hashes/sha1.d.ts +0 -11
  553. package/node_modules/@noble/hashes/sha1.d.ts.map +0 -1
  554. package/node_modules/@noble/hashes/sha1.js +0 -14
  555. package/node_modules/@noble/hashes/sha1.js.map +0 -1
  556. package/node_modules/@noble/hashes/sha2.d.ts +0 -159
  557. package/node_modules/@noble/hashes/sha2.d.ts.map +0 -1
  558. package/node_modules/@noble/hashes/sha2.js +0 -384
  559. package/node_modules/@noble/hashes/sha2.js.map +0 -1
  560. package/node_modules/@noble/hashes/sha256.d.ts +0 -20
  561. package/node_modules/@noble/hashes/sha256.d.ts.map +0 -1
  562. package/node_modules/@noble/hashes/sha256.js +0 -23
  563. package/node_modules/@noble/hashes/sha256.js.map +0 -1
  564. package/node_modules/@noble/hashes/sha3-addons.d.ts +0 -142
  565. package/node_modules/@noble/hashes/sha3-addons.d.ts.map +0 -1
  566. package/node_modules/@noble/hashes/sha3-addons.js +0 -402
  567. package/node_modules/@noble/hashes/sha3-addons.js.map +0 -1
  568. package/node_modules/@noble/hashes/sha3.d.ts +0 -53
  569. package/node_modules/@noble/hashes/sha3.d.ts.map +0 -1
  570. package/node_modules/@noble/hashes/sha3.js +0 -239
  571. package/node_modules/@noble/hashes/sha3.js.map +0 -1
  572. package/node_modules/@noble/hashes/sha512.d.ts +0 -26
  573. package/node_modules/@noble/hashes/sha512.d.ts.map +0 -1
  574. package/node_modules/@noble/hashes/sha512.js +0 -29
  575. package/node_modules/@noble/hashes/sha512.js.map +0 -1
  576. package/node_modules/@noble/hashes/src/_assert.ts +0 -22
  577. package/node_modules/@noble/hashes/src/_blake.ts +0 -50
  578. package/node_modules/@noble/hashes/src/_md.ts +0 -176
  579. package/node_modules/@noble/hashes/src/_u64.ts +0 -91
  580. package/node_modules/@noble/hashes/src/argon2.ts +0 -497
  581. package/node_modules/@noble/hashes/src/blake1.ts +0 -534
  582. package/node_modules/@noble/hashes/src/blake2.ts +0 -486
  583. package/node_modules/@noble/hashes/src/blake2b.ts +0 -10
  584. package/node_modules/@noble/hashes/src/blake2s.ts +0 -20
  585. package/node_modules/@noble/hashes/src/blake3.ts +0 -272
  586. package/node_modules/@noble/hashes/src/crypto.ts +0 -9
  587. package/node_modules/@noble/hashes/src/cryptoNode.ts +0 -15
  588. package/node_modules/@noble/hashes/src/eskdf.ts +0 -187
  589. package/node_modules/@noble/hashes/src/hkdf.ts +0 -88
  590. package/node_modules/@noble/hashes/src/hmac.ts +0 -94
  591. package/node_modules/@noble/hashes/src/index.ts +0 -31
  592. package/node_modules/@noble/hashes/src/legacy.ts +0 -293
  593. package/node_modules/@noble/hashes/src/pbkdf2.ts +0 -122
  594. package/node_modules/@noble/hashes/src/ripemd160.ts +0 -12
  595. package/node_modules/@noble/hashes/src/scrypt.ts +0 -257
  596. package/node_modules/@noble/hashes/src/sha1.ts +0 -10
  597. package/node_modules/@noble/hashes/src/sha2.ts +0 -402
  598. package/node_modules/@noble/hashes/src/sha256.ts +0 -24
  599. package/node_modules/@noble/hashes/src/sha3-addons.ts +0 -499
  600. package/node_modules/@noble/hashes/src/sha3.ts +0 -258
  601. package/node_modules/@noble/hashes/src/sha512.ts +0 -34
  602. package/node_modules/@noble/hashes/src/utils.ts +0 -395
  603. package/node_modules/@noble/hashes/utils.d.ts +0 -161
  604. package/node_modules/@noble/hashes/utils.d.ts.map +0 -1
  605. package/node_modules/@noble/hashes/utils.js +0 -313
  606. package/node_modules/@noble/hashes/utils.js.map +0 -1
@@ -0,0 +1,1857 @@
1
+ // ../mmt-base/dist/mmtp.js
2
+ var MPU_HEADER_SIZE = 8;
3
+ var MPU_LENGTH_FIELD_SIZE = 2;
4
+ var MPU_HEADER_REMAINDER_SIZE = MPU_HEADER_SIZE - MPU_LENGTH_FIELD_SIZE;
5
+
6
+ // ../mmt-base/dist/ntp-short.js
7
+ var NTP_SHORT_BITS = 32;
8
+ var NTP_SHORT_MODULUS = 2 ** NTP_SHORT_BITS;
9
+ var NTP_SHORT_HALF_RANGE = 2 ** (NTP_SHORT_BITS - 1);
10
+
11
+ // ../mmt-base/dist/fec-block-profile.js
12
+ var FEC_BLOCK_PROFILES = Object.freeze([
13
+ "iso-ssbg1-v1"
14
+ ]);
15
+ function isFecBlockProfile(value) {
16
+ return value === "iso-ssbg1-v1";
17
+ }
18
+ function parseFecBlockProfile(value, where) {
19
+ if (isFecBlockProfile(value))
20
+ return value;
21
+ if (value === void 0) {
22
+ throw new Error(`${where} is required: name the FEC block profile ("iso-ssbg1-v1")`);
23
+ }
24
+ throw new Error(`${where} must be "iso-ssbg1-v1" (got ${JSON.stringify(value)})`);
25
+ }
26
+
27
+ // node_modules/@blockcast/mmt-transport/dist/types.js
28
+ var MoqFecAlgorithm;
29
+ (function(MoqFecAlgorithm2) {
30
+ MoqFecAlgorithm2[MoqFecAlgorithm2["None"] = 0] = "None";
31
+ MoqFecAlgorithm2[MoqFecAlgorithm2["Xor"] = 1] = "Xor";
32
+ MoqFecAlgorithm2[MoqFecAlgorithm2["RaptorQ"] = 2] = "RaptorQ";
33
+ })(MoqFecAlgorithm || (MoqFecAlgorithm = {}));
34
+
35
+ // node_modules/@blockcast/mmt-base/dist/mmtp.js
36
+ var MPU_HEADER_SIZE2 = 8;
37
+ var MPU_LENGTH_FIELD_SIZE2 = 2;
38
+ var MPU_HEADER_REMAINDER_SIZE2 = MPU_HEADER_SIZE2 - MPU_LENGTH_FIELD_SIZE2;
39
+ var MMTP_SIGNALING_PACKET_ID = 0;
40
+ var MMTP_PACKET_ID_MAX = 65535;
41
+
42
+ // node_modules/@blockcast/mmt-base/dist/net-constants.js
43
+ var DEFAULT_AMT_RELAY_PORT = 2268;
44
+
45
+ // node_modules/@blockcast/mmt-base/dist/ntp-short.js
46
+ var NTP_SHORT_BITS2 = 32;
47
+ var NTP_SHORT_MODULUS2 = 2 ** NTP_SHORT_BITS2;
48
+ var NTP_SHORT_HALF_RANGE2 = 2 ** (NTP_SHORT_BITS2 - 1);
49
+ function isNtpShort(value) {
50
+ return Number.isInteger(value) && value >= 0 && value < NTP_SHORT_MODULUS2;
51
+ }
52
+ function compareNtpShort(a, b) {
53
+ if (!isNtpShort(a) || !isNtpShort(b)) {
54
+ throw new RangeError(`NTP-short values must be integers in [0, 2^${NTP_SHORT_BITS2}), got ${String(a)} and ${String(b)}`);
55
+ }
56
+ if (a === b)
57
+ return "equal";
58
+ const forward = (a - b + NTP_SHORT_MODULUS2) % NTP_SHORT_MODULUS2;
59
+ if (forward < NTP_SHORT_HALF_RANGE2)
60
+ return "after";
61
+ if (forward > NTP_SHORT_HALF_RANGE2)
62
+ return "before";
63
+ return "unordered";
64
+ }
65
+
66
+ // node_modules/@blockcast/mmt-base/dist/fec-block-profile.js
67
+ var FEC_BLOCK_PROFILES2 = Object.freeze([
68
+ "iso-ssbg1-v1"
69
+ ]);
70
+
71
+ // node_modules/@blockcast/mmt-transport/dist/driad-discovery.js
72
+ var DRIADDiscovery = class {
73
+ cache = /* @__PURE__ */ new Map();
74
+ cacheExpiry = 3e5;
75
+ // 5 minutes
76
+ /**
77
+ * Discover AMT relays for a multicast source address (RFC 8777)
78
+ *
79
+ * @param source - The multicast source IP address (NOT the group!)
80
+ * @returns Array of discovered AMT relays that can tunnel traffic from this source
81
+ */
82
+ async discoverRelays(source) {
83
+ const cached = this.cache.get(source);
84
+ if (cached) {
85
+ return cached;
86
+ }
87
+ try {
88
+ const reversedSource = source.split(".").reverse().join(".");
89
+ const queryDomain = `${reversedSource}.amt.in-addr.arpa`;
90
+ console.log(`[DRIAD] Discovering relays for source ${source} via ${queryDomain}`);
91
+ const relays = await this.queryDRIADProxy(source);
92
+ if (relays.length > 0) {
93
+ this.cache.set(source, relays);
94
+ setTimeout(() => this.cache.delete(source), this.cacheExpiry);
95
+ }
96
+ return relays;
97
+ } catch (error) {
98
+ console.warn(`[DRIAD] Discovery failed for source ${source}:`, error);
99
+ return [];
100
+ }
101
+ }
102
+ /**
103
+ * Query DRIAD proxy service (browser-compatible)
104
+ */
105
+ async queryDRIADProxy(source) {
106
+ const proxyEndpoints = [
107
+ "https://driad.amt.net/api/v1/relays",
108
+ "https://multicast-gateway.cloudflare.com/driad"
109
+ ];
110
+ for (const endpoint of proxyEndpoints) {
111
+ try {
112
+ const response = await fetch(`${endpoint}?source=${encodeURIComponent(source)}`, {
113
+ method: "GET",
114
+ headers: { Accept: "application/json" },
115
+ signal: AbortSignal.timeout(5e3)
116
+ });
117
+ if (response.ok) {
118
+ const data = await response.json();
119
+ return data.relays || [];
120
+ }
121
+ } catch {
122
+ }
123
+ }
124
+ const dohRelay = await this.queryDNSOverHTTPS(source);
125
+ if (dohRelay) {
126
+ return [dohRelay];
127
+ }
128
+ return [];
129
+ }
130
+ /**
131
+ * Query DNS-over-HTTPS for DRIAD relay based on source address (RFC 8777)
132
+ */
133
+ async queryDNSOverHTTPS(source) {
134
+ try {
135
+ const reversedSource = source.split(".").reverse().join(".");
136
+ const queryName = `${reversedSource}.amt.in-addr.arpa`;
137
+ const dohUrl = `https://cloudflare-dns.com/dns-query?name=${queryName}&type=A`;
138
+ const response = await fetch(dohUrl, {
139
+ headers: { Accept: "application/dns-json" },
140
+ signal: AbortSignal.timeout(3e3)
141
+ });
142
+ if (!response.ok) {
143
+ return null;
144
+ }
145
+ const result = await response.json();
146
+ if (result.Answer && result.Answer.length > 0) {
147
+ return {
148
+ host: result.Answer[0].data,
149
+ port: DEFAULT_AMT_RELAY_PORT,
150
+ priority: 10,
151
+ weight: 100,
152
+ asn: 0
153
+ };
154
+ }
155
+ return null;
156
+ } catch (error) {
157
+ console.warn("[DRIAD] DNS-over-HTTPS query failed:", error);
158
+ return null;
159
+ }
160
+ }
161
+ /**
162
+ * Select best relay based on RTT measurements
163
+ */
164
+ async selectBestRelay(relays) {
165
+ if (relays.length === 0)
166
+ return null;
167
+ const measured = await Promise.all(relays.map(async (relay) => {
168
+ const rtt = await this.measureRTT(relay.host, relay.port);
169
+ return { ...relay, rtt };
170
+ }));
171
+ measured.sort((a, b) => {
172
+ if (a.priority !== b.priority)
173
+ return a.priority - b.priority;
174
+ return (a.rtt || Infinity) - (b.rtt || Infinity);
175
+ });
176
+ console.log(`[DRIAD] Selected relay: ${measured[0].host} (RTT: ${measured[0].rtt}ms)`);
177
+ return measured[0];
178
+ }
179
+ async measureRTT(host, _port) {
180
+ const start = performance.now();
181
+ try {
182
+ await fetch(`https://${host}/health`, {
183
+ method: "HEAD",
184
+ signal: AbortSignal.timeout(2e3),
185
+ mode: "no-cors"
186
+ });
187
+ return performance.now() - start;
188
+ } catch {
189
+ return Infinity;
190
+ }
191
+ }
192
+ /**
193
+ * Clear the relay cache
194
+ */
195
+ clearCache() {
196
+ this.cache.clear();
197
+ }
198
+ /**
199
+ * Get cached relays for a source address
200
+ */
201
+ getCached(source) {
202
+ return this.cache.get(source);
203
+ }
204
+ };
205
+ var driadDiscovery = new DRIADDiscovery();
206
+
207
+ // node_modules/@blockcast/mmt-transport/dist/multicast-tier.js
208
+ function endpointKey(endpoint) {
209
+ return `${endpoint.sourceAddress ?? ""}|${endpoint.groupAddress}|${endpoint.port}`;
210
+ }
211
+ function carriesMedia(endpoint) {
212
+ return endpoint.carriesMedia !== false;
213
+ }
214
+ function selectMulticastTier(endpoints, estimate) {
215
+ const media = endpoints.filter(carriesMedia);
216
+ if (media.length <= 1)
217
+ return media[0];
218
+ const ranked = media.filter((endpoint) => typeof endpoint.bandwidth === "number" && endpoint.bandwidth > 0).sort((a, b) => a.bandwidth - b.bandwidth);
219
+ if (ranked.length < 2)
220
+ return media[0];
221
+ if (estimate === void 0)
222
+ return ranked[0];
223
+ const budget = estimate * 0.8;
224
+ let selected;
225
+ for (const endpoint of ranked) {
226
+ if (endpoint.bandwidth <= budget)
227
+ selected = endpoint;
228
+ }
229
+ return selected ?? ranked[0];
230
+ }
231
+
232
+ // node_modules/@blockcast/mmt-transport/dist/abr-controller.js
233
+ var QUALITY_LEVELS = Object.freeze([
234
+ { name: "240p", bitrate: 3e5, width: 426, height: 240, fps: 15 },
235
+ { name: "360p", bitrate: 5e5, width: 640, height: 360, fps: 24 },
236
+ { name: "480p", bitrate: 1e6, width: 854, height: 480, fps: 30 },
237
+ { name: "720p", bitrate: 25e5, width: 1280, height: 720, fps: 30 },
238
+ { name: "1080p", bitrate: 5e6, width: 1920, height: 1080, fps: 30 },
239
+ { name: "1440p", bitrate: 8e6, width: 2560, height: 1440, fps: 30 },
240
+ { name: "4K", bitrate: 15e6, width: 3840, height: 2160, fps: 30 }
241
+ ].map((level) => Object.freeze(level)));
242
+ function positiveFinite(value) {
243
+ return typeof value === "number" && Number.isFinite(value) && value > 0;
244
+ }
245
+ function validateQualityLadder(ladder) {
246
+ if (!Array.isArray(ladder) || ladder.length === 0) {
247
+ throw new TypeError("[ABR] ladder must list at least one rendition (e.g. the catalog's video tracks)");
248
+ }
249
+ const names = /* @__PURE__ */ new Set();
250
+ for (const level of ladder) {
251
+ if (typeof level?.name !== "string" || level.name.length === 0) {
252
+ throw new TypeError("[ABR] every ladder rendition needs a name");
253
+ }
254
+ if (!positiveFinite(level.bitrate)) {
255
+ throw new RangeError(`[ABR] rendition ${level.name}: bitrate must be a positive finite number, got ${String(level.bitrate)}`);
256
+ }
257
+ for (const field of ["width", "height", "fps"]) {
258
+ if (level[field] !== void 0 && !positiveFinite(level[field])) {
259
+ throw new RangeError(`[ABR] rendition ${level.name}: ${field} must be a positive finite number when stated, got ${String(level[field])}`);
260
+ }
261
+ }
262
+ if (names.has(level.name))
263
+ throw new RangeError(`[ABR] rendition ${level.name} appears twice in the ladder`);
264
+ names.add(level.name);
265
+ }
266
+ return Object.freeze([...ladder].sort((a, b) => a.bitrate - b.bitrate).map((level) => Object.freeze({ ...level })));
267
+ }
268
+ var AdaptiveBitrateController = class {
269
+ /** The caller's renditions, ascending by bitrate (`validateQualityLadder`). */
270
+ ladder;
271
+ currentQualityIndex;
272
+ history = [];
273
+ historyWindow = 1e4;
274
+ // 10 second window
275
+ upgradeThreshold = 0.8;
276
+ // 80% of target bitrate sustained
277
+ downgradeThreshold = 0.5;
278
+ // 50% of target bitrate triggers downgrade
279
+ stabilityPeriod = 5e3;
280
+ // Wait 5s before upgrading
281
+ lastQualityChange = 0;
282
+ onQualityChange;
283
+ // FEC stats for effective loss rate calculation
284
+ fecStats = {
285
+ rawLossRate: 0,
286
+ effectiveLossRate: 0,
287
+ recoveryRate: 1,
288
+ fecEnabled: false
289
+ };
290
+ constructor(options) {
291
+ if (!options || typeof options !== "object") {
292
+ throw new TypeError("[ABR] AdaptiveBitrateController needs { ladder, initialQuality }");
293
+ }
294
+ this.ladder = validateQualityLadder(options.ladder);
295
+ this.currentQualityIndex = options.initialQuality === void 0 ? 0 : this.ladder.findIndex((q) => q.name === options.initialQuality);
296
+ if (this.currentQualityIndex < 0) {
297
+ throw new RangeError(`[ABR] initial rendition ${String(options.initialQuality)} is not in the ladder`);
298
+ }
299
+ }
300
+ setCallback(callback) {
301
+ this.onQualityChange = callback;
302
+ }
303
+ getCurrentQuality() {
304
+ return this.ladder[this.currentQualityIndex];
305
+ }
306
+ /** Selects the multicast (S,G) tier without replacing a player's unicast ABR manager. */
307
+ selectMulticastTier(endpoints, estimate = this.getMetrics().measuredBitrate || void 0) {
308
+ return selectMulticastTier(endpoints, estimate);
309
+ }
310
+ /**
311
+ * Record network sample for bitrate adaptation
312
+ *
313
+ * @param bytesReceived - Bytes received in this sample
314
+ * @param packetsLost - Packets lost (raw, before FEC recovery)
315
+ */
316
+ recordSample(bytesReceived, packetsLost) {
317
+ const now = Date.now();
318
+ this.history.push({ timestamp: now, bytesReceived, packetsLost });
319
+ this.history = this.history.filter((s) => now - s.timestamp < this.historyWindow);
320
+ const { measuredBitrate, lossRate: rawLossRate } = this.calculateMetrics();
321
+ const currentQuality = this.getCurrentQuality();
322
+ const effectiveLossRate = this.fecStats.fecEnabled ? this.fecStats.effectiveLossRate : rawLossRate;
323
+ if (now - this.lastQualityChange < this.stabilityPeriod) {
324
+ return;
325
+ }
326
+ if (effectiveLossRate > 0.05 || measuredBitrate < currentQuality.bitrate * this.downgradeThreshold) {
327
+ this.downgrade();
328
+ return;
329
+ }
330
+ if (measuredBitrate > currentQuality.bitrate * this.upgradeThreshold && effectiveLossRate < 0.01 && this.currentQualityIndex < this.ladder.length - 1) {
331
+ this.upgrade();
332
+ }
333
+ }
334
+ /**
335
+ * Update FEC statistics for ABR decisions
336
+ *
337
+ * Per draft-ramadan-moq-fec-00, ABR should use the effective loss rate
338
+ * (after FEC recovery) rather than raw transport loss rate.
339
+ *
340
+ * @param stats - FEC statistics from the FEC decoder
341
+ */
342
+ setFecStats(stats) {
343
+ this.fecStats = stats;
344
+ }
345
+ /**
346
+ * Get current FEC statistics
347
+ */
348
+ getFecStats() {
349
+ return { ...this.fecStats };
350
+ }
351
+ calculateMetrics() {
352
+ if (this.history.length < 2) {
353
+ return { measuredBitrate: 0, lossRate: 0 };
354
+ }
355
+ const totalBytes = this.history.reduce((sum, s) => sum + s.bytesReceived, 0);
356
+ const totalLost = this.history.reduce((sum, s) => sum + s.packetsLost, 0);
357
+ const duration = (this.history[this.history.length - 1].timestamp - this.history[0].timestamp) / 1e3;
358
+ const measuredBitrate = duration > 0 ? totalBytes * 8 / duration : 0;
359
+ const lossRate = totalLost / (this.history.length + totalLost);
360
+ return { measuredBitrate, lossRate };
361
+ }
362
+ upgrade() {
363
+ if (this.currentQualityIndex >= this.ladder.length - 1)
364
+ return;
365
+ this.currentQualityIndex++;
366
+ this.lastQualityChange = Date.now();
367
+ const newQuality = this.getCurrentQuality();
368
+ console.log(`[ABR] Upgrading to ${newQuality.name} (${newQuality.bitrate / 1e6}Mbps)`);
369
+ this.onQualityChange?.(newQuality);
370
+ }
371
+ downgrade() {
372
+ if (this.currentQualityIndex <= 0)
373
+ return;
374
+ this.currentQualityIndex--;
375
+ this.lastQualityChange = Date.now();
376
+ const newQuality = this.getCurrentQuality();
377
+ console.log(`[ABR] Downgrading to ${newQuality.name} (${newQuality.bitrate / 1e6}Mbps)`);
378
+ this.onQualityChange?.(newQuality);
379
+ }
380
+ /**
381
+ * Select a ladder rendition: the caller switched to it (a manual override,
382
+ * or a switch the caller made). Throws for a name the ladder does not carry.
383
+ */
384
+ setQuality(name) {
385
+ const index = this.ladder.findIndex((q) => q.name === name);
386
+ if (index < 0)
387
+ throw new RangeError(`[ABR] rendition ${name} is not in the ladder`);
388
+ this.currentQualityIndex = index;
389
+ this.lastQualityChange = Date.now();
390
+ this.onQualityChange?.(this.getCurrentQuality());
391
+ }
392
+ /**
393
+ * Get current metrics including both raw and effective loss rates
394
+ */
395
+ getMetrics() {
396
+ const { measuredBitrate, lossRate: rawLossRate } = this.calculateMetrics();
397
+ return {
398
+ measuredBitrate,
399
+ rawLossRate,
400
+ effectiveLossRate: this.fecStats.fecEnabled ? this.fecStats.effectiveLossRate : rawLossRate,
401
+ fecEnabled: this.fecStats.fecEnabled,
402
+ sampleCount: this.history.length
403
+ };
404
+ }
405
+ /**
406
+ * Reset history and start fresh
407
+ */
408
+ reset() {
409
+ this.history = [];
410
+ this.lastQualityChange = 0;
411
+ }
412
+ };
413
+
414
+ // node_modules/@blockcast/mmt-transport/dist/multicast-orchestrator.js
415
+ var DEFAULT_DWELL_MS = 3e3;
416
+ var DEFAULT_JOIN_DEADLINE_MS = 5e3;
417
+ var MulticastOrchestrator = class {
418
+ options;
419
+ #state = "stable";
420
+ #current;
421
+ #target;
422
+ #estimate;
423
+ #favored;
424
+ #joinStartedAt = 0;
425
+ /**
426
+ * Latest active-tier send time (NTP short), or undefined before the first.
427
+ * "Latest" is serial order, not the numerically largest value: after the
428
+ * field wraps, the largest value is the stale one.
429
+ */
430
+ #highWater;
431
+ #dwellMs;
432
+ #joinDeadlineMs;
433
+ constructor(options) {
434
+ this.options = options;
435
+ this.#dwellMs = options.dwellMs ?? DEFAULT_DWELL_MS;
436
+ this.#joinDeadlineMs = options.joinDeadlineMs ?? DEFAULT_JOIN_DEADLINE_MS;
437
+ if (!Number.isFinite(this.#dwellMs) || !Number.isFinite(this.#joinDeadlineMs) || this.#dwellMs <= 0 || this.#joinDeadlineMs <= 0) {
438
+ throw new Error("Multicast dwell and join deadline must be positive");
439
+ }
440
+ }
441
+ get state() {
442
+ return this.#state;
443
+ }
444
+ get current() {
445
+ return this.#current;
446
+ }
447
+ get target() {
448
+ return this.#target;
449
+ }
450
+ get estimate() {
451
+ return this.#estimate;
452
+ }
453
+ start() {
454
+ this.#current ??= this.options.initialEndpoint ?? selectMulticastTier(this.options.endpoints, void 0);
455
+ return this.#current;
456
+ }
457
+ onGoodput(sample) {
458
+ const bitrate = sample.bitrate;
459
+ if (!this.#current)
460
+ return void 0;
461
+ if (this.#state === "joining")
462
+ return this.poll();
463
+ if (this.options.adaptive === false)
464
+ return void 0;
465
+ if (bitrate === void 0 || !Number.isFinite(bitrate))
466
+ return void 0;
467
+ this.#estimate = bitrate;
468
+ const desired = selectMulticastTier(this.options.endpoints, bitrate);
469
+ if (!desired)
470
+ return void 0;
471
+ const desiredKey = endpointKey(desired);
472
+ if (desiredKey === endpointKey(this.#current)) {
473
+ if (this.#favored?.source === "goodput")
474
+ this.#favored = void 0;
475
+ return void 0;
476
+ }
477
+ if (typeof desired.bandwidth !== "number" || typeof this.#current.bandwidth !== "number" || desired.bandwidth >= this.#current.bandwidth) {
478
+ if (this.#favored?.source === "goodput")
479
+ this.#favored = void 0;
480
+ return void 0;
481
+ }
482
+ const now = this.#now();
483
+ if (!this.#favored || this.#favored.key !== desiredKey || this.#favored.source !== "goodput") {
484
+ this.#favored = { key: desiredKey, since: now, source: "goodput" };
485
+ return void 0;
486
+ }
487
+ if (now - this.#favored.since < this.#dwellMs)
488
+ return void 0;
489
+ this.#state = "joining";
490
+ this.#target = desired;
491
+ this.#joinStartedAt = now;
492
+ this.#favored = void 0;
493
+ return { kind: "join-target", current: this.#current, target: desired };
494
+ }
495
+ onHeadroom(sample) {
496
+ if (!this.#current || this.options.adaptive === false || this.#state === "joining")
497
+ return void 0;
498
+ if (!sample.healthy) {
499
+ if (this.#favored?.source === "headroom")
500
+ this.#favored = void 0;
501
+ return void 0;
502
+ }
503
+ if (this.#favored?.source === "goodput")
504
+ return void 0;
505
+ const currentBandwidth = this.#current.bandwidth;
506
+ if (typeof currentBandwidth !== "number")
507
+ return void 0;
508
+ const desired = this.options.endpoints.filter((endpoint) => carriesMedia(endpoint) && typeof endpoint.bandwidth === "number" && endpoint.bandwidth > currentBandwidth).sort((a, b) => a.bandwidth - b.bandwidth)[0];
509
+ if (!desired) {
510
+ this.#favored = void 0;
511
+ return void 0;
512
+ }
513
+ const desiredKey = endpointKey(desired);
514
+ if (desiredKey === endpointKey(this.#current)) {
515
+ this.#favored = void 0;
516
+ return void 0;
517
+ }
518
+ const now = this.#now();
519
+ if (!this.#favored || this.#favored.key !== desiredKey) {
520
+ this.#favored = { key: desiredKey, since: now, source: "headroom" };
521
+ return void 0;
522
+ }
523
+ if (now - this.#favored.since < this.#dwellMs)
524
+ return void 0;
525
+ this.#state = "joining";
526
+ this.#target = desired;
527
+ this.#joinStartedAt = now;
528
+ this.#favored = void 0;
529
+ return { kind: "join-target", current: this.#current, target: desired };
530
+ }
531
+ /**
532
+ * Join `target` because the viewer selected it, not because goodput or
533
+ * headroom ranked it. It runs whether or not the orchestrator adapts, and
534
+ * takes the path an adaptive join takes: commit on the target's RAP at or
535
+ * beyond the high-water mark, abandon at the join deadline. While it is
536
+ * pending nothing re-ranks the ladder; goodput only advances the deadline.
537
+ *
538
+ * Returns undefined, changing nothing, while another join is pending (cancel
539
+ * it first), when `target` is the current tier, or when it carries no media.
540
+ */
541
+ select(target) {
542
+ if (!this.#current || this.#state === "joining" || !carriesMedia(target))
543
+ return void 0;
544
+ if (endpointKey(target) === endpointKey(this.#current))
545
+ return void 0;
546
+ this.#state = "joining";
547
+ this.#target = target;
548
+ this.#joinStartedAt = this.#now();
549
+ this.#favored = void 0;
550
+ return { kind: "join-target", current: this.#current, target };
551
+ }
552
+ /**
553
+ * Feed a packet from the active tier (to advance the high-water mark) or
554
+ * from the in-flight target (to find a committable RAP).
555
+ *
556
+ * Serial order is only the true order while the compared instants are less
557
+ * than `NTP_SHORT_HALF_RANGE` (2^15 s, ~9.1 h) apart. Feeding every
558
+ * active-tier packet keeps the mark that close to the live stream. A mark
559
+ * refreshed only by commits can fall further behind than that, and a
560
+ * target RAP may then compare as older, so the join is abandoned.
561
+ */
562
+ onTierPacket(packet) {
563
+ if (!this.#current)
564
+ return void 0;
565
+ const sentAt = tierPacketSendTime(packet);
566
+ if (packet.endpointKey === endpointKey(this.#current) && sentAt !== void 0 && (this.#highWater === void 0 || compareNtpShort(sentAt, this.#highWater) === "after")) {
567
+ this.#highWater = sentAt;
568
+ }
569
+ if (this.#state !== "joining" || !this.#target)
570
+ return void 0;
571
+ const expired = this.poll();
572
+ if (expired)
573
+ return expired;
574
+ if (packet.endpointKey !== endpointKey(this.#target) || !packet.keyframe || !packet.hasValidCodecConfig || sentAt === void 0 || !this.#reachesHighWater(sentAt))
575
+ return void 0;
576
+ const command = {
577
+ kind: "commit-swap",
578
+ target: this.#target,
579
+ old: this.#current
580
+ };
581
+ this.#highWater = sentAt;
582
+ this.#current = this.#target;
583
+ this.#target = void 0;
584
+ this.#state = "stable";
585
+ return command;
586
+ }
587
+ poll() {
588
+ if (this.#state !== "joining" || !this.#target || !this.#current)
589
+ return void 0;
590
+ if (this.#now() - this.#joinStartedAt < this.#joinDeadlineMs)
591
+ return void 0;
592
+ return this.cancel();
593
+ }
594
+ cancel() {
595
+ if (this.#state !== "joining" || !this.#target || !this.#current)
596
+ return void 0;
597
+ const command = {
598
+ kind: "abandon-join",
599
+ current: this.#current,
600
+ target: this.#target
601
+ };
602
+ this.#target = void 0;
603
+ this.#state = "stable";
604
+ return command;
605
+ }
606
+ /**
607
+ * Whether a target RAP sent at `sentAt` is at or beyond the active tier's
608
+ * high-water mark. A pair exactly half the NTP-short space apart has no
609
+ * serial order, so it cannot show that and does not commit.
610
+ */
611
+ #reachesHighWater(sentAt) {
612
+ if (this.#highWater === void 0)
613
+ return true;
614
+ const order = compareNtpShort(sentAt, this.#highWater);
615
+ return order === "after" || order === "equal";
616
+ }
617
+ #now() {
618
+ const now = this.options.now();
619
+ if (!Number.isFinite(now))
620
+ throw new Error("Multicast orchestrator clock must be finite");
621
+ return now;
622
+ }
623
+ };
624
+ function tierPacketSendTime(packet) {
625
+ if (!Number.isFinite(packet.timestamp))
626
+ return void 0;
627
+ if (!isNtpShort(packet.timestamp)) {
628
+ throw new RangeError(`Multicast tier packet timestamp must be an MMTP NTP-short send time, got ${packet.timestamp}`);
629
+ }
630
+ return packet.timestamp;
631
+ }
632
+
633
+ // node_modules/@blockcast/mmt-transport/dist/endpoint-config.js
634
+ function toWindowMulticastSubscribeConfig(input) {
635
+ if (input.mode !== void 0 && !["auto", "native", "tunnel"].includes(input.mode)) {
636
+ throw new TypeError(`Unsupported multicast mode: ${String(input.mode)}`);
637
+ }
638
+ if (input.packetIds !== void 0 && !Array.isArray(input.packetIds)) {
639
+ throw new TypeError(`multicast packetIds must be an array, got ${input.packetIds === null ? "null" : typeof input.packetIds}`);
640
+ }
641
+ if (input.packetIds?.some((id) => !isMulticastTrackPacketId(id)) || input.tracks?.some((track) => !isMulticastTrackPacketId(track.packetId))) {
642
+ throw new RangeError(`multicast packetId must be an integer from 1 to ${MMTP_PACKET_ID_MAX}; packetId 0 is the MMTP signaling flow and is never a track's`);
643
+ }
644
+ const base = {
645
+ group: input.group,
646
+ port: input.port,
647
+ ...input.source?.trim() ? { source: input.source.trim() } : {},
648
+ consume: "bytes",
649
+ ...input.packetIds?.length ? { packetIds: [...input.packetIds] } : {}
650
+ };
651
+ const relay = input.amtRelay?.trim();
652
+ const wantsAmt = input.mode === "tunnel" || input.mode !== "native" && relay !== void 0 && relay !== "";
653
+ if (!wantsAmt) {
654
+ const native = {
655
+ ...base,
656
+ origin: "ip-multicast",
657
+ ...input.tracks?.length ? { tracks: input.tracks.map(({ name, packetId }) => ({ name, packetId })) } : {}
658
+ };
659
+ return native;
660
+ }
661
+ const relayPort = input.amtRelayPort;
662
+ if (!relay || relayPort === void 0 || !isPositivePort(relayPort)) {
663
+ throw new TypeError("AMT requires a resolved relay and a valid relay port");
664
+ }
665
+ return {
666
+ ...base,
667
+ origin: "amt",
668
+ relay,
669
+ relayPort
670
+ };
671
+ }
672
+ function isValidMulticastGroupAddress(address) {
673
+ const value = address?.trim().toLowerCase();
674
+ if (!value)
675
+ return false;
676
+ if (value.startsWith("ff"))
677
+ return isValidIpv6MulticastAddress(value);
678
+ const parts = value.split(".");
679
+ if (parts.length !== 4)
680
+ return false;
681
+ const octets = parts.map((part) => {
682
+ if (!/^\d+$/.test(part))
683
+ return Number.NaN;
684
+ const octet = Number(part);
685
+ return Number.isInteger(octet) && octet >= 0 && octet <= 255 ? octet : Number.NaN;
686
+ });
687
+ return octets.every(Number.isInteger) && octets[0] >= 224 && octets[0] <= 239;
688
+ }
689
+ function normalizeMulticastEndpoint(endpoint) {
690
+ const groupAddress = endpoint.groupAddress.trim().toLowerCase();
691
+ const sourceAddress = endpoint.sourceAddress?.trim().toLowerCase() || void 0;
692
+ const amtRelay = endpoint.amtRelay?.trim().toLowerCase() || void 0;
693
+ if (!isValidMulticastGroupAddress(groupAddress) || !isPositivePort(endpoint.port))
694
+ return void 0;
695
+ if (endpoint.mode && !["auto", "native", "tunnel"].includes(endpoint.mode))
696
+ return void 0;
697
+ if (endpoint.amtRelayPort !== void 0 && !isPositivePort(endpoint.amtRelayPort))
698
+ return void 0;
699
+ return {
700
+ groupAddress,
701
+ ...sourceAddress ? { sourceAddress } : {},
702
+ port: endpoint.port,
703
+ ...endpoint.mode ? { mode: endpoint.mode } : {},
704
+ ...amtRelay ? { amtRelay } : {},
705
+ ...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
706
+ };
707
+ }
708
+ function multicastEndpointKey(endpoint) {
709
+ const normalized = normalizeMulticastEndpoint(endpoint);
710
+ if (!normalized)
711
+ throw new Error("Invalid multicast endpoint");
712
+ return JSON.stringify([
713
+ normalized.sourceAddress ?? "",
714
+ normalized.groupAddress,
715
+ normalized.port,
716
+ normalized.mode ?? "auto",
717
+ normalized.amtRelay ?? "",
718
+ normalized.amtRelayPort ?? ""
719
+ ]);
720
+ }
721
+ function isMulticastTrackPacketId(value) {
722
+ return Number.isInteger(value) && value > MMTP_SIGNALING_PACKET_ID && value <= MMTP_PACKET_ID_MAX;
723
+ }
724
+ function isValidIpv6MulticastAddress(value) {
725
+ if (!/^[0-9a-f:]+$/.test(value))
726
+ return false;
727
+ const compressed = value.includes("::");
728
+ if (value.indexOf("::") !== value.lastIndexOf("::"))
729
+ return false;
730
+ const groups = value.split(":").filter(Boolean);
731
+ if (groups.length === 0 || groups.length > 8)
732
+ return false;
733
+ if (!compressed && groups.length !== 8)
734
+ return false;
735
+ return groups.every((group) => /^[0-9a-f]{1,4}$/.test(group));
736
+ }
737
+ function isPositivePort(port2) {
738
+ return Number.isInteger(port2) && port2 > 0 && port2 <= 65535;
739
+ }
740
+
741
+ // node_modules/@blockcast/mmt-transport/dist/packet-batch.js
742
+ function subscriptionDeliversPacketBatches(subscription) {
743
+ return subscription.eventTypes?.includes("packets") === true;
744
+ }
745
+
746
+ // node_modules/@blockcast/mmt-transport/dist/multicast-subscription-pool.js
747
+ var MulticastSubscriptionPool = class {
748
+ #entries = /* @__PURE__ */ new Map();
749
+ #gatewayIds = /* @__PURE__ */ new WeakMap();
750
+ #nextGatewayId = 1;
751
+ async acquire(gateway, config, consumer) {
752
+ const endpoint = normalizeMulticastEndpoint({
753
+ groupAddress: config.group,
754
+ sourceAddress: config.source,
755
+ port: config.port,
756
+ mode: config.mode,
757
+ amtRelay: config.amtRelay,
758
+ amtRelayPort: config.amtRelayPort
759
+ });
760
+ if (!endpoint)
761
+ throw new Error("Invalid multicast endpoint");
762
+ if (typeof gateway.subscribe !== "function")
763
+ throw new Error("window.multicast.subscribe unavailable");
764
+ const key = multicastEndpointKey(endpoint);
765
+ const internalKey = `${this.#gatewayId(gateway)}|${key}`;
766
+ let record = this.#entries.get(internalKey);
767
+ if (!record) {
768
+ record = { claims: 0, entry: Promise.resolve(null) };
769
+ const createdRecord = record;
770
+ record.entry = this.#createEntry(gateway, endpoint, (entry2) => {
771
+ if (this.#entries.get(internalKey) === createdRecord)
772
+ this.#entries.delete(internalKey);
773
+ this.#detach(entry2);
774
+ }).catch((error) => {
775
+ if (this.#entries.get(internalKey) === createdRecord)
776
+ this.#entries.delete(internalKey);
777
+ throw error;
778
+ });
779
+ this.#entries.set(internalKey, record);
780
+ }
781
+ record.claims++;
782
+ let entry;
783
+ try {
784
+ entry = await record.entry;
785
+ } catch (error) {
786
+ record.claims--;
787
+ throw error;
788
+ }
789
+ if (entry.closed) {
790
+ record.claims--;
791
+ return this.acquire(gateway, config, consumer);
792
+ }
793
+ const token = Symbol(key);
794
+ entry.consumers.set(token, consumer);
795
+ let released = false;
796
+ return {
797
+ key,
798
+ release: async () => {
799
+ if (released)
800
+ return;
801
+ released = true;
802
+ entry.consumers.delete(token);
803
+ record.claims--;
804
+ if (record.claims > 0)
805
+ return;
806
+ if (this.#entries.get(internalKey) === record)
807
+ this.#entries.delete(internalKey);
808
+ this.#detach(entry);
809
+ if (!entry.closed)
810
+ await entry.subscription.unsubscribe();
811
+ }
812
+ };
813
+ }
814
+ get size() {
815
+ return this.#entries.size;
816
+ }
817
+ async #createEntry(gateway, endpoint, onClosed) {
818
+ const subscription = await gateway.subscribe(toWindowMulticastSubscribeConfig({
819
+ group: endpoint.groupAddress,
820
+ ...endpoint.sourceAddress ? { source: endpoint.sourceAddress } : {},
821
+ port: endpoint.port,
822
+ ...endpoint.mode ? { mode: endpoint.mode } : {},
823
+ ...endpoint.amtRelay ? { amtRelay: endpoint.amtRelay } : {},
824
+ ...endpoint.amtRelayPort ? { amtRelayPort: endpoint.amtRelayPort } : {}
825
+ }));
826
+ const consumers = /* @__PURE__ */ new Map();
827
+ let entry;
828
+ const packetListener = subscriptionDeliversPacketBatches(subscription) ? {
829
+ type: "packets",
830
+ listener: (event) => {
831
+ for (const data of event.detail) {
832
+ this.#dispatch(consumers, (consumer) => consumer.onBytes(data));
833
+ }
834
+ }
835
+ } : {
836
+ type: "bytes",
837
+ listener: (event) => {
838
+ this.#dispatch(consumers, (consumer) => consumer.onBytes(event.detail));
839
+ }
840
+ };
841
+ const stateListener = (event) => {
842
+ this.#dispatch(consumers, (consumer) => consumer.onState?.(event.detail));
843
+ if (event.detail === "closed" && !entry.closed) {
844
+ entry.closed = true;
845
+ onClosed(entry);
846
+ }
847
+ };
848
+ const errorListener = (event) => {
849
+ const error = event.detail instanceof Error ? event.detail : new Error(String(event.detail));
850
+ this.#dispatch(consumers, (consumer) => consumer.onError?.(error));
851
+ };
852
+ entry = { subscription, consumers, packetListener, stateListener, errorListener, closed: false };
853
+ if (packetListener.type === "packets") {
854
+ subscription.addEventListener("packets", packetListener.listener);
855
+ } else {
856
+ subscription.addEventListener("bytes", packetListener.listener);
857
+ }
858
+ subscription.addEventListener("state", stateListener);
859
+ subscription.addEventListener("error", errorListener);
860
+ return entry;
861
+ }
862
+ #gatewayId(gateway) {
863
+ const object2 = gateway;
864
+ let id = this.#gatewayIds.get(object2);
865
+ if (!id) {
866
+ id = this.#nextGatewayId++;
867
+ this.#gatewayIds.set(object2, id);
868
+ }
869
+ return id;
870
+ }
871
+ #detach(entry) {
872
+ const { packetListener } = entry;
873
+ if (packetListener.type === "packets") {
874
+ entry.subscription.removeEventListener("packets", packetListener.listener);
875
+ } else {
876
+ entry.subscription.removeEventListener("bytes", packetListener.listener);
877
+ }
878
+ entry.subscription.removeEventListener("state", entry.stateListener);
879
+ entry.subscription.removeEventListener("error", entry.errorListener);
880
+ }
881
+ #dispatch(consumers, callback) {
882
+ for (const consumer of consumers.values()) {
883
+ try {
884
+ callback(consumer);
885
+ } catch (error) {
886
+ console.error("[Transport] multicast consumer callback failed", error);
887
+ }
888
+ }
889
+ }
890
+ };
891
+ var multicastSubscriptionPool = new MulticastSubscriptionPool();
892
+
893
+ // node_modules/@blockcast/mmt-transport/dist/transport-manager.js
894
+ var TransportManager = class {
895
+ state = {
896
+ mode: "disconnected",
897
+ connected: false,
898
+ packetsReceived: 0,
899
+ bytesReceived: 0,
900
+ lastPacketTime: 0
901
+ };
902
+ capabilities = null;
903
+ subscription = null;
904
+ driad = new DRIADDiscovery();
905
+ /** Built by `connect()` from the caller's ladder; there is no built-in one. */
906
+ abr = null;
907
+ multicastOrchestrator = null;
908
+ onOrchestratorCommand;
909
+ connectionGeneration = 0;
910
+ onPacket;
911
+ onError;
912
+ onStateChange;
913
+ getWindow() {
914
+ return typeof window === "undefined" ? void 0 : window;
915
+ }
916
+ getWindowMulticastGateway() {
917
+ return this.getWindow()?.multicast;
918
+ }
919
+ async getGatewayCapabilities(gateway) {
920
+ if (!gateway?.capabilities)
921
+ return void 0;
922
+ try {
923
+ return typeof gateway.capabilities === "function" ? await gateway.capabilities() : gateway.capabilities;
924
+ } catch (error) {
925
+ console.warn("[Transport] window.multicast capabilities failed:", error);
926
+ return void 0;
927
+ }
928
+ }
929
+ async gatewaySupportsBytes(gateway) {
930
+ if (typeof gateway?.subscribe !== "function")
931
+ return false;
932
+ if (!gateway.capabilities)
933
+ return true;
934
+ const capabilities = await this.getGatewayCapabilities(gateway);
935
+ if (!capabilities)
936
+ return false;
937
+ const consumeModes = capabilities.consumeModes;
938
+ return !consumeModes || consumeModes.includes("bytes");
939
+ }
940
+ /**
941
+ * Detect available transport capabilities
942
+ */
943
+ async detectCapabilities() {
944
+ if (this.capabilities)
945
+ return this.capabilities;
946
+ const gateway = this.getWindowMulticastGateway();
947
+ const hasGatewayBytes = await this.gatewaySupportsBytes(gateway);
948
+ const win = this.getWindow();
949
+ this.capabilities = {
950
+ nativeSSM: hasGatewayBytes,
951
+ nativeIGMP: hasGatewayBytes,
952
+ directSockets: typeof win?.UDPSocket !== "undefined",
953
+ amt: false,
954
+ driad: true,
955
+ // DRIAD uses HTTP proxy, always available
956
+ fecDecode: false
957
+ };
958
+ console.log("[Transport] Capabilities:", this.capabilities);
959
+ return this.capabilities;
960
+ }
961
+ /**
962
+ * Connect using best available transport
963
+ *
964
+ * Promotion hierarchy:
965
+ * 1. window.multicast gateway bytes
966
+ * 2. AMT proxy (specified or discovered via DRIAD)
967
+ * 3. MOQ WebTransport (final fallback)
968
+ *
969
+ * The ABR ladder (`abrLadder`) and initial rendition (`initialQuality`)
970
+ * are checked first, before anything is torn down. A config that fails is
971
+ * refused with the same shape as an invalid endpoint, the error to the
972
+ * error callback and `false` resolved; unlike one, it is caught before the
973
+ * live subscription closes, so a refused reconnect leaves that subscription,
974
+ * its state and any connect already in flight untouched.
975
+ */
976
+ async connect(config) {
977
+ let abr;
978
+ try {
979
+ abr = new AdaptiveBitrateController({
980
+ ladder: config.abrLadder,
981
+ initialQuality: config.initialQuality?.name
982
+ });
983
+ } catch (error) {
984
+ const refused = error instanceof Error ? error : new Error(String(error));
985
+ if (this.onError)
986
+ this.onError(refused);
987
+ else
988
+ console.error("[Transport] ABR config refused, not connecting:", refused);
989
+ return false;
990
+ }
991
+ const generation = ++this.connectionGeneration;
992
+ this.subscription?.close();
993
+ this.subscription = null;
994
+ this.abr = null;
995
+ this.state = {
996
+ mode: "disconnected",
997
+ connected: false,
998
+ packetsReceived: 0,
999
+ bytesReceived: 0,
1000
+ lastPacketTime: 0
1001
+ };
1002
+ this.onStateChange?.(this.state);
1003
+ const endpoint = normalizeMulticastEndpoint({
1004
+ groupAddress: config.group,
1005
+ sourceAddress: config.source,
1006
+ port: config.port,
1007
+ mode: config.mode,
1008
+ amtRelay: config.amtRelay,
1009
+ amtRelayPort: config.amtRelayPort
1010
+ });
1011
+ if (!endpoint) {
1012
+ const error = new Error("Invalid multicast endpoint configuration");
1013
+ this.onError?.(error);
1014
+ return false;
1015
+ }
1016
+ config = {
1017
+ ...config,
1018
+ group: endpoint.groupAddress,
1019
+ source: endpoint.sourceAddress ?? "",
1020
+ mode: endpoint.mode,
1021
+ amtRelay: endpoint.amtRelay,
1022
+ amtRelayPort: endpoint.amtRelayPort
1023
+ };
1024
+ const caps = await this.detectCapabilities();
1025
+ if (generation !== this.connectionGeneration)
1026
+ return false;
1027
+ this.abr = abr;
1028
+ abr.setCallback((quality) => {
1029
+ this.state.quality = quality;
1030
+ this.subscription?.onqualitychange?.(quality);
1031
+ this.onStateChange?.(this.state);
1032
+ });
1033
+ let connected = false;
1034
+ if (caps.nativeSSM || caps.nativeIGMP) {
1035
+ console.log("[Transport] Attempting window.multicast...");
1036
+ connected = await this.connectWindowMulticast(config, generation);
1037
+ if (connected) {
1038
+ if (generation !== this.connectionGeneration)
1039
+ return false;
1040
+ this.state.mode = "multicast";
1041
+ return true;
1042
+ }
1043
+ }
1044
+ if (!connected) {
1045
+ console.log("[Transport] Attempting AMT tunnel...");
1046
+ connected = await this.connectAmt(config, generation);
1047
+ if (connected) {
1048
+ if (generation !== this.connectionGeneration)
1049
+ return false;
1050
+ this.state.mode = "amt";
1051
+ return true;
1052
+ }
1053
+ }
1054
+ console.log("[Transport] All multicast transports failed, falling back to MOQ");
1055
+ return false;
1056
+ }
1057
+ /**
1058
+ * Connect via the lowercase window.multicast bytes gateway.
1059
+ */
1060
+ async connectWindowMulticast(config, generation) {
1061
+ try {
1062
+ const gateway = this.getWindowMulticastGateway();
1063
+ if (typeof gateway?.subscribe !== "function")
1064
+ return false;
1065
+ const lease = await multicastSubscriptionPool.acquire(gateway, config, {
1066
+ onBytes: (data) => {
1067
+ if (generation === this.connectionGeneration)
1068
+ this.handlePacket(data);
1069
+ },
1070
+ onState: (state) => {
1071
+ if (generation !== this.connectionGeneration)
1072
+ return;
1073
+ this.state.connected = state !== "closed";
1074
+ this.onStateChange?.(this.state);
1075
+ },
1076
+ onError: (error) => {
1077
+ if (generation !== this.connectionGeneration)
1078
+ return;
1079
+ console.error("[Transport] window.multicast error:", error);
1080
+ this.onError?.(error);
1081
+ }
1082
+ });
1083
+ if (generation !== this.connectionGeneration) {
1084
+ await lease.release();
1085
+ return false;
1086
+ }
1087
+ this.subscription = {
1088
+ id: lease.key,
1089
+ config,
1090
+ close: () => {
1091
+ void lease.release();
1092
+ }
1093
+ };
1094
+ this.state = {
1095
+ mode: "multicast",
1096
+ connected: true,
1097
+ group: config.group,
1098
+ source: config.source,
1099
+ quality: this.requireAbr().getCurrentQuality(),
1100
+ packetsReceived: 0,
1101
+ bytesReceived: 0,
1102
+ lastPacketTime: 0
1103
+ };
1104
+ console.log(`[Transport] Connected via window.multicast: (${config.source}, ${config.group})`);
1105
+ this.onStateChange?.(this.state);
1106
+ return true;
1107
+ } catch (error) {
1108
+ console.warn("[Transport] window.multicast failed:", error);
1109
+ return false;
1110
+ }
1111
+ }
1112
+ /**
1113
+ * Connect via AMT proxy (with optional DRIAD discovery)
1114
+ */
1115
+ async connectAmt(config, generation) {
1116
+ try {
1117
+ let amtRelay = config.amtRelay;
1118
+ if (!amtRelay && config.driadEnabled !== false && config.source) {
1119
+ console.log(`[Transport] Discovering AMT relay via DRIAD for source ${config.source}...`);
1120
+ const relays = await this.driad.discoverRelays(config.source);
1121
+ if (generation !== this.connectionGeneration)
1122
+ return false;
1123
+ const bestRelay = await this.driad.selectBestRelay(relays);
1124
+ if (generation !== this.connectionGeneration)
1125
+ return false;
1126
+ if (bestRelay) {
1127
+ amtRelay = bestRelay.host;
1128
+ this.state.amtRelay = amtRelay;
1129
+ }
1130
+ }
1131
+ if (!amtRelay) {
1132
+ console.warn("[Transport] No AMT relay available (DRIAD requires source address for SSM)");
1133
+ return false;
1134
+ }
1135
+ return await this.connectAmtProxy(config, amtRelay, generation);
1136
+ } catch (error) {
1137
+ console.warn("[Transport] AMT connection failed:", error);
1138
+ return false;
1139
+ }
1140
+ }
1141
+ /**
1142
+ * Connect via WebSocket-based AMT proxy (browser fallback)
1143
+ */
1144
+ async connectAmtProxy(config, amtRelay, generation) {
1145
+ try {
1146
+ const relayHost = amtRelay.includes(":") && !amtRelay.startsWith("[") ? `[${amtRelay}]` : amtRelay;
1147
+ const wsUrl = new URL(`wss://${relayHost}/amt-proxy`);
1148
+ wsUrl.searchParams.set("group", config.group);
1149
+ wsUrl.searchParams.set("source", config.source || "");
1150
+ wsUrl.searchParams.set("port", String(config.port));
1151
+ const ws = new WebSocket(wsUrl);
1152
+ return new Promise((resolve, reject) => {
1153
+ ws.binaryType = "arraybuffer";
1154
+ const timeout = setTimeout(() => {
1155
+ ws.close();
1156
+ reject(new Error("AMT proxy connection timeout"));
1157
+ }, 1e4);
1158
+ ws.onopen = () => {
1159
+ clearTimeout(timeout);
1160
+ if (generation !== this.connectionGeneration) {
1161
+ ws.close();
1162
+ resolve(false);
1163
+ return;
1164
+ }
1165
+ console.log(`[Transport] Connected to AMT proxy: ${amtRelay}`);
1166
+ this.subscription = {
1167
+ id: `amt-proxy-${Date.now()}`,
1168
+ config,
1169
+ close: () => ws.close()
1170
+ };
1171
+ this.state = {
1172
+ mode: "amt",
1173
+ connected: true,
1174
+ group: config.group,
1175
+ source: config.source,
1176
+ amtRelay,
1177
+ quality: this.requireAbr().getCurrentQuality(),
1178
+ packetsReceived: 0,
1179
+ bytesReceived: 0,
1180
+ lastPacketTime: 0
1181
+ };
1182
+ this.onStateChange?.(this.state);
1183
+ resolve(true);
1184
+ };
1185
+ ws.onmessage = (event) => {
1186
+ if (generation === this.connectionGeneration && event.data instanceof ArrayBuffer) {
1187
+ this.handlePacket(event.data);
1188
+ }
1189
+ };
1190
+ ws.onerror = (error) => {
1191
+ clearTimeout(timeout);
1192
+ if (generation !== this.connectionGeneration) {
1193
+ resolve(false);
1194
+ return;
1195
+ }
1196
+ console.error("[Transport] AMT proxy error:", error);
1197
+ reject(error);
1198
+ };
1199
+ ws.onclose = () => {
1200
+ clearTimeout(timeout);
1201
+ if (generation !== this.connectionGeneration) {
1202
+ resolve(false);
1203
+ return;
1204
+ }
1205
+ this.state.connected = false;
1206
+ this.onStateChange?.(this.state);
1207
+ resolve(false);
1208
+ };
1209
+ });
1210
+ } catch (error) {
1211
+ console.warn("[Transport] AMT proxy failed:", error);
1212
+ return false;
1213
+ }
1214
+ }
1215
+ /**
1216
+ * Handle received packet
1217
+ */
1218
+ handlePacket(data) {
1219
+ this.state.packetsReceived++;
1220
+ this.state.bytesReceived += data.byteLength;
1221
+ this.state.lastPacketTime = Date.now();
1222
+ this.abr?.recordSample(data.byteLength, 0);
1223
+ this.onPacket?.(data);
1224
+ }
1225
+ /**
1226
+ * Get current transport state
1227
+ */
1228
+ getState() {
1229
+ return { ...this.state };
1230
+ }
1231
+ /**
1232
+ * The rung of the live connection's `abrLadder` ABR is on; `null` when
1233
+ * there is no ladder (before `connect(config)` succeeds, after
1234
+ * `disconnect()`, or after a reconnect that was torn down and bailed).
1235
+ */
1236
+ getQuality() {
1237
+ return this.abr?.getCurrentQuality() ?? null;
1238
+ }
1239
+ /**
1240
+ * Force the rung named `name` of the live connection's `abrLadder`.
1241
+ * Throws `Error` when there is no ladder (see `getQuality()`), and
1242
+ * `RangeError` when the ladder has no rung of that name; it never falls
1243
+ * back to another rung.
1244
+ */
1245
+ setQuality(name) {
1246
+ this.requireAbr().setQuality(name);
1247
+ }
1248
+ /** The controller `connect()` built; before it there is no ladder to adapt over. */
1249
+ requireAbr() {
1250
+ if (!this.abr)
1251
+ throw new Error("[Transport] ABR has no ladder before connect(config)");
1252
+ return this.abr;
1253
+ }
1254
+ /** Configures multicast-only ABR while leaving the caller's MoQ ABR untouched. */
1255
+ configureMulticastTiers(options, onCommand) {
1256
+ this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
1257
+ this.multicastOrchestrator = new MulticastOrchestrator(options);
1258
+ this.onOrchestratorCommand = onCommand;
1259
+ return this.multicastOrchestrator.start();
1260
+ }
1261
+ recordMulticastGoodput(bitrate) {
1262
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.onGoodput({ bitrate }));
1263
+ }
1264
+ recordMulticastHeadroom(healthy) {
1265
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.onHeadroom({ healthy }));
1266
+ }
1267
+ recordMulticastTierPacket(packet) {
1268
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.onTierPacket(packet));
1269
+ }
1270
+ pollMulticastTierSwitch() {
1271
+ return this.dispatchOrchestratorCommand(this.multicastOrchestrator?.poll());
1272
+ }
1273
+ /**
1274
+ * Set packet callback
1275
+ */
1276
+ setPacketCallback(callback) {
1277
+ this.onPacket = callback;
1278
+ }
1279
+ /**
1280
+ * Set error callback
1281
+ */
1282
+ setErrorCallback(callback) {
1283
+ this.onError = callback;
1284
+ }
1285
+ /**
1286
+ * Set state change callback
1287
+ */
1288
+ setStateCallback(callback) {
1289
+ this.onStateChange = callback;
1290
+ }
1291
+ /**
1292
+ * Disconnect
1293
+ */
1294
+ disconnect() {
1295
+ this.connectionGeneration++;
1296
+ this.subscription?.close();
1297
+ this.subscription = null;
1298
+ this.abr = null;
1299
+ this.dispatchOrchestratorCommand(this.multicastOrchestrator?.cancel());
1300
+ this.multicastOrchestrator = null;
1301
+ this.onOrchestratorCommand = void 0;
1302
+ this.state = {
1303
+ mode: "disconnected",
1304
+ connected: false,
1305
+ packetsReceived: 0,
1306
+ bytesReceived: 0,
1307
+ lastPacketTime: 0
1308
+ };
1309
+ this.onStateChange?.(this.state);
1310
+ }
1311
+ dispatchOrchestratorCommand(command) {
1312
+ if (command)
1313
+ this.onOrchestratorCommand?.(command);
1314
+ return command;
1315
+ }
1316
+ };
1317
+ var transportManager = new TransportManager();
1318
+
1319
+ // node_modules/@blockcast/mmt-transport/dist/moqt-priority.js
1320
+ var MAX_MOQT_PRIORITY = 255;
1321
+ function moqtPriority(value, field) {
1322
+ if (!Number.isInteger(value) || value < 0 || value > MAX_MOQT_PRIORITY) {
1323
+ throw new RangeError(`${field} must be an integer in [0, ${MAX_MOQT_PRIORITY}], got ${value}`);
1324
+ }
1325
+ return value;
1326
+ }
1327
+ function moqtSubscriberPriority(value) {
1328
+ return moqtPriority(value, "MOQT subscriber priority");
1329
+ }
1330
+ function moqtPublisherPriority(value) {
1331
+ return moqtPriority(value, "MOQT publisher priority");
1332
+ }
1333
+ var MOQT_SUBSCRIBER_PRIORITY = Object.freeze({
1334
+ catalog: moqtSubscriberPriority(0),
1335
+ /**
1336
+ * @deprecated A repair FETCH's SUBSCRIBER_PRIORITY is derived per request
1337
+ * from the catalog source and repair priorities (draft-ramadan-moq-fec
1338
+ * §11.4.5), not a player constant. Use the `subscriberPriority` that
1339
+ * `@blockcast/mmt-container`'s `wireRepairFetch` puts on each
1340
+ * `RepairFetchRequest` (`repairFetchSubscriberPriority`).
1341
+ */
1342
+ deadlineRepair: moqtSubscriberPriority(0),
1343
+ audio: moqtSubscriberPriority(1),
1344
+ video: moqtSubscriberPriority(2),
1345
+ /**
1346
+ * @deprecated See `deadlineRepair`: use the request's catalog-derived
1347
+ * `RepairFetchRequest.subscriberPriority` (draft-ramadan-moq-fec §11.4.5).
1348
+ */
1349
+ backgroundRepair: moqtSubscriberPriority(3)
1350
+ });
1351
+ var MOQT_PUBLISHER_PRIORITY = Object.freeze({
1352
+ catalog: moqtPublisherPriority(32),
1353
+ source: moqtPublisherPriority(128),
1354
+ repair: moqtPublisherPriority(240)
1355
+ });
1356
+
1357
+ // node_modules/@blockcast/mmt-transport/dist/amt-gateway.js
1358
+ var AMTGatewayManager = class {
1359
+ subscriptions = /* @__PURE__ */ new Map();
1360
+ messageHandler;
1361
+ pendingPackets = /* @__PURE__ */ new Map();
1362
+ driad = new DRIADDiscovery();
1363
+ constructor() {
1364
+ this.messageHandler = (event) => {
1365
+ const data = event.data;
1366
+ console.log(`[AMT] SW message received:`, data.type);
1367
+ if (data.type === "UDP_PACKET") {
1368
+ this.handlePacket(data);
1369
+ } else if (data.type === "SOCKET_ERROR") {
1370
+ this.handleSocketError(data);
1371
+ } else if (data.type === "DEBUG_LOG") {
1372
+ console.log(`[AMT SW Debug] ${data.message}`);
1373
+ }
1374
+ };
1375
+ if (typeof navigator !== "undefined" && navigator.serviceWorker) {
1376
+ navigator.serviceWorker.addEventListener("message", this.messageHandler);
1377
+ console.log("[AMT] Registered service worker message handler");
1378
+ } else {
1379
+ console.warn("[AMT] Service worker not available");
1380
+ }
1381
+ }
1382
+ /**
1383
+ * Subscribe via AMT tunnel
1384
+ */
1385
+ async subscribe(config) {
1386
+ const { key } = config;
1387
+ const keyStr = this.getKeyString(key);
1388
+ if (this.subscriptions.has(keyStr)) {
1389
+ console.log(`[AMT] Reusing existing subscription to ${keyStr}`);
1390
+ return keyStr;
1391
+ }
1392
+ try {
1393
+ let relayAddress;
1394
+ let discoveryMethod;
1395
+ const relayPort = config.relayPort || DEFAULT_AMT_RELAY_PORT;
1396
+ if (config.relayAddress) {
1397
+ relayAddress = config.relayAddress;
1398
+ discoveryMethod = "manual";
1399
+ console.log(`[AMT] Using configured relay ${relayAddress}:${relayPort}`);
1400
+ } else if (key.source) {
1401
+ console.log(`[AMT] No relay configured, discovering via DRIAD for source ${key.source}...`);
1402
+ const relays = await this.driad.discoverRelays(key.source);
1403
+ const bestRelay = await this.driad.selectBestRelay(relays);
1404
+ if (!bestRelay) {
1405
+ throw new Error(`AMT relay discovery failed for source ${key.source}. Please specify a relay address in the subscription configuration.`);
1406
+ }
1407
+ relayAddress = bestRelay.host;
1408
+ discoveryMethod = "driad";
1409
+ console.log(`[AMT] Discovered relay via DRIAD: ${relayAddress}:${relayPort}`);
1410
+ } else {
1411
+ throw new Error(`AMT relay discovery requires a source address for SSM (RFC 8777). Please specify either a relay address or source address.`);
1412
+ }
1413
+ const subscriptionId = keyStr;
1414
+ this.pendingPackets.set(subscriptionId, []);
1415
+ const subscription = {
1416
+ key,
1417
+ subscriptionId,
1418
+ config,
1419
+ handshakeComplete: false,
1420
+ relay: {
1421
+ address: relayAddress,
1422
+ port: relayPort,
1423
+ discoveryMethod,
1424
+ discoveredAt: Date.now()
1425
+ }
1426
+ };
1427
+ this.subscriptions.set(keyStr, subscription);
1428
+ console.log(`[AMT] Subscription created for ${keyStr} via ${relayAddress}:${relayPort}`);
1429
+ return keyStr;
1430
+ } catch (error) {
1431
+ const subscription = this.subscriptions.get(keyStr);
1432
+ if (subscription) {
1433
+ this.subscriptions.delete(keyStr);
1434
+ this.pendingPackets.delete(subscription.subscriptionId);
1435
+ }
1436
+ throw new Error(`Failed to subscribe via AMT: ${error instanceof Error ? error.message : String(error)}`);
1437
+ }
1438
+ }
1439
+ /**
1440
+ * Unsubscribe from AMT tunnel
1441
+ */
1442
+ async unsubscribe(handle) {
1443
+ const subscription = this.subscriptions.get(handle);
1444
+ if (!subscription) {
1445
+ throw new Error(`Subscription ${handle} not found`);
1446
+ }
1447
+ try {
1448
+ if (subscription.keepAliveTimer) {
1449
+ clearInterval(subscription.keepAliveTimer);
1450
+ }
1451
+ console.log(`[AMT] Unsubscribed from ${handle}`);
1452
+ } catch (error) {
1453
+ console.error("[AMT] Error during unsubscribe:", error);
1454
+ } finally {
1455
+ this.subscriptions.delete(handle);
1456
+ this.pendingPackets.delete(subscription.subscriptionId);
1457
+ }
1458
+ }
1459
+ /**
1460
+ * Get list of active subscriptions
1461
+ */
1462
+ getSubscriptions() {
1463
+ return Array.from(this.subscriptions.keys());
1464
+ }
1465
+ /**
1466
+ * Handle packet from service worker
1467
+ */
1468
+ handlePacket(message) {
1469
+ const { subscriptionId, data } = message;
1470
+ if (!subscriptionId)
1471
+ return;
1472
+ const subscription = this.subscriptions.get(subscriptionId);
1473
+ if (!subscription) {
1474
+ console.warn(`[AMT] Received packet for unknown subscription: ${subscriptionId}`);
1475
+ return;
1476
+ }
1477
+ if (!subscription.handshakeComplete) {
1478
+ const queue = this.pendingPackets.get(subscriptionId);
1479
+ const packetData2 = data;
1480
+ if (queue) {
1481
+ queue.push({
1482
+ data: packetData2.data,
1483
+ remoteAddress: packetData2.remoteAddress,
1484
+ remotePort: packetData2.remotePort
1485
+ });
1486
+ }
1487
+ return;
1488
+ }
1489
+ const packetData = data;
1490
+ const metadata = {
1491
+ sourceAddress: subscription.relay?.address || "unknown",
1492
+ sourcePort: subscription.relay?.port || 0,
1493
+ transport: "tunnel",
1494
+ timestamp: performance.now()
1495
+ };
1496
+ subscription.config.onPacket(packetData.data, metadata);
1497
+ }
1498
+ /**
1499
+ * Handle socket error from service worker
1500
+ */
1501
+ handleSocketError(message) {
1502
+ const { subscriptionId, error } = message;
1503
+ if (!subscriptionId)
1504
+ return;
1505
+ const subscription = this.subscriptions.get(subscriptionId);
1506
+ if (!subscription) {
1507
+ console.warn(`[AMT] Received error for unknown subscription: ${subscriptionId}`);
1508
+ return;
1509
+ }
1510
+ subscription.config.onError(new Error(error || "Unknown error"));
1511
+ }
1512
+ /**
1513
+ * Cleanup on destroy
1514
+ */
1515
+ destroy() {
1516
+ if (this.messageHandler && typeof navigator !== "undefined" && navigator.serviceWorker) {
1517
+ navigator.serviceWorker.removeEventListener("message", this.messageHandler);
1518
+ }
1519
+ const handles = Array.from(this.subscriptions.keys());
1520
+ for (const handle of handles) {
1521
+ this.unsubscribe(handle).catch((err) => {
1522
+ console.error(`[AMT] Error unsubscribing ${handle}:`, err);
1523
+ });
1524
+ }
1525
+ }
1526
+ /**
1527
+ * Get key string for HashMap
1528
+ */
1529
+ getKeyString(key) {
1530
+ const source = key.source ? `@${key.source}` : "";
1531
+ return `${key.group}:${key.port}${source}`;
1532
+ }
1533
+ };
1534
+ var amtGatewayManager = new AMTGatewayManager();
1535
+
1536
+ // src/delivery-catalog.ts
1537
+ var TEMPLATE_VARIABLE = /\$([A-Za-z][A-Za-z0-9]*)\$/g;
1538
+ var ALLOWED_TEMPLATE_VARIABLES = /* @__PURE__ */ new Set(["Number", "Time", "RepresentationID", "VariantID", "TrackID"]);
1539
+ function object(value, path) {
1540
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
1541
+ throw new Error(`${path} must be an object`);
1542
+ }
1543
+ return value;
1544
+ }
1545
+ function string(value, path) {
1546
+ if (typeof value !== "string" || value.trim().length === 0) {
1547
+ throw new Error(`${path} must be a non-empty string`);
1548
+ }
1549
+ return value;
1550
+ }
1551
+ function positiveInteger(value, path) {
1552
+ if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
1553
+ throw new Error(`${path} must be a positive integer`);
1554
+ }
1555
+ return value;
1556
+ }
1557
+ function nonNegativeInteger(value, path) {
1558
+ if (typeof value !== "number" || !Number.isInteger(value) || value < 0) {
1559
+ throw new Error(`${path} must be a non-negative integer`);
1560
+ }
1561
+ return value;
1562
+ }
1563
+ function nonNegativeSafeInteger(value, path) {
1564
+ const parsed = nonNegativeInteger(value, path);
1565
+ if (!Number.isSafeInteger(parsed)) throw new Error(`${path} must be a safe integer`);
1566
+ return parsed;
1567
+ }
1568
+ function mpuSequenceNumber(value, path) {
1569
+ const parsed = nonNegativeSafeInteger(value, path);
1570
+ if (parsed > 4294967295) throw new Error(`${path} must be between 0 and 4294967295`);
1571
+ return parsed;
1572
+ }
1573
+ function port(value, path) {
1574
+ const parsed = positiveInteger(value, path);
1575
+ if (parsed > 65535) throw new Error(`${path} must be between 1 and 65535`);
1576
+ return parsed;
1577
+ }
1578
+ function httpUrl(value, path) {
1579
+ const raw = string(value, path);
1580
+ let parsed;
1581
+ try {
1582
+ parsed = new URL(raw);
1583
+ } catch {
1584
+ throw new Error(`${path} must be an absolute HTTP(S) URL`);
1585
+ }
1586
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
1587
+ throw new Error(`${path} must be an absolute HTTP(S) URL`);
1588
+ }
1589
+ return raw;
1590
+ }
1591
+ function templateVariables(template, path) {
1592
+ const variables = /* @__PURE__ */ new Set();
1593
+ for (const match of template.matchAll(TEMPLATE_VARIABLE)) {
1594
+ const variable = match[1];
1595
+ if (variable === void 0 || !ALLOWED_TEMPLATE_VARIABLES.has(variable)) {
1596
+ throw new Error(`${path} contains unsupported template variable $${variable ?? ""}$`);
1597
+ }
1598
+ variables.add(variable);
1599
+ }
1600
+ if (template.includes("$") && template.replace(TEMPLATE_VARIABLE, "").includes("$")) {
1601
+ throw new Error(`${path} contains a malformed template variable`);
1602
+ }
1603
+ return variables;
1604
+ }
1605
+ function validateTemplatePair(mediaUriTemplate, mediaObjectTemplate, path) {
1606
+ const uriVariables = templateVariables(mediaUriTemplate, `${path}.mediaUriTemplate`);
1607
+ const objectVariables = templateVariables(mediaObjectTemplate, `${path}.objects.mediaObjectTemplate`);
1608
+ if (uriVariables.size === 0) {
1609
+ throw new Error(`${path}.mediaUriTemplate must contain a segment template variable`);
1610
+ }
1611
+ if (uriVariables.size !== objectVariables.size || [...uriVariables].some((variable) => !objectVariables.has(variable))) {
1612
+ throw new Error(`${path} URI and object templates must use the same variables`);
1613
+ }
1614
+ }
1615
+ function validateMmtpDashTemplate(template, path) {
1616
+ const variables = [...template.matchAll(TEMPLATE_VARIABLE)].map((match) => match[1]);
1617
+ const unsupported = variables.find((variable) => variable !== "Number" && variable !== "RepresentationID");
1618
+ if (unsupported !== void 0) {
1619
+ throw new Error(`${path} contains unsupported MMTP-backed DASH template variable $${unsupported}$`);
1620
+ }
1621
+ if (variables.filter((variable) => variable === "Number").length !== 1) {
1622
+ throw new Error(`${path} must contain exactly one $Number$ for MMTP-backed DASH`);
1623
+ }
1624
+ }
1625
+ function validateMmtpDashTemplates(route, path) {
1626
+ validateMmtpDashTemplate(route.mediaUriTemplate, `${path}.mediaUriTemplate`);
1627
+ validateMmtpDashTemplate(route.objects.mediaObjectTemplate, `${path}.objects.mediaObjectTemplate`);
1628
+ }
1629
+ function validateEndpoint(value, path) {
1630
+ const endpoint = object(value, path);
1631
+ return {
1632
+ source: string(endpoint["source"], `${path}.source`),
1633
+ group: string(endpoint["group"], `${path}.group`),
1634
+ port: port(endpoint["port"], `${path}.port`)
1635
+ };
1636
+ }
1637
+ function validateEndpoints(value) {
1638
+ const endpoints = object(value, "multicast.endpoints");
1639
+ const entries = Object.entries(endpoints);
1640
+ if (entries.length === 0) throw new Error("multicast.endpoints must not be empty");
1641
+ return Object.fromEntries(
1642
+ entries.map(([id, endpoint]) => [
1643
+ string(id, "multicast endpoint id"),
1644
+ validateEndpoint(endpoint, `multicast.endpoints.${id}`)
1645
+ ])
1646
+ );
1647
+ }
1648
+ function validateDeliveryPolicy(value) {
1649
+ const policy = object(value, "multicast.deliveryPolicy");
1650
+ const missPolicy = policy["missPolicy"];
1651
+ if (missPolicy !== "fail") {
1652
+ throw new Error("multicast.deliveryPolicy.missPolicy must be 'fail'");
1653
+ }
1654
+ return {
1655
+ bufferWindowSegments: positiveInteger(
1656
+ policy["bufferWindowSegments"],
1657
+ "multicast.deliveryPolicy.bufferWindowSegments"
1658
+ ),
1659
+ requestTimeoutMs: positiveInteger(policy["requestTimeoutMs"], "multicast.deliveryPolicy.requestTimeoutMs"),
1660
+ missPolicy
1661
+ };
1662
+ }
1663
+ function validateRouteBase(value, path, endpoints) {
1664
+ const route = object(value, path);
1665
+ const endpointRef = string(route["endpointRef"], `${path}.endpointRef`);
1666
+ if (!(endpointRef in endpoints)) throw new Error(`${path}.endpointRef does not resolve: ${endpointRef}`);
1667
+ const objects = object(route["objects"], `${path}.objects`);
1668
+ const fec = object(route["fec"], `${path}.fec`);
1669
+ if ("interleaveDepth" in fec || "interleaveMs" in fec) {
1670
+ throw new Error(`${path}.fec.interleaveDepthMs is the only supported interleave field`);
1671
+ }
1672
+ const mediaUriTemplate = httpUrl(route["mediaUriTemplate"], `${path}.mediaUriTemplate`);
1673
+ const mediaObjectTemplate = string(objects["mediaObjectTemplate"], `${path}.objects.mediaObjectTemplate`);
1674
+ validateTemplatePair(mediaUriTemplate, mediaObjectTemplate, path);
1675
+ return {
1676
+ id: string(route["id"], `${path}.id`),
1677
+ contentType: validateContentType(route["contentType"], `${path}.contentType`),
1678
+ endpointRef,
1679
+ initUri: httpUrl(route["initUri"], `${path}.initUri`),
1680
+ mediaUriTemplate,
1681
+ objects: {
1682
+ namespace: string(objects["namespace"], `${path}.objects.namespace`),
1683
+ initObject: string(objects["initObject"], `${path}.objects.initObject`),
1684
+ mediaObjectTemplate
1685
+ },
1686
+ fec: {
1687
+ K: positiveInteger(fec["K"], `${path}.fec.K`),
1688
+ P: nonNegativeInteger(fec["P"], `${path}.fec.P`),
1689
+ T: positiveInteger(fec["T"], `${path}.fec.T`),
1690
+ interleaveDepthMs: positiveInteger(fec["interleaveDepthMs"], `${path}.fec.interleaveDepthMs`),
1691
+ blockProfile: parseFecBlockProfile(fec["blockProfile"], `${path}.fec.blockProfile`)
1692
+ }
1693
+ };
1694
+ }
1695
+ function validateContentType(value, path) {
1696
+ if (value !== "video" && value !== "audio" && value !== "text") {
1697
+ throw new Error(`${path} must be 'video', 'audio', or 'text'`);
1698
+ }
1699
+ return value;
1700
+ }
1701
+ function templateShape(template) {
1702
+ return template.replace(TEMPLATE_VARIABLE, "$variable$");
1703
+ }
1704
+ function validateRouteUniqueness(routes, selectorKeys, rawRoutes) {
1705
+ const ids = /* @__PURE__ */ new Set();
1706
+ const selectors = /* @__PURE__ */ new Set();
1707
+ const initUris = /* @__PURE__ */ new Set();
1708
+ const mediaShapes = /* @__PURE__ */ new Set();
1709
+ routes.forEach((route, index) => {
1710
+ if (ids.has(route.id)) throw new Error(`duplicate route id: ${route.id}`);
1711
+ ids.add(route.id);
1712
+ const selector = selectorKeys.map((key) => String(rawRoutes[index]?.[key])).join("\0");
1713
+ if (selectors.has(selector)) throw new Error(`duplicate route selector: ${selectorKeys.join(", ")}`);
1714
+ selectors.add(selector);
1715
+ if (initUris.has(route.initUri)) throw new Error(`ambiguous init URI mapping: ${route.initUri}`);
1716
+ initUris.add(route.initUri);
1717
+ const mediaShape = templateShape(route.mediaUriTemplate);
1718
+ if (mediaShapes.has(mediaShape)) {
1719
+ throw new Error(`ambiguous media URI mapping: ${route.mediaUriTemplate}`);
1720
+ }
1721
+ mediaShapes.add(mediaShape);
1722
+ });
1723
+ }
1724
+ function validateRoutes(value, kind, endpoints) {
1725
+ if (!Array.isArray(value) || value.length === 0) throw new Error(`multicast.${kind}.routes must not be empty`);
1726
+ const rawRoutes = value.map((route, index) => object(route, `multicast.${kind}.routes[${index}]`));
1727
+ const routes = rawRoutes.map((route, index) => {
1728
+ const path = `multicast.${kind}.routes[${index}]`;
1729
+ const base = validateRouteBase(route, path, endpoints);
1730
+ if (kind === "dash") {
1731
+ validateMmtpDashTemplates(base, path);
1732
+ const mmtp = object(route["mmtp"], `${path}.mmtp`);
1733
+ if (mmtp["mode"] !== "mfu") throw new Error(`${path}.mmtp.mode must be 'mfu'`);
1734
+ const mode = "mfu";
1735
+ const packetId = mmtp["packetId"];
1736
+ if (!isMulticastTrackPacketId(packetId)) {
1737
+ throw new Error(`${path}.mmtp.packetId must be an integer from 1 to 65535 (0 is the MMTP signaling flow)`);
1738
+ }
1739
+ const repairTrack = mmtp["repairTrack"];
1740
+ if (repairTrack !== void 0 && (typeof repairTrack !== "string" || repairTrack.trim().length === 0)) {
1741
+ throw new Error(`${path}.mmtp.repairTrack must be a non-empty string when provided`);
1742
+ }
1743
+ const mediaUnitsPerObject = positiveInteger(mmtp["mediaUnitsPerObject"], `${path}.mmtp.mediaUnitsPerObject`);
1744
+ const firstMpuSequenceNumber = mpuSequenceNumber(
1745
+ mmtp["firstMpuSequenceNumber"],
1746
+ `${path}.mmtp.firstMpuSequenceNumber`
1747
+ );
1748
+ const firstObjectNumber = nonNegativeSafeInteger(mmtp["firstObjectNumber"], `${path}.mmtp.firstObjectNumber`);
1749
+ const mpuSequencesPerObject = positiveInteger(mmtp["mpuSequencesPerObject"], `${path}.mmtp.mpuSequencesPerObject`);
1750
+ if (mpuSequencesPerObject > mediaUnitsPerObject) {
1751
+ throw new Error(`${path}.mmtp.mpuSequencesPerObject must not exceed mediaUnitsPerObject`);
1752
+ }
1753
+ if (firstMpuSequenceNumber + mpuSequencesPerObject - 1 > 4294967295) {
1754
+ throw new Error(`${path}.mmtp first object exceeds the MMTP MPU sequence-number range`);
1755
+ }
1756
+ return {
1757
+ ...base,
1758
+ representationId: string(route["representationId"], `${path}.representationId`),
1759
+ mmtp: {
1760
+ trackName: string(mmtp["trackName"], `${path}.mmtp.trackName`),
1761
+ packetId,
1762
+ mode,
1763
+ codec: string(mmtp["codec"], `${path}.mmtp.codec`),
1764
+ timescale: positiveInteger(mmtp["timescale"], `${path}.mmtp.timescale`),
1765
+ mediaUnitDurationTicks: positiveInteger(
1766
+ mmtp["mediaUnitDurationTicks"],
1767
+ `${path}.mmtp.mediaUnitDurationTicks`
1768
+ ),
1769
+ mediaUnitsPerObject,
1770
+ firstMpuSequenceNumber,
1771
+ firstObjectNumber,
1772
+ mpuSequencesPerObject,
1773
+ ...repairTrack === void 0 ? {} : { repairTrack }
1774
+ }
1775
+ };
1776
+ }
1777
+ if (kind === "hls") {
1778
+ return {
1779
+ ...base,
1780
+ variantId: string(route["variantId"], `${path}.variantId`),
1781
+ trackId: string(route["trackId"], `${path}.trackId`)
1782
+ };
1783
+ }
1784
+ return { ...base, trackName: string(route["trackName"], `${path}.trackName`) };
1785
+ });
1786
+ validateRouteUniqueness(
1787
+ routes,
1788
+ kind === "dash" ? ["representationId", "contentType"] : kind === "hls" ? ["variantId", "trackId"] : ["trackName"],
1789
+ rawRoutes
1790
+ );
1791
+ return routes;
1792
+ }
1793
+ function validateV2Catalog(value) {
1794
+ const catalog = object(value, "catalog");
1795
+ if (catalog["schemaVersion"] !== 2) throw new Error("catalog.schemaVersion must be 2");
1796
+ const multicast = object(catalog["multicast"], "multicast");
1797
+ const packaging = multicast["packaging"];
1798
+ if (packaging !== "dash" && packaging !== "hls" && packaging !== "mmtp") {
1799
+ throw new Error("multicast.packaging must be 'dash', 'hls', or 'mmtp'");
1800
+ }
1801
+ const endpoints = validateEndpoints(multicast["endpoints"]);
1802
+ const deliveryPolicy = validateDeliveryPolicy(multicast["deliveryPolicy"]);
1803
+ const common = {
1804
+ schemaVersion: 2,
1805
+ channelId: string(catalog["channelId"], "catalog.channelId")
1806
+ };
1807
+ if (packaging === "dash") {
1808
+ const dash = object(multicast["dash"], "multicast.dash");
1809
+ return {
1810
+ ...common,
1811
+ multicast: {
1812
+ packaging,
1813
+ endpoints,
1814
+ deliveryPolicy,
1815
+ dash: {
1816
+ manifestUrl: httpUrl(dash["manifestUrl"], "multicast.dash.manifestUrl"),
1817
+ routes: validateRoutes(dash["routes"], packaging, endpoints)
1818
+ }
1819
+ }
1820
+ };
1821
+ }
1822
+ if (packaging === "hls") {
1823
+ const hls = object(multicast["hls"], "multicast.hls");
1824
+ return {
1825
+ ...common,
1826
+ multicast: {
1827
+ packaging,
1828
+ endpoints,
1829
+ deliveryPolicy,
1830
+ hls: {
1831
+ manifestUrl: httpUrl(hls["manifestUrl"], "multicast.hls.manifestUrl"),
1832
+ routes: validateRoutes(hls["routes"], packaging, endpoints)
1833
+ }
1834
+ }
1835
+ };
1836
+ }
1837
+ const mmtp = object(multicast["mmtp"], "multicast.mmtp");
1838
+ return {
1839
+ ...common,
1840
+ multicast: {
1841
+ packaging,
1842
+ endpoints,
1843
+ deliveryPolicy,
1844
+ mmtp: { routes: validateRoutes(mmtp["routes"], packaging, endpoints) }
1845
+ }
1846
+ };
1847
+ }
1848
+ function normalizeDeliveryCatalog(value) {
1849
+ const catalog = object(value, "catalog");
1850
+ if (catalog["schemaVersion"] === 2) return validateV2Catalog(catalog);
1851
+ if (catalog["schemaVersion"] === void 0) throw new Error("catalog.schemaVersion is required");
1852
+ throw new Error(`unsupported catalog.schemaVersion: ${String(catalog["schemaVersion"])}`);
1853
+ }
1854
+ export {
1855
+ normalizeDeliveryCatalog
1856
+ };
1857
+ //# sourceMappingURL=delivery-catalog.js.map