@vidispine/vdt-js 26.1.0-pre.5 → 26.1.0-pre.6

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.d.ts CHANGED
@@ -1461,6 +1461,8 @@ export declare interface ParseValueListOptions extends ParseValueOptions {
1461
1461
  arrayOnSingleValue?: boolean;
1462
1462
  /** Return the value based on selected language if the metadata have languageDependent is true */
1463
1463
  selectedLang?: string;
1464
+ /** Filter values based on selected language, having this setting due to we need to filter selectedLang === undefined */
1465
+ filterSelectedLang?: boolean;
1464
1466
  /** Include language attribute only for language dependent fields */
1465
1467
  includeLangAttrForLangDependentOnly?: boolean;
1466
1468
  }
package/dist/index.js CHANGED
@@ -419,6 +419,7 @@ const St = {
419
419
  joinValue: void 0,
420
420
  arrayOnSingleValue: !0,
421
421
  selectedLang: void 0,
422
+ filterSelectedLang: !1,
422
423
  includeLangAttrForLangDependentOnly: !1
423
424
  };
424
425
  function re(e, t, s) {
@@ -426,18 +427,19 @@ function re(e, t, s) {
426
427
  joinValue: n,
427
428
  arrayOnSingleValue: r,
428
429
  selectedLang: i,
429
- includeLangAttrForLangDependentOnly: o,
430
- ...a
430
+ filterSelectedLang: o,
431
+ includeLangAttrForLangDependentOnly: a,
432
+ ...c
431
433
  } = {
432
434
  ...St,
433
435
  ...t || {}
434
436
  };
435
- let c = e;
436
- s && e && i && (c = e.filter((u) => u.lang === i));
437
- const d = c == null ? void 0 : c.map(
438
- (u) => se(u, a, s && o)
437
+ let l = e;
438
+ s && e && o && (l = e.filter((f) => f.lang === i));
439
+ const u = l == null ? void 0 : l.map(
440
+ (f) => se(f, c, s && a)
439
441
  );
440
- return ee(d) && n ? d == null ? void 0 : d.join(n) : r !== !0 && (d == null ? void 0 : d.length) <= 1 ? d == null ? void 0 : d[0] : d;
442
+ return ee(u) && n ? u == null ? void 0 : u.join(n) : r !== !0 && (u == null ? void 0 : u.length) <= 1 ? u == null ? void 0 : u[0] : u;
441
443
  }
442
444
  const vt = {
443
445
  includeFieldAttributes: !1,
@@ -448,7 +450,7 @@ const vt = {
448
450
  ...t || {}
449
451
  }, { value: i, ...o } = e, a = re(i, r, s), c = n === !0 && o || Array.isArray(n) && Object.fromEntries(
450
452
  Object.entries(o).filter(
451
- ([d]) => n.includes(d)
453
+ ([l]) => n.includes(l)
452
454
  )
453
455
  ) || {};
454
456
  return n ? { ...c, value: a } : a;
@@ -463,13 +465,13 @@ const vt = {
463
465
  ...G,
464
466
  ...t || {}
465
467
  }, { fieldAsList: n, arrayOnSingleField: r, overrideField: i, languageDependentFields: o } = s, a = i === !0 && n === !1, c = {};
466
- return e == null || e.forEach((d) => {
467
- const { name: u } = d, f = (o == null ? void 0 : o.includes(u)) === !0, m = ne(
468
- d,
468
+ return e == null || e.forEach((l) => {
469
+ const { name: u } = l, f = (o == null ? void 0 : o.includes(u)) === !0, m = ne(
470
+ l,
469
471
  s,
470
472
  f
471
- ), p = r === !0 ? F(m) : m, l = c[u];
472
- l ? a ? c[u] = m : c[u] = [F(l), F(m)].flat() : c[u] = p;
473
+ ), p = r === !0 ? F(m) : m, d = c[u];
474
+ d ? a ? c[u] = m : c[u] = [F(d), F(m)].flat() : c[u] = p;
473
475
  }), n === !0 ? Object.values(c).flat() : c;
474
476
  }, Ft = {
475
477
  ...G,
@@ -485,7 +487,7 @@ const vt = {
485
487
  Object.entries(s).filter(
486
488
  ([f]) => Object.keys(G).includes(f)
487
489
  )
488
- ), { field: i, group: o, ...a } = e, c = i && Dt(i, r), d = o && Mt(o, s);
490
+ ), { field: i, group: o, ...a } = e, c = i && Dt(i, r), l = o && Mt(o, s);
489
491
  return {
490
492
  ...n === !0 && a || Array.isArray(n) && Object.fromEntries(
491
493
  Object.entries(a).filter(
@@ -493,16 +495,16 @@ const vt = {
493
495
  )
494
496
  ) || {},
495
497
  ...r != null && r.fieldAsList ? c && { field: c } || {} : c,
496
- ...s != null && s.groupAsList ? d && { group: d } || {} : d
498
+ ...s != null && s.groupAsList ? l && { group: l } || {} : l
497
499
  };
498
500
  }, Q = Ft, Mt = (e, t) => {
499
501
  const s = { ...Q, ...t || {} }, { groupAsList: n, arrayOnSingleGroup: r, overrideGroup: i } = s, o = i === !0 && n === !1, a = {};
500
502
  return e == null || e.forEach((c) => {
501
- const { name: d } = c, u = ie(c, s), f = r === !0 ? F(u) : u, m = a[d];
502
- m ? o ? a[d] = u : a[d] = [
503
+ const { name: l } = c, u = ie(c, s), f = r === !0 ? F(u) : u, m = a[l];
504
+ m ? o ? a[l] = u : a[l] = [
503
505
  F(m),
504
506
  F(u)
505
- ].flat() : a[d] = f;
507
+ ].flat() : a[l] = f;
506
508
  }), n ? Object.values(a).flat() : a;
507
509
  }, Nt = {
508
510
  ...Q,
@@ -517,20 +519,20 @@ const vt = {
517
519
  ...Nt,
518
520
  ...t || {}
519
521
  }, { includeTimespanAttributes: n, arrayOnSingle: r, flat: i } = s, o = Object.fromEntries(
520
- Object.entries(t).map(([l, h]) => {
521
- if (Object.keys(Q).includes(l))
522
- return ["arrayOnSingleGroup", "arrayOnSingleField", "arrayOnSingleValue"].includes(l) && (h !== void 0 ? h : r === !0) ? [l, !0] : ["overrideGroup", "overrideField"].includes(l) && (h !== void 0 ? h : i === !0) ? [l, !0] : [l, h];
523
- }).filter((l) => !!l)
522
+ Object.entries(t).map(([d, h]) => {
523
+ if (Object.keys(Q).includes(d))
524
+ return ["arrayOnSingleGroup", "arrayOnSingleField", "arrayOnSingleValue"].includes(d) && (h !== void 0 ? h : r === !0) ? [d, !0] : ["overrideGroup", "overrideField"].includes(d) && (h !== void 0 ? h : i === !0) ? [d, !0] : [d, h];
525
+ }).filter((d) => !!d)
524
526
  ), a = Object.fromEntries(
525
- Object.entries(t).map(([l, h]) => {
526
- if (Object.keys(G).includes(l))
527
- return ["arrayOnSingleField", "arrayOnSingleValue"].includes(l) && (h !== void 0 ? h : r === !0) ? [l, !0] : ["overrideField"].includes(l) && (h !== void 0 ? h : i === !0) ? [l, !0] : [l, h];
528
- }).filter((l) => !!l)
529
- ), { field: c, group: d, ...u } = e || {}, f = c && Dt(c, a), m = d && Mt(d, o);
527
+ Object.entries(t).map(([d, h]) => {
528
+ if (Object.keys(G).includes(d))
529
+ return ["arrayOnSingleField", "arrayOnSingleValue"].includes(d) && (h !== void 0 ? h : r === !0) ? [d, !0] : ["overrideField"].includes(d) && (h !== void 0 ? h : i === !0) ? [d, !0] : [d, h];
530
+ }).filter((d) => !!d)
531
+ ), { field: c, group: l, ...u } = e || {}, f = c && Dt(c, a), m = l && Mt(l, o);
530
532
  return {
531
533
  ...n === !0 && u || Array.isArray(n) && Object.fromEntries(
532
534
  Object.entries(u).filter(
533
- ([l]) => n.includes(l)
535
+ ([d]) => n.includes(d)
534
536
  )
535
537
  ) || {},
536
538
  ...a != null && a.fieldAsList ? { field: f } : f,
@@ -547,12 +549,12 @@ const vt = {
547
549
  const s = {
548
550
  ...Z,
549
551
  ...t || {}
550
- }, { timespanAsList: n, joinTimespan: r, sortTimespan: i, flat: o, flatTimespan: a, ...c } = s, d = { flat: o, ...c };
552
+ }, { timespanAsList: n, joinTimespan: r, sortTimespan: i, flat: o, flatTimespan: a, ...c } = s, l = { flat: o, ...c };
551
553
  i && e.sort(te);
552
554
  const u = (a !== void 0 ? a === !0 : o === !0) && n === !1, f = {};
553
555
  return e == null || e.forEach((m) => {
554
- const { start: p, end: l } = m, h = u ? "flat" : [p, l].join(r), g = ae(m, d), E = f[h];
555
- E ? u ? p === "-INF" && l === "+INF" ? f[h] = { ...at(E), ...g } : f[h] = { ...g, ...at(E) } : f[h] = [...F(E), g] : f[h] = g;
556
+ const { start: p, end: d } = m, h = u ? "flat" : [p, d].join(r), g = ae(m, l), E = f[h];
557
+ E ? u ? p === "-INF" && d === "+INF" ? f[h] = { ...at(E), ...g } : f[h] = { ...g, ...at(E) } : f[h] = [...F(E), g] : f[h] = g;
556
558
  }), n === !0 ? Object.values(f) : u ? Object.values(f).pop() : f;
557
559
  }, oe = {
558
560
  ...Z,
@@ -716,12 +718,12 @@ const et = (e) => {
716
718
  const { samples: t, timeBase: s } = e, n = st(s);
717
719
  if (!n)
718
720
  return 0;
719
- const r = s.toRate({ rounded: !0 }), i = 60 * r, o = 60 * r - n, a = 10 * (i - n) + n, c = Math.floor((t + 1) / a), d = Math.max(
721
+ const r = s.toRate({ rounded: !0 }), i = 60 * r, o = 60 * r - n, a = 10 * (i - n) + n, c = Math.floor((t + 1) / a), l = Math.max(
720
722
  0,
721
723
  (t + 1) % a - i
722
724
  ), u = Math.floor(
723
- d / o
724
- ), m = d % o > 0 ? n : 0;
725
+ l / o
726
+ ), m = l % o > 0 ? n : 0;
725
727
  return c * 9 * n + u * n + m;
726
728
  }, V = {
727
729
  conformTimeBase: {
@@ -930,44 +932,44 @@ class S {
930
932
  let { minutes: i, seconds: o, milliseconds: a } = r;
931
933
  if (s && typeof s != "string")
932
934
  throw Error("format has to be a string");
933
- const c = (m, p) => !s.includes(m) || !p.some((l) => s.includes(l) && s.lastIndexOf(m) > s.indexOf(l));
935
+ const c = (m, p) => !s.includes(m) || !p.some((d) => s.includes(d) && s.lastIndexOf(m) > s.indexOf(d));
934
936
  if (s && !(c("h", ["m", "s", "S"]) && c("m", ["s", "S"]) && c("s", ["S"])))
935
937
  throw Error("format order is unsupported (has to be h, m, s then S)");
936
938
  if (!s)
937
939
  return `${n > 0 ? `${n}:${`${i}`.padStart(2, "0")}` : i}:${`${o}`.padStart(2, "0")}`;
938
- const d = (m, p) => {
939
- let l = m;
940
- for (; p[l] === p[l + 1]; )
941
- l += 1;
942
- return l - m + 1;
940
+ const l = (m, p) => {
941
+ let d = m;
942
+ for (; p[d] === p[d + 1]; )
943
+ d += 1;
944
+ return d - m + 1;
943
945
  }, u = ["h", "m", "s", "S"], f = [];
944
- return [...s].forEach((m, p, l) => {
946
+ return [...s].forEach((m, p, d) => {
945
947
  switch (m) {
946
948
  case "h": {
947
- if (l[p - 1] === "h")
949
+ if (d[p - 1] === "h")
948
950
  break;
949
- const h = d(p, l);
950
- f.push(`${n}`.padStart(h, "0")), u.includes(l[p + h]) && f.push(":");
951
+ const h = l(p, d);
952
+ f.push(`${n}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(":");
951
953
  break;
952
954
  }
953
955
  case "m": {
954
- if (l[p - 1] === "m")
956
+ if (d[p - 1] === "m")
955
957
  break;
956
- const h = d(p, l);
957
- s.includes("h") || (i += n * 60), f.push(`${i}`.padStart(h, "0")), u.includes(l[p + h]) && f.push(":");
958
+ const h = l(p, d);
959
+ s.includes("h") || (i += n * 60), f.push(`${i}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(":");
958
960
  break;
959
961
  }
960
962
  case "s": {
961
- if (l[p - 1] === "s")
963
+ if (d[p - 1] === "s")
962
964
  break;
963
- const h = d(p, l);
964
- s.includes("m") || (o += i * 60), f.push(`${o}`.padStart(h, "0")), u.includes(l[p + h]) && f.push(".");
965
+ const h = l(p, d);
966
+ s.includes("m") || (o += i * 60), f.push(`${o}`.padStart(h, "0")), u.includes(d[p + h]) && f.push(".");
965
967
  break;
966
968
  }
967
969
  case "S": {
968
- if (l[p - 1] === "S")
970
+ if (d[p - 1] === "S")
969
971
  break;
970
- const h = d(p, l);
972
+ const h = l(p, d);
971
973
  s.includes("s") || (a += o * 1e3), f.push(`${Math.round(a / 10 ** (3 - h))}`.padStart(h, "0"));
972
974
  break;
973
975
  }
@@ -994,8 +996,8 @@ class S {
994
996
  n.toFixed().padStart(2, "0"),
995
997
  r.toFixed().padStart(2, "0"),
996
998
  i.toFixed().padStart(2, "0")
997
- ].join(a), d = Math.max(2, `${this.timeBase.toRate({ rounded: !0 }) - 1}`.length);
998
- return [c, `${o}`.padStart(d, "0")].join(this.frameSeparator);
999
+ ].join(a), l = Math.max(2, `${this.timeBase.toRate({ rounded: !0 }) - 1}`.length);
1000
+ return [c, `${o}`.padStart(l, "0")].join(this.frameSeparator);
999
1001
  }
1000
1002
  /**
1001
1003
  * Get TimeCode as a VidiCore TimeCodeType object
@@ -1037,22 +1039,22 @@ const ue = (e, t) => {
1037
1039
  const u = ue(a, c);
1038
1040
  c /= u, a /= u;
1039
1041
  }
1040
- const d = new S(
1042
+ const l = new S(
1041
1043
  { samples: c, timeBase: { denominator: a, numerator: 1 } },
1042
1044
  i
1043
1045
  );
1044
- return s !== void 0 ? d.conformTimeBase(s, { ...i, roundingMode: r }) : d;
1046
+ return s !== void 0 ? l.conformTimeBase(s, { ...i, roundingMode: r }) : l;
1045
1047
  }, le = ([e, t, s, n], r, i) => {
1046
1048
  const o = i.toRate({ rounded: !0 }), a = st(i);
1047
1049
  if (r === 0 || !a)
1048
1050
  return 0;
1049
- const c = t % 10 !== 0, d = c && s === 0, u = e * (3600 * o - 54 * a), f = t * 60 * o - (t - Math.ceil(t / 10)) * a, m = s * o - (c && s > 1 ? a : 0);
1050
- if (d && n < a)
1051
+ const c = t % 10 !== 0, l = c && s === 0, u = e * (3600 * o - 54 * a), f = t * 60 * o - (t - Math.ceil(t / 10)) * a, m = s * o - (c && s > 1 ? a : 0);
1052
+ if (l && n < a)
1051
1053
  throw new Error(
1052
1054
  `Frame does not exist for ${i.toConstant() || i.toRate()} drop-frame`
1053
1055
  );
1054
- const p = d ? n - a : n, l = u + f + m + p;
1055
- return r - l;
1056
+ const p = l ? n - a : n, d = u + f + m + p;
1057
+ return r - d;
1056
1058
  }, H = (e, t, s) => {
1057
1059
  const [n, r, i, o] = e, a = t.toRate({ rounded: !0 }), c = n * 3600 * a + r * 60 * a + i * a + o;
1058
1060
  return c - (s ? le(e, c, t) : 0);
@@ -1090,16 +1092,16 @@ const ue = (e, t) => {
1090
1092
  ...(r == null ? void 0 : r.dropFrame) === void 0 ? {
1091
1093
  dropFrame: n !== void 0 ? wt(a) : [";", ","].includes(o)
1092
1094
  } : {}
1093
- }, d = a.toRate({ rounded: !0 }), u = Math.max(0, d - 1);
1095
+ }, l = a.toRate({ rounded: !0 }), u = Math.max(0, l - 1);
1094
1096
  if (i.some((m) => m < 0))
1095
1097
  throw new Error("Negative values are not supported");
1096
1098
  let f;
1097
1099
  switch (s) {
1098
1100
  case "error": {
1099
- const [m, p, l, h] = i;
1101
+ const [m, p, d, h] = i;
1100
1102
  if (m >= 100 || p >= 60)
1101
1103
  throw Error("Minutes has to be less than 60");
1102
- if (l >= 60)
1104
+ if (d >= 60)
1103
1105
  throw Error("Seconds has to be less than 60");
1104
1106
  if (h > u)
1105
1107
  throw Error(`Frames has to be less or equal to ${u}`);
@@ -1107,10 +1109,10 @@ const ue = (e, t) => {
1107
1109
  break;
1108
1110
  }
1109
1111
  case "ignore": {
1110
- const [m, p, l, h] = i, g = [
1112
+ const [m, p, d, h] = i, g = [
1111
1113
  Math.min(100, m),
1112
1114
  Math.min(59, p),
1113
- Math.min(59, l),
1115
+ Math.min(59, d),
1114
1116
  Math.min(u, h)
1115
1117
  ];
1116
1118
  f = H(
@@ -1183,12 +1185,12 @@ const Ae = {
1183
1185
  }).map((a) => {
1184
1186
  const {
1185
1187
  start: c,
1186
- end: d,
1188
+ end: l,
1187
1189
  [s]: { [n]: u } = {}
1188
1190
  } = (Array.isArray(a) ? a[0] : a) || {};
1189
1191
  if (!u)
1190
1192
  return "";
1191
- const f = dt(U(c).toTime()), m = dt(U(d).toTime());
1193
+ const f = dt(U(c).toTime()), m = dt(U(l).toTime());
1192
1194
  return `${f} --> ${m} line:0%\r${u}\r`;
1193
1195
  });
1194
1196
  if (o.some((a) => !!a))
@@ -1238,8 +1240,8 @@ ${o.join(`
1238
1240
  const { name: m, value: p = [] } = f;
1239
1241
  if (p.length === 0)
1240
1242
  return u;
1241
- let l;
1242
- return s === !1 && p.length === 1 ? [l] = p : n ? l = p.join(n) : l = p, { ...u, [m]: l };
1243
+ let d;
1244
+ return s === !1 && p.length === 1 ? [d] = p : n ? d = p.join(n) : d = p, { ...u, [m]: d };
1243
1245
  }, c);
1244
1246
  }, Oe = {
1245
1247
  ...Lt,
@@ -1275,7 +1277,7 @@ ${o.join(`
1275
1277
  const c = a.split("/").pop().split("?").shift();
1276
1278
  return U(c).toSeconds();
1277
1279
  }), o = i.reduce(
1278
- (a, c, d) => Math.abs(c - s) < Math.abs(i[a] - s) ? d : a,
1280
+ (a, c, l) => Math.abs(c - s) < Math.abs(i[a] - s) ? l : a,
1279
1281
  0
1280
1282
  );
1281
1283
  return r[o];
@@ -1295,9 +1297,9 @@ ${o.join(`
1295
1297
  const { entry: s = [] } = e, n = {
1296
1298
  ...Re,
1297
1299
  ...t || {}
1298
- }, { includeGroupMetadata: r, flatEvents: i, includeEntityType: o, includeNearestThumbnail: a } = n, c = s.map((d) => {
1299
- const { type: u, item: { metadata: f = {}, id: m, thumbnails: p = {} } = {}, timespan: l, item: h } = d;
1300
- let g = l.map(
1300
+ }, { includeGroupMetadata: r, flatEvents: i, includeEntityType: o, includeNearestThumbnail: a } = n, c = s.map((l) => {
1301
+ const { type: u, item: { metadata: f = {}, id: m, thumbnails: p = {} } = {}, timespan: d, item: h } = l;
1302
+ let g = d.map(
1301
1303
  (E) => ye(E)
1302
1304
  );
1303
1305
  if (a && u === "Item" && p.uri && (g = g.map((E) => {
@@ -1340,16 +1342,16 @@ ${o.join(`
1340
1342
  };
1341
1343
  });
1342
1344
  return i ? c.flatMap(
1343
- ({ events: d, entityType: u, entityId: f, itemType: m, collectionType: p }) => d.map(
1344
- (l) => ({
1345
- ...l,
1345
+ ({ events: l, entityType: u, entityId: f, itemType: m, collectionType: p }) => l.map(
1346
+ (d) => ({
1347
+ ...d,
1346
1348
  entityType: u,
1347
1349
  entityId: f,
1348
1350
  ...m && { itemType: m },
1349
1351
  ...p && { collectionType: p }
1350
1352
  })
1351
1353
  )
1352
- ).sort((d, u) => d.startSeconds - u.startSeconds) : c;
1354
+ ).sort((l, u) => l.startSeconds - u.startSeconds) : c;
1353
1355
  }, gs = (e = "NOW") => {
1354
1356
  if (e.startsWith("NOW")) {
1355
1357
  if (e === "NOW")
@@ -1390,23 +1392,23 @@ ${o.join(`
1390
1392
  metadata: o
1391
1393
  } = e, a = Se(r), {
1392
1394
  Format: c,
1393
- Resolution: d,
1395
+ Resolution: l,
1394
1396
  Bit_rate_mode: u
1395
1397
  } = a, f = M(o || []), m = t != null && t.denominator ? ((t == null ? void 0 : t.denominator) || 1) / ((t == null ? void 0 : t.numerator) || 1) : void 0, p = m !== void 0 ? w(m, {
1396
1398
  base: 10,
1397
1399
  round: 1,
1398
1400
  symbols: De
1399
1401
  }) : void 0;
1400
- let l, h;
1401
- return i !== void 0 && (l = w(i, { round: 2, symbols: lt }), h = Number(
1402
+ let d, h;
1403
+ return i !== void 0 && (d = w(i, { round: 2, symbols: lt }), h = Number(
1402
1404
  (g = w(i, { exponent: 1, symbols: lt }).split(" kbps")) == null ? void 0 : g[0]
1403
1405
  )), {
1404
1406
  audioFormat: c,
1405
1407
  audioCodec: n,
1406
1408
  audioSamplerate: p,
1407
1409
  audioSamplerateSamples: m,
1408
- audioBitDepth: d,
1409
- audioBitrate: l,
1410
+ audioBitDepth: l,
1411
+ audioBitrate: d,
1410
1412
  audioBitrateKbps: h,
1411
1413
  audioBitRateMode: u,
1412
1414
  audioChannels: s,
@@ -1444,7 +1446,7 @@ ${o.join(`
1444
1446
  path: r,
1445
1447
  id: i,
1446
1448
  storage: o
1447
- } = e, [a] = t, c = s !== void 0 ? w(s, { base: 2, standard: "jedec" }) : "", d = (r == null ? void 0 : r.split("/")) || [], u = d.pop() || "", f = d.map((m) => `${m}/`).join("") || void 0;
1449
+ } = e, [a] = t, c = s !== void 0 ? w(s, { base: 2, standard: "jedec" }) : "", l = (r == null ? void 0 : r.split("/")) || [], u = l.pop() || "", f = l.map((m) => `${m}/`).join("") || void 0;
1448
1450
  return {
1449
1451
  uri: a,
1450
1452
  hash: n,
@@ -1476,40 +1478,40 @@ ${o.join(`
1476
1478
  startTimestamp: i,
1477
1479
  startTimecode: o,
1478
1480
  timeCodeTimeBase: a
1479
- } = e, c = M(s || []), d = z(t);
1480
- let { Format: u } = d;
1481
+ } = e, c = M(s || []), l = z(t);
1482
+ let { Format: u } = l;
1481
1483
  const {
1482
1484
  Video_Format_List: f,
1483
1485
  Audio_Format_List: m,
1484
1486
  Text_Format_List: p
1485
- } = d;
1487
+ } = l;
1486
1488
  if (u === void 0) {
1487
1489
  const { format: h } = e;
1488
1490
  u = h, h && h.includes(",") && ([u] = h.split(","));
1489
1491
  }
1490
- let l = {
1492
+ let d = {
1491
1493
  containerFormat: u,
1492
1494
  videoFormat: f,
1493
1495
  audioFormat: m,
1494
1496
  textFormat: p,
1495
1497
  containerMetadata: c,
1496
- containerMediaInfo: d
1498
+ containerMediaInfo: l
1497
1499
  };
1498
- if (c.componentOriginalFilename && (l.originalFilename = c.componentOriginalFilename), r !== void 0 && r.samples !== 0) {
1500
+ if (c.componentOriginalFilename && (d.originalFilename = c.componentOriginalFilename), r !== void 0 && r.samples !== 0) {
1499
1501
  const h = P(r);
1500
- l.durationTimeCode = h.toObject(), l.duration = h.toDuration();
1502
+ d.durationTimeCode = h.toObject(), d.duration = h.toDuration();
1501
1503
  }
1502
- if (i && (l.startTimestamp = P(i).toObject()), o !== void 0 && a && (l.startTimecode = P({
1504
+ if (i && (d.startTimestamp = P(i).toObject()), o !== void 0 && a && (d.startTimecode = P({
1503
1505
  samples: o,
1504
1506
  timeBase: a
1505
1507
  })), n) {
1506
1508
  const [h] = n, g = Bt(h);
1507
- l = {
1508
- ...l,
1509
+ d = {
1510
+ ...d,
1509
1511
  ...g
1510
1512
  };
1511
1513
  }
1512
- return l;
1514
+ return d;
1513
1515
  }, ft = { kB: "kbps", B: "bps", MB: "mbps" }, Ce = (e = {}) => {
1514
1516
  var k;
1515
1517
  const {
@@ -1520,18 +1522,18 @@ ${o.join(`
1520
1522
  mediaInfo: i,
1521
1523
  metadata: o = []
1522
1524
  } = e, a = ve(i), c = M(o), {
1523
- Format: d,
1525
+ Format: l,
1524
1526
  "Frame rate": u,
1525
1527
  "Color space": f,
1526
1528
  "Color primaries": m,
1527
1529
  Colorimetry: p
1528
1530
  } = a;
1529
- let l;
1531
+ let d;
1530
1532
  const { averageFrameRate: h, realBaseFrameRate: g } = e;
1531
- g !== void 0 ? l = x({
1533
+ g !== void 0 ? d = x({
1532
1534
  numerator: g.denominator,
1533
1535
  denominator: g.numerator
1534
- }) : u !== void 0 ? l = et(u) : h !== void 0 && (l = x({
1536
+ }) : u !== void 0 ? d = et(u) : h !== void 0 && (d = x({
1535
1537
  numerator: h.denominator,
1536
1538
  denominator: h.numerator
1537
1539
  }));
@@ -1541,18 +1543,18 @@ ${o.join(`
1541
1543
  it !== void 0 && (E = it.toString());
1542
1544
  }
1543
1545
  let A, O, I;
1544
- E && l && (A = P({ samples: E, timeBase: l }), O = A.timeBase.toConstant() || A.timeBase.toRate(), I = A.toSmpte());
1546
+ E && d && (A = P({ samples: E, timeBase: d }), O = A.timeBase.toConstant() || A.timeBase.toRate(), I = A.toSmpte());
1545
1547
  const { height: b, width: D } = r || {}, N = J(r), C = `${D}x${b}`;
1546
1548
  let v, L;
1547
1549
  return s !== void 0 && (v = w(s, { round: 2, symbols: ft }), L = Number(
1548
1550
  (k = w(s, { exponent: 2, symbols: ft }).split(" mbps")) == null ? void 0 : k[0]
1549
1551
  )), {
1550
- videoFormat: d,
1552
+ videoFormat: l,
1551
1553
  dimension: C,
1552
1554
  frameRate: O,
1553
1555
  height: b,
1554
1556
  width: D,
1555
- timeBase: l,
1557
+ timeBase: d,
1556
1558
  timeCode: A,
1557
1559
  videoCodec: t,
1558
1560
  smpte: I,
@@ -1574,9 +1576,9 @@ ${o.join(`
1574
1576
  audioComponent: o,
1575
1577
  binaryComponent: a,
1576
1578
  mimeType: c = [],
1577
- tag: d = []
1579
+ tag: l = []
1578
1580
  } = e;
1579
- [s.tag] = d, [s.mimeType] = c;
1581
+ [s.tag] = l, [s.mimeType] = c;
1580
1582
  const u = (f, m) => Object.fromEntries(
1581
1583
  [.../* @__PURE__ */ new Set([...Object.keys(m), ...Object.keys(f)])].map((p) => [
1582
1584
  p,
@@ -1681,17 +1683,17 @@ ${o.join(`
1681
1683
  mimeTypeKey: o = "type",
1682
1684
  shapeKey: a = "shape",
1683
1685
  parsedShapeKey: c = "parsedShape"
1684
- } = t || {}, { shape: d = [] } = e || {}, u = d.reduce((f, m) => {
1685
- let p, l;
1686
+ } = t || {}, { shape: l = [] } = e || {}, u = l.reduce((f, m) => {
1687
+ let p, d;
1686
1688
  const h = rt(m), { uri: g, mimeType: E, containerFormat: A, videoCodec: O } = h;
1687
1689
  if (E && (p = E, (E === ke || E === We) && (A === $e || A === Ue) && O === Ge && (p = je)), g)
1688
1690
  if (n) {
1689
1691
  const [I] = g.split("://");
1690
- n.includes(I) && (l = g);
1692
+ n.includes(I) && (d = g);
1691
1693
  } else
1692
- l = g;
1693
- return l && s.includes(p) && f.push({
1694
- [i]: l,
1694
+ d = g;
1695
+ return d && s.includes(p) && f.push({
1696
+ [i]: d,
1695
1697
  [o]: p,
1696
1698
  [a]: m,
1697
1699
  [c]: h
@@ -1748,19 +1750,19 @@ ${o.join(`
1748
1750
  flat: !0,
1749
1751
  arrayOnSingleValue: !1
1750
1752
  });
1751
- return i.reduce((c, d) => {
1753
+ return i.reduce((c, l) => {
1752
1754
  var D, N, C;
1753
1755
  let u, f, m;
1754
- const p = rt(d), { uri: l, mimeType: h, containerFormat: g, videoCodec: E } = p;
1755
- if (!(s != null && s.includes(h)) || !(n != null && n.includes((D = l == null ? void 0 : l.split("://")) == null ? void 0 : D[0])))
1756
+ const p = rt(l), { uri: d, mimeType: h, containerFormat: g, videoCodec: E } = p;
1757
+ if (!(s != null && s.includes(h)) || !(n != null && n.includes((D = d == null ? void 0 : d.split("://")) == null ? void 0 : D[0])))
1756
1758
  return c;
1757
1759
  if (m = p.tag, !m) {
1758
1760
  const v = (C = (N = h == null ? void 0 : h.split) == null ? void 0 : N.call(h, "/")) == null ? void 0 : C.pop(), L = c.filter((k) => k.label === v).length;
1759
1761
  L === 0 ? m = v : m = v + (L + 1);
1760
1762
  }
1761
1763
  const { timeBase: A, startTimecode: O } = p, I = o ?? O, b = I && j(I);
1762
- return f = l, u = h, (h === xt || h === jt) && (g === ze || g === Ve) && E === He && (u = Pt), r != null && r.length && kt.includes(h) && (f = Qe({
1763
- url: l,
1764
+ return f = d, u = h, (h === xt || h === jt) && (g === ze || g === Ve) && E === He && (u = Pt), r != null && r.length && kt.includes(h) && (f = Qe({
1765
+ url: d,
1764
1766
  streamingServers: r,
1765
1767
  ending: "mpd"
1766
1768
  }), u = "application/dash+xml"), f && c.push({
@@ -1777,21 +1779,21 @@ ${o.join(`
1777
1779
  return t;
1778
1780
  const n = JSON.parse(s[0]), { Settings: { ContainerSettings: r, VideoDescription: i, AudioDescriptions: o } = {} } = n;
1779
1781
  if (r && (t.containerFormat = r.Container), i) {
1780
- const { CodecSettings: a = {} } = i, { Codec: c, ...d } = a;
1782
+ const { CodecSettings: a = {} } = i, { Codec: c, ...l } = a;
1781
1783
  t.videoFormat = c;
1782
1784
  const { Height: u, Width: f } = i;
1783
1785
  t.height = u, t.width = f, u && f && (t.dimension = `${f}x${u}`, t.aspectRatio = J({ height: u, width: f }));
1784
- const [m] = Object.values(d);
1786
+ const [m] = Object.values(l);
1785
1787
  if (m) {
1786
1788
  t.fieldOrder = m.InterlaceMode, t.fieldOrder && t.fieldOrder.includes("TOP") && (t.fieldOrder = "interlaced"), t.videoBitrate = m.Bitrate;
1787
- const p = m.FramerateDenominator, l = m.FramerateNumerator, h = x({ denominator: l, numerator: p });
1789
+ const p = m.FramerateDenominator, d = m.FramerateNumerator, h = x({ denominator: d, numerator: p });
1788
1790
  t.timeBase = h, t.frameRate = h.toConstant() || h.toRate();
1789
1791
  }
1790
1792
  }
1791
1793
  if (o && o.length > 0) {
1792
- const { CodecSettings: a = {} } = o[0], { Codec: c, ...d } = a;
1794
+ const { CodecSettings: a = {} } = o[0], { Codec: c, ...l } = a;
1793
1795
  t.audioFormat = c;
1794
- const [u] = Object.values(d);
1796
+ const [u] = Object.values(l);
1795
1797
  u && (t.audioSamplerate = u.SampleRate, t.audioBitrate = u.Bitrate, t.audioBitRateMode = u.RateControlMode);
1796
1798
  }
1797
1799
  return t;
@@ -1826,13 +1828,13 @@ ${o.join(`
1826
1828
  integerRestriction: o,
1827
1829
  longRestriction: a,
1828
1830
  data: c,
1829
- values: d,
1831
+ values: l,
1830
1832
  system: u
1831
- } = e, { minLength: f, maxLength: m, pattern: p } = r || {}, { minInclusive: l, maxInclusive: h } = i || o || a || {}, g = ((d == null ? void 0 : d.field) || []).map(({ key: I, value: b }) => ({
1833
+ } = e, { minLength: f, maxLength: m, pattern: p } = r || {}, { minInclusive: d, maxInclusive: h } = i || o || a || {}, g = ((l == null ? void 0 : l.field) || []).map(({ key: I, value: b }) => ({
1832
1834
  label: b ?? I,
1833
1835
  value: I
1834
1836
  })), A = ((I) => Object.fromEntries(Object.entries(I).filter(([, b]) => b !== void 0)))({
1835
- min: l,
1837
+ min: d,
1836
1838
  max: h,
1837
1839
  minLength: f,
1838
1840
  maxLength: m,
@@ -1842,7 +1844,7 @@ ${o.join(`
1842
1844
  name: t,
1843
1845
  type: s,
1844
1846
  defaultValue: n,
1845
- required: l !== void 0 || f !== void 0 && f > 0,
1847
+ required: d !== void 0 || f !== void 0 && f > 0,
1846
1848
  restrictions: A,
1847
1849
  data: O,
1848
1850
  options: g,
@@ -2060,11 +2062,11 @@ class ht {
2060
2062
  n.push({ start: 0, end: t.size });
2061
2063
  else
2062
2064
  for (let c = 0; c <= a; c += 1) {
2063
- const d = o * c;
2065
+ const l = o * c;
2064
2066
  let u = o * c + o;
2065
2067
  t.size - o * c <= r && (u = t.size);
2066
2068
  const m = {
2067
- start: d,
2069
+ start: l,
2068
2070
  end: u
2069
2071
  };
2070
2072
  if (n.push(m), u === t.size)
@@ -2151,15 +2153,15 @@ class ht {
2151
2153
  }
2152
2154
  getStats() {
2153
2155
  const t = this.state.chunks.length, s = this.state.chunks.filter(
2154
- (d) => d.state.status === _.complete
2156
+ (l) => l.state.status === _.complete
2155
2157
  ), n = this.state.chunks.filter(
2156
- (d) => d.state.status === _.transferring
2158
+ (l) => l.state.status === _.transferring
2157
2159
  ), r = s.length;
2158
2160
  let i = 0, o = 0;
2159
- s.forEach((d) => {
2160
- i += d.transferRate, o += d.blobSlice.size;
2161
- }), n.forEach((d) => {
2162
- o += d.state.bytesTransferred;
2161
+ s.forEach((l) => {
2162
+ i += l.transferRate, o += l.blobSlice.size;
2163
+ }), n.forEach((l) => {
2164
+ o += l.state.bytesTransferred;
2163
2165
  });
2164
2166
  const a = i / r, c = {
2165
2167
  totalChunks: t,
@@ -2368,8 +2370,8 @@ class vs {
2368
2370
  }
2369
2371
  const Wt = (e, t, s = "") => {
2370
2372
  const n = (a) => {
2371
- const c = a.startsWith("/") ? a.slice(1) : a, d = (c == null ? void 0 : c.search("/")) ?? -1;
2372
- return d === -1 ? [c] : [c.slice(0, d), c.slice(d + 1)];
2373
+ const c = a.startsWith("/") ? a.slice(1) : a, l = (c == null ? void 0 : c.search("/")) ?? -1;
2374
+ return l === -1 ? [c] : [c.slice(0, l), c.slice(l + 1)];
2373
2375
  }, [r, i] = n(t), o = [s, r].filter(Boolean).join("/");
2374
2376
  return i ? {
2375
2377
  [r]: {
@@ -1,5 +1,5 @@
1
- (function(p,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("filesize"),require("url-join"),require("lodash.merge")):typeof define=="function"&&define.amd?define(["exports","filesize","url-join","lodash.merge"],v):(p=typeof globalThis<"u"?globalThis:p||self,v(p["@vidispine/vdt-js"]={},p.filesize,p.urlJoin,p._merge))})(this,function(p,v,se,re){"use strict";const lt=(e,t)=>t?lt(t,e%t):e,J=e=>{const{width:t,height:s}=e||{};if(t===void 0||s===void 0)return;const i=lt(t,s);let r=t/i,n=s/i;return r>21&&(n=1,r=(t/s).toFixed(2)),[r,n].join(":")},D=e=>Object.fromEntries((e==null?void 0:e.map(({key:t,value:s})=>[t,s]))||[]),ie=(e,t,s)=>{let i;return r=>{const o=()=>{i=null,s||e.apply(void 0,r)},a=s&&!i;clearTimeout(i),i=setTimeout(o,t),a&&e.apply(void 0,r)}};function ne(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}const ae={ACCESSCONTROL_READ:"_accesscontrol_read",ACCESSCONTROL_WRITE:"_accesscontrol_write",ADMINISTRATOR:"_administrator",AUTO_PROJECTION_READ:"_auto_projection_read",AUTO_PROJECTION_WRITE:"_auto_projection_write",COLLECTION_NOTIFICATION_READ:"_collection_notification_read",COLLECTION_NOTIFICATION_WRITE:"_collection_notification_write",COLLECTION_READ:"_collection_read",COLLECTION_WRITE:"_collection_write",CONFIGURATION_READ:"_configuration_read",DELETION_LOCK_NOTIFICATION_READ:"_deletion_lock_notification_read",DELETION_LOCK_NOTIFICATION_WRITE:"_deletion_lock_notification_write",DELETION_LOCK_READ:"_deletion_lock_read",DELETION_LOCK_WRITE:"_deletion_lock_write",DOCUMENT_NOTIFICATION_READ:"_document_notification_read",DOCUMENT_NOTIFICATION_WRITE:"_document_notification_write",DOCUMENT_READ:"_document_read",DOCUMENT_WRITE:"_document_write",ERROR_READ:"_error_read",ERROR_WRITE:"_error_write",EXPORT:"_export",EXPORT_TEMPLATE_READ:"_export_template_read",EXPORT_TEMPLATE_WRITE:"_export_template_write",EXTERNAL_ID_READ:"_external_id_read",EXTERNAL_ID_WRITE:"_external_id_write",FILE_NOTIFICATION_READ:"_file_notification_read",FILE_NOTIFICATION_WRITE:"_file_notification_write",FILE_READ:"_file_read",FILE_WRITE:"_file_write",GROUP_READ:"_group_read",GROUP_WRITE:"_group_write",IMPORT_WRITE:"_import",ITEM_ID_READ:"_item_id_read",ITEM_ID_WRITE:"_item_id_write",ITEM_NOTIFICATION_READ:"_item_notification_read",ITEM_NOTIFICATION_WRITE:"_item_notification_write",ITEM_WRITE:"_item_write",ITEM_SEARCH:"_item_search",ITEM_SHAPE_READ:"_item_shape_read",ITEM_SHAPE_WRITE:"_item_shape_write",ITEM_TIMELINE_READ:"_item_timeline_read",ITEM_TIMELINE_WRITE:"_item_timeline_write",ITEM_URI:"_item_uri",JOB_NOTIFICATION_READ:"_job_notification_read",JOB_NOTIFICATION_WRITE:"_job_notification_write",JOB_READ:"_job_read",JOB_WRITE:"_job_write",LIBRARY_READ:"_library_read",LIBRARY_WRITE:"_library_write",LOCK_READ:"_lock_read",LOCK_WRITE:"_lock_write",LOG_READ:"_log_read",METADATA_DATASET_READ:"_metadata_dataset_read",METADATA_DATASET_WRITE:"_metadata_dataset_write",METADATA_FIELD_GROUP_READ:"_metadata_field_group_read",METADATA_FIELD_GROUP_WRITE:"_metadata_field_group_write",METADATA_FIELD_READ:"_metadata_field_read",METADATA_FIELD_WRITE:"_metadata_field_write",METADATA_GLOBAL_READ:"_metadata_global_read",METADATA_GLOBAL_WRITE:"_metadata_global_write",METADATA_LOCK_READ:"_metadata_lock_read",METADATA_LOCK_WRITE:"_metadata_lock_write",METADATA_READ:"_metadata_read",METADATA_SCHEMA_READ:"_metadata_schema_read",METADATA_SCHEMA_WRITE:"_metadata_schema_write",METADATA_WRITE:"_metadata_write",OTIF_ANALYZE:"_otif_analyze",OTIF_READ:"_otif_read",OTIF_WRITE:"_otif_write",PLACEHOLDER_NOTIFICATION_READ:"_placeholder_notification_read",PLACEHOLDER_NOTIFICATION_WRITE:"_placeholder_notification_write",PROJECTION_READ:"_projection_read",PROJECTION_WRITE:"_projection_write",QUOTA_NOTIFICATION_READ:"_quota_notification_read",QUOTA_NOTIFICATION_WRITE:"_quota_notification_write",QUOTA_READ:"_quota_read",QUOTA_WRITE:"_quota_write",RELATION_READ:"_relation_read",RELATION_WRITE:"_relation_write",RESOURCE_READ:"_resource_read",RESOURCE_WRITE:"_resource_write",RUN_AS:"_run_as",SEARCH:"_search",SEQUENCE_READ:"_sequence_read",SEQUENCE_WRITE:"_sequence_write",SHAPE_TAG_READ:"_shape_tag_read",SHAPE_TAG_WRITE:"_shape_tag_write",SITE_MANAGER:"_site_manager",SITE_RULE_READ:"_site_rule_read",SITE_RULE_WRITE:"_site_rule_write",STORAGE_GROUP_READ:"_storage_group_read",STORAGE_GROUP_WRITE:"_storage_group_write",STORAGE_NOTIFICATION_READ:"_storage_notification_read",STORAGE_NOTIFICATION_WRITE:"_storage_notification_write",STORAGE_READ:"_storage_read",STORAGE_RULE_READ:"_storage_rule_read",STORAGE_RULE_WRITE:"_storage_rule_write",STORAGE_WRITE:"_storage_write",SUPER_ACCESS_USER:"_super_access_user",TASKDEFINITION_READ:"_taskdefinition_read",TASKDEFINITION_WRITE:"_taskdefinition_write",THUMBNAIL_READ:"_thumbnail_read",THUMBNAIL_WRITE:"_thumbnail_write",TRANSCODER:"_transcoder",TRANSFER_READ:"_transfer_read",TRANSFER_WRITE:"_transfer_write",USER:"_user",VXA:"_vxa",VXA_READ:"_vxa_read"},oe=["stl_subtitle","stl_tti","stl_gsi","mrk_marker","pho_validation","pho_resource","pho_error","facedetect_rect","facedetect_face","originalTrackFilename","stl_gsiHeader"],ce=["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"],X=["uuid","user","timestamp","change","conflict","mode"],ft=["name","id","referenced","data","inheritance"],mt=[...X,"value","lang"],ht=[...X,...ft,"value","reference","type","track"],pt=[...X,...ft,"cycle","field","group"],Q=e=>Object.prototype.toString.call(e)==="[object Object]"&&e.value!==void 0,_t=e=>["string","boolean","number"].includes(typeof e),Tt=e=>Q(e)&&((e==null?void 0:e.value)===null||Q(e.value)||_t(e.value)),ue=e=>Object.prototype.toString.call(e)==="[object Object]",Et=e=>Object.prototype.toString.call(e)==="[object Date]",gt=e=>e===null?!0:Array.isArray(e)?e.some(gt):_t(e)||Tt(e)||Et(e),At=e=>{const t=s=>ue(s)&&s.value===void 0&&!!Object.entries(e);return Array.isArray(e)?e.every(At):t(e)},de=(e,t)=>e+(t.length>1?"s":""),It=(e,t)=>{const s=e.filter(i=>!t.includes(i));if(s.length)throw Error(`Unsupported ${de("key",s)} (${s.join(", ")})`)},Ot=e=>{if(Array.isArray(e))throw Error("Invalid value inside value object, cannot be array");return[void 0,null].includes(e)?{}:Et(e)?{value:e.toISOString()}:{value:e.toString()}},le=e=>{if(It(Object.keys(e),mt),Object.keys(e).length===0)throw Error("Invalid value object, cannot be empty object");if(typeof(e==null?void 0:e.value)=="string")return e;const t=Ot(e==null?void 0:e.value);return{...e,...t!==void 0?t:{}}},Z=e=>{if(![void 0,null].includes(e))return Array.isArray(e)?e.flatMap(Z):Q(e)?le(e):Ot(e)},fe=e=>{It(Object.keys(e),ht);const t=Z(e==null?void 0:e.value);if(t===void 0){const{value:s,...i}=e;return i}return{...e,value:[...Array.isArray(t)?t:[t]]}},me=e=>{if(Tt(e))return fe(e);const t=Z(e);if(t!==void 0)return{value:[...Array.isArray(t)?t:[t]]}},bt=e=>{const t=[],s=[];let i={};return Object.entries(e||{}).forEach(([r,n])=>{if(pt.includes(r))i={...i,[r]:n};else if(gt(n))try{s.push({name:r,...me(n)})}catch(o){throw Error(o.message+(r?` for field "${r}"`:""))}else if(At(n))(Array.isArray(n)?n:[n]).forEach(o=>{t.push({name:r,...bt(o)})});else throw Error(`Unhandled value for "${r}"`)}),{...i,...t.length>0?{group:t}:{},...s.length>0?{field:s}:{}}},he=e=>{const{start:t="-INF",end:s="+INF",base:i=void 0,...r}=e,{group:n,field:o}=bt(r);return{...n?{group:n}:{},...o?{field:o}:{},start:t.toString(),end:s.toString(),...i?{base:i}:{}}},pe=e=>({timespan:(Array.isArray(e)?e:[e||{}]).map(t=>he(t))}),_e=(e,t)=>{var r,n;const[s]=((r=e==null?void 0:e.start)==null?void 0:r.split("@"))||[],[i]=((n=t==null?void 0:t.start)==null?void 0:n.split("@"))||[];return Number(s)<Number(i)?-1:Number(s)>Number(i)?1:0},C=e=>Array.isArray(e)?e:e&&[e]||[],St=e=>Array.isArray(e)?e.pop():e,Te=e=>(e==null?void 0:e.every(t=>typeof t=="string"))||!1,yt={includeValueAttributes:!1};function Ee(e,t,s=!1){const{includeValueAttributes:i}={...yt,...t||{}};let r=i;if(r===!1&&!s)return e==null?void 0:e.value;r===!1&&s&&(r=["lang"]);const{value:n,...o}=e;return{...r===!0&&o||Array.isArray(r)&&Object.fromEntries(Object.entries(o).filter(([c])=>Array.isArray(r)&&r.includes(c)))||{},value:n}}const Rt={...yt,joinValue:void 0,arrayOnSingleValue:!0,selectedLang:void 0,includeLangAttrForLangDependentOnly:!1};function ge(e,t,s){const{joinValue:i,arrayOnSingleValue:r,selectedLang:n,includeLangAttrForLangDependentOnly:o,...a}={...Rt,...t||{}};let c=e;s&&e&&n&&(c=e.filter(u=>u.lang===n));const d=c==null?void 0:c.map(u=>Ee(u,a,s&&o));return Te(d)&&i?d==null?void 0:d.join(i):r!==!0&&(d==null?void 0:d.length)<=1?d==null?void 0:d[0]:d}const vt={includeFieldAttributes:!1,...Rt},Ae=(e,t,s)=>{const{includeFieldAttributes:i,...r}={...vt,...t||{}},{value:n,...o}=e,a=ge(n,r,s),c=i===!0&&o||Array.isArray(i)&&Object.fromEntries(Object.entries(o).filter(([d])=>i.includes(d)))||{};return i?{...c,value:a}:a},x={...vt,fieldAsList:!1,arrayOnSingleField:!1,overrideField:void 0,languageDependentFields:void 0},tt=(e,t)=>{const s={...x,...t||{}},{fieldAsList:i,arrayOnSingleField:r,overrideField:n,languageDependentFields:o}=s,a=n===!0&&i===!1,c={};return e==null||e.forEach(d=>{const{name:u}=d,f=(o==null?void 0:o.includes(u))===!0,m=Ae(d,s,f),_=r===!0?C(m):m,l=c[u];l?a?c[u]=m:c[u]=[C(l),C(m)].flat():c[u]=_}),i===!0?Object.values(c).flat():c},Ft={...x,includeGroupAttributes:!1,groupAsList:!1,arrayOnSingleGroup:!1,overrideGroup:void 0},Ie=(e,t)=>{const s={...Ft,...t||{}},{includeGroupAttributes:i}=s,r=Object.fromEntries(Object.entries(s).filter(([f])=>Object.keys(x).includes(f))),{field:n,group:o,...a}=e,c=n&&tt(n,r),d=o&&st(o,s);return{...i===!0&&a||Array.isArray(i)&&Object.fromEntries(Object.entries(a).filter(([f])=>i.includes(f)))||{},...r!=null&&r.fieldAsList?c&&{field:c}||{}:c,...s!=null&&s.groupAsList?d&&{group:d}||{}:d}},et=Ft,st=(e,t)=>{const s={...et,...t||{}},{groupAsList:i,arrayOnSingleGroup:r,overrideGroup:n}=s,o=n===!0&&i===!1,a={};return e==null||e.forEach(c=>{const{name:d}=c,u=Ie(c,s),f=r===!0?C(u):u,m=a[d];m?o?a[d]=u:a[d]=[C(m),C(u)].flat():a[d]=f}),i?Object.values(a).flat():a},Dt={...et,includeTimespanAttributes:!1,flat:!1,arrayOnSingle:!1,arrayOnSingleValue:!0,arrayOnSingleGroup:void 0,arrayOnSingleField:void 0},Mt=(e,t)=>{const s={...Dt,...t||{}},{includeTimespanAttributes:i,arrayOnSingle:r,flat:n}=s,o=Object.fromEntries(Object.entries(t).map(([l,h])=>{if(Object.keys(et).includes(l))return["arrayOnSingleGroup","arrayOnSingleField","arrayOnSingleValue"].includes(l)&&(h!==void 0?h:r===!0)?[l,!0]:["overrideGroup","overrideField"].includes(l)&&(h!==void 0?h:n===!0)?[l,!0]:[l,h]}).filter(l=>!!l)),a=Object.fromEntries(Object.entries(t).map(([l,h])=>{if(Object.keys(x).includes(l))return["arrayOnSingleField","arrayOnSingleValue"].includes(l)&&(h!==void 0?h:r===!0)?[l,!0]:["overrideField"].includes(l)&&(h!==void 0?h:n===!0)?[l,!0]:[l,h]}).filter(l=>!!l)),{field:c,group:d,...u}=e||{},f=c&&tt(c,a),m=d&&st(d,o);return{...i===!0&&u||Array.isArray(i)&&Object.fromEntries(Object.entries(u).filter(([l])=>i.includes(l)))||{},...a!=null&&a.fieldAsList?{field:f}:f,...o!=null&&o.groupAsList?{group:m}:m}},rt={...Dt,timespanAsList:!1,joinTimespan:"_",sortTimespan:!1,flat:!1,flatTimespan:void 0},it=(e,t)=>{const s={...rt,...t||{}},{timespanAsList:i,joinTimespan:r,sortTimespan:n,flat:o,flatTimespan:a,...c}=s,d={flat:o,...c};n&&e.sort(_e);const u=(a!==void 0?a===!0:o===!0)&&i===!1,f={};return e==null||e.forEach(m=>{const{start:_,end:l}=m,h=u?"flat":[_,l].join(r),g=Mt(m,d),A=f[h];A?u?_==="-INF"&&l==="+INF"?f[h]={...St(A),...g}:f[h]={...g,...St(A)}:f[h]=[...C(A),g]:f[h]=g}),i===!0?Object.values(f):u?Object.values(f).pop():f},Oe={...rt,includeMetadataAttributes:!1,flat:!1};function Ct(e,t){const s={...Oe,...t||{}},{includeMetadataAttributes:i,flat:r}=s,{timespan:n=[],...o}=e||{},a=Object.fromEntries(Object.entries(s).map(([u,f])=>{if(Object.keys(rt).includes(u))return["onlyGeneric","overrideGroup","overrideField"].includes(u)&&(f!==void 0?f:r===!0)?[u,!0]:[u,f]}).filter(u=>!!u)),c=it(n,a);return{...i===!0&&{...o,...o.revision?{revision:o.revision.split(",")}:{}}||Array.isArray(i)&&Object.fromEntries(Object.entries(o).map(([u,f])=>{if(i.includes(u))return[u,u==="revision"&&typeof f=="string"?f.split(","):f]}).filter(u=>!!u))||{},...a!=null&&a.timespanAsList?{timespan:c}:c}}const be=e=>{const{field:t=[]}=e||{};return D(t)},nt={PAL:{denominator:25,numerator:1},NTSC:{denominator:3e4,numerator:1001},NTSC30:{denominator:30,numerator:1},29.97:{denominator:3e4,numerator:1001},59.94:{denominator:6e4,numerator:1001},23.976:{denominator:48e3,numerator:2002},23.98:{denominator:48e3,numerator:2002}},Nt=Object.keys(nt),wt={toText:{constant:!1,fraction:!1},toRate:{fixed:!0,rounded:!1}};class y{constructor(t){this.numerator=1,this.denominator=1;const{numerator:s=1,denominator:i=1}=t||{};this.numerator=Number(s),this.denominator=Number(i)}toConstant(){let t;return Object.entries(nt).find(s=>{const[i,r]=s,{numerator:n,denominator:o}=r;return n===this.numerator&&o===this.denominator?(t=i,!0):!1}),t}toText(t){const{constant:s,fraction:i}={...wt.toText,...t};if(s){const n=this.toConstant();if(n)return n}return i||this.numerator>1?[this.denominator,this.numerator].join(":"):String(this.denominator)}toRate(t){const s=this.denominator/this.numerator;if(Number.isInteger(s))return s;const{rounded:i,fixed:r}={...wt.toRate,...t||{}};return i?Math.round(s):r===!0||typeof r=="number"?Number(s.toFixed(typeof r=="boolean"?2:r)):s}toObject(){return{denominator:this.denominator,numerator:this.numerator}}toJson(){return console.warn("Deprecated - use toObject instead"),this.toObject()}}const G=e=>{var t;if(e===void 0)return new y;if(Nt.includes((t=e==null?void 0:e.toString)==null?void 0:t.call(e)))return new y(nt[e]);if(typeof e=="number")return new y({denominator:e});if(typeof e=="string"&&e.includes(":")){const[s,i]=e.split(":");return new y({denominator:s,numerator:i})}if(!["string","number"].includes(typeof e)||Number.isNaN(Number(e)))throw new Error(`timeBaseText must be a number or ${Nt.join(",")} - is ${JSON.stringify(e)}`);return new y({denominator:Number(e)})},w=e=>new y(e),W=e=>e instanceof y?e:typeof e=="string"||typeof e=="number"?G(e):w(e),at=e=>{const t=e.toConstant();return t==="59.94"&&4||["NTSC","29.97"].includes(t)&&2||void 0},Lt=e=>at(e)>0,Bt=e=>{const{samples:t,timeBase:s}=e,i=at(s);if(!i)return 0;const r=s.toRate({rounded:!0}),n=60*r,o=60*r-i,a=10*(n-i)+i,c=Math.floor((t+1)/a),d=Math.max(0,(t+1)%a-n),u=Math.floor(d/o),m=d%o>0?i:0;return c*9*i+u*i+m},ot={conformTimeBase:{dropFrame:void 0,frameSeparator:void 0},toText:{constant:!1,fraction:!1,includeTimeBaseForSeconds:!1},toDuration:{format:void 0}};class F{constructor(t,s){this.samples=0,this.timeBase=new y;const{samples:i,timeBase:r}=t||{};if(i!==void 0)if(typeof i=="number")this.samples=i;else if(typeof i=="string")i==="-INF"?this.samples=-1/0:i==="+INF"?this.samples=1/0:this.samples=Number(i);else throw new Error(`samples is not number/string/-Inf/+Inf is: ${i}`);r!==void 0&&(r instanceof y?this.timeBase=r:this.timeBase=W(r)),this.dropFrame=(s==null?void 0:s.dropFrame)??Lt(this.timeBase),this.frameSeparator=(s==null?void 0:s.frameSeparator)??(this.dropFrame?";":":")}add(t){if(!(t!=null&&t.timeBase)||(t==null?void 0:t.samples)===void 0)throw Error("Invalid timeCodeType, cannot be added");const{numerator:s,denominator:i}=(t==null?void 0:t.timeBase)||{};let r=t;(s!==this.timeBase.numerator||i!==this.timeBase.denominator)&&(r=t.conformTimeBase(this.timeBase));const{samples:n}=r;return new F({samples:this.samples+n,timeBase:this.timeBase})}subtract(t){if(!(t!=null&&t.timeBase)||(t==null?void 0:t.samples)===void 0)throw Error("Invalid timeCodeType, cannot be subtracted");const{timeBase:{numerator:s,denominator:i}={}}=t;let r=t;(s!==this.timeBase.numerator||i!==this.timeBase.denominator)&&(r=t.conformTimeBase(this.timeBase));const{samples:n}=r;return new F({samples:this.samples-n,timeBase:this.timeBase})}conformTimeBase(t,s){const i=t instanceof y?t:W(t),r=(s==null?void 0:s.roundingMode)??"floor";if(!["floor","ceil","round"].includes(r))throw Error(`Invalid mode selection "${r}". Has to be one of "${["floor","ceil","round"].join(", ")}"`);const n=Math[r](this.samples/(this.timeBase.toRate({fixed:!1})/i.toRate({fixed:!1}))),o={...ot.conformTimeBase,...s||{}};return new F({samples:n,timeBase:i},o)}toText(t){let s=`${this.samples}`;const i={...ot.toText,...t||{}},r=this.timeBase.toText(i);return(t!=null&&t.includeTimeBaseForSeconds||!["1","1:1"].includes(r))&&(s=[this.samples,r].join("@")),s}toUnits(){if(this.samples===1/0)return{hours:1/0,minutes:1/0,seconds:1/0,frames:1/0};const t=this.samples+(this.dropFrame?Bt(this):0);let s=this.timeBase.toRate({rounded:!0});["23.976","23.98"].includes(this.timeBase.toConstant())&&(s=this.timeBase.toRate({fixed:!0}));const i=Math.floor(t/(3600*s)),r=Math.floor(t/(60*s))%60,n=Math.floor(t/s)%60,o=Math.floor(t%s);return{hours:i,minutes:r,seconds:n,frames:o}}toTime(){const t=this.samples+Bt(this),{hours:s,minutes:i,seconds:r}=this.toUnits(),n=this.timeBase.toRate({rounded:!0}),o=t%n,a=Math.floor(1e3*o/n),c=o/n;return{hours:s,minutes:i,seconds:r,milliseconds:a,partialSeconds:c}}toSeconds(t){const{numerator:s,denominator:i}=this.timeBase,r=+(this.samples*s/i);return t!=null&&t.round?Math.round(1e3*r)/1e3:r}toDuration(t){const{format:s}={...ot.toDuration,...t||{}},{hours:i,...r}=this.toTime();let{minutes:n,seconds:o,milliseconds:a}=r;if(s&&typeof s!="string")throw Error("format has to be a string");const c=(m,_)=>!s.includes(m)||!_.some(l=>s.includes(l)&&s.lastIndexOf(m)>s.indexOf(l));if(s&&!(c("h",["m","s","S"])&&c("m",["s","S"])&&c("s",["S"])))throw Error("format order is unsupported (has to be h, m, s then S)");if(!s)return`${i>0?`${i}:${`${n}`.padStart(2,"0")}`:n}:${`${o}`.padStart(2,"0")}`;const d=(m,_)=>{let l=m;for(;_[l]===_[l+1];)l+=1;return l-m+1},u=["h","m","s","S"],f=[];return[...s].forEach((m,_,l)=>{switch(m){case"h":{if(l[_-1]==="h")break;const h=d(_,l);f.push(`${i}`.padStart(h,"0")),u.includes(l[_+h])&&f.push(":");break}case"m":{if(l[_-1]==="m")break;const h=d(_,l);s.includes("h")||(n+=i*60),f.push(`${n}`.padStart(h,"0")),u.includes(l[_+h])&&f.push(":");break}case"s":{if(l[_-1]==="s")break;const h=d(_,l);s.includes("m")||(o+=n*60),f.push(`${o}`.padStart(h,"0")),u.includes(l[_+h])&&f.push(".");break}case"S":{if(l[_-1]==="S")break;const h=d(_,l);s.includes("s")||(a+=o*1e3),f.push(`${Math.round(a/10**(3-h))}`.padStart(h,"0"));break}default:f.push(m)}}),f.join("")}toSmpte(t){const{uniformSeparators:s}={uniformSeparators:!1,...t};if(this.samples===-1/0)return"00:00:00:00";const{hours:i,minutes:r,seconds:n,frames:o}=this.toUnits(),a=s?this.frameSeparator:":",c=[i.toFixed().padStart(2,"0"),r.toFixed().padStart(2,"0"),n.toFixed().padStart(2,"0")].join(a),d=Math.max(2,`${this.timeBase.toRate({rounded:!0})-1}`.length);return[c,`${o}`.padStart(d,"0")].join(this.frameSeparator)}toObject(){return{samples:this.samples,timeBase:this.timeBase.toObject()}}toJson(){return console.warn("Deprecated - use toObject instead"),this.toObject()}}const Se=(e,t)=>{let s=Math.abs(e),i=Math.abs(t);for(;s&&i&&s!==i;)s>i?[s,i]=[s-i,i]:[s,i]=[s,i-s];return s||i},Pt=(e,t)=>{const{timeBase:s,useGCD:i=!1,roundingMode:r,...n}=t||{},o=`${e}`.replace(/,/g,".");if(Number.isNaN(+o))throw new Error(`seconds must be digits, is ${e}`);let a=1,c;if(Number.isInteger(+o))c=+o*a;else{const[,u]=o.split("."),f=Math.min((u==null?void 0:u.length)??0,16);a*=10**f,c=Math.round(Number(o)*a)}if(s===void 0&&i){const u=Se(a,c);c/=u,a/=u}const d=new F({samples:c,timeBase:{denominator:a,numerator:1}},n);return s!==void 0?d.conformTimeBase(s,{...n,roundingMode:r}):d},ye=([e,t,s,i],r,n)=>{const o=n.toRate({rounded:!0}),a=at(n);if(r===0||!a)return 0;const c=t%10!==0,d=c&&s===0,u=e*(3600*o-54*a),f=t*60*o-(t-Math.ceil(t/10))*a,m=s*o-(c&&s>1?a:0);if(d&&i<a)throw new Error(`Frame does not exist for ${n.toConstant()||n.toRate()} drop-frame`);const _=d?i-a:i,l=u+f+m+_;return r-l},ct=(e,t,s)=>{const[i,r,n,o]=e,a=t.toRate({rounded:!0}),c=i*3600*a+r*60*a+n*a+o;return c-(s?ye(e,c,t):0)},Re=e=>{const[t]=(e==null?void 0:e.match(/[^0-9:\-_]/))||[];let s=[];if(t){const[r,n]=e.split(t);s=[...r.split(":"),n]}else s=e.split(":");if(s.length!==4)throw new Error('Invalid format, must be "##:##:##:##');if(s.some(r=>Number.isNaN(r)))throw new Error("Invalid format, values must be numbers");const i=t||":";return{smpteValues:s.map(Number),smpteFrameSeparator:i}},ve=["error","add","ignore"],Fe={exceedingMode:"error",timeBase:void 0,dropFrame:void 0,frameSeparator:void 0},jt=(e,t)=>{const{exceedingMode:s,timeBase:i,...r}={...Fe,...t};if([null,void 0].includes(e))throw new Error("smpte cannot be undefined or null");if(typeof e!="string")throw new Error(`smpte must be a string, is ${JSON.stringify(e)}`);const{smpteValues:n,smpteFrameSeparator:o}=Re(e),a=W(i),c={...r,frameSeparator:(r==null?void 0:r.frameSeparator)||o,...(r==null?void 0:r.dropFrame)===void 0?{dropFrame:i!==void 0?Lt(a):[";",","].includes(o)}:{}},d=a.toRate({rounded:!0}),u=Math.max(0,d-1);if(n.some(m=>m<0))throw new Error("Negative values are not supported");let f;switch(s){case"error":{const[m,_,l,h]=n;if(m>=100||_>=60)throw Error("Minutes has to be less than 60");if(l>=60)throw Error("Seconds has to be less than 60");if(h>u)throw Error(`Frames has to be less or equal to ${u}`);f=ct(n,a,c==null?void 0:c.dropFrame);break}case"ignore":{const[m,_,l,h]=n,g=[Math.min(100,m),Math.min(59,_),Math.min(59,l),Math.min(u,h)];f=ct(g,a,c==null?void 0:c.dropFrame);break}case"add":{f=ct(n,a,c==null?void 0:c.dropFrame);break}default:throw new Error(`Invalid exceedingMode, options are ${JSON.stringify(ve)}`)}return new F({samples:f,timeBase:a},c)},De={timeBase:void 0,dropFrame:void 0,frameSeparator:void 0},$=(e,t)=>{const{timeBase:s,...i}={...De,...t};let r;if(e===void 0)r={samples:0};else if(typeof e=="number")r={samples:e};else if(e.includes("@")){const[o,a]=e.split("@");r={samples:Number(o),timeBase:G(a)}}else e==="-INF"?r={samples:-1/0}:e==="+INF"?r={samples:1/0}:r={samples:Number(e)};if(Number.isNaN(r==null?void 0:r.samples)||r.timeBase&&!(r.timeBase instanceof y))throw new Error(`timeCodeText must be a number or sample@timeBase - is ${e}`);const n=new F(r,i);return s?n.conformTimeBase(W(s),i):n},Me={dropFrame:void 0,frameSeparator:void 0},L=(e,t)=>new F(e,{...Me,...t}),Ce=e=>!!e.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/),Ne=e=>!Number.isNaN(Number(e)),B=(e,t)=>{if(e instanceof F)return e;if(typeof e!="string"&&typeof e!="number")return L(e,t);if(typeof e=="string"&&Ce(e))return jt(e,t);if(["string","number"].includes(typeof e)&&Ne(e))return Pt(e,t);if(typeof e=="string")return $(e,t)};function kt({hours:e=0,minutes:t=0,seconds:s=0,partialSeconds:i=0}){const r=e.toFixed().padStart(2,"0"),n=t.toFixed().padStart(2,"0"),o=s.toFixed().padStart(2,"0"),a=(i*10).toFixed().padStart(3,"0");return`${r}:${n}:${o}.${a}`}const we={subtitleGroup:"stl_subtitle",subtitleField:"stl_text"},Le=(e,t)=>{const{subtitleGroup:s,subtitleField:i}={...we,...t||{}},{timespan:r=[]}=e||{};if(r.length===0)return"";const o=it(r,{includeTimespanAttributes:!0,sortTimespan:!0,timespanAsList:!0,overrideGroup:!0,joinValue:","}).map(a=>{const{start:c,end:d,[s]:{[i]:u}={}}=(Array.isArray(a)?a[0]:a)||{};if(!u)return"";const f=kt($(c).toTime()),m=kt($(d).toTime());return`${f} --> ${m} line:0%\r${u}\r`});if(o.some(a=>!!a))return`WEBVTT
1
+ (function(p,v){typeof exports=="object"&&typeof module<"u"?v(exports,require("filesize"),require("url-join"),require("lodash.merge")):typeof define=="function"&&define.amd?define(["exports","filesize","url-join","lodash.merge"],v):(p=typeof globalThis<"u"?globalThis:p||self,v(p["@vidispine/vdt-js"]={},p.filesize,p.urlJoin,p._merge))})(this,function(p,v,se,re){"use strict";const lt=(e,t)=>t?lt(t,e%t):e,J=e=>{const{width:t,height:s}=e||{};if(t===void 0||s===void 0)return;const i=lt(t,s);let r=t/i,n=s/i;return r>21&&(n=1,r=(t/s).toFixed(2)),[r,n].join(":")},D=e=>Object.fromEntries((e==null?void 0:e.map(({key:t,value:s})=>[t,s]))||[]),ie=(e,t,s)=>{let i;return r=>{const o=()=>{i=null,s||e.apply(void 0,r)},a=s&&!i;clearTimeout(i),i=setTimeout(o,t),a&&e.apply(void 0,r)}};function ne(){return([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))}const ae={ACCESSCONTROL_READ:"_accesscontrol_read",ACCESSCONTROL_WRITE:"_accesscontrol_write",ADMINISTRATOR:"_administrator",AUTO_PROJECTION_READ:"_auto_projection_read",AUTO_PROJECTION_WRITE:"_auto_projection_write",COLLECTION_NOTIFICATION_READ:"_collection_notification_read",COLLECTION_NOTIFICATION_WRITE:"_collection_notification_write",COLLECTION_READ:"_collection_read",COLLECTION_WRITE:"_collection_write",CONFIGURATION_READ:"_configuration_read",DELETION_LOCK_NOTIFICATION_READ:"_deletion_lock_notification_read",DELETION_LOCK_NOTIFICATION_WRITE:"_deletion_lock_notification_write",DELETION_LOCK_READ:"_deletion_lock_read",DELETION_LOCK_WRITE:"_deletion_lock_write",DOCUMENT_NOTIFICATION_READ:"_document_notification_read",DOCUMENT_NOTIFICATION_WRITE:"_document_notification_write",DOCUMENT_READ:"_document_read",DOCUMENT_WRITE:"_document_write",ERROR_READ:"_error_read",ERROR_WRITE:"_error_write",EXPORT:"_export",EXPORT_TEMPLATE_READ:"_export_template_read",EXPORT_TEMPLATE_WRITE:"_export_template_write",EXTERNAL_ID_READ:"_external_id_read",EXTERNAL_ID_WRITE:"_external_id_write",FILE_NOTIFICATION_READ:"_file_notification_read",FILE_NOTIFICATION_WRITE:"_file_notification_write",FILE_READ:"_file_read",FILE_WRITE:"_file_write",GROUP_READ:"_group_read",GROUP_WRITE:"_group_write",IMPORT_WRITE:"_import",ITEM_ID_READ:"_item_id_read",ITEM_ID_WRITE:"_item_id_write",ITEM_NOTIFICATION_READ:"_item_notification_read",ITEM_NOTIFICATION_WRITE:"_item_notification_write",ITEM_WRITE:"_item_write",ITEM_SEARCH:"_item_search",ITEM_SHAPE_READ:"_item_shape_read",ITEM_SHAPE_WRITE:"_item_shape_write",ITEM_TIMELINE_READ:"_item_timeline_read",ITEM_TIMELINE_WRITE:"_item_timeline_write",ITEM_URI:"_item_uri",JOB_NOTIFICATION_READ:"_job_notification_read",JOB_NOTIFICATION_WRITE:"_job_notification_write",JOB_READ:"_job_read",JOB_WRITE:"_job_write",LIBRARY_READ:"_library_read",LIBRARY_WRITE:"_library_write",LOCK_READ:"_lock_read",LOCK_WRITE:"_lock_write",LOG_READ:"_log_read",METADATA_DATASET_READ:"_metadata_dataset_read",METADATA_DATASET_WRITE:"_metadata_dataset_write",METADATA_FIELD_GROUP_READ:"_metadata_field_group_read",METADATA_FIELD_GROUP_WRITE:"_metadata_field_group_write",METADATA_FIELD_READ:"_metadata_field_read",METADATA_FIELD_WRITE:"_metadata_field_write",METADATA_GLOBAL_READ:"_metadata_global_read",METADATA_GLOBAL_WRITE:"_metadata_global_write",METADATA_LOCK_READ:"_metadata_lock_read",METADATA_LOCK_WRITE:"_metadata_lock_write",METADATA_READ:"_metadata_read",METADATA_SCHEMA_READ:"_metadata_schema_read",METADATA_SCHEMA_WRITE:"_metadata_schema_write",METADATA_WRITE:"_metadata_write",OTIF_ANALYZE:"_otif_analyze",OTIF_READ:"_otif_read",OTIF_WRITE:"_otif_write",PLACEHOLDER_NOTIFICATION_READ:"_placeholder_notification_read",PLACEHOLDER_NOTIFICATION_WRITE:"_placeholder_notification_write",PROJECTION_READ:"_projection_read",PROJECTION_WRITE:"_projection_write",QUOTA_NOTIFICATION_READ:"_quota_notification_read",QUOTA_NOTIFICATION_WRITE:"_quota_notification_write",QUOTA_READ:"_quota_read",QUOTA_WRITE:"_quota_write",RELATION_READ:"_relation_read",RELATION_WRITE:"_relation_write",RESOURCE_READ:"_resource_read",RESOURCE_WRITE:"_resource_write",RUN_AS:"_run_as",SEARCH:"_search",SEQUENCE_READ:"_sequence_read",SEQUENCE_WRITE:"_sequence_write",SHAPE_TAG_READ:"_shape_tag_read",SHAPE_TAG_WRITE:"_shape_tag_write",SITE_MANAGER:"_site_manager",SITE_RULE_READ:"_site_rule_read",SITE_RULE_WRITE:"_site_rule_write",STORAGE_GROUP_READ:"_storage_group_read",STORAGE_GROUP_WRITE:"_storage_group_write",STORAGE_NOTIFICATION_READ:"_storage_notification_read",STORAGE_NOTIFICATION_WRITE:"_storage_notification_write",STORAGE_READ:"_storage_read",STORAGE_RULE_READ:"_storage_rule_read",STORAGE_RULE_WRITE:"_storage_rule_write",STORAGE_WRITE:"_storage_write",SUPER_ACCESS_USER:"_super_access_user",TASKDEFINITION_READ:"_taskdefinition_read",TASKDEFINITION_WRITE:"_taskdefinition_write",THUMBNAIL_READ:"_thumbnail_read",THUMBNAIL_WRITE:"_thumbnail_write",TRANSCODER:"_transcoder",TRANSFER_READ:"_transfer_read",TRANSFER_WRITE:"_transfer_write",USER:"_user",VXA:"_vxa",VXA_READ:"_vxa_read"},oe=["stl_subtitle","stl_tti","stl_gsi","mrk_marker","pho_validation","pho_resource","pho_error","facedetect_rect","facedetect_face","originalTrackFilename","stl_gsiHeader"],ce=["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"],X=["uuid","user","timestamp","change","conflict","mode"],ft=["name","id","referenced","data","inheritance"],mt=[...X,"value","lang"],ht=[...X,...ft,"value","reference","type","track"],pt=[...X,...ft,"cycle","field","group"],Q=e=>Object.prototype.toString.call(e)==="[object Object]"&&e.value!==void 0,_t=e=>["string","boolean","number"].includes(typeof e),Tt=e=>Q(e)&&((e==null?void 0:e.value)===null||Q(e.value)||_t(e.value)),ue=e=>Object.prototype.toString.call(e)==="[object Object]",Et=e=>Object.prototype.toString.call(e)==="[object Date]",gt=e=>e===null?!0:Array.isArray(e)?e.some(gt):_t(e)||Tt(e)||Et(e),At=e=>{const t=s=>ue(s)&&s.value===void 0&&!!Object.entries(e);return Array.isArray(e)?e.every(At):t(e)},de=(e,t)=>e+(t.length>1?"s":""),It=(e,t)=>{const s=e.filter(i=>!t.includes(i));if(s.length)throw Error(`Unsupported ${de("key",s)} (${s.join(", ")})`)},Ot=e=>{if(Array.isArray(e))throw Error("Invalid value inside value object, cannot be array");return[void 0,null].includes(e)?{}:Et(e)?{value:e.toISOString()}:{value:e.toString()}},le=e=>{if(It(Object.keys(e),mt),Object.keys(e).length===0)throw Error("Invalid value object, cannot be empty object");if(typeof(e==null?void 0:e.value)=="string")return e;const t=Ot(e==null?void 0:e.value);return{...e,...t!==void 0?t:{}}},Z=e=>{if(![void 0,null].includes(e))return Array.isArray(e)?e.flatMap(Z):Q(e)?le(e):Ot(e)},fe=e=>{It(Object.keys(e),ht);const t=Z(e==null?void 0:e.value);if(t===void 0){const{value:s,...i}=e;return i}return{...e,value:[...Array.isArray(t)?t:[t]]}},me=e=>{if(Tt(e))return fe(e);const t=Z(e);if(t!==void 0)return{value:[...Array.isArray(t)?t:[t]]}},bt=e=>{const t=[],s=[];let i={};return Object.entries(e||{}).forEach(([r,n])=>{if(pt.includes(r))i={...i,[r]:n};else if(gt(n))try{s.push({name:r,...me(n)})}catch(o){throw Error(o.message+(r?` for field "${r}"`:""))}else if(At(n))(Array.isArray(n)?n:[n]).forEach(o=>{t.push({name:r,...bt(o)})});else throw Error(`Unhandled value for "${r}"`)}),{...i,...t.length>0?{group:t}:{},...s.length>0?{field:s}:{}}},he=e=>{const{start:t="-INF",end:s="+INF",base:i=void 0,...r}=e,{group:n,field:o}=bt(r);return{...n?{group:n}:{},...o?{field:o}:{},start:t.toString(),end:s.toString(),...i?{base:i}:{}}},pe=e=>({timespan:(Array.isArray(e)?e:[e||{}]).map(t=>he(t))}),_e=(e,t)=>{var r,n;const[s]=((r=e==null?void 0:e.start)==null?void 0:r.split("@"))||[],[i]=((n=t==null?void 0:t.start)==null?void 0:n.split("@"))||[];return Number(s)<Number(i)?-1:Number(s)>Number(i)?1:0},C=e=>Array.isArray(e)?e:e&&[e]||[],St=e=>Array.isArray(e)?e.pop():e,Te=e=>(e==null?void 0:e.every(t=>typeof t=="string"))||!1,yt={includeValueAttributes:!1};function Ee(e,t,s=!1){const{includeValueAttributes:i}={...yt,...t||{}};let r=i;if(r===!1&&!s)return e==null?void 0:e.value;r===!1&&s&&(r=["lang"]);const{value:n,...o}=e;return{...r===!0&&o||Array.isArray(r)&&Object.fromEntries(Object.entries(o).filter(([c])=>Array.isArray(r)&&r.includes(c)))||{},value:n}}const Rt={...yt,joinValue:void 0,arrayOnSingleValue:!0,selectedLang:void 0,filterSelectedLang:!1,includeLangAttrForLangDependentOnly:!1};function ge(e,t,s){const{joinValue:i,arrayOnSingleValue:r,selectedLang:n,filterSelectedLang:o,includeLangAttrForLangDependentOnly:a,...c}={...Rt,...t||{}};let l=e;s&&e&&o&&(l=e.filter(f=>f.lang===n));const u=l==null?void 0:l.map(f=>Ee(f,c,s&&a));return Te(u)&&i?u==null?void 0:u.join(i):r!==!0&&(u==null?void 0:u.length)<=1?u==null?void 0:u[0]:u}const vt={includeFieldAttributes:!1,...Rt},Ae=(e,t,s)=>{const{includeFieldAttributes:i,...r}={...vt,...t||{}},{value:n,...o}=e,a=ge(n,r,s),c=i===!0&&o||Array.isArray(i)&&Object.fromEntries(Object.entries(o).filter(([l])=>i.includes(l)))||{};return i?{...c,value:a}:a},x={...vt,fieldAsList:!1,arrayOnSingleField:!1,overrideField:void 0,languageDependentFields:void 0},tt=(e,t)=>{const s={...x,...t||{}},{fieldAsList:i,arrayOnSingleField:r,overrideField:n,languageDependentFields:o}=s,a=n===!0&&i===!1,c={};return e==null||e.forEach(l=>{const{name:u}=l,f=(o==null?void 0:o.includes(u))===!0,m=Ae(l,s,f),_=r===!0?C(m):m,d=c[u];d?a?c[u]=m:c[u]=[C(d),C(m)].flat():c[u]=_}),i===!0?Object.values(c).flat():c},Ft={...x,includeGroupAttributes:!1,groupAsList:!1,arrayOnSingleGroup:!1,overrideGroup:void 0},Ie=(e,t)=>{const s={...Ft,...t||{}},{includeGroupAttributes:i}=s,r=Object.fromEntries(Object.entries(s).filter(([f])=>Object.keys(x).includes(f))),{field:n,group:o,...a}=e,c=n&&tt(n,r),l=o&&st(o,s);return{...i===!0&&a||Array.isArray(i)&&Object.fromEntries(Object.entries(a).filter(([f])=>i.includes(f)))||{},...r!=null&&r.fieldAsList?c&&{field:c}||{}:c,...s!=null&&s.groupAsList?l&&{group:l}||{}:l}},et=Ft,st=(e,t)=>{const s={...et,...t||{}},{groupAsList:i,arrayOnSingleGroup:r,overrideGroup:n}=s,o=n===!0&&i===!1,a={};return e==null||e.forEach(c=>{const{name:l}=c,u=Ie(c,s),f=r===!0?C(u):u,m=a[l];m?o?a[l]=u:a[l]=[C(m),C(u)].flat():a[l]=f}),i?Object.values(a).flat():a},Dt={...et,includeTimespanAttributes:!1,flat:!1,arrayOnSingle:!1,arrayOnSingleValue:!0,arrayOnSingleGroup:void 0,arrayOnSingleField:void 0},Mt=(e,t)=>{const s={...Dt,...t||{}},{includeTimespanAttributes:i,arrayOnSingle:r,flat:n}=s,o=Object.fromEntries(Object.entries(t).map(([d,h])=>{if(Object.keys(et).includes(d))return["arrayOnSingleGroup","arrayOnSingleField","arrayOnSingleValue"].includes(d)&&(h!==void 0?h:r===!0)?[d,!0]:["overrideGroup","overrideField"].includes(d)&&(h!==void 0?h:n===!0)?[d,!0]:[d,h]}).filter(d=>!!d)),a=Object.fromEntries(Object.entries(t).map(([d,h])=>{if(Object.keys(x).includes(d))return["arrayOnSingleField","arrayOnSingleValue"].includes(d)&&(h!==void 0?h:r===!0)?[d,!0]:["overrideField"].includes(d)&&(h!==void 0?h:n===!0)?[d,!0]:[d,h]}).filter(d=>!!d)),{field:c,group:l,...u}=e||{},f=c&&tt(c,a),m=l&&st(l,o);return{...i===!0&&u||Array.isArray(i)&&Object.fromEntries(Object.entries(u).filter(([d])=>i.includes(d)))||{},...a!=null&&a.fieldAsList?{field:f}:f,...o!=null&&o.groupAsList?{group:m}:m}},rt={...Dt,timespanAsList:!1,joinTimespan:"_",sortTimespan:!1,flat:!1,flatTimespan:void 0},it=(e,t)=>{const s={...rt,...t||{}},{timespanAsList:i,joinTimespan:r,sortTimespan:n,flat:o,flatTimespan:a,...c}=s,l={flat:o,...c};n&&e.sort(_e);const u=(a!==void 0?a===!0:o===!0)&&i===!1,f={};return e==null||e.forEach(m=>{const{start:_,end:d}=m,h=u?"flat":[_,d].join(r),g=Mt(m,l),A=f[h];A?u?_==="-INF"&&d==="+INF"?f[h]={...St(A),...g}:f[h]={...g,...St(A)}:f[h]=[...C(A),g]:f[h]=g}),i===!0?Object.values(f):u?Object.values(f).pop():f},Oe={...rt,includeMetadataAttributes:!1,flat:!1};function Ct(e,t){const s={...Oe,...t||{}},{includeMetadataAttributes:i,flat:r}=s,{timespan:n=[],...o}=e||{},a=Object.fromEntries(Object.entries(s).map(([u,f])=>{if(Object.keys(rt).includes(u))return["onlyGeneric","overrideGroup","overrideField"].includes(u)&&(f!==void 0?f:r===!0)?[u,!0]:[u,f]}).filter(u=>!!u)),c=it(n,a);return{...i===!0&&{...o,...o.revision?{revision:o.revision.split(",")}:{}}||Array.isArray(i)&&Object.fromEntries(Object.entries(o).map(([u,f])=>{if(i.includes(u))return[u,u==="revision"&&typeof f=="string"?f.split(","):f]}).filter(u=>!!u))||{},...a!=null&&a.timespanAsList?{timespan:c}:c}}const be=e=>{const{field:t=[]}=e||{};return D(t)},nt={PAL:{denominator:25,numerator:1},NTSC:{denominator:3e4,numerator:1001},NTSC30:{denominator:30,numerator:1},29.97:{denominator:3e4,numerator:1001},59.94:{denominator:6e4,numerator:1001},23.976:{denominator:48e3,numerator:2002},23.98:{denominator:48e3,numerator:2002}},Nt=Object.keys(nt),wt={toText:{constant:!1,fraction:!1},toRate:{fixed:!0,rounded:!1}};class y{constructor(t){this.numerator=1,this.denominator=1;const{numerator:s=1,denominator:i=1}=t||{};this.numerator=Number(s),this.denominator=Number(i)}toConstant(){let t;return Object.entries(nt).find(s=>{const[i,r]=s,{numerator:n,denominator:o}=r;return n===this.numerator&&o===this.denominator?(t=i,!0):!1}),t}toText(t){const{constant:s,fraction:i}={...wt.toText,...t};if(s){const n=this.toConstant();if(n)return n}return i||this.numerator>1?[this.denominator,this.numerator].join(":"):String(this.denominator)}toRate(t){const s=this.denominator/this.numerator;if(Number.isInteger(s))return s;const{rounded:i,fixed:r}={...wt.toRate,...t||{}};return i?Math.round(s):r===!0||typeof r=="number"?Number(s.toFixed(typeof r=="boolean"?2:r)):s}toObject(){return{denominator:this.denominator,numerator:this.numerator}}toJson(){return console.warn("Deprecated - use toObject instead"),this.toObject()}}const G=e=>{var t;if(e===void 0)return new y;if(Nt.includes((t=e==null?void 0:e.toString)==null?void 0:t.call(e)))return new y(nt[e]);if(typeof e=="number")return new y({denominator:e});if(typeof e=="string"&&e.includes(":")){const[s,i]=e.split(":");return new y({denominator:s,numerator:i})}if(!["string","number"].includes(typeof e)||Number.isNaN(Number(e)))throw new Error(`timeBaseText must be a number or ${Nt.join(",")} - is ${JSON.stringify(e)}`);return new y({denominator:Number(e)})},w=e=>new y(e),W=e=>e instanceof y?e:typeof e=="string"||typeof e=="number"?G(e):w(e),at=e=>{const t=e.toConstant();return t==="59.94"&&4||["NTSC","29.97"].includes(t)&&2||void 0},Lt=e=>at(e)>0,Bt=e=>{const{samples:t,timeBase:s}=e,i=at(s);if(!i)return 0;const r=s.toRate({rounded:!0}),n=60*r,o=60*r-i,a=10*(n-i)+i,c=Math.floor((t+1)/a),l=Math.max(0,(t+1)%a-n),u=Math.floor(l/o),m=l%o>0?i:0;return c*9*i+u*i+m},ot={conformTimeBase:{dropFrame:void 0,frameSeparator:void 0},toText:{constant:!1,fraction:!1,includeTimeBaseForSeconds:!1},toDuration:{format:void 0}};class F{constructor(t,s){this.samples=0,this.timeBase=new y;const{samples:i,timeBase:r}=t||{};if(i!==void 0)if(typeof i=="number")this.samples=i;else if(typeof i=="string")i==="-INF"?this.samples=-1/0:i==="+INF"?this.samples=1/0:this.samples=Number(i);else throw new Error(`samples is not number/string/-Inf/+Inf is: ${i}`);r!==void 0&&(r instanceof y?this.timeBase=r:this.timeBase=W(r)),this.dropFrame=(s==null?void 0:s.dropFrame)??Lt(this.timeBase),this.frameSeparator=(s==null?void 0:s.frameSeparator)??(this.dropFrame?";":":")}add(t){if(!(t!=null&&t.timeBase)||(t==null?void 0:t.samples)===void 0)throw Error("Invalid timeCodeType, cannot be added");const{numerator:s,denominator:i}=(t==null?void 0:t.timeBase)||{};let r=t;(s!==this.timeBase.numerator||i!==this.timeBase.denominator)&&(r=t.conformTimeBase(this.timeBase));const{samples:n}=r;return new F({samples:this.samples+n,timeBase:this.timeBase})}subtract(t){if(!(t!=null&&t.timeBase)||(t==null?void 0:t.samples)===void 0)throw Error("Invalid timeCodeType, cannot be subtracted");const{timeBase:{numerator:s,denominator:i}={}}=t;let r=t;(s!==this.timeBase.numerator||i!==this.timeBase.denominator)&&(r=t.conformTimeBase(this.timeBase));const{samples:n}=r;return new F({samples:this.samples-n,timeBase:this.timeBase})}conformTimeBase(t,s){const i=t instanceof y?t:W(t),r=(s==null?void 0:s.roundingMode)??"floor";if(!["floor","ceil","round"].includes(r))throw Error(`Invalid mode selection "${r}". Has to be one of "${["floor","ceil","round"].join(", ")}"`);const n=Math[r](this.samples/(this.timeBase.toRate({fixed:!1})/i.toRate({fixed:!1}))),o={...ot.conformTimeBase,...s||{}};return new F({samples:n,timeBase:i},o)}toText(t){let s=`${this.samples}`;const i={...ot.toText,...t||{}},r=this.timeBase.toText(i);return(t!=null&&t.includeTimeBaseForSeconds||!["1","1:1"].includes(r))&&(s=[this.samples,r].join("@")),s}toUnits(){if(this.samples===1/0)return{hours:1/0,minutes:1/0,seconds:1/0,frames:1/0};const t=this.samples+(this.dropFrame?Bt(this):0);let s=this.timeBase.toRate({rounded:!0});["23.976","23.98"].includes(this.timeBase.toConstant())&&(s=this.timeBase.toRate({fixed:!0}));const i=Math.floor(t/(3600*s)),r=Math.floor(t/(60*s))%60,n=Math.floor(t/s)%60,o=Math.floor(t%s);return{hours:i,minutes:r,seconds:n,frames:o}}toTime(){const t=this.samples+Bt(this),{hours:s,minutes:i,seconds:r}=this.toUnits(),n=this.timeBase.toRate({rounded:!0}),o=t%n,a=Math.floor(1e3*o/n),c=o/n;return{hours:s,minutes:i,seconds:r,milliseconds:a,partialSeconds:c}}toSeconds(t){const{numerator:s,denominator:i}=this.timeBase,r=+(this.samples*s/i);return t!=null&&t.round?Math.round(1e3*r)/1e3:r}toDuration(t){const{format:s}={...ot.toDuration,...t||{}},{hours:i,...r}=this.toTime();let{minutes:n,seconds:o,milliseconds:a}=r;if(s&&typeof s!="string")throw Error("format has to be a string");const c=(m,_)=>!s.includes(m)||!_.some(d=>s.includes(d)&&s.lastIndexOf(m)>s.indexOf(d));if(s&&!(c("h",["m","s","S"])&&c("m",["s","S"])&&c("s",["S"])))throw Error("format order is unsupported (has to be h, m, s then S)");if(!s)return`${i>0?`${i}:${`${n}`.padStart(2,"0")}`:n}:${`${o}`.padStart(2,"0")}`;const l=(m,_)=>{let d=m;for(;_[d]===_[d+1];)d+=1;return d-m+1},u=["h","m","s","S"],f=[];return[...s].forEach((m,_,d)=>{switch(m){case"h":{if(d[_-1]==="h")break;const h=l(_,d);f.push(`${i}`.padStart(h,"0")),u.includes(d[_+h])&&f.push(":");break}case"m":{if(d[_-1]==="m")break;const h=l(_,d);s.includes("h")||(n+=i*60),f.push(`${n}`.padStart(h,"0")),u.includes(d[_+h])&&f.push(":");break}case"s":{if(d[_-1]==="s")break;const h=l(_,d);s.includes("m")||(o+=n*60),f.push(`${o}`.padStart(h,"0")),u.includes(d[_+h])&&f.push(".");break}case"S":{if(d[_-1]==="S")break;const h=l(_,d);s.includes("s")||(a+=o*1e3),f.push(`${Math.round(a/10**(3-h))}`.padStart(h,"0"));break}default:f.push(m)}}),f.join("")}toSmpte(t){const{uniformSeparators:s}={uniformSeparators:!1,...t};if(this.samples===-1/0)return"00:00:00:00";const{hours:i,minutes:r,seconds:n,frames:o}=this.toUnits(),a=s?this.frameSeparator:":",c=[i.toFixed().padStart(2,"0"),r.toFixed().padStart(2,"0"),n.toFixed().padStart(2,"0")].join(a),l=Math.max(2,`${this.timeBase.toRate({rounded:!0})-1}`.length);return[c,`${o}`.padStart(l,"0")].join(this.frameSeparator)}toObject(){return{samples:this.samples,timeBase:this.timeBase.toObject()}}toJson(){return console.warn("Deprecated - use toObject instead"),this.toObject()}}const Se=(e,t)=>{let s=Math.abs(e),i=Math.abs(t);for(;s&&i&&s!==i;)s>i?[s,i]=[s-i,i]:[s,i]=[s,i-s];return s||i},Pt=(e,t)=>{const{timeBase:s,useGCD:i=!1,roundingMode:r,...n}=t||{},o=`${e}`.replace(/,/g,".");if(Number.isNaN(+o))throw new Error(`seconds must be digits, is ${e}`);let a=1,c;if(Number.isInteger(+o))c=+o*a;else{const[,u]=o.split("."),f=Math.min((u==null?void 0:u.length)??0,16);a*=10**f,c=Math.round(Number(o)*a)}if(s===void 0&&i){const u=Se(a,c);c/=u,a/=u}const l=new F({samples:c,timeBase:{denominator:a,numerator:1}},n);return s!==void 0?l.conformTimeBase(s,{...n,roundingMode:r}):l},ye=([e,t,s,i],r,n)=>{const o=n.toRate({rounded:!0}),a=at(n);if(r===0||!a)return 0;const c=t%10!==0,l=c&&s===0,u=e*(3600*o-54*a),f=t*60*o-(t-Math.ceil(t/10))*a,m=s*o-(c&&s>1?a:0);if(l&&i<a)throw new Error(`Frame does not exist for ${n.toConstant()||n.toRate()} drop-frame`);const _=l?i-a:i,d=u+f+m+_;return r-d},ct=(e,t,s)=>{const[i,r,n,o]=e,a=t.toRate({rounded:!0}),c=i*3600*a+r*60*a+n*a+o;return c-(s?ye(e,c,t):0)},Re=e=>{const[t]=(e==null?void 0:e.match(/[^0-9:\-_]/))||[];let s=[];if(t){const[r,n]=e.split(t);s=[...r.split(":"),n]}else s=e.split(":");if(s.length!==4)throw new Error('Invalid format, must be "##:##:##:##');if(s.some(r=>Number.isNaN(r)))throw new Error("Invalid format, values must be numbers");const i=t||":";return{smpteValues:s.map(Number),smpteFrameSeparator:i}},ve=["error","add","ignore"],Fe={exceedingMode:"error",timeBase:void 0,dropFrame:void 0,frameSeparator:void 0},jt=(e,t)=>{const{exceedingMode:s,timeBase:i,...r}={...Fe,...t};if([null,void 0].includes(e))throw new Error("smpte cannot be undefined or null");if(typeof e!="string")throw new Error(`smpte must be a string, is ${JSON.stringify(e)}`);const{smpteValues:n,smpteFrameSeparator:o}=Re(e),a=W(i),c={...r,frameSeparator:(r==null?void 0:r.frameSeparator)||o,...(r==null?void 0:r.dropFrame)===void 0?{dropFrame:i!==void 0?Lt(a):[";",","].includes(o)}:{}},l=a.toRate({rounded:!0}),u=Math.max(0,l-1);if(n.some(m=>m<0))throw new Error("Negative values are not supported");let f;switch(s){case"error":{const[m,_,d,h]=n;if(m>=100||_>=60)throw Error("Minutes has to be less than 60");if(d>=60)throw Error("Seconds has to be less than 60");if(h>u)throw Error(`Frames has to be less or equal to ${u}`);f=ct(n,a,c==null?void 0:c.dropFrame);break}case"ignore":{const[m,_,d,h]=n,g=[Math.min(100,m),Math.min(59,_),Math.min(59,d),Math.min(u,h)];f=ct(g,a,c==null?void 0:c.dropFrame);break}case"add":{f=ct(n,a,c==null?void 0:c.dropFrame);break}default:throw new Error(`Invalid exceedingMode, options are ${JSON.stringify(ve)}`)}return new F({samples:f,timeBase:a},c)},De={timeBase:void 0,dropFrame:void 0,frameSeparator:void 0},$=(e,t)=>{const{timeBase:s,...i}={...De,...t};let r;if(e===void 0)r={samples:0};else if(typeof e=="number")r={samples:e};else if(e.includes("@")){const[o,a]=e.split("@");r={samples:Number(o),timeBase:G(a)}}else e==="-INF"?r={samples:-1/0}:e==="+INF"?r={samples:1/0}:r={samples:Number(e)};if(Number.isNaN(r==null?void 0:r.samples)||r.timeBase&&!(r.timeBase instanceof y))throw new Error(`timeCodeText must be a number or sample@timeBase - is ${e}`);const n=new F(r,i);return s?n.conformTimeBase(W(s),i):n},Me={dropFrame:void 0,frameSeparator:void 0},L=(e,t)=>new F(e,{...Me,...t}),Ce=e=>!!e.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/),Ne=e=>!Number.isNaN(Number(e)),B=(e,t)=>{if(e instanceof F)return e;if(typeof e!="string"&&typeof e!="number")return L(e,t);if(typeof e=="string"&&Ce(e))return jt(e,t);if(["string","number"].includes(typeof e)&&Ne(e))return Pt(e,t);if(typeof e=="string")return $(e,t)};function kt({hours:e=0,minutes:t=0,seconds:s=0,partialSeconds:i=0}){const r=e.toFixed().padStart(2,"0"),n=t.toFixed().padStart(2,"0"),o=s.toFixed().padStart(2,"0"),a=(i*10).toFixed().padStart(3,"0");return`${r}:${n}:${o}.${a}`}const we={subtitleGroup:"stl_subtitle",subtitleField:"stl_text"},Le=(e,t)=>{const{subtitleGroup:s,subtitleField:i}={...we,...t||{}},{timespan:r=[]}=e||{};if(r.length===0)return"";const o=it(r,{includeTimespanAttributes:!0,sortTimespan:!0,timespanAsList:!0,overrideGroup:!0,joinValue:","}).map(a=>{const{start:c,end:l,[s]:{[i]:u}={}}=(Array.isArray(a)?a[0]:a)||{};if(!u)return"";const f=kt($(c).toTime()),m=kt($(l).toTime());return`${f} --> ${m} line:0%\r${u}\r`});if(o.some(a=>!!a))return`WEBVTT
2
2
 
3
3
 
4
4
  ${o.join(`
5
- `)}`},Be={count:!0,exclude:!0},Pe=(e=[],t={})=>{const s={...Be,...t},{count:i,exclude:r}=s;return e.map(n=>typeof n=="string"?{field:n,name:n,count:i,...r===!0?{exclude:[n]}:{}}:n)},je=(e=[])=>e==null?void 0:e.map(({name:t,field:s,count:i,range:r})=>({facetName:t,fieldName:s,count:i==null?void 0:i.reduce((n,{fieldValue:o,value:a})=>({...n,[o]:a}),{}),...r?{range:r.map(({value:n,start:o,end:a})=>({start:Number.isNaN(+o)?o:Number(o),end:Number.isNaN(+a)?a:Number(a),count:Number(n)||0}))}:{}})),ke=(e=[])=>{const t={};return e.forEach(({name:s,field:i,count:r})=>{t[s||i]=r.reduce((n,{fieldValue:o,value:a})=>({...n,[o]:a}),{})}),t},Wt={arrayOnSingle:!0,joinValue:void 0,timespanAsList:!1},z=(e,t)=>{const{arrayOnSingle:s=!0,joinValue:i=void 0,timespanAsList:r=!1}={...Wt,...t||{}},{field:n=[],start:o,end:a}=e||{},c=r?{start:o,end:a}:{};return n.reduce((u,f)=>{const{name:m,value:_=[]}=f;if(_.length===0)return u;let l;return s===!1&&_.length===1?[l]=_:i?l=_.join(i):l=_,{...u,[m]:l}},c)},We={...Wt,timespanAsList:!1,joinTimespan:"_",flat:!1,flatTimespan:!1},$e=(e=[],t)=>{const{timespanAsList:s,joinTimespan:i="_",flat:r,flatTimespan:n,...o}={...We,...t||{}};return s===!0?e.map(a=>z(a,{...o,timespanAsList:s})):r===!0||n===!0?e.reduce((a,c)=>({...a,...z(c,t)}),{}):e.reduce((a,c)=>({...a,[[c.start,c.end].join(i)]:z(c,t)}),{})},$t=(e,t)=>{const s=B(t).toSeconds(),{thumbnails:i={}}=e||{},{uri:r=[]}=i,n=r.map(a=>{const c=a.split("/").pop().split("?").shift();return $(c).toSeconds()}),o=n.reduce((a,c,d)=>Math.abs(c-s)<Math.abs(n[a]-s)?d:a,0);return r[o]},Ue={includeGroupMetadata:!1,flatEvents:!1,includeEntityType:!1,includeNearestThumbnail:!1},xe=({start:e,end:t,group:s=[{id:"unknown",name:"unknown"}]})=>{const[{id:i,name:r}]=s,n=B(e).toSeconds(),o=B(t).toSeconds();return{start:e,end:t,startSeconds:n,endSeconds:o,group:{uuid:i,name:r}}},Ge=(e={},t)=>{const{entry:s=[]}=e,i={...Ue,...t||{}},{includeGroupMetadata:r,flatEvents:n,includeEntityType:o,includeNearestThumbnail:a}=i,c=s.map(d=>{const{type:u,item:{metadata:f={},id:m,thumbnails:_={}}={},timespan:l,item:h}=d;let g=l.map(A=>xe(A));if(a&&u==="Item"&&_.uri&&(g=g.map(A=>{const{start:I}=A,b=$t(h,B(I));return{...A,thumbnail:b}})),r&&u==="Item"){const{timespan:A=[]}=f,I=A.flatMap(b=>b.group);if(I.length>0){const b=g.map(O=>{const{group:{uuid:S}}=O,[N]=S.split("/"),{field:j=[],group:k=[]}=I.find(({uuid:M})=>M===N);return{...O,group:{...O.group,field:j,group:k}}});return{entityType:"Item",entityId:m,events:b.sort((O,S)=>O.startSeconds-S.startSeconds),...o?{itemType:h}:{}}}}return{entityType:u==="Item"?"Item":"Collection",entityId:m,events:g.sort((A,I)=>A.startSeconds-I.startSeconds),...o&&u==="Item"?{itemType:h}:{},...o&&u==="Collection"?{collectionType:h}:{}}});return n?c.flatMap(({events:d,entityType:u,entityId:f,itemType:m,collectionType:_})=>d.map(l=>({...l,entityType:u,entityId:f,...m&&{itemType:m},..._&&{collectionType:_}}))).sort((d,u)=>d.startSeconds-u.startSeconds):c},ze=(e="NOW")=>{if(e.startsWith("NOW")){if(e==="NOW")return new Date;const t=e[3],s=Number(e.match(/(\d+)/)[0]),i=e.match(/(\d.*)/)[0].replace(/\d/g,""),r=new Date;switch(i){case"HOUR":case"HOURS":t==="+"&&r.setHours(r.getHours()+s),t==="-"&&r.setHours(r.getHours()-s);break;case"DAY":case"DAYS":t==="+"&&r.setDate(r.getDate()+s),t==="-"&&r.setDate(r.getDate()-s);break;case"MONTH":case"MONTHS":t==="+"&&r.setMonth(r.getMonth()+s),t==="-"&&r.setMonth(r.getMonth()-s);break;case"YEAR":case"YEARS":t==="+"&&r.setFullYear(r.getFullYear()+s),t==="-"&&r.setFullYear(r.getFullYear()-s);break}return r}return new Date(e)},V=e=>{const{property:t=[],...s}=e||{};return{...D(t),...s}},Ve=e=>V(e),Ye=e=>V(e),He={kB:"kHz",B:"Hz",mB:"mHz"},Ut={kB:"kbps",B:"bps",MB:"mbps"},xt=e=>{var g;const{timeBase:t,channelCount:s,codec:i,mediaInfo:r,bitrate:n,metadata:o}=e,a=Ve(r),{Format:c,Resolution:d,Bit_rate_mode:u}=a,f=D(o||[]),m=t!=null&&t.denominator?((t==null?void 0:t.denominator)||1)/((t==null?void 0:t.numerator)||1):void 0,_=m!==void 0?v.filesize(m,{base:10,round:1,symbols:He}):void 0;let l,h;return n!==void 0&&(l=v.filesize(n,{round:2,symbols:Ut}),h=Number((g=v.filesize(n,{exponent:1,symbols:Ut}).split(" kbps"))==null?void 0:g[0])),{audioFormat:c,audioCodec:i,audioSamplerate:_,audioSamplerateSamples:m,audioBitDepth:d,audioBitrate:l,audioBitrateKbps:h,audioBitRateMode:u,audioChannels:s,audioMediaInfo:a,audioMetadata:f}},Ke={NONE:"NONE",OPEN:"OPEN",CLOSED:"CLOSED",UNKNOWN:"UNKNOWN",MISSING:"MISSING",LOST:"LOST",TO_APPEAR:"TO_APPEAR",TO_BE_DELETED:"TO_BE_DELETED",BEING_READ:"BEING_READ",ARCHIVED:"ARCHIVED",AWAITING_SYNC:"AWAITING_SYNC"},ut=e=>{const{uri:t=[],size:s,hash:i,path:r,id:n,storage:o}=e,[a]=t,c=s!==void 0?v.filesize(s,{base:2,standard:"jedec"}):"",d=(r==null?void 0:r.split("/"))||[],u=d.pop()||"",f=d.map(m=>`${m}/`).join("")||void 0;return{uri:a,hash:i,fileSize:c,fileSizeBytes:s,path:r,fileName:u,fileId:n,storageId:o,folderPath:f}},Gt=(e={})=>{const{file:t,mediaInfo:s,metadata:i=[]}=e,r=D(i),n=V(s);let o={binaryMetadata:r,binaryMediaInfo:n};if(t){const[a]=t,c=ut(a);o={...o,...c}}return o},zt=(e={})=>{const{mediaInfo:t,metadata:s,file:i,duration:r,startTimestamp:n,startTimecode:o,timeCodeTimeBase:a}=e,c=D(s||[]),d=V(t);let{Format:u}=d;const{Video_Format_List:f,Audio_Format_List:m,Text_Format_List:_}=d;if(u===void 0){const{format:h}=e;u=h,h&&h.includes(",")&&([u]=h.split(","))}let l={containerFormat:u,videoFormat:f,audioFormat:m,textFormat:_,containerMetadata:c,containerMediaInfo:d};if(c.componentOriginalFilename&&(l.originalFilename=c.componentOriginalFilename),r!==void 0&&r.samples!==0){const h=L(r);l.durationTimeCode=h.toObject(),l.duration=h.toDuration()}if(n&&(l.startTimestamp=L(n).toObject()),o!==void 0&&a&&(l.startTimecode=L({samples:o,timeBase:a})),i){const[h]=i,g=ut(h);l={...l,...g}}return l},Vt={kB:"kbps",B:"bps",MB:"mbps"},Yt=(e={})=>{var q;const{codec:t,bitrate:s,fieldOrder:i,resolution:r,mediaInfo:n,metadata:o=[]}=e,a=Ye(n),c=D(o),{Format:d,"Frame rate":u,"Color space":f,"Color primaries":m,Colorimetry:_}=a;let l;const{averageFrameRate:h,realBaseFrameRate:g}=e;g!==void 0?l=w({numerator:g.denominator,denominator:g.numerator}):u!==void 0?l=G(u):h!==void 0&&(l=w({numerator:h.denominator,denominator:h.numerator}));let{"Frame count":A}=a;if(A===void 0){const{numberOfPackets:ee}=e;ee!==void 0&&(A=ee.toString())}let I,b,O;A&&l&&(I=L({samples:A,timeBase:l}),b=I.timeBase.toConstant()||I.timeBase.toRate(),O=I.toSmpte());const{height:S,width:N}=r||{},j=J(r),k=`${N}x${S}`;let M,U;return s!==void 0&&(M=v.filesize(s,{round:2,symbols:Vt}),U=Number((q=v.filesize(s,{exponent:2,symbols:Vt}).split(" mbps"))==null?void 0:q[0])),{videoFormat:d,dimension:k,frameRate:b,height:S,width:N,timeBase:l,timeCode:I,videoCodec:t,smpte:O,videoBitrate:M,videoBitrateMbps:U,fieldOrder:i,colorSpace:f,chromaSubsampling:_,aspectRatio:j,colorPrimaries:m,videoMetadata:c,videoMediaInfo:a}},Y=(e={},t={})=>{let s={};const{priority:i=["container","video","audio","binary"]}=t,{containerComponent:r,videoComponent:n,audioComponent:o,binaryComponent:a,mimeType:c=[],tag:d=[]}=e;[s.tag]=d,[s.mimeType]=c;const u=(f,m)=>Object.fromEntries([...new Set([...Object.keys(m),...Object.keys(f)])].map(_=>[_,m[_]??f[_]]));return i.reverse().forEach(f=>{switch(f){case"container":r&&(s=u(s,zt(r)));break;case"video":if(n){const[m]=n;s=u(s,Yt(m))}break;case"audio":if(o){const[m]=o;s=u(s,xt(m))}break;case"binary":if(a){const[m]=a;s=u(s,Gt(m))}break}}),s},P={PDF:"PDF",TEXT:"TEXT",MSWORD:"MSWORD",JSON:"JSON",XML:"XML"},R={IMAGE:"IMAGE",AUDIO:"AUDIO",VIDEO:"VIDEO",DOCUMENT:"DOCUMENT",BINARY:"BINARY"},qe=(e={})=>{const{mimeType:t}=e,s=Array.isArray(t)?t[0]:t;if(s){if(s.endsWith("/pdf"))return P.PDF;if(s.startsWith("text/"))return P.TEXT;if(s.endsWith("/msword"))return P.MSWORD;if(s.endsWith("/json"))return P.JSON;if(s.endsWith("/xml"))return P.XML}},Je=["image/apng","image/bmp","image/gif","image/jpeg","image/x-icon","image/png","image/svg+xml"],Xe=["video/mp4"],Qe=["audio/mp4","audio/mpeg","audio/x-aac","audio/aac","audio/x-wav","audio/wav","audio/accp","audio/ogg","audio/webm","audio/x-flac"],Ze=[...Xe,...Je,...Qe],ts=["http","https"],es="video/mp4",ss="video/quicktime",rs="video/x-m4v",is="MPEG-4",ns="mov",as="h264",H=["__mp4","__mp3_160k","__png","__jpeg","__gif","original"].reverse(),Ht=({parsedShape:{tag:e}},{parsedShape:{tag:t}})=>H.includes(e)||H.includes(t)?H.indexOf(t)-H.indexOf(e):e.toLowerCase().localeCompare(t.toLowerCase()),os=(e,t)=>{const{allowedMimeTypes:s=Ze,allowedMethods:i=ts,sortPriority:r=Ht,sourceKey:n="src",mimeTypeKey:o="type",shapeKey:a="shape",parsedShapeKey:c="parsedShape"}=t||{},{shape:d=[]}=e||{},u=d.reduce((f,m)=>{let _,l;const h=Y(m),{uri:g,mimeType:A,containerFormat:I,videoCodec:b}=h;if(A&&(_=A,(A===ss||A===rs)&&(I===is||I===ns)&&b===as&&(_=es)),g)if(i){const[O]=g.split("://");i.includes(O)&&(l=g)}else l=g;return l&&s.includes(_)&&f.push({[n]:l,[o]:_,[a]:m,[c]:h}),f},[]);return typeof r=="function"&&u.sort(Ht),u},cs=e=>{const t=Y(e),{mimeType:s,videoCodec:i,audioCodec:r}=t;if(s){if(s.startsWith("audio/")&&r!==void 0)return R.AUDIO;if(s.startsWith("video/")){if(i!==void 0)return R.VIDEO;if(r!==void 0)return R.AUDIO}if(s.startsWith("image/"))return R.IMAGE;if(s.endsWith("/pdf")||s.startsWith("text/")||s.endsWith("/msword")||s.endsWith("/json")||s.endsWith("/xml"))return R.DOCUMENT;if(s.endsWith("/octet-stream"))return R.BINARY}},Kt="video/mp4",qt="video/quicktime",Jt="video/x-m4v",us="MPEG-4",ds="mov",ls="h264",fs=[Kt,qt,Jt],Xt=["video/x-mxf-h264","video/x-mxf-h264-aac","video/x-mxf-h264-pcm_s24le","video/x-mxf-mpeg2video-pcm_s24le","video/x-mxf-mpeg2video-pcm_s16le","video/x-mxf-prores-pcm_s16le","video/x-mxf-h264-pcm_s16le"],ms=[...fs,...Xt],hs=["audio/mp4","audio/mpeg","audio/x-aac","audio/aac","audio/x-wav","audio/wav","audio/accp","audio/ogg","audio/webm","audio/x-flac"],ps=[...ms,...hs],_s=["http","https"],Ts=({streamingServers:e,url:t,ending:s})=>se(e[0],window.btoa(t),`.${s}`),Es=(e,t)=>{const{allowedMimeTypes:s=ps,allowedMethods:i=_s,streamingServers:r=[]}=t||{},{shape:n=[]}=e||{},{startTimeCode:o}=Ct(e==null?void 0:e.metadata,{flat:!0,arrayOnSingleValue:!1});return n.reduce((c,d)=>{var N,j,k;let u,f,m;const _=Y(d),{uri:l,mimeType:h,containerFormat:g,videoCodec:A}=_;if(!(s!=null&&s.includes(h))||!(i!=null&&i.includes((N=l==null?void 0:l.split("://"))==null?void 0:N[0])))return c;if(m=_.tag,!m){const M=(k=(j=h==null?void 0:h.split)==null?void 0:j.call(h,"/"))==null?void 0:k.pop(),U=c.filter(q=>q.label===M).length;U===0?m=M:m=M+(U+1)}const{timeBase:I,startTimecode:b}=_,O=o??b,S=O&&B(O);return f=l,u=h,(h===qt||h===Jt)&&(g===us||g===ds)&&A===ls&&(u=Kt),r!=null&&r.length&&Xt.includes(h)&&(f=Ts({url:l,streamingServers:r,ending:"mpd"}),u="application/dash+xml"),f&&c.push({src:f,...u?{type:u}:{},...m?{label:m}:{},...I?{timeBase:I}:{},...S?{startTimeCode:S}:{}}),c},[])},Qt=e=>{const t={},{outputSetting:s=[]}=e||{};if(s.length===0)return t;const i=JSON.parse(s[0]),{Settings:{ContainerSettings:r,VideoDescription:n,AudioDescriptions:o}={}}=i;if(r&&(t.containerFormat=r.Container),n){const{CodecSettings:a={}}=n,{Codec:c,...d}=a;t.videoFormat=c;const{Height:u,Width:f}=n;t.height=u,t.width=f,u&&f&&(t.dimension=`${f}x${u}`,t.aspectRatio=J({height:u,width:f}));const[m]=Object.values(d);if(m){t.fieldOrder=m.InterlaceMode,t.fieldOrder&&t.fieldOrder.includes("TOP")&&(t.fieldOrder="interlaced"),t.videoBitrate=m.Bitrate;const _=m.FramerateDenominator,l=m.FramerateNumerator,h=w({denominator:l,numerator:_});t.timeBase=h,t.frameRate=h.toConstant()||h.toRate()}}if(o&&o.length>0){const{CodecSettings:a={}}=o[0],{Codec:c,...d}=a;t.audioFormat=c;const[u]=Object.values(d);u&&(t.audioSamplerate=u.SampleRate,t.audioBitrate=u.Bitrate,t.audioBitRateMode=u.RateControlMode)}return t},gs=e=>{const t={},{description:s,format:i,audio:r,video:n,mediaconvert:o}=e||{};if(o)return{description:s,...Qt(o)};if(t.description=s,t.containerFormat=i,n){if(t.videoFormat=n.codec,t.videoBitrate=n.bitrate,n.framerate){const a=w(n.framerate);t.timeBase=a,t.frameRate=a.toConstant()||a.toRate()}if(n.scaling){const{height:a,width:c}=n.scaling;t.height=a,t.width=c,a&&c&&(t.dimension=`${c}x${a}`,t.aspectRatio=J({height:a,width:c}))}}if(r){const{codec:a,channel:c}=r;t.audioFormat=a,c&&(t.audioChannels=c.length)}return t},As=e=>{if(!e)return;const{name:t,type:s,defaultValue:i,stringRestriction:r,floatRestriction:n,integerRestriction:o,longRestriction:a,data:c,values:d,system:u}=e,{minLength:f,maxLength:m,pattern:_}=r||{},{minInclusive:l,maxInclusive:h}=n||o||a||{},g=((d==null?void 0:d.field)||[]).map(({key:O,value:S})=>({label:S??O,value:O})),I=(O=>Object.fromEntries(Object.entries(O).filter(([,S])=>S!==void 0)))({min:l,max:h,minLength:f,maxLength:m,pattern:_?new RegExp(_):void 0}),b=D(c);return{name:t,type:s,defaultValue:i,required:l!==void 0||f!==void 0&&f>0,restrictions:I,data:b,options:g,system:u!==void 0?u==="true":void 0}},Is=e=>e==null?void 0:e.map(As).filter(t=>!!t),Os=["date","float","integer","long","string","string-exact","boolean","timeCode"];class K{constructor(){this.events={}}on(t,s){const i=this.events[t]||[];i.push(s),this.events[t]=i}off(t){this.events[t]&&(this.events[t]=[])}trigger(t,s,i){const r=this.events[t];!r||r.length<1||r.forEach(n=>{n(s,i)})}}var T=(e=>(e[e.transferring=1]="transferring",e[e.paused=2]="paused",e[e.complete=3]="complete",e[e.failed=4]="failed",e[e.idle=5]="idle",e[e.canceled=6]="canceled",e[e.offline=7]="offline",e))(T||{}),E=(e=>(e.progress="progress",e.update="update",e.complete="complete",e.error="error",e.added="upload-added",e.removed="upload-removed",e.failed="upload-failed",e.retry="retry",e.pausing="pausing",e.paused="paused",e.resuming="resuming",e.offline="offline",e.online="online",e))(E||{});class Zt{constructor(t={}){this.blobSlice=(t==null?void 0:t.blobSlice)??null,this.fileSize=(t==null?void 0:t.fileSize)??null,this.start=(t==null?void 0:t.start)??null,this.end=(t==null?void 0:t.end)??null,this.api=(t==null?void 0:t.api)??null,this.state={retries:0,status:T.idle,startTime:null,completeTime:null,response:null,bytesTransferred:null},this.eventBus=new K}tryTransfer(){return this.state.status=T.transferring,this.state.startTime=performance.now(),new Promise((t,s)=>{const i=()=>{this.transfer().then(r=>{this.state.response=r,this.onComplete(),t(this)}).catch(()=>{this.state.retries>3?(this.state.status=T.failed,s(new Error(`Chunk ${this.start}-${this.end} failed`))):this.state.status!==T.paused?(this.state.retries+=1,this.tryTimeout=setTimeout(()=>{i()},1e3)):clearTimeout(this.tryTimeout)})};i(),window.addEventListener(E.online,()=>{this.resume()}),window.addEventListener(E.offline,()=>{this.pause()})})}transfer(){let t={file:this.blobSlice,onUploadProgress:s=>{[T.complete,T.offline].includes(this.state.status)||(this.state.bytesTransferred=s==null?void 0:s.loaded,this.eventBus.trigger(E.progress,this.state))}};return t={...t,...this.api.props||{}},this.end-this.start!==this.fileSize&&(t.headers={index:this.start,size:this.fileSize,...t.headers||{}}),this.transferPromise=this.api.method(t),this.state.status=T.transferring,this.transferPromise}pause(){this.state.status!==T.complete&&(this.state.status=T.paused)}resume(){this.state.status!==T.complete&&(this.state.status=T.transferring)}cancel(){this.state.status!==T.complete&&(this.state.status=T.canceled)}get transferRate(){if(this.state.bytesTransferred){const t=(this.state.completeTime-this.state.startTime)/1e3;return this.state.bytesTransferred/t}return 0}onComplete(){this.state.status=T.complete,this.state.bytesTransferred=this.end-this.start,this.state.completeTime=performance.now(),this.eventBus.trigger(E.complete,this.state)}}class dt{constructor(t,s){var i,r,n,o,a,c;if(this.DEFAULT_OPTIONS=Object.freeze({targetRate:4e6,chunkSize:8388608,minChunkSize:8388608,maxConcurrentTransfers:1,maxConcurrentFileTransfers:1,autoMaxConcurrentTransfers:!1,minFileSize:104857600,autoResume:!0,api:void 0}),this.eventBus=new K,!s.api.method)throw new Error("No api method specified");this.options={...this.DEFAULT_OPTIONS,...s,api:{...s.api??{},props:{...((i=s.api)==null?void 0:i.props)??{},queryParams:{transferId:ne(),...((n=(r=s.api)==null?void 0:r.props)==null?void 0:n.queryParams)??{}}}}},this.state={blob:null,chunks:[],transferPromises:[],targetRate:this.options.targetRate,rate:0,autoMaxConcurrentTransfers:this.options.autoMaxConcurrentTransfers,maxConcurrentTransfers:this.options.maxConcurrentTransfers,mime:"",status:T.idle,transferId:(c=(a=(o=s.api)==null?void 0:o.props)==null?void 0:a.queryParams)==null?void 0:c.transferId,lastStats:{}},typeof t=="object"?(this.state.blob=t,this.state.mime=t.type,this.addChunksFromBlob(t)):console.error(new Error(`Expected a File or a Blob object, but got ${typeof t}`))}upload(){const{status:t}=this.state;if(t!==T.complete)if(t===T.idle||t===T.transferring){const s=this.state.chunks.length;let i=0;const r=()=>{for(;this.state.transferPromises.length<this.state.maxConcurrentTransfers&&i<s;){const n=this.state.chunks[i];if(i+=1,n.state.status!==T.complete&&n.state.status!==T.transferring){this.state.status=T.transferring;const o=n.tryTransfer();this.state.transferPromises.push(o),o.then(()=>{const a=this.state.transferPromises.indexOf(o);a!==-1&&this.state.transferPromises.splice(a,1),this.state.status!==T.canceled&&r()}).catch(a=>{const c=this.state.transferPromises.indexOf(o);c!==-1&&this.state.transferPromises.splice(c,1),console.error("Failed on this upload(), check connectivity and try to resume",a),this.state.status!==T.offline?(this.state.status=T.failed,this.eventBus.trigger(E.failed,this.state,a),this.options.onFail&&this.options.onFail(a)):setTimeout(()=>this.retry(),5e3)})}}};r()}else this.retry()}getByteRangesForChunks(t,s=this.options.chunkSize){const i=[],{minChunkSize:r}=this.options;let o=s>=r?s:r,a=Math.floor(t.size/o);if(t.size-(t.size-t.size/a)>=r||(a-=1,o=Math.floor(t.size/a)),a<2||t.size<this.options.minFileSize)i.push({start:0,end:t.size});else for(let c=0;c<=a;c+=1){const d=o*c;let u=o*c+o;t.size-o*c<=r&&(u=t.size);const m={start:d,end:u};if(i.push(m),u===t.size)break}return i}addChunksFromBlob(t){this.getByteRangesForChunks(t).forEach(i=>{const r=new Zt({start:i.start,end:i.end,blobSlice:t.slice(i.start,i.end),fileSize:t.size,api:this.options.api});r.eventBus.on(E.progress,()=>{this.onProgress()}),r.eventBus.on(E.complete,()=>{this.onProgress()}),this.state.chunks.push(r)})}retry(){this.state.status===T.failed&&(this.resume(),this.eventBus.trigger(E.retry,this.state))}resume(){this.state.status=T.transferring,this.eventBus.trigger(E.resuming,this.state),this.state.chunks.length>0&&this.state.chunks.forEach(t=>{t.resume()})}pause(){this.state.status=T.paused,this.state.chunks.length>0&&this.state.chunks.forEach(s=>{s.pause()});const t=Promise.all(this.state.transferPromises);return this.eventBus.trigger(E.pausing,this.state),t.then(()=>{this.eventBus.trigger(E.paused,this.state)}),Promise.all(this.state.transferPromises)}cancel(){this.state.status=T.canceled,this.state.chunks.length>0&&this.state.chunks.forEach(s=>{s.cancel()});const t=Promise.all(this.state.transferPromises);return t.then(()=>{this.eventBus.trigger(E.removed,this.state)}),t}autoAdjustMaxConcurrentTransfers(t){if(this.state.autoMaxConcurrentTransfers&&this.state.status!==T.complete){const s=t.avgTransferRate/this.state.targetRate;if(s>1.2)this.state.maxConcurrentTransfers+=1;else if(s<.3)this.state.maxConcurrentTransfers=1;else{const i=this.options.maxConcurrentTransfers-1;this.state.maxConcurrentTransfers=Math.max(this.options.maxConcurrentTransfers,Math.min(i,this.options.maxConcurrentTransfers))}}}onProgress(){try{const t=this.getStats();t!==this.state.lastStats&&(this.state.lastStats=t,ie(()=>{this.autoAdjustMaxConcurrentTransfers(t)},1e3,!1)({}),this.state.status!==T.complete&&(t.totalChunks===t.completedChunks?this.onComplete():(this.eventBus.trigger(E.progress,this.state),this.options.onProgress&&this.options.onProgress(t))))}catch(t){console.error(t)}}onComplete(){const t=this.getStats();this.state.lastStats=t,this.state.status=T.complete,this.eventBus.trigger(E.complete,this.state),this.options.onComplete&&this.options.onComplete(this.finalResponse)}getStats(){const t=this.state.chunks.length,s=this.state.chunks.filter(d=>d.state.status===T.complete),i=this.state.chunks.filter(d=>d.state.status===T.transferring),r=s.length;let n=0,o=0;s.forEach(d=>{n+=d.transferRate,o+=d.blobSlice.size}),i.forEach(d=>{o+=d.state.bytesTransferred});const a=n/r,c={totalChunks:t,completedChunks:r,totalBytes:this.state.blob.size,transferredBytes:o,avgTransferRate:a,concurrentTransfers:this.state.maxConcurrentTransfers};return this.state.rate=c.avgTransferRate,c}set concurrentTransfers(t){this.state.autoMaxConcurrentTransfers=!1,this.state.maxConcurrentTransfers=t}set rate(t){this.state.targetRate=t}get rate(){return this.state.rate}get finalResponse(){const t=this.state.chunks.length-1,s=!1;for(let i=t;i>=0;i-=1){const r=this.state.chunks[i];if(typeof r.state.response.data=="object")return r.state.response}return s}get transferId(){return this.state.transferId}}function bs(e,t){return e===0||t===0?0:Math.floor(e/t*100)}const Ss={maxConcurrentFileTransfers:1,autoResume:!0};class ys{constructor(t){this.initialState=Object.freeze({status:T.idle,transfers:[],bytesDone:0,bytesTotal:0,lastStats:{bytesDone:0,bytesTotal:0}}),this.state={...this.initialState},this.options={...Ss,...t},this.events=new K,this.bindNetworkEvents()}get transfers(){return Object.values(this.state.transfers)||[]}get status(){return this.state.status}set status(t){this.events.trigger(E.update,this.state),this.state.status=t}get bytesTotal(){let t=0;return this.transfers.forEach(s=>{t+=s.state.blob.size}),t}get bytesDone(){let t=0;return this.transfers.forEach(s=>{t+=s.getStats().transferredBytes}),t}get isUploading(){return this.state.status===T.transferring}get paused(){let t=!0;return this.transfers.forEach(s=>{s.state.status!==T.paused&&(t=!1)}),t}bindNetworkEvents(){typeof window>"u"||(window.addEventListener(E.online,()=>{this.events.trigger(E.online,this.state),this.state.status=T.transferring,this.options.autoResume&&setTimeout(()=>{this.retry()},1500)}),window.addEventListener(E.offline,()=>{this.events.trigger(E.offline,this.state),this.state.status=T.offline}))}addChunkedUpload(t){t.transferId!==null&&(this.state.transfers[t.transferId]=t,t.eventBus.on(E.progress,()=>{this.onProgress()}),t.eventBus.on(E.complete,()=>{this.upload(),this.onProgress()}),t.eventBus.on(E.failed,(s,i)=>{this.onFail(i,s)}),t.eventBus.on(E.retry,()=>{this.events.trigger(E.retry,this.state)}),t.eventBus.on(E.paused,()=>{this.paused&&this.events.trigger(E.paused,this.state)}),this.updateStats(),this.events.trigger(E.added,this.state),this.events.trigger(E.update,this.state))}removeChunkedUpload(t,s=!1){const i=r=>r?r.state.status===T.complete&&!s?(console.error("Can't cancel complete transfers, pass true as a second argument in .removeChunkedUpload() to force removal."),!1):(Object.keys(this.state.transfers).forEach(n=>{r===this.state.transfers[n]&&delete this.state.transfers[n]}),this.events.trigger(E.removed,this.state),r.cancel(),!0):(console.error("Could not find a matching transfer to cancel."),!1);t instanceof dt?i(t):t instanceof File?i(this.exists(t)):typeof t=="string"?i(this.transfers.find(r=>r.transferId===t)):console.error("Invalid object to remove - has to be either ChunkedUpload, File or transferId")}onProgress(){this.updateStats(),this.hasCompleted?this.onComplete():this.state.bytesDone!==this.state.lastStats.bytesDone&&(this.state.status=T.transferring,this.events.trigger(E.progress,this.state))}onComplete(){this.state.status=T.complete,this.events.trigger(E.complete,this.state)}exists(t){let s;for(let i=0;i<this.transfers.length;i+=1){const r=this.transfers[i];if(r.state.blob.name===t.name&&r.state.blob.lastModified===t.lastModified&&r.state.blob.size&&t.size)return s=r,s}return s}isTransferAvailable(t){return t.state.status!==T.complete&&t.state.status!==T.transferring||t.state.status===T.idle}pause(){let t=Promise.resolve(!0);if(!this.paused){this.events.trigger(E.pausing,this.state);const s=[];this.transfers.forEach(i=>{s.push(i.pause())}),t=Promise.all(s),t.then(()=>{this.events.trigger(E.paused,this.state)})}return t}resume(){this.events.trigger(E.update,this.state),this.transfers.forEach(t=>{this.isTransferAvailable(t)&&t.state.status!==T.idle&&t.resume()})}retry(){this.status===T.failed&&(this.resume(),this.events.trigger(E.retry,this.state))}upload(){let t=0;this.transfers.forEach(s=>{this.isTransferAvailable(s)?t<this.options.maxConcurrentFileTransfers&&(this.events.trigger(E.update,this.state),s.upload(),t+=1):s.state.status!==T.complete&&(t+=1)}),t>0&&(this.status=T.transferring),t<this.options.maxConcurrentFileTransfers&&this.transfers.length<t&&this.upload()}onFail(t,s){this.status=T.failed,this.events.trigger(E.error,s,t)}reset(){this.transfers.forEach(t=>{t.constructor.name===dt.name&&this.removeChunkedUpload(t,!0)}),this.state={...this.initialState},this.events.trigger(E.update,this.state),this.events.trigger(E.complete,this.state)}destroy(){this.reset()}get hasCompleted(){let t=!0;return this.transfers.forEach(s=>{s.state.status!==T.complete&&(t=!1)}),t}updateStats(){this.state.lastStats.bytesDone=this.state.bytesDone,this.state.lastStats.bytesTotal=this.state.bytesTotal,this.state.bytesTotal=this.bytesTotal,this.state.bytesDone=this.bytesDone}get percentDone(){return bs(this.state.bytesDone,this.state.bytesTotal)}get fileList(){const t=[];return this.transfers.forEach(s=>{const i=s.getStats(),{totalChunks:r,completedChunks:n}=i,o={name:s.state.blob.name,bytesDone:i.transferredBytes,bytesTotal:s.state.blob.size,totalChunks:r,completedChunks:n,transfer:s};t.push(o)}),t}}const te=(e,t,s="")=>{const i=a=>{const c=a.startsWith("/")?a.slice(1):a,d=(c==null?void 0:c.search("/"))??-1;return d===-1?[c]:[c.slice(0,d),c.slice(d+1)]},[r,n]=i(t),o=[s,r].filter(Boolean).join("/");return n?{[r]:{file:new File([e],r,{...e,type:"folder"}),path:o,progress:{totalBytes:e.size??0,transferredBytes:0},files:te(e,n,o)}}:{[r]:{file:e,path:o,progress:{totalBytes:e.size??0,transferredBytes:0}}}},Rs=e=>e.map(t=>te(t,t.path??t.webkitRelativePath)).reduce((t,s)=>re(t,s),{});p.Chunk=Zt,p.ChunkedTransferManager=ys,p.ChunkedUpload=dt,p.ChunkedUploadEventBus=K,p.DOCUMENT_TYPES=P,p.EVENTS=E,p.FIELD_ATTRIBUTE_KEYS=ht,p.FIELD_DEFINITION_TYPES=Os,p.FIELD_VALUE_ATTRIBUTE_KEYS=mt,p.FILE_STATES=Ke,p.GROUP_ATTRIBUTE_KEYS=pt,p.ROLE_NAMES=ae,p.SHAPE_MEDIA_TYPES=R,p.STATUSES=T,p.SYSTEM_FIELDGROUPS=oe,p.SYSTEM_FIELDS=ce,p.TimeBase=y,p.TimeCode=F,p.createMetadataType=pe,p.createSearchFacetList=Pe,p.createTimeBase=W,p.createTimeCode=B,p.fileListToFileTree=Rs,p.filterShapeSource=os,p.findNearestThumbnail=$t,p.formatTimeBaseText=G,p.formatTimeBaseType=w,p.formatTimeCodeSeconds=Pt,p.formatTimeCodeSmpte=jt,p.formatTimeCodeText=$,p.formatTimeCodeType=L,p.getPlayerSources=Es,p.getShapeDocumentType=qe,p.getShapeMediaType=cs,p.metadataTypeToWebVtt=Le,p.parseAudioComponent=xt,p.parseBinaryComponent=Gt,p.parseContainerComponent=zt,p.parseFacetList=je,p.parseFacetType=ke,p.parseFieldDefinitionList=Is,p.parseFieldList=tt,p.parseFileType=ut,p.parseGroupList=st,p.parseHighlightTimespan=z,p.parseHighlightTimespanList=$e,p.parseKeyValuePairType=D,p.parseMediaConvertPreset=Qt,p.parseMetadataType=Ct,p.parseNowDate=ze,p.parseSearchResultEvents=Ge,p.parseShapeType=Y,p.parseSimpleMetadataType=be,p.parseTimespan=Mt,p.parseTimespanList=it,p.parseTranscodePreset=gs,p.parseVideoComponent=Yt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
5
+ `)}`},Be={count:!0,exclude:!0},Pe=(e=[],t={})=>{const s={...Be,...t},{count:i,exclude:r}=s;return e.map(n=>typeof n=="string"?{field:n,name:n,count:i,...r===!0?{exclude:[n]}:{}}:n)},je=(e=[])=>e==null?void 0:e.map(({name:t,field:s,count:i,range:r})=>({facetName:t,fieldName:s,count:i==null?void 0:i.reduce((n,{fieldValue:o,value:a})=>({...n,[o]:a}),{}),...r?{range:r.map(({value:n,start:o,end:a})=>({start:Number.isNaN(+o)?o:Number(o),end:Number.isNaN(+a)?a:Number(a),count:Number(n)||0}))}:{}})),ke=(e=[])=>{const t={};return e.forEach(({name:s,field:i,count:r})=>{t[s||i]=r.reduce((n,{fieldValue:o,value:a})=>({...n,[o]:a}),{})}),t},Wt={arrayOnSingle:!0,joinValue:void 0,timespanAsList:!1},z=(e,t)=>{const{arrayOnSingle:s=!0,joinValue:i=void 0,timespanAsList:r=!1}={...Wt,...t||{}},{field:n=[],start:o,end:a}=e||{},c=r?{start:o,end:a}:{};return n.reduce((u,f)=>{const{name:m,value:_=[]}=f;if(_.length===0)return u;let d;return s===!1&&_.length===1?[d]=_:i?d=_.join(i):d=_,{...u,[m]:d}},c)},We={...Wt,timespanAsList:!1,joinTimespan:"_",flat:!1,flatTimespan:!1},$e=(e=[],t)=>{const{timespanAsList:s,joinTimespan:i="_",flat:r,flatTimespan:n,...o}={...We,...t||{}};return s===!0?e.map(a=>z(a,{...o,timespanAsList:s})):r===!0||n===!0?e.reduce((a,c)=>({...a,...z(c,t)}),{}):e.reduce((a,c)=>({...a,[[c.start,c.end].join(i)]:z(c,t)}),{})},$t=(e,t)=>{const s=B(t).toSeconds(),{thumbnails:i={}}=e||{},{uri:r=[]}=i,n=r.map(a=>{const c=a.split("/").pop().split("?").shift();return $(c).toSeconds()}),o=n.reduce((a,c,l)=>Math.abs(c-s)<Math.abs(n[a]-s)?l:a,0);return r[o]},Ue={includeGroupMetadata:!1,flatEvents:!1,includeEntityType:!1,includeNearestThumbnail:!1},xe=({start:e,end:t,group:s=[{id:"unknown",name:"unknown"}]})=>{const[{id:i,name:r}]=s,n=B(e).toSeconds(),o=B(t).toSeconds();return{start:e,end:t,startSeconds:n,endSeconds:o,group:{uuid:i,name:r}}},Ge=(e={},t)=>{const{entry:s=[]}=e,i={...Ue,...t||{}},{includeGroupMetadata:r,flatEvents:n,includeEntityType:o,includeNearestThumbnail:a}=i,c=s.map(l=>{const{type:u,item:{metadata:f={},id:m,thumbnails:_={}}={},timespan:d,item:h}=l;let g=d.map(A=>xe(A));if(a&&u==="Item"&&_.uri&&(g=g.map(A=>{const{start:I}=A,b=$t(h,B(I));return{...A,thumbnail:b}})),r&&u==="Item"){const{timespan:A=[]}=f,I=A.flatMap(b=>b.group);if(I.length>0){const b=g.map(O=>{const{group:{uuid:S}}=O,[N]=S.split("/"),{field:j=[],group:k=[]}=I.find(({uuid:M})=>M===N);return{...O,group:{...O.group,field:j,group:k}}});return{entityType:"Item",entityId:m,events:b.sort((O,S)=>O.startSeconds-S.startSeconds),...o?{itemType:h}:{}}}}return{entityType:u==="Item"?"Item":"Collection",entityId:m,events:g.sort((A,I)=>A.startSeconds-I.startSeconds),...o&&u==="Item"?{itemType:h}:{},...o&&u==="Collection"?{collectionType:h}:{}}});return n?c.flatMap(({events:l,entityType:u,entityId:f,itemType:m,collectionType:_})=>l.map(d=>({...d,entityType:u,entityId:f,...m&&{itemType:m},..._&&{collectionType:_}}))).sort((l,u)=>l.startSeconds-u.startSeconds):c},ze=(e="NOW")=>{if(e.startsWith("NOW")){if(e==="NOW")return new Date;const t=e[3],s=Number(e.match(/(\d+)/)[0]),i=e.match(/(\d.*)/)[0].replace(/\d/g,""),r=new Date;switch(i){case"HOUR":case"HOURS":t==="+"&&r.setHours(r.getHours()+s),t==="-"&&r.setHours(r.getHours()-s);break;case"DAY":case"DAYS":t==="+"&&r.setDate(r.getDate()+s),t==="-"&&r.setDate(r.getDate()-s);break;case"MONTH":case"MONTHS":t==="+"&&r.setMonth(r.getMonth()+s),t==="-"&&r.setMonth(r.getMonth()-s);break;case"YEAR":case"YEARS":t==="+"&&r.setFullYear(r.getFullYear()+s),t==="-"&&r.setFullYear(r.getFullYear()-s);break}return r}return new Date(e)},V=e=>{const{property:t=[],...s}=e||{};return{...D(t),...s}},Ve=e=>V(e),Ye=e=>V(e),He={kB:"kHz",B:"Hz",mB:"mHz"},Ut={kB:"kbps",B:"bps",MB:"mbps"},xt=e=>{var g;const{timeBase:t,channelCount:s,codec:i,mediaInfo:r,bitrate:n,metadata:o}=e,a=Ve(r),{Format:c,Resolution:l,Bit_rate_mode:u}=a,f=D(o||[]),m=t!=null&&t.denominator?((t==null?void 0:t.denominator)||1)/((t==null?void 0:t.numerator)||1):void 0,_=m!==void 0?v.filesize(m,{base:10,round:1,symbols:He}):void 0;let d,h;return n!==void 0&&(d=v.filesize(n,{round:2,symbols:Ut}),h=Number((g=v.filesize(n,{exponent:1,symbols:Ut}).split(" kbps"))==null?void 0:g[0])),{audioFormat:c,audioCodec:i,audioSamplerate:_,audioSamplerateSamples:m,audioBitDepth:l,audioBitrate:d,audioBitrateKbps:h,audioBitRateMode:u,audioChannels:s,audioMediaInfo:a,audioMetadata:f}},Ke={NONE:"NONE",OPEN:"OPEN",CLOSED:"CLOSED",UNKNOWN:"UNKNOWN",MISSING:"MISSING",LOST:"LOST",TO_APPEAR:"TO_APPEAR",TO_BE_DELETED:"TO_BE_DELETED",BEING_READ:"BEING_READ",ARCHIVED:"ARCHIVED",AWAITING_SYNC:"AWAITING_SYNC"},ut=e=>{const{uri:t=[],size:s,hash:i,path:r,id:n,storage:o}=e,[a]=t,c=s!==void 0?v.filesize(s,{base:2,standard:"jedec"}):"",l=(r==null?void 0:r.split("/"))||[],u=l.pop()||"",f=l.map(m=>`${m}/`).join("")||void 0;return{uri:a,hash:i,fileSize:c,fileSizeBytes:s,path:r,fileName:u,fileId:n,storageId:o,folderPath:f}},Gt=(e={})=>{const{file:t,mediaInfo:s,metadata:i=[]}=e,r=D(i),n=V(s);let o={binaryMetadata:r,binaryMediaInfo:n};if(t){const[a]=t,c=ut(a);o={...o,...c}}return o},zt=(e={})=>{const{mediaInfo:t,metadata:s,file:i,duration:r,startTimestamp:n,startTimecode:o,timeCodeTimeBase:a}=e,c=D(s||[]),l=V(t);let{Format:u}=l;const{Video_Format_List:f,Audio_Format_List:m,Text_Format_List:_}=l;if(u===void 0){const{format:h}=e;u=h,h&&h.includes(",")&&([u]=h.split(","))}let d={containerFormat:u,videoFormat:f,audioFormat:m,textFormat:_,containerMetadata:c,containerMediaInfo:l};if(c.componentOriginalFilename&&(d.originalFilename=c.componentOriginalFilename),r!==void 0&&r.samples!==0){const h=L(r);d.durationTimeCode=h.toObject(),d.duration=h.toDuration()}if(n&&(d.startTimestamp=L(n).toObject()),o!==void 0&&a&&(d.startTimecode=L({samples:o,timeBase:a})),i){const[h]=i,g=ut(h);d={...d,...g}}return d},Vt={kB:"kbps",B:"bps",MB:"mbps"},Yt=(e={})=>{var q;const{codec:t,bitrate:s,fieldOrder:i,resolution:r,mediaInfo:n,metadata:o=[]}=e,a=Ye(n),c=D(o),{Format:l,"Frame rate":u,"Color space":f,"Color primaries":m,Colorimetry:_}=a;let d;const{averageFrameRate:h,realBaseFrameRate:g}=e;g!==void 0?d=w({numerator:g.denominator,denominator:g.numerator}):u!==void 0?d=G(u):h!==void 0&&(d=w({numerator:h.denominator,denominator:h.numerator}));let{"Frame count":A}=a;if(A===void 0){const{numberOfPackets:ee}=e;ee!==void 0&&(A=ee.toString())}let I,b,O;A&&d&&(I=L({samples:A,timeBase:d}),b=I.timeBase.toConstant()||I.timeBase.toRate(),O=I.toSmpte());const{height:S,width:N}=r||{},j=J(r),k=`${N}x${S}`;let M,U;return s!==void 0&&(M=v.filesize(s,{round:2,symbols:Vt}),U=Number((q=v.filesize(s,{exponent:2,symbols:Vt}).split(" mbps"))==null?void 0:q[0])),{videoFormat:l,dimension:k,frameRate:b,height:S,width:N,timeBase:d,timeCode:I,videoCodec:t,smpte:O,videoBitrate:M,videoBitrateMbps:U,fieldOrder:i,colorSpace:f,chromaSubsampling:_,aspectRatio:j,colorPrimaries:m,videoMetadata:c,videoMediaInfo:a}},Y=(e={},t={})=>{let s={};const{priority:i=["container","video","audio","binary"]}=t,{containerComponent:r,videoComponent:n,audioComponent:o,binaryComponent:a,mimeType:c=[],tag:l=[]}=e;[s.tag]=l,[s.mimeType]=c;const u=(f,m)=>Object.fromEntries([...new Set([...Object.keys(m),...Object.keys(f)])].map(_=>[_,m[_]??f[_]]));return i.reverse().forEach(f=>{switch(f){case"container":r&&(s=u(s,zt(r)));break;case"video":if(n){const[m]=n;s=u(s,Yt(m))}break;case"audio":if(o){const[m]=o;s=u(s,xt(m))}break;case"binary":if(a){const[m]=a;s=u(s,Gt(m))}break}}),s},P={PDF:"PDF",TEXT:"TEXT",MSWORD:"MSWORD",JSON:"JSON",XML:"XML"},R={IMAGE:"IMAGE",AUDIO:"AUDIO",VIDEO:"VIDEO",DOCUMENT:"DOCUMENT",BINARY:"BINARY"},qe=(e={})=>{const{mimeType:t}=e,s=Array.isArray(t)?t[0]:t;if(s){if(s.endsWith("/pdf"))return P.PDF;if(s.startsWith("text/"))return P.TEXT;if(s.endsWith("/msword"))return P.MSWORD;if(s.endsWith("/json"))return P.JSON;if(s.endsWith("/xml"))return P.XML}},Je=["image/apng","image/bmp","image/gif","image/jpeg","image/x-icon","image/png","image/svg+xml"],Xe=["video/mp4"],Qe=["audio/mp4","audio/mpeg","audio/x-aac","audio/aac","audio/x-wav","audio/wav","audio/accp","audio/ogg","audio/webm","audio/x-flac"],Ze=[...Xe,...Je,...Qe],ts=["http","https"],es="video/mp4",ss="video/quicktime",rs="video/x-m4v",is="MPEG-4",ns="mov",as="h264",H=["__mp4","__mp3_160k","__png","__jpeg","__gif","original"].reverse(),Ht=({parsedShape:{tag:e}},{parsedShape:{tag:t}})=>H.includes(e)||H.includes(t)?H.indexOf(t)-H.indexOf(e):e.toLowerCase().localeCompare(t.toLowerCase()),os=(e,t)=>{const{allowedMimeTypes:s=Ze,allowedMethods:i=ts,sortPriority:r=Ht,sourceKey:n="src",mimeTypeKey:o="type",shapeKey:a="shape",parsedShapeKey:c="parsedShape"}=t||{},{shape:l=[]}=e||{},u=l.reduce((f,m)=>{let _,d;const h=Y(m),{uri:g,mimeType:A,containerFormat:I,videoCodec:b}=h;if(A&&(_=A,(A===ss||A===rs)&&(I===is||I===ns)&&b===as&&(_=es)),g)if(i){const[O]=g.split("://");i.includes(O)&&(d=g)}else d=g;return d&&s.includes(_)&&f.push({[n]:d,[o]:_,[a]:m,[c]:h}),f},[]);return typeof r=="function"&&u.sort(Ht),u},cs=e=>{const t=Y(e),{mimeType:s,videoCodec:i,audioCodec:r}=t;if(s){if(s.startsWith("audio/")&&r!==void 0)return R.AUDIO;if(s.startsWith("video/")){if(i!==void 0)return R.VIDEO;if(r!==void 0)return R.AUDIO}if(s.startsWith("image/"))return R.IMAGE;if(s.endsWith("/pdf")||s.startsWith("text/")||s.endsWith("/msword")||s.endsWith("/json")||s.endsWith("/xml"))return R.DOCUMENT;if(s.endsWith("/octet-stream"))return R.BINARY}},Kt="video/mp4",qt="video/quicktime",Jt="video/x-m4v",us="MPEG-4",ds="mov",ls="h264",fs=[Kt,qt,Jt],Xt=["video/x-mxf-h264","video/x-mxf-h264-aac","video/x-mxf-h264-pcm_s24le","video/x-mxf-mpeg2video-pcm_s24le","video/x-mxf-mpeg2video-pcm_s16le","video/x-mxf-prores-pcm_s16le","video/x-mxf-h264-pcm_s16le"],ms=[...fs,...Xt],hs=["audio/mp4","audio/mpeg","audio/x-aac","audio/aac","audio/x-wav","audio/wav","audio/accp","audio/ogg","audio/webm","audio/x-flac"],ps=[...ms,...hs],_s=["http","https"],Ts=({streamingServers:e,url:t,ending:s})=>se(e[0],window.btoa(t),`.${s}`),Es=(e,t)=>{const{allowedMimeTypes:s=ps,allowedMethods:i=_s,streamingServers:r=[]}=t||{},{shape:n=[]}=e||{},{startTimeCode:o}=Ct(e==null?void 0:e.metadata,{flat:!0,arrayOnSingleValue:!1});return n.reduce((c,l)=>{var N,j,k;let u,f,m;const _=Y(l),{uri:d,mimeType:h,containerFormat:g,videoCodec:A}=_;if(!(s!=null&&s.includes(h))||!(i!=null&&i.includes((N=d==null?void 0:d.split("://"))==null?void 0:N[0])))return c;if(m=_.tag,!m){const M=(k=(j=h==null?void 0:h.split)==null?void 0:j.call(h,"/"))==null?void 0:k.pop(),U=c.filter(q=>q.label===M).length;U===0?m=M:m=M+(U+1)}const{timeBase:I,startTimecode:b}=_,O=o??b,S=O&&B(O);return f=d,u=h,(h===qt||h===Jt)&&(g===us||g===ds)&&A===ls&&(u=Kt),r!=null&&r.length&&Xt.includes(h)&&(f=Ts({url:d,streamingServers:r,ending:"mpd"}),u="application/dash+xml"),f&&c.push({src:f,...u?{type:u}:{},...m?{label:m}:{},...I?{timeBase:I}:{},...S?{startTimeCode:S}:{}}),c},[])},Qt=e=>{const t={},{outputSetting:s=[]}=e||{};if(s.length===0)return t;const i=JSON.parse(s[0]),{Settings:{ContainerSettings:r,VideoDescription:n,AudioDescriptions:o}={}}=i;if(r&&(t.containerFormat=r.Container),n){const{CodecSettings:a={}}=n,{Codec:c,...l}=a;t.videoFormat=c;const{Height:u,Width:f}=n;t.height=u,t.width=f,u&&f&&(t.dimension=`${f}x${u}`,t.aspectRatio=J({height:u,width:f}));const[m]=Object.values(l);if(m){t.fieldOrder=m.InterlaceMode,t.fieldOrder&&t.fieldOrder.includes("TOP")&&(t.fieldOrder="interlaced"),t.videoBitrate=m.Bitrate;const _=m.FramerateDenominator,d=m.FramerateNumerator,h=w({denominator:d,numerator:_});t.timeBase=h,t.frameRate=h.toConstant()||h.toRate()}}if(o&&o.length>0){const{CodecSettings:a={}}=o[0],{Codec:c,...l}=a;t.audioFormat=c;const[u]=Object.values(l);u&&(t.audioSamplerate=u.SampleRate,t.audioBitrate=u.Bitrate,t.audioBitRateMode=u.RateControlMode)}return t},gs=e=>{const t={},{description:s,format:i,audio:r,video:n,mediaconvert:o}=e||{};if(o)return{description:s,...Qt(o)};if(t.description=s,t.containerFormat=i,n){if(t.videoFormat=n.codec,t.videoBitrate=n.bitrate,n.framerate){const a=w(n.framerate);t.timeBase=a,t.frameRate=a.toConstant()||a.toRate()}if(n.scaling){const{height:a,width:c}=n.scaling;t.height=a,t.width=c,a&&c&&(t.dimension=`${c}x${a}`,t.aspectRatio=J({height:a,width:c}))}}if(r){const{codec:a,channel:c}=r;t.audioFormat=a,c&&(t.audioChannels=c.length)}return t},As=e=>{if(!e)return;const{name:t,type:s,defaultValue:i,stringRestriction:r,floatRestriction:n,integerRestriction:o,longRestriction:a,data:c,values:l,system:u}=e,{minLength:f,maxLength:m,pattern:_}=r||{},{minInclusive:d,maxInclusive:h}=n||o||a||{},g=((l==null?void 0:l.field)||[]).map(({key:O,value:S})=>({label:S??O,value:O})),I=(O=>Object.fromEntries(Object.entries(O).filter(([,S])=>S!==void 0)))({min:d,max:h,minLength:f,maxLength:m,pattern:_?new RegExp(_):void 0}),b=D(c);return{name:t,type:s,defaultValue:i,required:d!==void 0||f!==void 0&&f>0,restrictions:I,data:b,options:g,system:u!==void 0?u==="true":void 0}},Is=e=>e==null?void 0:e.map(As).filter(t=>!!t),Os=["date","float","integer","long","string","string-exact","boolean","timeCode"];class K{constructor(){this.events={}}on(t,s){const i=this.events[t]||[];i.push(s),this.events[t]=i}off(t){this.events[t]&&(this.events[t]=[])}trigger(t,s,i){const r=this.events[t];!r||r.length<1||r.forEach(n=>{n(s,i)})}}var T=(e=>(e[e.transferring=1]="transferring",e[e.paused=2]="paused",e[e.complete=3]="complete",e[e.failed=4]="failed",e[e.idle=5]="idle",e[e.canceled=6]="canceled",e[e.offline=7]="offline",e))(T||{}),E=(e=>(e.progress="progress",e.update="update",e.complete="complete",e.error="error",e.added="upload-added",e.removed="upload-removed",e.failed="upload-failed",e.retry="retry",e.pausing="pausing",e.paused="paused",e.resuming="resuming",e.offline="offline",e.online="online",e))(E||{});class Zt{constructor(t={}){this.blobSlice=(t==null?void 0:t.blobSlice)??null,this.fileSize=(t==null?void 0:t.fileSize)??null,this.start=(t==null?void 0:t.start)??null,this.end=(t==null?void 0:t.end)??null,this.api=(t==null?void 0:t.api)??null,this.state={retries:0,status:T.idle,startTime:null,completeTime:null,response:null,bytesTransferred:null},this.eventBus=new K}tryTransfer(){return this.state.status=T.transferring,this.state.startTime=performance.now(),new Promise((t,s)=>{const i=()=>{this.transfer().then(r=>{this.state.response=r,this.onComplete(),t(this)}).catch(()=>{this.state.retries>3?(this.state.status=T.failed,s(new Error(`Chunk ${this.start}-${this.end} failed`))):this.state.status!==T.paused?(this.state.retries+=1,this.tryTimeout=setTimeout(()=>{i()},1e3)):clearTimeout(this.tryTimeout)})};i(),window.addEventListener(E.online,()=>{this.resume()}),window.addEventListener(E.offline,()=>{this.pause()})})}transfer(){let t={file:this.blobSlice,onUploadProgress:s=>{[T.complete,T.offline].includes(this.state.status)||(this.state.bytesTransferred=s==null?void 0:s.loaded,this.eventBus.trigger(E.progress,this.state))}};return t={...t,...this.api.props||{}},this.end-this.start!==this.fileSize&&(t.headers={index:this.start,size:this.fileSize,...t.headers||{}}),this.transferPromise=this.api.method(t),this.state.status=T.transferring,this.transferPromise}pause(){this.state.status!==T.complete&&(this.state.status=T.paused)}resume(){this.state.status!==T.complete&&(this.state.status=T.transferring)}cancel(){this.state.status!==T.complete&&(this.state.status=T.canceled)}get transferRate(){if(this.state.bytesTransferred){const t=(this.state.completeTime-this.state.startTime)/1e3;return this.state.bytesTransferred/t}return 0}onComplete(){this.state.status=T.complete,this.state.bytesTransferred=this.end-this.start,this.state.completeTime=performance.now(),this.eventBus.trigger(E.complete,this.state)}}class dt{constructor(t,s){var i,r,n,o,a,c;if(this.DEFAULT_OPTIONS=Object.freeze({targetRate:4e6,chunkSize:8388608,minChunkSize:8388608,maxConcurrentTransfers:1,maxConcurrentFileTransfers:1,autoMaxConcurrentTransfers:!1,minFileSize:104857600,autoResume:!0,api:void 0}),this.eventBus=new K,!s.api.method)throw new Error("No api method specified");this.options={...this.DEFAULT_OPTIONS,...s,api:{...s.api??{},props:{...((i=s.api)==null?void 0:i.props)??{},queryParams:{transferId:ne(),...((n=(r=s.api)==null?void 0:r.props)==null?void 0:n.queryParams)??{}}}}},this.state={blob:null,chunks:[],transferPromises:[],targetRate:this.options.targetRate,rate:0,autoMaxConcurrentTransfers:this.options.autoMaxConcurrentTransfers,maxConcurrentTransfers:this.options.maxConcurrentTransfers,mime:"",status:T.idle,transferId:(c=(a=(o=s.api)==null?void 0:o.props)==null?void 0:a.queryParams)==null?void 0:c.transferId,lastStats:{}},typeof t=="object"?(this.state.blob=t,this.state.mime=t.type,this.addChunksFromBlob(t)):console.error(new Error(`Expected a File or a Blob object, but got ${typeof t}`))}upload(){const{status:t}=this.state;if(t!==T.complete)if(t===T.idle||t===T.transferring){const s=this.state.chunks.length;let i=0;const r=()=>{for(;this.state.transferPromises.length<this.state.maxConcurrentTransfers&&i<s;){const n=this.state.chunks[i];if(i+=1,n.state.status!==T.complete&&n.state.status!==T.transferring){this.state.status=T.transferring;const o=n.tryTransfer();this.state.transferPromises.push(o),o.then(()=>{const a=this.state.transferPromises.indexOf(o);a!==-1&&this.state.transferPromises.splice(a,1),this.state.status!==T.canceled&&r()}).catch(a=>{const c=this.state.transferPromises.indexOf(o);c!==-1&&this.state.transferPromises.splice(c,1),console.error("Failed on this upload(), check connectivity and try to resume",a),this.state.status!==T.offline?(this.state.status=T.failed,this.eventBus.trigger(E.failed,this.state,a),this.options.onFail&&this.options.onFail(a)):setTimeout(()=>this.retry(),5e3)})}}};r()}else this.retry()}getByteRangesForChunks(t,s=this.options.chunkSize){const i=[],{minChunkSize:r}=this.options;let o=s>=r?s:r,a=Math.floor(t.size/o);if(t.size-(t.size-t.size/a)>=r||(a-=1,o=Math.floor(t.size/a)),a<2||t.size<this.options.minFileSize)i.push({start:0,end:t.size});else for(let c=0;c<=a;c+=1){const l=o*c;let u=o*c+o;t.size-o*c<=r&&(u=t.size);const m={start:l,end:u};if(i.push(m),u===t.size)break}return i}addChunksFromBlob(t){this.getByteRangesForChunks(t).forEach(i=>{const r=new Zt({start:i.start,end:i.end,blobSlice:t.slice(i.start,i.end),fileSize:t.size,api:this.options.api});r.eventBus.on(E.progress,()=>{this.onProgress()}),r.eventBus.on(E.complete,()=>{this.onProgress()}),this.state.chunks.push(r)})}retry(){this.state.status===T.failed&&(this.resume(),this.eventBus.trigger(E.retry,this.state))}resume(){this.state.status=T.transferring,this.eventBus.trigger(E.resuming,this.state),this.state.chunks.length>0&&this.state.chunks.forEach(t=>{t.resume()})}pause(){this.state.status=T.paused,this.state.chunks.length>0&&this.state.chunks.forEach(s=>{s.pause()});const t=Promise.all(this.state.transferPromises);return this.eventBus.trigger(E.pausing,this.state),t.then(()=>{this.eventBus.trigger(E.paused,this.state)}),Promise.all(this.state.transferPromises)}cancel(){this.state.status=T.canceled,this.state.chunks.length>0&&this.state.chunks.forEach(s=>{s.cancel()});const t=Promise.all(this.state.transferPromises);return t.then(()=>{this.eventBus.trigger(E.removed,this.state)}),t}autoAdjustMaxConcurrentTransfers(t){if(this.state.autoMaxConcurrentTransfers&&this.state.status!==T.complete){const s=t.avgTransferRate/this.state.targetRate;if(s>1.2)this.state.maxConcurrentTransfers+=1;else if(s<.3)this.state.maxConcurrentTransfers=1;else{const i=this.options.maxConcurrentTransfers-1;this.state.maxConcurrentTransfers=Math.max(this.options.maxConcurrentTransfers,Math.min(i,this.options.maxConcurrentTransfers))}}}onProgress(){try{const t=this.getStats();t!==this.state.lastStats&&(this.state.lastStats=t,ie(()=>{this.autoAdjustMaxConcurrentTransfers(t)},1e3,!1)({}),this.state.status!==T.complete&&(t.totalChunks===t.completedChunks?this.onComplete():(this.eventBus.trigger(E.progress,this.state),this.options.onProgress&&this.options.onProgress(t))))}catch(t){console.error(t)}}onComplete(){const t=this.getStats();this.state.lastStats=t,this.state.status=T.complete,this.eventBus.trigger(E.complete,this.state),this.options.onComplete&&this.options.onComplete(this.finalResponse)}getStats(){const t=this.state.chunks.length,s=this.state.chunks.filter(l=>l.state.status===T.complete),i=this.state.chunks.filter(l=>l.state.status===T.transferring),r=s.length;let n=0,o=0;s.forEach(l=>{n+=l.transferRate,o+=l.blobSlice.size}),i.forEach(l=>{o+=l.state.bytesTransferred});const a=n/r,c={totalChunks:t,completedChunks:r,totalBytes:this.state.blob.size,transferredBytes:o,avgTransferRate:a,concurrentTransfers:this.state.maxConcurrentTransfers};return this.state.rate=c.avgTransferRate,c}set concurrentTransfers(t){this.state.autoMaxConcurrentTransfers=!1,this.state.maxConcurrentTransfers=t}set rate(t){this.state.targetRate=t}get rate(){return this.state.rate}get finalResponse(){const t=this.state.chunks.length-1,s=!1;for(let i=t;i>=0;i-=1){const r=this.state.chunks[i];if(typeof r.state.response.data=="object")return r.state.response}return s}get transferId(){return this.state.transferId}}function bs(e,t){return e===0||t===0?0:Math.floor(e/t*100)}const Ss={maxConcurrentFileTransfers:1,autoResume:!0};class ys{constructor(t){this.initialState=Object.freeze({status:T.idle,transfers:[],bytesDone:0,bytesTotal:0,lastStats:{bytesDone:0,bytesTotal:0}}),this.state={...this.initialState},this.options={...Ss,...t},this.events=new K,this.bindNetworkEvents()}get transfers(){return Object.values(this.state.transfers)||[]}get status(){return this.state.status}set status(t){this.events.trigger(E.update,this.state),this.state.status=t}get bytesTotal(){let t=0;return this.transfers.forEach(s=>{t+=s.state.blob.size}),t}get bytesDone(){let t=0;return this.transfers.forEach(s=>{t+=s.getStats().transferredBytes}),t}get isUploading(){return this.state.status===T.transferring}get paused(){let t=!0;return this.transfers.forEach(s=>{s.state.status!==T.paused&&(t=!1)}),t}bindNetworkEvents(){typeof window>"u"||(window.addEventListener(E.online,()=>{this.events.trigger(E.online,this.state),this.state.status=T.transferring,this.options.autoResume&&setTimeout(()=>{this.retry()},1500)}),window.addEventListener(E.offline,()=>{this.events.trigger(E.offline,this.state),this.state.status=T.offline}))}addChunkedUpload(t){t.transferId!==null&&(this.state.transfers[t.transferId]=t,t.eventBus.on(E.progress,()=>{this.onProgress()}),t.eventBus.on(E.complete,()=>{this.upload(),this.onProgress()}),t.eventBus.on(E.failed,(s,i)=>{this.onFail(i,s)}),t.eventBus.on(E.retry,()=>{this.events.trigger(E.retry,this.state)}),t.eventBus.on(E.paused,()=>{this.paused&&this.events.trigger(E.paused,this.state)}),this.updateStats(),this.events.trigger(E.added,this.state),this.events.trigger(E.update,this.state))}removeChunkedUpload(t,s=!1){const i=r=>r?r.state.status===T.complete&&!s?(console.error("Can't cancel complete transfers, pass true as a second argument in .removeChunkedUpload() to force removal."),!1):(Object.keys(this.state.transfers).forEach(n=>{r===this.state.transfers[n]&&delete this.state.transfers[n]}),this.events.trigger(E.removed,this.state),r.cancel(),!0):(console.error("Could not find a matching transfer to cancel."),!1);t instanceof dt?i(t):t instanceof File?i(this.exists(t)):typeof t=="string"?i(this.transfers.find(r=>r.transferId===t)):console.error("Invalid object to remove - has to be either ChunkedUpload, File or transferId")}onProgress(){this.updateStats(),this.hasCompleted?this.onComplete():this.state.bytesDone!==this.state.lastStats.bytesDone&&(this.state.status=T.transferring,this.events.trigger(E.progress,this.state))}onComplete(){this.state.status=T.complete,this.events.trigger(E.complete,this.state)}exists(t){let s;for(let i=0;i<this.transfers.length;i+=1){const r=this.transfers[i];if(r.state.blob.name===t.name&&r.state.blob.lastModified===t.lastModified&&r.state.blob.size&&t.size)return s=r,s}return s}isTransferAvailable(t){return t.state.status!==T.complete&&t.state.status!==T.transferring||t.state.status===T.idle}pause(){let t=Promise.resolve(!0);if(!this.paused){this.events.trigger(E.pausing,this.state);const s=[];this.transfers.forEach(i=>{s.push(i.pause())}),t=Promise.all(s),t.then(()=>{this.events.trigger(E.paused,this.state)})}return t}resume(){this.events.trigger(E.update,this.state),this.transfers.forEach(t=>{this.isTransferAvailable(t)&&t.state.status!==T.idle&&t.resume()})}retry(){this.status===T.failed&&(this.resume(),this.events.trigger(E.retry,this.state))}upload(){let t=0;this.transfers.forEach(s=>{this.isTransferAvailable(s)?t<this.options.maxConcurrentFileTransfers&&(this.events.trigger(E.update,this.state),s.upload(),t+=1):s.state.status!==T.complete&&(t+=1)}),t>0&&(this.status=T.transferring),t<this.options.maxConcurrentFileTransfers&&this.transfers.length<t&&this.upload()}onFail(t,s){this.status=T.failed,this.events.trigger(E.error,s,t)}reset(){this.transfers.forEach(t=>{t.constructor.name===dt.name&&this.removeChunkedUpload(t,!0)}),this.state={...this.initialState},this.events.trigger(E.update,this.state),this.events.trigger(E.complete,this.state)}destroy(){this.reset()}get hasCompleted(){let t=!0;return this.transfers.forEach(s=>{s.state.status!==T.complete&&(t=!1)}),t}updateStats(){this.state.lastStats.bytesDone=this.state.bytesDone,this.state.lastStats.bytesTotal=this.state.bytesTotal,this.state.bytesTotal=this.bytesTotal,this.state.bytesDone=this.bytesDone}get percentDone(){return bs(this.state.bytesDone,this.state.bytesTotal)}get fileList(){const t=[];return this.transfers.forEach(s=>{const i=s.getStats(),{totalChunks:r,completedChunks:n}=i,o={name:s.state.blob.name,bytesDone:i.transferredBytes,bytesTotal:s.state.blob.size,totalChunks:r,completedChunks:n,transfer:s};t.push(o)}),t}}const te=(e,t,s="")=>{const i=a=>{const c=a.startsWith("/")?a.slice(1):a,l=(c==null?void 0:c.search("/"))??-1;return l===-1?[c]:[c.slice(0,l),c.slice(l+1)]},[r,n]=i(t),o=[s,r].filter(Boolean).join("/");return n?{[r]:{file:new File([e],r,{...e,type:"folder"}),path:o,progress:{totalBytes:e.size??0,transferredBytes:0},files:te(e,n,o)}}:{[r]:{file:e,path:o,progress:{totalBytes:e.size??0,transferredBytes:0}}}},Rs=e=>e.map(t=>te(t,t.path??t.webkitRelativePath)).reduce((t,s)=>re(t,s),{});p.Chunk=Zt,p.ChunkedTransferManager=ys,p.ChunkedUpload=dt,p.ChunkedUploadEventBus=K,p.DOCUMENT_TYPES=P,p.EVENTS=E,p.FIELD_ATTRIBUTE_KEYS=ht,p.FIELD_DEFINITION_TYPES=Os,p.FIELD_VALUE_ATTRIBUTE_KEYS=mt,p.FILE_STATES=Ke,p.GROUP_ATTRIBUTE_KEYS=pt,p.ROLE_NAMES=ae,p.SHAPE_MEDIA_TYPES=R,p.STATUSES=T,p.SYSTEM_FIELDGROUPS=oe,p.SYSTEM_FIELDS=ce,p.TimeBase=y,p.TimeCode=F,p.createMetadataType=pe,p.createSearchFacetList=Pe,p.createTimeBase=W,p.createTimeCode=B,p.fileListToFileTree=Rs,p.filterShapeSource=os,p.findNearestThumbnail=$t,p.formatTimeBaseText=G,p.formatTimeBaseType=w,p.formatTimeCodeSeconds=Pt,p.formatTimeCodeSmpte=jt,p.formatTimeCodeText=$,p.formatTimeCodeType=L,p.getPlayerSources=Es,p.getShapeDocumentType=qe,p.getShapeMediaType=cs,p.metadataTypeToWebVtt=Le,p.parseAudioComponent=xt,p.parseBinaryComponent=Gt,p.parseContainerComponent=zt,p.parseFacetList=je,p.parseFacetType=ke,p.parseFieldDefinitionList=Is,p.parseFieldList=tt,p.parseFileType=ut,p.parseGroupList=st,p.parseHighlightTimespan=z,p.parseHighlightTimespanList=$e,p.parseKeyValuePairType=D,p.parseMediaConvertPreset=Qt,p.parseMetadataType=Ct,p.parseNowDate=ze,p.parseSearchResultEvents=Ge,p.parseShapeType=Y,p.parseSimpleMetadataType=be,p.parseTimespan=Mt,p.parseTimespanList=it,p.parseTranscodePreset=gs,p.parseVideoComponent=Yt,Object.defineProperty(p,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vidispine/vdt-js",
3
- "version": "26.1.0-pre.5",
3
+ "version": "26.1.0-pre.6",
4
4
  "license": "SEE LICENSE IN LICENSE.md",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -38,18 +38,18 @@
38
38
  "format": "prettier . --check"
39
39
  },
40
40
  "dependencies": {
41
- "@vidispine/types": "26.1.0-pre.5",
41
+ "@vidispine/types": "26.1.0-pre.6",
42
42
  "filesize": "10.1.0",
43
43
  "lodash.merge": "4.6.2",
44
44
  "url-join": "5.0.0"
45
45
  },
46
46
  "devDependencies": {
47
- "@vidispine/eslint-config-base": "26.1.0-pre.5",
48
- "@vidispine/eslint-config-mdx": "26.1.0-pre.5",
49
- "@vidispine/eslint-config-storybook": "26.1.0-pre.5",
50
- "@vidispine/tests": "26.1.0-pre.5",
51
- "@vidispine/types": "26.1.0-pre.5",
52
- "@vidispine/vdt-storybook": "26.1.0-pre.5",
47
+ "@vidispine/eslint-config-base": "26.1.0-pre.6",
48
+ "@vidispine/eslint-config-mdx": "26.1.0-pre.6",
49
+ "@vidispine/eslint-config-storybook": "26.1.0-pre.6",
50
+ "@vidispine/tests": "26.1.0-pre.6",
51
+ "@vidispine/types": "26.1.0-pre.6",
52
+ "@vidispine/vdt-storybook": "26.1.0-pre.6",
53
53
  "eslint": "8.55.0",
54
54
  "eslint-plugin-testing-library": "6.2.0",
55
55
  "prettier": "3.1.1",