@flowplayer/player 3.16.0-rc → 3.16.0-rc.1

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 (58) hide show
  1. package/core/events.d.ts +2 -8
  2. package/core/events.js +1 -4
  3. package/core.js +1 -1
  4. package/default.js +1 -1
  5. package/embed.js +2 -2
  6. package/flowplayer.css +1 -1
  7. package/index.d.ts +29 -40
  8. package/package.json +1 -1
  9. package/plugins/ads.d.ts +29 -40
  10. package/plugins/ads.js +1 -1
  11. package/plugins/airplay.d.ts +29 -40
  12. package/plugins/analytics.d.ts +29 -40
  13. package/plugins/analytics.js +1 -1
  14. package/plugins/asel.d.ts +29 -40
  15. package/plugins/audio.d.ts +29 -40
  16. package/plugins/chapters.d.ts +29 -40
  17. package/plugins/chromecast.d.ts +29 -40
  18. package/plugins/comscore.d.ts +29 -40
  19. package/plugins/consent.d.ts +78 -41
  20. package/plugins/consent.js +1 -1
  21. package/plugins/context-menu.d.ts +29 -40
  22. package/plugins/cuepoints.d.ts +29 -40
  23. package/plugins/dash.d.ts +29 -40
  24. package/plugins/drm.d.ts +29 -40
  25. package/plugins/endscreen.d.ts +29 -40
  26. package/plugins/fas.d.ts +29 -40
  27. package/plugins/float-on-scroll.d.ts +29 -40
  28. package/plugins/ga4.d.ts +29 -40
  29. package/plugins/gemius.d.ts +29 -40
  30. package/plugins/google-analytics.d.ts +29 -40
  31. package/plugins/health.d.ts +37 -41
  32. package/plugins/health.js +1 -1
  33. package/plugins/hls.d.ts +29 -40
  34. package/plugins/hls.js +1 -1
  35. package/plugins/id3.d.ts +96 -41
  36. package/plugins/iframe.d.ts +29 -40
  37. package/plugins/keyboard.d.ts +29 -40
  38. package/plugins/media-session.d.ts +29 -40
  39. package/plugins/message.d.ts +29 -40
  40. package/plugins/ovp.d.ts +29 -40
  41. package/plugins/playlist.d.ts +29 -71
  42. package/plugins/playlist.js +1 -1
  43. package/plugins/preview.d.ts +29 -40
  44. package/plugins/qsel.d.ts +102 -38
  45. package/plugins/qsel.js +1 -1
  46. package/plugins/qul.d.ts +29 -40
  47. package/plugins/rts.d.ts +29 -40
  48. package/plugins/share.d.ts +29 -40
  49. package/plugins/speed.d.ts +29 -40
  50. package/plugins/ssai.d.ts +29 -40
  51. package/plugins/ssai.js +1 -1
  52. package/plugins/subtitles.d.ts +29 -40
  53. package/plugins/thumbnails.d.ts +29 -40
  54. package/plugins/tizen.d.ts +29 -40
  55. package/plugins/vtsel.d.ts +122 -33
  56. package/plugins/vtsel.js +1 -1
  57. package/plugins/webos.d.ts +29 -40
  58. package/util/loader.d.ts +27 -40
@@ -768,6 +768,8 @@ declare const NO_CONTROLS = "no-controls";
768
768
 
769
769
  declare const NO_DVR = "no-timeline";
770
770
 
771
+ declare type NoInfer_2<T> = [T][T extends any ? 0 : never];
772
+
771
773
  /* Excluded from this release type: NON_RECOVERABLE_ERROR */
772
774
 
773
775
  /* Excluded from this release type: NonRecoverableErrorEventDetail */
@@ -908,7 +910,6 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
908
910
  disabled: boolean;
909
911
  /* Excluded from this release type: started */
910
912
  /* Excluded from this release type: token */
911
- tracks?: VideoTrack[];
912
913
  /* Excluded from this release type: _customElements */
913
914
  /* Excluded from this release type: _storage */
914
915
  };
@@ -992,6 +993,7 @@ declare type PlayerCustomEventsOverloads = {
992
993
  */
993
994
  on(event: typeof QUALITIES, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof QUALITIES]>) => void): Player;
994
995
  /* Excluded from this release type: on */
996
+ /* Excluded from this release type: on */
995
997
  /**
996
998
  * Listen to this event to create a recommendations grid using the data passed with the event.
997
999
  */
@@ -1010,6 +1012,11 @@ declare type PlayerCustomEventsOverloads = {
1010
1012
  /* Excluded from this release type: on */
1011
1013
  /* Excluded from this release type: on */
1012
1014
  /* Excluded from this release type: on */
1015
+ /* Excluded from this release type: on */
1016
+ /**
1017
+ * TODO: this is a workaround, since not all event overloads are typed. when all plugin work is finished, remove this
1018
+ * https://wowzamedia.jira.com/browse/PLAY-653
1019
+ */
1013
1020
  on<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1014
1021
  /* Excluded from this release type: on */
1015
1022
  /**
@@ -1034,9 +1041,12 @@ declare type PlayerCustomEventsOverloads = {
1034
1041
  */
1035
1042
  off<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1036
1043
  /* Excluded from this release type: poll */
1044
+ emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1045
+ emit(event: never, data?: never): Player;
1046
+ /* Excluded from this release type: emit */
1047
+ /* Excluded from this release type: emit */
1037
1048
  /* Excluded from this release type: emit */
1038
1049
  /* Excluded from this release type: emit */
1039
- emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1040
1050
  /* Excluded from this release type: emit */
1041
1051
  };
1042
1052
 
@@ -1144,6 +1154,17 @@ declare const /**
1144
1154
  */
1145
1155
  PROGRESS = "progress";
1146
1156
 
1157
+ /**
1158
+ * @public
1159
+ */
1160
+ declare type QselOption = {
1161
+ height: number;
1162
+ level: number;
1163
+ text: string;
1164
+ /* Excluded from this release type: videoCodec */
1165
+ width: number;
1166
+ };
1167
+
1147
1168
  /**
1148
1169
  * @public
1149
1170
  * emitted whenever a list of qualities has been made available
@@ -1162,27 +1183,11 @@ QUALITIES = "qualities";
1162
1183
  /**
1163
1184
  * @public
1164
1185
  */
