@vidispine/vdt-js 22.4.0-pre.8 → 22.4.0

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.
package/dist/index.es.js CHANGED
@@ -10,25 +10,20 @@ import parseFileSize from 'filesize';
10
10
  var gcd = function gcd(a, b) {
11
11
  return b ? gcd(b, a % b) : a;
12
12
  };
13
-
14
13
  var parseAspectRatio = function parseAspectRatio(aspectRatio) {
15
14
  var _ref = aspectRatio || {},
16
- width = _ref.width,
17
- height = _ref.height;
18
-
15
+ width = _ref.width,
16
+ height = _ref.height;
19
17
  if (width === undefined || height === undefined) {
20
18
  return undefined;
21
19
  }
22
-
23
20
  var denominator = gcd(width, height);
24
21
  var widthRatio = width / denominator;
25
22
  var heightRatio = height / denominator;
26
-
27
23
  if (widthRatio > 21) {
28
24
  heightRatio = 1;
29
25
  widthRatio = (width / height).toFixed(2);
30
26
  }
31
-
32
27
  return [widthRatio, heightRatio].join(':');
33
28
  };
34
29
 
@@ -42,7 +37,7 @@ var parseAspectRatio = function parseAspectRatio(aspectRatio) {
42
37
  var parseKeyValuePairTypes = function parseKeyValuePairTypes(keyValuePairTypes) {
43
38
  return Object.fromEntries(keyValuePairTypes.map(function (_ref) {
44
39
  var key = _ref.key,
45
- value = _ref.value;
40
+ value = _ref.value;
46
41
  return [key, value];
47
42
  }));
48
43
  };
@@ -166,26 +161,26 @@ var ROLE_NAMES = {
166
161
 
167
162
  var SHARED_ATTRIBUTE_KEYS = ['uuid', 'user', 'timestamp', 'change', 'conflict', 'mode'];
168
163
  var SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS = ['name', 'id', 'referenced', 'data', 'inheritance'];
164
+
169
165
  /**
170
166
  * Array with all available metadata group attributes
171
167
  *
172
168
  * @category Metadata
173
169
  */
174
-
175
170
  var GROUP_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['cycle', 'field', 'group']);
171
+
176
172
  /**
177
173
  * Array with all available metadata group attributes
178
174
  *
179
175
  * @category Metadata
180
176
  */
181
-
182
177
  var FIELD_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, SHARED_FIELD_AND_GROUP_ATTRIBUTE_KEYS, ['value', 'reference', 'type', 'track']);
178
+
183
179
  /**
184
180
  * Array with all available metadata field value attributes
185
181
  *
186
182
  * @category Metadata
187
183
  */
188
-
189
184
  var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, ['value', 'lang']);
190
185
 
191
186
  /**
@@ -194,84 +189,66 @@ var FIELD_VALUE_ATTRIBUTE_KEYS = [].concat(SHARED_ATTRIBUTE_KEYS, ['value', 'lan
194
189
  * @category Metadata
195
190
  */
196
191
  var SYSTEM_FIELDGROUPS = ['stl_subtitle', 'stl_tti', 'stl_gsi', 'mrk_marker', 'pho_validation', 'pho_resource', 'pho_error', 'facedetect_rect', 'facedetect_face', 'originalTrackFilename', 'stl_gsiHeader'];
192
+
197
193
  /**
198
194
  * Array with all available VidiCore system/default field group names
199
195
  *
200
196
  * @category Metadata
201
197
  */
202
-
203
198
  var SYSTEM_FIELDS = ['title', 'user', 'shapeTag', 'representativeThumbnail', 'representativeThumbnailNoAuth', 'representativeItems', 'itemId', 'collectionId', 'mediaType', 'mimeType', 'created', 'startTimeCode', 'startSeconds', 'fieldValidationError', 'schemaValidationError', 'originalFilename', 'originalUri', 'originalAudioCodec', 'originalVideoCodec', 'originalHeight', 'originalWidth', 'originalFormat', 'durationSeconds', 'durationTimeCode', 'solr-index', '__user', '__collection', '__collection_size', '__ancestor_collection', '__ancestor_collection_size', '__shape', '__shape_size', '__shape_last_added', '__placeholder_shape_size', '__version', '__version_count', '__storage', '__storage_size', '__shapetag_{tag}_hash_{hash}', '__storage_{tag}', '__storage_{tag}_size', '__storagegroup', '__storagegroup_size', '__sequence', '__sequence_size', '__metadata_last_modified', '__external_id', '__deletion_lock_id', '__deletion_lock_expiry', '__child_collection', '__child_collection_size', '__parent_collection', '__parent_collection_size', '__items_size', 'stl_text', 'stl_justification', 'stl_xrelative', 'stl_yrelative', 'stl_vertical', 'stl_verticalbase', 'stl_horizontalbase', 'stl_sizerelative', 'stl_color', 'stl_outline', 'stl_outlinecolor', 'stl_outlinesize', 'stl_font', 'stl_service', 'stl_tti', 'stl_gsi', 'cct', 'tcd', 'tcf', 'oet', 'cd', 'mnc', 'cpn', 'dfc', 'tcp', 'tcs', 'tet', 'tnb', 'tnd', 'en', 'co', 'tng', 'rd', 'mnr', 'dsc', 'opt', 'lc', 'tpt', 'tn', 'slr', 'tns', 'rn', 'pub', 'dsn', 'ecd', 'mrk_zerolength', 'mrk_text', 'mrk_color', 'pho_resource_name', 'pho_error_level', 'pho_error_code', 'pho_error_description', 'facedetect_rect_width', 'facedetect_rect_height', 'facedetect_rect_y', 'facedetect_rect_x', 'facedetect_pid', 'facedetect_rect', 'trackId', 'eidr_actor', 'eidr_alternateId', 'eidr_countryOfOrigin', 'eidr_director', 'eidr_id', 'eidr_referentType', 'eidr_releaseDate', 'eidr_resourceName', 'eidr_status', 'eidr_sync', 'ttml_div', 'ttml_root', 'vxa_collection_id', 'vxaId', 'vxaLocalPath', 'tco', 'cs', 'ebn', 'tf', 'cf', 'sgn', 'tci', 'jc', 'vp', 'sn'];
204
199
 
205
200
  var _excluded$e = ["value"],
