@designcombo/state 0.1.30 → 0.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +107 -103
- package/dist/index.umd.js +1 -1
- package/package.json +6 -6
package/dist/index.es.js
CHANGED
|
@@ -513,8 +513,8 @@ function wn(t) {
|
|
|
513
513
|
var er = { exports: {} };
|
|
514
514
|
er.exports;
|
|
515
515
|
(function(t, r) {
|
|
516
|
-
var n = 200, i = "__lodash_hash_undefined__", s = 1, c = 2, h = 9007199254740991, m = "[object Arguments]", P = "[object Array]", F = "[object AsyncFunction]", E = "[object Boolean]", N = "[object Date]", b = "[object Error]", d = "[object Function]", f = "[object GeneratorFunction]", p = "[object Map]", g = "[object Number]",
|
|
517
|
-
U[A] = U[O] = U[Z] = U[V] = U[ft] = U[Jt] = U[Zt] = U[L] = U[ur] = !0, U[m] = U[P] = U[k] = U[E] = U[
|
|
516
|
+
var n = 200, i = "__lodash_hash_undefined__", s = 1, c = 2, h = 9007199254740991, m = "[object Arguments]", P = "[object Array]", F = "[object AsyncFunction]", E = "[object Boolean]", N = "[object Date]", b = "[object Error]", d = "[object Function]", f = "[object GeneratorFunction]", p = "[object Map]", g = "[object Number]", v = "[object Null]", _ = "[object Object]", y = "[object Promise]", l = "[object Proxy]", x = "[object RegExp]", M = "[object Set]", I = "[object String]", C = "[object Symbol]", w = "[object Undefined]", D = "[object WeakMap]", k = "[object ArrayBuffer]", S = "[object DataView]", A = "[object Float32Array]", O = "[object Float64Array]", Z = "[object Int8Array]", V = "[object Int16Array]", ft = "[object Int32Array]", Jt = "[object Uint8Array]", Zt = "[object Uint8ClampedArray]", L = "[object Uint16Array]", ur = "[object Uint32Array]", lr = /[\\^$.*+?()[\]{}|]/g, ot = /^\[object .+?Constructor\]$/, Me = /^(?:0|[1-9]\d*)$/, U = {};
|
|
517
|
+
U[A] = U[O] = U[Z] = U[V] = U[ft] = U[Jt] = U[Zt] = U[L] = U[ur] = !0, U[m] = U[P] = U[k] = U[E] = U[S] = U[N] = U[b] = U[d] = U[p] = U[g] = U[_] = U[x] = U[M] = U[I] = U[D] = !1;
|
|
518
518
|
var Ae = typeof st == "object" && st && st.Object === Object && st, fr = typeof self == "object" && self && self.Object === Object && self, ct = Ae || fr || Function("return this")(), Oe = r && !r.nodeType && r, xe = Oe && !0 && t && !t.nodeType && t, Qt = xe && xe.exports === Oe, te = Qt && Ae.process, De = function() {
|
|
519
519
|
try {
|
|
520
520
|
return te && te.binding && te.binding("util");
|
|
@@ -728,7 +728,7 @@ er.exports;
|
|
|
728
728
|
return Kt(e) ? u : re(u, o(e));
|
|
729
729
|
}
|
|
730
730
|
function At(e) {
|
|
731
|
-
return e == null ? e === void 0 ? w :
|
|
731
|
+
return e == null ? e === void 0 ? w : v : ut && ut in Object(e) ? gt(e) : Be(e);
|
|
732
732
|
}
|
|
733
733
|
function We(e) {
|
|
734
734
|
return mt(e) && At(e) == m;
|
|
@@ -808,7 +808,7 @@ er.exports;
|
|
|
808
808
|
}
|
|
809
809
|
function Gr(e, a, o, u, R, T, z) {
|
|
810
810
|
switch (o) {
|
|
811
|
-
case
|
|
811
|
+
case S:
|
|
812
812
|
if (e.byteLength != a.byteLength || e.byteOffset != a.byteOffset)
|
|
813
813
|
return !1;
|
|
814
814
|
e = e.buffer, a = a.buffer;
|
|
@@ -898,12 +898,12 @@ er.exports;
|
|
|
898
898
|
return Ut.call(e, a);
|
|
899
899
|
}));
|
|
900
900
|
} : Jr, ht = At;
|
|
901
|
-
(oe && ht(new oe(new ArrayBuffer(1))) !=
|
|
901
|
+
(oe && ht(new oe(new ArrayBuffer(1))) != S || Mt && ht(new Mt()) != p || ce && ht(ce.resolve()) != y || ue && ht(new ue()) != M || le && ht(new le()) != D) && (ht = function(e) {
|
|
902
902
|
var a = At(e), o = a == _ ? e.constructor : void 0, u = o ? Q(o) : "";
|
|
903
903
|
if (u)
|
|
904
904
|
switch (u) {
|
|
905
905
|
case Ne:
|
|
906
|
-
return
|
|
906
|
+
return S;
|
|
907
907
|
case yt:
|
|
908
908
|
return p;
|
|
909
909
|
case yr:
|
|
@@ -993,8 +993,8 @@ const rt = /* @__PURE__ */ wn(Ji);
|
|
|
993
993
|
var rr = { exports: {} };
|
|
994
994
|
rr.exports;
|
|
995
995
|
(function(t, r) {
|
|
996
|
-
var n = 200, i = "__lodash_hash_undefined__", s = 9007199254740991, c = "[object Arguments]", h = "[object Array]", m = "[object Boolean]", P = "[object Date]", F = "[object Error]", E = "[object Function]", N = "[object GeneratorFunction]", b = "[object Map]", d = "[object Number]", f = "[object Object]", p = "[object Promise]", g = "[object RegExp]",
|
|
997
|
-
L[c] = L[h] = L[x] = L[M] = L[m] = L[P] = L[I] = L[C] = L[w] = L[D] = L[k] = L[b] = L[d] = L[f] = L[g] = L[
|
|
996
|
+
var n = 200, i = "__lodash_hash_undefined__", s = 9007199254740991, c = "[object Arguments]", h = "[object Array]", m = "[object Boolean]", P = "[object Date]", F = "[object Error]", E = "[object Function]", N = "[object GeneratorFunction]", b = "[object Map]", d = "[object Number]", f = "[object Object]", p = "[object Promise]", g = "[object RegExp]", v = "[object Set]", _ = "[object String]", y = "[object Symbol]", l = "[object WeakMap]", x = "[object ArrayBuffer]", M = "[object DataView]", I = "[object Float32Array]", C = "[object Float64Array]", w = "[object Int8Array]", D = "[object Int16Array]", k = "[object Int32Array]", S = "[object Uint8Array]", A = "[object Uint8ClampedArray]", O = "[object Uint16Array]", Z = "[object Uint32Array]", V = /[\\^$.*+?()[\]{}|]/g, ft = /\w*$/, Jt = /^\[object .+?Constructor\]$/, Zt = /^(?:0|[1-9]\d*)$/, L = {};
|
|
997
|
+
L[c] = L[h] = L[x] = L[M] = L[m] = L[P] = L[I] = L[C] = L[w] = L[D] = L[k] = L[b] = L[d] = L[f] = L[g] = L[v] = L[_] = L[y] = L[S] = L[A] = L[O] = L[Z] = !0, L[F] = L[E] = L[l] = !1;
|
|
998
998
|
var ur = typeof st == "object" && st && st.Object === Object && st, lr = typeof self == "object" && self && self.Object === Object && self, ot = ur || lr || Function("return this")(), Me = r && !r.nodeType && r, U = Me && !0 && t && !t.nodeType && t, Ae = U && U.exports === Me;
|
|
999
999
|
function fr(e, a) {
|
|
1000
1000
|
return e.set(a[0], a[1]), e;
|
|
@@ -1309,7 +1309,7 @@ rr.exports;
|
|
|
1309
1309
|
return zr(o) ? o : void 0;
|
|
1310
1310
|
}
|
|
1311
1311
|
var bt = ae ? re(ae, Object) : Jr, gt = jr;
|
|
1312
|
-
(Ut && gt(new Ut(new ArrayBuffer(1))) != M || Tt && gt(new Tt()) != b || ut && gt(ut.resolve()) != p || Wt && gt(new Wt()) !=
|
|
1312
|
+
(Ut && gt(new Ut(new ArrayBuffer(1))) != M || Tt && gt(new Tt()) != b || ut && gt(ut.resolve()) != p || Wt && gt(new Wt()) != v || se && gt(new se()) != l) && (gt = function(e) {
|
|
1313
1313
|
var a = Ht.call(e), o = a == f ? e.constructor : void 0, u = o ? Q(o) : void 0;
|
|
1314
1314
|
if (u)
|
|
1315
1315
|
switch (u) {
|
|
@@ -1320,7 +1320,7 @@ rr.exports;
|
|
|
1320
1320
|
case ce:
|
|
1321
1321
|
return p;
|
|
1322
1322
|
case ue:
|
|
1323
|
-
return
|
|
1323
|
+
return v;
|
|
1324
1324
|
case le:
|
|
1325
1325
|
return l;
|
|
1326
1326
|
}
|
|
@@ -1348,7 +1348,7 @@ rr.exports;
|
|
|
1348
1348
|
case w:
|
|
1349
1349
|
case D:
|
|
1350
1350
|
case k:
|
|
1351
|
-
case
|
|
1351
|
+
case S:
|
|
1352
1352
|
case A:
|
|
1353
1353
|
case O:
|
|
1354
1354
|
case Z:
|
|
@@ -1360,7 +1360,7 @@ rr.exports;
|
|
|
1360
1360
|
return new R(e);
|
|
1361
1361
|
case g:
|
|
1362
1362
|
return Ge(e);
|
|
1363
|
-
case
|
|
1363
|
+
case v:
|
|
1364
1364
|
return Nr(e, u, o);
|
|
1365
1365
|
case y:
|
|
1366
1366
|
return Lr(e);
|
|
@@ -1817,13 +1817,17 @@ const qt = (t) => Object.keys(t).reduce((r, n) => {
|
|
|
1817
1817
|
let c = !1;
|
|
1818
1818
|
return t.forEach((h) => {
|
|
1819
1819
|
const m = n[h], P = m.display.from, F = m.display.to;
|
|
1820
|
-
(i !== void 0 || s !== void 0)
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1820
|
+
if (i !== void 0 || s !== void 0) {
|
|
1821
|
+
const E = r.find((b, d) => {
|
|
1822
|
+
if (i !== void 0 && b.id === i) return b;
|
|
1823
|
+
if (s !== void 0 && d === s) return b;
|
|
1824
|
+
});
|
|
1825
|
+
if (!E) return;
|
|
1826
|
+
c = E.items.map((b) => n[b]).some((b) => {
|
|
1827
|
+
const d = b.display.from, f = b.display.to;
|
|
1828
|
+
return d <= P && f >= F;
|
|
1829
|
+
});
|
|
1830
|
+
}
|
|
1827
1831
|
}), c;
|
|
1828
1832
|
};
|
|
1829
1833
|
function ia(t) {
|
|
@@ -1842,7 +1846,7 @@ function ia(t) {
|
|
|
1842
1846
|
), m = r.subscribe(async (d) => {
|
|
1843
1847
|
var f, p;
|
|
1844
1848
|
if (d.key === vi) {
|
|
1845
|
-
const g = (f = d.value) == null ? void 0 : f.payload,
|
|
1849
|
+
const g = (f = d.value) == null ? void 0 : f.payload, v = g.size, _ = g.trackItemIds, y = g.trackItemsMap, l = g.trackItemDetailsMap;
|
|
1846
1850
|
console.warn("IMPROVE FONTS LOADING");
|
|
1847
1851
|
const x = _.map(async (I) => {
|
|
1848
1852
|
var C;
|
|
@@ -1852,43 +1856,43 @@ function ia(t) {
|
|
|
1852
1856
|
const k = await hn(
|
|
1853
1857
|
{ id: I, details: w.details, ...D },
|
|
1854
1858
|
{
|
|
1855
|
-
size:
|
|
1859
|
+
size: v
|
|
1856
1860
|
}
|
|
1857
|
-
), { details:
|
|
1858
|
-
l[I] = { type: "image", details:
|
|
1861
|
+
), { details: S, ...A } = k;
|
|
1862
|
+
l[I] = { type: "image", details: S }, y[I] = A;
|
|
1859
1863
|
} else if (w.type === "video") {
|
|
1860
1864
|
const k = B(
|
|
1861
1865
|
(C = d.value) == null ? void 0 : C.payload.trackItemsMap[I]
|
|
1862
|
-
),
|
|
1866
|
+
), S = await dn(
|
|
1863
1867
|
{ ...w, ...k, ...D },
|
|
1864
1868
|
{
|
|
1865
|
-
size:
|
|
1869
|
+
size: v
|
|
1866
1870
|
}
|
|
1867
|
-
), { details: A, ...O } =
|
|
1871
|
+
), { details: A, ...O } = S;
|
|
1868
1872
|
l[I] = { type: "video", details: A }, y[I] = O;
|
|
1869
1873
|
} else if (w.type === "audio") {
|
|
1870
1874
|
const k = await pn({
|
|
1871
1875
|
id: I,
|
|
1872
1876
|
details: w.details,
|
|
1873
1877
|
...D
|
|
1874
|
-
}), { details:
|
|
1875
|
-
l[I] = { type: "audio", details:
|
|
1878
|
+
}), { details: S, ...A } = k;
|
|
1879
|
+
l[I] = { type: "audio", details: S }, y[I] = A;
|
|
1876
1880
|
} else if (w.type === "caption") {
|
|
1877
1881
|
const k = await mn(
|
|
1878
1882
|
{ id: I, details: w.details, ...D },
|
|
1879
1883
|
{
|
|
1880
|
-
size:
|
|
1884
|
+
size: v
|
|
1881
1885
|
}
|
|
1882
|
-
), { details:
|
|
1883
|
-
l[I] = { type: "caption", details:
|
|
1886
|
+
), { details: S, ...A } = k;
|
|
1887
|
+
l[I] = { type: "caption", details: S }, y[I] = A;
|
|
1884
1888
|
} else if (w.type === "text") {
|
|
1885
1889
|
const k = await yn(
|
|
1886
1890
|
{ id: I, details: w.details, ...D },
|
|
1887
1891
|
{
|
|
1888
|
-
size:
|
|
1892
|
+
size: v
|
|
1889
1893
|
}
|
|
1890
|
-
), { details:
|
|
1891
|
-
l[I] = { type: "text", details:
|
|
1894
|
+
), { details: S, ...A } = k;
|
|
1895
|
+
l[I] = { type: "text", details: S }, y[I] = A;
|
|
1892
1896
|
}
|
|
1893
1897
|
return !0;
|
|
1894
1898
|
} catch {
|
|
@@ -1913,9 +1917,9 @@ function ia(t) {
|
|
|
1913
1917
|
if (d.key === wi) return t.undo();
|
|
1914
1918
|
if (d.key === ki) return t.redo();
|
|
1915
1919
|
}), F = i.subscribe((d) => {
|
|
1916
|
-
var g,
|
|
1920
|
+
var g, v, _, y;
|
|
1917
1921
|
const f = [], p = [];
|
|
1918
|
-
if ((g = d.value) != null && g.payload.trackItemIds && (f.push((
|
|
1922
|
+
if ((g = d.value) != null && g.payload.trackItemIds && (f.push((v = d.value) == null ? void 0 : v.payload.trackItemIds), t.updateState({ activeIds: f })), d.key === Ti) {
|
|
1919
1923
|
const l = (_ = d.value) == null ? void 0 : _.payload.trackItemIds, x = B(t.getState()), M = l && l.length ? l : x.activeIds, I = x.trackItemIds, C = x.trackItemDetailsMap, w = I.filter(
|
|
1920
1924
|
(O) => !M.includes(O)
|
|
1921
1925
|
), D = Object.fromEntries(
|
|
@@ -1925,17 +1929,17 @@ function ia(t) {
|
|
|
1925
1929
|
), k = ra(
|
|
1926
1930
|
x.tracks,
|
|
1927
1931
|
M
|
|
1928
|
-
),
|
|
1932
|
+
), S = Object.fromEntries(
|
|
1929
1933
|
Object.entries(x.trackItemsMap).filter(
|
|
1930
1934
|
([O]) => !M.includes(O)
|
|
1931
1935
|
)
|
|
1932
|
-
), A = qt(
|
|
1936
|
+
), A = qt(S);
|
|
1933
1937
|
t.updateState(
|
|
1934
1938
|
{
|
|
1935
1939
|
trackItemIds: w,
|
|
1936
1940
|
trackItemDetailsMap: D,
|
|
1937
1941
|
activeIds: [],
|
|
1938
|
-
trackItemsMap:
|
|
1942
|
+
trackItemsMap: S,
|
|
1939
1943
|
tracks: k,
|
|
1940
1944
|
duration: A
|
|
1941
1945
|
},
|
|
@@ -1989,11 +1993,11 @@ function ia(t) {
|
|
|
1989
1993
|
var l, x, M, I, C, w, D, k;
|
|
1990
1994
|
const f = B(t.getState());
|
|
1991
1995
|
let p = [], g = "text";
|
|
1992
|
-
const
|
|
1996
|
+
const v = (l = d.value) == null ? void 0 : l.options.trackId, _ = (x = d.value) == null ? void 0 : x.options.trackIndex;
|
|
1993
1997
|
if (d.key === Mi) {
|
|
1994
1998
|
g = "caption";
|
|
1995
|
-
const
|
|
1996
|
-
for (const V of
|
|
1999
|
+
const S = (M = d.value) == null ? void 0 : M.payload, A = [];
|
|
2000
|
+
for (const V of S) {
|
|
1997
2001
|
const ft = mn(V, {
|
|
1998
2002
|
size: f.size
|
|
1999
2003
|
});
|
|
@@ -2013,9 +2017,9 @@ function ia(t) {
|
|
|
2013
2017
|
}
|
|
2014
2018
|
if (d.key === Ai) {
|
|
2015
2019
|
g = "text";
|
|
2016
|
-
const
|
|
2020
|
+
const S = await yn((I = d.value) == null ? void 0 : I.payload, {
|
|
2017
2021
|
size: f.size
|
|
2018
|
-
}), { details: A, ...O } =
|
|
2022
|
+
}), { details: A, ...O } = S;
|
|
2019
2023
|
f.trackItemDetailsMap[O.id] = {
|
|
2020
2024
|
type: g,
|
|
2021
2025
|
details: A
|
|
@@ -2023,10 +2027,10 @@ function ia(t) {
|
|
|
2023
2027
|
}
|
|
2024
2028
|
if (d.key === Oi) {
|
|
2025
2029
|
g = "template";
|
|
2026
|
-
const
|
|
2030
|
+
const S = await ta((C = d.value) == null ? void 0 : C.payload, {
|
|
2027
2031
|
size: f.size
|
|
2028
|
-
}), { details: A, ...O } =
|
|
2029
|
-
f.trackItemsMap[
|
|
2032
|
+
}), { details: A, ...O } = S;
|
|
2033
|
+
f.trackItemsMap[S.id] = {
|
|
2030
2034
|
...O,
|
|
2031
2035
|
type: "template"
|
|
2032
2036
|
}, f.trackItemIds.push(O.id), f.trackItemDetailsMap[O.id] = {
|
|
@@ -2036,9 +2040,9 @@ function ia(t) {
|
|
|
2036
2040
|
}
|
|
2037
2041
|
if (d.key === xi) {
|
|
2038
2042
|
g = "image";
|
|
2039
|
-
const
|
|
2043
|
+
const S = await hn((w = d.value) == null ? void 0 : w.payload, {
|
|
2040
2044
|
size: f.size
|
|
2041
|
-
}), { details: A, ...O } =
|
|
2045
|
+
}), { details: A, ...O } = S;
|
|
2042
2046
|
f.trackItemDetailsMap[O.id] = {
|
|
2043
2047
|
type: g,
|
|
2044
2048
|
details: A
|
|
@@ -2046,7 +2050,7 @@ function ia(t) {
|
|
|
2046
2050
|
}
|
|
2047
2051
|
if (d.key === Di) {
|
|
2048
2052
|
g = "audio";
|
|
2049
|
-
const
|
|
2053
|
+
const S = await pn((D = d.value) == null ? void 0 : D.payload), { details: A, ...O } = S;
|
|
2050
2054
|
f.trackItemDetailsMap[O.id] = {
|
|
2051
2055
|
type: g,
|
|
2052
2056
|
details: A
|
|
@@ -2054,9 +2058,9 @@ function ia(t) {
|
|
|
2054
2058
|
}
|
|
2055
2059
|
if (d.key === Pi) {
|
|
2056
2060
|
g = "video";
|
|
2057
|
-
const
|
|
2061
|
+
const S = await dn((k = d.value) == null ? void 0 : k.payload, {
|
|
2058
2062
|
size: f.size
|
|
2059
|
-
}), { details: A, ...O } =
|
|
2063
|
+
}), { details: A, ...O } = S;
|
|
2060
2064
|
f.trackItemDetailsMap[O.id] = {
|
|
2061
2065
|
type: g,
|
|
2062
2066
|
details: A
|
|
@@ -2066,10 +2070,10 @@ function ia(t) {
|
|
|
2066
2070
|
p,
|
|
2067
2071
|
f.tracks,
|
|
2068
2072
|
f.trackItemsMap,
|
|
2069
|
-
|
|
2073
|
+
v,
|
|
2070
2074
|
_
|
|
2071
2075
|
);
|
|
2072
|
-
|
|
2076
|
+
v !== void 0 && v !== "main" && !y ? f.tracks.map((A) => A.id).includes(v) && (f.tracks = f.tracks.map((A) => (A.id === v && A.items.push(...p), A))) : _ !== void 0 && !y ? f.tracks = f.tracks.map((S, A) => (A === _ && S.items.push(...p), S)) : f.tracks.unshift({
|
|
2073
2077
|
id: tr(),
|
|
2074
2078
|
accepts: ["text", "audio", "helper", "video", "image", "caption"],
|
|
2075
2079
|
type: g,
|
|
@@ -2094,10 +2098,10 @@ function ia(t) {
|
|
|
2094
2098
|
if (d.key === Ci) {
|
|
2095
2099
|
const p = B(t.getState()), g = (f = d.value) == null ? void 0 : f.options.time;
|
|
2096
2100
|
if (p.activeIds.length === 1) {
|
|
2097
|
-
const
|
|
2101
|
+
const v = p.activeIds[0], _ = p.trackItemsMap[v];
|
|
2098
2102
|
if (g >= _.display.to || g <= _.display.from)
|
|
2099
2103
|
return;
|
|
2100
|
-
const y = p.trackItemDetailsMap[
|
|
2104
|
+
const y = p.trackItemDetailsMap[v], l = en(), x = {
|
|
2101
2105
|
..._,
|
|
2102
2106
|
id: l,
|
|
2103
2107
|
display: {
|
|
@@ -2109,8 +2113,8 @@ function ia(t) {
|
|
|
2109
2113
|
to: _.display.to
|
|
2110
2114
|
}
|
|
2111
2115
|
};
|
|
2112
|
-
p.trackItemsMap[
|
|
2113
|
-
M.items.includes(
|
|
2116
|
+
p.trackItemsMap[v].display.to = g, p.trackItemsMap[l] = x, p.trackItemIds.push(l), p.trackItemDetailsMap[l] = y, p.tracks.forEach((M) => {
|
|
2117
|
+
M.items.includes(v) && M.items.push(l);
|
|
2114
2118
|
}), t.updateState(
|
|
2115
2119
|
{
|
|
2116
2120
|
trackItemDetailsMap: p.trackItemDetailsMap,
|
|
@@ -2129,25 +2133,25 @@ function ia(t) {
|
|
|
2129
2133
|
if (d.key === Ri) {
|
|
2130
2134
|
const p = B(t.getState());
|
|
2131
2135
|
if (p.activeIds.length) {
|
|
2132
|
-
const g = p.activeIds,
|
|
2136
|
+
const g = p.activeIds, v = [], _ = {
|
|
2133
2137
|
activeIds: g,
|
|
2134
2138
|
trackItemDetailsMap: {},
|
|
2135
2139
|
trackItemsMap: {},
|
|
2136
2140
|
tracks: []
|
|
2137
2141
|
};
|
|
2138
2142
|
g.forEach((l) => {
|
|
2139
|
-
_.trackItemDetailsMap[l] = p.trackItemDetailsMap[l], _.trackItemsMap[l] = p.trackItemsMap[l],
|
|
2143
|
+
_.trackItemDetailsMap[l] = p.trackItemDetailsMap[l], _.trackItemsMap[l] = p.trackItemsMap[l], v.push(
|
|
2140
2144
|
p.tracks.find((x) => x.items.includes(l))
|
|
2141
2145
|
);
|
|
2142
2146
|
});
|
|
2143
2147
|
const y = /* @__PURE__ */ new Set();
|
|
2144
|
-
|
|
2148
|
+
v.filter((l) => y.has(l.id) ? !1 : (y.add(l), !0)), _.tracks = Array.from(y.keys()), localStorage.setItem("DesignComboTemp", JSON.stringify(_));
|
|
2145
2149
|
}
|
|
2146
2150
|
}
|
|
2147
2151
|
if (d.key === Fi) {
|
|
2148
2152
|
const p = localStorage.getItem("DesignComboTemp");
|
|
2149
2153
|
if (!p) return;
|
|
2150
|
-
const g = B(t.getState()),
|
|
2154
|
+
const g = B(t.getState()), v = JSON.parse(p), _ = {}, y = v.trackItemsMap, l = v.trackItemDetailsMap, x = v.tracks, M = [], I = v.activeIds.map(async (C) => {
|
|
2151
2155
|
const w = l[C];
|
|
2152
2156
|
(w.type === "caption" || w.type === "text") && w.details.fontUrl && await kn([
|
|
2153
2157
|
{
|
|
@@ -2182,7 +2186,7 @@ function ia(t) {
|
|
|
2182
2186
|
);
|
|
2183
2187
|
}
|
|
2184
2188
|
}), b = h.subscribe(async (d) => {
|
|
2185
|
-
var f, p, g,
|
|
2189
|
+
var f, p, g, v;
|
|
2186
2190
|
if (d.key === ji) {
|
|
2187
2191
|
const _ = B(t.getState()), [y] = (f = d.value) == null ? void 0 : f.payload.trackItemIds, l = _.trackItemDetailsMap;
|
|
2188
2192
|
_.trackItemIds.forEach((M) => {
|
|
@@ -2231,7 +2235,7 @@ function ia(t) {
|
|
|
2231
2235
|
);
|
|
2232
2236
|
}
|
|
2233
2237
|
if (d.key === Hi) {
|
|
2234
|
-
const _ = (
|
|
2238
|
+
const _ = (v = d.value) == null ? void 0 : v.payload, y = Object.keys(_)[0], l = Object.values(_)[0], x = B(t.getState());
|
|
2235
2239
|
for (const M of x.trackItemIds)
|
|
2236
2240
|
if (x.trackItemsMap[M].type === "template") {
|
|
2237
2241
|
const I = x.trackItemDetailsMap[M];
|
|
@@ -2240,16 +2244,16 @@ function ia(t) {
|
|
|
2240
2244
|
if (w.id === y) {
|
|
2241
2245
|
if (l.details) {
|
|
2242
2246
|
if (l.type === "image" && l.details.src) {
|
|
2243
|
-
const k = await ti(l.details.src),
|
|
2247
|
+
const k = await ti(l.details.src), S = w.details.width, A = w.details.height;
|
|
2244
2248
|
let O = k.width, Z = k.height;
|
|
2245
2249
|
const V = k.width / k.height;
|
|
2246
|
-
|
|
2250
|
+
S / A > V ? (O = S, Z = S / V) : (Z = A, O = A * V), l.details.mediaWidth = O, l.details.mediaHeight = Z;
|
|
2247
2251
|
}
|
|
2248
2252
|
if (l.type === "video" && l.details.src) {
|
|
2249
|
-
const k = await ei(l.details.src),
|
|
2253
|
+
const k = await ei(l.details.src), S = w.details.width, A = w.details.height;
|
|
2250
2254
|
let O = k.width, Z = k.height;
|
|
2251
2255
|
const V = k.width / k.height;
|
|
2252
|
-
|
|
2256
|
+
S / A > V ? (O = S, Z = S / V) : (Z = A, O = A * V), l.details.mediaWidth = O, l.details.mediaHeight = Z;
|
|
2253
2257
|
}
|
|
2254
2258
|
const D = w.details;
|
|
2255
2259
|
w.details = { ...D, ...l.details }, l.details = w.details;
|
|
@@ -2819,10 +2823,10 @@ function Un() {
|
|
|
2819
2823
|
}
|
|
2820
2824
|
}
|
|
2821
2825
|
function c(b, d, f, p) {
|
|
2822
|
-
let { base_: g, assigned_:
|
|
2826
|
+
let { base_: g, assigned_: v } = b, _ = b.copy_;
|
|
2823
2827
|
_.length < g.length && ([g, _] = [_, g], [f, p] = [p, f]);
|
|
2824
2828
|
for (let y = 0; y < g.length; y++)
|
|
2825
|
-
if (
|
|
2829
|
+
if (v[y] && _[y] !== g[y]) {
|
|
2826
2830
|
const l = d.concat([y]);
|
|
2827
2831
|
f.push({
|
|
2828
2832
|
op: r,
|
|
@@ -2855,9 +2859,9 @@ function Un() {
|
|
|
2855
2859
|
}
|
|
2856
2860
|
}
|
|
2857
2861
|
function h(b, d, f, p) {
|
|
2858
|
-
const { base_: g, copy_:
|
|
2862
|
+
const { base_: g, copy_: v } = b;
|
|
2859
2863
|
_e(b.assigned_, (_, y) => {
|
|
2860
|
-
const l = rn(g, _), x = rn(
|
|
2864
|
+
const l = rn(g, _), x = rn(v, _), M = y ? Ie(g, _) ? r : n : i;
|
|
2861
2865
|
if (l === x && M === r)
|
|
2862
2866
|
return;
|
|
2863
2867
|
const I = d.concat(_);
|
|
@@ -2867,9 +2871,9 @@ function Un() {
|
|
|
2867
2871
|
});
|
|
2868
2872
|
}
|
|
2869
2873
|
function m(b, d, f, p) {
|
|
2870
|
-
let { base_: g, copy_:
|
|
2874
|
+
let { base_: g, copy_: v } = b, _ = 0;
|
|
2871
2875
|
g.forEach((y) => {
|
|
2872
|
-
if (!
|
|
2876
|
+
if (!v.has(y)) {
|
|
2873
2877
|
const l = d.concat([_]);
|
|
2874
2878
|
f.push({
|
|
2875
2879
|
op: i,
|
|
@@ -2882,7 +2886,7 @@ function Un() {
|
|
|
2882
2886
|
});
|
|
2883
2887
|
}
|
|
2884
2888
|
_++;
|
|
2885
|
-
}), _ = 0,
|
|
2889
|
+
}), _ = 0, v.forEach((y) => {
|
|
2886
2890
|
if (!g.has(y)) {
|
|
2887
2891
|
const l = d.concat([_]);
|
|
2888
2892
|
f.push({
|
|
@@ -2912,44 +2916,44 @@ function Un() {
|
|
|
2912
2916
|
function F(b, d) {
|
|
2913
2917
|
return d.forEach((f) => {
|
|
2914
2918
|
const { path: p, op: g } = f;
|
|
2915
|
-
let
|
|
2919
|
+
let v = b;
|
|
2916
2920
|
for (let x = 0; x < p.length - 1; x++) {
|
|
2917
|
-
const M = Ft(
|
|
2921
|
+
const M = Ft(v);
|
|
2918
2922
|
let I = p[x];
|
|
2919
|
-
typeof I != "string" && typeof I != "number" && (I = "" + I), (M === 0 || M === 1) && (I === "__proto__" || I === "constructor") && $(19), typeof
|
|
2923
|
+
typeof I != "string" && typeof I != "number" && (I = "" + I), (M === 0 || M === 1) && (I === "__proto__" || I === "constructor") && $(19), typeof v == "function" && I === "prototype" && $(19), v = rn(v, I), typeof v != "object" && $(18, p.join("/"));
|
|
2920
2924
|
}
|
|
2921
|
-
const _ = Ft(
|
|
2925
|
+
const _ = Ft(v), y = E(f.value), l = p[p.length - 1];
|
|
2922
2926
|
switch (g) {
|
|
2923
2927
|
case r:
|
|
2924
2928
|
switch (_) {
|
|
2925
2929
|
case 2:
|
|
2926
|
-
return
|
|
2930
|
+
return v.set(l, y);
|
|
2927
2931
|
case 3:
|
|
2928
2932
|
$(16);
|
|
2929
2933
|
default:
|
|
2930
|
-
return
|
|
2934
|
+
return v[l] = y;
|
|
2931
2935
|
}
|
|
2932
2936
|
case n:
|
|
2933
2937
|
switch (_) {
|
|
2934
2938
|
case 1:
|
|
2935
|
-
return l === "-" ?
|
|
2939
|
+
return l === "-" ? v.push(y) : v.splice(l, 0, y);
|
|
2936
2940
|
case 2:
|
|
2937
|
-
return
|
|
2941
|
+
return v.set(l, y);
|
|
2938
2942
|
case 3:
|
|
2939
|
-
return
|
|
2943
|
+
return v.add(y);
|
|
2940
2944
|
default:
|
|
2941
|
-
return
|
|
2945
|
+
return v[l] = y;
|
|
2942
2946
|
}
|
|
2943
2947
|
case i:
|
|
2944
2948
|
switch (_) {
|
|
2945
2949
|
case 1:
|
|
2946
|
-
return
|
|
2950
|
+
return v.splice(l, 1);
|
|
2947
2951
|
case 2:
|
|
2948
|
-
return
|
|
2952
|
+
return v.delete(l);
|
|
2949
2953
|
case 3:
|
|
2950
|
-
return
|
|
2954
|
+
return v.delete(f.value);
|
|
2951
2955
|
default:
|
|
2952
|
-
return delete
|
|
2956
|
+
return delete v[l];
|
|
2953
2957
|
}
|
|
2954
2958
|
default:
|
|
2955
2959
|
$(17, g);
|
|
@@ -3244,23 +3248,23 @@ class Za {
|
|
|
3244
3248
|
trackItemsMap: F
|
|
3245
3249
|
}), N = [], b = [], d = [], f = [], p = [], g = [];
|
|
3246
3250
|
n.forEach((k) => {
|
|
3247
|
-
let
|
|
3251
|
+
let S;
|
|
3248
3252
|
const A = k.path.slice(1);
|
|
3249
|
-
k.type === "CREATE" ?
|
|
3253
|
+
k.type === "CREATE" ? S = {
|
|
3250
3254
|
path: A,
|
|
3251
3255
|
op: "remove",
|
|
3252
3256
|
value: k.value
|
|
3253
|
-
} : k.type === "CHANGE" ?
|
|
3257
|
+
} : k.type === "CHANGE" ? S = {
|
|
3254
3258
|
path: A,
|
|
3255
3259
|
op: "replace",
|
|
3256
3260
|
value: k.oldValue
|
|
3257
|
-
} :
|
|
3261
|
+
} : S = {
|
|
3258
3262
|
path: A,
|
|
3259
3263
|
op: "add",
|
|
3260
3264
|
value: k.oldValue
|
|
3261
|
-
}, k.path.includes("trackItemIds") ? d.push(
|
|
3265
|
+
}, k.path.includes("trackItemIds") ? d.push(S) : k.path.includes("transitionIds") ? b.push(S) : k.path.includes("trackItemsMap") ? p.push(S) : k.path.includes("transitionsMap") ? f.push(S) : k.path.includes("tracks") ? N.push(S) : k.path.includes("trackItemDetailsMap") && g.push(S);
|
|
3262
3266
|
});
|
|
3263
|
-
const
|
|
3267
|
+
const v = this.applyPatch(
|
|
3264
3268
|
E.tracks,
|
|
3265
3269
|
N
|
|
3266
3270
|
), _ = this.applyPatch(
|
|
@@ -3279,7 +3283,7 @@ class Za {
|
|
|
3279
3283
|
E.trackItemDetailsMap,
|
|
3280
3284
|
g
|
|
3281
3285
|
), I = B({
|
|
3282
|
-
tracks:
|
|
3286
|
+
tracks: v,
|
|
3283
3287
|
transitionIds: _,
|
|
3284
3288
|
trackItemIds: y,
|
|
3285
3289
|
transitionsMap: l,
|
|
@@ -3315,23 +3319,23 @@ class Za {
|
|
|
3315
3319
|
trackItemsMap: F
|
|
3316
3320
|
}), N = [], b = [], d = [], f = [], p = [], g = [];
|
|
3317
3321
|
n.forEach((k) => {
|
|
3318
|
-
let
|
|
3322
|
+
let S;
|
|
3319
3323
|
const A = k.path.slice(1);
|
|
3320
|
-
k.type === "CREATE" ?
|
|
3324
|
+
k.type === "CREATE" ? S = {
|
|
3321
3325
|
path: A,
|
|
3322
3326
|
op: "add",
|
|
3323
3327
|
value: k.value
|
|
3324
|
-
} : k.type === "CHANGE" ?
|
|
3328
|
+
} : k.type === "CHANGE" ? S = {
|
|
3325
3329
|
path: A,
|
|
3326
3330
|
op: "replace",
|
|
3327
3331
|
value: k.value
|
|
3328
|
-
} :
|
|
3332
|
+
} : S = {
|
|
3329
3333
|
path: A,
|
|
3330
3334
|
op: "remove",
|
|
3331
3335
|
value: k.oldValue
|
|
3332
|
-
}, k.path.includes("trackItemIds") ? d.push(
|
|
3336
|
+
}, k.path.includes("trackItemIds") ? d.push(S) : k.path.includes("transitionIds") ? b.push(S) : k.path.includes("trackItemsMap") ? p.push(S) : k.path.includes("transitionsMap") ? f.push(S) : k.path.includes("trackItemDetailsMap") ? g.push(S) : N.push(S);
|
|
3333
3337
|
});
|
|
3334
|
-
const
|
|
3338
|
+
const v = this.applyPatch(
|
|
3335
3339
|
E.tracks,
|
|
3336
3340
|
N
|
|
3337
3341
|
), _ = this.applyPatch(
|
|
@@ -3350,7 +3354,7 @@ class Za {
|
|
|
3350
3354
|
E.trackItemDetailsMap,
|
|
3351
3355
|
g
|
|
3352
3356
|
), I = B({
|
|
3353
|
-
tracks:
|
|
3357
|
+
tracks: v,
|
|
3354
3358
|
transitionIds: _,
|
|
3355
3359
|
trackItemIds: y,
|
|
3356
3360
|
transitionsMap: l,
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
(function(x,Q){typeof exports=="object"&&typeof module<"u"?module.exports=Q(require("@designcombo/events")):typeof define=="function"&&define.amd?define(["@designcombo/events"],Q):(x=typeof globalThis<"u"?globalThis:x||self,x.events=Q(x.events))})(this,function(x){"use strict";var Sa=Object.defineProperty;var wa=(x,Q,pt)=>Q in x?Sa(x,Q,{enumerable:!0,configurable:!0,writable:!0,value:pt}):x[Q]=pt;var Nt=(x,Q,pt)=>wa(x,typeof Q!="symbol"?Q+"":Q,pt);var Q=function(t,r){return Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,i){n.__proto__=i}||function(n,i){for(var s in i)Object.prototype.hasOwnProperty.call(i,s)&&(n[s]=i[s])},Q(t,r)};function pt(t,r){if(typeof r!="function"&&r!==null)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");Q(t,r);function n(){this.constructor=t}t.prototype=r===null?Object.create(r):(n.prototype=r.prototype,new n)}function ur(t){var r=typeof Symbol=="function"&&Symbol.iterator,n=r&&t[r],i=0;if(n)return n.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&i>=t.length&&(t=void 0),{value:t&&t[i++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}function lr(t,r){var n=typeof Symbol=="function"&&t[Symbol.iterator];if(!n)return t;var i=n.call(t),s,c=[],h;try{for(;(r===void 0||r-- >0)&&!(s=i.next()).done;)c.push(s.value)}catch(m){h={error:m}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(h)throw h.error}}return c}function fr(t,r,n){if(n||arguments.length===2)for(var i=0,s=r.length,c;i<s;i++)(c||!(i in r))&&(c||(c=Array.prototype.slice.call(r,0,i)),c[i]=r[i]);return t.concat(c||Array.prototype.slice.call(r))}typeof SuppressedError=="function"&&SuppressedError;function _t(t){return typeof t=="function"}function On(t){var r=function(i){Error.call(i),i.stack=new Error().stack},n=t(r);return n.prototype=Object.create(Error.prototype),n.prototype.constructor=n,n}var dr=On(function(t){return function(n){t(this),this.message=n?n.length+` errors occurred during unsubscription:
|
|
2
2
|
`+n.map(function(i,s){return s+1+") "+i.toString()}).join(`
|
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=n}});function pr(t,r){if(t){var n=t.indexOf(r);0<=n&&t.splice(n,1)}}var Me=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,n,i,s,c;if(!this.closed){this.closed=!0;var h=this._parentage;if(h)if(this._parentage=null,Array.isArray(h))try{for(var m=ur(h),C=m.next();!C.done;C=m.next()){var F=C.value;F.remove(this)}}catch(p){r={error:p}}finally{try{C&&!C.done&&(n=m.return)&&n.call(m)}finally{if(r)throw r.error}}else h.remove(this);var E=this.initialTeardown;if(_t(E))try{E()}catch(p){c=p instanceof dr?p.errors:[p]}var L=this._finalizers;if(L){this._finalizers=null;try{for(var b=ur(L),d=b.next();!d.done;d=b.next()){var f=d.value;try{Pn(f)}catch(p){c=c??[],p instanceof dr?c=fr(fr([],lr(c)),lr(p.errors)):c.push(p)}}}catch(p){i={error:p}}finally{try{d&&!d.done&&(s=b.return)&&s.call(b)}finally{if(i)throw i.error}}}if(c)throw new dr(c)}},t.prototype.add=function(r){var n;if(r&&r!==this)if(this.closed)Pn(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(r)}},t.prototype._hasParent=function(r){var n=this._parentage;return n===r||Array.isArray(n)&&n.includes(r)},t.prototype._addParent=function(r){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(r),n):n?[n,r]:r},t.prototype._removeParent=function(r){var n=this._parentage;n===r?this._parentage=null:Array.isArray(n)&&pr(n,r)},t.prototype.remove=function(r){var n=this._finalizers;n&&pr(n,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),xn=Me.EMPTY;function Dn(t){return t instanceof Me||t&&"closed"in t&&_t(t.remove)&&_t(t.add)&&_t(t.unsubscribe)}function Pn(t){_t(t)?t():t.unsubscribe()}var Cn={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},jn={setTimeout:function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return setTimeout.apply(void 0,fr([t,r],lr(n)))},clearTimeout:function(t){var r=jn.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(t)},delegate:void 0};function di(t){jn.setTimeout(function(){throw t})}function Rn(){}function Ae(t){t()}var Fn=function(t){pt(r,t);function r(n){var i=t.call(this)||this;return i.isStopped=!1,n?(i.destination=n,Dn(n)&&n.add(i)):i.destination=yi,i}return r.create=function(n,i,s){return new mr(n,i,s)},r.prototype.next=function(n){this.isStopped||this._next(n)},r.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(n){this.destination.next(n)},r.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(Me),pi=Function.prototype.bind;function hr(t,r){return pi.call(t,r)}var hi=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var n=this.partialObserver;if(n.next)try{n.next(r)}catch(i){Oe(i)}},t.prototype.error=function(r){var n=this.partialObserver;if(n.error)try{n.error(r)}catch(i){Oe(i)}else Oe(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(n){Oe(n)}},t}(),mr=function(t){pt(r,t);function r(n,i,s){var c=t.call(this)||this,h;if(_t(n)||!n)h={next:n??void 0,error:i??void 0,complete:s??void 0};else{var m;c&&Cn.useDeprecatedNextContext?(m=Object.create(n),m.unsubscribe=function(){return c.unsubscribe()},h={next:n.next&&hr(n.next,m),error:n.error&&hr(n.error,m),complete:n.complete&&hr(n.complete,m)}):h=n}return c.destination=new hi(h),c}return r}(Fn);function Oe(t){di(t)}function mi(t){throw t}var yi={closed:!0,next:Rn,error:mi,complete:Rn},bi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function gi(t){return t}function _i(t){return t.length===0?gi:t.length===1?t[0]:function(n){return t.reduce(function(i,s){return s(i)},n)}}var zn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var n=new t;return n.source=this,n.operator=r,n},t.prototype.subscribe=function(r,n,i){var s=this,c=vi(r)?r:new mr(r,n,i);return Ae(function(){var h=s,m=h.operator,C=h.source;c.add(m?m.call(c,C):C?s._subscribe(c):s._trySubscribe(c))}),c},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(n){r.error(n)}},t.prototype.forEach=function(r,n){var i=this;return n=Hn(n),new n(function(s,c){var h=new mr({next:function(m){try{r(m)}catch(C){c(C),h.unsubscribe()}},error:c,complete:s});i.subscribe(h)})},t.prototype._subscribe=function(r){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(r)},t.prototype[bi]=function(){return this},t.prototype.pipe=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return _i(r)(this)},t.prototype.toPromise=function(r){var n=this;return r=Hn(r),new r(function(i,s){var c;n.subscribe(function(h){return c=h},function(h){return s(h)},function(){return i(c)})})},t.create=function(r){return new t(r)},t}();function Hn(t){var r;return(r=t??Cn.Promise)!==null&&r!==void 0?r:Promise}function Ii(t){return t&&_t(t.next)&&_t(t.error)&&_t(t.complete)}function vi(t){return t&&t instanceof Fn||Ii(t)&&Dn(t)}var Si=On(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Nn=function(t){pt(r,t);function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return r.prototype.lift=function(n){var i=new Ln(this,this);return i.operator=n,i},r.prototype._throwIfClosed=function(){if(this.closed)throw new Si},r.prototype.next=function(n){var i=this;Ae(function(){var s,c;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var h=ur(i.currentObservers),m=h.next();!m.done;m=h.next()){var C=m.value;C.next(n)}}catch(F){s={error:F}}finally{try{m&&!m.done&&(c=h.return)&&c.call(h)}finally{if(s)throw s.error}}}})},r.prototype.error=function(n){var i=this;Ae(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=n;for(var s=i.observers;s.length;)s.shift().error(n)}})},r.prototype.complete=function(){var n=this;Ae(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var i=n.observers;i.length;)i.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},r.prototype._innerSubscribe=function(n){var i=this,s=this,c=s.hasError,h=s.isStopped,m=s.observers;return c||h?xn:(this.currentObservers=null,m.push(n),new Me(function(){i.currentObservers=null,pr(m,n)}))},r.prototype._checkFinalizedStatuses=function(n){var i=this,s=i.hasError,c=i.thrownError,h=i.isStopped;s?n.error(c):h&&n.complete()},r.prototype.asObservable=function(){var n=new zn;return n.source=this,n},r.create=function(n,i){return new Ln(n,i)},r}(zn),Ln=function(t){pt(r,t);function r(n,i){var s=t.call(this)||this;return s.destination=n,s.source=i,s}return r.prototype.next=function(n){var i,s;(s=(i=this.destination)===null||i===void 0?void 0:i.next)===null||s===void 0||s.call(i,n)},r.prototype.error=function(n){var i,s;(s=(i=this.destination)===null||i===void 0?void 0:i.error)===null||s===void 0||s.call(i,n)},r.prototype.complete=function(){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||i===void 0||i.call(n)},r.prototype._subscribe=function(n){var i,s;return(s=(i=this.source)===null||i===void 0?void 0:i.subscribe(n))!==null&&s!==void 0?s:xn},r}(Nn),Un=function(t){pt(r,t);function r(n){var i=t.call(this)||this;return i._value=n,i}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var i=t.prototype._subscribe.call(this,n);return!i.closed&&n.next(this._value),i},r.prototype.getValue=function(){var n=this,i=n.hasError,s=n.thrownError,c=n._value;if(i)throw s;return this._throwIfClosed(),c},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(Nn),ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xe={exports:{}};xe.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",s=1,c=2,h=9007199254740991,m="[object Arguments]",C="[object Array]",F="[object AsyncFunction]",E="[object Boolean]",L="[object Date]",b="[object Error]",d="[object Function]",f="[object GeneratorFunction]",p="[object Map]",g="[object Number]",S="[object Null]",_="[object Object]",y="[object Promise]",l="[object Proxy]",D="[object RegExp]",M="[object Set]",I="[object String]",j="[object Symbol]",w="[object Undefined]",P="[object WeakMap]",k="[object ArrayBuffer]",v="[object DataView]",A="[object Float32Array]",O="[object Float64Array]",tt="[object Int8Array]",X="[object Int16Array]",ht="[object Int32Array]",se="[object Uint8Array]",oe="[object Uint8ClampedArray]",U="[object Uint16Array]",Hr="[object Uint32Array]",Nr=/[\\^$.*+?()[\]{}|]/g,ut=/^\[object .+?Constructor\]$/,He=/^(?:0|[1-9]\d*)$/,W={};W[A]=W[O]=W[tt]=W[X]=W[ht]=W[se]=W[oe]=W[U]=W[Hr]=!0,W[m]=W[C]=W[k]=W[E]=W[v]=W[L]=W[b]=W[d]=W[p]=W[g]=W[_]=W[D]=W[M]=W[I]=W[P]=!1;var Ne=typeof ot=="object"&&ot&&ot.Object===Object&&ot,Lr=typeof self=="object"&&self&&self.Object===Object&&self,lt=Ne||Lr||Function("return this")(),Le=r&&!r.nodeType&&r,Ue=Le&&!0&&t&&!t.nodeType&&t,ce=Ue&&Ue.exports===Le,ue=ce&&Ne.process,We=function(){try{return ue&&ue.binding&&ue.binding("util")}catch{}}(),le=We&&We.isTypedArray;function Ge(e,a){for(var o=-1,u=e==null?0:e.length,R=0,T=[];++o<u;){var H=e[o];a(H,o,e)&&(T[R++]=H)}return T}function fe(e,a){for(var o=-1,u=a.length,R=e.length;++o<u;)e[R+o]=a[o];return e}function Be(e,a){for(var o=-1,u=e==null?0:e.length;++o<u;)if(a(e[o],o,e))return!0;return!1}function Ur(e,a){for(var o=-1,u=Array(e);++o<e;)u[o]=a(o);return u}function Wr(e){return function(a){return e(a)}}function Ut(e,a){return e.has(a)}function de(e,a){return e==null?void 0:e[a]}function $e(e){var a=-1,o=Array(e.size);return e.forEach(function(u,R){o[++a]=[R,u]}),o}function Ke(e,a){return function(o){return e(a(o))}}function mt(e){var a=-1,o=Array(e.size);return e.forEach(function(u){o[++a]=u}),o}var Wt=Array.prototype,Gr=Function.prototype,Pt=Object.prototype,Gt=lt["__core-js_shared__"],pe=Gr.toString,ct=Pt.hasOwnProperty,Ye=function(){var e=/[^.]+$/.exec(Gt&&Gt.keys&&Gt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ve=Pt.toString,Br=RegExp("^"+pe.call(ct).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),he=ce?lt.Buffer:void 0,Bt=lt.Symbol,Xe=lt.Uint8Array,$t=Pt.propertyIsEnumerable,Ct=Wt.splice,ft=Bt?Bt.toStringTag:void 0,Kt=Object.getOwnPropertySymbols,me=he?he.isBuffer:void 0,jt=Ke(Object.keys,Object),ye=vt(lt,"DataView"),Rt=vt(lt,"Map"),be=vt(lt,"Promise"),ge=vt(lt,"Set"),_e=vt(lt,"WeakMap"),Tt=vt(Object,"create"),qe=et(ye),It=et(Rt),$r=et(be),Kr=et(ge),Yr=et(_e),Ze=Bt?Bt.prototype:void 0,Ie=Ze?Ze.valueOf:void 0;function Y(e){var a=-1,o=e==null?0:e.length;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Vr(){this.__data__=Tt?Tt(null):{},this.size=0}function Xr(e){var a=this.has(e)&&delete this.__data__[e];return this.size-=a?1:0,a}function qr(e){var a=this.__data__;if(Tt){var o=a[e];return o===i?void 0:o}return ct.call(a,e)?a[e]:void 0}function Zr(e){var a=this.__data__;return Tt?a[e]!==void 0:ct.call(a,e)}function Jr(e,a){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=Tt&&a===void 0?i:a,this}Y.prototype.clear=Vr,Y.prototype.delete=Xr,Y.prototype.get=qr,Y.prototype.has=Zr,Y.prototype.set=Jr;function q(e){var a=-1,o=e==null?0:e.length;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Qr(){this.__data__=[],this.size=0}function tn(e){var a=this.__data__,o=Xt(a,e);if(o<0)return!1;var u=a.length-1;return o==u?a.pop():Ct.call(a,o,1),--this.size,!0}function en(e){var a=this.__data__,o=Xt(a,e);return o<0?void 0:a[o][1]}function rn(e){return Xt(this.__data__,e)>-1}function nn(e,a){var o=this.__data__,u=Xt(o,e);return u<0?(++this.size,o.push([e,a])):o[u][1]=a,this}q.prototype.clear=Qr,q.prototype.delete=tn,q.prototype.get=en,q.prototype.has=rn,q.prototype.set=nn;function rt(e){var a=-1,o=e==null?0:e.length;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function an(){this.size=0,this.__data__={hash:new Y,map:new(Rt||q),string:new Y}}function sn(e){var a=dt(this,e).delete(e);return this.size-=a?1:0,a}function on(e){return dt(this,e).get(e)}function cn(e){return dt(this,e).has(e)}function un(e,a){var o=dt(this,e),u=o.size;return o.set(e,a),this.size+=o.size==u?0:1,this}rt.prototype.clear=an,rt.prototype.delete=sn,rt.prototype.get=on,rt.prototype.has=cn,rt.prototype.set=un;function Yt(e){var a=-1,o=e==null?0:e.length;for(this.__data__=new rt;++a<o;)this.add(e[a])}function Je(e){return this.__data__.set(e,i),this}function Vt(e){return this.__data__.has(e)}Yt.prototype.add=Yt.prototype.push=Je,Yt.prototype.has=Vt;function yt(e){var a=this.__data__=new q(e);this.size=a.size}function ve(){this.__data__=new q,this.size=0}function ln(e){var a=this.__data__,o=a.delete(e);return this.size=a.size,o}function fn(e){return this.__data__.get(e)}function dn(e){return this.__data__.has(e)}function pn(e,a){var o=this.__data__;if(o instanceof q){var u=o.__data__;if(!Rt||u.length<n-1)return u.push([e,a]),this.size=++o.size,this;o=this.__data__=new rt(u)}return o.set(e,a),this.size=o.size,this}yt.prototype.clear=ve,yt.prototype.delete=ln,yt.prototype.get=fn,yt.prototype.has=dn,yt.prototype.set=pn;function hn(e,a){var o=qt(e),u=!o&&nr(e),R=!o&&!u&&Zt(e),T=!o&&!u&&!R&&sr(e),H=o||u||R||T,z=H?Ur(e.length,String):[],G=z.length;for(var N in e)ct.call(e,N)&&!(H&&(N=="length"||R&&(N=="offset"||N=="parent")||T&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||Sn(N,G)))&&z.push(N);return z}function Xt(e,a){for(var o=e.length;o--;)if(rr(e[o][0],a))return o;return-1}function Se(e,a,o){var u=a(e);return qt(e)?u:fe(u,o(e))}function Ft(e){return e==null?e===void 0?w:S:ft&&ft in Object(e)?St(e):er(e)}function Qe(e){return gt(e)&&Ft(e)==m}function tr(e,a,o,u,R){return e===a?!0:e==null||a==null||!gt(e)&&!gt(a)?e!==e&&a!==a:mn(e,a,o,u,tr,R)}function mn(e,a,o,u,R,T){var H=qt(e),z=qt(a),G=H?C:bt(e),N=z?C:bt(a);G=G==m?_:G,N=N==m?_:N;var Z=G==_,nt=N==_,K=G==N;if(K&&Zt(e)){if(!Zt(a))return!1;H=!0,Z=!1}if(K&&!Z)return T||(T=new yt),H||sr(e)?we(e,a,o,u,R,T):_n(e,a,G,o,u,R,T);if(!(o&s)){var J=Z&&ct.call(e,"__wrapped__"),V=nt&&ct.call(a,"__wrapped__");if(J||V){var Et=J?e.value():e,wt=V?a.value():a;return T||(T=new yt),R(Et,wt,o,u,T)}}return K?(T||(T=new yt),In(e,a,o,u,R,T)):!1}function yn(e){if(!ar(e)||kn(e))return!1;var a=ir(e)?Br:ut;return a.test(et(e))}function bn(e){return gt(e)&&Te(e.length)&&!!W[Ft(e)]}function gn(e){if(!Tn(e))return jt(e);var a=[];for(var o in Object(e))ct.call(e,o)&&o!="constructor"&&a.push(o);return a}function we(e,a,o,u,R,T){var H=o&s,z=e.length,G=a.length;if(z!=G&&!(H&&G>z))return!1;var N=T.get(e);if(N&&T.get(a))return N==a;var Z=-1,nt=!0,K=o&c?new Yt:void 0;for(T.set(e,a),T.set(a,e);++Z<z;){var J=e[Z],V=a[Z];if(u)var Et=H?u(V,J,Z,a,e,T):u(J,V,Z,e,a,T);if(Et!==void 0){if(Et)continue;nt=!1;break}if(K){if(!Be(a,function(wt,Ht){if(!Ut(K,Ht)&&(J===wt||R(J,wt,o,u,T)))return K.push(Ht)})){nt=!1;break}}else if(!(J===V||R(J,V,o,u,T))){nt=!1;break}}return T.delete(e),T.delete(a),nt}function _n(e,a,o,u,R,T,H){switch(o){case v:if(e.byteLength!=a.byteLength||e.byteOffset!=a.byteOffset)return!1;e=e.buffer,a=a.buffer;case k:return!(e.byteLength!=a.byteLength||!T(new Xe(e),new Xe(a)));case E:case L:case g:return rr(+e,+a);case b:return e.name==a.name&&e.message==a.message;case D:case I:return e==a+"";case p:var z=$e;case M:var G=u&s;if(z||(z=mt),e.size!=a.size&&!G)return!1;var N=H.get(e);if(N)return N==a;u|=c,H.set(e,a);var Z=we(z(e),z(a),u,R,T,H);return H.delete(e),Z;case j:if(Ie)return Ie.call(e)==Ie.call(a)}return!1}function In(e,a,o,u,R,T){var H=o&s,z=zt(e),G=z.length,N=zt(a),Z=N.length;if(G!=Z&&!H)return!1;for(var nt=G;nt--;){var K=z[nt];if(!(H?K in a:ct.call(a,K)))return!1}var J=T.get(e);if(J&&T.get(a))return J==a;var V=!0;T.set(e,a),T.set(a,e);for(var Et=H;++nt<G;){K=z[nt];var wt=e[K],Ht=a[K];if(u)var fi=H?u(Ht,wt,K,a,e,T):u(wt,Ht,K,e,a,T);if(!(fi===void 0?wt===Ht||R(wt,Ht,o,u,T):fi)){V=!1;break}Et||(Et=K=="constructor")}if(V&&!Et){var or=e.constructor,cr=a.constructor;or!=cr&&"constructor"in e&&"constructor"in a&&!(typeof or=="function"&&or instanceof or&&typeof cr=="function"&&cr instanceof cr)&&(V=!1)}return T.delete(e),T.delete(a),V}function zt(e){return Se(e,Ee,vn)}function dt(e,a){var o=e.__data__;return wn(a)?o[typeof a=="string"?"string":"hash"]:o.map}function vt(e,a){var o=de(e,a);return yn(o)?o:void 0}function St(e){var a=ct.call(e,ft),o=e[ft];try{e[ft]=void 0;var u=!0}catch{}var R=Ve.call(e);return u&&(a?e[ft]=o:delete e[ft]),R}var vn=Kt?function(e){return e==null?[]:(e=Object(e),Ge(Kt(e),function(a){return $t.call(e,a)}))}:Mn,bt=Ft;(ye&&bt(new ye(new ArrayBuffer(1)))!=v||Rt&&bt(new Rt)!=p||be&&bt(be.resolve())!=y||ge&&bt(new ge)!=M||_e&&bt(new _e)!=P)&&(bt=function(e){var a=Ft(e),o=a==_?e.constructor:void 0,u=o?et(o):"";if(u)switch(u){case qe:return v;case It:return p;case $r:return y;case Kr:return M;case Yr:return P}return a});function Sn(e,a){return a=a??h,!!a&&(typeof e=="number"||He.test(e))&&e>-1&&e%1==0&&e<a}function wn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function kn(e){return!!Ye&&Ye in e}function Tn(e){var a=e&&e.constructor,o=typeof a=="function"&&a.prototype||Pt;return e===o}function er(e){return Ve.call(e)}function et(e){if(e!=null){try{return pe.call(e)}catch{}try{return e+""}catch{}}return""}function rr(e,a){return e===a||e!==e&&a!==a}var nr=Qe(function(){return arguments}())?Qe:function(e){return gt(e)&&ct.call(e,"callee")&&!$t.call(e,"callee")},qt=Array.isArray;function ke(e){return e!=null&&Te(e.length)&&!ir(e)}var Zt=me||An;function En(e,a){return tr(e,a)}function ir(e){if(!ar(e))return!1;var a=Ft(e);return a==d||a==f||a==F||a==l}function Te(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=h}function ar(e){var a=typeof e;return e!=null&&(a=="object"||a=="function")}function gt(e){return e!=null&&typeof e=="object"}var sr=le?Wr(le):bn;function Ee(e){return ke(e)?hn(e):gn(e)}function Mn(){return[]}function An(){return!1}t.exports=En}(xe,xe.exports);var wi=xe.exports;const it=yr(wi);var De={exports:{}};De.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",s=9007199254740991,c="[object Arguments]",h="[object Array]",m="[object Boolean]",C="[object Date]",F="[object Error]",E="[object Function]",L="[object GeneratorFunction]",b="[object Map]",d="[object Number]",f="[object Object]",p="[object Promise]",g="[object RegExp]",S="[object Set]",_="[object String]",y="[object Symbol]",l="[object WeakMap]",D="[object ArrayBuffer]",M="[object DataView]",I="[object Float32Array]",j="[object Float64Array]",w="[object Int8Array]",P="[object Int16Array]",k="[object Int32Array]",v="[object Uint8Array]",A="[object Uint8ClampedArray]",O="[object Uint16Array]",tt="[object Uint32Array]",X=/[\\^$.*+?()[\]{}|]/g,ht=/\w*$/,se=/^\[object .+?Constructor\]$/,oe=/^(?:0|[1-9]\d*)$/,U={};U[c]=U[h]=U[D]=U[M]=U[m]=U[C]=U[I]=U[j]=U[w]=U[P]=U[k]=U[b]=U[d]=U[f]=U[g]=U[S]=U[_]=U[y]=U[v]=U[A]=U[O]=U[tt]=!0,U[F]=U[E]=U[l]=!1;var Hr=typeof ot=="object"&&ot&&ot.Object===Object&&ot,Nr=typeof self=="object"&&self&&self.Object===Object&&self,ut=Hr||Nr||Function("return this")(),He=r&&!r.nodeType&&r,W=He&&!0&&t&&!t.nodeType&&t,Ne=W&&W.exports===He;function Lr(e,a){return e.set(a[0],a[1]),e}function lt(e,a){return e.add(a),e}function Le(e,a){for(var o=-1,u=e?e.length:0;++o<u&&a(e[o],o,e)!==!1;);return e}function Ue(e,a){for(var o=-1,u=a.length,R=e.length;++o<u;)e[R+o]=a[o];return e}function ce(e,a,o,u){for(var R=-1,T=e?e.length:0;++R<T;)o=a(o,e[R],R,e);return o}function ue(e,a){for(var o=-1,u=Array(e);++o<e;)u[o]=a(o);return u}function We(e,a){return e==null?void 0:e[a]}function le(e){var a=!1;if(e!=null&&typeof e.toString!="function")try{a=!!(e+"")}catch{}return a}function Ge(e){var a=-1,o=Array(e.size);return e.forEach(function(u,R){o[++a]=[R,u]}),o}function fe(e,a){return function(o){return e(a(o))}}function Be(e){var a=-1,o=Array(e.size);return e.forEach(function(u){o[++a]=u}),o}var Ur=Array.prototype,Wr=Function.prototype,Ut=Object.prototype,de=ut["__core-js_shared__"],$e=function(){var e=/[^.]+$/.exec(de&&de.keys&&de.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ke=Wr.toString,mt=Ut.hasOwnProperty,Wt=Ut.toString,Gr=RegExp("^"+Ke.call(mt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Pt=Ne?ut.Buffer:void 0,Gt=ut.Symbol,pe=ut.Uint8Array,ct=fe(Object.getPrototypeOf,Object),Ye=Object.create,Ve=Ut.propertyIsEnumerable,Br=Ur.splice,he=Object.getOwnPropertySymbols,Bt=Pt?Pt.isBuffer:void 0,Xe=fe(Object.keys,Object),$t=dt(ut,"DataView"),Ct=dt(ut,"Map"),ft=dt(ut,"Promise"),Kt=dt(ut,"Set"),me=dt(ut,"WeakMap"),jt=dt(Object,"create"),ye=et($t),Rt=et(Ct),be=et(ft),ge=et(Kt),_e=et(me),Tt=Gt?Gt.prototype:void 0,qe=Tt?Tt.valueOf:void 0;function It(e){var a=-1,o=e?e.length:0;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function $r(){this.__data__=jt?jt(null):{}}function Kr(e){return this.has(e)&&delete this.__data__[e]}function Yr(e){var a=this.__data__;if(jt){var o=a[e];return o===i?void 0:o}return mt.call(a,e)?a[e]:void 0}function Ze(e){var a=this.__data__;return jt?a[e]!==void 0:mt.call(a,e)}function Ie(e,a){var o=this.__data__;return o[e]=jt&&a===void 0?i:a,this}It.prototype.clear=$r,It.prototype.delete=Kr,It.prototype.get=Yr,It.prototype.has=Ze,It.prototype.set=Ie;function Y(e){var a=-1,o=e?e.length:0;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Vr(){this.__data__=[]}function Xr(e){var a=this.__data__,o=Vt(a,e);if(o<0)return!1;var u=a.length-1;return o==u?a.pop():Br.call(a,o,1),!0}function qr(e){var a=this.__data__,o=Vt(a,e);return o<0?void 0:a[o][1]}function Zr(e){return Vt(this.__data__,e)>-1}function Jr(e,a){var o=this.__data__,u=Vt(o,e);return u<0?o.push([e,a]):o[u][1]=a,this}Y.prototype.clear=Vr,Y.prototype.delete=Xr,Y.prototype.get=qr,Y.prototype.has=Zr,Y.prototype.set=Jr;function q(e){var a=-1,o=e?e.length:0;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Qr(){this.__data__={hash:new It,map:new(Ct||Y),string:new It}}function tn(e){return zt(this,e).delete(e)}function en(e){return zt(this,e).get(e)}function rn(e){return zt(this,e).has(e)}function nn(e,a){return zt(this,e).set(e,a),this}q.prototype.clear=Qr,q.prototype.delete=tn,q.prototype.get=en,q.prototype.has=rn,q.prototype.set=nn;function rt(e){this.__data__=new Y(e)}function an(){this.__data__=new Y}function sn(e){return this.__data__.delete(e)}function on(e){return this.__data__.get(e)}function cn(e){return this.__data__.has(e)}function un(e,a){var o=this.__data__;if(o instanceof Y){var u=o.__data__;if(!Ct||u.length<n-1)return u.push([e,a]),this;o=this.__data__=new q(u)}return o.set(e,a),this}rt.prototype.clear=an,rt.prototype.delete=sn,rt.prototype.get=on,rt.prototype.has=cn,rt.prototype.set=un;function Yt(e,a){var o=ke(e)||qt(e)?ue(e.length,String):[],u=o.length,R=!!u;for(var T in e)mt.call(e,T)&&!(R&&(T=="length"||wn(T,u)))&&o.push(T);return o}function Je(e,a,o){var u=e[a];(!(mt.call(e,a)&&nr(u,o))||o===void 0&&!(a in e))&&(e[a]=o)}function Vt(e,a){for(var o=e.length;o--;)if(nr(e[o][0],a))return o;return-1}function yt(e,a){return e&&we(a,Ee(a),e)}function ve(e,a,o,u,R,T,H){var z;if(u&&(z=T?u(e,R,T,H):u(e)),z!==void 0)return z;if(!gt(e))return e;var G=ke(e);if(G){if(z=vn(e),!a)return gn(e,z)}else{var N=St(e),Z=N==E||N==L;if(ir(e))return Xt(e,a);if(N==f||N==c||Z&&!T){if(le(e))return T?e:{};if(z=bt(Z?{}:e),!a)return _n(e,yt(z,e))}else{if(!U[N])return T?e:{};z=Sn(e,N,ve,a)}}H||(H=new rt);var nt=H.get(e);if(nt)return nt;if(H.set(e,z),!G)var K=o?In(e):Ee(e);return Le(K||e,function(J,V){K&&(V=J,J=e[V]),Je(z,V,ve(J,a,o,u,V,e,H))}),z}function ln(e){return gt(e)?Ye(e):{}}function fn(e,a,o){var u=a(e);return ke(e)?u:Ue(u,o(e))}function dn(e){return Wt.call(e)}function pn(e){if(!gt(e)||Tn(e))return!1;var a=Te(e)||le(e)?Gr:se;return a.test(et(e))}function hn(e){if(!er(e))return Xe(e);var a=[];for(var o in Object(e))mt.call(e,o)&&o!="constructor"&&a.push(o);return a}function Xt(e,a){if(a)return e.slice();var o=new e.constructor(e.length);return e.copy(o),o}function Se(e){var a=new e.constructor(e.byteLength);return new pe(a).set(new pe(e)),a}function Ft(e,a){var o=a?Se(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}function Qe(e,a,o){var u=a?o(Ge(e),!0):Ge(e);return ce(u,Lr,new e.constructor)}function tr(e){var a=new e.constructor(e.source,ht.exec(e));return a.lastIndex=e.lastIndex,a}function mn(e,a,o){var u=a?o(Be(e),!0):Be(e);return ce(u,lt,new e.constructor)}function yn(e){return qe?Object(qe.call(e)):{}}function bn(e,a){var o=a?Se(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}function gn(e,a){var o=-1,u=e.length;for(a||(a=Array(u));++o<u;)a[o]=e[o];return a}function we(e,a,o,u){o||(o={});for(var R=-1,T=a.length;++R<T;){var H=a[R],z=void 0;Je(o,H,z===void 0?e[H]:z)}return o}function _n(e,a){return we(e,vt(e),a)}function In(e){return fn(e,Ee,vt)}function zt(e,a){var o=e.__data__;return kn(a)?o[typeof a=="string"?"string":"hash"]:o.map}function dt(e,a){var o=We(e,a);return pn(o)?o:void 0}var vt=he?fe(he,Object):Mn,St=dn;($t&&St(new $t(new ArrayBuffer(1)))!=M||Ct&&St(new Ct)!=b||ft&&St(ft.resolve())!=p||Kt&&St(new Kt)!=S||me&&St(new me)!=l)&&(St=function(e){var a=Wt.call(e),o=a==f?e.constructor:void 0,u=o?et(o):void 0;if(u)switch(u){case ye:return M;case Rt:return b;case be:return p;case ge:return S;case _e:return l}return a});function vn(e){var a=e.length,o=e.constructor(a);return a&&typeof e[0]=="string"&&mt.call(e,"index")&&(o.index=e.index,o.input=e.input),o}function bt(e){return typeof e.constructor=="function"&&!er(e)?ln(ct(e)):{}}function Sn(e,a,o,u){var R=e.constructor;switch(a){case D:return Se(e);case m:case C:return new R(+e);case M:return Ft(e,u);case I:case j:case w:case P:case k:case v:case A:case O:case tt:return bn(e,u);case b:return Qe(e,u,o);case d:case _:return new R(e);case g:return tr(e);case S:return mn(e,u,o);case y:return yn(e)}}function wn(e,a){return a=a??s,!!a&&(typeof e=="number"||oe.test(e))&&e>-1&&e%1==0&&e<a}function kn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function Tn(e){return!!$e&&$e in e}function er(e){var a=e&&e.constructor,o=typeof a=="function"&&a.prototype||Ut;return e===o}function et(e){if(e!=null){try{return Ke.call(e)}catch{}try{return e+""}catch{}}return""}function rr(e){return ve(e,!0,!0)}function nr(e,a){return e===a||e!==e&&a!==a}function qt(e){return En(e)&&mt.call(e,"callee")&&(!Ve.call(e,"callee")||Wt.call(e)==c)}var ke=Array.isArray;function Zt(e){return e!=null&&ar(e.length)&&!Te(e)}function En(e){return sr(e)&&Zt(e)}var ir=Bt||An;function Te(e){var a=gt(e)?Wt.call(e):"";return a==E||a==L}function ar(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=s}function gt(e){var a=typeof e;return!!e&&(a=="object"||a=="function")}function sr(e){return!!e&&typeof e=="object"}function Ee(e){return Zt(e)?Yt(e):hn(e)}function Mn(){return[]}function An(){return!1}t.exports=rr}(De,De.exports);var ki=De.exports;const B=yr(ki),Wn=t=>new Promise((r,n)=>{const i=new Image;console.warn("update cdn config for cors?"),i.onload=()=>{const s=i.width,c=i.height;r({width:s,height:c})},i.onerror=s=>{n(s)},i.crossOrigin="anonymous",i.src=t}),Ti=t=>new Promise((r,n)=>{const i=new Audio;i.preload="auto",i.addEventListener("loadedmetadata",()=>{const s=i.duration*1e3;r({duration:s})}),i.addEventListener("error",s=>{n(s)}),i.src=t,i.crossOrigin="anonymous",i.load()}),Gn=t=>new Promise((r,n)=>{const i=document.createElement("video");i.preload="auto",i.addEventListener("loadedmetadata",()=>{const s=i.duration*1e3,c=i.videoWidth,h=i.videoHeight;r({duration:s,width:c,height:h})}),i.addEventListener("error",s=>{n(s)}),i.src=t,i.load()}),Bn=(t,r)=>{const n=document.createElement("div");Object.keys(r).forEach(s=>{s!=="height"&&(n.style[s]=r[s])}),document.body.appendChild(n),n.textContent=t,n.style.whiteSpace="normal",n.style.position="absolute",n.style.visibility="hidden",n.style.display="inline-block",n.style.width=r.width+"px",n.style.fontSize=r.fontSize+"px";const i=getComputedStyle(n).height;return document.body.removeChild(n),parseFloat(i)},br=t=>{const r=t.map(n=>new FontFace(n.fontFamily,`url(${n.url})`).load().catch(i=>i));return r.length===0?Promise.resolve(!0):new Promise((n,i)=>{Promise.all(r).then(s=>{s.forEach(c=>{c&&c.family&&(document.fonts.add(c),n(!0))})}).catch(s=>i(s))})},Pe={color:"#000000",x:0,y:0,blur:0},Jt=(t,r)=>{let n=r!=null&&r.trim?r.trim.to-r.trim.from:(r==null?void 0:r.duration)||5e3;const i={from:0,to:n};if(!t)return i;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),i;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+n};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),i;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),i}return t},$n=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function Ce(t,r){const n={x:t.size.width/2,y:t.size.height/2},i={x:r.width/2,y:r.height/2},s=Math.min(t.size.width/r.width,t.size.height/r.height),c=n.x-i.x;return{top:`${n.y-i.y}px`,left:`${c}px`,transform:`scale(${s})`}}const gr=async(t,r)=>{const n=t.details.src,i=await Gn(n),s=Ce(r,{...i}),c=$n(t.trim,{duration:i.duration}),h={width:i.width,height:i.height,opacity:100,src:n,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||Pe,top:t.details.top||s.top||"0px",left:t.details.left||s.left||"0px",transform:t.details.transform||s.transform,blur:t.details.blur||0,brightness:t.details.brightness||100,flipX:t.details.flipX||!1,flipY:t.details.flipY||!1,rotate:t.details.rotate||"0deg",visibility:t.details.visibility||"visible",mediaWidth:t.details.mediaWidth||i.width||100,mediaHeight:t.details.mediaHeight||i.height||100};return{...t,trim:c,type:"video",name:"video",details:h,playbackRate:t.playbackRate||1,display:Jt(t.display,{duration:i.duration,trim:c}),duration:i.duration}},_r=async t=>{console.log({payload:t});const r=t.id,n=t.details,i=await Ti(n.src);console.log({audioData:i});const s=i.duration,c=$n(t.trim,{duration:s});return{id:r,name:"",type:"audio",display:Jt(t.display,{duration:s,trim:c}),trim:c,playbackRate:t.playbackRate||1,details:{src:n.src,volume:n.volume??100},metadata:{...t.metadata},duration:s}},Ei=async(t,r)=>{const n=t.trackItemsIds,i=t.size,s=Math.min(r.size.width/i.width,r.size.height/i.height),c=t.rotate||0,h=t.position,m=t.display,C=t.trim||t.display;let F=1/0,E=0;const L=n.map(d=>{const f=t.trackItemsMap[d],p=t.trackItemsDetails[d];if(f.display.from<F&&(F=f.display.from),f.display.to>E&&(E=f.display.to),f.type==="text")return Sr({...f,details:p.details},{size:i});if(f.type==="image")return Ir({...f,details:p.details},{size:i});if(f.type==="video")return gr({...f,details:p.details},{size:i});if(f.type==="audio")return _r({...f,details:p.details});if(f.type==="caption")return vr({...f,details:p.details},{size:i})}),b=await Promise.all(L);return{id:t.id,details:b,size:i,position:{top:h.top||0,left:h.left||0},trim:C,scale:s,display:m||{from:F,to:E},rotate:c,activeEdit:!1}},Ir=async(t,r)=>{const n=t.details,i=await Wn(n.src),s=Ce(r,i);return{id:t.id,type:"image",name:"image",display:Jt(t.display),playbackRate:t.playbackRate||1,details:{src:n.src||"",width:n.width||i.width||100,height:n.height||i.height||100,opacity:n.opacity??100,transform:n.transform||s.transform,border:n.border||"none",borderRadius:n.borderRadius||0,boxShadow:n.boxShadow||Pe,top:n.top||s.top||"0px",left:n.left||s.left||"0px",borderWidth:n.borderWidth??0,borderColor:n.borderColor||"#000000",blur:n.blur||0,brightness:n.brightness||100,flipX:n.flipX||!1,flipY:n.flipY||!1,rotate:n.rotate||"0deg",visibility:n.visibility||"visible",mediaWidth:n.mediaWidth||n.width||i.width||100,mediaHeight:n.mediaHeight||n.height||i.height||100},metadata:t.metadata||{}}},vr=async(t,r)=>{const n=t;n.details.fontUrl&&await br([{fontFamily:n.details.fontFamily,url:n.details.fontUrl}]);const i=n.id,s=n.details,c=Kn(s),h=Bn(n.details.text,c),m=Ce(r,{width:c.width,height:h});return{id:i,name:"caption",type:"caption",display:Jt(n.display),details:{...c,text:s.text||"",height:h,fontUrl:s.fontUrl,top:c.top||m.top,left:c.left||m.left,borderWidth:s.borderWidth||0,borderColor:s.borderColor||"#000000",boxShadow:s.boxShadow||Pe,words:s.words||[]},metadata:{}}},Sr=async(t,r)=>{t.details.fontUrl&&await br([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const n=t.id,i=t.details,s=Kn(i),c=Bn(t.details.text,s),h=Ce(r,{width:s.width,height:c});return{id:n,name:"text",type:"text",display:Jt(t.display),details:{...s,text:i.text||"",height:c,fontUrl:i.fontUrl,top:s.top||h.top,left:s.left||h.left,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",boxShadow:i.boxShadow||Pe},metadata:{}}},Kn=t=>({fontFamily:t.fontFamily||"Arial",fontSize:t.fontSize||"16px",fontWeight:t.fontWeight||"normal",fontStyle:t.fontStyle||"normal",textDecoration:t.textDecoration||"none",textAlign:t.textAlign||"left",lineHeight:t.lineHeight||"normal",letterSpacing:t.letterSpacing||"normal",wordSpacing:t.wordSpacing||"normal",color:t.color||"#ffffff",backgroundColor:t.backgroundColor||"transparent",border:t.border||"none",textShadow:t.textShadow||"none",text:t.text||"",opacity:t.opacity??100,width:t.width||300,wordWrap:t.wordWrap||"normal",wordBreak:t.wordBreak||"normal",WebkitTextStrokeColor:t.WebkitTextStrokeColor||"#ffffff",WebkitTextStrokeWidth:t.WebkitTextStrokeWidth||"0px",top:t.top,left:t.left,textTransform:t.textTransform||"none",transform:t.transform||"none"}),Mi="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let je=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)r+=Mi[n[t]&63];return r};function Ai(t,r){return t.filter(i=>{if(r.forEach(s=>{i.items.includes(s)&&(i.items=i.items.filter(c=>c!==s))}),i.items.length!==0)return i})}function wr(t=16){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=r.charAt(Math.floor(Math.random()*r.length));let i=je(t-1);return i=i.replace(/[^a-zA-Z0-9]/g,"").slice(0,t-1),n+i}const Lt=t=>Object.keys(t).reduce((r,n)=>{const{display:i,playbackRate:s}=t[n];return Math.max(r,i.to/(s||1))},0),Oi=(t,r,n,i,s)=>{let c=!1;return t.forEach(h=>{const m=n[h],C=m.display.from,F=m.display.to;(i!==void 0||s!==void 0)&&(c=r.find((b,d)=>{if(i!==void 0&&b.id===i)return b;if(s!==void 0&&d===s)return b}).items.map(b=>n[b]).some(b=>{const d=b.display.from,f=b.display.to;return d<=C&&f>=F}))}),c};function xi(t){const r=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.DESIGN_PREFIX))),n=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.ADD_PREFIX))),i=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.LAYER_PREFIX))),s=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.HISTORY_PREFIX))),c=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.ACTIVE_PREFIX))),h=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.EDIT_PREFIX))),m=r.subscribe(async d=>{var f,p;if(d.key===x.DESIGN_LOAD){const g=(f=d.value)==null?void 0:f.payload,S=g.size,_=g.trackItemIds,y=g.trackItemsMap,l=g.trackItemDetailsMap;console.warn("IMPROVE FONTS LOADING");const D=_.map(async I=>{var j;try{const w=l[I],P=y[I];if(w.type==="image"){const k=await Ir({id:I,details:w.details,...P},{size:S}),{details:v,...A}=k;l[I]={type:"image",details:v},y[I]=A}else if(w.type==="video"){const k=B((j=d.value)==null?void 0:j.payload.trackItemsMap[I]),v=await gr({...w,...k,...P},{size:S}),{details:A,...O}=v;l[I]={type:"video",details:A},y[I]=O}else if(w.type==="audio"){const k=await _r({id:I,details:w.details,...P}),{details:v,...A}=k;l[I]={type:"audio",details:v},y[I]=A}else if(w.type==="caption"){const k=await vr({id:I,details:w.details,...P},{size:S}),{details:v,...A}=k;l[I]={type:"caption",details:v},y[I]=A}else if(w.type==="text"){const k=await Sr({id:I,details:w.details,...P},{size:S}),{details:v,...A}=k;l[I]={type:"text",details:v},y[I]=A}return!0}catch{return!1}});await Promise.all(D);const M=Lt(y);t.updateState({...g,trackItemsMap:y,duration:M})}if(d.key===x.DESIGN_RESIZE){const g=(p=d.value)==null?void 0:p.payload;t.updateState({size:g})}}),C=s.subscribe(d=>{if(d.key===x.HISTORY_UNDO)return t.undo();if(d.key===x.HISTORY_REDO)return t.redo()}),F=i.subscribe(d=>{var g,S,_,y;const f=[],p=[];if((g=d.value)!=null&&g.payload.trackItemIds&&(f.push((S=d.value)==null?void 0:S.payload.trackItemIds),t.updateState({activeIds:f})),d.key===x.LAYER_DELETE){const l=(_=d.value)==null?void 0:_.payload.trackItemIds,D=B(t.getState()),M=l&&l.length?l:D.activeIds,I=D.trackItemIds,j=D.trackItemDetailsMap,w=I.filter(O=>!M.includes(O)),P=Object.fromEntries(Object.entries(j).filter(([O])=>!M.includes(O))),k=Ai(D.tracks,M),v=Object.fromEntries(Object.entries(D.trackItemsMap).filter(([O])=>!M.includes(O))),A=Lt(v);t.updateState({trackItemIds:w,trackItemDetailsMap:P,activeIds:[],trackItemsMap:v,tracks:k,duration:A},{updateHistory:!0,kind:"remove"})}if(d.key===x.LAYER_CLONE){const l=B(t.getState()),D=((y=d.value)==null?void 0:y.payload.trackItemIds)||l.activeIds;if(D.length===0)return;D.forEach(I=>{const j=l.trackItemsMap[I],w=l.trackItemDetailsMap[I],P=wr();p.push(P),l.trackItemsMap={...l.trackItemsMap,[P]:{...B(j),id:P}},l.trackItemDetailsMap={...l.trackItemDetailsMap,[P]:{...B(w)}},l.trackItemIds.push(P)});const M=[];l.tracks.forEach(I=>{const j={...I,items:[],id:je()};I.items.forEach(w=>{if(D.includes(w)){const P=D.indexOf(w);j.items.push(p[P])}}),M.push(j)}),M.forEach(I=>{I.items.length!==0&&l.tracks.unshift(I)}),t.updateState({trackItemDetailsMap:l.trackItemDetailsMap,tracks:l.tracks,trackItemIds:l.trackItemIds,trackItemsMap:l.trackItemsMap},{updateHistory:!0,kind:"update"})}}),E=n.subscribe(async d=>{var l,D,M,I,j,w,P,k;const f=B(t.getState());let p=[],g="text";const S=(l=d.value)==null?void 0:l.options.trackId,_=(D=d.value)==null?void 0:D.options.trackIndex;if(d.key===x.ADD_CAPTION){g="caption";const v=(M=d.value)==null?void 0:M.payload,A=[];for(const X of v){const ht=vr(X,{size:f.size});A.push(ht)}const O=await Promise.all(A),tt=[];for(const X of O){const ht=X.id;tt.push(ht);const{details:se,...oe}=X;f.trackItemDetailsMap[ht]={type:g,details:se},f.trackItemsMap[ht]=oe,f.trackItemIds.push(ht)}p=tt}if(d.key===x.ADD_TEXT){g="text";const v=await Sr((I=d.value)==null?void 0:I.payload,{size:f.size}),{details:A,...O}=v;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}if(d.key===x.ADD_TEMPLATE){g="template";const v=await Ei((j=d.value)==null?void 0:j.payload,{size:f.size}),{details:A,...O}=v;f.trackItemsMap[v.id]={...O,type:"template"},f.trackItemIds.push(O.id),f.trackItemDetailsMap[O.id]={type:"template",details:A},p=[O.id]}if(d.key===x.ADD_IMAGE){g="image";const v=await Ir((w=d.value)==null?void 0:w.payload,{size:f.size}),{details:A,...O}=v;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}if(d.key===x.ADD_AUDIO){g="audio";const v=await _r((P=d.value)==null?void 0:P.payload),{details:A,...O}=v;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}if(d.key===x.ADD_VIDEO){g="video";const v=await gr((k=d.value)==null?void 0:k.payload,{size:f.size}),{details:A,...O}=v;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}const y=Oi(p,f.tracks,f.trackItemsMap,S,_);S!==void 0&&!y?f.tracks.map(A=>A.id).includes(S)&&(f.tracks=f.tracks.map(A=>(A.id===S&&A.items.push(...p),A))):_!==void 0&&!y?f.tracks=f.tracks.map((v,A)=>(A===_&&v.items.push(...p),v)):f.tracks.unshift({id:je(),accepts:["text","audio","helper","video","image","caption"],type:g,items:p,magnetic:!1,static:!1}),f.duration=Lt(f.trackItemsMap),t.updateState({trackItemIds:f.trackItemIds,trackItemDetailsMap:f.trackItemDetailsMap,trackItemsMap:f.trackItemsMap,tracks:f.tracks,duration:f.duration},{updateHistory:!0,kind:"add"})}),L=c.subscribe(async d=>{var f;if(d.key===x.ACTIVE_SPLIT){const p=B(t.getState()),g=(f=d.value)==null?void 0:f.options.time;if(p.activeIds.length===1){const S=p.activeIds[0],_=p.trackItemsMap[S];if(g>=_.display.to||g<=_.display.from)return;const y=p.trackItemDetailsMap[S],l=wr(),D={..._,id:l,display:{from:g,to:_.display.to},trim:{from:g,to:_.display.to}};p.trackItemsMap[S].display.to=g,p.trackItemsMap[l]=D,p.trackItemIds.push(l),p.trackItemDetailsMap[l]=y,p.tracks.forEach(M=>{M.items.includes(S)&&M.items.push(l)}),t.updateState({trackItemDetailsMap:p.trackItemDetailsMap,tracks:p.tracks,trackItemIds:p.trackItemIds,trackItemsMap:p.trackItemsMap},{updateHistory:!0,kind:"update"})}return}if(d.key===x.ACTIVE_CLONE){const p=B(t.getState());if(p.activeIds.length){const g=p.activeIds,S=[],_={activeIds:g,trackItemDetailsMap:{},trackItemsMap:{},tracks:[]};g.forEach(l=>{_.trackItemDetailsMap[l]=p.trackItemDetailsMap[l],_.trackItemsMap[l]=p.trackItemsMap[l],S.push(p.tracks.find(D=>D.items.includes(l)))});const y=new Set;S.filter(l=>y.has(l.id)?!1:(y.add(l),!0)),_.tracks=Array.from(y.keys()),localStorage.setItem("DesignComboTemp",JSON.stringify(_))}}if(d.key===x.ACTIVE_PASTE){const p=localStorage.getItem("DesignComboTemp");if(!p)return;const g=B(t.getState()),S=JSON.parse(p),_={},y=S.trackItemsMap,l=S.trackItemDetailsMap,D=S.tracks,M=[],I=S.activeIds.map(async j=>{const w=l[j];(w.type==="caption"||w.type==="text")&&w.details.fontUrl&&await br([{fontFamily:w.details.fontFamily,url:w.details.fontUrl}]);const P=wr();return _[j]=P,g.trackItemsMap[P]={...y[j],id:P},g.trackItemDetailsMap[P]=w,g.trackItemIds.push(P),!0});await Promise.all(I),D.forEach(j=>{const w=j.items.map(k=>_[k]),P={...j,items:w,id:je()};M.push(P)}),g.tracks=[...g.tracks,...M],t.updateState({trackItemDetailsMap:g.trackItemDetailsMap,tracks:g.tracks,trackItemIds:g.trackItemIds,trackItemsMap:g.trackItemsMap},{updateHistory:!0,kind:"update"})}}),b=h.subscribe(async d=>{var f,p,g,S;if(d.key===x.DELETE_TEMPLATE_ITEM){const _=B(t.getState()),[y]=(f=d.value)==null?void 0:f.payload.trackItemIds,l=_.trackItemDetailsMap;_.trackItemIds.forEach(M=>{const I=l[M];if(I.type==="template"&&I.details.map(w=>w.id).includes(y)){const w=I.details.filter(P=>P.id!==y);I.details=w}}),t.updateState({trackItemDetailsMap:{...l}},{updateHistory:!0,kind:"update"})}if(d.key===x.EDIT_OBJECT){const _=B(t.getState()),y=_.trackItemDetailsMap,l=_.trackItemsMap,D=Object.keys((p=d.value)==null?void 0:p.payload);if(!D.length)return;const M=(g=d.value)==null?void 0:g.payload;D.forEach(j=>{const w=M[j];w.details?y[j].details={...y[j].details,...w.details}:M[j].playbackRate?l[j].playbackRate=M[j].playbackRate:y[j].type==="template"&&(l[j]={...l[j],...M[j]})});const I=Lt(l);t.updateState({trackItemDetailsMap:{...y},trackItemsMap:{...l},duration:I},{updateHistory:!0,kind:"update:details"})}if(d.key===x.EDIT_TEMPLATE_ITEM){const _=(S=d.value)==null?void 0:S.payload,y=Object.keys(_)[0],l=Object.values(_)[0],D=B(t.getState());for(const M of D.trackItemIds)if(D.trackItemsMap[M].type==="template"){const I=D.trackItemDetailsMap[M];if(I.details.map(w=>w.id).includes(y)){for(let w of I.details)if(w.id===y){if(l.details){if(l.type==="image"&&l.details.src){const k=await Wn(l.details.src),v=w.details.width,A=w.details.height;let O=k.width,tt=k.height;const X=k.width/k.height;v/A>X?(O=v,tt=v/X):(tt=A,O=A*X),l.details.mediaWidth=O,l.details.mediaHeight=tt}if(l.type==="video"&&l.details.src){const k=await Gn(l.details.src),v=w.details.width,A=w.details.height;let O=k.width,tt=k.height;const X=k.width/k.height;v/A>X?(O=v,tt=v/X):(tt=A,O=A*X),l.details.mediaWidth=O,l.details.mediaHeight=tt}const P=w.details;w.details={...P,...l.details},l.details=w.details}w={...w,...l},D.trackItemDetailsMap[M].details=I.details.map(P=>P.id===y?w:P)}}}t.updateState({trackItemDetailsMap:{...D.trackItemDetailsMap}},{updateHistory:!0,kind:"update:details"})}if(d.key===x.CLOSE_EDIT_TEMPLATE){const _=B(t.getState());_.trackItemIds.forEach(y=>{const l=_.trackItemsMap[y];l.type==="template"&&(l.activeEdit=!1,t.updateState({trackItemsMap:{..._.trackItemsMap,[y]:l},activeIds:[]}))})}});return{unsubscribe:()=>{E.unsubscribe(),L.unsubscribe(),b.unsubscribe(),C.unsubscribe(),F.unsubscribe(),m.unsubscribe()}}}const Di={Date:!0,RegExp:!0,String:!0,Number:!0};function Yn(t,r,n={cyclesFix:!0},i=[]){var m,C;let s=[];const c=Array.isArray(t);for(const F in t){const E=t[F],L=c?+F:F;if(!(F in r)){s.push({type:"REMOVE",path:[L],oldValue:t[F]});continue}const b=r[F],d=typeof E=="object"&&typeof b=="object"&&Array.isArray(E)===Array.isArray(b);if(E&&b&&d&&!Di[(C=(m=Object.getPrototypeOf(E))==null?void 0:m.constructor)==null?void 0:C.name]&&(!n.cyclesFix||!i.includes(E))){const f=Yn(E,b,n,n.cyclesFix?i.concat([E]):[]);s.push.apply(s,f.map(p=>(p.path.unshift(L),p)))}else E!==b&&!(Number.isNaN(E)&&Number.isNaN(b))&&!(d&&(isNaN(E)?E+""==b+"":+E==+b))&&s.push({path:[L],type:"CHANGE",value:b,oldValue:E})}const h=Array.isArray(r);for(const F in r)F in t||s.push({type:"CREATE",path:[h?+F:F],value:r[F]});return s}var kr=Symbol.for("immer-nothing"),Qt=Symbol.for("immer-draftable"),at=Symbol.for("immer-state"),Vn=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function $(t,...r){if(process.env.NODE_ENV!=="production"){const n=Vn[t],i=typeof n=="function"?n.apply(null,r):n;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Mt=Object.getPrototypeOf;function At(t){return!!t&&!!t[at]}function kt(t){var r;return t?Xn(t)||Array.isArray(t)||!!t[Qt]||!!((r=t.constructor)!=null&&r[Qt])||re(t)||ne(t):!1}var Pi=Object.prototype.constructor.toString();function Xn(t){if(!t||typeof t!="object")return!1;const r=Mt(t);if(r===null)return!0;const n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Pi}function te(t,r){Ot(t)===0?Reflect.ownKeys(t).forEach(n=>{r(n,t[n],t)}):t.forEach((n,i)=>r(i,n,t))}function Ot(t){const r=t[at];return r?r.type_:Array.isArray(t)?1:re(t)?2:ne(t)?3:0}function ee(t,r){return Ot(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function Tr(t,r){return Ot(t)===2?t.get(r):t[r]}function qn(t,r,n){const i=Ot(t);i===2?t.set(r,n):i===3?t.add(n):t[r]=n}function Ci(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function re(t){return t instanceof Map}function ne(t){return t instanceof Set}function xt(t){return t.copy_||t.base_}function Er(t,r){if(re(t))return new Map(t);if(ne(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Xn(t);if(r===!0||r==="class_only"&&!n){const i=Object.getOwnPropertyDescriptors(t);delete i[at];let s=Reflect.ownKeys(i);for(let c=0;c<s.length;c++){const h=s[c],m=i[h];m.writable===!1&&(m.writable=!0,m.configurable=!0),(m.get||m.set)&&(i[h]={configurable:!0,writable:!0,enumerable:m.enumerable,value:t[h]})}return Object.create(Mt(t),i)}else{const i=Mt(t);if(i!==null&&n)return{...t};const s=Object.create(i);return Object.assign(s,t)}}function Mr(t,r=!1){return Re(t)||At(t)||!kt(t)||(Ot(t)>1&&(t.set=t.add=t.clear=t.delete=ji),Object.freeze(t),r&&Object.entries(t).forEach(([n,i])=>Mr(i,!0))),t}function ji(){$(2)}function Re(t){return Object.isFrozen(t)}var Ar={};function Dt(t){const r=Ar[t];return r||$(0,t),r}function Ri(t,r){Ar[t]||(Ar[t]=r)}var ie;function Zn(){return ie}function Fi(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Jn(t,r){r&&(Dt("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function Or(t){xr(t),t.drafts_.forEach(zi),t.drafts_=null}function xr(t){t===ie&&(ie=t.parent_)}function Qn(t){return ie=Fi(ie,t)}function zi(t){const r=t[at];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function ti(t,r){r.unfinalizedDrafts_=r.drafts_.length;const n=r.drafts_[0];return t!==void 0&&t!==n?(n[at].modified_&&(Or(r),$(4)),kt(t)&&(t=Fe(r,t),r.parent_||ze(r,t)),r.patches_&&Dt("Patches").generateReplacementPatches_(n[at].base_,t,r.patches_,r.inversePatches_)):t=Fe(r,n,[]),Or(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==kr?t:void 0}function Fe(t,r,n){if(Re(r))return r;const i=r[at];if(!i)return te(r,(s,c)=>ei(t,i,r,s,c,n)),r;if(i.scope_!==t)return r;if(!i.modified_)return ze(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let c=s,h=!1;i.type_===3&&(c=new Set(s),s.clear(),h=!0),te(c,(m,C)=>ei(t,i,s,m,C,n,h)),ze(t,s,!1),n&&t.patches_&&Dt("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function ei(t,r,n,i,s,c,h){if(process.env.NODE_ENV!=="production"&&s===n&&$(5),At(s)){const m=c&&r&&r.type_!==3&&!ee(r.assigned_,i)?c.concat(i):void 0,C=Fe(t,s,m);if(qn(n,i,C),At(C))t.canAutoFreeze_=!1;else return}else h&&n.add(s);if(kt(s)&&!Re(s)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Fe(t,s),(!r||!r.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&ze(t,s)}}function ze(t,r,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Mr(r,n)}function Hi(t,r){const n=Array.isArray(t),i={type_:n?1:0,scope_:r?r.scope_:Zn(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=i,c=Dr;n&&(s=[i],c=ae);const{revoke:h,proxy:m}=Proxy.revocable(s,c);return i.draft_=m,i.revoke_=h,m}var Dr={get(t,r){if(r===at)return t;const n=xt(t);if(!ee(n,r))return Ni(t,n,r);const i=n[r];return t.finalized_||!kt(i)?i:i===Pr(t.base_,r)?(jr(t),t.copy_[r]=Rr(i,t)):i},has(t,r){return r in xt(t)},ownKeys(t){return Reflect.ownKeys(xt(t))},set(t,r,n){const i=ri(xt(t),r);if(i!=null&&i.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const s=Pr(xt(t),r),c=s==null?void 0:s[at];if(c&&c.base_===n)return t.copy_[r]=n,t.assigned_[r]=!1,!0;if(Ci(n,s)&&(n!==void 0||ee(t.base_,r)))return!0;jr(t),Cr(t)}return t.copy_[r]===n&&(n!==void 0||r in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=n,t.assigned_[r]=!0),!0},deleteProperty(t,r){return Pr(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,jr(t),Cr(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const n=xt(t),i=Reflect.getOwnPropertyDescriptor(n,r);return i&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:i.enumerable,value:n[r]}},defineProperty(){$(11)},getPrototypeOf(t){return Mt(t.base_)},setPrototypeOf(){$(12)}},ae={};te(Dr,(t,r)=>{ae[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),ae.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&$(13),ae.set.call(this,t,r,void 0)},ae.set=function(t,r,n){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&$(14),Dr.set.call(this,t[0],r,n,t[0])};function Pr(t,r){const n=t[at];return(n?xt(n):t)[r]}function Ni(t,r,n){var s;const i=ri(r,n);return i?"value"in i?i.value:(s=i.get)==null?void 0:s.call(t.draft_):void 0}function ri(t,r){if(!(r in t))return;let n=Mt(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,r);if(i)return i;n=Mt(n)}}function Cr(t){t.modified_||(t.modified_=!0,t.parent_&&Cr(t.parent_))}function jr(t){t.copy_||(t.copy_=Er(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Li=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,i)=>{if(typeof r=="function"&&typeof n!="function"){const c=n;n=r;const h=this;return function(C=c,...F){return h.produce(C,E=>n.call(this,E,...F))}}typeof n!="function"&&$(6),i!==void 0&&typeof i!="function"&&$(7);let s;if(kt(r)){const c=Qn(this),h=Rr(r,void 0);let m=!0;try{s=n(h),m=!1}finally{m?Or(c):xr(c)}return Jn(c,i),ti(s,c)}else if(!r||typeof r!="object"){if(s=n(r),s===void 0&&(s=r),s===kr&&(s=void 0),this.autoFreeze_&&Mr(s,!0),i){const c=[],h=[];Dt("Patches").generateReplacementPatches_(r,s,c,h),i(c,h)}return s}else $(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(h,...m)=>this.produceWithPatches(h,C=>r(C,...m));let i,s;return[this.produce(r,n,(h,m)=>{i=h,s=m}),i,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){kt(t)||$(8),At(t)&&(t=Ui(t));const r=Qn(this),n=Rr(t,void 0);return n[at].isManual_=!0,xr(r),n}finishDraft(t,r){const n=t&&t[at];(!n||!n.isManual_)&&$(9);const{scope_:i}=n;return Jn(i,r),ti(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){const s=r[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(r=r.slice(n+1));const i=Dt("Patches").applyPatches_;return At(t)?i(t,r):this.produce(t,s=>i(s,r))}};function Rr(t,r){const n=re(t)?Dt("MapSet").proxyMap_(t,r):ne(t)?Dt("MapSet").proxySet_(t,r):Hi(t,r);return(r?r.scope_:Zn()).drafts_.push(n),n}function Ui(t){return At(t)||$(10,t),ni(t)}function ni(t){if(!kt(t)||Re(t))return t;const r=t[at];let n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=Er(t,r.scope_.immer_.useStrictShallowCopy_)}else n=Er(t,!0);return te(n,(i,s)=>{qn(n,i,ni(s))}),r&&(r.finalized_=!1),n}function ii(){process.env.NODE_ENV!=="production"&&Vn.push('Sets cannot have "replace" patches.',function(b){return"Unsupported patch operation: "+b},function(b){return"Cannot apply patch, path doesn't resolve: "+b},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",n="add",i="remove";function s(b,d,f,p){switch(b.type_){case 0:case 2:return h(b,d,f,p);case 1:return c(b,d,f,p);case 3:return m(b,d,f,p)}}function c(b,d,f,p){let{base_:g,assigned_:S}=b,_=b.copy_;_.length<g.length&&([g,_]=[_,g],[f,p]=[p,f]);for(let y=0;y<g.length;y++)if(S[y]&&_[y]!==g[y]){const l=d.concat([y]);f.push({op:r,path:l,value:L(_[y])}),p.push({op:r,path:l,value:L(g[y])})}for(let y=g.length;y<_.length;y++){const l=d.concat([y]);f.push({op:n,path:l,value:L(_[y])})}for(let y=_.length-1;g.length<=y;--y){const l=d.concat([y]);p.push({op:i,path:l})}}function h(b,d,f,p){const{base_:g,copy_:S}=b;te(b.assigned_,(_,y)=>{const l=Tr(g,_),D=Tr(S,_),M=y?ee(g,_)?r:n:i;if(l===D&&M===r)return;const I=d.concat(_);f.push(M===i?{op:M,path:I}:{op:M,path:I,value:D}),p.push(M===n?{op:i,path:I}:M===i?{op:n,path:I,value:L(l)}:{op:r,path:I,value:L(l)})})}function m(b,d,f,p){let{base_:g,copy_:S}=b,_=0;g.forEach(y=>{if(!S.has(y)){const l=d.concat([_]);f.push({op:i,path:l,value:y}),p.unshift({op:n,path:l,value:y})}_++}),_=0,S.forEach(y=>{if(!g.has(y)){const l=d.concat([_]);f.push({op:n,path:l,value:y}),p.unshift({op:i,path:l,value:y})}_++})}function C(b,d,f,p){f.push({op:r,path:[],value:d===kr?void 0:d}),p.push({op:r,path:[],value:b})}function F(b,d){return d.forEach(f=>{const{path:p,op:g}=f;let S=b;for(let D=0;D<p.length-1;D++){const M=Ot(S);let I=p[D];typeof I!="string"&&typeof I!="number"&&(I=""+I),(M===0||M===1)&&(I==="__proto__"||I==="constructor")&&$(19),typeof S=="function"&&I==="prototype"&&$(19),S=Tr(S,I),typeof S!="object"&&$(18,p.join("/"))}const _=Ot(S),y=E(f.value),l=p[p.length-1];switch(g){case r:switch(_){case 2:return S.set(l,y);case 3:$(16);default:return S[l]=y}case n:switch(_){case 1:return l==="-"?S.push(y):S.splice(l,0,y);case 2:return S.set(l,y);case 3:return S.add(y);default:return S[l]=y}case i:switch(_){case 1:return S.splice(l,1);case 2:return S.delete(l);case 3:return S.delete(f.value);default:return delete S[l]}default:$(17,g)}}),b}function E(b){if(!kt(b))return b;if(Array.isArray(b))return b.map(E);if(re(b))return new Map(Array.from(b.entries()).map(([f,p])=>[f,E(p)]));if(ne(b))return new Set(Array.from(b).map(E));const d=Object.create(Mt(b));for(const f in b)d[f]=E(b[f]);return ee(b,Qt)&&(d[Qt]=b[Qt]),d}function L(b){return At(b)?E(b):b}Ri("Patches",{applyPatches_:F,generatePatches_:s,generateReplacementPatches_:C})}var st=new Li,Wi=st.produce;st.produceWithPatches.bind(st),st.setAutoFreeze.bind(st),st.setUseStrictShallowCopy.bind(st);var Gi=st.applyPatches.bind(st);st.createDraft.bind(st),st.finishDraft.bind(st);var Bi=1/0,$i=9007199254740991,Ki="[object Arguments]",Yi="[object Function]",Vi="[object GeneratorFunction]",Xi="[object Symbol]",qi=typeof ot=="object"&&ot&&ot.Object===Object&&ot,Zi=typeof self=="object"&&self&&self.Object===Object&&self,Ji=qi||Zi||Function("return this")();function Qi(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}function ta(t,r){for(var n=-1,i=t?t.length:0,s=Array(i);++n<i;)s[n]=r(t[n],n,t);return s}function ea(t,r){for(var n=-1,i=r.length,s=t.length;++n<i;)t[s+n]=r[n];return t}var Fr=Object.prototype,ra=Fr.hasOwnProperty,zr=Fr.toString,ai=Ji.Symbol,na=Fr.propertyIsEnumerable,si=ai?ai.isConcatSpreadable:void 0,oi=Math.max;function ia(t,r,n,i,s){var c=-1,h=t.length;for(n||(n=ca),s||(s=[]);++c<h;){var m=t[c];n(m)?ea(s,m):s[s.length]=m}return s}function aa(t,r){return t=Object(t),sa(t,r,function(n,i){return i in t})}function sa(t,r,n){for(var i=-1,s=r.length,c={};++i<s;){var h=r[i],m=t[h];n(m,h)&&(c[h]=m)}return c}function oa(t,r){return r=oi(r===void 0?t.length-1:r,0),function(){for(var n=arguments,i=-1,s=oi(n.length-r,0),c=Array(s);++i<s;)c[i]=n[r+i];i=-1;for(var h=Array(r+1);++i<r;)h[i]=n[i];return h[r]=c,Qi(t,this,h)}}function ca(t){return fa(t)||la(t)||!!(si&&t&&t[si])}function ua(t){if(typeof t=="string"||ba(t))return t;var r=t+"";return r=="0"&&1/t==-Bi?"-0":r}function la(t){return pa(t)&&ra.call(t,"callee")&&(!na.call(t,"callee")||zr.call(t)==Ki)}var fa=Array.isArray;function da(t){return t!=null&&ma(t.length)&&!ha(t)}function pa(t){return ci(t)&&da(t)}function ha(t){var r=ya(t)?zr.call(t):"";return r==Yi||r==Vi}function ma(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=$i}function ya(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function ci(t){return!!t&&typeof t=="object"}function ba(t){return typeof t=="symbol"||ci(t)&&zr.call(t)==Xi}var ga=oa(function(t,r){return t==null?{}:aa(t,ta(ia(r),ua))}),_a=ga;const ui=yr(_a),Ia={size:{width:1080,height:1920},tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{unit:1,zoom:1,segments:1,index:1},duration:0,activeIds:[],trackItemDetailsMap:{}},li=["tracks","trackItemsMap","trackItemDetailsMap","transitionIds","transitionsMap","trackItemIds"];class va{constructor(r){Nt(this,"stateSubject");Nt(this,"stateHistorySubject");Nt(this,"prevState");Nt(this,"undos",[]);Nt(this,"redos",[]);Nt(this,"listener");const n=r||Ia;this.stateSubject=new Un(n),this.stateHistorySubject=new Un({handleRedo:!1,handleUndo:!1}),this.prevState=n,this.initListeners()}initListeners(){xi(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,n){const i=ui(r,li),s=ui(this.getState(),li),c=Yn(s,i);c.length&&(this.undos.push({undos:c,type:n}),this.redos=[])}getStateHistory(){return this.stateHistorySubject.getValue()}subscribeHistory(r){return this.stateHistorySubject.subscribe(r)}getState(){return this.stateSubject.getValue()}subscribe(r){return this.stateSubject.subscribe(r)}updateState(r,n={updateHistory:!1}){const i=this.getState(),s={...i,...r};it(i,s)||(n.updateHistory&&this.updateHistory(s,n.kind),this.prevState=i,this.stateSubject.next(s))}subscribeToSize(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.size,this.prevState.size)||r({size:n.size})})}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.scale,this.prevState.scale)||r({scale:n.scale})})}subscribeToUpdateTrackItem(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemsMap,this.prevState.trackItemsMap)||r({trackItemsMap:n.trackItemsMap})})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap)||r({trackItemDetailsMap:n.trackItemDetailsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(n=>{n.duration!==this.prevState.duration&&r({duration:n.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(n=>{if(n.handleRedo){const i=this.undos[this.undos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(n.handleUndo){const i=this.redos[this.redos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemIds,this.prevState.trackItemIds)||r({trackItemIds:n.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.activeIds,this.prevState.activeIds)||r({activeIds:n.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(n=>{(!it(n.tracks,this.prevState.tracks)||!it(n.trackItemIds,this.prevState.trackItemIds)||!it(n.trackItemsMap,this.prevState.trackItemsMap)||!it(n.transitionIds,this.prevState.transitionIds)||!it(n.transitionsMap,this.prevState.transitionsMap)||!it(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap))&&r({tracks:n.tracks,trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap,trackItemDetailsMap:n.trackItemDetailsMap})})}undo(){const r=this.undos.pop(),n=r==null?void 0:r.undos,i=r==null?void 0:r.type;if(!n||!i)return;ii();const{trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}=this.getState(),E=B({trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}),L=[],b=[],d=[],f=[],p=[],g=[];n.forEach(k=>{let v;const A=k.path.slice(1);k.type==="CREATE"?v={path:A,op:"remove",value:k.value}:k.type==="CHANGE"?v={path:A,op:"replace",value:k.oldValue}:v={path:A,op:"add",value:k.oldValue},k.path.includes("trackItemIds")?d.push(v):k.path.includes("transitionIds")?b.push(v):k.path.includes("trackItemsMap")?p.push(v):k.path.includes("transitionsMap")?f.push(v):k.path.includes("tracks")?L.push(v):k.path.includes("trackItemDetailsMap")&&g.push(v)});const S=this.applyPatch(E.tracks,L),_=this.applyPatch(E.transitionIds,b),y=this.applyPatch(E.trackItemIds,d),l=this.applyPatch(E.transitionsMap,f),D=this.applyPatch(E.trackItemsMap,p),M=this.applyPatch(E.trackItemDetailsMap,g),I=B({tracks:S,transitionIds:_,trackItemIds:y,transitionsMap:l,trackItemsMap:D,trackItemDetailsMap:M}),j=B(this.getState()),w={...j,...I};this.prevState=j,this.redos.push({redos:n,type:i});const P=Lt(w.trackItemsMap);this.stateSubject.next({...w,duration:P}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0})}applyPatch(r,n){return n.reverse().reduce((i,s)=>Wi(i,c=>{Gi(c,[s])}),r)}redo(){const r=this.redos.pop(),n=r==null?void 0:r.redos,i=r==null?void 0:r.type;if(!n||!i)return;ii();const{trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}=this.getState(),E=B({trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}),L=[],b=[],d=[],f=[],p=[],g=[];n.forEach(k=>{let v;const A=k.path.slice(1);k.type==="CREATE"?v={path:A,op:"add",value:k.value}:k.type==="CHANGE"?v={path:A,op:"replace",value:k.value}:v={path:A,op:"remove",value:k.oldValue},k.path.includes("trackItemIds")?d.push(v):k.path.includes("transitionIds")?b.push(v):k.path.includes("trackItemsMap")?p.push(v):k.path.includes("transitionsMap")?f.push(v):k.path.includes("trackItemDetailsMap")?g.push(v):L.push(v)});const S=this.applyPatch(E.tracks,L),_=this.applyPatch(E.transitionIds,b),y=this.applyPatch(E.trackItemIds,d),l=this.applyPatch(E.transitionsMap,f),D=this.applyPatch(E.trackItemsMap,p),M=this.applyPatch(E.trackItemDetailsMap,g),I=B({tracks:S,transitionIds:_,trackItemIds:y,transitionsMap:l,trackItemsMap:D,trackItemDetailsMap:M}),j=B(this.getState()),w={...j,...I};this.prevState=j,this.undos.push({undos:n,type:i});const P=Lt(w.trackItemsMap);this.stateSubject.next({...w,duration:P}),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1})}}return va});
|
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=n}});function pr(t,r){if(t){var n=t.indexOf(r);0<=n&&t.splice(n,1)}}var Me=function(){function t(r){this.initialTeardown=r,this.closed=!1,this._parentage=null,this._finalizers=null}return t.prototype.unsubscribe=function(){var r,n,i,s,c;if(!this.closed){this.closed=!0;var h=this._parentage;if(h)if(this._parentage=null,Array.isArray(h))try{for(var m=ur(h),C=m.next();!C.done;C=m.next()){var F=C.value;F.remove(this)}}catch(p){r={error:p}}finally{try{C&&!C.done&&(n=m.return)&&n.call(m)}finally{if(r)throw r.error}}else h.remove(this);var E=this.initialTeardown;if(_t(E))try{E()}catch(p){c=p instanceof dr?p.errors:[p]}var L=this._finalizers;if(L){this._finalizers=null;try{for(var b=ur(L),d=b.next();!d.done;d=b.next()){var f=d.value;try{Pn(f)}catch(p){c=c??[],p instanceof dr?c=fr(fr([],lr(c)),lr(p.errors)):c.push(p)}}}catch(p){i={error:p}}finally{try{d&&!d.done&&(s=b.return)&&s.call(b)}finally{if(i)throw i.error}}}if(c)throw new dr(c)}},t.prototype.add=function(r){var n;if(r&&r!==this)if(this.closed)Pn(r);else{if(r instanceof t){if(r.closed||r._hasParent(this))return;r._addParent(this)}(this._finalizers=(n=this._finalizers)!==null&&n!==void 0?n:[]).push(r)}},t.prototype._hasParent=function(r){var n=this._parentage;return n===r||Array.isArray(n)&&n.includes(r)},t.prototype._addParent=function(r){var n=this._parentage;this._parentage=Array.isArray(n)?(n.push(r),n):n?[n,r]:r},t.prototype._removeParent=function(r){var n=this._parentage;n===r?this._parentage=null:Array.isArray(n)&&pr(n,r)},t.prototype.remove=function(r){var n=this._finalizers;n&&pr(n,r),r instanceof t&&r._removeParent(this)},t.EMPTY=function(){var r=new t;return r.closed=!0,r}(),t}(),xn=Me.EMPTY;function Dn(t){return t instanceof Me||t&&"closed"in t&&_t(t.remove)&&_t(t.add)&&_t(t.unsubscribe)}function Pn(t){_t(t)?t():t.unsubscribe()}var Cn={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},jn={setTimeout:function(t,r){for(var n=[],i=2;i<arguments.length;i++)n[i-2]=arguments[i];return setTimeout.apply(void 0,fr([t,r],lr(n)))},clearTimeout:function(t){var r=jn.delegate;return((r==null?void 0:r.clearTimeout)||clearTimeout)(t)},delegate:void 0};function di(t){jn.setTimeout(function(){throw t})}function Rn(){}function Ae(t){t()}var Fn=function(t){pt(r,t);function r(n){var i=t.call(this)||this;return i.isStopped=!1,n?(i.destination=n,Dn(n)&&n.add(i)):i.destination=yi,i}return r.create=function(n,i,s){return new mr(n,i,s)},r.prototype.next=function(n){this.isStopped||this._next(n)},r.prototype.error=function(n){this.isStopped||(this.isStopped=!0,this._error(n))},r.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},r.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,t.prototype.unsubscribe.call(this),this.destination=null)},r.prototype._next=function(n){this.destination.next(n)},r.prototype._error=function(n){try{this.destination.error(n)}finally{this.unsubscribe()}},r.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},r}(Me),pi=Function.prototype.bind;function hr(t,r){return pi.call(t,r)}var hi=function(){function t(r){this.partialObserver=r}return t.prototype.next=function(r){var n=this.partialObserver;if(n.next)try{n.next(r)}catch(i){Oe(i)}},t.prototype.error=function(r){var n=this.partialObserver;if(n.error)try{n.error(r)}catch(i){Oe(i)}else Oe(r)},t.prototype.complete=function(){var r=this.partialObserver;if(r.complete)try{r.complete()}catch(n){Oe(n)}},t}(),mr=function(t){pt(r,t);function r(n,i,s){var c=t.call(this)||this,h;if(_t(n)||!n)h={next:n??void 0,error:i??void 0,complete:s??void 0};else{var m;c&&Cn.useDeprecatedNextContext?(m=Object.create(n),m.unsubscribe=function(){return c.unsubscribe()},h={next:n.next&&hr(n.next,m),error:n.error&&hr(n.error,m),complete:n.complete&&hr(n.complete,m)}):h=n}return c.destination=new hi(h),c}return r}(Fn);function Oe(t){di(t)}function mi(t){throw t}var yi={closed:!0,next:Rn,error:mi,complete:Rn},bi=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function gi(t){return t}function _i(t){return t.length===0?gi:t.length===1?t[0]:function(n){return t.reduce(function(i,s){return s(i)},n)}}var zn=function(){function t(r){r&&(this._subscribe=r)}return t.prototype.lift=function(r){var n=new t;return n.source=this,n.operator=r,n},t.prototype.subscribe=function(r,n,i){var s=this,c=vi(r)?r:new mr(r,n,i);return Ae(function(){var h=s,m=h.operator,C=h.source;c.add(m?m.call(c,C):C?s._subscribe(c):s._trySubscribe(c))}),c},t.prototype._trySubscribe=function(r){try{return this._subscribe(r)}catch(n){r.error(n)}},t.prototype.forEach=function(r,n){var i=this;return n=Hn(n),new n(function(s,c){var h=new mr({next:function(m){try{r(m)}catch(C){c(C),h.unsubscribe()}},error:c,complete:s});i.subscribe(h)})},t.prototype._subscribe=function(r){var n;return(n=this.source)===null||n===void 0?void 0:n.subscribe(r)},t.prototype[bi]=function(){return this},t.prototype.pipe=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return _i(r)(this)},t.prototype.toPromise=function(r){var n=this;return r=Hn(r),new r(function(i,s){var c;n.subscribe(function(h){return c=h},function(h){return s(h)},function(){return i(c)})})},t.create=function(r){return new t(r)},t}();function Hn(t){var r;return(r=t??Cn.Promise)!==null&&r!==void 0?r:Promise}function Ii(t){return t&&_t(t.next)&&_t(t.error)&&_t(t.complete)}function vi(t){return t&&t instanceof Fn||Ii(t)&&Dn(t)}var Si=On(function(t){return function(){t(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),Nn=function(t){pt(r,t);function r(){var n=t.call(this)||this;return n.closed=!1,n.currentObservers=null,n.observers=[],n.isStopped=!1,n.hasError=!1,n.thrownError=null,n}return r.prototype.lift=function(n){var i=new Ln(this,this);return i.operator=n,i},r.prototype._throwIfClosed=function(){if(this.closed)throw new Si},r.prototype.next=function(n){var i=this;Ae(function(){var s,c;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var h=ur(i.currentObservers),m=h.next();!m.done;m=h.next()){var C=m.value;C.next(n)}}catch(F){s={error:F}}finally{try{m&&!m.done&&(c=h.return)&&c.call(h)}finally{if(s)throw s.error}}}})},r.prototype.error=function(n){var i=this;Ae(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=n;for(var s=i.observers;s.length;)s.shift().error(n)}})},r.prototype.complete=function(){var n=this;Ae(function(){if(n._throwIfClosed(),!n.isStopped){n.isStopped=!0;for(var i=n.observers;i.length;)i.shift().complete()}})},r.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(r.prototype,"observed",{get:function(){var n;return((n=this.observers)===null||n===void 0?void 0:n.length)>0},enumerable:!1,configurable:!0}),r.prototype._trySubscribe=function(n){return this._throwIfClosed(),t.prototype._trySubscribe.call(this,n)},r.prototype._subscribe=function(n){return this._throwIfClosed(),this._checkFinalizedStatuses(n),this._innerSubscribe(n)},r.prototype._innerSubscribe=function(n){var i=this,s=this,c=s.hasError,h=s.isStopped,m=s.observers;return c||h?xn:(this.currentObservers=null,m.push(n),new Me(function(){i.currentObservers=null,pr(m,n)}))},r.prototype._checkFinalizedStatuses=function(n){var i=this,s=i.hasError,c=i.thrownError,h=i.isStopped;s?n.error(c):h&&n.complete()},r.prototype.asObservable=function(){var n=new zn;return n.source=this,n},r.create=function(n,i){return new Ln(n,i)},r}(zn),Ln=function(t){pt(r,t);function r(n,i){var s=t.call(this)||this;return s.destination=n,s.source=i,s}return r.prototype.next=function(n){var i,s;(s=(i=this.destination)===null||i===void 0?void 0:i.next)===null||s===void 0||s.call(i,n)},r.prototype.error=function(n){var i,s;(s=(i=this.destination)===null||i===void 0?void 0:i.error)===null||s===void 0||s.call(i,n)},r.prototype.complete=function(){var n,i;(i=(n=this.destination)===null||n===void 0?void 0:n.complete)===null||i===void 0||i.call(n)},r.prototype._subscribe=function(n){var i,s;return(s=(i=this.source)===null||i===void 0?void 0:i.subscribe(n))!==null&&s!==void 0?s:xn},r}(Nn),Un=function(t){pt(r,t);function r(n){var i=t.call(this)||this;return i._value=n,i}return Object.defineProperty(r.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),r.prototype._subscribe=function(n){var i=t.prototype._subscribe.call(this,n);return!i.closed&&n.next(this._value),i},r.prototype.getValue=function(){var n=this,i=n.hasError,s=n.thrownError,c=n._value;if(i)throw s;return this._throwIfClosed(),c},r.prototype.next=function(n){t.prototype.next.call(this,this._value=n)},r}(Nn),ot=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function yr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var xe={exports:{}};xe.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",s=1,c=2,h=9007199254740991,m="[object Arguments]",C="[object Array]",F="[object AsyncFunction]",E="[object Boolean]",L="[object Date]",b="[object Error]",d="[object Function]",f="[object GeneratorFunction]",p="[object Map]",g="[object Number]",v="[object Null]",_="[object Object]",y="[object Promise]",l="[object Proxy]",D="[object RegExp]",M="[object Set]",I="[object String]",j="[object Symbol]",w="[object Undefined]",P="[object WeakMap]",k="[object ArrayBuffer]",S="[object DataView]",A="[object Float32Array]",O="[object Float64Array]",tt="[object Int8Array]",X="[object Int16Array]",ht="[object Int32Array]",se="[object Uint8Array]",oe="[object Uint8ClampedArray]",U="[object Uint16Array]",Hr="[object Uint32Array]",Nr=/[\\^$.*+?()[\]{}|]/g,ut=/^\[object .+?Constructor\]$/,He=/^(?:0|[1-9]\d*)$/,W={};W[A]=W[O]=W[tt]=W[X]=W[ht]=W[se]=W[oe]=W[U]=W[Hr]=!0,W[m]=W[C]=W[k]=W[E]=W[S]=W[L]=W[b]=W[d]=W[p]=W[g]=W[_]=W[D]=W[M]=W[I]=W[P]=!1;var Ne=typeof ot=="object"&&ot&&ot.Object===Object&&ot,Lr=typeof self=="object"&&self&&self.Object===Object&&self,lt=Ne||Lr||Function("return this")(),Le=r&&!r.nodeType&&r,Ue=Le&&!0&&t&&!t.nodeType&&t,ce=Ue&&Ue.exports===Le,ue=ce&&Ne.process,We=function(){try{return ue&&ue.binding&&ue.binding("util")}catch{}}(),le=We&&We.isTypedArray;function Ge(e,a){for(var o=-1,u=e==null?0:e.length,R=0,T=[];++o<u;){var H=e[o];a(H,o,e)&&(T[R++]=H)}return T}function fe(e,a){for(var o=-1,u=a.length,R=e.length;++o<u;)e[R+o]=a[o];return e}function Be(e,a){for(var o=-1,u=e==null?0:e.length;++o<u;)if(a(e[o],o,e))return!0;return!1}function Ur(e,a){for(var o=-1,u=Array(e);++o<e;)u[o]=a(o);return u}function Wr(e){return function(a){return e(a)}}function Ut(e,a){return e.has(a)}function de(e,a){return e==null?void 0:e[a]}function $e(e){var a=-1,o=Array(e.size);return e.forEach(function(u,R){o[++a]=[R,u]}),o}function Ke(e,a){return function(o){return e(a(o))}}function mt(e){var a=-1,o=Array(e.size);return e.forEach(function(u){o[++a]=u}),o}var Wt=Array.prototype,Gr=Function.prototype,Pt=Object.prototype,Gt=lt["__core-js_shared__"],pe=Gr.toString,ct=Pt.hasOwnProperty,Ye=function(){var e=/[^.]+$/.exec(Gt&&Gt.keys&&Gt.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ve=Pt.toString,Br=RegExp("^"+pe.call(ct).replace(Nr,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),he=ce?lt.Buffer:void 0,Bt=lt.Symbol,Xe=lt.Uint8Array,$t=Pt.propertyIsEnumerable,Ct=Wt.splice,ft=Bt?Bt.toStringTag:void 0,Kt=Object.getOwnPropertySymbols,me=he?he.isBuffer:void 0,jt=Ke(Object.keys,Object),ye=vt(lt,"DataView"),Rt=vt(lt,"Map"),be=vt(lt,"Promise"),ge=vt(lt,"Set"),_e=vt(lt,"WeakMap"),Tt=vt(Object,"create"),qe=et(ye),It=et(Rt),$r=et(be),Kr=et(ge),Yr=et(_e),Ze=Bt?Bt.prototype:void 0,Ie=Ze?Ze.valueOf:void 0;function Y(e){var a=-1,o=e==null?0:e.length;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Vr(){this.__data__=Tt?Tt(null):{},this.size=0}function Xr(e){var a=this.has(e)&&delete this.__data__[e];return this.size-=a?1:0,a}function qr(e){var a=this.__data__;if(Tt){var o=a[e];return o===i?void 0:o}return ct.call(a,e)?a[e]:void 0}function Zr(e){var a=this.__data__;return Tt?a[e]!==void 0:ct.call(a,e)}function Jr(e,a){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=Tt&&a===void 0?i:a,this}Y.prototype.clear=Vr,Y.prototype.delete=Xr,Y.prototype.get=qr,Y.prototype.has=Zr,Y.prototype.set=Jr;function q(e){var a=-1,o=e==null?0:e.length;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Qr(){this.__data__=[],this.size=0}function tn(e){var a=this.__data__,o=Xt(a,e);if(o<0)return!1;var u=a.length-1;return o==u?a.pop():Ct.call(a,o,1),--this.size,!0}function en(e){var a=this.__data__,o=Xt(a,e);return o<0?void 0:a[o][1]}function rn(e){return Xt(this.__data__,e)>-1}function nn(e,a){var o=this.__data__,u=Xt(o,e);return u<0?(++this.size,o.push([e,a])):o[u][1]=a,this}q.prototype.clear=Qr,q.prototype.delete=tn,q.prototype.get=en,q.prototype.has=rn,q.prototype.set=nn;function rt(e){var a=-1,o=e==null?0:e.length;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function an(){this.size=0,this.__data__={hash:new Y,map:new(Rt||q),string:new Y}}function sn(e){var a=dt(this,e).delete(e);return this.size-=a?1:0,a}function on(e){return dt(this,e).get(e)}function cn(e){return dt(this,e).has(e)}function un(e,a){var o=dt(this,e),u=o.size;return o.set(e,a),this.size+=o.size==u?0:1,this}rt.prototype.clear=an,rt.prototype.delete=sn,rt.prototype.get=on,rt.prototype.has=cn,rt.prototype.set=un;function Yt(e){var a=-1,o=e==null?0:e.length;for(this.__data__=new rt;++a<o;)this.add(e[a])}function Je(e){return this.__data__.set(e,i),this}function Vt(e){return this.__data__.has(e)}Yt.prototype.add=Yt.prototype.push=Je,Yt.prototype.has=Vt;function yt(e){var a=this.__data__=new q(e);this.size=a.size}function ve(){this.__data__=new q,this.size=0}function ln(e){var a=this.__data__,o=a.delete(e);return this.size=a.size,o}function fn(e){return this.__data__.get(e)}function dn(e){return this.__data__.has(e)}function pn(e,a){var o=this.__data__;if(o instanceof q){var u=o.__data__;if(!Rt||u.length<n-1)return u.push([e,a]),this.size=++o.size,this;o=this.__data__=new rt(u)}return o.set(e,a),this.size=o.size,this}yt.prototype.clear=ve,yt.prototype.delete=ln,yt.prototype.get=fn,yt.prototype.has=dn,yt.prototype.set=pn;function hn(e,a){var o=qt(e),u=!o&&nr(e),R=!o&&!u&&Zt(e),T=!o&&!u&&!R&&sr(e),H=o||u||R||T,z=H?Ur(e.length,String):[],G=z.length;for(var N in e)ct.call(e,N)&&!(H&&(N=="length"||R&&(N=="offset"||N=="parent")||T&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||Sn(N,G)))&&z.push(N);return z}function Xt(e,a){for(var o=e.length;o--;)if(rr(e[o][0],a))return o;return-1}function Se(e,a,o){var u=a(e);return qt(e)?u:fe(u,o(e))}function Ft(e){return e==null?e===void 0?w:v:ft&&ft in Object(e)?St(e):er(e)}function Qe(e){return gt(e)&&Ft(e)==m}function tr(e,a,o,u,R){return e===a?!0:e==null||a==null||!gt(e)&&!gt(a)?e!==e&&a!==a:mn(e,a,o,u,tr,R)}function mn(e,a,o,u,R,T){var H=qt(e),z=qt(a),G=H?C:bt(e),N=z?C:bt(a);G=G==m?_:G,N=N==m?_:N;var Z=G==_,nt=N==_,K=G==N;if(K&&Zt(e)){if(!Zt(a))return!1;H=!0,Z=!1}if(K&&!Z)return T||(T=new yt),H||sr(e)?we(e,a,o,u,R,T):_n(e,a,G,o,u,R,T);if(!(o&s)){var J=Z&&ct.call(e,"__wrapped__"),V=nt&&ct.call(a,"__wrapped__");if(J||V){var Et=J?e.value():e,wt=V?a.value():a;return T||(T=new yt),R(Et,wt,o,u,T)}}return K?(T||(T=new yt),In(e,a,o,u,R,T)):!1}function yn(e){if(!ar(e)||kn(e))return!1;var a=ir(e)?Br:ut;return a.test(et(e))}function bn(e){return gt(e)&&Te(e.length)&&!!W[Ft(e)]}function gn(e){if(!Tn(e))return jt(e);var a=[];for(var o in Object(e))ct.call(e,o)&&o!="constructor"&&a.push(o);return a}function we(e,a,o,u,R,T){var H=o&s,z=e.length,G=a.length;if(z!=G&&!(H&&G>z))return!1;var N=T.get(e);if(N&&T.get(a))return N==a;var Z=-1,nt=!0,K=o&c?new Yt:void 0;for(T.set(e,a),T.set(a,e);++Z<z;){var J=e[Z],V=a[Z];if(u)var Et=H?u(V,J,Z,a,e,T):u(J,V,Z,e,a,T);if(Et!==void 0){if(Et)continue;nt=!1;break}if(K){if(!Be(a,function(wt,Ht){if(!Ut(K,Ht)&&(J===wt||R(J,wt,o,u,T)))return K.push(Ht)})){nt=!1;break}}else if(!(J===V||R(J,V,o,u,T))){nt=!1;break}}return T.delete(e),T.delete(a),nt}function _n(e,a,o,u,R,T,H){switch(o){case S:if(e.byteLength!=a.byteLength||e.byteOffset!=a.byteOffset)return!1;e=e.buffer,a=a.buffer;case k:return!(e.byteLength!=a.byteLength||!T(new Xe(e),new Xe(a)));case E:case L:case g:return rr(+e,+a);case b:return e.name==a.name&&e.message==a.message;case D:case I:return e==a+"";case p:var z=$e;case M:var G=u&s;if(z||(z=mt),e.size!=a.size&&!G)return!1;var N=H.get(e);if(N)return N==a;u|=c,H.set(e,a);var Z=we(z(e),z(a),u,R,T,H);return H.delete(e),Z;case j:if(Ie)return Ie.call(e)==Ie.call(a)}return!1}function In(e,a,o,u,R,T){var H=o&s,z=zt(e),G=z.length,N=zt(a),Z=N.length;if(G!=Z&&!H)return!1;for(var nt=G;nt--;){var K=z[nt];if(!(H?K in a:ct.call(a,K)))return!1}var J=T.get(e);if(J&&T.get(a))return J==a;var V=!0;T.set(e,a),T.set(a,e);for(var Et=H;++nt<G;){K=z[nt];var wt=e[K],Ht=a[K];if(u)var fi=H?u(Ht,wt,K,a,e,T):u(wt,Ht,K,e,a,T);if(!(fi===void 0?wt===Ht||R(wt,Ht,o,u,T):fi)){V=!1;break}Et||(Et=K=="constructor")}if(V&&!Et){var or=e.constructor,cr=a.constructor;or!=cr&&"constructor"in e&&"constructor"in a&&!(typeof or=="function"&&or instanceof or&&typeof cr=="function"&&cr instanceof cr)&&(V=!1)}return T.delete(e),T.delete(a),V}function zt(e){return Se(e,Ee,vn)}function dt(e,a){var o=e.__data__;return wn(a)?o[typeof a=="string"?"string":"hash"]:o.map}function vt(e,a){var o=de(e,a);return yn(o)?o:void 0}function St(e){var a=ct.call(e,ft),o=e[ft];try{e[ft]=void 0;var u=!0}catch{}var R=Ve.call(e);return u&&(a?e[ft]=o:delete e[ft]),R}var vn=Kt?function(e){return e==null?[]:(e=Object(e),Ge(Kt(e),function(a){return $t.call(e,a)}))}:Mn,bt=Ft;(ye&&bt(new ye(new ArrayBuffer(1)))!=S||Rt&&bt(new Rt)!=p||be&&bt(be.resolve())!=y||ge&&bt(new ge)!=M||_e&&bt(new _e)!=P)&&(bt=function(e){var a=Ft(e),o=a==_?e.constructor:void 0,u=o?et(o):"";if(u)switch(u){case qe:return S;case It:return p;case $r:return y;case Kr:return M;case Yr:return P}return a});function Sn(e,a){return a=a??h,!!a&&(typeof e=="number"||He.test(e))&&e>-1&&e%1==0&&e<a}function wn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function kn(e){return!!Ye&&Ye in e}function Tn(e){var a=e&&e.constructor,o=typeof a=="function"&&a.prototype||Pt;return e===o}function er(e){return Ve.call(e)}function et(e){if(e!=null){try{return pe.call(e)}catch{}try{return e+""}catch{}}return""}function rr(e,a){return e===a||e!==e&&a!==a}var nr=Qe(function(){return arguments}())?Qe:function(e){return gt(e)&&ct.call(e,"callee")&&!$t.call(e,"callee")},qt=Array.isArray;function ke(e){return e!=null&&Te(e.length)&&!ir(e)}var Zt=me||An;function En(e,a){return tr(e,a)}function ir(e){if(!ar(e))return!1;var a=Ft(e);return a==d||a==f||a==F||a==l}function Te(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=h}function ar(e){var a=typeof e;return e!=null&&(a=="object"||a=="function")}function gt(e){return e!=null&&typeof e=="object"}var sr=le?Wr(le):bn;function Ee(e){return ke(e)?hn(e):gn(e)}function Mn(){return[]}function An(){return!1}t.exports=En}(xe,xe.exports);var wi=xe.exports;const it=yr(wi);var De={exports:{}};De.exports,function(t,r){var n=200,i="__lodash_hash_undefined__",s=9007199254740991,c="[object Arguments]",h="[object Array]",m="[object Boolean]",C="[object Date]",F="[object Error]",E="[object Function]",L="[object GeneratorFunction]",b="[object Map]",d="[object Number]",f="[object Object]",p="[object Promise]",g="[object RegExp]",v="[object Set]",_="[object String]",y="[object Symbol]",l="[object WeakMap]",D="[object ArrayBuffer]",M="[object DataView]",I="[object Float32Array]",j="[object Float64Array]",w="[object Int8Array]",P="[object Int16Array]",k="[object Int32Array]",S="[object Uint8Array]",A="[object Uint8ClampedArray]",O="[object Uint16Array]",tt="[object Uint32Array]",X=/[\\^$.*+?()[\]{}|]/g,ht=/\w*$/,se=/^\[object .+?Constructor\]$/,oe=/^(?:0|[1-9]\d*)$/,U={};U[c]=U[h]=U[D]=U[M]=U[m]=U[C]=U[I]=U[j]=U[w]=U[P]=U[k]=U[b]=U[d]=U[f]=U[g]=U[v]=U[_]=U[y]=U[S]=U[A]=U[O]=U[tt]=!0,U[F]=U[E]=U[l]=!1;var Hr=typeof ot=="object"&&ot&&ot.Object===Object&&ot,Nr=typeof self=="object"&&self&&self.Object===Object&&self,ut=Hr||Nr||Function("return this")(),He=r&&!r.nodeType&&r,W=He&&!0&&t&&!t.nodeType&&t,Ne=W&&W.exports===He;function Lr(e,a){return e.set(a[0],a[1]),e}function lt(e,a){return e.add(a),e}function Le(e,a){for(var o=-1,u=e?e.length:0;++o<u&&a(e[o],o,e)!==!1;);return e}function Ue(e,a){for(var o=-1,u=a.length,R=e.length;++o<u;)e[R+o]=a[o];return e}function ce(e,a,o,u){for(var R=-1,T=e?e.length:0;++R<T;)o=a(o,e[R],R,e);return o}function ue(e,a){for(var o=-1,u=Array(e);++o<e;)u[o]=a(o);return u}function We(e,a){return e==null?void 0:e[a]}function le(e){var a=!1;if(e!=null&&typeof e.toString!="function")try{a=!!(e+"")}catch{}return a}function Ge(e){var a=-1,o=Array(e.size);return e.forEach(function(u,R){o[++a]=[R,u]}),o}function fe(e,a){return function(o){return e(a(o))}}function Be(e){var a=-1,o=Array(e.size);return e.forEach(function(u){o[++a]=u}),o}var Ur=Array.prototype,Wr=Function.prototype,Ut=Object.prototype,de=ut["__core-js_shared__"],$e=function(){var e=/[^.]+$/.exec(de&&de.keys&&de.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ke=Wr.toString,mt=Ut.hasOwnProperty,Wt=Ut.toString,Gr=RegExp("^"+Ke.call(mt).replace(X,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Pt=Ne?ut.Buffer:void 0,Gt=ut.Symbol,pe=ut.Uint8Array,ct=fe(Object.getPrototypeOf,Object),Ye=Object.create,Ve=Ut.propertyIsEnumerable,Br=Ur.splice,he=Object.getOwnPropertySymbols,Bt=Pt?Pt.isBuffer:void 0,Xe=fe(Object.keys,Object),$t=dt(ut,"DataView"),Ct=dt(ut,"Map"),ft=dt(ut,"Promise"),Kt=dt(ut,"Set"),me=dt(ut,"WeakMap"),jt=dt(Object,"create"),ye=et($t),Rt=et(Ct),be=et(ft),ge=et(Kt),_e=et(me),Tt=Gt?Gt.prototype:void 0,qe=Tt?Tt.valueOf:void 0;function It(e){var a=-1,o=e?e.length:0;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function $r(){this.__data__=jt?jt(null):{}}function Kr(e){return this.has(e)&&delete this.__data__[e]}function Yr(e){var a=this.__data__;if(jt){var o=a[e];return o===i?void 0:o}return mt.call(a,e)?a[e]:void 0}function Ze(e){var a=this.__data__;return jt?a[e]!==void 0:mt.call(a,e)}function Ie(e,a){var o=this.__data__;return o[e]=jt&&a===void 0?i:a,this}It.prototype.clear=$r,It.prototype.delete=Kr,It.prototype.get=Yr,It.prototype.has=Ze,It.prototype.set=Ie;function Y(e){var a=-1,o=e?e.length:0;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Vr(){this.__data__=[]}function Xr(e){var a=this.__data__,o=Vt(a,e);if(o<0)return!1;var u=a.length-1;return o==u?a.pop():Br.call(a,o,1),!0}function qr(e){var a=this.__data__,o=Vt(a,e);return o<0?void 0:a[o][1]}function Zr(e){return Vt(this.__data__,e)>-1}function Jr(e,a){var o=this.__data__,u=Vt(o,e);return u<0?o.push([e,a]):o[u][1]=a,this}Y.prototype.clear=Vr,Y.prototype.delete=Xr,Y.prototype.get=qr,Y.prototype.has=Zr,Y.prototype.set=Jr;function q(e){var a=-1,o=e?e.length:0;for(this.clear();++a<o;){var u=e[a];this.set(u[0],u[1])}}function Qr(){this.__data__={hash:new It,map:new(Ct||Y),string:new It}}function tn(e){return zt(this,e).delete(e)}function en(e){return zt(this,e).get(e)}function rn(e){return zt(this,e).has(e)}function nn(e,a){return zt(this,e).set(e,a),this}q.prototype.clear=Qr,q.prototype.delete=tn,q.prototype.get=en,q.prototype.has=rn,q.prototype.set=nn;function rt(e){this.__data__=new Y(e)}function an(){this.__data__=new Y}function sn(e){return this.__data__.delete(e)}function on(e){return this.__data__.get(e)}function cn(e){return this.__data__.has(e)}function un(e,a){var o=this.__data__;if(o instanceof Y){var u=o.__data__;if(!Ct||u.length<n-1)return u.push([e,a]),this;o=this.__data__=new q(u)}return o.set(e,a),this}rt.prototype.clear=an,rt.prototype.delete=sn,rt.prototype.get=on,rt.prototype.has=cn,rt.prototype.set=un;function Yt(e,a){var o=ke(e)||qt(e)?ue(e.length,String):[],u=o.length,R=!!u;for(var T in e)mt.call(e,T)&&!(R&&(T=="length"||wn(T,u)))&&o.push(T);return o}function Je(e,a,o){var u=e[a];(!(mt.call(e,a)&&nr(u,o))||o===void 0&&!(a in e))&&(e[a]=o)}function Vt(e,a){for(var o=e.length;o--;)if(nr(e[o][0],a))return o;return-1}function yt(e,a){return e&&we(a,Ee(a),e)}function ve(e,a,o,u,R,T,H){var z;if(u&&(z=T?u(e,R,T,H):u(e)),z!==void 0)return z;if(!gt(e))return e;var G=ke(e);if(G){if(z=vn(e),!a)return gn(e,z)}else{var N=St(e),Z=N==E||N==L;if(ir(e))return Xt(e,a);if(N==f||N==c||Z&&!T){if(le(e))return T?e:{};if(z=bt(Z?{}:e),!a)return _n(e,yt(z,e))}else{if(!U[N])return T?e:{};z=Sn(e,N,ve,a)}}H||(H=new rt);var nt=H.get(e);if(nt)return nt;if(H.set(e,z),!G)var K=o?In(e):Ee(e);return Le(K||e,function(J,V){K&&(V=J,J=e[V]),Je(z,V,ve(J,a,o,u,V,e,H))}),z}function ln(e){return gt(e)?Ye(e):{}}function fn(e,a,o){var u=a(e);return ke(e)?u:Ue(u,o(e))}function dn(e){return Wt.call(e)}function pn(e){if(!gt(e)||Tn(e))return!1;var a=Te(e)||le(e)?Gr:se;return a.test(et(e))}function hn(e){if(!er(e))return Xe(e);var a=[];for(var o in Object(e))mt.call(e,o)&&o!="constructor"&&a.push(o);return a}function Xt(e,a){if(a)return e.slice();var o=new e.constructor(e.length);return e.copy(o),o}function Se(e){var a=new e.constructor(e.byteLength);return new pe(a).set(new pe(e)),a}function Ft(e,a){var o=a?Se(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}function Qe(e,a,o){var u=a?o(Ge(e),!0):Ge(e);return ce(u,Lr,new e.constructor)}function tr(e){var a=new e.constructor(e.source,ht.exec(e));return a.lastIndex=e.lastIndex,a}function mn(e,a,o){var u=a?o(Be(e),!0):Be(e);return ce(u,lt,new e.constructor)}function yn(e){return qe?Object(qe.call(e)):{}}function bn(e,a){var o=a?Se(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}function gn(e,a){var o=-1,u=e.length;for(a||(a=Array(u));++o<u;)a[o]=e[o];return a}function we(e,a,o,u){o||(o={});for(var R=-1,T=a.length;++R<T;){var H=a[R],z=void 0;Je(o,H,z===void 0?e[H]:z)}return o}function _n(e,a){return we(e,vt(e),a)}function In(e){return fn(e,Ee,vt)}function zt(e,a){var o=e.__data__;return kn(a)?o[typeof a=="string"?"string":"hash"]:o.map}function dt(e,a){var o=We(e,a);return pn(o)?o:void 0}var vt=he?fe(he,Object):Mn,St=dn;($t&&St(new $t(new ArrayBuffer(1)))!=M||Ct&&St(new Ct)!=b||ft&&St(ft.resolve())!=p||Kt&&St(new Kt)!=v||me&&St(new me)!=l)&&(St=function(e){var a=Wt.call(e),o=a==f?e.constructor:void 0,u=o?et(o):void 0;if(u)switch(u){case ye:return M;case Rt:return b;case be:return p;case ge:return v;case _e:return l}return a});function vn(e){var a=e.length,o=e.constructor(a);return a&&typeof e[0]=="string"&&mt.call(e,"index")&&(o.index=e.index,o.input=e.input),o}function bt(e){return typeof e.constructor=="function"&&!er(e)?ln(ct(e)):{}}function Sn(e,a,o,u){var R=e.constructor;switch(a){case D:return Se(e);case m:case C:return new R(+e);case M:return Ft(e,u);case I:case j:case w:case P:case k:case S:case A:case O:case tt:return bn(e,u);case b:return Qe(e,u,o);case d:case _:return new R(e);case g:return tr(e);case v:return mn(e,u,o);case y:return yn(e)}}function wn(e,a){return a=a??s,!!a&&(typeof e=="number"||oe.test(e))&&e>-1&&e%1==0&&e<a}function kn(e){var a=typeof e;return a=="string"||a=="number"||a=="symbol"||a=="boolean"?e!=="__proto__":e===null}function Tn(e){return!!$e&&$e in e}function er(e){var a=e&&e.constructor,o=typeof a=="function"&&a.prototype||Ut;return e===o}function et(e){if(e!=null){try{return Ke.call(e)}catch{}try{return e+""}catch{}}return""}function rr(e){return ve(e,!0,!0)}function nr(e,a){return e===a||e!==e&&a!==a}function qt(e){return En(e)&&mt.call(e,"callee")&&(!Ve.call(e,"callee")||Wt.call(e)==c)}var ke=Array.isArray;function Zt(e){return e!=null&&ar(e.length)&&!Te(e)}function En(e){return sr(e)&&Zt(e)}var ir=Bt||An;function Te(e){var a=gt(e)?Wt.call(e):"";return a==E||a==L}function ar(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=s}function gt(e){var a=typeof e;return!!e&&(a=="object"||a=="function")}function sr(e){return!!e&&typeof e=="object"}function Ee(e){return Zt(e)?Yt(e):hn(e)}function Mn(){return[]}function An(){return!1}t.exports=rr}(De,De.exports);var ki=De.exports;const B=yr(ki),Wn=t=>new Promise((r,n)=>{const i=new Image;console.warn("update cdn config for cors?"),i.onload=()=>{const s=i.width,c=i.height;r({width:s,height:c})},i.onerror=s=>{n(s)},i.crossOrigin="anonymous",i.src=t}),Ti=t=>new Promise((r,n)=>{const i=new Audio;i.preload="auto",i.addEventListener("loadedmetadata",()=>{const s=i.duration*1e3;r({duration:s})}),i.addEventListener("error",s=>{n(s)}),i.src=t,i.crossOrigin="anonymous",i.load()}),Gn=t=>new Promise((r,n)=>{const i=document.createElement("video");i.preload="auto",i.addEventListener("loadedmetadata",()=>{const s=i.duration*1e3,c=i.videoWidth,h=i.videoHeight;r({duration:s,width:c,height:h})}),i.addEventListener("error",s=>{n(s)}),i.src=t,i.load()}),Bn=(t,r)=>{const n=document.createElement("div");Object.keys(r).forEach(s=>{s!=="height"&&(n.style[s]=r[s])}),document.body.appendChild(n),n.textContent=t,n.style.whiteSpace="normal",n.style.position="absolute",n.style.visibility="hidden",n.style.display="inline-block",n.style.width=r.width+"px",n.style.fontSize=r.fontSize+"px";const i=getComputedStyle(n).height;return document.body.removeChild(n),parseFloat(i)},br=t=>{const r=t.map(n=>new FontFace(n.fontFamily,`url(${n.url})`).load().catch(i=>i));return r.length===0?Promise.resolve(!0):new Promise((n,i)=>{Promise.all(r).then(s=>{s.forEach(c=>{c&&c.family&&(document.fonts.add(c),n(!0))})}).catch(s=>i(s))})},Pe={color:"#000000",x:0,y:0,blur:0},Jt=(t,r)=>{let n=r!=null&&r.trim?r.trim.to-r.trim.from:(r==null?void 0:r.duration)||5e3;const i={from:0,to:n};if(!t)return i;if(t.from<0)return console.error("'from' must be a non-negative number. Returning default display."),i;if(t.from!==void 0&&t.to===void 0)return{from:t.from,to:t.from+n};if(t.to!==void 0){if(t.to<0)return console.error("'to' must be a non-negative number. Returning default display."),i;if(t.to<t.from)return console.error("'to' must be greater than or equal to 'from'. Returning default display."),i}return t},$n=(t,r)=>t?t.from&&!t.to?{from:t.from,to:r.duration}:t:{from:0,to:r.duration};function Ce(t,r){const n={x:t.size.width/2,y:t.size.height/2},i={x:r.width/2,y:r.height/2},s=Math.min(t.size.width/r.width,t.size.height/r.height),c=n.x-i.x;return{top:`${n.y-i.y}px`,left:`${c}px`,transform:`scale(${s})`}}const gr=async(t,r)=>{const n=t.details.src,i=await Gn(n),s=Ce(r,{...i}),c=$n(t.trim,{duration:i.duration}),h={width:i.width,height:i.height,opacity:100,src:n,volume:t.details.volume??100,borderRadius:t.details.borderRadius??0,borderWidth:t.details.borderWidth??0,borderColor:t.details.borderColor||"#000000",boxShadow:t.details.boxShadow||Pe,top:t.details.top||s.top||"0px",left:t.details.left||s.left||"0px",transform:t.details.transform||s.transform,blur:t.details.blur||0,brightness:t.details.brightness||100,flipX:t.details.flipX||!1,flipY:t.details.flipY||!1,rotate:t.details.rotate||"0deg",visibility:t.details.visibility||"visible",mediaWidth:t.details.mediaWidth||i.width||100,mediaHeight:t.details.mediaHeight||i.height||100};return{...t,trim:c,type:"video",name:"video",details:h,playbackRate:t.playbackRate||1,display:Jt(t.display,{duration:i.duration,trim:c}),duration:i.duration}},_r=async t=>{console.log({payload:t});const r=t.id,n=t.details,i=await Ti(n.src);console.log({audioData:i});const s=i.duration,c=$n(t.trim,{duration:s});return{id:r,name:"",type:"audio",display:Jt(t.display,{duration:s,trim:c}),trim:c,playbackRate:t.playbackRate||1,details:{src:n.src,volume:n.volume??100},metadata:{...t.metadata},duration:s}},Ei=async(t,r)=>{const n=t.trackItemsIds,i=t.size,s=Math.min(r.size.width/i.width,r.size.height/i.height),c=t.rotate||0,h=t.position,m=t.display,C=t.trim||t.display;let F=1/0,E=0;const L=n.map(d=>{const f=t.trackItemsMap[d],p=t.trackItemsDetails[d];if(f.display.from<F&&(F=f.display.from),f.display.to>E&&(E=f.display.to),f.type==="text")return Sr({...f,details:p.details},{size:i});if(f.type==="image")return Ir({...f,details:p.details},{size:i});if(f.type==="video")return gr({...f,details:p.details},{size:i});if(f.type==="audio")return _r({...f,details:p.details});if(f.type==="caption")return vr({...f,details:p.details},{size:i})}),b=await Promise.all(L);return{id:t.id,details:b,size:i,position:{top:h.top||0,left:h.left||0},trim:C,scale:s,display:m||{from:F,to:E},rotate:c,activeEdit:!1}},Ir=async(t,r)=>{const n=t.details,i=await Wn(n.src),s=Ce(r,i);return{id:t.id,type:"image",name:"image",display:Jt(t.display),playbackRate:t.playbackRate||1,details:{src:n.src||"",width:n.width||i.width||100,height:n.height||i.height||100,opacity:n.opacity??100,transform:n.transform||s.transform,border:n.border||"none",borderRadius:n.borderRadius||0,boxShadow:n.boxShadow||Pe,top:n.top||s.top||"0px",left:n.left||s.left||"0px",borderWidth:n.borderWidth??0,borderColor:n.borderColor||"#000000",blur:n.blur||0,brightness:n.brightness||100,flipX:n.flipX||!1,flipY:n.flipY||!1,rotate:n.rotate||"0deg",visibility:n.visibility||"visible",mediaWidth:n.mediaWidth||n.width||i.width||100,mediaHeight:n.mediaHeight||n.height||i.height||100},metadata:t.metadata||{}}},vr=async(t,r)=>{const n=t;n.details.fontUrl&&await br([{fontFamily:n.details.fontFamily,url:n.details.fontUrl}]);const i=n.id,s=n.details,c=Kn(s),h=Bn(n.details.text,c),m=Ce(r,{width:c.width,height:h});return{id:i,name:"caption",type:"caption",display:Jt(n.display),details:{...c,text:s.text||"",height:h,fontUrl:s.fontUrl,top:c.top||m.top,left:c.left||m.left,borderWidth:s.borderWidth||0,borderColor:s.borderColor||"#000000",boxShadow:s.boxShadow||Pe,words:s.words||[]},metadata:{}}},Sr=async(t,r)=>{t.details.fontUrl&&await br([{fontFamily:t.details.fontFamily,url:t.details.fontUrl}]);const n=t.id,i=t.details,s=Kn(i),c=Bn(t.details.text,s),h=Ce(r,{width:s.width,height:c});return{id:n,name:"text",type:"text",display:Jt(t.display),details:{...s,text:i.text||"",height:c,fontUrl:i.fontUrl,top:s.top||h.top,left:s.left||h.left,borderWidth:i.borderWidth||0,borderColor:i.borderColor||"#000000",boxShadow:i.boxShadow||Pe},metadata:{}}},Kn=t=>({fontFamily:t.fontFamily||"Arial",fontSize:t.fontSize||"16px",fontWeight:t.fontWeight||"normal",fontStyle:t.fontStyle||"normal",textDecoration:t.textDecoration||"none",textAlign:t.textAlign||"left",lineHeight:t.lineHeight||"normal",letterSpacing:t.letterSpacing||"normal",wordSpacing:t.wordSpacing||"normal",color:t.color||"#ffffff",backgroundColor:t.backgroundColor||"transparent",border:t.border||"none",textShadow:t.textShadow||"none",text:t.text||"",opacity:t.opacity??100,width:t.width||300,wordWrap:t.wordWrap||"normal",wordBreak:t.wordBreak||"normal",WebkitTextStrokeColor:t.WebkitTextStrokeColor||"#ffffff",WebkitTextStrokeWidth:t.WebkitTextStrokeWidth||"0px",top:t.top,left:t.left,textTransform:t.textTransform||"none",transform:t.transform||"none"}),Mi="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let je=(t=21)=>{let r="",n=crypto.getRandomValues(new Uint8Array(t));for(;t--;)r+=Mi[n[t]&63];return r};function Ai(t,r){return t.filter(i=>{if(r.forEach(s=>{i.items.includes(s)&&(i.items=i.items.filter(c=>c!==s))}),i.items.length!==0)return i})}function wr(t=16){const r="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",n=r.charAt(Math.floor(Math.random()*r.length));let i=je(t-1);return i=i.replace(/[^a-zA-Z0-9]/g,"").slice(0,t-1),n+i}const Lt=t=>Object.keys(t).reduce((r,n)=>{const{display:i,playbackRate:s}=t[n];return Math.max(r,i.to/(s||1))},0),Oi=(t,r,n,i,s)=>{let c=!1;return t.forEach(h=>{const m=n[h],C=m.display.from,F=m.display.to;if(i!==void 0||s!==void 0){const E=r.find((b,d)=>{if(i!==void 0&&b.id===i)return b;if(s!==void 0&&d===s)return b});if(!E)return;c=E.items.map(b=>n[b]).some(b=>{const d=b.display.from,f=b.display.to;return d<=C&&f>=F})}}),c};function xi(t){const r=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.DESIGN_PREFIX))),n=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.ADD_PREFIX))),i=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.LAYER_PREFIX))),s=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.HISTORY_PREFIX))),c=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.ACTIVE_PREFIX))),h=x.subject.pipe(x.filter(({key:d})=>d.startsWith(x.EDIT_PREFIX))),m=r.subscribe(async d=>{var f,p;if(d.key===x.DESIGN_LOAD){const g=(f=d.value)==null?void 0:f.payload,v=g.size,_=g.trackItemIds,y=g.trackItemsMap,l=g.trackItemDetailsMap;console.warn("IMPROVE FONTS LOADING");const D=_.map(async I=>{var j;try{const w=l[I],P=y[I];if(w.type==="image"){const k=await Ir({id:I,details:w.details,...P},{size:v}),{details:S,...A}=k;l[I]={type:"image",details:S},y[I]=A}else if(w.type==="video"){const k=B((j=d.value)==null?void 0:j.payload.trackItemsMap[I]),S=await gr({...w,...k,...P},{size:v}),{details:A,...O}=S;l[I]={type:"video",details:A},y[I]=O}else if(w.type==="audio"){const k=await _r({id:I,details:w.details,...P}),{details:S,...A}=k;l[I]={type:"audio",details:S},y[I]=A}else if(w.type==="caption"){const k=await vr({id:I,details:w.details,...P},{size:v}),{details:S,...A}=k;l[I]={type:"caption",details:S},y[I]=A}else if(w.type==="text"){const k=await Sr({id:I,details:w.details,...P},{size:v}),{details:S,...A}=k;l[I]={type:"text",details:S},y[I]=A}return!0}catch{return!1}});await Promise.all(D);const M=Lt(y);t.updateState({...g,trackItemsMap:y,duration:M})}if(d.key===x.DESIGN_RESIZE){const g=(p=d.value)==null?void 0:p.payload;t.updateState({size:g})}}),C=s.subscribe(d=>{if(d.key===x.HISTORY_UNDO)return t.undo();if(d.key===x.HISTORY_REDO)return t.redo()}),F=i.subscribe(d=>{var g,v,_,y;const f=[],p=[];if((g=d.value)!=null&&g.payload.trackItemIds&&(f.push((v=d.value)==null?void 0:v.payload.trackItemIds),t.updateState({activeIds:f})),d.key===x.LAYER_DELETE){const l=(_=d.value)==null?void 0:_.payload.trackItemIds,D=B(t.getState()),M=l&&l.length?l:D.activeIds,I=D.trackItemIds,j=D.trackItemDetailsMap,w=I.filter(O=>!M.includes(O)),P=Object.fromEntries(Object.entries(j).filter(([O])=>!M.includes(O))),k=Ai(D.tracks,M),S=Object.fromEntries(Object.entries(D.trackItemsMap).filter(([O])=>!M.includes(O))),A=Lt(S);t.updateState({trackItemIds:w,trackItemDetailsMap:P,activeIds:[],trackItemsMap:S,tracks:k,duration:A},{updateHistory:!0,kind:"remove"})}if(d.key===x.LAYER_CLONE){const l=B(t.getState()),D=((y=d.value)==null?void 0:y.payload.trackItemIds)||l.activeIds;if(D.length===0)return;D.forEach(I=>{const j=l.trackItemsMap[I],w=l.trackItemDetailsMap[I],P=wr();p.push(P),l.trackItemsMap={...l.trackItemsMap,[P]:{...B(j),id:P}},l.trackItemDetailsMap={...l.trackItemDetailsMap,[P]:{...B(w)}},l.trackItemIds.push(P)});const M=[];l.tracks.forEach(I=>{const j={...I,items:[],id:je()};I.items.forEach(w=>{if(D.includes(w)){const P=D.indexOf(w);j.items.push(p[P])}}),M.push(j)}),M.forEach(I=>{I.items.length!==0&&l.tracks.unshift(I)}),t.updateState({trackItemDetailsMap:l.trackItemDetailsMap,tracks:l.tracks,trackItemIds:l.trackItemIds,trackItemsMap:l.trackItemsMap},{updateHistory:!0,kind:"update"})}}),E=n.subscribe(async d=>{var l,D,M,I,j,w,P,k;const f=B(t.getState());let p=[],g="text";const v=(l=d.value)==null?void 0:l.options.trackId,_=(D=d.value)==null?void 0:D.options.trackIndex;if(d.key===x.ADD_CAPTION){g="caption";const S=(M=d.value)==null?void 0:M.payload,A=[];for(const X of S){const ht=vr(X,{size:f.size});A.push(ht)}const O=await Promise.all(A),tt=[];for(const X of O){const ht=X.id;tt.push(ht);const{details:se,...oe}=X;f.trackItemDetailsMap[ht]={type:g,details:se},f.trackItemsMap[ht]=oe,f.trackItemIds.push(ht)}p=tt}if(d.key===x.ADD_TEXT){g="text";const S=await Sr((I=d.value)==null?void 0:I.payload,{size:f.size}),{details:A,...O}=S;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}if(d.key===x.ADD_TEMPLATE){g="template";const S=await Ei((j=d.value)==null?void 0:j.payload,{size:f.size}),{details:A,...O}=S;f.trackItemsMap[S.id]={...O,type:"template"},f.trackItemIds.push(O.id),f.trackItemDetailsMap[O.id]={type:"template",details:A},p=[O.id]}if(d.key===x.ADD_IMAGE){g="image";const S=await Ir((w=d.value)==null?void 0:w.payload,{size:f.size}),{details:A,...O}=S;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}if(d.key===x.ADD_AUDIO){g="audio";const S=await _r((P=d.value)==null?void 0:P.payload),{details:A,...O}=S;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}if(d.key===x.ADD_VIDEO){g="video";const S=await gr((k=d.value)==null?void 0:k.payload,{size:f.size}),{details:A,...O}=S;f.trackItemDetailsMap[O.id]={type:g,details:A},f.trackItemsMap[O.id]=O,f.trackItemIds.push(O.id),p=[O.id]}const y=Oi(p,f.tracks,f.trackItemsMap,v,_);v!==void 0&&v!=="main"&&!y?f.tracks.map(A=>A.id).includes(v)&&(f.tracks=f.tracks.map(A=>(A.id===v&&A.items.push(...p),A))):_!==void 0&&!y?f.tracks=f.tracks.map((S,A)=>(A===_&&S.items.push(...p),S)):f.tracks.unshift({id:je(),accepts:["text","audio","helper","video","image","caption"],type:g,items:p,magnetic:!1,static:!1}),f.duration=Lt(f.trackItemsMap),t.updateState({trackItemIds:f.trackItemIds,trackItemDetailsMap:f.trackItemDetailsMap,trackItemsMap:f.trackItemsMap,tracks:f.tracks,duration:f.duration},{updateHistory:!0,kind:"add"})}),L=c.subscribe(async d=>{var f;if(d.key===x.ACTIVE_SPLIT){const p=B(t.getState()),g=(f=d.value)==null?void 0:f.options.time;if(p.activeIds.length===1){const v=p.activeIds[0],_=p.trackItemsMap[v];if(g>=_.display.to||g<=_.display.from)return;const y=p.trackItemDetailsMap[v],l=wr(),D={..._,id:l,display:{from:g,to:_.display.to},trim:{from:g,to:_.display.to}};p.trackItemsMap[v].display.to=g,p.trackItemsMap[l]=D,p.trackItemIds.push(l),p.trackItemDetailsMap[l]=y,p.tracks.forEach(M=>{M.items.includes(v)&&M.items.push(l)}),t.updateState({trackItemDetailsMap:p.trackItemDetailsMap,tracks:p.tracks,trackItemIds:p.trackItemIds,trackItemsMap:p.trackItemsMap},{updateHistory:!0,kind:"update"})}return}if(d.key===x.ACTIVE_CLONE){const p=B(t.getState());if(p.activeIds.length){const g=p.activeIds,v=[],_={activeIds:g,trackItemDetailsMap:{},trackItemsMap:{},tracks:[]};g.forEach(l=>{_.trackItemDetailsMap[l]=p.trackItemDetailsMap[l],_.trackItemsMap[l]=p.trackItemsMap[l],v.push(p.tracks.find(D=>D.items.includes(l)))});const y=new Set;v.filter(l=>y.has(l.id)?!1:(y.add(l),!0)),_.tracks=Array.from(y.keys()),localStorage.setItem("DesignComboTemp",JSON.stringify(_))}}if(d.key===x.ACTIVE_PASTE){const p=localStorage.getItem("DesignComboTemp");if(!p)return;const g=B(t.getState()),v=JSON.parse(p),_={},y=v.trackItemsMap,l=v.trackItemDetailsMap,D=v.tracks,M=[],I=v.activeIds.map(async j=>{const w=l[j];(w.type==="caption"||w.type==="text")&&w.details.fontUrl&&await br([{fontFamily:w.details.fontFamily,url:w.details.fontUrl}]);const P=wr();return _[j]=P,g.trackItemsMap[P]={...y[j],id:P},g.trackItemDetailsMap[P]=w,g.trackItemIds.push(P),!0});await Promise.all(I),D.forEach(j=>{const w=j.items.map(k=>_[k]),P={...j,items:w,id:je()};M.push(P)}),g.tracks=[...g.tracks,...M],t.updateState({trackItemDetailsMap:g.trackItemDetailsMap,tracks:g.tracks,trackItemIds:g.trackItemIds,trackItemsMap:g.trackItemsMap},{updateHistory:!0,kind:"update"})}}),b=h.subscribe(async d=>{var f,p,g,v;if(d.key===x.DELETE_TEMPLATE_ITEM){const _=B(t.getState()),[y]=(f=d.value)==null?void 0:f.payload.trackItemIds,l=_.trackItemDetailsMap;_.trackItemIds.forEach(M=>{const I=l[M];if(I.type==="template"&&I.details.map(w=>w.id).includes(y)){const w=I.details.filter(P=>P.id!==y);I.details=w}}),t.updateState({trackItemDetailsMap:{...l}},{updateHistory:!0,kind:"update"})}if(d.key===x.EDIT_OBJECT){const _=B(t.getState()),y=_.trackItemDetailsMap,l=_.trackItemsMap,D=Object.keys((p=d.value)==null?void 0:p.payload);if(!D.length)return;const M=(g=d.value)==null?void 0:g.payload;D.forEach(j=>{const w=M[j];w.details?y[j].details={...y[j].details,...w.details}:M[j].playbackRate?l[j].playbackRate=M[j].playbackRate:y[j].type==="template"&&(l[j]={...l[j],...M[j]})});const I=Lt(l);t.updateState({trackItemDetailsMap:{...y},trackItemsMap:{...l},duration:I},{updateHistory:!0,kind:"update:details"})}if(d.key===x.EDIT_TEMPLATE_ITEM){const _=(v=d.value)==null?void 0:v.payload,y=Object.keys(_)[0],l=Object.values(_)[0],D=B(t.getState());for(const M of D.trackItemIds)if(D.trackItemsMap[M].type==="template"){const I=D.trackItemDetailsMap[M];if(I.details.map(w=>w.id).includes(y)){for(let w of I.details)if(w.id===y){if(l.details){if(l.type==="image"&&l.details.src){const k=await Wn(l.details.src),S=w.details.width,A=w.details.height;let O=k.width,tt=k.height;const X=k.width/k.height;S/A>X?(O=S,tt=S/X):(tt=A,O=A*X),l.details.mediaWidth=O,l.details.mediaHeight=tt}if(l.type==="video"&&l.details.src){const k=await Gn(l.details.src),S=w.details.width,A=w.details.height;let O=k.width,tt=k.height;const X=k.width/k.height;S/A>X?(O=S,tt=S/X):(tt=A,O=A*X),l.details.mediaWidth=O,l.details.mediaHeight=tt}const P=w.details;w.details={...P,...l.details},l.details=w.details}w={...w,...l},D.trackItemDetailsMap[M].details=I.details.map(P=>P.id===y?w:P)}}}t.updateState({trackItemDetailsMap:{...D.trackItemDetailsMap}},{updateHistory:!0,kind:"update:details"})}if(d.key===x.CLOSE_EDIT_TEMPLATE){const _=B(t.getState());_.trackItemIds.forEach(y=>{const l=_.trackItemsMap[y];l.type==="template"&&(l.activeEdit=!1,t.updateState({trackItemsMap:{..._.trackItemsMap,[y]:l},activeIds:[]}))})}});return{unsubscribe:()=>{E.unsubscribe(),L.unsubscribe(),b.unsubscribe(),C.unsubscribe(),F.unsubscribe(),m.unsubscribe()}}}const Di={Date:!0,RegExp:!0,String:!0,Number:!0};function Yn(t,r,n={cyclesFix:!0},i=[]){var m,C;let s=[];const c=Array.isArray(t);for(const F in t){const E=t[F],L=c?+F:F;if(!(F in r)){s.push({type:"REMOVE",path:[L],oldValue:t[F]});continue}const b=r[F],d=typeof E=="object"&&typeof b=="object"&&Array.isArray(E)===Array.isArray(b);if(E&&b&&d&&!Di[(C=(m=Object.getPrototypeOf(E))==null?void 0:m.constructor)==null?void 0:C.name]&&(!n.cyclesFix||!i.includes(E))){const f=Yn(E,b,n,n.cyclesFix?i.concat([E]):[]);s.push.apply(s,f.map(p=>(p.path.unshift(L),p)))}else E!==b&&!(Number.isNaN(E)&&Number.isNaN(b))&&!(d&&(isNaN(E)?E+""==b+"":+E==+b))&&s.push({path:[L],type:"CHANGE",value:b,oldValue:E})}const h=Array.isArray(r);for(const F in r)F in t||s.push({type:"CREATE",path:[h?+F:F],value:r[F]});return s}var kr=Symbol.for("immer-nothing"),Qt=Symbol.for("immer-draftable"),at=Symbol.for("immer-state"),Vn=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){return`produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function $(t,...r){if(process.env.NODE_ENV!=="production"){const n=Vn[t],i=typeof n=="function"?n.apply(null,r):n;throw new Error(`[Immer] ${i}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Mt=Object.getPrototypeOf;function At(t){return!!t&&!!t[at]}function kt(t){var r;return t?Xn(t)||Array.isArray(t)||!!t[Qt]||!!((r=t.constructor)!=null&&r[Qt])||re(t)||ne(t):!1}var Pi=Object.prototype.constructor.toString();function Xn(t){if(!t||typeof t!="object")return!1;const r=Mt(t);if(r===null)return!0;const n=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return n===Object?!0:typeof n=="function"&&Function.toString.call(n)===Pi}function te(t,r){Ot(t)===0?Reflect.ownKeys(t).forEach(n=>{r(n,t[n],t)}):t.forEach((n,i)=>r(i,n,t))}function Ot(t){const r=t[at];return r?r.type_:Array.isArray(t)?1:re(t)?2:ne(t)?3:0}function ee(t,r){return Ot(t)===2?t.has(r):Object.prototype.hasOwnProperty.call(t,r)}function Tr(t,r){return Ot(t)===2?t.get(r):t[r]}function qn(t,r,n){const i=Ot(t);i===2?t.set(r,n):i===3?t.add(n):t[r]=n}function Ci(t,r){return t===r?t!==0||1/t===1/r:t!==t&&r!==r}function re(t){return t instanceof Map}function ne(t){return t instanceof Set}function xt(t){return t.copy_||t.base_}function Er(t,r){if(re(t))return new Map(t);if(ne(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const n=Xn(t);if(r===!0||r==="class_only"&&!n){const i=Object.getOwnPropertyDescriptors(t);delete i[at];let s=Reflect.ownKeys(i);for(let c=0;c<s.length;c++){const h=s[c],m=i[h];m.writable===!1&&(m.writable=!0,m.configurable=!0),(m.get||m.set)&&(i[h]={configurable:!0,writable:!0,enumerable:m.enumerable,value:t[h]})}return Object.create(Mt(t),i)}else{const i=Mt(t);if(i!==null&&n)return{...t};const s=Object.create(i);return Object.assign(s,t)}}function Mr(t,r=!1){return Re(t)||At(t)||!kt(t)||(Ot(t)>1&&(t.set=t.add=t.clear=t.delete=ji),Object.freeze(t),r&&Object.entries(t).forEach(([n,i])=>Mr(i,!0))),t}function ji(){$(2)}function Re(t){return Object.isFrozen(t)}var Ar={};function Dt(t){const r=Ar[t];return r||$(0,t),r}function Ri(t,r){Ar[t]||(Ar[t]=r)}var ie;function Zn(){return ie}function Fi(t,r){return{drafts_:[],parent_:t,immer_:r,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function Jn(t,r){r&&(Dt("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=r)}function Or(t){xr(t),t.drafts_.forEach(zi),t.drafts_=null}function xr(t){t===ie&&(ie=t.parent_)}function Qn(t){return ie=Fi(ie,t)}function zi(t){const r=t[at];r.type_===0||r.type_===1?r.revoke_():r.revoked_=!0}function ti(t,r){r.unfinalizedDrafts_=r.drafts_.length;const n=r.drafts_[0];return t!==void 0&&t!==n?(n[at].modified_&&(Or(r),$(4)),kt(t)&&(t=Fe(r,t),r.parent_||ze(r,t)),r.patches_&&Dt("Patches").generateReplacementPatches_(n[at].base_,t,r.patches_,r.inversePatches_)):t=Fe(r,n,[]),Or(r),r.patches_&&r.patchListener_(r.patches_,r.inversePatches_),t!==kr?t:void 0}function Fe(t,r,n){if(Re(r))return r;const i=r[at];if(!i)return te(r,(s,c)=>ei(t,i,r,s,c,n)),r;if(i.scope_!==t)return r;if(!i.modified_)return ze(t,i.base_,!0),i.base_;if(!i.finalized_){i.finalized_=!0,i.scope_.unfinalizedDrafts_--;const s=i.copy_;let c=s,h=!1;i.type_===3&&(c=new Set(s),s.clear(),h=!0),te(c,(m,C)=>ei(t,i,s,m,C,n,h)),ze(t,s,!1),n&&t.patches_&&Dt("Patches").generatePatches_(i,n,t.patches_,t.inversePatches_)}return i.copy_}function ei(t,r,n,i,s,c,h){if(process.env.NODE_ENV!=="production"&&s===n&&$(5),At(s)){const m=c&&r&&r.type_!==3&&!ee(r.assigned_,i)?c.concat(i):void 0,C=Fe(t,s,m);if(qn(n,i,C),At(C))t.canAutoFreeze_=!1;else return}else h&&n.add(s);if(kt(s)&&!Re(s)){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1)return;Fe(t,s),(!r||!r.scope_.parent_)&&typeof i!="symbol"&&Object.prototype.propertyIsEnumerable.call(n,i)&&ze(t,s)}}function ze(t,r,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Mr(r,n)}function Hi(t,r){const n=Array.isArray(t),i={type_:n?1:0,scope_:r?r.scope_:Zn(),modified_:!1,finalized_:!1,assigned_:{},parent_:r,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=i,c=Dr;n&&(s=[i],c=ae);const{revoke:h,proxy:m}=Proxy.revocable(s,c);return i.draft_=m,i.revoke_=h,m}var Dr={get(t,r){if(r===at)return t;const n=xt(t);if(!ee(n,r))return Ni(t,n,r);const i=n[r];return t.finalized_||!kt(i)?i:i===Pr(t.base_,r)?(jr(t),t.copy_[r]=Rr(i,t)):i},has(t,r){return r in xt(t)},ownKeys(t){return Reflect.ownKeys(xt(t))},set(t,r,n){const i=ri(xt(t),r);if(i!=null&&i.set)return i.set.call(t.draft_,n),!0;if(!t.modified_){const s=Pr(xt(t),r),c=s==null?void 0:s[at];if(c&&c.base_===n)return t.copy_[r]=n,t.assigned_[r]=!1,!0;if(Ci(n,s)&&(n!==void 0||ee(t.base_,r)))return!0;jr(t),Cr(t)}return t.copy_[r]===n&&(n!==void 0||r in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[r])||(t.copy_[r]=n,t.assigned_[r]=!0),!0},deleteProperty(t,r){return Pr(t.base_,r)!==void 0||r in t.base_?(t.assigned_[r]=!1,jr(t),Cr(t)):delete t.assigned_[r],t.copy_&&delete t.copy_[r],!0},getOwnPropertyDescriptor(t,r){const n=xt(t),i=Reflect.getOwnPropertyDescriptor(n,r);return i&&{writable:!0,configurable:t.type_!==1||r!=="length",enumerable:i.enumerable,value:n[r]}},defineProperty(){$(11)},getPrototypeOf(t){return Mt(t.base_)},setPrototypeOf(){$(12)}},ae={};te(Dr,(t,r)=>{ae[t]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)}}),ae.deleteProperty=function(t,r){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(r))&&$(13),ae.set.call(this,t,r,void 0)},ae.set=function(t,r,n){return process.env.NODE_ENV!=="production"&&r!=="length"&&isNaN(parseInt(r))&&$(14),Dr.set.call(this,t[0],r,n,t[0])};function Pr(t,r){const n=t[at];return(n?xt(n):t)[r]}function Ni(t,r,n){var s;const i=ri(r,n);return i?"value"in i?i.value:(s=i.get)==null?void 0:s.call(t.draft_):void 0}function ri(t,r){if(!(r in t))return;let n=Mt(t);for(;n;){const i=Object.getOwnPropertyDescriptor(n,r);if(i)return i;n=Mt(n)}}function Cr(t){t.modified_||(t.modified_=!0,t.parent_&&Cr(t.parent_))}function jr(t){t.copy_||(t.copy_=Er(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var Li=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.produce=(r,n,i)=>{if(typeof r=="function"&&typeof n!="function"){const c=n;n=r;const h=this;return function(C=c,...F){return h.produce(C,E=>n.call(this,E,...F))}}typeof n!="function"&&$(6),i!==void 0&&typeof i!="function"&&$(7);let s;if(kt(r)){const c=Qn(this),h=Rr(r,void 0);let m=!0;try{s=n(h),m=!1}finally{m?Or(c):xr(c)}return Jn(c,i),ti(s,c)}else if(!r||typeof r!="object"){if(s=n(r),s===void 0&&(s=r),s===kr&&(s=void 0),this.autoFreeze_&&Mr(s,!0),i){const c=[],h=[];Dt("Patches").generateReplacementPatches_(r,s,c,h),i(c,h)}return s}else $(1,r)},this.produceWithPatches=(r,n)=>{if(typeof r=="function")return(h,...m)=>this.produceWithPatches(h,C=>r(C,...m));let i,s;return[this.produce(r,n,(h,m)=>{i=h,s=m}),i,s]},typeof(t==null?void 0:t.autoFreeze)=="boolean"&&this.setAutoFreeze(t.autoFreeze),typeof(t==null?void 0:t.useStrictShallowCopy)=="boolean"&&this.setUseStrictShallowCopy(t.useStrictShallowCopy)}createDraft(t){kt(t)||$(8),At(t)&&(t=Ui(t));const r=Qn(this),n=Rr(t,void 0);return n[at].isManual_=!0,xr(r),n}finishDraft(t,r){const n=t&&t[at];(!n||!n.isManual_)&&$(9);const{scope_:i}=n;return Jn(i,r),ti(void 0,i)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}applyPatches(t,r){let n;for(n=r.length-1;n>=0;n--){const s=r[n];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}n>-1&&(r=r.slice(n+1));const i=Dt("Patches").applyPatches_;return At(t)?i(t,r):this.produce(t,s=>i(s,r))}};function Rr(t,r){const n=re(t)?Dt("MapSet").proxyMap_(t,r):ne(t)?Dt("MapSet").proxySet_(t,r):Hi(t,r);return(r?r.scope_:Zn()).drafts_.push(n),n}function Ui(t){return At(t)||$(10,t),ni(t)}function ni(t){if(!kt(t)||Re(t))return t;const r=t[at];let n;if(r){if(!r.modified_)return r.base_;r.finalized_=!0,n=Er(t,r.scope_.immer_.useStrictShallowCopy_)}else n=Er(t,!0);return te(n,(i,s)=>{qn(n,i,ni(s))}),r&&(r.finalized_=!1),n}function ii(){process.env.NODE_ENV!=="production"&&Vn.push('Sets cannot have "replace" patches.',function(b){return"Unsupported patch operation: "+b},function(b){return"Cannot apply patch, path doesn't resolve: "+b},"Patching reserved attributes like __proto__, prototype and constructor is not allowed");const r="replace",n="add",i="remove";function s(b,d,f,p){switch(b.type_){case 0:case 2:return h(b,d,f,p);case 1:return c(b,d,f,p);case 3:return m(b,d,f,p)}}function c(b,d,f,p){let{base_:g,assigned_:v}=b,_=b.copy_;_.length<g.length&&([g,_]=[_,g],[f,p]=[p,f]);for(let y=0;y<g.length;y++)if(v[y]&&_[y]!==g[y]){const l=d.concat([y]);f.push({op:r,path:l,value:L(_[y])}),p.push({op:r,path:l,value:L(g[y])})}for(let y=g.length;y<_.length;y++){const l=d.concat([y]);f.push({op:n,path:l,value:L(_[y])})}for(let y=_.length-1;g.length<=y;--y){const l=d.concat([y]);p.push({op:i,path:l})}}function h(b,d,f,p){const{base_:g,copy_:v}=b;te(b.assigned_,(_,y)=>{const l=Tr(g,_),D=Tr(v,_),M=y?ee(g,_)?r:n:i;if(l===D&&M===r)return;const I=d.concat(_);f.push(M===i?{op:M,path:I}:{op:M,path:I,value:D}),p.push(M===n?{op:i,path:I}:M===i?{op:n,path:I,value:L(l)}:{op:r,path:I,value:L(l)})})}function m(b,d,f,p){let{base_:g,copy_:v}=b,_=0;g.forEach(y=>{if(!v.has(y)){const l=d.concat([_]);f.push({op:i,path:l,value:y}),p.unshift({op:n,path:l,value:y})}_++}),_=0,v.forEach(y=>{if(!g.has(y)){const l=d.concat([_]);f.push({op:n,path:l,value:y}),p.unshift({op:i,path:l,value:y})}_++})}function C(b,d,f,p){f.push({op:r,path:[],value:d===kr?void 0:d}),p.push({op:r,path:[],value:b})}function F(b,d){return d.forEach(f=>{const{path:p,op:g}=f;let v=b;for(let D=0;D<p.length-1;D++){const M=Ot(v);let I=p[D];typeof I!="string"&&typeof I!="number"&&(I=""+I),(M===0||M===1)&&(I==="__proto__"||I==="constructor")&&$(19),typeof v=="function"&&I==="prototype"&&$(19),v=Tr(v,I),typeof v!="object"&&$(18,p.join("/"))}const _=Ot(v),y=E(f.value),l=p[p.length-1];switch(g){case r:switch(_){case 2:return v.set(l,y);case 3:$(16);default:return v[l]=y}case n:switch(_){case 1:return l==="-"?v.push(y):v.splice(l,0,y);case 2:return v.set(l,y);case 3:return v.add(y);default:return v[l]=y}case i:switch(_){case 1:return v.splice(l,1);case 2:return v.delete(l);case 3:return v.delete(f.value);default:return delete v[l]}default:$(17,g)}}),b}function E(b){if(!kt(b))return b;if(Array.isArray(b))return b.map(E);if(re(b))return new Map(Array.from(b.entries()).map(([f,p])=>[f,E(p)]));if(ne(b))return new Set(Array.from(b).map(E));const d=Object.create(Mt(b));for(const f in b)d[f]=E(b[f]);return ee(b,Qt)&&(d[Qt]=b[Qt]),d}function L(b){return At(b)?E(b):b}Ri("Patches",{applyPatches_:F,generatePatches_:s,generateReplacementPatches_:C})}var st=new Li,Wi=st.produce;st.produceWithPatches.bind(st),st.setAutoFreeze.bind(st),st.setUseStrictShallowCopy.bind(st);var Gi=st.applyPatches.bind(st);st.createDraft.bind(st),st.finishDraft.bind(st);var Bi=1/0,$i=9007199254740991,Ki="[object Arguments]",Yi="[object Function]",Vi="[object GeneratorFunction]",Xi="[object Symbol]",qi=typeof ot=="object"&&ot&&ot.Object===Object&&ot,Zi=typeof self=="object"&&self&&self.Object===Object&&self,Ji=qi||Zi||Function("return this")();function Qi(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}function ta(t,r){for(var n=-1,i=t?t.length:0,s=Array(i);++n<i;)s[n]=r(t[n],n,t);return s}function ea(t,r){for(var n=-1,i=r.length,s=t.length;++n<i;)t[s+n]=r[n];return t}var Fr=Object.prototype,ra=Fr.hasOwnProperty,zr=Fr.toString,ai=Ji.Symbol,na=Fr.propertyIsEnumerable,si=ai?ai.isConcatSpreadable:void 0,oi=Math.max;function ia(t,r,n,i,s){var c=-1,h=t.length;for(n||(n=ca),s||(s=[]);++c<h;){var m=t[c];n(m)?ea(s,m):s[s.length]=m}return s}function aa(t,r){return t=Object(t),sa(t,r,function(n,i){return i in t})}function sa(t,r,n){for(var i=-1,s=r.length,c={};++i<s;){var h=r[i],m=t[h];n(m,h)&&(c[h]=m)}return c}function oa(t,r){return r=oi(r===void 0?t.length-1:r,0),function(){for(var n=arguments,i=-1,s=oi(n.length-r,0),c=Array(s);++i<s;)c[i]=n[r+i];i=-1;for(var h=Array(r+1);++i<r;)h[i]=n[i];return h[r]=c,Qi(t,this,h)}}function ca(t){return fa(t)||la(t)||!!(si&&t&&t[si])}function ua(t){if(typeof t=="string"||ba(t))return t;var r=t+"";return r=="0"&&1/t==-Bi?"-0":r}function la(t){return pa(t)&&ra.call(t,"callee")&&(!na.call(t,"callee")||zr.call(t)==Ki)}var fa=Array.isArray;function da(t){return t!=null&&ma(t.length)&&!ha(t)}function pa(t){return ci(t)&&da(t)}function ha(t){var r=ya(t)?zr.call(t):"";return r==Yi||r==Vi}function ma(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=$i}function ya(t){var r=typeof t;return!!t&&(r=="object"||r=="function")}function ci(t){return!!t&&typeof t=="object"}function ba(t){return typeof t=="symbol"||ci(t)&&zr.call(t)==Xi}var ga=oa(function(t,r){return t==null?{}:aa(t,ta(ia(r),ua))}),_a=ga;const ui=yr(_a),Ia={size:{width:1080,height:1920},tracks:[],trackItemIds:[],trackItemsMap:{},transitionIds:[],transitionsMap:{},scale:{unit:1,zoom:1,segments:1,index:1},duration:0,activeIds:[],trackItemDetailsMap:{}},li=["tracks","trackItemsMap","trackItemDetailsMap","transitionIds","transitionsMap","trackItemIds"];class va{constructor(r){Nt(this,"stateSubject");Nt(this,"stateHistorySubject");Nt(this,"prevState");Nt(this,"undos",[]);Nt(this,"redos",[]);Nt(this,"listener");const n=r||Ia;this.stateSubject=new Un(n),this.stateHistorySubject=new Un({handleRedo:!1,handleUndo:!1}),this.prevState=n,this.initListeners()}initListeners(){xi(this)}destroyListeners(){this.listener&&this.listener.unsubscribe()}purge(){this.destroyListeners()}updateHistory(r,n){const i=ui(r,li),s=ui(this.getState(),li),c=Yn(s,i);c.length&&(this.undos.push({undos:c,type:n}),this.redos=[])}getStateHistory(){return this.stateHistorySubject.getValue()}subscribeHistory(r){return this.stateHistorySubject.subscribe(r)}getState(){return this.stateSubject.getValue()}subscribe(r){return this.stateSubject.subscribe(r)}updateState(r,n={updateHistory:!1}){const i=this.getState(),s={...i,...r};it(i,s)||(n.updateHistory&&this.updateHistory(s,n.kind),this.prevState=i,this.stateSubject.next(s))}subscribeToSize(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.size,this.prevState.size)||r({size:n.size})})}subscribeToScale(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.scale,this.prevState.scale)||r({scale:n.scale})})}subscribeToUpdateTrackItem(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemsMap,this.prevState.trackItemsMap)||r({trackItemsMap:n.trackItemsMap})})}subscribeToUpdateItemDetails(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap)||r({trackItemDetailsMap:n.trackItemDetailsMap})})}subscribeToDuration(r){return this.stateSubject.asObservable().subscribe(n=>{n.duration!==this.prevState.duration&&r({duration:n.duration})})}subscribeToHistory(r){return this.stateHistorySubject.asObservable().subscribe(n=>{if(n.handleRedo){const i=this.undos[this.undos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}if(n.handleUndo){const i=this.redos[this.redos.length-1].type;i==="update"&&r({...this.getState(),type:i}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!1})}})}subscribeToAddOrRemoveItems(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.trackItemIds,this.prevState.trackItemIds)||r({trackItemIds:n.trackItemIds})})}subscribeToActiveIds(r){return this.stateSubject.asObservable().subscribe(n=>{it(n.activeIds,this.prevState.activeIds)||r({activeIds:n.activeIds})})}subscribeToTracks(r){return this.stateSubject.asObservable().subscribe(n=>{(!it(n.tracks,this.prevState.tracks)||!it(n.trackItemIds,this.prevState.trackItemIds)||!it(n.trackItemsMap,this.prevState.trackItemsMap)||!it(n.transitionIds,this.prevState.transitionIds)||!it(n.transitionsMap,this.prevState.transitionsMap)||!it(n.trackItemDetailsMap,this.prevState.trackItemDetailsMap))&&r({tracks:n.tracks,trackItemIds:n.trackItemIds,trackItemsMap:n.trackItemsMap,transitionIds:n.transitionIds,transitionsMap:n.transitionsMap,trackItemDetailsMap:n.trackItemDetailsMap})})}undo(){const r=this.undos.pop(),n=r==null?void 0:r.undos,i=r==null?void 0:r.type;if(!n||!i)return;ii();const{trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}=this.getState(),E=B({trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}),L=[],b=[],d=[],f=[],p=[],g=[];n.forEach(k=>{let S;const A=k.path.slice(1);k.type==="CREATE"?S={path:A,op:"remove",value:k.value}:k.type==="CHANGE"?S={path:A,op:"replace",value:k.oldValue}:S={path:A,op:"add",value:k.oldValue},k.path.includes("trackItemIds")?d.push(S):k.path.includes("transitionIds")?b.push(S):k.path.includes("trackItemsMap")?p.push(S):k.path.includes("transitionsMap")?f.push(S):k.path.includes("tracks")?L.push(S):k.path.includes("trackItemDetailsMap")&&g.push(S)});const v=this.applyPatch(E.tracks,L),_=this.applyPatch(E.transitionIds,b),y=this.applyPatch(E.trackItemIds,d),l=this.applyPatch(E.transitionsMap,f),D=this.applyPatch(E.trackItemsMap,p),M=this.applyPatch(E.trackItemDetailsMap,g),I=B({tracks:v,transitionIds:_,trackItemIds:y,transitionsMap:l,trackItemsMap:D,trackItemDetailsMap:M}),j=B(this.getState()),w={...j,...I};this.prevState=j,this.redos.push({redos:n,type:i});const P=Lt(w.trackItemsMap);this.stateSubject.next({...w,duration:P}),this.stateHistorySubject.next({handleRedo:!1,handleUndo:!0})}applyPatch(r,n){return n.reverse().reduce((i,s)=>Wi(i,c=>{Gi(c,[s])}),r)}redo(){const r=this.redos.pop(),n=r==null?void 0:r.redos,i=r==null?void 0:r.type;if(!n||!i)return;ii();const{trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}=this.getState(),E=B({trackItemDetailsMap:s,trackItemIds:c,tracks:h,transitionIds:m,transitionsMap:C,trackItemsMap:F}),L=[],b=[],d=[],f=[],p=[],g=[];n.forEach(k=>{let S;const A=k.path.slice(1);k.type==="CREATE"?S={path:A,op:"add",value:k.value}:k.type==="CHANGE"?S={path:A,op:"replace",value:k.value}:S={path:A,op:"remove",value:k.oldValue},k.path.includes("trackItemIds")?d.push(S):k.path.includes("transitionIds")?b.push(S):k.path.includes("trackItemsMap")?p.push(S):k.path.includes("transitionsMap")?f.push(S):k.path.includes("trackItemDetailsMap")?g.push(S):L.push(S)});const v=this.applyPatch(E.tracks,L),_=this.applyPatch(E.transitionIds,b),y=this.applyPatch(E.trackItemIds,d),l=this.applyPatch(E.transitionsMap,f),D=this.applyPatch(E.trackItemsMap,p),M=this.applyPatch(E.trackItemDetailsMap,g),I=B({tracks:v,transitionIds:_,trackItemIds:y,transitionsMap:l,trackItemsMap:D,trackItemDetailsMap:M}),j=B(this.getState()),w={...j,...I};this.prevState=j,this.undos.push({undos:n,type:i});const P=Lt(w.trackItemsMap);this.stateSubject.next({...w,duration:P}),this.stateHistorySubject.next({handleRedo:!0,handleUndo:!1})}}return va});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@designcombo/state",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,9 +24,9 @@
|
|
|
24
24
|
"typescript": "^5.3.3",
|
|
25
25
|
"vite": "^5.2.0",
|
|
26
26
|
"vite-plugin-dts": "^3.9.1",
|
|
27
|
-
"@designcombo/
|
|
28
|
-
"@designcombo/
|
|
29
|
-
"@designcombo/
|
|
27
|
+
"@designcombo/events": "0.1.31",
|
|
28
|
+
"@designcombo/types": "0.1.31",
|
|
29
|
+
"@designcombo/typescript-config": "0.0.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"immer": "^10.1.1",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
"nanoid": "^5.0.7"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@designcombo/events": "0.1.
|
|
42
|
-
"@designcombo/types": "0.1.
|
|
41
|
+
"@designcombo/events": "0.1.31",
|
|
42
|
+
"@designcombo/types": "0.1.31"
|
|
43
43
|
},
|
|
44
44
|
"scripts": {
|
|
45
45
|
"dev": "vite",
|