1165
- declare type QualitiesEventDetail = QualityDetail[];
1186
+ declare type QualitiesEventDetail = QselOption[];
1166
1187
 
1167
- /**
1168
- * @public
1169
- */
1170
- declare type QualityDetail = {
1171
- level: number;
1172
- text: string;
1173
- width: number;
1174
- height: number;
1175
- videoCodec: string;
1176
- } | BitrateInfo | {
1177
- text: string | number;
1178
- encodingId: string;
1179
- spatialLayerId: number;
1180
- temporalLayerId: number;
1181
- maxSpatialLayerId: number;
1182
- maxTemporalLayerId: number;
1183
- height: number;
1184
- width: number;
1185
- };
1188
+ /* Excluded from this release type: _QualitiesEventDetail */
1189
+
1190
+ /* Excluded from this release type: _QualityDetail */
1186
1191
 
1187
1192
  declare enum QualityOpts {
1188
1193
  LOW = 1,
@@ -1354,20 +1359,14 @@ SEEKING_2 = "seeking";
1354
1359
 
1355
1360
  /**
1356
1361
  * @public
1357
- * allows plugins to listen for forced quality changes
1358
- * it should emit the index of the quality to set
1359
- * -1 is a special idx saying to use ABR if the plugin
1360
- * exposes an ABR implementation
1362
+ * @deprecated please use Qsel.events.SET_QUALITY
1361
1363
  */
1362
1364
  declare const /**
1363
1365
  @public
1364
1366
  * when a new player is inserted into the HTML
1365
1367
  */ /**
1366
1368
  * @public
1367
- * allows plugins to listen for forced quality changes
1368
- * it should emit the index of the quality to set
1369
- * -1 is a special idx saying to use ABR if the plugin
1370
- * exposes an ABR implementation
1369
+ * @deprecated please use Qsel.events.SET_QUALITY
1371
1370
  */
1372
1371
  SET_QUALITY = "quality:set";
1373
1372
 
@@ -1556,16 +1555,6 @@ declare const /**
1556
1555
  */
1557
1556
  VIDEO_TRACKS = "videoTracks";
1558
1557
 
1559
- /**
1560
- * @public
1561
- */
1562
- declare interface VideoTrack {
1563
- name: string;
1564
- /* Excluded from this release type: data */
1565
- default: boolean;
1566
- selected: boolean;
1567
- }
1568
-
1569
1558
  /**
1570
1559
  * @public
1571
1560
  * when a player enters the viewpoint
package/plugins/ovp.d.ts CHANGED
@@ -779,6 +779,8 @@ declare const NO_CONTROLS = "no-controls";
779
779
 
780
780
  declare const NO_DVR = "no-timeline";
781
781
 
782
+ declare type NoInfer_2<T> = [T][T extends any ? 0 : never];
783
+
782
784
  /* Excluded from this release type: NON_RECOVERABLE_ERROR */
783
785
 
784
786
  /* Excluded from this release type: NonRecoverableErrorEventDetail */
@@ -942,7 +944,6 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
942
944
  disabled: boolean;
943
945
  /* Excluded from this release type: started */
944
946
  /* Excluded from this release type: token */
945
- tracks?: VideoTrack[];
946
947
  /* Excluded from this release type: _customElements */
947
948
  /* Excluded from this release type: _storage */
948
949
  };
@@ -1026,6 +1027,7 @@ declare type PlayerCustomEventsOverloads = {
1026
1027
  */
1027
1028
  on(event: typeof QUALITIES, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof QUALITIES]>) => void): Player;
1028
1029
  /* Excluded from this release type: on */
1030
+ /* Excluded from this release type: on */
1029
1031
  /**
1030
1032
  * Listen to this event to create a recommendations grid using the data passed with the event.
1031
1033
  */
@@ -1044,6 +1046,11 @@ declare type PlayerCustomEventsOverloads = {
1044
1046
  /* Excluded from this release type: on */
1045
1047
  /* Excluded from this release type: on */
1046
1048
  /* Excluded from this release type: on */
1049
+ /* Excluded from this release type: on */
1050
+ /**
1051
+ * TODO: this is a workaround, since not all event overloads are typed. when all plugin work is finished, remove this
1052
+ * https://wowzamedia.jira.com/browse/PLAY-653
1053
+ */
1047
1054
  on<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1048
1055
  /* Excluded from this release type: on */
1049
1056
  /**
@@ -1068,9 +1075,12 @@ declare type PlayerCustomEventsOverloads = {
1068
1075
  */
1069
1076
  off<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1070
1077
  /* Excluded from this release type: poll */
1078
+ emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1079
+ emit(event: never, data?: never): Player;
1080
+ /* Excluded from this release type: emit */
1081
+ /* Excluded from this release type: emit */
1071
1082
  /* Excluded from this release type: emit */
1072
1083
  /* Excluded from this release type: emit */
1073
- emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1074
1084
  /* Excluded from this release type: emit */
1075
1085
  };
1076
1086
 
@@ -1185,6 +1195,17 @@ declare const /**
1185
1195
  */
1186
1196
  PROGRESS = "progress";
1187
1197
 
1198
+ /**
1199
+ * @public
1200
+ */
1201
+ declare type QselOption = {
1202
+ height: number;
1203
+ level: number;
1204
+ text: string;
1205
+ /* Excluded from this release type: videoCodec */
1206
+ width: number;
1207
+ };
1208
+
1188
1209
  /**
1189
1210
  * @public
1190
1211
  * emitted whenever a list of qualities has been made available
@@ -1203,27 +1224,11 @@ QUALITIES = "qualities";
1203
1224
  /**
1204
1225
  * @public
1205
1226
  */
1206
- declare type QualitiesEventDetail = QualityDetail[];
1227
+ declare type QualitiesEventDetail = QselOption[];
1207
1228
 
1208
- /**
1209
- * @public
1210
- */
1211
- declare type QualityDetail = {
1212
- level: number;
1213
- text: string;
1214
- width: number;
1215
- height: number;
1216
- videoCodec: string;
1217
- } | BitrateInfo | {
1218
- text: string | number;
1219
- encodingId: string;
1220
- spatialLayerId: number;
1221
- temporalLayerId: number;
1222
- maxSpatialLayerId: number;
1223
- maxTemporalLayerId: number;
1224
- height: number;
1225
- width: number;
1226
- };
1229
+ /* Excluded from this release type: _QualitiesEventDetail */
1230
+
1231
+ /* Excluded from this release type: _QualityDetail */
1227
1232
 