206
- _excluded2$2 = ["start", "end", "base"];
207
-
201
+ _excluded2$2 = ["start", "end", "base"];
208
202
  function ownKeys$i(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
209
-
210
203
  function _objectSpread$i(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$i(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$i(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
211
-
212
204
  var isValueObject = function isValueObject(o) {
213
205
  return Object.prototype.toString.call(o) === '[object Object]' && o.value !== undefined;
214
206
  };
215
-
216
207
  var isFieldType = function isFieldType(v) {
217
208
  return ['string', 'boolean', 'number'].includes(_typeof(v));
218
209
  };
219
-
220
210
  var isFieldObject = function isFieldObject(o) {
221
211
  return isValueObject(o) && ((o === null || o === void 0 ? void 0 : o.value) === null || isValueObject(o.value) || isFieldType(o.value));
222
212
  };
223
-
224
213
  var isObject = function isObject(o) {
225
214
  return Object.prototype.toString.call(o) === '[object Object]';
226
215
  };
227
-
228
216
  var isDate = function isDate(o) {
229
217
  return Object.prototype.toString.call(o) === '[object Date]';
230
218
  };
231
-
232
219
  var isField = function isField(value) {
233
220
  if (value === null) {
234
221
  return true;
235
222
  }
236
-
237
223
  if (Array.isArray(value)) {
238
224
  return value.some(isField);
239
225
  }
240
-
241
226
  return isFieldType(value) || isFieldObject(value) || isDate(value);
242
227
  };
243
-
244
228
  var isGroup = function isGroup(value) {
245
229
  var isGroupObject = function isGroupObject(v) {
246
230
  return isObject(v) && v.value === undefined && !!Object.entries(value);
247
231
  };
248
-
249
232
  if (Array.isArray(value)) {
250
233
  return value.every(isGroup);
251
234
  }
252
-
253
235
  return isGroupObject(value);
254
236
  };
255
-
256
237
  var tryPluralize = function tryPluralize(str, arr) {
257
238
  return str + (arr.length > 1 ? 's' : '');
258
239
  };
259
-
260
240
  var ensureKeysAreValid = function ensureKeysAreValid(keysToCheck, keysToMatch) {
261
241
  var unsupportedKeys = keysToCheck.filter(function (k) {
262
242
  return !keysToMatch.includes(k);
263
243
  });
264
-
265
244
  if (unsupportedKeys.length) {
266
245
  throw Error("Unsupported ".concat(tryPluralize('key', unsupportedKeys), " (").concat(unsupportedKeys.join(', '), ")"));
267
246
  }
268
247
  };
269
-
270
248
  var parseValue$1 = function parseValue(value) {
271
249
  if (Array.isArray(value)) {
272
250
  throw Error('Invalid value inside value object, cannot be array');
273
251
  }
274
-
275
252
  if ([undefined, null].includes(value)) return {};
276
253
  if (isDate(value)) return {
277
254
  value: value.toISOString()
@@ -280,70 +257,55 @@ var parseValue$1 = function parseValue(value) {
280
257
  value: value.toString()
281
258
  };
282
259
  };
283
-
284
260
  var parseValueObject = function parseValueObject(valueObject) {
285
261
  ensureKeysAreValid(Object.keys(valueObject), FIELD_VALUE_ATTRIBUTE_KEYS);
286
-
287
262
  if (Object.keys(valueObject).length === 0) {
288
263
  throw Error('Invalid value object, cannot be empty object');
289
264
  }
290
-
291
265
  if (typeof (valueObject === null || valueObject === void 0 ? void 0 : valueObject.value) === 'string') {
292
266
  return valueObject;
293
267
  }
294
-
295
268
  var parsedValue = parseValue$1(valueObject === null || valueObject === void 0 ? void 0 : valueObject.value);
296
269
  return _objectSpread$i(_objectSpread$i({}, valueObject), parsedValue !== undefined ? parsedValue : {});
297
270
  };
298
-
299
271
  var parseFieldValue = function parseFieldValue(value) {
300
272
  if ([undefined, null].includes(value)) return undefined;
301
273
  if (Array.isArray(value)) return value.flatMap(parseFieldValue);
302
274
  if (isValueObject(value)) return parseValueObject(value);
303
275
  return parseValue$1(value);
304
276
  };
305
-
306
277
  var parseFieldObject = function parseFieldObject(fieldObject) {
307
278
  ensureKeysAreValid(Object.keys(fieldObject), FIELD_ATTRIBUTE_KEYS);
308
279
  var parsedFieldValue = parseFieldValue(fieldObject === null || fieldObject === void 0 ? void 0 : fieldObject.value);
309
-
310
280
  if (parsedFieldValue === undefined) {
311
281
  fieldObject.value;
312
- var fieldObjectWithoutValue = _objectWithoutProperties(fieldObject, _excluded$e);
313
-
282
+ var fieldObjectWithoutValue = _objectWithoutProperties(fieldObject, _excluded$e);
314
283
  return fieldObjectWithoutValue;
315
284
  }
316
-
317
285
  return _objectSpread$i(_objectSpread$i({}, fieldObject), {}, {
318
286
  value: _toConsumableArray(Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
319
287
  });
320
288
  };
321
-
322
289
  var parseField$1 = function parseField(field) {
323
290
  if (isFieldObject(field)) {
324
291
  return parseFieldObject(field);
325
292
  }
326
-
327
293
  var parsedFieldValue = parseFieldValue(field);
328
-
329
294
  if (parsedFieldValue === undefined) {
330
295
  return undefined;
331
296
  }
332
-
333
297
  return {
334
298
  value: _toConsumableArray(Array.isArray(parsedFieldValue) ? parsedFieldValue : [parsedFieldValue])
335
299
  };
336
300
  };
337
-
338
301
  var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
339
302
  var group = [];
340
303
  var field = [];
341
304
  var groupAttributes = {};
342
305
  Object.entries(groupOrField || {}).forEach(function (_ref) {
343
306
  var _ref2 = _slicedToArray(_ref, 2),
344
- name = _ref2[0],
345
- value = _ref2[1];
346
-
307
+ name = _ref2[0],
308
+ value = _ref2[1];
347
309
  if (GROUP_ATTRIBUTE_KEYS.includes(name)) {
348
310
  groupAttributes = _objectSpread$i(_objectSpread$i({}, groupAttributes), {}, _defineProperty({}, name, value));
349
311
  } else if (isField(value)) {
@@ -370,20 +332,17 @@ var parseGroupsAndFields = function parseGroupsAndFields(groupOrField) {
370
332
  field: field
371
333
  } : {});
372
334
  };
373
-
374
335
  var parseTimespan$1 = function parseTimespan(timespan) {
375
336
  var _timespan$start = timespan.start,
376
- start = _timespan$start === void 0 ? '-INF' : _timespan$start,
377
- _timespan$end = timespan.end,
378
- end = _timespan$end === void 0 ? '+INF' : _timespan$end,
379
- _timespan$base = timespan.base,
380
- base = _timespan$base === void 0 ? undefined : _timespan$base,
381
- groupsAndFields = _objectWithoutProperties(timespan, _excluded2$2);
382
-
337
+ start = _timespan$start === void 0 ? '-INF' : _timespan$start,
338
+ _timespan$end = timespan.end,
339
+ end = _timespan$end === void 0 ? '+INF' : _timespan$end,
340
+ _timespan$base = timespan.base,
341
+ base = _timespan$base === void 0 ? undefined : _timespan$base,
342
+ groupsAndFields = _objectWithoutProperties(timespan, _excluded2$2);
383
343
  var _parseGroupsAndFields = parseGroupsAndFields(groupsAndFields),
384
- group = _parseGroupsAndFields.group,
385
- field = _parseGroupsAndFields.field;
386
-
344
+ group = _parseGroupsAndFields.group,
345
+ field = _parseGroupsAndFields.field;
387
346
  return _objectSpread$i(_objectSpread$i(_objectSpread$i({}, group ? {
388
347
  group: group
389
348
  } : {}), field ? {
@@ -395,7 +354,6 @@ var parseTimespan$1 = function parseTimespan(timespan) {
395
354
  base: base
396
355
  } : {});
397
356
  };
398
-
399
357
  /**
400
358
  * Create a VidiCore metadata object from a more dense/simplified structure
401
359
  *
@@ -427,23 +385,18 @@ var createMetadataType = function createMetadataType(input) {
427
385
  */
428
386
  var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
429
387
  var _timespan1$start, _timespan2$start;
430
-
431
388
  var _ref = (timespan1 === null || timespan1 === void 0 ? void 0 : (_timespan1$start = timespan1.start) === null || _timespan1$start === void 0 ? void 0 : _timespan1$start.split('@')) || [],
432
- _ref2 = _slicedToArray(_ref, 1),
433
- firstStart = _ref2[0];
434
-
389
+ _ref2 = _slicedToArray(_ref, 1),
390
+ firstStart = _ref2[0];
435
391
  var _ref3 = (timespan2 === null || timespan2 === void 0 ? void 0 : (_timespan2$start = timespan2.start) === null || _timespan2$start === void 0 ? void 0 : _timespan2$start.split('@')) || [],
436
- _ref4 = _slicedToArray(_ref3, 1),
437
- secondStart = _ref4[0];
438
-
392
+ _ref4 = _slicedToArray(_ref3, 1),
393
+ secondStart = _ref4[0];
439
394
  if (Number(firstStart) < Number(secondStart)) {
440
395
  return -1;
441
396
  }
442
-
443
397
  if (Number(firstStart) > Number(secondStart)) {
444
398
  return 1;
445
399
  }
446
-
447
400
  return 0;
448
401
  };
449
402
 
@@ -455,10 +408,10 @@ var sortTimespanList = function sortTimespanList(timespan1, timespan2) {
455
408
  * @param v value to return as array
456
409
  * @returns input value wrapped as array
457
410
  */
458
-
459
411
  var asArray = function asArray(v) {
460
412
  return Array.isArray(v) ? v : v && [v] || [];
461
413
  };
414
+
462
415
  /**
463
416
  * @private
464
417
  *
@@ -467,10 +420,10 @@ var asArray = function asArray(v) {
467
420
  * @param v value to return as array
468
421
  * @returns input value wrapped as array
469
422
  */
470
-
471
423
  var asSingle = function asSingle(v) {
472
424
  return Array.isArray(v) ? v.pop() : v;
473
425
  };
426
+
474
427
  /**
475
428
  * @private
476
429
  * Check if array is string array (+ type guard)
@@ -478,7 +431,6 @@ var asSingle = function asSingle(v) {
478
431
  * @param arr Array to check if string array
479
432
  * @returns true if string array
480
433
  */
481
-
482
434
  var isStringArray = function isStringArray(arr) {
483
435
  return (arr === null || arr === void 0 ? void 0 : arr.every(function (v) {
484
436
  return typeof v === 'string';
@@ -486,14 +438,12 @@ var isStringArray = function isStringArray(arr) {
486
438
  };
487
439
 
488
440
  var _excluded$d = ["value"];
489
-
490
441
  function ownKeys$h(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
491
-
492
442
  function _objectSpread$h(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$h(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$h(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
493
-
494
443
  var defaultOptions$a = {
495
444
  includeValueAttributes: false
496
445
  };
446
+
497
447
  /**
498
448
  * @internal
499
449
  * Parse the value object inside a field value list
@@ -502,22 +452,17 @@ var defaultOptions$a = {
502
452
  * @param options For how to parse the value object
503
453
  * @returns The parsed value
504
454
  */
505
-
506
455
  function parseValue(value, options) {
507
456
  var _defaultOptions = _objectSpread$h(_objectSpread$h({}, defaultOptions$a), options || {}),
508
- includeValueAttributes = _defaultOptions.includeValueAttributes;
509
-
457
+ includeValueAttributes = _defaultOptions.includeValueAttributes;
510
458
  if (includeValueAttributes === false) {
511
459
  return value === null || value === void 0 ? void 0 : value.value;
512
460
  }
513
-
514
461
  var stringValue = value.value,
515
- attributes = _objectWithoutProperties(value, _excluded$d);
516
-
462
+ attributes = _objectWithoutProperties(value, _excluded$d);
517
463
  var valueAttributes = includeValueAttributes === true && attributes || Array.isArray(includeValueAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref) {
518
464
  var _ref2 = _slicedToArray(_ref, 1),
519
- key = _ref2[0];
520
-
465
+ key = _ref2[0];
521
466
  return includeValueAttributes.includes(key);
522
467
  })) || {};
523
468
  return _objectSpread$h(_objectSpread$h({}, valueAttributes), {}, {
@@ -526,14 +471,13 @@ function parseValue(value, options) {
526
471
  }
527
472
 
528
473
  var _excluded$c = ["joinValue", "arrayOnSingleValue"];
529
-
530
474
  function ownKeys$g(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
531
-
532
475
  function _objectSpread$g(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$g(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$g(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
533
476
  var defaultOptions$9 = _objectSpread$g(_objectSpread$g({}, defaultOptions$a), {}, {
534
477
  joinValue: undefined,
535
478
  arrayOnSingleValue: true
536
479
  });
480
+
537
481
  /**
538
482
  * @internal
539
483
  *
@@ -541,13 +485,11 @@ var defaultOptions$9 = _objectSpread$g(_objectSpread$g({}, defaultOptions$a), {}
541
485
  * @param options
542
486
  * @returns
543
487
  */
544
-
545
488
  function parseValueList(valueList, options) {
546
489
  var _defaultOptions = _objectSpread$g(_objectSpread$g({}, defaultOptions$9), options || {}),
547
- joinValue = _defaultOptions.joinValue,
548
- arrayOnSingleValue = _defaultOptions.arrayOnSingleValue,
549
- parseValueOptions = _objectWithoutProperties(_defaultOptions, _excluded$c);
550
-
490
+ joinValue = _defaultOptions.joinValue,
491
+ arrayOnSingleValue = _defaultOptions.arrayOnSingleValue,
492
+ parseValueOptions = _objectWithoutProperties(_defaultOptions, _excluded$c);
551
493
  var parsedValueList = valueList === null || valueList === void 0 ? void 0 : valueList.map(function (v) {
552
494
  return parseValue(v, parseValueOptions);
553
495
  });
@@ -557,14 +499,13 @@ function parseValueList(valueList, options) {
557
499
  }
558
500
 
559
501
  var _excluded$b = ["includeFieldAttributes"],
560
- _excluded2$1 = ["value"];
561
-
502
+ _excluded2$1 = ["value"];
562
503
  function ownKeys$f(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
563
-
564
504
  function _objectSpread$f(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$f(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$f(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
565
505
  var defaultOptions$8 = _objectSpread$f({
566
506
  includeFieldAttributes: false
567
507
  }, defaultOptions$9);
508
+
568
509
  /**
569
510
  * @internal
570
511
  *
@@ -572,20 +513,16 @@ var defaultOptions$8 = _objectSpread$f({
572
513
  * @param options
573
514
  * @returns
574
515
  */
575
-
576
516
  var parseField = function parseField(field, options) {
577
517
  var _defaultOptions = _objectSpread$f(_objectSpread$f({}, defaultOptions$8), options || {}),
578
- includeFieldAttributes = _defaultOptions.includeFieldAttributes,
579
- parseValueListOptions = _objectWithoutProperties(_defaultOptions, _excluded$b);
580
-
518
+ includeFieldAttributes = _defaultOptions.includeFieldAttributes,
519
+ parseValueListOptions = _objectWithoutProperties(_defaultOptions, _excluded$b);
581
520
  var value = field.value,
582
- attributes = _objectWithoutProperties(field, _excluded2$1);
583
-
521
+ attributes = _objectWithoutProperties(field, _excluded2$1);
584
522
  var parsedValueList = parseValueList(value, parseValueListOptions);
585
523
  var fieldAttributes = includeFieldAttributes === true && attributes || Array.isArray(includeFieldAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref) {
586
524
  var _ref2 = _slicedToArray(_ref, 1),
587
- key = _ref2[0];
588
-
525
+ key = _ref2[0];
589
526
  return includeFieldAttributes.includes(key);
590
527
  })) || {};
591
528
  return includeFieldAttributes ? _objectSpread$f(_objectSpread$f({}, fieldAttributes), {}, {
@@ -594,25 +531,22 @@ var parseField = function parseField(field, options) {
594
531
  };
595
532
 
596
533
  function ownKeys$e(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
597
-
598
534
  function _objectSpread$e(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$e(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$e(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
599
535
  var defaultOptions$7 = _objectSpread$e(_objectSpread$e({}, defaultOptions$8), {}, {
600
536
  fieldAsList: false,
601
537
  arrayOnSingleField: false,
602
538
  overrideField: undefined
603
539
  });
604
-
605
540
  /**
606
541
  * Parse a metadata field list according to selected options
607
542
  *
608
543
  * @remarks
609
- * Duplicate fields (same field name in the same field list) are usually not the data model we'd advise using.
610
- * Since VidiCore supports multiple values in one fields, it's typically advised to store them as such.
611
- * But, given duplicated fields when parsing it will:
612
- * - with default options, merge duplicated field values to one field value array
613
- * - with `fieldAsList` enabled, separate fields in the list/array (as usual, even if not duplicate)
614
- * - with `includeFieldAttributes` enabled, return an array of field objects
615
- * - with `overrideField` enabled - Override so it returns the latest "duplicated" field it parses
544
+ * When parsing duplicate fields (same field name in the same field list) it will:
545
+ * - with default options: combine field values to one array within the same field name key
546
+ * - with `joinValue` enabled: join values within each field (returns array with string for each field value)
547
+ * - with `fieldAsList` enabled: separate fields in the list/array (as usual, even if not duplicate)
548
+ * - with `includeFieldAttributes` enabled: return an array of field objects
549
+ * - with `overrideField` enabled: return the latest duplicated field it parses
616
550
  *
617
551
  * @param fieldList Field list to parse
618
552
  * @param [options=defaultOptions] Options for how to parse the field list
@@ -622,10 +556,9 @@ var defaultOptions$7 = _objectSpread$e(_objectSpread$e({}, defaultOptions$8), {}
622
556
  */
623
557
  var parseFieldList = function parseFieldList(fieldList, options) {
624
558
  var parseFieldListOptions = _objectSpread$e(_objectSpread$e({}, defaultOptions$7), options || {});
625
-
626
559
  var fieldAsList = parseFieldListOptions.fieldAsList,
627
- arrayOnSingleField = parseFieldListOptions.arrayOnSingleField,
628
- overrideField = parseFieldListOptions.overrideField;
560
+ arrayOnSingleField = parseFieldListOptions.arrayOnSingleField,
561
+ overrideField = parseFieldListOptions.overrideField;
629
562
  var shouldOverride = overrideField === true && fieldAsList === false;
630
563
  var output = {};
631
564
  fieldList === null || fieldList === void 0 ? void 0 : fieldList.forEach(function (field) {
@@ -639,18 +572,14 @@ var parseFieldList = function parseFieldList(fieldList, options) {
639
572
  };
640
573
 
641
574
  var _excluded$a = ["field", "group"];
642
-
643
575
  function ownKeys$d(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
644
-
645
576
  function _objectSpread$d(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$d(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$d(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
646
-
647
577
  var defaultParseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOptions$7), {}, {
648
578
  includeGroupAttributes: false,
649
579
  groupAsList: false,
650
580
  arrayOnSingleGroup: false,
651
581
  overrideGroup: undefined
652
582
  });
653
-
654
583
  /**
655
584
  * @internal
656
585
  *
@@ -662,26 +591,21 @@ var defaultParseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOption
662
591
  */
663
592
  var parseGroup = function parseGroup(group, options) {
664
593
  var parseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultParseGroupOptions), options || {});
665
-
666
594
  var includeGroupAttributes = parseGroupOptions.includeGroupAttributes;
667
595
  var parseFieldListOptions = Object.fromEntries(Object.entries(parseGroupOptions).filter(function (_ref) {
668
596
  var _ref2 = _slicedToArray(_ref, 1),
669
- key = _ref2[0];
670
-
597
+ key = _ref2[0];
671
598
  return Object.keys(defaultOptions$7).includes(key);
672
599
  }));
673
-
674
600
  var fieldList = group.field,
675
- groupList = group.group,
676
- attributes = _objectWithoutProperties(group, _excluded$a);
677
-
678
- var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions); // eslint-disable-next-line @typescript-eslint/no-use-before-define
679
-
601
+ groupList = group.group,
602
+ attributes = _objectWithoutProperties(group, _excluded$a);
603
+ var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions);
604
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
680
605
  var parsedGroupList = groupList && parseGroupList(groupList, parseGroupOptions);
681
606
  var groupAttributes = includeGroupAttributes === true && attributes || Array.isArray(includeGroupAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref3) {
682
607
  var _ref4 = _slicedToArray(_ref3, 1),
683
- key = _ref4[0];
684
-
608
+ key = _ref4[0];
685
609
  return includeGroupAttributes.includes(key);
686
610
  })) || {};
687
611
  return _objectSpread$d(_objectSpread$d(_objectSpread$d({}, groupAttributes), parseFieldListOptions !== null && parseFieldListOptions !== void 0 && parseFieldListOptions.fieldAsList ? parsedFieldList && {
@@ -690,16 +614,16 @@ var parseGroup = function parseGroup(group, options) {
690
614
  group: parsedGroupList
691
615
  } || {} : parsedGroupList);
692
616
  };
693
-
694
617
  var defaultOptions$6 = defaultParseGroupOptions;
618
+
695
619
  /**
696
620
  * Parse a metadata group list according to selected options
697
621
  *
698
622
  * @remarks
699
- * Parsing duplicate groups (with identical name) in the same group list will return:
700
- * - with default options, an array of group objects
701
- * - with `groupAsList` enabled, separate group objects in the list/array (as usual, even if not duplicate)
702
- * - with `overrideGroup` enabled, return the latest duplicated group it parses
623
+ * Parsing duplicate groups (same group name in the same group list) it will:
624
+ * - with default options: combine group objects to one array within the same group name key
625
+ * - with `groupAsList` enabled: return separate group objects in a list/array (as usual, even if not duplicate)
626
+ * - with `overrideGroup` enabled: return the latest duplicated group it parses
703
627
  *
704
628
  * @param groupList Group list to parse
705
629
  * @param options options for how to parse list
@@ -707,13 +631,11 @@ var defaultOptions$6 = defaultParseGroupOptions;
707
631
  *
708
632
  * @category Metadata
709
633
  */
710
-
711
634
  var parseGroupList = function parseGroupList(groupList, options) {
712
635
  var parseGroupOptions = _objectSpread$d(_objectSpread$d({}, defaultOptions$6), options || {});
713
-
714
636
  var groupAsList = parseGroupOptions.groupAsList,
715
- arrayOnSingleGroup = parseGroupOptions.arrayOnSingleGroup,
716
- overrideGroup = parseGroupOptions.overrideGroup;
637
+ arrayOnSingleGroup = parseGroupOptions.arrayOnSingleGroup,
638
+ overrideGroup = parseGroupOptions.overrideGroup;
717
639
  var shouldOverride = overrideGroup === true && groupAsList === false;
718
640
  var output = {};
719
641
  groupList === null || groupList === void 0 ? void 0 : groupList.forEach(function (group) {
@@ -723,18 +645,14 @@ var parseGroupList = function parseGroupList(groupList, options) {
723
645
  var existingParsedGroups = output[name];
724
646
  if (!existingParsedGroups) output[name] = parsedGroupOutput;else if (shouldOverride) output[name] = parsedGroup;else output[name] = [asArray(existingParsedGroups), asArray(parsedGroup)].flat();
725
647
  });
726
-
727
648
  if (groupAsList) {
728
649
  return Object.values(output).flat();
729
650
  }
730
-
731
651
  return output;
732
652
  };
733
653
 
734
654
  var _excluded$9 = ["field", "group"];
735
-
736
655
  function ownKeys$c(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
737
-
738
656
  function _objectSpread$c(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$c(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$c(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
739
657
  var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}, {
740
658
  includeTimespanAttributes: false,
@@ -744,6 +662,7 @@ var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}
744
662
  arrayOnSingleGroup: undefined,
745
663
  arrayOnSingleField: undefined
746
664
  });
665
+
747
666
  /**
748
667
  *
749
668
  * Parses timespan according to specified options
@@ -759,68 +678,55 @@ var defaultOptions$5 = _objectSpread$c(_objectSpread$c({}, defaultOptions$6), {}
759
678
  *
760
679
  * @category Metadata
761
680
  */
762
-
763
681
  var parseTimespan = function parseTimespan(timespan, options) {
764
682
  var parseTimespanOptions = _objectSpread$c(_objectSpread$c({}, defaultOptions$5), options || {});
765
-
766
683
  var includeTimespanAttributes = parseTimespanOptions.includeTimespanAttributes,
767
- arrayOnSingle = parseTimespanOptions.arrayOnSingle,
768
- flat = parseTimespanOptions.flat;
684
+ arrayOnSingle = parseTimespanOptions.arrayOnSingle,
685
+ flat = parseTimespanOptions.flat;
769
686
  var parseGroupListOptions = Object.fromEntries(Object.entries(options).map(function (_ref) {
770
687
  var _ref2 = _slicedToArray(_ref, 2),
771
- key = _ref2[0],
772
- value = _ref2[1];
773
-
688
+ key = _ref2[0],
689
+ value = _ref2[1];
774
690
  if (Object.keys(defaultOptions$6).includes(key)) {
775
691
  if (['arrayOnSingleGroup', 'arrayOnSingleField', 'arrayOnSingleValue'].includes(key) && (value !== undefined ? value : arrayOnSingle === true)) {
776
692
  return [key, true];
777
693
  }
778
-
779
694
  if (['overrideGroup', 'overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
780
695
  return [key, true];
781
696
  }
782
-
783
697
  return [key, value];
784
698
  }
785
-
786
699
  return undefined;
787
700
  }).filter(function (e) {
788
701
  return !!e;
789
702
  }));
790
703
  var parseFieldListOptions = Object.fromEntries(Object.entries(options).map(function (_ref3) {
791
704
  var _ref4 = _slicedToArray(_ref3, 2),
792
- key = _ref4[0],
793
- value = _ref4[1];
794
-
705
+ key = _ref4[0],
706
+ value = _ref4[1];
795
707
  if (Object.keys(defaultOptions$7).includes(key)) {
796
708
  if (['arrayOnSingleField', 'arrayOnSingleValue'].includes(key) && (value !== undefined ? value : arrayOnSingle === true)) {
797
709
  return [key, true];
798
710
  }
799
-
800
711
  if (['overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
801
712
  return [key, true];
802
713
  }
803
-
804
714
  return [key, value];
805
715
  }
806
-
807
716
  return undefined;
808
717
  }).filter(function (e) {
809
718
  return !!e;
810
719
  }));
811
-
812
720
  var _ref5 = timespan || {},
813
- fieldList = _ref5.field,
814
- groupList = _ref5.group,
815
- attributes = _objectWithoutProperties(_ref5, _excluded$9);
816
-
817
- var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions); // eslint-disable-next-line @typescript-eslint/no-use-before-define
818
-
721
+ fieldList = _ref5.field,
722
+ groupList = _ref5.group,
723
+ attributes = _objectWithoutProperties(_ref5, _excluded$9);
724
+ var parsedFieldList = fieldList && parseFieldList(fieldList, parseFieldListOptions);
725
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
819
726
  var parsedGroupList = groupList && parseGroupList(groupList, parseGroupListOptions);
820
727
  var timespanAttributes = includeTimespanAttributes === true && attributes || Array.isArray(includeTimespanAttributes) && Object.fromEntries(Object.entries(attributes).filter(function (_ref6) {
821
728
  var _ref7 = _slicedToArray(_ref6, 1),
822
- key = _ref7[0];
823
-
729
+ key = _ref7[0];
824
730
  return includeTimespanAttributes.includes(key);
825
731
  })) || {};
826
732
  return _objectSpread$c(_objectSpread$c(_objectSpread$c({}, timespanAttributes), parseFieldListOptions !== null && parseFieldListOptions !== void 0 && parseFieldListOptions.fieldAsList ? {
@@ -831,9 +737,7 @@ var parseTimespan = function parseTimespan(timespan, options) {
831
737
  };
832
738
 
833
739
  var _excluded$8 = ["timespanAsList", "joinTimespan", "sortTimespan", "flat", "flatTimespan"];
834
-
835
740
  function ownKeys$b(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
836
-
837
741
  function _objectSpread$b(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$b(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$b(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
838
742
  var defaultOptions$4 = _objectSpread$b(_objectSpread$b({}, defaultOptions$5), {}, {
839
743
  timespanAsList: false,
@@ -854,27 +758,23 @@ var defaultOptions$4 = _objectSpread$b(_objectSpread$b({}, defaultOptions$5), {}
854
758
  *
855
759
  * @category Metadata
856
760
  */
857
-
858
761
  var parseTimespanList = function parseTimespanList(timespanList, options) {
859
762
  var parseTimespanListOptions = _objectSpread$b(_objectSpread$b({}, defaultOptions$4), options || {});
860
-
861
763
  var timespanAsList = parseTimespanListOptions.timespanAsList,
862
- joinTimespan = parseTimespanListOptions.joinTimespan,
863
- sortTimespan = parseTimespanListOptions.sortTimespan,
864
- flat = parseTimespanListOptions.flat,
865
- flatTimespan = parseTimespanListOptions.flatTimespan,
866
- otherOptions = _objectWithoutProperties(parseTimespanListOptions, _excluded$8);
867
-
764
+ joinTimespan = parseTimespanListOptions.joinTimespan,
765
+ sortTimespan = parseTimespanListOptions.sortTimespan,
766
+ flat = parseTimespanListOptions.flat,
767
+ flatTimespan = parseTimespanListOptions.flatTimespan,
768
+ otherOptions = _objectWithoutProperties(parseTimespanListOptions, _excluded$8);
868
769
  var parseTimespanOptions = _objectSpread$b({
869
770
  flat: flat
870
771
  }, otherOptions);
871
-
872
772
  if (sortTimespan) timespanList.sort(sortTimespanList);
873
773
  var shouldFlatten = (flatTimespan !== undefined ? flatTimespan === true : flat === true) && timespanAsList === false;
874
774
  var output = {};
875
775
  timespanList === null || timespanList === void 0 ? void 0 : timespanList.forEach(function (timespan) {
876
776
  var start = timespan.start,
877
- end = timespan.end;
777
+ end = timespan.end;
878
778
  var key = shouldFlatten ? 'flat' : [start, end].join(joinTimespan);
879
779
  var parsedTimespan = parseTimespan(timespan, parseTimespanOptions);
880
780
  var existingParsedTimespans = output[key];
@@ -886,27 +786,23 @@ var parseTimespanList = function parseTimespanList(timespanList, options) {
886
786
  }
887
787
  } else output[key] = [].concat(_toConsumableArray(asArray(existingParsedTimespans)), [parsedTimespan]);
888
788
  });
889
-
890
789
  if (timespanAsList === true) {
891
790
  return Object.values(output);
892
791
  }
893
-
894
792
  if (shouldFlatten) {
895
793
  return Object.values(output).pop();
896
794
  }
897
-
898
795
  return output;
899
796
  };
900
797
 
901
798
  var _excluded$7 = ["timespan"];
902
-
903
799
  function ownKeys$a(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
904
-
905
800
  function _objectSpread$a(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$a(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$a(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
906
801
  var defaultOptions$3 = _objectSpread$a(_objectSpread$a({}, defaultOptions$4), {}, {
907
802
  includeMetadataAttributes: false,
908
803
  flat: false
909
804
  });
805
+
910
806
  /**
911
807
  * Parses MetadataType according to specified options
912
808
  *
@@ -923,31 +819,24 @@ var defaultOptions$3 = _objectSpread$a(_objectSpread$a({}, defaultOptions$4), {}
923
819
  *
924
820
  * @category Metadata
925
821
  */
926
-
927
822
  function parseMetadataType(metadataType, options) {
928
823
  var parseMetadataTypeOptions = _objectSpread$a(_objectSpread$a({}, defaultOptions$3), options || {});
929
-
930
824
  var includeMetadataAttributes = parseMetadataTypeOptions.includeMetadataAttributes,
931
- flat = parseMetadataTypeOptions.flat;
932
-
825
+ flat = parseMetadataTypeOptions.flat;
933
826
  var _ref = metadataType || {},
934
- _ref$timespan = _ref.timespan,
935
- timespanList = _ref$timespan === void 0 ? [] : _ref$timespan,
936
- attributes = _objectWithoutProperties(_ref, _excluded$7);
937
-
827
+ _ref$timespan = _ref.timespan,
828
+ timespanList = _ref$timespan === void 0 ? [] : _ref$timespan,
829
+ attributes = _objectWithoutProperties(_ref, _excluded$7);
938
830
  var parseTimespanListOptions = Object.fromEntries(Object.entries(options).map(function (_ref2) {
939
831
  var _ref3 = _slicedToArray(_ref2, 2),
940
- key = _ref3[0],
941
- value = _ref3[1];
942
-
832
+ key = _ref3[0],
833
+ value = _ref3[1];
943
834
  if (Object.keys(defaultOptions$4).includes(key)) {
944
835
  if (['onlyGeneric', 'overrideGroup', 'overrideField'].includes(key) && (value !== undefined ? value : flat === true)) {
945
836
  return [key, true];
946
837
  }
947
-
948
838
  return [key, value];
949
839
  }
950
-
951
840
  return undefined;
952
841
  }).filter(function (e) {
953
842
  return !!e;
@@ -957,13 +846,11 @@ function parseMetadataType(metadataType, options) {
957
846
  revision: attributes.revision.split(',')
958
847
  } : {}) || Array.isArray(includeMetadataAttributes) && Object.fromEntries(Object.entries(attributes).map(function (_ref4) {
959
848
  var _ref5 = _slicedToArray(_ref4, 2),
960
- key = _ref5[0],
961
- value = _ref5[1];
962
-
849
+ key = _ref5[0],
850
+ value = _ref5[1];
963
851
  if (includeMetadataAttributes.includes(key)) {
964
852
  return [key, key === 'revision' && typeof value === 'string' ? value.split(',') : value];
965
853
  }
966
-
967
854
  return undefined;
968
855
  }).filter(function (o) {
969
856
  return !!o;
@@ -983,12 +870,10 @@ function parseMetadataType(metadataType, options) {
983
870
  *
984
871
  * @category Metadata
985
872
  */
986
-
987
873
  var parseSimpleMetadataType = function parseSimpleMetadataType(simpleMetadataType) {
988
874
  var _ref = simpleMetadataType || {},
989
- _ref$field = _ref.field,
990
- field = _ref$field === void 0 ? [] : _ref$field;
991
-
875
+ _ref$field = _ref.field,
876
+ field = _ref$field === void 0 ? [] : _ref$field;
992
877
  return parseKeyValuePairTypes(field);
993
878
  };
994
879
 
@@ -1033,6 +918,7 @@ var TIME_BASE_CONSTANTS = Object.keys(MAP_CONSTANT_TO_DEN_NUM);
1033
918
  */
1034
919
  var TimeBase = /*#__PURE__*/function () {
1035
920
  // The numerator for the TimeBase
921
+
1036
922
  // The denominator for the TimeBase
1037
923
 
1038
924
  /**
@@ -1042,50 +928,42 @@ var TimeBase = /*#__PURE__*/function () {
1042
928
  */
1043
929
  function TimeBase(timeBaseType) {
1044
930
  _classCallCheck(this, TimeBase);
1045
-
1046
931
  _defineProperty(this, "numerator", 1);
1047
-
1048
932
  _defineProperty(this, "denominator", 1);
1049
-
1050
933
  var _ref = timeBaseType || {},
1051
- _ref$numerator = _ref.numerator,
1052
- numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
1053
- _ref$denominator = _ref.denominator,
1054
- denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
1055
-
934
+ _ref$numerator = _ref.numerator,
935
+ numerator = _ref$numerator === void 0 ? 1 : _ref$numerator,
936
+ _ref$denominator = _ref.denominator,
937
+ denominator = _ref$denominator === void 0 ? 1 : _ref$denominator;
1056
938
  this.numerator = Number(numerator);
1057
939
  this.denominator = Number(denominator);
1058
940
  }
941
+
1059
942
  /**
1060
943
  * Get TimeBase in a constant representation (e.g. "PAL") if possible, otherwise undefined
1061
944
  * @returns Constant representation of the TimeBase
1062
945
  */
1063
-
1064
-
1065
946
  _createClass(TimeBase, [{
1066
947
  key: "toConstant",
1067
948
  value: function toConstant() {
1068
949
  var _this = this;
1069
-
1070
- var constant; // If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
1071
-
950
+ var constant;
951
+ // If multiple equal den/num, it selects first in MAP_CONSTANT_TO_DEN_NUM
1072
952
  Object.entries(MAP_CONSTANT_TO_DEN_NUM).find(function (timeBaseConstant) {
1073
953
  var _timeBaseConstant = _slicedToArray(timeBaseConstant, 2),
1074
- thisTimeBaseText = _timeBaseConstant[0],
1075
- thisTimeBaseType = _timeBaseConstant[1];
1076
-
954
+ thisTimeBaseText = _timeBaseConstant[0],
955
+ thisTimeBaseType = _timeBaseConstant[1];
1077
956
  var numerator = thisTimeBaseType.numerator,
1078
- denominator = thisTimeBaseType.denominator;
1079
-
957
+ denominator = thisTimeBaseType.denominator;
1080
958
  if (numerator === _this.numerator && denominator === _this.denominator) {
1081
959
  constant = thisTimeBaseText;
1082
960
  return true;
1083
961
  }
1084
-
1085
962
  return false;
1086
963
  });
1087
964
  return constant;
1088
965
  }
966
+
1089
967
  /**
1090
968
  * Get TimeBase as a VidiCore TimeBaseType string
1091
969
  *
@@ -1096,25 +974,21 @@ var TimeBase = /*#__PURE__*/function () {
1096
974
  * @param options For how to display it as text
1097
975
  * @returns Text representation of the TimeBase
1098
976
  */
1099
-
1100
977
  }, {
1101
978
  key: "toText",
1102
979
  value: function toText(options) {
1103
980
  if (options !== null && options !== void 0 && options.constant) {
1104
981
  var _timeBaseText = this.toConstant();
1105
-
1106
982
  if (_timeBaseText) return _timeBaseText;
1107
983
  }
1108
-
1109
984
  if (options !== null && options !== void 0 && options.fraction || this.numerator > 1) {
1110
985
  var _timeBaseText2 = [this.denominator, this.numerator].join(':');
1111
-
1112
986
  return _timeBaseText2;
1113
987
  }
1114
-
1115
988
  var timeBaseText = String(this.denominator);
1116
989
  return timeBaseText;
1117
990
  }
991
+
1118
992
  /**
1119
993
  * Output TimeBase as frame rate (by default max 16 decimal places)
1120
994
  *
@@ -1133,36 +1007,30 @@ var TimeBase = /*#__PURE__*/function () {
1133
1007
  *
1134
1008
  * @category Time
1135
1009
  */
1136
-
1137
1010
  }, {
1138
1011
  key: "toRate",
1139
1012
  value: function toRate(options) {
1140
1013
  var rate = this.denominator / this.numerator;
1141
-
1142
1014
  if (Number.isInteger(rate)) {
1143
1015
  return rate;
1144
1016
  }
1145
-
1146
1017
  if (options !== null && options !== void 0 && options.rounded) {
1147
1018
  return Math.round(rate);
1148
1019
  }
1149
-
1150
1020
  var _ref2 = options || {},
1151
- _ref2$fixed = _ref2.fixed,
1152
- fixed = _ref2$fixed === void 0 ? true : _ref2$fixed;
1153
-
1021
+ _ref2$fixed = _ref2.fixed,
1022
+ fixed = _ref2$fixed === void 0 ? true : _ref2$fixed;
1154
1023
  if (fixed === true || typeof fixed === 'number') {
1155
1024
  return Number(rate.toFixed(typeof fixed === 'boolean' ? 2 : fixed));
1156
1025
  }
1157
-
1158
1026
  return rate;
1159
1027
  }
1028
+
1160
1029
  /**
1161
1030
  * Get TimeBase in a object representation
1162
1031
  *
1163
1032
  * @returns TimeBase as `{denominator, numerator}` object
1164
1033
  */
1165
-
1166
1034
  }, {
1167
1035
  key: "toObject",
1168
1036
  value: function toObject() {
@@ -1171,12 +1039,12 @@ var TimeBase = /*#__PURE__*/function () {
1171
1039
  numerator: this.numerator
1172
1040
  };
1173
1041
  }
1042
+
1174
1043
  /**
1175
1044
  * @deprecated Use {@link TimeBase#toObject | toObject} instead
1176
1045
  *
1177
1046
  * @returns TimeBase as `{denominator, numerator}` object
1178
1047
  */
1179
-
1180
1048
  }, {
1181
1049
  key: "toJson",
1182
1050
  value: function toJson() {
@@ -1185,7 +1053,6 @@ var TimeBase = /*#__PURE__*/function () {
1185
1053
  return this.toObject();
1186
1054
  }
1187
1055
  }]);
1188
-
1189
1056
  return TimeBase;
1190
1057
  }();
1191
1058
 
@@ -1197,38 +1064,31 @@ var TimeBase = /*#__PURE__*/function () {
1197
1064
  *
1198
1065
  * @category Time
1199
1066
  */
1200
-
1201
1067
  var formatTimeBaseText = function formatTimeBaseText(timeBaseText) {
1202
1068
  if (timeBaseText === undefined) {
1203
1069
  return new TimeBase();
1204
1070
  }
1205
-
1206
1071
  if (typeof timeBaseText === 'number') {
1207
1072
  return new TimeBase({
1208
1073
  denominator: timeBaseText
1209
1074
  });
1210
1075
  }
1211
-
1212
1076
  if (typeof timeBaseText === 'string' && timeBaseText.includes(':')) {
1213
1077
  var _timeBaseText$split = timeBaseText.split(':'),
1214
- _timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
1215
- denominator = _timeBaseText$split2[0],
1216
- numerator = _timeBaseText$split2[1];
1217
-
1078
+ _timeBaseText$split2 = _slicedToArray(_timeBaseText$split, 2),
1079
+ denominator = _timeBaseText$split2[0],
1080
+ numerator = _timeBaseText$split2[1];
1218
1081
  return new TimeBase({
1219
1082
  denominator: denominator,
1220
1083
  numerator: numerator
1221
1084
  });
1222
1085
  }
1223
-
1224
1086
  if (TIME_BASE_CONSTANTS.includes(timeBaseText)) {
1225
1087
  return new TimeBase(MAP_CONSTANT_TO_DEN_NUM[timeBaseText]);
1226
1088
  }
1227
-
1228
1089
  if (!['string', 'number'].includes(_typeof(timeBaseText)) || Number.isNaN(Number(timeBaseText))) {
1229
1090
  throw new Error("timeBaseText must be a number or ".concat(TIME_BASE_CONSTANTS.join(','), " - is ").concat(JSON.stringify(timeBaseText)));
1230
1091
  }
1231
-
1232
1092
  return new TimeBase({
1233
1093
  denominator: Number(timeBaseText)
1234
1094
  });
@@ -1258,7 +1118,6 @@ var createTimeBase = function createTimeBase(timeBase) {
1258
1118
  if (typeof timeBase === 'string' || typeof timeBase === 'number') {
1259
1119
  return formatTimeBaseText(timeBase);
1260
1120
  }
1261
-
1262
1121
  return formatTimeBaseType(timeBase);
1263
1122
  };
1264
1123
 
@@ -1283,16 +1142,14 @@ var getAmountOfFrameDrops = function getAmountOfFrameDrops(timeBase) {
1283
1142
  * @param timeBase TimeBase Instance to check
1284
1143
  * @returns true if time base drops frames, false otherwise
1285
1144
  */
1286
-
1287
1145
  var isDropFrameTimeBase = function isDropFrameTimeBase(timeBase) {
1288
1146
  return getAmountOfFrameDrops(timeBase) > 0;
1289
1147
  };
1290
1148
 
1291
1149
  var _excluded$6 = ["hours"];
1292
-
1293
1150
  var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode) {
1294
1151
  var samples = timeCode.samples,
1295
- timeBase = timeCode.timeBase;
1152
+ timeBase = timeCode.timeBase;
1296
1153
  var amountOfFrameDrops = getAmountOfFrameDrops(timeBase);
1297
1154
  if (!amountOfFrameDrops) return 0;
1298
1155
  var roundedFrameRate = timeBase.toRate({
@@ -1308,7 +1165,6 @@ var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode)
1308
1165
  var amountOfFrameRemainderChunks = frameRemainder > 0 ? amountOfFrameDrops : 0;
1309
1166
  return amountOfTenMinuteChunks * 9 * amountOfFrameDrops + amountOfOneMinuteReminderChunks * amountOfFrameDrops + amountOfFrameRemainderChunks;
1310
1167
  };
1311
-
1312
1168
  /**
1313
1169
  * TimeCode class representing the TimeCodeType in VidiCore
1314
1170
  *
@@ -1318,8 +1174,11 @@ var getDroppedFramesFromSamples = function getDroppedFramesFromSamples(timeCode)
1318
1174
  */
1319
1175
  var TimeCode = /*#__PURE__*/function () {
1320
1176
  // Amount of samples for the time code
1177
+
1321
1178
  // The time base for the time code
1179
+
1322
1180
  // If time code is dropFrame or not (by default checks timeBase)
1181
+
1323
1182
  // Separator for frame in smpte output (default ":" for non-drop-frame and ";" for dropFrame)
1324
1183
 
1325
1184
  /**
@@ -1330,21 +1189,14 @@ var TimeCode = /*#__PURE__*/function () {
1330
1189
  */
1331
1190
  function TimeCode(timeCodeType, options) {
1332
1191
  var _options$dropFrame, _options$frameSeparat;
1333
-
1334
1192
  _classCallCheck(this, TimeCode);
1335
-
1336
1193
  _defineProperty(this, "samples", 0);
1337
-
1338
1194
  _defineProperty(this, "timeBase", new TimeBase());
1339
-
1340
1195
  _defineProperty(this, "dropFrame", void 0);
1341
-
1342
1196
  _defineProperty(this, "frameSeparator", void 0);
1343
-
1344
1197
  var _ref = timeCodeType || {},
1345
- samples = _ref.samples,
1346
- timeBase = _ref.timeBase;
1347
-
1198
+ samples = _ref.samples,
1199
+ timeBase = _ref.timeBase;
1348
1200
  if (samples !== undefined) {
1349
1201
  if (typeof samples === 'number') {
1350
1202
  this.samples = samples;
@@ -1360,7 +1212,6 @@ var TimeCode = /*#__PURE__*/function () {
1360
1212
  throw new Error("samples is not number/string/-Inf/+Inf is: ".concat(samples));
1361
1213
  }
1362
1214
  }
1363
-
1364
1215
  if (timeBase !== undefined) {
1365
1216
  if (timeBase instanceof TimeBase) {
1366
1217
  this.timeBase = timeBase;
@@ -1368,10 +1219,10 @@ var TimeCode = /*#__PURE__*/function () {
1368
1219
  this.timeBase = createTimeBase(timeBase);
1369
1220
  }
1370
1221
  }
1371
-
1372
1222
  this.dropFrame = (_options$dropFrame = options === null || options === void 0 ? void 0 : options.dropFrame) !== null && _options$dropFrame !== void 0 ? _options$dropFrame : isDropFrameTimeBase(this.timeBase);
1373
1223
  this.frameSeparator = (_options$frameSeparat = options === null || options === void 0 ? void 0 : options.frameSeparator) !== null && _options$frameSeparat !== void 0 ? _options$frameSeparat : this.dropFrame ? ';' : ':';
1374
1224
  }
1225
+
1375
1226
  /**
1376
1227
  * Return this TimeCode added with the supplied timeCodeType
1377
1228
  * If time bases differ, it will retain the time base of this TimeCode instance
@@ -1384,32 +1235,27 @@ var TimeCode = /*#__PURE__*/function () {
1384
1235
  * @param timeCode A TimeCode instance you want to add with
1385
1236
  * @returns A new TimeCode instance with the addition applied
1386
1237
  */
1387
-
1388
-
1389
1238
  _createClass(TimeCode, [{
1390
1239
  key: "add",
1391
1240
  value: function add(timeCode) {
1392
1241
  if (!(timeCode !== null && timeCode !== void 0 && timeCode.timeBase) || (timeCode === null || timeCode === void 0 ? void 0 : timeCode.samples) === undefined) {
1393
1242
  throw Error('Invalid timeCodeType, cannot be added');
1394
1243
  }
1395
-
1396
1244
  var _ref2 = (timeCode === null || timeCode === void 0 ? void 0 : timeCode.timeBase) || {},
1397
- numerator = _ref2.numerator,
1398
- denominator = _ref2.denominator;
1399
-
1245
+ numerator = _ref2.numerator,
1246
+ denominator = _ref2.denominator;
1400
1247
  var conformedTimeCode = timeCode;
1401
-
1402
1248
  if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1403
1249
  conformedTimeCode = timeCode.conformTimeBase(this.timeBase);
1404
1250
  }
1405
-
1406
1251
  var _conformedTimeCode = conformedTimeCode,
1407
- samples = _conformedTimeCode.samples;
1252
+ samples = _conformedTimeCode.samples;
1408
1253
  return new TimeCode({
1409
1254
  samples: this.samples + samples,
1410
1255
  timeBase: this.timeBase
1411
1256
  });
1412
1257
  }
1258
+
1413
1259
  /**
1414
1260
  * Return this TimeCode subtracted with the supplied timeCodeType
1415
1261
  * If time bases differ, it will retain the time base of the instance time code
@@ -1422,31 +1268,28 @@ var TimeCode = /*#__PURE__*/function () {
1422
1268
  * @param timeCode A TimeCode instance you want to subtract with
1423
1269
  * @returns A new TimeCode instance with the subtraction applied
1424
1270
  */
1425
-
1426
1271
  }, {
1427
1272
  key: "subtract",
1428
1273
  value: function subtract(timeCode) {
1429
1274
  if (!(timeCode !== null && timeCode !== void 0 && timeCode.timeBase) || (timeCode === null || timeCode === void 0 ? void 0 : timeCode.samples) === undefined) {
1430
1275
  throw Error('Invalid timeCodeType, cannot be subtracted');
1431
1276
  }
1432
-
1433
1277
  var _timeCode$timeBase = timeCode.timeBase;
1434
1278
  _timeCode$timeBase = _timeCode$timeBase === void 0 ? {} : _timeCode$timeBase;
1435
1279
  var numerator = _timeCode$timeBase.numerator,
1436
- denominator = _timeCode$timeBase.denominator;
1280
+ denominator = _timeCode$timeBase.denominator;
1437
1281
  var conformedTimeCode = timeCode;
1438
-
1439
1282
  if (numerator !== this.timeBase.numerator || denominator !== this.timeBase.denominator) {
1440
1283
  conformedTimeCode = timeCode.conformTimeBase(this.timeBase);
1441
1284
  }
1442
-
1443
1285
  var _conformedTimeCode2 = conformedTimeCode,
1444
- samples = _conformedTimeCode2.samples;
1286
+ samples = _conformedTimeCode2.samples;
1445
1287
  return new TimeCode({
1446
1288
  samples: this.samples - samples,
1447
1289
  timeBase: this.timeBase
1448
1290
  });
1449
1291
  }
1292
+
1450
1293
  /**
1451
1294
  * Creates a new TimeCode instance with specified timeBase and samples adjusted to that.
1452
1295
  *
@@ -1456,7 +1299,6 @@ var TimeCode = /*#__PURE__*/function () {
1456
1299
  * @param timeBase The TimeBase it should conform the TimeCode to
1457
1300
  * @returns A new TimeCode instance with the conformTo timeBase applied
1458
1301
  */
1459
-
1460
1302
  }, {
1461
1303
  key: "conformTimeBase",
1462
1304
  value: function conformTimeBase(timeBase) {
@@ -1472,6 +1314,7 @@ var TimeCode = /*#__PURE__*/function () {
1472
1314
  };
1473
1315
  return new TimeCode(timeCode);
1474
1316
  }
1317
+
1475
1318
  /**
1476
1319
  * Get TimeCode as a text representation
1477
1320
  *
@@ -1484,39 +1327,36 @@ var TimeCode = /*#__PURE__*/function () {
1484
1327
  *
1485
1328
  * @category Time
1486
1329
  */
1487
-
1488
1330
  }, {
1489
1331
  key: "toText",
1490
1332
  value: function toText(options) {
1491
1333
  var timeCodeText = "".concat(this.samples);
1492
1334
  var timeBaseText = this.timeBase.toText(options);
1493
-
1494
1335
  if (options !== null && options !== void 0 && options.includeTimeBaseForSeconds || !['1', '1:1'].includes(timeBaseText)) {
1495
1336
  timeCodeText = [this.samples, timeBaseText].join('@');
1496
1337
  }
1497
-
1498
1338
  return timeCodeText;
1499
1339
  }
1340
+
1500
1341
  /**
1501
1342
  * Get TimeCode in a units object representation
1502
1343
  *
1503
1344
  * @returns Units (time and frames) for the time code
1504
1345
  */
1505
-
1506
1346
  }, {
1507
1347
  key: "toUnits",
1508
1348
  value: function toUnits() {
1509
1349
  var totalSamples = this.samples + (this.dropFrame ? getDroppedFramesFromSamples(this) : 0);
1510
1350
  var roundedFrameRate = this.timeBase.toRate({
1511
1351
  rounded: true
1512
- }); // Calculated without drop-frame but with 2 decimal places
1352
+ });
1513
1353
 
1354
+ // Calculated without drop-frame but with 2 decimal places
1514
1355
  if (['23.976', '23.98'].includes(this.timeBase.toConstant())) {
1515
1356
  roundedFrameRate = this.timeBase.toRate({
1516
1357
  fixed: true
1517
1358
  });
1518
1359
  }
1519
-
1520
1360
  var hours = Math.floor(totalSamples / (3600 * roundedFrameRate));
1521
1361
  var minutes = Math.floor(totalSamples / (60 * roundedFrameRate)) % 60;
1522
1362
  var seconds = Math.floor(totalSamples / roundedFrameRate) % 60;
@@ -1528,23 +1368,21 @@ var TimeCode = /*#__PURE__*/function () {
1528
1368
  frames: frames
1529
1369
  };
1530
1370
  }
1371
+
1531
1372
  /**
1532
1373
  * Get TimeCode in a time object representation
1533
1374
  * "milliseconds" is rounded down, if you want another representation use "partialSeconds"
1534
1375
  *
1535
1376
  * @returns Time for the time code
1536
1377
  */
1537
-
1538
1378
  }, {
1539
1379
  key: "toTime",
1540
1380
  value: function toTime() {
1541
1381
  var totalSamples = this.samples + getDroppedFramesFromSamples(this);
1542
-
1543
1382
  var _this$toUnits = this.toUnits(),
1544
- hours = _this$toUnits.hours,
1545
- minutes = _this$toUnits.minutes,
1546
- seconds = _this$toUnits.seconds;
1547
-
1383
+ hours = _this$toUnits.hours,
1384
+ minutes = _this$toUnits.minutes,
1385
+ seconds = _this$toUnits.seconds;
1548
1386
  var roundedFrameRate = this.timeBase.toRate({
1549
1387
  rounded: true
1550
1388
  });
@@ -1559,20 +1397,21 @@ var TimeCode = /*#__PURE__*/function () {
1559
1397
  partialSeconds: partialSeconds
1560
1398
  };
1561
1399
  }
1400
+
1562
1401
  /**
1563
1402
  * Get TimeCode in a seconds representation
1564
1403
  *
1565
1404
  * @returns Total seconds for the time code
1566
1405
  */
1567
-
1568
1406
  }, {
1569
1407
  key: "toSeconds",
1570
1408
  value: function toSeconds() {
1571
1409
  var _this$timeBase = this.timeBase,
1572
- numerator = _this$timeBase.numerator,
1573
- denominator = _this$timeBase.denominator;
1410
+ numerator = _this$timeBase.numerator,
1411
+ denominator = _this$timeBase.denominator;
1574
1412
  return Math.round(1000 * +(this.samples * numerator / denominator)) / 1000;
1575
1413
  }
1414
+
1576
1415
  /**
1577
1416
  * Get TimeCode in a duration representation
1578
1417
  * The time unit char keys for the format string are:
@@ -1591,52 +1430,40 @@ var TimeCode = /*#__PURE__*/function () {
1591
1430
  * @param options Options for how to display duration
1592
1431
  * @returns Duration representation of the TimeCode
1593
1432
  */
1594
-
1595
1433
  }, {
1596
1434
  key: "toDuration",
1597
1435
  value: function toDuration(options) {
1598
1436
  var _ref3 = options || {},
1599
- format = _ref3.format;
1600
-
1437
+ format = _ref3.format;
1601
1438
  var _this$toTime = this.toTime(),
1602
- hours = _this$toTime.hours,
1603
- rest = _objectWithoutProperties(_this$toTime, _excluded$6);
1604
-
1439
+ hours = _this$toTime.hours,
1440
+ rest = _objectWithoutProperties(_this$toTime, _excluded$6);
1605
1441
  var minutes = rest.minutes,
1606
- seconds = rest.seconds,
1607
- milliseconds = rest.milliseconds;
1608
-
1442
+ seconds = rest.seconds,
1443
+ milliseconds = rest.milliseconds;
1609
1444
  if (!!format && typeof format !== 'string') {
1610
1445
  throw Error('format has to be a string');
1611
1446
  }
1612
-
1613
1447
  var isBefore = function isBefore(unit, units) {
1614
1448
  return !format.includes(unit) || !units.some(function (u) {
1615
1449
  return format.includes(u) && format.lastIndexOf(unit) > format.indexOf(u);
1616
1450
  });
1617
1451
  };
1618
-
1619
1452
  if (!!format && !(isBefore('h', ['m', 's', 'S']) && isBefore('m', ['s', 'S']) && isBefore('s', ['S']))) {
1620
1453
  throw Error('format order is unsupported (has to be h, m, s then S)');
1621
1454
  }
1622
-
1623
1455
  if (!format) {
1624
1456
  return "".concat(hours > 0 ? "".concat(hours, ":").concat("".concat(minutes).padStart(2, '0')) : minutes, ":").concat("".concat(seconds).padStart(2, '0'));
1625
1457
  }
1626
-
1627
1458
  var countConsecutiveChars = function countConsecutiveChars(i, arr) {
1628
1459
  var j = i;
1629
-
1630
1460
  while (arr[j] === arr[j + 1]) {
1631
1461
  j += 1;
1632
1462
  }
1633
-
1634
1463
  return j - i + 1;
1635
1464
  };
1636
-
1637
1465
  var timeUnitKeys = ['h', 'm', 's', 'S'];
1638
1466
  var output = [];
1639
-
1640
1467
  _toConsumableArray(format).forEach(function (c, i, arr) {
1641
1468
  switch (c) {
1642
1469
  case 'h':
@@ -1644,108 +1471,85 @@ var TimeCode = /*#__PURE__*/function () {
1644
1471
  if (arr[i - 1] === 'h') {
1645
1472
  break;
1646
1473
  }
1647
-
1648
1474
  var amount = countConsecutiveChars(i, arr);
1649
1475
  output.push("".concat(hours).padStart(amount, '0'));
1650
-
1651
1476
  if (timeUnitKeys.includes(arr[i + amount])) {
1652
1477
  output.push(':');
1653
1478
  }
1654
-
1655
1479
  break;
1656
1480
  }
1657
-
1658
1481
  case 'm':
1659
1482
  {
1660
1483
  if (arr[i - 1] === 'm') {
1661
1484
  break;
1662
1485
  }
1663
-
1664
1486
  var _amount = countConsecutiveChars(i, arr);
1665
-
1666
1487
  if (!format.includes('h')) {
1667
1488
  minutes += hours * 60;
1668
1489
  }
1669
-
1670
1490
  output.push("".concat(minutes).padStart(_amount, '0'));
1671
-
1672
1491
  if (timeUnitKeys.includes(arr[i + _amount])) {
1673
1492
  output.push(':');
1674
1493
  }
1675
-
1676
1494
  break;
1677
1495
  }
1678
-
1679
1496
  case 's':
1680
1497
  {
1681
1498
  if (arr[i - 1] === 's') {
1682
1499
  break;
1683
1500
  }
1684
-
1685
1501
  var _amount2 = countConsecutiveChars(i, arr);
1686
-
1687
1502
  if (!format.includes('m')) {
1688
1503
  seconds += minutes * 60;
1689
1504
  }
1690
-
1691
1505
  output.push("".concat(seconds).padStart(_amount2, '0'));
1692
-
1693
1506
  if (timeUnitKeys.includes(arr[i + _amount2])) {
1694
1507
  output.push('.');
1695
1508
  }
1696
-
1697
1509
  break;
1698
1510
  }
1699
-
1700
1511
  case 'S':
1701
1512
  {
1702
1513
  if (arr[i - 1] === 'S') {
1703
1514
  break;
1704
1515
  }
1705
-
1706
1516
  var _amount3 = countConsecutiveChars(i, arr);
1707
-
1708
1517
  if (!format.includes('s')) {
1709
1518
  milliseconds += seconds * 1000;
1710
1519
  }
1711
-
1712
1520
  output.push("".concat(Math.round(milliseconds / Math.pow(10, 3 - _amount3))).padStart(_amount3, '0'));
1713
1521
  break;
1714
1522
  }
1715
-
1716
1523
  default:
1717
1524
  output.push(c);
1718
1525
  }
1719
1526
  });
1720
-
1721
1527
  return output.join('');
1722
1528
  }
1529
+
1723
1530
  /**
1724
1531
  * Get TimeCode in a smpte representation
1725
1532
  *
1726
1533
  * @returns Smpte representation of the TimeCode
1727
1534
  */
1728
-
1729
1535
  }, {
1730
1536
  key: "toSmpte",
1731
1537
  value: function toSmpte() {
1732
1538
  if (this.samples === -Infinity) return '00:00:00:00';
1733
-
1734
1539
  var _this$toUnits2 = this.toUnits(),
1735
- hours = _this$toUnits2.hours,
1736
- minutes = _this$toUnits2.minutes,
1737
- seconds = _this$toUnits2.seconds,
1738
- frames = _this$toUnits2.frames;
1739
-
1540
+ hours = _this$toUnits2.hours,
1541
+ minutes = _this$toUnits2.minutes,
1542
+ seconds = _this$toUnits2.seconds,
1543
+ frames = _this$toUnits2.frames;
1740
1544
  var hhmmss = [hours.toFixed().padStart(2, '0'), minutes.toFixed().padStart(2, '0'), seconds.toFixed().padStart(2, '0')].join(':');
1741
1545
  return [hhmmss, "".concat(frames).padStart(2, '0')].join(this.frameSeparator);
1742
1546
  }
1547
+
1743
1548
  /**
1744
1549
  * Get TimeCode as a VidiCore TimeCodeType object
1745
1550
  *
1746
1551
  * @returns TimeCode as `{ samples, timeBase }`
1747
1552
  */
1748
-
1749
1553
  }, {
1750
1554
  key: "toObject",
1751
1555
  value: function toObject() {
@@ -1754,12 +1558,12 @@ var TimeCode = /*#__PURE__*/function () {
1754
1558
  timeBase: this.timeBase.toObject()
1755
1559
  };
1756
1560
  }
1561
+
1757
1562
  /**
1758
1563
  * @deprecated Use {@link TimeCode#toObject | toObject} instead
1759
1564
  *
1760
1565
  * @returns TimeCode as `{ samples, timeBase }`
1761
1566
  */
1762
-
1763
1567
  }, {
1764
1568
  key: "toJson",
1765
1569
  value: function toJson() {
@@ -1768,7 +1572,6 @@ var TimeCode = /*#__PURE__*/function () {
1768
1572
  return this.toObject();
1769
1573
  }
1770
1574
  }]);
1771
-
1772
1575
  return TimeCode;
1773
1576
  }();
1774
1577
 
@@ -1786,7 +1589,6 @@ var TimeCode = /*#__PURE__*/function () {
1786
1589
  var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
1787
1590
  var a = Math.abs(num1);
1788
1591
  var b = Math.abs(num2);
1789
-
1790
1592
  while (a && b && a !== b) {
1791
1593
  if (a > b) {
1792
1594
  var _ref = [a - b, b];
@@ -1798,12 +1600,10 @@ var getGreatestCommonDivisor = function getGreatestCommonDivisor(num1, num2) {
1798
1600
  b = _ref2[1];
1799
1601
  }
1800
1602
  }
1801
-
1802
1603
  return a || b;
1803
1604
  };
1804
1605
 
1805
1606
  var _excluded$5 = ["timeBase", "useGCD"];
1806
-
1807
1607
  /**
1808
1608
  * Format seconds to TimeCode object
1809
1609
  * Input time base is always 1:1 since it expects seconds as input
@@ -1821,40 +1621,32 @@ var _excluded$5 = ["timeBase", "useGCD"];
1821
1621
  */
1822
1622
  var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds, options) {
1823
1623
  var _ref = options || {},
1824
- timeBase = _ref.timeBase,
1825
- _ref$useGCD = _ref.useGCD,
1826
- useGCD = _ref$useGCD === void 0 ? false : _ref$useGCD,
1827
- timeCodeOptions = _objectWithoutProperties(_ref, _excluded$5);
1828
-
1624
+ timeBase = _ref.timeBase,
1625
+ _ref$useGCD = _ref.useGCD,
1626
+ useGCD = _ref$useGCD === void 0 ? false : _ref$useGCD,
1627
+ timeCodeOptions = _objectWithoutProperties(_ref, _excluded$5);
1829
1628
  var secondsWithDot = "".concat(seconds).replace(/,/g, '.');
1830
-
1831
1629
  if (Number.isNaN(+secondsWithDot)) {
1832
1630
  throw new Error("seconds must be digits, is ".concat(seconds));
1833
1631
  }
1834
-
1835
1632
  var denominator = 1;
1836
1633
  var samples;
1837
-
1838
1634
  if (Number.isInteger(+secondsWithDot)) {
1839
1635
  samples = +secondsWithDot * denominator;
1840
1636
  } else {
1841
1637
  var _ms$length;
1842
-
1843
1638
  var _secondsWithDot$split = secondsWithDot.split('.'),
1844
- _secondsWithDot$split2 = _slicedToArray(_secondsWithDot$split, 2),
1845
- ms = _secondsWithDot$split2[1];
1846
-
1639
+ _secondsWithDot$split2 = _slicedToArray(_secondsWithDot$split, 2),
1640
+ ms = _secondsWithDot$split2[1];
1847
1641
  var decimalPlaces = Math.min((_ms$length = ms === null || ms === void 0 ? void 0 : ms.length) !== null && _ms$length !== void 0 ? _ms$length : 0, 16);
1848
1642
  denominator *= Math.pow(10, decimalPlaces);
1849
1643
  samples = Math.round(Number(secondsWithDot) * denominator);
1850
1644
  }
1851
-
1852
1645
  if (timeBase === undefined && useGCD) {
1853
1646
  var gcd = getGreatestCommonDivisor(denominator, samples);
1854
1647
  samples /= gcd;
1855
1648
  denominator /= gcd;
1856
1649
  }
1857
-
1858
1650
  var timeCode = new TimeCode({
1859
1651
  samples: samples,
1860
1652
  timeBase: {
@@ -1862,47 +1654,40 @@ var formatTimeCodeSeconds = function formatTimeCodeSeconds(seconds, options) {
1862
1654
  numerator: 1
1863
1655
  }
1864
1656
  }, timeCodeOptions);
1865
- return timeBase !== undefined ? timeCode.conformTimeBase(createTimeBase(timeBase === true ? 1 : timeBase)) : timeCode;
1657
+ return timeBase !== undefined ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
1866
1658
  };
1867
1659
 
1868
1660
  var getDroppedFramesFromSmpte = function getDroppedFramesFromSmpte(_ref, samples, timeBase) {
1869
1661
  var _ref2 = _slicedToArray(_ref, 4),
1870
- hh = _ref2[0],
1871
- mm = _ref2[1],
1872
- ss = _ref2[2],
1873
- ff = _ref2[3];
1874
-
1662
+ hh = _ref2[0],
1663
+ mm = _ref2[1],
1664
+ ss = _ref2[2],
1665
+ ff = _ref2[3];
1875
1666
  var roundedFrameRate = timeBase.toRate({
1876
1667
  rounded: true
1877
1668
  });
1878
1669
  var dropFrames = getAmountOfFrameDrops(timeBase);
1879
-
1880
1670
  if (samples === 0 || !dropFrames) {
1881
1671
  return 0;
1882
1672
  }
1883
-
1884
1673
  var shouldDropMinute = mm % 10 !== 0;
1885
1674
  var shouldDropSecond = shouldDropMinute && ss === 0;
1886
1675
  var hourFrames = hh * (3600 * roundedFrameRate - 54 * dropFrames);
1887
1676
  var minuteFrames = mm * 60 * roundedFrameRate - (mm - Math.ceil(mm / 10)) * dropFrames;
1888
1677
  var secondFrames = ss * roundedFrameRate - (shouldDropMinute && ss > 1 ? dropFrames : 0);
1889
-
1890
1678
  if (shouldDropSecond && ff < dropFrames) {
1891
1679
  throw new Error("Frame does not exist for ".concat(timeBase.toConstant() || timeBase.toRate(), " drop-frame"));
1892
1680
  }
1893
-
1894
1681
  var frameFrames = shouldDropSecond ? ff - dropFrames : ff;
1895
1682
  var samplesWithoutDroppedFrames = hourFrames + minuteFrames + secondFrames + frameFrames;
1896
1683
  return samples - samplesWithoutDroppedFrames;
1897
1684
  };
1898
-
1899
1685
  var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dropFrame) {
1900
1686
  var _smpteValues = _slicedToArray(smpteValues, 4),
1901
- hh = _smpteValues[0],
1902
- mm = _smpteValues[1],
1903
- ss = _smpteValues[2],
1904
- ff = _smpteValues[3];
1905
-
1687
+ hh = _smpteValues[0],
1688
+ mm = _smpteValues[1],
1689
+ ss = _smpteValues[2],
1690
+ ff = _smpteValues[3];
1906
1691
  var roundedFrameRate = timeBase.toRate({
1907
1692
  rounded: true
1908
1693
  });
@@ -1912,32 +1697,26 @@ var getSamplesFromSmpte = function getSamplesFromSmpte(smpteValues, timeBase, dr
1912
1697
 
1913
1698
  var splitSmpte = function splitSmpte(smpte) {
1914
1699
  var _ref = (smpte === null || smpte === void 0 ? void 0 : smpte.match(/[^0-9:\-_]/)) || [],
1915
- _ref2 = _slicedToArray(_ref, 1),
1916
- nonColonFrameSeparator = _ref2[0];
1917
-
1700
+ _ref2 = _slicedToArray(_ref, 1),
1701
+ nonColonFrameSeparator = _ref2[0];
1918
1702
  var smpteValues = [];
1919
-
1920
1703
  if (nonColonFrameSeparator) {
1921
1704
  var _smpte$split = smpte.split(nonColonFrameSeparator),
1922
- _smpte$split2 = _slicedToArray(_smpte$split, 2),
1923
- hhmmss = _smpte$split2[0],
1924
- ff = _smpte$split2[1];
1925
-
1705
+ _smpte$split2 = _slicedToArray(_smpte$split, 2),
1706
+ hhmmss = _smpte$split2[0],
1707
+ ff = _smpte$split2[1];
1926
1708
  smpteValues = [].concat(_toConsumableArray(hhmmss.split(':')), [ff]);
1927
1709
  } else {
1928
1710
  smpteValues = smpte.split(':');
1929
1711
  }
1930
-
1931
1712
  if (smpteValues.length !== 4) {
1932
1713
  throw new Error('Invalid format, must be "##:##:##:##');
1933
1714
  }
1934
-
1935
1715
  if (smpteValues.some(function (n) {
1936
1716
  return Number.isNaN(n);
1937
1717
  })) {
1938
1718
  throw new Error('Invalid format, values must be numbers');
1939
1719
  }
1940
-
1941
1720
  var smpteFrameSeparator = nonColonFrameSeparator || ':';
1942
1721
  return {
1943
1722
  smpteValues: smpteValues.map(Number),
@@ -1946,12 +1725,9 @@ var splitSmpte = function splitSmpte(smpte) {
1946
1725
  };
1947
1726
 
1948
1727
  var _excluded$4 = ["exceedingMode", "timeBase"];
1949
-
1950
1728
  function ownKeys$9(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
1951
-
1952
1729
  function _objectSpread$9(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$9(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$9(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1953
1730
  var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
1954
-
1955
1731
  /**
1956
1732
  * Format smpte text to a TimeCode Instance
1957
1733
  *
@@ -1968,98 +1744,79 @@ var EXCEEDING_OPTIONS = ['error', 'add', 'ignore'];
1968
1744
  */
1969
1745
  var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte, options) {
1970
1746
  var _ref = options || {},
1971
- _ref$exceedingMode = _ref.exceedingMode,
1972
- exceedingMode = _ref$exceedingMode === void 0 ? 'error' : _ref$exceedingMode,
1973
- timeBase = _ref.timeBase,
1974
- timeCodeOptions = _objectWithoutProperties(_ref, _excluded$4);
1975
-
1747
+ _ref$exceedingMode = _ref.exceedingMode,
1748
+ exceedingMode = _ref$exceedingMode === void 0 ? 'error' : _ref$exceedingMode,
1749
+ timeBase = _ref.timeBase,
1750
+ timeCodeOptions = _objectWithoutProperties(_ref, _excluded$4);
1976
1751
  if ([null, undefined].includes(smpte)) {
1977
1752
  throw new Error("smpte cannot be undefined or null");
1978
1753
  }
1979
-
1980
1754
  if (typeof smpte !== 'string') {
1981
1755
  throw new Error("smpte must be a string, is ".concat(JSON.stringify(smpte)));
1982
1756
  }
1983
-
1984
1757
  var _splitSmpte = splitSmpte(smpte),
1985
- smpteValues = _splitSmpte.smpteValues,
1986
- smpteFrameSeparator = _splitSmpte.smpteFrameSeparator;
1987
-
1758
+ smpteValues = _splitSmpte.smpteValues,
1759
+ smpteFrameSeparator = _splitSmpte.smpteFrameSeparator;
1988
1760
  var timeBaseInstance = createTimeBase(timeBase);
1989
-
1990
1761
  var mergedOptions = _objectSpread$9(_objectSpread$9({}, timeCodeOptions), {}, {
1991
1762
  frameSeparator: (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.frameSeparator) || smpteFrameSeparator
1992
1763
  }, (timeCodeOptions === null || timeCodeOptions === void 0 ? void 0 : timeCodeOptions.dropFrame) === undefined ? {
1993
1764
  dropFrame: timeBase !== undefined ? isDropFrameTimeBase(timeBaseInstance) : [';', ','].includes(smpteFrameSeparator)
1994
1765
  } : {});
1995
-
1996
1766
  var roundedFrameRate = timeBaseInstance.toRate({
1997
1767
  rounded: true
1998
1768
  });
1999
1769
  var maxFrame = Math.max(0, roundedFrameRate - 1);
2000
-
2001
1770
  if (smpteValues.some(function (v) {
2002
1771
  return v < 0;
2003
1772
  })) {
2004
1773
  throw new Error('Negative values are not supported');
2005
1774
  }
2006
-
2007
1775
  var samples;
2008
-
2009
1776
  switch (exceedingMode) {
2010
1777
  case 'error':
2011
1778
  {
2012
1779
  var _smpteValues = _slicedToArray(smpteValues, 4),
2013
- hours = _smpteValues[0],
2014
- minutes = _smpteValues[1],
2015
- seconds = _smpteValues[2],
2016
- frames = _smpteValues[3];
2017
-
1780
+ hours = _smpteValues[0],
1781
+ minutes = _smpteValues[1],
1782
+ seconds = _smpteValues[2],
1783
+ frames = _smpteValues[3];
2018
1784
  if (hours >= 100) {
2019
1785
  throw Error('Minutes has to be less than 60');
2020
1786
  }
2021
-
2022
1787
  if (minutes >= 60) {
2023
1788
  throw Error('Minutes has to be less than 60');
2024
1789
  }
2025
-
2026
1790
  if (seconds >= 60) {
2027
1791
  throw Error('Seconds has to be less than 60');
2028
1792
  }
2029
-
2030
1793
  if (frames > maxFrame) {
2031
1794
  throw Error("Frames has to be less or equal to ".concat(maxFrame));
2032
1795
  }
2033
-
2034
1796
  samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
2035
1797
  break;
2036
1798
  }
2037
-
2038
1799
  case 'ignore':
2039
1800
  {
2040
1801
  var _smpteValues2 = _slicedToArray(smpteValues, 4),
2041
- _hours = _smpteValues2[0],
2042
- _minutes = _smpteValues2[1],
2043
- _seconds = _smpteValues2[2],
2044
- _frames = _smpteValues2[3];
2045
-
1802
+ _hours = _smpteValues2[0],
1803
+ _minutes = _smpteValues2[1],
1804
+ _seconds = _smpteValues2[2],
1805
+ _frames = _smpteValues2[3];
2046
1806
  var truncatedSmpteValues = [Math.min(100, _hours), Math.min(59, _minutes), Math.min(59, _seconds), Math.min(maxFrame, _frames)];
2047
1807
  samples = getSamplesFromSmpte(truncatedSmpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
2048
1808
  break;
2049
1809
  }
2050
-
2051
1810
  case 'add':
2052
1811
  {
2053
1812
  samples = getSamplesFromSmpte(smpteValues, timeBaseInstance, mergedOptions === null || mergedOptions === void 0 ? void 0 : mergedOptions.dropFrame);
2054
1813
  break;
2055
1814
  }
2056
-
2057
1815
  default:
2058
1816
  {
2059
1817
  throw new Error("Invalid exceedingMode, options are ".concat(JSON.stringify(EXCEEDING_OPTIONS)));
2060
1818
  }
2061
1819
  }
2062
-
2063
1820
  return new TimeCode({
2064
1821
  samples: samples,
2065
1822
  timeBase: timeBaseInstance
@@ -2067,7 +1824,6 @@ var formatTimeCodeSmpte = function formatTimeCodeSmpte(smpte, options) {
2067
1824
  };
2068
1825
 
2069
1826
  var _excluded$3 = ["timeBase"];
2070
-
2071
1827
  /**
2072
1828
  * Format text to a TimeCode instance
2073
1829
  *
@@ -2077,13 +1833,10 @@ var _excluded$3 = ["timeBase"];
2077
1833
  */
2078
1834
  var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2079
1835
  var _timeCodeObject;
2080
-
2081
1836
  var _ref = options || {},
2082
- timeBase = _ref.timeBase,
2083
- timeCodeOptions = _objectWithoutProperties(_ref, _excluded$3);
2084
-
1837
+ timeBase = _ref.timeBase,
1838
+ timeCodeOptions = _objectWithoutProperties(_ref, _excluded$3);
2085
1839
  var timeCodeObject;
2086
-
2087
1840
  if (timeCodeText === undefined) {
2088
1841
  timeCodeObject = {
2089
1842
  samples: 0
@@ -2094,10 +1847,9 @@ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2094
1847
  };
2095
1848
  } else if (timeCodeText.includes('@')) {
2096
1849
  var _timeCodeText$split = timeCodeText.split('@'),
2097
- _timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
2098
- samplesString = _timeCodeText$split2[0],
2099
- timeBaseText = _timeCodeText$split2[1];
2100
-
1850
+ _timeCodeText$split2 = _slicedToArray(_timeCodeText$split, 2),
1851
+ samplesString = _timeCodeText$split2[0],
1852
+ timeBaseText = _timeCodeText$split2[1];
2101
1853
  var samples = Number(samplesString);
2102
1854
  timeCodeObject = {
2103
1855
  samples: samples,
@@ -2116,11 +1868,9 @@ var formatTimeCodeText = function formatTimeCodeText(timeCodeText, options) {
2116
1868
  samples: Number(timeCodeText)
2117
1869
  };
2118
1870
  }
2119
-
2120
1871
  if (Number.isNaN((_timeCodeObject = timeCodeObject) === null || _timeCodeObject === void 0 ? void 0 : _timeCodeObject.samples) || timeCodeObject.timeBase && !(timeCodeObject.timeBase instanceof TimeBase)) {
2121
1872
  throw new Error("timeCodeText must be a number or sample@timeBase - is ".concat(timeCodeText));
2122
1873
  }
2123
-
2124
1874
  var timeCode = new TimeCode(timeCodeObject, timeCodeOptions);
2125
1875
  return timeBase ? timeCode.conformTimeBase(createTimeBase(timeBase)) : timeCode;
2126
1876
  };
@@ -2141,11 +1891,9 @@ var formatTimeCodeType = function formatTimeCodeType(timeCode, options) {
2141
1891
  var hasSmpteFormat = function hasSmpteFormat(s) {
2142
1892
  return !!s.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/);
2143
1893
  };
2144
-
2145
1894
  var isNumber = function isNumber(s) {
2146
1895
  return !Number.isNaN(Number(s));
2147
1896
  };
2148
-
2149
1897
  /**
2150
1898
  * Create a TimeCode instance from smpte, seconds/samples, timeCode object or string
2151
1899
  *
@@ -2157,42 +1905,38 @@ var isNumber = function isNumber(s) {
2157
1905
  */
2158
1906
  var createTimeCode = function createTimeCode(timeCode, options) {
2159
1907
  // TimeCode
2160
- if (typeof timeCode !== 'string' && typeof timeCode !== 'number') return formatTimeCodeType(timeCode, options); // SMPTE
2161
-
1908
+ if (typeof timeCode !== 'string' && typeof timeCode !== 'number') return formatTimeCodeType(timeCode, options);
1909
+ // SMPTE
2162
1910
  if (typeof timeCode === 'string' && hasSmpteFormat(timeCode)) return formatTimeCodeSmpte(timeCode, options);
2163
1911
  if (['string', 'number'].includes(_typeof(timeCode)) && isNumber(timeCode)) return formatTimeCodeSeconds(timeCode, options);
2164
-
2165
1912
  if (typeof timeCode === 'string') {
2166
1913
  return formatTimeCodeText(timeCode, options);
2167
1914
  }
2168
-
2169
1915
  return undefined;
2170
1916
  };
2171
1917
 
2172
1918
  function ownKeys$8(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2173
-
2174
1919
  function _objectSpread$8(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$8(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$8(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2175
-
2176
1920
  function timeToCueTime(_ref) {
2177
1921
  var _ref$hours = _ref.hours,
2178
- hours = _ref$hours === void 0 ? 0 : _ref$hours,
2179
- _ref$minutes = _ref.minutes,
2180
- minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
2181
- _ref$seconds = _ref.seconds,
2182
- seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
2183
- _ref$partialSeconds = _ref.partialSeconds,
2184
- partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
1922
+ hours = _ref$hours === void 0 ? 0 : _ref$hours,
1923
+ _ref$minutes = _ref.minutes,
1924
+ minutes = _ref$minutes === void 0 ? 0 : _ref$minutes,
1925
+ _ref$seconds = _ref.seconds,
1926
+ seconds = _ref$seconds === void 0 ? 0 : _ref$seconds,
1927
+ _ref$partialSeconds = _ref.partialSeconds,
1928
+ partialSeconds = _ref$partialSeconds === void 0 ? 0 : _ref$partialSeconds;
2185
1929
  var hourStr = hours.toFixed().padStart(2, '0');
2186
1930
  var minStr = minutes.toFixed().padStart(2, '0');
2187
1931
  var secondsStr = seconds.toFixed().padStart(2, '0');
2188
1932
  var partialStr = (partialSeconds * 10).toFixed().padStart(3, '0');
2189
1933
  return "".concat(hourStr, ":").concat(minStr, ":").concat(secondsStr, ".").concat(partialStr);
2190
1934
  }
2191
-
2192
1935
  var defaultOptions$2 = {
2193
1936
  subtitleGroup: 'stl_subtitle',
2194
1937
  subtitleField: 'stl_text'
2195
1938
  };
1939
+
2196
1940
  /**
2197
1941
  * Convert metadata subtitle groups to WebVtt subtitles
2198
1942
  *
@@ -2202,16 +1946,13 @@ var defaultOptions$2 = {
2202
1946
  *
2203
1947
  * @category Metadata
2204
1948
  */
2205
-
2206
1949
  var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options) {
2207
1950
  var _defaultOptions = _objectSpread$8(_objectSpread$8({}, defaultOptions$2), options || {}),
2208
- subtitleGroup = _defaultOptions.subtitleGroup,
2209
- subtitleField = _defaultOptions.subtitleField;
2210
-
1951
+ subtitleGroup = _defaultOptions.subtitleGroup,
1952
+ subtitleField = _defaultOptions.subtitleField;
2211
1953
  var _ref2 = metadataType || {},
2212
- _ref2$timespan = _ref2.timespan,
2213
- timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan;
2214
-
1954
+ _ref2$timespan = _ref2.timespan,
1955
+ timespanList = _ref2$timespan === void 0 ? [] : _ref2$timespan;
2215
1956
  if (timespanList.length === 0) return '';
2216
1957
  var parsedTimespans = parseTimespanList(timespanList, {
2217
1958
  includeTimespanAttributes: true,
@@ -2222,10 +1963,9 @@ var metadataTypeToWebVtt = function metadataTypeToWebVtt(metadataType, options)
2222
1963
  });
2223
1964
  var vttCues = parsedTimespans.map(function (timespan) {
2224
1965
  var _ref3 = (Array.isArray(timespan) ? timespan[0] : timespan) || {},
2225
- startText = _ref3.start,
2226
- endText = _ref3.end,
2227
- _ref3$subtitleGroup = _ref3[subtitleGroup];
2228
-
1966
+ startText = _ref3.start,
1967
+ endText = _ref3.end,
1968
+ _ref3$subtitleGroup = _ref3[subtitleGroup];
2229
1969
  _ref3$subtitleGroup = _ref3$subtitleGroup === void 0 ? {} : _ref3$subtitleGroup;
2230
1970
  var text = _ref3$subtitleGroup[subtitleField];
2231
1971
  if (!text) return '';
@@ -2261,9 +2001,7 @@ var createFacetType = function createFacetType() {
2261
2001
  };
2262
2002
 
2263
2003
  function ownKeys$7(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2264
-
2265
2004
  function _objectSpread$7(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$7(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$7(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2266
-
2267
2005
  /** Parsed facet type */
2268
2006
 
2269
2007
  /**
@@ -2279,11 +2017,11 @@ var parseFacetType = function parseFacetType() {
2279
2017
  var output = {};
2280
2018
  facetType.forEach(function (_ref) {
2281
2019
  var name = _ref.name,
2282
- field = _ref.field,
2283
- count = _ref.count;
2020
+ field = _ref.field,
2021
+ count = _ref.count;
2284
2022
  output[name || field] = count.reduce(function (acc, _ref2) {
2285
2023
  var fieldValue = _ref2.fieldValue,
2286
- value = _ref2.value;
2024
+ value = _ref2.value;
2287
2025
  return _objectSpread$7(_objectSpread$7({}, acc), {}, _defineProperty({}, fieldValue, value));
2288
2026
  }, {});
2289
2027
  });
@@ -2291,14 +2029,13 @@ var parseFacetType = function parseFacetType() {
2291
2029
  };
2292
2030
 
2293
2031
  function ownKeys$6(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2294
-
2295
2032
  function _objectSpread$6(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$6(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$6(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2296
-
2297
2033
  var defaultOptions$1 = {
2298
2034
  arrayOnSingle: true,
2299
2035
  joinValue: undefined,
2300
2036
  timespanAsList: false
2301
2037
  };
2038
+
2302
2039
  /**
2303
2040
  * Parses highlight timespan in VidiCore into key/value object.
2304
2041
  * The attributes can be targeted for each sub-type.
@@ -2307,48 +2044,40 @@ var defaultOptions$1 = {
2307
2044
  *
2308
2045
  * @category Search
2309
2046
  */
2310
-
2311
2047
  var parseHighlightTimespan = function parseHighlightTimespan(timespan, options) {
2312
2048
  var _defaultOptions = _objectSpread$6(_objectSpread$6({}, defaultOptions$1), options || {}),
2313
- _defaultOptions$array = _defaultOptions.arrayOnSingle,
2314
- arrayOnSingle = _defaultOptions$array === void 0 ? true : _defaultOptions$array,
2315
- _defaultOptions$joinV = _defaultOptions.joinValue,
2316
- joinValue = _defaultOptions$joinV === void 0 ? undefined : _defaultOptions$joinV,
2317
- _defaultOptions$times = _defaultOptions.timespanAsList,
2318
- timespanAsList = _defaultOptions$times === void 0 ? false : _defaultOptions$times;
2319
-
2049
+ _defaultOptions$array = _defaultOptions.arrayOnSingle,
2050
+ arrayOnSingle = _defaultOptions$array === void 0 ? true : _defaultOptions$array,
2051
+ _defaultOptions$joinV = _defaultOptions.joinValue,
2052
+ joinValue = _defaultOptions$joinV === void 0 ? undefined : _defaultOptions$joinV,
2053
+ _defaultOptions$times = _defaultOptions.timespanAsList,
2054
+ timespanAsList = _defaultOptions$times === void 0 ? false : _defaultOptions$times;
2320
2055
  var _ref = timespan || {},
2321
- _ref$field = _ref.field,
2322
- field = _ref$field === void 0 ? [] : _ref$field,
2323
- start = _ref.start,
2324
- end = _ref.end;
2325
-
2056
+ _ref$field = _ref.field,
2057
+ field = _ref$field === void 0 ? [] : _ref$field,
2058
+ start = _ref.start,
2059
+ end = _ref.end;
2326
2060
  var initialValue = timespanAsList ? {
2327
2061
  start: start,
2328
2062
  end: end
2329
2063
  } : {};
2330
2064
  var fieldList = field.reduce(function (acc, curr) {
2331
2065
  var name = curr.name,
2332
- _curr$value = curr.value,
2333
- valueList = _curr$value === void 0 ? [] : _curr$value;
2066
+ _curr$value = curr.value,
2067
+ valueList = _curr$value === void 0 ? [] : _curr$value;
2334
2068
  if (valueList.length === 0) return acc;
2335
2069
  var fieldValue;
2336
-
2337
2070
  if (arrayOnSingle === false && valueList.length === 1) {
2338
2071
  var _valueList = _slicedToArray(valueList, 1);
2339
-
2340
2072
  fieldValue = _valueList[0];
2341
2073
  } else if (joinValue) fieldValue = valueList.join(joinValue);else fieldValue = valueList;
2342
-
2343
2074
  return _objectSpread$6(_objectSpread$6({}, acc), {}, _defineProperty({}, name, fieldValue));
2344
2075
  }, initialValue);
2345
2076
  return fieldList;
2346
2077
  };
2347
2078
 
2348
2079
  var _excluded$2 = ["timespanAsList", "joinTimespan", "flat", "flatTimespan"];
2349
-
2350
2080
  function ownKeys$5(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2351
-
2352
2081
  function _objectSpread$5(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$5(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$5(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2353
2082
  var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {}, {
2354
2083
  timespanAsList: false,
@@ -2356,6 +2085,7 @@ var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {},
2356
2085
  flat: false,
2357
2086
  flatTimespan: false
2358
2087
  });
2088
+
2359
2089
  /**
2360
2090
  * Parses highlight timespans from VidiCore into key/value object.
2361
2091
  * The attributes can be targeted for each sub-type.
@@ -2365,19 +2095,16 @@ var defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions$1), {},
2365
2095
  *
2366
2096
  * @category Search
2367
2097
  */
2368
-
2369
2098
  var parseHighlightTimespanList = function parseHighlightTimespanList() {
2370
2099
  var highlightTimespanList = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
2371
2100
  var options = arguments.length > 1 ? arguments[1] : undefined;
2372
-
2373
2101
  var _defaultOptions = _objectSpread$5(_objectSpread$5({}, defaultOptions), options || {}),
2374
- timespanAsList = _defaultOptions.timespanAsList,
2375
- _defaultOptions$joinT = _defaultOptions.joinTimespan,
2376
- joinTimespan = _defaultOptions$joinT === void 0 ? '_' : _defaultOptions$joinT,
2377
- flat = _defaultOptions.flat,
2378
- flatTimespan = _defaultOptions.flatTimespan,
2379
- parseHighlightTimespanOptions = _objectWithoutProperties(_defaultOptions, _excluded$2);
2380
-
2102
+ timespanAsList = _defaultOptions.timespanAsList,
2103
+ _defaultOptions$joinT = _defaultOptions.joinTimespan,
2104
+ joinTimespan = _defaultOptions$joinT === void 0 ? '_' : _defaultOptions$joinT,
2105
+ flat = _defaultOptions.flat,
2106
+ flatTimespan = _defaultOptions.flatTimespan,
2107
+ parseHighlightTimespanOptions = _objectWithoutProperties(_defaultOptions, _excluded$2);
2381
2108
  if (timespanAsList === true) return highlightTimespanList.map(function (timespan) {
2382
2109
  return parseHighlightTimespan(timespan, _objectSpread$5(_objectSpread$5({}, parseHighlightTimespanOptions), {}, {
2383
2110
  timespanAsList: timespanAsList
@@ -2393,57 +2120,47 @@ var parseHighlightTimespanList = function parseHighlightTimespanList() {
2393
2120
 
2394
2121
  var parseNowDate = function parseNowDate() {
2395
2122
  var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'NOW';
2396
-
2397
2123
  if (value.startsWith('NOW')) {
2398
2124
  if (value === 'NOW') return new Date();
2399
2125
  var sign = value[3];
2400
2126
  var number = Number(value.match(/(\d+)/)[0]);
2401
2127
  var unit = value.match(/(\d.*)/)[0].replace(/\d/g, '');
2402
2128
  var nowDiff = new Date();
2403
-
2404
2129
  switch (unit) {
2405
2130
  case 'HOUR':
2406
2131
  case 'HOURS':
2407
2132
  if (sign === '+') nowDiff.setHours(nowDiff.getHours() + number);
2408
2133
  if (sign === '-') nowDiff.setHours(nowDiff.getHours() - number);
2409
2134
  break;
2410
-
2411
2135
  case 'DAY':
2412
2136
  case 'DAYS':
2413
2137
  if (sign === '+') nowDiff.setDate(nowDiff.getDate() + number);
2414
2138
  if (sign === '-') nowDiff.setDate(nowDiff.getDate() - number);
2415
2139
  break;
2416
-
2417
2140
  case 'MONTH':
2418
2141
  case 'MONTHS':
2419
2142
  if (sign === '+') nowDiff.setMonth(nowDiff.getMonth() + number);
2420
2143
  if (sign === '-') nowDiff.setMonth(nowDiff.getMonth() - number);
2421
2144
  break;
2422
-
2423
2145
  case 'YEAR':
2424
2146
  case 'YEARS':
2425
2147
  if (sign === '+') nowDiff.setFullYear(nowDiff.getFullYear() + number);
2426
2148
  if (sign === '-') nowDiff.setFullYear(nowDiff.getFullYear() - number);
2427
2149
  break;
2428
2150
  }
2429
-
2430
2151
  return nowDiff;
2431
2152
  }
2432
-
2433
2153
  return new Date(value);
2434
2154
  };
2435
2155
 
2436
2156
  var _excluded$1 = ["property"];
2437
-
2438
2157
  function ownKeys$4(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2439
-
2440
2158
  function _objectSpread$4(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$4(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$4(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2441
2159
  var parseBaseMediaInfoType = function parseBaseMediaInfoType(baseMediaInfoType) {
2442
2160
  var _ref = baseMediaInfoType || {},
2443
- _ref$property = _ref.property,
2444
- keyValuePairTypes = _ref$property === void 0 ? [] : _ref$property,
2445
- props = _objectWithoutProperties(_ref, _excluded$1);
2446
-
2161
+ _ref$property = _ref.property,
2162
+ keyValuePairTypes = _ref$property === void 0 ? [] : _ref$property,
2163
+ props = _objectWithoutProperties(_ref, _excluded$1);
2447
2164
  var parsedKeyValuePairType = parseKeyValuePairTypes(keyValuePairTypes);
2448
2165
  return _objectSpread$4(_objectSpread$4({}, parsedKeyValuePairType), props);
2449
2166
  };
@@ -2464,7 +2181,6 @@ var bitRateSymbols = {
2464
2181
  B: 'bps',
2465
2182
  MB: 'mbps'
2466
2183
  };
2467
-
2468
2184
  /**
2469
2185
  * Parses the technical information of a AudioComponentType.
2470
2186
  * @param audioComponentType - A AudioComponentType from VidiCore.
@@ -2474,15 +2190,15 @@ var bitRateSymbols = {
2474
2190
  */
2475
2191
  var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2476
2192
  var timeBase = audioComponentType.timeBase,
2477
- audioChannels = audioComponentType.channelCount,
2478
- audioCodec = audioComponentType.codec,
2479
- mediaInfo = audioComponentType.mediaInfo,
2480
- bitrate = audioComponentType.bitrate,
2481
- metadata = audioComponentType.metadata;
2193
+ audioChannels = audioComponentType.channelCount,
2194
+ audioCodec = audioComponentType.codec,
2195
+ mediaInfo = audioComponentType.mediaInfo,
2196
+ bitrate = audioComponentType.bitrate,
2197
+ metadata = audioComponentType.metadata;
2482
2198
  var audioMediaInfo = parseAudioMediaInfoType(mediaInfo);
2483
2199
  var audioFormat = audioMediaInfo.Format,
2484
- audioBitDepth = audioMediaInfo.Resolution,
2485
- audioBitRateMode = audioMediaInfo.Bit_rate_mode;
2200
+ audioBitDepth = audioMediaInfo.Resolution,
2201
+ audioBitRateMode = audioMediaInfo.Bit_rate_mode;
2486
2202
  var audioMetadata = parseKeyValuePairTypes(metadata || []);
2487
2203
  var audioSamplerateSamples = timeBase !== null && timeBase !== void 0 && timeBase.denominator ? ((timeBase === null || timeBase === void 0 ? void 0 : timeBase.denominator) || 1) / ((timeBase === null || timeBase === void 0 ? void 0 : timeBase.numerator) || 1) : undefined;
2488
2204
  var audioSamplerate = audioSamplerateSamples !== undefined ? parseFileSize(audioSamplerateSamples, {
@@ -2519,15 +2235,13 @@ var parseAudioComponent = function parseAudioComponent(audioComponentType) {
2519
2235
  */
2520
2236
  var parseFileType = function parseFileType(fileType) {
2521
2237
  var _fileType$uri = fileType.uri,
2522
- uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
2523
- fileSizeBytes = fileType.size,
2524
- hash = fileType.hash,
2525
- path = fileType.path,
2526
- fileId = fileType.id;
2527
-
2238
+ uriList = _fileType$uri === void 0 ? [] : _fileType$uri,
2239
+ fileSizeBytes = fileType.size,
2240
+ hash = fileType.hash,
2241
+ path = fileType.path,
2242
+ fileId = fileType.id;
2528
2243
  var _uriList = _slicedToArray(uriList, 1),
2529
- uri = _uriList[0];
2530
-
2244
+ uri = _uriList[0];
2531
2245
  var fileSize = fileSizeBytes !== undefined ? parseFileSize(fileSizeBytes) : '';
2532
2246
  var fileName = path ? path.split('/').pop() : undefined;
2533
2247
  return {
@@ -2542,9 +2256,7 @@ var parseFileType = function parseFileType(fileType) {
2542
2256
  };
2543
2257
 
2544
2258
  function ownKeys$3(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2545
-
2546
2259
  function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2547
-
2548
2260
  /**
2549
2261
  * Parses the technical information of a BinaryComponentType.
2550
2262
  * @param binaryComponentType - A BinaryComponentType from VidiCore.
@@ -2555,30 +2267,27 @@ function _objectSpread$3(target) { for (var i = 1; i < arguments.length; i++) {
2555
2267
  var parseBinaryComponent = function parseBinaryComponent() {
2556
2268
  var binaryComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2557
2269
  var fileList = binaryComponentType.file,
2558
- mediaInfo = binaryComponentType.mediaInfo,
2559
- _binaryComponentType$ = binaryComponentType.metadata,
2560
- metadata = _binaryComponentType$ === void 0 ? [] : _binaryComponentType$;
2270
+ mediaInfo = binaryComponentType.mediaInfo,
2271
+ _binaryComponentType$ = binaryComponentType.metadata,
2272
+ metadata = _binaryComponentType$ === void 0 ? [] : _binaryComponentType$;
2561
2273
  var binaryMetadata = parseKeyValuePairTypes(metadata);
2562
2274
  var binaryMediaInfo = parseBaseMediaInfoType(mediaInfo);
2563
2275
  var parsedBinaryComponent = {
2564
2276
  binaryMetadata: binaryMetadata,
2565
2277
  binaryMediaInfo: binaryMediaInfo
2566
2278
  };
2567
-
2568
2279
  if (fileList) {
2569
2280
  var _fileList = _slicedToArray(fileList, 1),
2570
- fileType = _fileList[0];
2571
-
2281
+ fileType = _fileList[0];
2572
2282
  var parsedFileType = parseFileType(fileType);
2573
2283
  parsedBinaryComponent = _objectSpread$3(_objectSpread$3({}, parsedBinaryComponent), parsedFileType);
2574
2284
  }
2575
-
2576
2285
  return parsedBinaryComponent;
2577
2286
  };
2578
2287
 
2579
2288
  function ownKeys$2(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2580
-
2581
2289
  function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2290
+
2582
2291
  /**
2583
2292
  * Parsed container component
2584
2293
  */
@@ -2593,32 +2302,27 @@ function _objectSpread$2(target) { for (var i = 1; i < arguments.length; i++) {
2593
2302
  var parseContainerComponent = function parseContainerComponent() {
2594
2303
  var containerComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2595
2304
  var mediaInfo = containerComponentType.mediaInfo,
2596
- metadata = containerComponentType.metadata,
2597
- fileList = containerComponentType.file,
2598
- durationTimeCode = containerComponentType.duration,
2599
- startTimestamp = containerComponentType.startTimestamp,
2600
- startTimecode = containerComponentType.startTimecode,
2601
- timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
2305
+ metadata = containerComponentType.metadata,
2306
+ fileList = containerComponentType.file,
2307
+ durationTimeCode = containerComponentType.duration,
2308
+ startTimestamp = containerComponentType.startTimestamp,
2309
+ startTimecode = containerComponentType.startTimecode,
2310
+ timeCodeTimeBase = containerComponentType.timeCodeTimeBase;
2602
2311
  var containerMetadata = parseKeyValuePairTypes(metadata || []);
2603
2312
  var containerMediaInfo = parseBaseMediaInfoType(mediaInfo);
2604
2313
  var containerFormat = containerMediaInfo.Format;
2605
2314
  var videoFormat = containerMediaInfo.Video_Format_List,
2606
- audioFormat = containerMediaInfo.Audio_Format_List,
2607
- textFormat = containerMediaInfo.Text_Format_List;
2608
-
2315
+ audioFormat = containerMediaInfo.Audio_Format_List,
2316
+ textFormat = containerMediaInfo.Text_Format_List;
2609
2317
  if (containerFormat === undefined) {
2610
2318
  var format = containerComponentType.format;
2611
2319
  containerFormat = format;
2612
-
2613
2320
  if (format && format.includes(',')) {
2614
2321
  var formatList = format.split(',');
2615
-
2616
2322
  var _formatList = _slicedToArray(formatList, 1);
2617
-
2618
2323
  containerFormat = _formatList[0];
2619
2324
  }
2620
2325
  }
2621
-
2622
2326
  var parsedContainerComponentType = {
2623
2327
  containerFormat: containerFormat,
2624
2328
  videoFormat: videoFormat,
@@ -2627,36 +2331,29 @@ var parseContainerComponent = function parseContainerComponent() {
2627
2331
  containerMetadata: containerMetadata,
2628
2332
  containerMediaInfo: containerMediaInfo
2629
2333
  };
2630
-
2631
2334
  if (containerMetadata.componentOriginalFilename) {
2632
2335
  parsedContainerComponentType.originalFilename = containerMetadata.componentOriginalFilename;
2633
2336
  }
2634
-
2635
2337
  if (durationTimeCode !== undefined && durationTimeCode.samples !== 0) {
2636
2338
  var timeCode = formatTimeCodeType(durationTimeCode);
2637
2339
  parsedContainerComponentType.durationTimeCode = timeCode.toObject();
2638
2340
  parsedContainerComponentType.duration = timeCode.toDuration();
2639
2341
  }
2640
-
2641
2342
  if (startTimestamp) {
2642
2343
  parsedContainerComponentType.startTimestamp = formatTimeCodeType(startTimestamp).toObject();
2643
2344
  }
2644
-
2645
2345
  if (startTimecode !== undefined && timeCodeTimeBase) {
2646
2346
  parsedContainerComponentType.startTimecode = formatTimeCodeType({
2647
2347
  samples: startTimecode,
2648
2348
  timeBase: timeCodeTimeBase
2649
2349
  });
2650
2350
  }
2651
-
2652
2351
  if (fileList) {
2653
2352
  var _fileList = _slicedToArray(fileList, 1),
2654
- fileType = _fileList[0];
2655
-
2353
+ fileType = _fileList[0];
2656
2354
  var parsedFileType = parseFileType(fileType);
2657
2355
  parsedContainerComponentType = _objectSpread$2(_objectSpread$2({}, parsedContainerComponentType), parsedFileType);
2658
2356
  }
2659
-
2660
2357
  return parsedContainerComponentType;
2661
2358
  };
2662
2359
 
@@ -2670,23 +2367,22 @@ var parseContainerComponent = function parseContainerComponent() {
2670
2367
  var parseVideoComponent = function parseVideoComponent() {
2671
2368
  var videoComponentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2672
2369
  var videoCodec = videoComponentType.codec,
2673
- bitrate = videoComponentType.bitrate,
2674
- fieldOrder = videoComponentType.fieldOrder,
2675
- resolution = videoComponentType.resolution,
2676
- mediaInfo = videoComponentType.mediaInfo,
2677
- _videoComponentType$m = videoComponentType.metadata,
2678
- metadata = _videoComponentType$m === void 0 ? [] : _videoComponentType$m;
2370
+ bitrate = videoComponentType.bitrate,
2371
+ fieldOrder = videoComponentType.fieldOrder,
2372
+ resolution = videoComponentType.resolution,
2373
+ mediaInfo = videoComponentType.mediaInfo,
2374
+ _videoComponentType$m = videoComponentType.metadata,
2375
+ metadata = _videoComponentType$m === void 0 ? [] : _videoComponentType$m;
2679
2376
  var videoMediaInfo = parseVideoMediaInfoType(mediaInfo);
2680
2377
  var videoMetadata = parseKeyValuePairTypes(metadata);
2681
2378
  var videoFormat = videoMediaInfo.Format,
2682
- timeBaseText = videoMediaInfo['Frame rate'],
2683
- colorSpace = videoMediaInfo['Color space'],
2684
- colorPrimaries = videoMediaInfo['Color primaries'],
2685
- chromaSubsampling = videoMediaInfo.Colorimetry;
2379
+ timeBaseText = videoMediaInfo['Frame rate'],
2380
+ colorSpace = videoMediaInfo['Color space'],
2381
+ colorPrimaries = videoMediaInfo['Color primaries'],
2382
+ chromaSubsampling = videoMediaInfo.Colorimetry;
2686
2383
  var timeBase;
2687
2384
  var averageFrameRate = videoComponentType.averageFrameRate,
2688
- realBaseFrameRate = videoComponentType.realBaseFrameRate;
2689
-
2385
+ realBaseFrameRate = videoComponentType.realBaseFrameRate;
2690
2386
  if (realBaseFrameRate !== undefined) {
2691
2387
  timeBase = formatTimeBaseType({
2692
2388
  numerator: realBaseFrameRate.denominator,
@@ -2700,18 +2396,14 @@ var parseVideoComponent = function parseVideoComponent() {
2700
2396
  denominator: averageFrameRate.numerator
2701
2397
  });
2702
2398
  }
2703
-
2704
2399
  var samples = videoMediaInfo['Frame count'];
2705
-
2706
2400
  if (samples === undefined) {
2707
2401
  var numberOfPackets = videoComponentType.numberOfPackets;
2708
2402
  if (numberOfPackets !== undefined) samples = numberOfPackets.toString();
2709
2403
  }
2710
-
2711
2404
  var timeCode;
2712
2405
  var frameRate;
2713
2406
  var smpte;
2714
-
2715
2407
  if (samples && timeBase) {
2716
2408
  timeCode = formatTimeCodeType({
2717
2409
  samples: samples,
@@ -2720,11 +2412,9 @@ var parseVideoComponent = function parseVideoComponent() {
2720
2412
  frameRate = timeCode.timeBase.toConstant() || timeCode.timeBase.toRate();
2721
2413
  smpte = timeCode.toSmpte();
2722
2414
  }
2723
-
2724
2415
  var _ref = resolution || {},
2725
- height = _ref.height,
2726
- width = _ref.width;
2727
-
2416
+ height = _ref.height,
2417
+ width = _ref.width;
2728
2418
  var aspectRatio = parseAspectRatio(resolution);
2729
2419
  var dimension = "".concat(width, "x").concat(height);
2730
2420
  var videoBitrate = bitrate ? parseFileSize(bitrate, {
@@ -2752,9 +2442,7 @@ var parseVideoComponent = function parseVideoComponent() {
2752
2442
  };
2753
2443
 
2754
2444
  function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2755
-
2756
2445
  function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
2757
-
2758
2446
  /**
2759
2447
  * Parses the technical information of a ShapeType and its various components.
2760
2448
  *
@@ -2773,55 +2461,44 @@ var parseShapeType = function parseShapeType() {
2773
2461
  var shapeType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
2774
2462
  var parsedShape = {};
2775
2463
  var containerComponent = shapeType.containerComponent,
2776
- videoComponentList = shapeType.videoComponent,
2777
- audioComponentList = shapeType.audioComponent,
2778
- binaryComponentList = shapeType.binaryComponent,
2779
- _shapeType$mimeType = shapeType.mimeType,
2780
- mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
2781
- _shapeType$tag = shapeType.tag,
2782
- tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
2783
-
2464
+ videoComponentList = shapeType.videoComponent,
2465
+ audioComponentList = shapeType.audioComponent,
2466
+ binaryComponentList = shapeType.binaryComponent,
2467
+ _shapeType$mimeType = shapeType.mimeType,
2468
+ mimeTypeList = _shapeType$mimeType === void 0 ? [] : _shapeType$mimeType,
2469
+ _shapeType$tag = shapeType.tag,
2470
+ tagList = _shapeType$tag === void 0 ? [] : _shapeType$tag;
2784
2471
  var _tagList = _slicedToArray(tagList, 1);
2785
-
2786
2472
  parsedShape.tag = _tagList[0];
2787
-
2788
2473
  var _mimeTypeList = _slicedToArray(mimeTypeList, 1);
2789
-
2790
2474
  parsedShape.mimeType = _mimeTypeList[0];
2791
-
2792
2475
  if (containerComponent) {
2793
2476
  var parsedContainerComponent = parseContainerComponent(containerComponent);
2794
2477
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedContainerComponent);
2795
2478
  }
2796
-
2797
2479
  if (videoComponentList) {
2798
2480
  var _videoComponentList = _slicedToArray(videoComponentList, 1),
2799
- videoComponent = _videoComponentList[0];
2800
-
2481
+ videoComponent = _videoComponentList[0];
2801
2482
  var parsedVideoComponent = parseVideoComponent(videoComponent);
2802
2483
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedVideoComponent);
2803
2484
  }
2804
-
2805
2485
  if (audioComponentList) {
2806
2486
  var _audioComponentList = _slicedToArray(audioComponentList, 1),
2807
- audioComponent = _audioComponentList[0];
2808
-
2487
+ audioComponent = _audioComponentList[0];
2809
2488
  var parsedAudioComponent = parseAudioComponent(audioComponent);
2810
2489
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedAudioComponent);
2811
2490
  }
2812
-
2813
2491
  if (binaryComponentList) {
2814
2492
  var _binaryComponentList = _slicedToArray(binaryComponentList, 1),
2815
- binaryComponent = _binaryComponentList[0];
2816
-
2493
+ binaryComponent = _binaryComponentList[0];
2817
2494
  var parsedBinaryComponent = parseBinaryComponent(binaryComponent);
2818
2495
  parsedShape = _objectSpread$1(_objectSpread$1({}, parsedShape), parsedBinaryComponent);
2819
2496
  }
2820
-
2821
2497
  return parsedShape;
2822
2498
  };
2823
2499
 
2824
2500
  // eslint-disable-next-line import/no-cycle
2501
+
2825
2502
  var DOCUMENT_TYPES = {
2826
2503
  PDF: 'PDF',
2827
2504
  TEXT: 'TEXT',
@@ -2829,7 +2506,6 @@ var DOCUMENT_TYPES = {
2829
2506
  JSON: 'JSON',
2830
2507
  XML: 'XML'
2831
2508
  };
2832
-
2833
2509
  /**
2834
2510
  * Return a const for the document type of a shape (looks at mimeType)
2835
2511
  *
@@ -2863,21 +2539,20 @@ var QUICKTIME_MIMETYPE = 'video/quicktime';
2863
2539
  var M4V_MIMETYPE = 'video/x-m4v';
2864
2540
  var MP4_CONTAINER = 'MPEG-4';
2865
2541
  var MOV_CONTAINER = 'mov';
2866
- var H264_CODEC = 'h264'; // Sort by tags in the order of previewShapeOrder, secondary alphabetical.
2867
- // using reverse() so the first has highest index
2542
+ var H264_CODEC = 'h264';
2868
2543
 
2544
+ // Sort by tags in the order of previewShapeOrder, secondary alphabetical.
2545
+ // using reverse() so the first has highest index
2869
2546
  var PREVIEW_SHAPE_ORDER = ['__mp4', '__mp3_160k', '__png', '__jpeg', '__gif', 'original'].reverse();
2870
-
2871
2547
  var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
2872
2548
  var firstEl = _ref.parsedShape.tag;
2873
2549
  var secondEl = _ref2.parsedShape.tag;
2874
-
2875
2550
  if (PREVIEW_SHAPE_ORDER.includes(firstEl) || PREVIEW_SHAPE_ORDER.includes(secondEl)) {
2876
2551
  return PREVIEW_SHAPE_ORDER.indexOf(secondEl) - PREVIEW_SHAPE_ORDER.indexOf(firstEl);
2877
2552
  }
2878
-
2879
2553
  return firstEl.toLowerCase().localeCompare(secondEl.toLowerCase());
2880
2554
  };
2555
+
2881
2556
  /**
2882
2557
  * Filter a shape type list to get shapes that are playable in a browser
2883
2558
  *
@@ -2887,67 +2562,59 @@ var defaultSortPriority = function defaultSortPriority(_ref, _ref2) {
2887
2562
  *
2888
2563
  * @category Shape
2889
2564
  */
2890
-
2891
-
2892
2565
  var filterShapeSource = function filterShapeSource(itemType, options) {
2893
2566
  var _ref3 = options || {},
2894
- _ref3$allowedMimeType = _ref3.allowedMimeTypes,
2895
- allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
2896
- _ref3$allowedMethods = _ref3.allowedMethods,
2897
- allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
2898
- _ref3$sortPriority = _ref3.sortPriority,
2899
- sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
2900
- _ref3$sourceKey = _ref3.sourceKey,
2901
- sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
2902
- _ref3$mimeTypeKey = _ref3.mimeTypeKey,
2903
- mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
2904
- _ref3$shapeKey = _ref3.shapeKey,
2905
- shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
2906
- _ref3$parsedShapeKey = _ref3.parsedShapeKey,
2907
- parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShape' : _ref3$parsedShapeKey;
2908
-
2567
+ _ref3$allowedMimeType = _ref3.allowedMimeTypes,
2568
+ allowedMimeTypes = _ref3$allowedMimeType === void 0 ? DEFAULT_ALLOWED_MIME_TYPES : _ref3$allowedMimeType,
2569
+ _ref3$allowedMethods = _ref3.allowedMethods,
2570
+ allowedMethods = _ref3$allowedMethods === void 0 ? DEFAULT_ALLOWED_METHODS : _ref3$allowedMethods,
2571
+ _ref3$sortPriority = _ref3.sortPriority,
2572
+ sortPriority = _ref3$sortPriority === void 0 ? defaultSortPriority : _ref3$sortPriority,
2573
+ _ref3$sourceKey = _ref3.sourceKey,
2574
+ sourceKey = _ref3$sourceKey === void 0 ? 'src' : _ref3$sourceKey,
2575
+ _ref3$mimeTypeKey = _ref3.mimeTypeKey,
2576
+ mimeTypeKey = _ref3$mimeTypeKey === void 0 ? 'type' : _ref3$mimeTypeKey,
2577
+ _ref3$shapeKey = _ref3.shapeKey,
2578
+ shapeKey = _ref3$shapeKey === void 0 ? 'shape' : _ref3$shapeKey,
2579
+ _ref3$parsedShapeKey = _ref3.parsedShapeKey,
2580
+ parsedShapeKey = _ref3$parsedShapeKey === void 0 ? 'parsedShape' : _ref3$parsedShapeKey;
2909
2581
  var _ref4 = itemType || {},
2910
- _ref4$shape = _ref4.shape,
2911
- shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
2912
-
2582
+ _ref4$shape = _ref4.shape,
2583
+ shapeList = _ref4$shape === void 0 ? [] : _ref4$shape;
2913
2584
  var filteredShapeList = shapeList.reduce(function (acc, shapeType) {
2914
2585
  var type;
2915
2586
  var src;
2916
2587
  var parsedShape = parseShapeType(shapeType);
2917
2588
  var uri = parsedShape.uri,
2918
- mimeType = parsedShape.mimeType,
2919
- containerFormat = parsedShape.containerFormat,
2920
- videoCodec = parsedShape.videoCodec;
2921
-
2589
+ mimeType = parsedShape.mimeType,
2590
+ containerFormat = parsedShape.containerFormat,
2591
+ videoCodec = parsedShape.videoCodec;
2922
2592
  if (mimeType) {
2923
2593
  type = mimeType;
2924
2594
  if ((mimeType === QUICKTIME_MIMETYPE || mimeType === M4V_MIMETYPE) && (containerFormat === MP4_CONTAINER || containerFormat === MOV_CONTAINER) && videoCodec === H264_CODEC) type = MP4_MIMETYPE;
2925
2595
  }
2926
-
2927
2596
  if (uri) {
2928
2597
  if (allowedMethods) {
2929
2598
  var _uri$split = uri.split('://'),
2930
- _uri$split2 = _slicedToArray(_uri$split, 1),
2931
- thisMethod = _uri$split2[0];
2932
-
2599
+ _uri$split2 = _slicedToArray(_uri$split, 1),
2600
+ thisMethod = _uri$split2[0];
2933
2601
  if (allowedMethods.includes(thisMethod)) src = uri;
2934
2602
  } else {
2935
2603
  src = uri;
2936
2604
  }
2937
2605
  }
2938
-
2939
2606
  if (src && allowedMimeTypes.includes(type)) {
2940
2607
  var _acc$push;
2941
-
2942
2608
  acc.push((_acc$push = {}, _defineProperty(_acc$push, sourceKey, src), _defineProperty(_acc$push, mimeTypeKey, type), _defineProperty(_acc$push, shapeKey, shapeType), _defineProperty(_acc$push, parsedShapeKey, parsedShape), _acc$push));
2943
2609
  }
2944
-
2945
2610
  return acc;
2946
2611
  }, []);
2947
2612
  if (typeof sortPriority === 'function') filteredShapeList.sort(defaultSortPriority);
2948
2613
  return filteredShapeList;
2949
2614
  };
2950
2615
 
2616
+ // eslint-disable-next-line import/no-cycle
2617
+
2951
2618
  var SHAPE_MEDIA_TYPES = {
2952
2619
  IMAGE: 'IMAGE',
2953
2620
  AUDIO: 'AUDIO',
@@ -2955,7 +2622,6 @@ var SHAPE_MEDIA_TYPES = {
2955
2622
  DOCUMENT: 'DOCUMENT',
2956
2623
  BINARY: 'BINARY'
2957
2624
  };
2958
-
2959
2625
  /**
2960
2626
  * Returns a const for which media type a shape has
2961
2627
  *
@@ -2967,19 +2633,16 @@ var SHAPE_MEDIA_TYPES = {
2967
2633
  var getShapeMediaType = function getShapeMediaType(shape) {
2968
2634
  var parsedShape = parseShapeType(shape);
2969
2635
  var mimeType = parsedShape.mimeType,
2970
- videoCodec = parsedShape.videoCodec,
2971
- audioCodec = parsedShape.audioCodec;
2636
+ videoCodec = parsedShape.videoCodec,
2637
+ audioCodec = parsedShape.audioCodec;
2972
2638
  if (!mimeType) return undefined;
2973
-
2974
2639
  if (mimeType.startsWith('audio/')) {
2975
2640
  if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
2976
2641
  }
2977
-
2978
2642
  if (mimeType.startsWith('video/')) {
2979
2643
  if (videoCodec !== undefined) return SHAPE_MEDIA_TYPES.VIDEO;
2980
2644
  if (audioCodec !== undefined) return SHAPE_MEDIA_TYPES.AUDIO;
2981
2645
  }
2982
-
2983
2646
  if (mimeType.startsWith('image/')) return SHAPE_MEDIA_TYPES.IMAGE;
2984
2647
  if (mimeType.endsWith('/pdf')) return SHAPE_MEDIA_TYPES.DOCUMENT;
2985
2648
  if (mimeType.startsWith('text/')) return SHAPE_MEDIA_TYPES.DOCUMENT;
@@ -3004,13 +2667,11 @@ var getShapeMediaType = function getShapeMediaType(shape) {
3004
2667
  */
3005
2668
  var findNearestThumbnail = function findNearestThumbnail(itemType, timeCode) {
3006
2669
  var tcSeconds = createTimeCode(timeCode).toSeconds();
3007
-
3008
2670
  var _ref = itemType || {},
3009
- _ref$thumbnails = _ref.thumbnails,
3010
- thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
3011
-
2671
+ _ref$thumbnails = _ref.thumbnails,
2672
+ thumbnails = _ref$thumbnails === void 0 ? {} : _ref$thumbnails;
3012
2673
  var _thumbnails$uri = thumbnails.uri,
3013
- srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
2674
+ srcList = _thumbnails$uri === void 0 ? [] : _thumbnails$uri;
3014
2675
  var srcTcSeconds = srcList.map(function (url) {
3015
2676
  var tc = new URL(url).pathname.split('/').pop();
3016
2677
  return formatTimeCodeText(tc).toSeconds();
@@ -3022,7 +2683,8 @@ var findNearestThumbnail = function findNearestThumbnail(itemType, timeCode) {
3022
2683
  };
3023
2684
 
3024
2685
  var _excluded = ["Codec"],
3025
- _excluded2 = ["Codec"];
2686
+ _excluded2 = ["Codec"];
2687
+
3026
2688
  /**
3027
2689
  * TODO
3028
2690
  */
@@ -3037,36 +2699,29 @@ var _excluded = ["Codec"],
3037
2699
  */
3038
2700
  var parseMediaConvertPreset = function parseMediaConvertPreset(mediaconvert) {
3039
2701
  var output = {};
3040
-
3041
2702
  var _ref = mediaconvert || {},
3042
- _ref$outputSetting = _ref.outputSetting,
3043
- outputSetting = _ref$outputSetting === void 0 ? [] : _ref$outputSetting;
3044
-
2703
+ _ref$outputSetting = _ref.outputSetting,
2704
+ outputSetting = _ref$outputSetting === void 0 ? [] : _ref$outputSetting;
3045
2705
  if (outputSetting.length === 0) return output;
3046
2706
  var mc = JSON.parse(outputSetting[0]);
3047
2707
  var _mc$Settings = mc.Settings;
3048
2708
  _mc$Settings = _mc$Settings === void 0 ? {} : _mc$Settings;
3049
2709
  var ContainerSettings = _mc$Settings.ContainerSettings,
3050
- VideoDescription = _mc$Settings.VideoDescription,
3051
- AudioDescriptions = _mc$Settings.AudioDescriptions;
3052
-
2710
+ VideoDescription = _mc$Settings.VideoDescription,
2711
+ AudioDescriptions = _mc$Settings.AudioDescriptions;
3053
2712
  if (ContainerSettings) {
3054
2713
  output.containerFormat = ContainerSettings.Container;
3055
2714
  }
3056
-
3057
2715
  if (VideoDescription) {
3058
2716
  var _VideoDescription$Cod = VideoDescription.CodecSettings,
3059
- CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
3060
-
2717
+ CodecSettings = _VideoDescription$Cod === void 0 ? {} : _VideoDescription$Cod;
3061
2718
  var Codec = CodecSettings.Codec,
3062
- otherSettings = _objectWithoutProperties(CodecSettings, _excluded);
3063
-
2719
+ otherSettings = _objectWithoutProperties(CodecSettings, _excluded);
3064
2720
  output.videoFormat = Codec;
3065
2721
  var height = VideoDescription.Height,
3066
- width = VideoDescription.Width;
2722
+ width = VideoDescription.Width;
3067
2723
  output.height = height;
3068
2724
  output.width = width;
3069
-
3070
2725
  if (height && width) {
3071
2726
  output.dimension = "".concat(width, "x").concat(height);
3072
2727
  output.aspectRatio = parseAspectRatio({
@@ -3074,17 +2729,14 @@ var parseMediaConvertPreset = function parseMediaConvertPreset(mediaconvert) {
3074
2729
  width: width
3075
2730
  });
3076
2731
  }
3077
-
3078
2732
  var _Object$values = Object.values(otherSettings),
3079
- _Object$values2 = _slicedToArray(_Object$values, 1),
3080
- codecSpecs = _Object$values2[0];
3081
-
2733
+ _Object$values2 = _slicedToArray(_Object$values, 1),
2734
+ codecSpecs = _Object$values2[0];
3082
2735
  if (codecSpecs) {
3083
2736
  output.fieldOrder = codecSpecs.InterlaceMode;
3084
2737
  if (output.fieldOrder && output.fieldOrder.includes('TOP')) output.fieldOrder = 'interlaced';
3085
2738
  output.videoBitrate = codecSpecs.Bitrate;
3086
2739
  var numerator = codecSpecs.FramerateDenominator; // other way round to vs ¯\_(ツ)_/¯
3087
-
3088
2740
  var denominator = codecSpecs.FramerateNumerator;
3089
2741
  var timeBase = formatTimeBaseType({
3090
2742
  denominator: denominator,
@@ -3094,78 +2746,61 @@ var parseMediaConvertPreset = function parseMediaConvertPreset(mediaconvert) {
3094
2746
  output.frameRate = timeBase.toConstant() || timeBase.toRate();
3095
2747
  }
3096
2748
  }
3097
-
3098
2749
  if (AudioDescriptions && AudioDescriptions.length > 0) {
3099
2750
  var _AudioDescriptions$0$ = AudioDescriptions[0].CodecSettings,
3100
- _CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
3101
-
2751
+ _CodecSettings = _AudioDescriptions$0$ === void 0 ? {} : _AudioDescriptions$0$;
3102
2752
  var _Codec = _CodecSettings.Codec,
3103
- _otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2);
3104
-
2753
+ _otherSettings = _objectWithoutProperties(_CodecSettings, _excluded2);
3105
2754
  output.audioFormat = _Codec;
3106
-
3107
2755
  var _Object$values3 = Object.values(_otherSettings),
3108
- _Object$values4 = _slicedToArray(_Object$values3, 1),
3109
- _codecSpecs = _Object$values4[0];
3110
-
2756
+ _Object$values4 = _slicedToArray(_Object$values3, 1),
2757
+ _codecSpecs = _Object$values4[0];
3111
2758
  if (_codecSpecs) {
3112
2759
  output.audioSamplerate = _codecSpecs.SampleRate;
3113
2760
  output.audioBitrate = _codecSpecs.Bitrate;
3114
2761
  output.audioBitRateMode = _codecSpecs.RateControlMode;
3115
2762
  }
3116
2763
  }
3117
-
3118
2764
  return output;
3119
2765
  };
3120
2766
 
3121
2767
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3122
-
3123
2768
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3124
2769
  /**
3125
- * TODO
3126
- */
3127
-
3128
- /**
3129
- * TODO
2770
+ * Parse a VidiCore transcode preset
3130
2771
  *
3131
- * @param transcodePresetType
3132
- * @returns
2772
+ * @param transcodePresetType a VidiCore transcode preset
2773
+ * @returns A parsed transcode preset
3133
2774
  *
3134
2775
  * @category Transcode
3135
2776
  */
3136
2777
  var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
3137
2778
  var output = {};
3138
-
3139
2779
  var _ref = transcodePresetType || {},
3140
- description = _ref.description,
3141
- format = _ref.format,
3142
- audio = _ref.audio,
3143
- video = _ref.video,
3144
- mediaconvert = _ref.mediaconvert;
3145
-
2780
+ description = _ref.description,
2781
+ format = _ref.format,
2782
+ audio = _ref.audio,
2783
+ video = _ref.video,
2784
+ mediaconvert = _ref.mediaconvert;
3146
2785
  if (mediaconvert) return _objectSpread({
3147
2786
  description: description
3148
2787
  }, parseMediaConvertPreset(mediaconvert));
3149
2788
  output.description = description;
3150
2789
  output.containerFormat = format;
3151
-
3152
2790
  if (video) {
3153
2791
  output.videoFormat = video.codec;
3154
2792
  output.videoBitrate = video.bitrate;
3155
-
3156
2793
  if (video.framerate) {
3157
2794
  var timeBase = formatTimeBaseType(video.framerate);
3158
2795
  output.timeBase = timeBase;
3159
2796
  output.frameRate = timeBase.toConstant() || timeBase.toRate();
3160
2797
  }
3161
-
3162
2798
  if (video.scaling) {
3163
2799
  var _video$scaling = video.scaling,
3164
- height = _video$scaling.height,
3165
- width = _video$scaling.width;
2800
+ height = _video$scaling.height,
2801
+ width = _video$scaling.width;
3166
2802
  output.height = height;
3167
2803
  output.width = width;
3168
-
3169
2804
  if (height && width) {
3170
2805
  output.dimension = "".concat(width, "x").concat(height);
3171
2806
  output.aspectRatio = parseAspectRatio({
@@ -3175,14 +2810,12 @@ var parseTranscodePreset = function parseTranscodePreset(transcodePresetType) {
3175
2810
  }
3176
2811
  }
3177
2812
  }
3178
-
3179
2813
  if (audio) {
3180
2814
  var audioFormat = audio.codec,
3181
- channel = audio.channel;
2815
+ channel = audio.channel;
3182
2816
  output.audioFormat = audioFormat;
3183
2817
  if (channel) output.audioChannels = channel.length;
3184
2818
  }
3185
-
3186
2819
  return output;
3187
2820
  };
3188
2821