@vidispine/vdt-js 24.1.0-pre.1 → 24.2.0-pre.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +35 -34
- package/dist/index.umd.cjs +2 -2
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -544,7 +544,7 @@ function ce(e, t) {
|
|
|
544
544
|
...oe,
|
|
545
545
|
...t || {}
|
|
546
546
|
}, { includeMetadataAttributes: n, flat: r } = s, { timespan: i = [], ...o } = e || {}, a = Object.fromEntries(
|
|
547
|
-
Object.entries(
|
|
547
|
+
Object.entries(s).map(([u, f]) => {
|
|
548
548
|
if (Object.keys(Z).includes(u))
|
|
549
549
|
return ["onlyGeneric", "overrideGroup", "overrideField"].includes(u) && (f !== void 0 ? f : r === !0) ? [u, !0] : [u, f];
|
|
550
550
|
}).filter((u) => !!u)
|
|
@@ -671,16 +671,17 @@ class R {
|
|
|
671
671
|
}
|
|
672
672
|
}
|
|
673
673
|
const et = (e) => {
|
|
674
|
+
var t;
|
|
674
675
|
if (e === void 0)
|
|
675
676
|
return new R();
|
|
677
|
+
if (ot.includes((t = e == null ? void 0 : e.toString) == null ? void 0 : t.call(e)))
|
|
678
|
+
return new R(tt[e]);
|
|
676
679
|
if (typeof e == "number")
|
|
677
680
|
return new R({ denominator: e });
|
|
678
681
|
if (typeof e == "string" && e.includes(":")) {
|
|
679
|
-
const [
|
|
680
|
-
return new R({ denominator:
|
|
682
|
+
const [s, n] = e.split(":");
|
|
683
|
+
return new R({ denominator: s, numerator: n });
|
|
681
684
|
}
|
|
682
|
-
if (ot.includes(e))
|
|
683
|
-
return new R(tt[e]);
|
|
684
685
|
if (!["string", "number"].includes(typeof e) || Number.isNaN(Number(e)))
|
|
685
686
|
throw new Error(
|
|
686
687
|
`timeBaseText must be a number or ${ot.join(",")} - is ${JSON.stringify(
|
|
@@ -688,7 +689,7 @@ const et = (e) => {
|
|
|
688
689
|
)}`
|
|
689
690
|
);
|
|
690
691
|
return new R({ denominator: Number(e) });
|
|
691
|
-
},
|
|
692
|
+
}, x = (e) => new R(e), $ = (e) => e instanceof R ? e : typeof e == "string" || typeof e == "number" ? et(e) : x(e), st = (e) => {
|
|
692
693
|
const t = e.toConstant();
|
|
693
694
|
return t === "59.94" && 4 || ["NTSC", "29.97"].includes(t) && 2 || void 0;
|
|
694
695
|
}, wt = (e) => st(e) > 0, ut = (e) => {
|
|
@@ -1130,11 +1131,11 @@ const ue = (e, t) => {
|
|
|
1130
1131
|
}, Te = {
|
|
1131
1132
|
dropFrame: void 0,
|
|
1132
1133
|
frameSeparator: void 0
|
|
1133
|
-
},
|
|
1134
|
+
}, L = (e, t) => new S(e, { ...Te, ...t }), ge = (e) => !!e.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/), Ee = (e) => !Number.isNaN(Number(e)), j = (e, t) => {
|
|
1134
1135
|
if (e instanceof S)
|
|
1135
1136
|
return e;
|
|
1136
1137
|
if (typeof e != "string" && typeof e != "number")
|
|
1137
|
-
return
|
|
1138
|
+
return L(e, t);
|
|
1138
1139
|
if (typeof e == "string" && ge(e))
|
|
1139
1140
|
return pe(e, t);
|
|
1140
1141
|
if (["string", "number"].includes(typeof e) && Ee(e))
|
|
@@ -1415,7 +1416,7 @@ ${o.join(`
|
|
|
1415
1416
|
ARCHIVED: "ARCHIVED",
|
|
1416
1417
|
/** File will be synchronized by multi-site agent. */
|
|
1417
1418
|
AWAITING_SYNC: "AWAITING_SYNC"
|
|
1418
|
-
},
|
|
1419
|
+
}, Pt = (e) => {
|
|
1419
1420
|
const {
|
|
1420
1421
|
uri: t = [],
|
|
1421
1422
|
size: s,
|
|
@@ -1439,7 +1440,7 @@ ${o.join(`
|
|
|
1439
1440
|
const { file: t, mediaInfo: s, metadata: n = [] } = e, r = F(n), i = z(s);
|
|
1440
1441
|
let o = { binaryMetadata: r, binaryMediaInfo: i };
|
|
1441
1442
|
if (t) {
|
|
1442
|
-
const [a] = t, c =
|
|
1443
|
+
const [a] = t, c = Pt(a);
|
|
1443
1444
|
o = {
|
|
1444
1445
|
...o,
|
|
1445
1446
|
...c
|
|
@@ -1475,14 +1476,14 @@ ${o.join(`
|
|
|
1475
1476
|
containerMediaInfo: d
|
|
1476
1477
|
};
|
|
1477
1478
|
if (c.componentOriginalFilename && (l.originalFilename = c.componentOriginalFilename), r !== void 0 && r.samples !== 0) {
|
|
1478
|
-
const h =
|
|
1479
|
+
const h = L(r);
|
|
1479
1480
|
l.durationTimeCode = h.toObject(), l.duration = h.toDuration();
|
|
1480
1481
|
}
|
|
1481
|
-
if (i && (l.startTimestamp =
|
|
1482
|
+
if (i && (l.startTimestamp = L(i).toObject()), o !== void 0 && a && (l.startTimecode = L({
|
|
1482
1483
|
samples: o,
|
|
1483
1484
|
timeBase: a
|
|
1484
1485
|
})), n) {
|
|
1485
|
-
const [h] = n, g =
|
|
1486
|
+
const [h] = n, g = Pt(h);
|
|
1486
1487
|
l = {
|
|
1487
1488
|
...l,
|
|
1488
1489
|
...g
|
|
@@ -1507,10 +1508,10 @@ ${o.join(`
|
|
|
1507
1508
|
} = a;
|
|
1508
1509
|
let l;
|
|
1509
1510
|
const { averageFrameRate: h, realBaseFrameRate: g } = e;
|
|
1510
|
-
g !== void 0 ? l =
|
|
1511
|
+
g !== void 0 ? l = x({
|
|
1511
1512
|
numerator: g.denominator,
|
|
1512
1513
|
denominator: g.numerator
|
|
1513
|
-
}) : u !== void 0 ? l = et(u) : h !== void 0 && (l =
|
|
1514
|
+
}) : u !== void 0 ? l = et(u) : h !== void 0 && (l = x({
|
|
1514
1515
|
numerator: h.denominator,
|
|
1515
1516
|
denominator: h.numerator
|
|
1516
1517
|
}));
|
|
@@ -1520,7 +1521,7 @@ ${o.join(`
|
|
|
1520
1521
|
it !== void 0 && (E = it.toString());
|
|
1521
1522
|
}
|
|
1522
1523
|
let A, O, I;
|
|
1523
|
-
E && l && (A =
|
|
1524
|
+
E && l && (A = L({ samples: E, timeBase: l }), O = A.timeBase.toConstant() || A.timeBase.toRate(), I = A.toSmpte());
|
|
1524
1525
|
const { height: b, width: M } = r || {}, N = J(r), C = `${M}x${b}`;
|
|
1525
1526
|
let v, B;
|
|
1526
1527
|
return s !== void 0 && (v = w(s, { round: 2, symbols: ft }), B = Number(
|
|
@@ -1599,7 +1600,7 @@ ${o.join(`
|
|
|
1599
1600
|
break;
|
|
1600
1601
|
}
|
|
1601
1602
|
}), s;
|
|
1602
|
-
},
|
|
1603
|
+
}, P = {
|
|
1603
1604
|
PDF: "PDF",
|
|
1604
1605
|
TEXT: "TEXT",
|
|
1605
1606
|
MSWORD: "MSWORD",
|
|
@@ -1615,15 +1616,15 @@ ${o.join(`
|
|
|
1615
1616
|
const { mimeType: t } = e, s = Array.isArray(t) ? t[0] : t;
|
|
1616
1617
|
if (s) {
|
|
1617
1618
|
if (s.endsWith("/pdf"))
|
|
1618
|
-
return
|
|
1619
|
+
return P.PDF;
|
|
1619
1620
|
if (s.startsWith("text/"))
|
|
1620
|
-
return
|
|
1621
|
+
return P.TEXT;
|
|
1621
1622
|
if (s.endsWith("/msword"))
|
|
1622
|
-
return
|
|
1623
|
+
return P.MSWORD;
|
|
1623
1624
|
if (s.endsWith("/json"))
|
|
1624
|
-
return
|
|
1625
|
+
return P.JSON;
|
|
1625
1626
|
if (s.endsWith("/xml"))
|
|
1626
|
-
return
|
|
1627
|
+
return P.XML;
|
|
1627
1628
|
}
|
|
1628
1629
|
}, we = [
|
|
1629
1630
|
"image/apng",
|
|
@@ -1633,7 +1634,7 @@ ${o.join(`
|
|
|
1633
1634
|
"image/x-icon",
|
|
1634
1635
|
"image/png",
|
|
1635
1636
|
"image/svg+xml"
|
|
1636
|
-
], Be = ["video/mp4"],
|
|
1637
|
+
], Be = ["video/mp4"], Pe = [
|
|
1637
1638
|
"audio/mp4",
|
|
1638
1639
|
"audio/mpeg",
|
|
1639
1640
|
"audio/x-aac",
|
|
@@ -1644,7 +1645,7 @@ ${o.join(`
|
|
|
1644
1645
|
"audio/ogg",
|
|
1645
1646
|
"audio/webm",
|
|
1646
1647
|
"audio/x-flac"
|
|
1647
|
-
],
|
|
1648
|
+
], Le = [...Be, ...we, ...Pe], xe = ["http", "https"], je = "video/mp4", ke = "video/quicktime", We = "video/x-m4v", $e = "MPEG-4", Ue = "mov", Ge = "h264", W = [
|
|
1648
1649
|
"__mp4",
|
|
1649
1650
|
"__mp3_160k",
|
|
1650
1651
|
"__png",
|
|
@@ -1653,8 +1654,8 @@ ${o.join(`
|
|
|
1653
1654
|
"original"
|
|
1654
1655
|
].reverse(), mt = ({ parsedShape: { tag: e } }, { parsedShape: { tag: t } }) => W.includes(e) || W.includes(t) ? W.indexOf(t) - W.indexOf(e) : e.toLowerCase().localeCompare(t.toLowerCase()), Is = (e, t) => {
|
|
1655
1656
|
const {
|
|
1656
|
-
allowedMimeTypes: s =
|
|
1657
|
-
allowedMethods: n =
|
|
1657
|
+
allowedMimeTypes: s = Le,
|
|
1658
|
+
allowedMethods: n = xe,
|
|
1658
1659
|
sortPriority: r = mt,
|
|
1659
1660
|
sourceKey: i = "src",
|
|
1660
1661
|
mimeTypeKey: o = "type",
|
|
@@ -1695,7 +1696,7 @@ ${o.join(`
|
|
|
1695
1696
|
if (s.endsWith("/octet-stream"))
|
|
1696
1697
|
return y.BINARY;
|
|
1697
1698
|
}
|
|
1698
|
-
},
|
|
1699
|
+
}, Lt = "video/mp4", xt = "video/quicktime", jt = "video/x-m4v", ze = "MPEG-4", Ve = "mov", He = "h264", Ye = [Lt, xt, jt], kt = [
|
|
1699
1700
|
"video/x-mxf-h264",
|
|
1700
1701
|
"video/x-mxf-h264-aac",
|
|
1701
1702
|
"video/x-mxf-h264-pcm_s24le",
|
|
@@ -1738,7 +1739,7 @@ ${o.join(`
|
|
|
1738
1739
|
B === 0 ? m = v : m = v + (B + 1);
|
|
1739
1740
|
}
|
|
1740
1741
|
const { timeBase: A, startTimecode: O } = p, I = o ?? O, b = I && j(I);
|
|
1741
|
-
return f = l, u = h, (h ===
|
|
1742
|
+
return f = l, u = h, (h === xt || h === jt) && (g === ze || g === Ve) && E === He && (u = Lt), r != null && r.length && kt.includes(h) && (f = Qe({
|
|
1742
1743
|
url: l,
|
|
1743
1744
|
streamingServers: r,
|
|
1744
1745
|
ending: "mpd"
|
|
@@ -1763,7 +1764,7 @@ ${o.join(`
|
|
|
1763
1764
|
const [m] = Object.values(d);
|
|
1764
1765
|
if (m) {
|
|
1765
1766
|
t.fieldOrder = m.InterlaceMode, t.fieldOrder && t.fieldOrder.includes("TOP") && (t.fieldOrder = "interlaced"), t.videoBitrate = m.Bitrate;
|
|
1766
|
-
const p = m.FramerateDenominator, l = m.FramerateNumerator, h =
|
|
1767
|
+
const p = m.FramerateDenominator, l = m.FramerateNumerator, h = x({ denominator: l, numerator: p });
|
|
1767
1768
|
t.timeBase = h, t.frameRate = h.toConstant() || h.toRate();
|
|
1768
1769
|
}
|
|
1769
1770
|
}
|
|
@@ -1780,7 +1781,7 @@ ${o.join(`
|
|
|
1780
1781
|
return { description: s, ...Ze(o) };
|
|
1781
1782
|
if (t.description = s, t.containerFormat = n, i) {
|
|
1782
1783
|
if (t.videoFormat = i.codec, t.videoBitrate = i.bitrate, i.framerate) {
|
|
1783
|
-
const a =
|
|
1784
|
+
const a = x(i.framerate);
|
|
1784
1785
|
t.timeBase = a, t.frameRate = a.toConstant() || a.toRate();
|
|
1785
1786
|
}
|
|
1786
1787
|
if (i.scaling) {
|
|
@@ -2363,7 +2364,7 @@ export {
|
|
|
2363
2364
|
vs as ChunkedTransferManager,
|
|
2364
2365
|
ht as ChunkedUpload,
|
|
2365
2366
|
nt as ChunkedUploadEventBus,
|
|
2366
|
-
|
|
2367
|
+
P as DOCUMENT_TYPES,
|
|
2367
2368
|
T as EVENTS,
|
|
2368
2369
|
Ht as FIELD_ATTRIBUTE_KEYS,
|
|
2369
2370
|
Ss as FIELD_DEFINITION_TYPES,
|
|
@@ -2385,11 +2386,11 @@ export {
|
|
|
2385
2386
|
Is as filterShapeSource,
|
|
2386
2387
|
be as findNearestThumbnail,
|
|
2387
2388
|
et as formatTimeBaseText,
|
|
2388
|
-
|
|
2389
|
+
x as formatTimeBaseType,
|
|
2389
2390
|
le as formatTimeCodeSeconds,
|
|
2390
2391
|
pe as formatTimeCodeSmpte,
|
|
2391
2392
|
U as formatTimeCodeText,
|
|
2392
|
-
|
|
2393
|
+
L as formatTimeCodeType,
|
|
2393
2394
|
bs as getPlayerSources,
|
|
2394
2395
|
As as getShapeDocumentType,
|
|
2395
2396
|
Os as getShapeMediaType,
|
|
@@ -2401,7 +2402,7 @@ export {
|
|
|
2401
2402
|
ps as parseFacetType,
|
|
2402
2403
|
ys as parseFieldDefinitionList,
|
|
2403
2404
|
Mt as parseFieldList,
|
|
2404
|
-
|
|
2405
|
+
Pt as parseFileType,
|
|
2405
2406
|
Ft as parseGroupList,
|
|
2406
2407
|
Y as parseHighlightTimespan,
|
|
2407
2408
|
_s as parseHighlightTimespanList,
|
package/dist/index.umd.cjs
CHANGED
|
@@ -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(":")},M=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,Rt={includeValueAttributes:!1};function Ee(e,t){const{includeValueAttributes:s}={...Rt,...t||{}};if(s===!1)return e==null?void 0:e.value;const{value:i,...r}=e;return{...s===!0&&r||Array.isArray(s)&&Object.fromEntries(Object.entries(r).filter(([o])=>s.includes(o)))||{},value:i}}const yt={...Rt,joinValue:void 0,arrayOnSingleValue:!0};function ge(e,t){const{joinValue:s,arrayOnSingleValue:i,...r}={...yt,...t||{}},n=e==null?void 0:e.map(o=>Ee(o,r));return Te(n)&&s?n==null?void 0:n.join(s):i!==!0&&(n==null?void 0:n.length)<=1?n==null?void 0:n[0]:n}const vt={includeFieldAttributes:!1,...yt},Ae=(e,t)=>{const{includeFieldAttributes:s,...i}={...vt,...t||{}},{value:r,...n}=e,o=ge(r,i),a=s===!0&&n||Array.isArray(s)&&Object.fromEntries(Object.entries(n).filter(([c])=>s.includes(c)))||{};return s?{...a,value:o}:o},x={...vt,fieldAsList:!1,arrayOnSingleField:!1,overrideField:void 0},tt=(e,t)=>{const s={...x,...t||{}},{fieldAsList:i,arrayOnSingleField:r,overrideField:n}=s,o=n===!0&&i===!1,a={};return e==null||e.forEach(c=>{const{name:l}=c,u=Ae(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===!0?Object.values(a).flat():a},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},Mt={...et,includeTimespanAttributes:!1,flat:!1,arrayOnSingle:!1,arrayOnSingleValue:!0,arrayOnSingleGroup:void 0,arrayOnSingleField:void 0},Dt=(e,t)=>{const s={...Mt,...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={...Mt,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=Dt(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(t).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 M(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 R{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=>{if(e===void 0)return new R;if(typeof e=="number")return new R({denominator:e});if(typeof e=="string"&&e.includes(":")){const[t,s]=e.split(":");return new R({denominator:t,numerator:s})}if(Nt.includes(e))return new R(nt[e]);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 R({denominator:Number(e)})},w=e=>new R(e),W=e=>e instanceof R?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},Bt=e=>at(e)>0,Lt=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 R;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 R?this.timeBase=r:this.timeBase=W(r)),this.dropFrame=(s==null?void 0:s.dropFrame)??Bt(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 R?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?Lt(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+Lt(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},Re=([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?Re(e,c,t):0)},ye=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}=ye(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?Bt(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)},Me={timeBase:void 0,dropFrame:void 0,frameSeparator:void 0},$=(e,t)=>{const{timeBase:s,...i}={...Me,...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 R))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},De={dropFrame:void 0,frameSeparator:void 0},B=(e,t)=>new F(e,{...De,...t}),Ce=e=>!!e.match(/^(\d\d+):(\d\d+):(\d\d+)(:|;|\.|,)(\d\d+)$/),Ne=e=>!Number.isNaN(Number(e)),L=(e,t)=>{if(e instanceof F)return e;if(typeof e!="string"&&typeof e!="number")return B(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"},Be=(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
|
|
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(":")},M=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]",gt=e=>Object.prototype.toString.call(e)==="[object Date]",Et=e=>e===null?!0:Array.isArray(e)?e.some(Et):_t(e)||Tt(e)||gt(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)?{}:gt(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(Et(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,Rt={includeValueAttributes:!1};function ge(e,t){const{includeValueAttributes:s}={...Rt,...t||{}};if(s===!1)return e==null?void 0:e.value;const{value:i,...r}=e;return{...s===!0&&r||Array.isArray(s)&&Object.fromEntries(Object.entries(r).filter(([o])=>s.includes(o)))||{},value:i}}const yt={...Rt,joinValue:void 0,arrayOnSingleValue:!0};function Ee(e,t){const{joinValue:s,arrayOnSingleValue:i,...r}={...yt,...t||{}},n=e==null?void 0:e.map(o=>ge(o,r));return Te(n)&&s?n==null?void 0:n.join(s):i!==!0&&(n==null?void 0:n.length)<=1?n==null?void 0:n[0]:n}const vt={includeFieldAttributes:!1,...yt},Ae=(e,t)=>{const{includeFieldAttributes:s,...i}={...vt,...t||{}},{value:r,...n}=e,o=Ee(r,i),a=s===!0&&n||Array.isArray(s)&&Object.fromEntries(Object.entries(n).filter(([c])=>s.includes(c)))||{};return s?{...a,value:o}:o},G={...vt,fieldAsList:!1,arrayOnSingleField:!1,overrideField:void 0},tt=(e,t)=>{const s={...G,...t||{}},{fieldAsList:i,arrayOnSingleField:r,overrideField:n}=s,o=n===!0&&i===!1,a={};return e==null||e.forEach(c=>{const{name:l}=c,u=Ae(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===!0?Object.values(a).flat():a},Ft={...G,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(G).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},Mt={...et,includeTimespanAttributes:!1,flat:!1,arrayOnSingle:!1,arrayOnSingleValue:!0,arrayOnSingleGroup:void 0,arrayOnSingleField:void 0},Dt=(e,t)=>{const s={...Mt,...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(G).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={...Mt,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),E=Dt(m,l),A=f[h];A?u?_==="-INF"&&d==="+INF"?f[h]={...St(A),...E}:f[h]={...E,...St(A)}:f[h]=[...C(A),E]:f[h]=E}),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 M(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 R{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 x=e=>{var t;if(e===void 0)return new R;if(Nt.includes((t=e==null?void 0:e.toString)==null?void 0:t.call(e)))return new R(nt[e]);if(typeof e=="number")return new R({denominator:e});if(typeof e=="string"&&e.includes(":")){const[s,i]=e.split(":");return new R({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 R({denominator:Number(e)})},w=e=>new R(e),W=e=>e instanceof R?e:typeof e=="string"||typeof e=="number"?x(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 R;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 R?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 R?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},Re=([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?Re(e,c,t):0)},ye=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}=ye(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,E=[Math.min(100,m),Math.min(59,_),Math.min(59,d),Math.min(u,h)];f=ct(E,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)},Me={timeBase:void 0,dropFrame:void 0,frameSeparator:void 0},$=(e,t)=>{const{timeBase:s,...i}={...Me,...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:x(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 R))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},De={dropFrame:void 0,frameSeparator:void 0},L=(e,t)=>new F(e,{...De,...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
|
-
`)}`},Le={count:!0,exclude:!0},Pe=(e=[],t={})=>{const s={...Le,...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=L(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=L(e).toSeconds(),o=L(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,L(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:D})=>D===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{...M(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=M(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=M(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=M(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=B(r);d.durationTimeCode=h.toObject(),d.duration=h.toDuration()}if(n&&(d.startTimestamp=B(n).toObject()),o!==void 0&&a&&(d.startTimecode=B({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=M(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=B({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 D,U;return s!==void 0&&(D=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:D,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"},y={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 y.AUDIO;if(s.startsWith("video/")){if(i!==void 0)return y.VIDEO;if(r!==void 0)return y.AUDIO}if(s.startsWith("image/"))return y.IMAGE;if(s.endsWith("/pdf")||s.startsWith("text/")||s.endsWith("/msword")||s.endsWith("/json")||s.endsWith("/xml"))return y.DOCUMENT;if(s.endsWith("/octet-stream"))return y.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 D=(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===D).length;U===0?m=D:m=D+(U+1)}const{timeBase:I,startTimecode:b}=_,O=o??b,S=O&&L(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=M(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 this.end-this.start!==this.fileSize&&(t.headers={index:this.start,size:this.fileSize}),t={...t,...this.api.props||{}},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");console.log(s),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(console.log("status",t),t!==T.complete)if(t===T.idle||t===T.transferring){this.state.transferPromises=[];const s=()=>{const i=this.state.chunks[0].state.status,r=this.state.transferPromises.length<this.state.maxConcurrentTransfers&&i!==T.transferring;return console.log("isOK",r),console.log("this.state",this.state),r};s()&&(console.log("this.state.chunks",this.state.chunks),this.state.chunks.forEach(i=>{i.state.status!==T.complete&&i.state.status!==T.transferring&&s()&&(this.state.status=T.transferring,this.state.transferPromises.push(i.tryTransfer()))}),this.state.transferPromises.length>0&&Promise.all(this.state.transferPromises).then(()=>{this.upload()}).catch(i=>{console.log("Failed on this upload() cycle, check connectivity and try to resume :(",i),this.state.status!==T.offline?(this.state.status=T.failed,this.eventBus.trigger(E.failed,this.state,i)):setTimeout(()=>this.retry(),5e3)}))}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()}),this.upload=()=>{};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 Rs{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){console.log("chunkedUpload",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;console.log("this.transfers",this.transfers),console.log("this.options.maxConcurrentFileTransfers",this.options.maxConcurrentFileTransfers),console.log("before ongoingTransfers",t),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(),console.log("after ongoingTransfers",t)}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}}}},ys=e=>e.map(t=>te(t,t.path??t.webkitRelativePath)).reduce((t,s)=>re(t,s),{});p.Chunk=Zt,p.ChunkedTransferManager=Rs,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=y,p.STATUSES=T,p.SYSTEM_FIELDGROUPS=oe,p.SYSTEM_FIELDS=ce,p.TimeBase=R,p.TimeCode=F,p.createMetadataType=pe,p.createSearchFacetList=Pe,p.createTimeBase=W,p.createTimeCode=L,p.fileListToFileTree=ys,p.filterShapeSource=os,p.findNearestThumbnail=$t,p.formatTimeBaseText=G,p.formatTimeBaseType=w,p.formatTimeCodeSeconds=Pt,p.formatTimeCodeSmpte=jt,p.formatTimeCodeText=$,p.formatTimeCodeType=B,p.getPlayerSources=Es,p.getShapeDocumentType=qe,p.getShapeMediaType=cs,p.metadataTypeToWebVtt=Be,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=M,p.parseMediaConvertPreset=Qt,p.parseMetadataType=Ct,p.parseNowDate=ze,p.parseSearchResultEvents=Ge,p.parseShapeType=Y,p.parseSimpleMetadataType=be,p.parseTimespan=Dt,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},Ge=({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}}},xe=(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 E=d.map(A=>Ge(A));if(a&&u==="Item"&&_.uri&&(E=E.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=E.map(O=>{const{group:{uuid:S}}=O,[N]=S.split("/"),{field:j=[],group:k=[]}=I.find(({uuid:D})=>D===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:E.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{...M(t),...s}},Ve=e=>V(e),Ye=e=>V(e),He={kB:"kHz",B:"Hz",mB:"mHz"},Ut={kB:"kbps",B:"bps",MB:"mbps"},Gt=e=>{var E;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=M(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((E=v.filesize(n,{exponent:1,symbols:Ut}).split(" kbps"))==null?void 0:E[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}},xt=(e={})=>{const{file:t,mediaInfo:s,metadata:i=[]}=e,r=M(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=M(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,E=ut(h);d={...d,...E}}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=M(o),{Format:l,"Frame rate":u,"Color space":f,"Color primaries":m,Colorimetry:_}=a;let d;const{averageFrameRate:h,realBaseFrameRate:E}=e;E!==void 0?d=w({numerator:E.denominator,denominator:E.numerator}):u!==void 0?d=x(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 D,U;return s!==void 0&&(D=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:D,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,Gt(m))}break;case"binary":if(a){const[m]=a;s=u(s,xt(m))}break}}),s},P={PDF:"PDF",TEXT:"TEXT",MSWORD:"MSWORD",JSON:"JSON",XML:"XML"},y={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:E,mimeType:A,containerFormat:I,videoCodec:b}=h;if(A&&(_=A,(A===ss||A===rs)&&(I===is||I===ns)&&b===as&&(_=es)),E)if(i){const[O]=E.split("://");i.includes(O)&&(d=E)}else d=E;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 y.AUDIO;if(s.startsWith("video/")){if(i!==void 0)return y.VIDEO;if(r!==void 0)return y.AUDIO}if(s.startsWith("image/"))return y.IMAGE;if(s.endsWith("/pdf")||s.startsWith("text/")||s.endsWith("/msword")||s.endsWith("/json")||s.endsWith("/xml"))return y.DOCUMENT;if(s.endsWith("/octet-stream"))return y.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}`),gs=(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:E,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 D=(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===D).length;U===0?m=D:m=D+(U+1)}const{timeBase:I,startTimecode:b}=_,O=o??b,S=O&&B(O);return f=d,u=h,(h===qt||h===Jt)&&(E===us||E===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},Es=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||{},E=((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=M(c);return{name:t,type:s,defaultValue:i,required:d!==void 0||f!==void 0&&f>0,restrictions:I,data:b,options:E,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||{}),g=(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))(g||{});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(g.online,()=>{this.resume()}),window.addEventListener(g.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(g.progress,this.state))}};return this.end-this.start!==this.fileSize&&(t.headers={index:this.start,size:this.fileSize}),t={...t,...this.api.props||{}},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(g.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");console.log(s),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(console.log("status",t),t!==T.complete)if(t===T.idle||t===T.transferring){this.state.transferPromises=[];const s=()=>{const i=this.state.chunks[0].state.status,r=this.state.transferPromises.length<this.state.maxConcurrentTransfers&&i!==T.transferring;return console.log("isOK",r),console.log("this.state",this.state),r};s()&&(console.log("this.state.chunks",this.state.chunks),this.state.chunks.forEach(i=>{i.state.status!==T.complete&&i.state.status!==T.transferring&&s()&&(this.state.status=T.transferring,this.state.transferPromises.push(i.tryTransfer()))}),this.state.transferPromises.length>0&&Promise.all(this.state.transferPromises).then(()=>{this.upload()}).catch(i=>{console.log("Failed on this upload() cycle, check connectivity and try to resume :(",i),this.state.status!==T.offline?(this.state.status=T.failed,this.eventBus.trigger(g.failed,this.state,i)):setTimeout(()=>this.retry(),5e3)}))}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(g.progress,()=>{this.onProgress()}),r.eventBus.on(g.complete,()=>{this.onProgress()}),this.state.chunks.push(r)})}retry(){this.state.status===T.failed&&(this.resume(),this.eventBus.trigger(g.retry,this.state))}resume(){this.state.status=T.transferring,this.eventBus.trigger(g.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(g.pausing,this.state),t.then(()=>{this.eventBus.trigger(g.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()}),this.upload=()=>{};const t=Promise.all(this.state.transferPromises);return t.then(()=>{this.eventBus.trigger(g.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(g.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(g.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 Rs{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(g.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(g.online,()=>{this.events.trigger(g.online,this.state),this.state.status=T.transferring,this.options.autoResume&&setTimeout(()=>{this.retry()},1500)}),window.addEventListener(g.offline,()=>{this.events.trigger(g.offline,this.state),this.state.status=T.offline}))}addChunkedUpload(t){console.log("chunkedUpload",t),t.transferId!==null&&(this.state.transfers[t.transferId]=t,t.eventBus.on(g.progress,()=>{this.onProgress()}),t.eventBus.on(g.complete,()=>{this.upload(),this.onProgress()}),t.eventBus.on(g.failed,(s,i)=>{this.onFail(i,s)}),t.eventBus.on(g.retry,()=>{this.events.trigger(g.retry,this.state)}),t.eventBus.on(g.paused,()=>{this.paused&&this.events.trigger(g.paused,this.state)}),this.updateStats(),this.events.trigger(g.added,this.state),this.events.trigger(g.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(g.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(g.progress,this.state))}onComplete(){this.state.status=T.complete,this.events.trigger(g.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(g.pausing,this.state);const s=[];this.transfers.forEach(i=>{s.push(i.pause())}),t=Promise.all(s),t.then(()=>{this.events.trigger(g.paused,this.state)})}return t}resume(){this.events.trigger(g.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(g.retry,this.state))}upload(){let t=0;console.log("this.transfers",this.transfers),console.log("this.options.maxConcurrentFileTransfers",this.options.maxConcurrentFileTransfers),console.log("before ongoingTransfers",t),this.transfers.forEach(s=>{this.isTransferAvailable(s)?t<this.options.maxConcurrentFileTransfers&&(this.events.trigger(g.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(),console.log("after ongoingTransfers",t)}onFail(t,s){this.status=T.failed,this.events.trigger(g.error,s,t)}reset(){this.transfers.forEach(t=>{t.constructor.name===dt.name&&this.removeChunkedUpload(t,!0)}),this.state={...this.initialState},this.events.trigger(g.update,this.state),this.events.trigger(g.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}}}},ys=e=>e.map(t=>te(t,t.path??t.webkitRelativePath)).reduce((t,s)=>re(t,s),{});p.Chunk=Zt,p.ChunkedTransferManager=Rs,p.ChunkedUpload=dt,p.ChunkedUploadEventBus=K,p.DOCUMENT_TYPES=P,p.EVENTS=g,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=y,p.STATUSES=T,p.SYSTEM_FIELDGROUPS=oe,p.SYSTEM_FIELDS=ce,p.TimeBase=R,p.TimeCode=F,p.createMetadataType=pe,p.createSearchFacetList=Pe,p.createTimeBase=W,p.createTimeCode=B,p.fileListToFileTree=ys,p.filterShapeSource=os,p.findNearestThumbnail=$t,p.formatTimeBaseText=x,p.formatTimeBaseType=w,p.formatTimeCodeSeconds=Pt,p.formatTimeCodeSmpte=jt,p.formatTimeCodeText=$,p.formatTimeCodeType=L,p.getPlayerSources=gs,p.getShapeDocumentType=qe,p.getShapeMediaType=cs,p.metadataTypeToWebVtt=Le,p.parseAudioComponent=Gt,p.parseBinaryComponent=xt,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=M,p.parseMediaConvertPreset=Qt,p.parseMetadataType=Ct,p.parseNowDate=ze,p.parseSearchResultEvents=xe,p.parseShapeType=Y,p.parseSimpleMetadataType=be,p.parseTimespan=Dt,p.parseTimespanList=it,p.parseTranscodePreset=Es,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": "24.
|
|
3
|
+
"version": "24.2.0-pre.1",
|
|
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": "24.
|
|
41
|
+
"@vidispine/types": "24.2.0-pre.1",
|
|
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": "24.
|
|
48
|
-
"@vidispine/eslint-config-mdx": "24.
|
|
49
|
-
"@vidispine/eslint-config-storybook": "24.
|
|
50
|
-
"@vidispine/tests": "24.
|
|
51
|
-
"@vidispine/types": "24.
|
|
52
|
-
"@vidispine/vdt-storybook": "24.
|
|
47
|
+
"@vidispine/eslint-config-base": "24.2.0-pre.1",
|
|
48
|
+
"@vidispine/eslint-config-mdx": "24.2.0-pre.1",
|
|
49
|
+
"@vidispine/eslint-config-storybook": "24.2.0-pre.1",
|
|
50
|
+
"@vidispine/tests": "24.2.0-pre.1",
|
|
51
|
+
"@vidispine/types": "24.2.0-pre.1",
|
|
52
|
+
"@vidispine/vdt-storybook": "24.2.0-pre.1",
|
|
53
53
|
"eslint": "8.55.0",
|
|
54
54
|
"eslint-plugin-testing-library": "6.2.0",
|
|
55
55
|
"prettier": "3.1.1",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"typedoc": "0.25.4",
|
|
58
58
|
"typedoc-plugin-missing-exports": "2.1.0",
|
|
59
59
|
"typescript": "5.0.4",
|
|
60
|
-
"vite": "4.5.
|
|
60
|
+
"vite": "4.5.3",
|
|
61
61
|
"vite-plugin-dts": "3.6.4"
|
|
62
62
|
},
|
|
63
63
|
"eslintConfig": {
|