1228
1233
  declare enum QualityOpts {
1229
1234
  LOW = 1,
@@ -1410,20 +1415,14 @@ SEEKING_2 = "seeking";
1410
1415
 
1411
1416
  /**
1412
1417
  * @public
1413
- * allows plugins to listen for forced quality changes
1414
- * it should emit the index of the quality to set
1415
- * -1 is a special idx saying to use ABR if the plugin
1416
- * exposes an ABR implementation
1418
+ * @deprecated please use Qsel.events.SET_QUALITY
1417
1419
  */
1418
1420
  declare const /**
1419
1421
  @public
1420
1422
  * when a new player is inserted into the HTML
1421
1423
  */ /**
1422
1424
  * @public
1423
- * allows plugins to listen for forced quality changes
1424
- * it should emit the index of the quality to set
1425
- * -1 is a special idx saying to use ABR if the plugin
1426
- * exposes an ABR implementation
1425
+ * @deprecated please use Qsel.events.SET_QUALITY
1427
1426
  */
1428
1427
  SET_QUALITY = "quality:set";
1429
1428
 
@@ -1612,16 +1611,6 @@ declare const /**
1612
1611
  */
1613
1612
  VIDEO_TRACKS = "videoTracks";
1614
1613
 
1615
- /**
1616
- * @public
1617
- */
1618
- declare interface VideoTrack {
1619
- name: string;
1620
- /* Excluded from this release type: data */
1621
- default: boolean;
1622
- selected: boolean;
1623
- }
1624
-
1625
1614
  /**
1626
1615
  * @public
1627
1616
  * when a player enters the viewpoint
@@ -762,6 +762,8 @@ declare const NO_CONTROLS = "no-controls";
762
762
 
763
763
  declare const NO_DVR = "no-timeline";
764
764
 
765
+ declare type NoInfer_2<T> = [T][T extends any ? 0 : never];
766
+
765
767
  /* Excluded from this release type: NON_RECOVERABLE_ERROR */
766
768
 
767
769
  /* Excluded from this release type: NonRecoverableErrorEventDetail */
@@ -902,7 +904,6 @@ declare type Player = HTMLVideoElement & PlayerEventOverloads & {
902
904
  disabled: boolean;
903
905
  /* Excluded from this release type: started */
904
906
  /* Excluded from this release type: token */
905
- tracks?: VideoTrack[];
906
907
  /* Excluded from this release type: _customElements */
907
908
  /* Excluded from this release type: _storage */
908
909
  };
@@ -986,6 +987,7 @@ declare type PlayerCustomEventsOverloads = {
986
987
  */
987
988
  on(event: typeof QUALITIES, handler: (e: FPEvent<PlayerCustomEventsDetailMap[typeof QUALITIES]>) => void): Player;
988
989
  /* Excluded from this release type: on */
990
+ /* Excluded from this release type: on */
989
991
  /**
990
992
  * Listen to this event to create a recommendations grid using the data passed with the event.
991
993
  */
@@ -1004,6 +1006,11 @@ declare type PlayerCustomEventsOverloads = {
1004
1006
  /* Excluded from this release type: on */
1005
1007
  /* Excluded from this release type: on */
1006
1008
  /* Excluded from this release type: on */
1009
+ /* Excluded from this release type: on */
1010
+ /**
1011
+ * TODO: this is a workaround, since not all event overloads are typed. when all plugin work is finished, remove this
1012
+ * https://wowzamedia.jira.com/browse/PLAY-653
1013
+ */
1007
1014
  on<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1008
1015
  /* Excluded from this release type: on */
1009
1016
  /**
@@ -1028,9 +1035,12 @@ declare type PlayerCustomEventsOverloads = {
1028
1035
  */
1029
1036
  off<T>(event: string, handler: (e: FPEvent<T>) => void): Player;
1030
1037
  /* Excluded from this release type: poll */
1038
+ emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1039
+ emit(event: never, data?: never): Player;
1040
+ /* Excluded from this release type: emit */
1041
+ /* Excluded from this release type: emit */
1031
1042
  /* Excluded from this release type: emit */
1032
1043
  /* Excluded from this release type: emit */
1033
- emit<T extends PlayerEmittableEventNames>(event: T, data?: PlayerCustomEventsDetailMap[T]): Player;
1034
1044
  /* Excluded from this release type: emit */
1035
1045
  };
1036
1046
 
@@ -1099,29 +1109,6 @@ PLAYING_2 = "playing";
1099
1109
  declare const Playlist: PluginCtor<Config, Player>;
1100
1110
  export default Playlist;
1101
1111
 
1102
- declare type PlaylistConfig = {
1103
- controls?: string | HTMLElement;
1104
- autoplay?: boolean;
1105
- loop?: boolean;
1106
- skip_controls?: boolean;
1107
- advance?: boolean;
1108
- start_index?: number;
1109
- delay?: number;
1110
- should_play?: boolean;
1111
- mode?: QueueModes;
1112
- sort?: (list: QueueMembers, mode: QueueModes) => QueueMembers;
1113
- plays?: number;
1114
- shuffle?: boolean;
1115
- theme?: string;
1116
- };
1117
-
1118
- /**
1119
- * @public
1120
- */
1121
- export declare type PlaylistPluginConfig = ConfigWith<{
1122
- playlist?: PlaylistConfig;
1123
- }>;
1124
-
1125
1112
  /**
1126
1113
  * @public
1127
1114
  */
@@ -1167,6 +1154,17 @@ declare const /**
1167
1154
  */
1168
1155
  PROGRESS = "progress";
1169
1156
 
1157
+ /**
1158
+ * @public
1159
+ */
1160
+ declare type QselOption = {
1161
+ height: number;
1162
+ level: number;
1163
+ text: string;
1164
+ /* Excluded from this release type: videoCodec */
1165
+ width: number;
1166
+ };
1167
+
1170
1168
  /**
1171
1169
  * @public
1172
1170
  * emitted whenever a list of qualities has been made available
@@ -1185,27 +1183,11 @@ QUALITIES = "qualities";
1185
1183
  /**
1186
1184
  * @public
1187
1185
  */
1188
- declare type QualitiesEventDetail = QualityDetail[];
1186
+ declare type QualitiesEventDetail = QselOption[];
1189
1187
 
1190
- /**
1191
- * @public
1192
- */
1193
- declare type QualityDetail = {
1194
- level: number;
1195
- text: string;
1196
- width: number;
1197
- height: number;
1198
- videoCodec: string;
1199
- } | BitrateInfo | {
1200
- text: string | number;
1201
- encodingId: string;
1202
- spatialLayerId: number;
1203
- temporalLayerId: number;
1204
- maxSpatialLayerId: number;
1205
- maxTemporalLayerId: number;
1206
- height: number;
1207
- width: number;
1208
- };
1188
+ /* Excluded from this release type: _QualitiesEventDetail */
1189
+
1190
+ /* Excluded from this release type: _QualityDetail */
1209
1191
 
1210
1192
  declare enum QualityOpts {
1211
1193
  LOW = 1,
@@ -1213,14 +1195,6 @@ declare enum QualityOpts {
1213
1195
  HIGH = 4
1214
1196
  }
1215
1197
 
1216
- declare type QueueMembers = Array<Config>;
1217
-
1218
- declare enum QueueModes {
1219
- SHUFFLE = 1,
1220
- FIFO = 2,
1221
- LOOP = 4
1222
- }
1223
-
1224
1198
  /**
1225
1199
  * @public
1226
1200
  * emitted when it is safe to clean up a fp instance
@@ -1385,20 +1359,14 @@ SEEKING_2 = "seeking";
1385
1359
 
1386
1360
  /**
1387
1361
  * @public
1388
- * allows plugins to listen for forced quality changes
1389
- * it should emit the index of the quality to set
1390
- * -1 is a special idx saying to use ABR if the plugin
1391
- * exposes an ABR implementation
1362
+ * @deprecated please use Qsel.events.SET_QUALITY
1392
1363
  */
1393
1364
  declare const /**
1394
1365
  @public
1395
1366
  * when a new player is inserted into the HTML
1396
1367
  */ /**
1397
1368
  * @public
1398
- * allows plugins to listen for forced quality changes
1399
- * it should emit the index of the quality to set
1400
- * -1 is a special idx saying to use ABR if the plugin
1401
- * exposes an ABR implementation
1369
+ * @deprecated please use Qsel.events.SET_QUALITY
1402
1370
  */
1403
1371
  SET_QUALITY = "quality:set";
1404
1372
 
@@ -1587,16 +1555,6 @@ declare const /**
1587
1555
  */
1588
1556
  VIDEO_TRACKS = "videoTracks";
1589
1557
 
1590
- /**
1591
- * @public
1592
- */
1593
- declare interface VideoTrack {
1594
- name: string;
1595
- /* Excluded from this release type: data */
1596
- default: boolean;
1597
- selected: boolean;
1598
- }
1599
-
1600
1558
  /**
1601
1559
  * @public
1602
1560
  * when a player enters the viewpoint
@@ -1 +1 @@
1
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function l(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function o(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;l("Config must be an Object",o(t)&&a(t)),l("property `playlist` is required",o(t.playlist)),l("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,l("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),l("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){l("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){o(t[e])&&l(e+" must be a boolean value if present","boolean"==typeof t[e])})),o(t.delay)&&l("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const l=document.createElement("div");l.classList.add("pane","right"),i.append(s,l);const o=document.createElement("div");o.classList.add("poster"),o.style.backgroundImage="url("+this.getPoster()+")",s.append(o),o.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),o.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),l.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,l=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",l+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function h(t){const e="number"==typeof t?t:parseInt(t,10);return(e>9?"":"0")+e}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),this.playlistWrapper=document.createElement("ol"),this.className="fp-playlist-controls is-empty",this.header=this.controlsHeader(e),this.append(this.header,this.playlistWrapper),e.on(t.PLAYLIST_READY,t=>{const n=t.detail.queue;n&&(this.list(n,e),this.classList.toggle("is-empty",!n.members.length))}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;const s=n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx);t.classList.toggle("is-current",s),t.setAttribute("aria-current",""+s)})}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.playlistWrapper.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.playlistWrapper.removeChild(e)})}list(t,e){this.playlistWrapper.innerHTML="",t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.playlistWrapper.append(n)})}videoRow(t,e){const n=document.createElement("li");return n.onclick=this.videoRow_onclick.bind(this,n,e),n.setAttribute("tabindex","0"),n.append(this.item(e,t)),n}item(t,e){const n=document.createElement("div");n.className="fp-playlist-controls-item";const i=this.itemHeader(t,e),s=this.itemContent(e);return n.append(i,s),n}itemContent(t){var e,n;const i=document.createElement("div");i.className="fp-playlist-controls-item-content";const s=document.createElement("div");s.className="fp-playlist-controls-item-title",s.textContent=t.title||(null===(e=t.metadata)||void 0===e?void 0:e.title)||"";const l=document.createElement("div");return l.className="fp-playlist-controls-item-desc",l.textContent=t.description||(null===(n=t.metadata)||void 0===n?void 0:n.description)||"",i.append(s,l),i}itemHeader(t,e){var n,i;const s=document.createElement("div");s.className="fp-playlist-controls-item-header";const l=document.createElement("img");l.alt=e.title||(null===(n=e.metadata)||void 0===n?void 0:n.title)||"",l.className="fp-playlist-controls-image",l.src=e.poster||"";const o=document.createElement("span");o.className="fp-playlist-controls-playing",o.textContent=t.i18n("playlist.now_playing","Now playing"),s.append(l,o);const r=e.duration||(null===(i=e.metadata)||void 0===i?void 0:i.duration);if(void 0!==r){const t=document.createElement("span");t.className="fp-playlist-controls-duration",t.textContent=isFinite(r)?function(t){if(isNaN(t)||t>=Number.MAX_SAFE_INTEGER)return"";const e=t<0?"-":"";t=Math.round(Math.abs(t));const n=Math.floor(t/3600);let i=Math.floor(t/60);return t-=60*i,n>=1?(i-=60*n,e+n+":"+h(i)+":"+h(t)):e+h(i)+":"+h(t)}(r):"",s.append(t)}return s}controlsHeader(e){const n=document.createElement("div");n.className="fp-playlist-controls-header";const i=document.createElement("input");i.type="checkbox",i.className="fp-playlist-toggle",i.id="toggle";const s=document.createElement("label");s.className="fp-playlist-label",s.tabIndex=0,s.setAttribute("role","button"),s.setAttribute("for","toggle");const l=document.createElement("span");return l.textContent=e.i18n("playlist.autoplay","Autoplay"),s.addEventListener("click",t=>{t.preventDefault();const n=!i.checked;i.checked=n,Object.assign(e.opts.playlist,{advance:n}),s.ariaPressed=n+"",s.ariaLabel=n?e.i18n("playlist.turn_off_autoplay","Turn off autoplay"):e.i18n("playlist.autoplay","Autoplay")}),e.on(t.PLAYLIST_READY,()=>{var t,n;const l=null===(n=null===(t=e.opts)||void 0===t?void 0:t.playlist)||void 0===n?void 0:n.advance;i.checked=!1!==l,s.ariaPressed=""+(!1!==l),s.ariaLabel=!1!==l?e.i18n("playlist.turn_off_autoplay","Turn off autoplay"):e.i18n("playlist.autoplay","Autoplay")}),n.append(l,i,s),n}videoRow_onclick(t,e){var n;if(t.classList.contains("is-current"))return;const i=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==i&&(null===(n=e.playlist)||void 0===n||n.play(i))}}var v;function L(t,e){var n,i;const s=e.sort||x,l=null!==(n=e.mode)&&void 0!==n?n:v.FIFO;return t=s(t.slice(0),l),{mode:l,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function E(t){return t.idx==t.last_idx}function b(t){const e=t.idx+1;return e>t.last_idx?0:e}function A(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}function x(t,e){return(e&v.SHUFFLE)==v.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function T(t){return L(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(v||(v={})),function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const w=["touchstart","touchmove"];function _(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function I(t,e,n,i){Array.isArray(e)?e.forEach(e=>g(t,e,n,i)):g(t,e,n,i)}function g(t,e,n,i){if(s=e,!~w.indexOf(s))return t.addEventListener(e,n,i),t;var s;const l=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,l),t}function S(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function P(t,e,n){return t.setAttribute(e,n),t}function N(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function O(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function q(e,n,i){const s=n.idx+n.plays<0;if(!s&&i.delay)return function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue,l=S(e,"flowplayer-playlist-interstitial");if(!l||!s||!n.delay)return;e.root.classList.add("is-interstitial");const o=s.members[b(s)];_(l,t.INTERSTITIAL_NEXT_ITEM,{next:o})}(e,i);C(e,A(n,s,i.start_index),s)}function C(e,n,i){i||(e.preload=n.preload="auto",!e.opts.autoplay&&e.setOpts({autoplay:1})),e.emit("playlist/advance"),"object"==typeof n&&e.setOpts(n),function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!s)return;const l=s.idx,o=s.members[l],r=e.currentSrc;if(o.src&&e.setSrc(o.src),e.emit(t.PLAYLIST_NEXT,{next_index:l}),e.opts.autoplay||n)return;const a=n=>{("canplay"===n.type&&r!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",a),e.removeEventListener(t.PLAYLIST_NEXT,a),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],a)}(e,i)}function Y(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,C(e,n.members[t]))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=T(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function k(e){const n=y(e,"flowplayer-skip-previous-icon");P(n,"role","button"),I(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");P(i,"role","button"),I(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=O("fp-playlist-prev-preview"),l=O("fp-playlist-next-preview"),o=S(e,"flowplayer-control-buttons");return o&&(o.prepend(n),o.append(i),o.append(s),o.append(l)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=m(t,"data.queue",m(e,"playlist.queue"));if(!n||!o||!e.skip_controls)return;N(o,"is-prev-button-disabled",!n.idx),N(o,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!E(t)||0!=(t.mode&v.LOOP))return t.members[b(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&v.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;l.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:l}}function D(t,e){if(!e)return;!1!==e.skip_controls&&(t.skip_controls=k(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");n.append(s)}function F(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?v.SHUFFLE:v.FIFO;return e.loop&&(n|=v.LOOP),L(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function R(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),l=null===(n=t.detail)||void 0===n?void 0:n.queue,o=null===(i=t.detail)||void 0===i?void 0:i.should_play;l&&s&&(e.playlist=Y(e,l),o&&q(e,l,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?E(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=T(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return q(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&q(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking","src"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=S(e,"flowplayer-playlist-interstitial");n&&_(n,t.INTERSTITIAL_CANCEL)}))}var M;const j=((M=class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:5,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),D(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{var t;e.root.classList.remove("is-interstitial");const n=null===(t=e.playlist)||void 0===t?void 0:t.queue;n&&C(e,A(n,!1))}),null===(n=S(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),R(i)}onload(e,n,i,s){F(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,M);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,j)}));
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):((t="undefined"!=typeof globalThis?globalThis:t||self).flowplayer=t.flowplayer||{},t.flowplayer.playlist=e())}(this,(function(){"use strict";var t={PLAYLIST_NEXT:"playlist:next",PLAYLIST_PREVIOUS:"playlist:previous",PLAYLIST_SELECTION:"playlist:selection",PLAYLIST_LOOP:"playlist:loop",PLAYLIST_ENDED:"playlist:ended",PLAYLIST_READY:"playlist:ready",PLAYLIST_ADD:"playlist:add",PLAYLIST_REMOVE:"playlist:remove",INTERSTITIAL_END:"interstitial/end",INTERSTITIAL_CANCEL:"interstitial/cancel",INTERSTITIAL_NEXT_ITEM:"interstitial/next_item"};const e={translation_key:"core.skip-next",name:"fp-skip-next"},n={translation_key:"core.skip-prev",name:"fp-skip-prev"};class Pipe{constructor(t){this.data=t}static of(t){return new Pipe(t)}static maybe(t,e,...n){return null==t?t:e.apply(t,[t,...n])}tap(t,...e){return t.apply(this,[this.data,...e]),new Pipe(this.data)}fmap(t,...e){const n=t.apply(this,[this.data,...e]);return new Pipe(n)}unwrap(){return this.data}}function i(t,e){if(!e)throw new Error(t)}function s(t){return"invalid playlist configuration\ndetails: "+t+"\n\tmust match Object of shape:\n"+["\t\t{ controls?: Selector|HTMLElement","player: Selector|HTMLElement","playlist: PlaylistId|Array(MediaId|PlayerConfig)","shuffle?: Boolean|false","loop?: Boolean|false","advance?: Boolean|true","delay?: Milliseconds|5000"].join("\n\t\t, ")+"\n\t\t}"}function o(t,e){Pipe.of(t).fmap(s).fmap(i,e)}function l(t){return void 0!==t}function r(t){return"string"==typeof t}function a(t){return"object"==typeof t}function c(t){return t instanceof HTMLElement}function u(t){var e;o("Config must be an Object",l(t)&&a(t)),o("property `playlist` is required",l(t.playlist)),o("property `playlist` was not a String(MediaId)",r(t.playlist)||(e=t.playlist,o("playlist property was not of type PlaylistId|Array(MediaId|PlayConfig)",Array.isArray(e)),o("playlist property cannot be an empty Array",e.length>0),!e.forEach((function(t,e){o("item at playlist["+e+"] was not valid",r(t)||a(t))})))),"loop shuffle".split(" ").forEach((function(e){l(t[e])&&o(e+" must be a boolean value if present","boolean"==typeof t[e])})),l(t.delay)&&o("property `delay` must be a Number (Milliseconds)","number"==typeof t.delay)}function p(t){try{u(t)}catch(t){return!1}return!0}class FlowplayerComponent extends HTMLElement{constructor(t){super(),this.player=t}}class FlowplayerIcon extends FlowplayerComponent{constructor(t,e){super(t),this.classList.add("fp-icon",e.name),e.title&&this.setAttribute("title",e.title),e.title&&this.setAttribute("aria-label",e.title),e.translation_key&&this.setAttribute("aria-label",t.i18n(e.translation_key)),this.setAttribute("tabindex","0"),this.setAttribute("focusable","true")}}const d=["title","delay","description","poster","src"];class UpNext extends FlowplayerComponent{static get observedAttributes(){return d}constructor(e){super(e),this.classList.add("up-next"),this.addEventListener("animationend",()=>{this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END))}),this.addEventListener("animationcancel",()=>{this.classList.add("cancelled"),this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_CANCEL))}),this.addEventListener(t.INTERSTITIAL_NEXT_ITEM,this._setUpNext.bind(this))}getTitle(){return this.getAttribute("title")||""}getDescription(){return this.getAttribute("description")||""}getPoster(){return this.getAttribute("poster")||""}getDelay(){return this.getAttribute("delay")||""}connectedCallback(){this.isConnected&&this._render()}attributeChangedCallback(){this._render()}_render(){var e,n;this.innerHTML="",this.classList.remove("cancelled");const i=document.createDocumentFragment(),s=document.createElement("div");s.classList.add("pane","left");const o=document.createElement("div");o.classList.add("pane","right"),i.append(s,o);const l=document.createElement("div");l.classList.add("poster"),l.style.backgroundImage="url("+this.getPoster()+")",s.append(l),l.addEventListener("click",()=>this.dispatchEvent(new CustomEvent(t.INTERSTITIAL_END)));const r=document.createElement("span");r.classList.add("fp-icon","fp-play"),l.append(r);const a=document.createElement("span");a.classList.add("title"),a.textContent=this.getTitle();const c=document.createElement("span");c.classList.add("description"),c.textContent=this.getDescription();const u=document.createElement("span");u.classList.add("countdown"),this.getDelay()&&(u.style.setProperty("--up-next-delay",this.getDelay()+"s"),u.classList.add("go"));const p=document.createElement("span");p.classList.add("cancel"),p.textContent=null!==(n=null===(e=this.player)||void 0===e?void 0:e.i18n("playlist.cancel"))&&void 0!==n?n:"cancel",p.addEventListener("click",()=>u.classList.remove("go")),o.append(a,c,p,u),this.append(i)}_setUpNext(t){var e,n,i;const s=t.detail.next,o=this.player.opt("playlist.delay",void 0)||10;this.setAttribute("title",null!==(e=s.title)&&void 0!==e?e:""),this.setAttribute("description",null!==(n=s.description)&&void 0!==n?n:""),this.setAttribute("poster",null!==(i=s.poster)&&void 0!==i?i:""),this.setAttribute("delay",o+"")}}const y=(t,e)=>new(((t,e)=>{const n=t.get(e);if(!n)throw new Error(`no flowplayer component with the name ${e} exists`);const i=window.customElements.get(e);if(!i)throw new Error(`no default flowplayer component with the name ${e} exists`);const s=window.customElements.get(n);return"function"!=typeof s?i:s})(t._customElements,e))(t),f=(t,e,n)=>{window.customElements.get(e)||window.customElements.define(e,n),t.customElements.get(e)||t.customElements.set(e,e)};function m(t,e){const n=t._customElements.get(e);return n&&t.root.querySelector(n)||void 0}function h(t,e,n){return t.setAttribute(e,n),t}function v(t,e){return t.classList.add(...e.split(" ")),t}function L(t,e,n){return e.split(" ").forEach(e=>t.classList.toggle(e,n)),t}function E(...t){const e=document.createElement("div");return 0==t.length||e.classList.add(...t),e}function b(t,e,n){const i=function(t){return Array.isArray(t)?t.slice(0):t.split(".")}(e);for(;i.length;){if(null==t)return n;const e=i.shift();if("string"!=typeof e)return n;t=t[e]}return null==t?n:t}function A(t,e){if(!e[t])return;const n=document.createElement("span");n.innerText=e[t];const i=E(t);return i.append(n),i}class FlowplayerPlaylistControls extends FlowplayerComponent{constructor(e){super(e),e.on(t.PLAYLIST_READY,t=>{const n=b(t,"data.queue",b(e,"playlist.queue"));n&&this.list(n,e)}),e.on(t.PLAYLIST_NEXT,()=>{var t;(null===(t=e.playlist)||void 0===t?void 0:t.queue)&&Array.from(this.querySelectorAll("li")).forEach((t,n)=>{var i;const s=n===(null===(i=e.playlist)||void 0===i?void 0:i.queue.idx);t.className=s?"is-current":"is-queued",t.setAttribute("aria-current",""+s)})}),e.on(["playing","pause"],t=>{const e=this.querySelector(".is-current");e&&(e.classList.toggle("is-playing","playing"===t.type),e.classList.toggle("is-paused","pause"===t.type))}),e.on(t.PLAYLIST_ADD,t=>{var n;const i=null===(n=e.playlist)||void 0===n?void 0:n.queue;if(!t.data||!i)return;t.data.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}),e.on(t.PLAYLIST_REMOVE,t=>{if(!t.data)return;const e=Array.from(this.querySelectorAll("li"))[t.data.index];e&&this.removeChild(e)})}list(t,e){this.innerHTML="",v(this,"fp-playlist"),t.members.forEach(t=>{const n=this.videoRow(t,e);n&&this.append(n)})}videoRow(t,e){if(!t.title)return;const n=document.createElement("li");var i,s;return n.classList.add("is-queued"),n.onclick=this.videoRow_onclick.bind(this,n,t,e),n.setAttribute("tabindex","0"),n.setAttribute("role","listitem"),i=n,s=[E("fp-color"),this.videoInfo(t),this.buttons(t,e)],i.append(...s),n}videoRow_onclick(t,e,n){var i;if(t.classList.contains("is-current"))return n.togglePlay(!n.playerState["is-playing"]);const s=Array.from(this.querySelectorAll("li")).indexOf(t);-1!==s&&(null===(i=n.playlist)||void 0===i||i.play(s))}videoInfo(t){const e=E("video-info"),n=A("title",t);n&&e.append(n);const i=A("description",t);return i&&e.append(i),e}buttons(t,e){const n=E("video-buttons"),i=y(e,"flowplayer-play-icon"),s=y(e,"flowplayer-pause-icon");return n.append(i,s),t.poster&&(n.style.backgroundImage=["url(",t.poster,")"].join("")),n}}var w;function x(t,e){var n,i;const s=e.sort||g,o=null!==(n=e.mode)&&void 0!==n?n:w.FIFO;return t=s(t.slice(0),o),{mode:o,sort:s,members:t,last_idx:t.length-1,plays:null!==(i=e.plays)&&void 0!==i?i:0,idx:-1}}function T(t){return t.idx==t.last_idx}function I(t){const e=t.idx+1;return e>t.last_idx?0:e}function _(t,e,n){return t.idx=e&&"number"==typeof n&&n>=0&&n<=t.last_idx?n:t.idx+1,t.members[t.idx]}function g(t,e){return(e&w.SHUFFLE)==w.SHUFFLE?t.sort((function(){return Math.random()-Math.random()})):t.slice(0)}function S(t){return x(t.members,{mode:t.mode,plays:t.plays+1,sort:t.sort})}!function(t){t[t.SHUFFLE=1]="SHUFFLE",t[t.FIFO=2]="FIFO",t[t.LOOP=4]="LOOP"}(w||(w={})),function(){let t=!1;try{const e=Object.defineProperty({},"passive",{get:function(){t=!0}});window.addEventListener("testPassive",null,e),window.removeEventListener("testPassive",null,e)}catch(t){}}();const P=["touchstart","touchmove"];function q(t,e,n){const i=function(t,e){const n=new CustomEvent(t,{detail:e,cancelable:!0});return e&&Object.defineProperty(n,"data",{get:()=>e}),n}(e,n);return t.dispatchEvent(i),t}function N(t,e,n,i){Array.isArray(e)?e.forEach(e=>O(t,e,n,i)):O(t,e,n,i)}function O(t,e,n,i){if(s=e,!~P.indexOf(s))return t.addEventListener(e,n,i),t;var s;const o=Object.assign(i||{},{passive:!0});return t.addEventListener(e,n,o),t}function Y(e,n,i){const s=n.idx+n.plays<0;if(!s&&i.delay)return function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue,o=m(e,"flowplayer-playlist-interstitial");if(!o||!s||!n.delay)return;e.root.classList.add("is-interstitial");const l=s.members[I(s)];q(o,t.INTERSTITIAL_NEXT_ITEM,{next:l})}(e,i);C(e,_(n,s,i.start_index),s)}function C(e,n,i){i||(e.preload=n.preload="auto",!e.opts.autoplay&&e.setOpts({autoplay:1})),e.emit("playlist/advance"),"object"==typeof n&&e.setOpts(n),function(e,n){var i;const s=null===(i=e.playlist)||void 0===i?void 0:i.queue;if(!s)return;const o=s.idx,l=s.members[o],r=e.currentSrc;if(l.src&&e.setSrc(l.src),e.emit(t.PLAYLIST_NEXT,{next_index:o}),e.opts.autoplay||n)return;const a=n=>{("canplay"===n.type&&r!==e.currentSrc||n.type===t.PLAYLIST_NEXT)&&(e.removeEventListener("canplay",a),e.removeEventListener(t.PLAYLIST_NEXT,a),"canplay"===n.type&&e.togglePlay(!0))};e.on(["canplay",t.PLAYLIST_NEXT],a)}(e,i)}function k(e,n){return{queue:n,events:t,play:function(t){t<0||t>=n.members.length||(this.queue.idx=t,C(e,n.members[t]))},next:function(){this.queue.idx!==this.queue.last_idx&&this.play(this.queue.idx+1)},prev:function(){this.queue.idx&&this.play(this.queue.idx-1)},remove:function(n){const i=this.queue;return i.members[n]?i.idx===n?console.warn("operation failed: you cannot remove current playlist item"):(i.members.splice(n,1),i.last_idx=i.members.length-1,n<i.idx&&--i.idx,void e.emit(t.PLAYLIST_REMOVE,{index:n})):console.warn("there is no playlist item at this index")},push:function(...n){const i=e.root;if(0==this.queue.idx&&i.classList.contains("is-interstitial"))return console.warn("new items cannot be added when playlist has ended.");const s=this.queue.members;s.push(...n),this.queue.last_idx=s.length-1,e.emit(t.PLAYLIST_ADD,{members:n})},clear:function(){this.queue.members=[],this.queue.plays--,function(e,n){e.playlist&&(n=e.playlist.queue=S(n),e.emit(t.PLAYLIST_READY,{queue:n,should_play:!1}))}(e,this.queue)}}}function F(e){const n=y(e,"flowplayer-skip-previous-icon");h(n,"role","button"),N(n,"click",(function(){e.playlist&&e.playlist.prev()}));const i=y(e,"flowplayer-skip-next-icon");h(i,"role","button"),N(i,"click",(function(){e.playlist&&e.playlist.next()}));const s=E("fp-playlist-prev-preview"),o=E("fp-playlist-next-preview"),l=m(e,"flowplayer-control-buttons");return l&&(l.prepend(n),l.append(i),l.append(s),l.append(o)),e.on("reap",(function(){e.skip_controls=void 0})),e.on([t.PLAYLIST_NEXT,t.PLAYLIST_ADD,t.PLAYLIST_REMOVE],(function(t){const n=b(t,"data.queue",b(e,"playlist.queue"));if(!n||!l||!e.skip_controls)return;L(l,"is-prev-button-disabled",!n.idx),L(l,"is-next-button-disabled",n.idx===n.last_idx);const i=n.idx<n.last_idx?function(t){if(!T(t)||0!=(t.mode&w.LOOP))return t.members[I(t)]}(n):null,r=n.idx>0?function(t){if(0!==t.idx||0!=(t.mode&w.LOOP))return t.members[function(t){const e=t.idx-1;return e<0?t.last_idx:e}(t)]}(n):null;o.style.backgroundImage=["url(",i?i.poster:null,")"].join(""),s.style.backgroundImage=["url(",r?r.poster:null,")"].join("")})),{prevButton:n,nextButton:i,prevPreview:s,nextPreview:o}}function D(t,e){if(!e)return;!1!==e.skip_controls&&(t.skip_controls=F(t));const n=function(t){let e=null;if(n=t.controls,!r(n)&&!c(n))return;var n;c(t.controls)?e=t.controls:r(t.controls)&&(e=document.querySelector(t.controls));return i("Could not find controls by Selector["+t.controls+"]",c(e)),e}(e);if(!n)return;const s=y(t,"flowplayer-playlist-controls");if(n.append(s),!(s instanceof FlowplayerPlaylistControls))return;v(n,"fp-playlist-controls "+(t.opt("playlist",{}).theme||"fp-dark"));const o=t.root.className.split(" ").filter((function(t){return t.match(/^use-play/)})).pop();o&&v(n,o)}function R(t,e,n){if(Array.isArray(e))return n(function(t,e){let n=e.shuffle?w.SHUFFLE:w.FIFO;return e.loop&&(n|=w.LOOP),x(t,{mode:n,sort:e.sort})}(e,t));throw new Error("config.playlist must be an Array")}function M(e){var n;e.on(t.PLAYLIST_READY,(function(t){var n,i;const s=e.opt("playlist",{}),o=null===(n=t.detail)||void 0===n?void 0:n.queue,l=null===(i=t.detail)||void 0===i?void 0:i.should_play;o&&s&&(e.playlist=k(e,o),l&&Y(e,o,s))})),e.on("ended",(n=n=>{if(n.prevented_from_ads)return;const i=e.opt("playlist");return e.playlist&&i?T(e.playlist.queue)?function(e,n){if(e.emit(t.PLAYLIST_ENDED),!n.loop)return;if(!e.playlist)return;const i=e.playlist.queue=S(e.playlist.queue);if(e.emit(t.PLAYLIST_LOOP),!n.shuffle)return Y(e,i,n);e.emit(t.PLAYLIST_READY,{queue:i,should_play:!0})}(e,i):void(!1!==i.advance&&Y(e,e.playlist.queue,i)):void 0},t=>{setTimeout((function(){if(!t.defaultPrevented)return n(t)}),0)})),e.on(["playing","waiting","seeking","src"],(function(){if(!e.root.classList.contains("is-interstitial"))return;const n=m(e,"flowplayer-playlist-interstitial");n&&q(n,t.INTERSTITIAL_CANCEL)}))}var j;const H=((j=class Playlist{constructor(t){f(t,"flowplayer-playlist-controls",FlowplayerPlaylistControls),f(t,"flowplayer-playlist-interstitial",class extends UpNext{constructor(t){super(t),this.classList.add("fp-interstitial")}}),f(t,"flowplayer-skip-next-icon",class extends FlowplayerIcon{constructor(t){super(t,e)}}),f(t,"flowplayer-skip-previous-icon",class extends FlowplayerIcon{constructor(t){super(t,n)}})}init(e,n,i){const s=e.playlist||{};s.delay="number"==typeof s.delay?s.delay:5,i.setOpts(Object.assign(Object.assign({},e),{playlist:s})),D(i,e.playlist),function(e){var n;const i=y(e,"flowplayer-playlist-interstitial");i.addEventListener(t.INTERSTITIAL_CANCEL,()=>e.root.classList.remove("is-interstitial")),i.addEventListener(t.INTERSTITIAL_END,()=>{var t;e.root.classList.remove("is-interstitial");const n=null===(t=e.playlist)||void 0===t?void 0:t.queue;n&&C(e,_(n,!1))}),null===(n=m(e,"flowplayer-ui"))||void 0===n||n.prepend(i)}(i),M(i)}onload(e,n,i,s){R(e.playlist||{},s.items,(function(e){i.setState("is-playlist",!0),i.emit(t.PLAYLIST_READY,{queue:e,should_play:0===i.currentSrc.length})}))}wants(t,e,n){return"flowplayer/playlist"==e.type&&!!e.items&&p(Object.assign(Object.assign({},n),{playlist:e.items}))}}).events=t,j);return function(t,e){if("object"==typeof exports&&"undefined"!=typeof module)return e;if(null===document.currentScript)return e;"flowplayer"in t||(t.flowplayer={extensions:[]});const n=t.flowplayer;return"function"==typeof n?(n(e),e):(Array.isArray(n.extensions)||(n.extensions=[]),~n.extensions.indexOf(e)||n.extensions.push(e),e)}(window,H)}));