melies-video-editor 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2033 @@
1
+ import Lt, { useState as J, useRef as V, useEffect as bt, useMemo as _t, useLayoutEffect as Wt } from "react";
2
+ import { Timeline as Ht } from "@xzdarcy/react-timeline-editor";
3
+ import { Howl as Yt, Howler as qt } from "howler";
4
+ import { Select as $t, Button as zt } from "antd";
5
+ import { useSensors as Xt, useSensor as jt, PointerSensor as Jt, TouchSensor as Kt, useDroppable as Gt, DndContext as Zt, rectIntersection as Qt, DragOverlay as en, useDraggable as tn } from "@dnd-kit/core";
6
+ var gt = { exports: {} }, et = {};
7
+ var Dt;
8
+ function nn() {
9
+ if (Dt) return et;
10
+ Dt = 1;
11
+ var u = Lt, a = /* @__PURE__ */ Symbol.for("react.element"), m = /* @__PURE__ */ Symbol.for("react.fragment"), d = Object.prototype.hasOwnProperty, g = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, S = { key: !0, ref: !0, __self: !0, __source: !0 };
12
+ function R(E, x, T) {
13
+ var k, A = {}, q = null, z = null;
14
+ T !== void 0 && (q = "" + T), x.key !== void 0 && (q = "" + x.key), x.ref !== void 0 && (z = x.ref);
15
+ for (k in x) d.call(x, k) && !S.hasOwnProperty(k) && (A[k] = x[k]);
16
+ if (E && E.defaultProps) for (k in x = E.defaultProps, x) A[k] === void 0 && (A[k] = x[k]);
17
+ return { $$typeof: a, type: E, key: q, ref: z, props: A, _owner: g.current };
18
+ }
19
+ return et.Fragment = m, et.jsx = R, et.jsxs = R, et;
20
+ }
21
+ var tt = {};
22
+ var Ot;
23
+ function rn() {
24
+ return Ot || (Ot = 1, process.env.NODE_ENV !== "production" && (function() {
25
+ var u = Lt, a = /* @__PURE__ */ Symbol.for("react.element"), m = /* @__PURE__ */ Symbol.for("react.portal"), d = /* @__PURE__ */ Symbol.for("react.fragment"), g = /* @__PURE__ */ Symbol.for("react.strict_mode"), S = /* @__PURE__ */ Symbol.for("react.profiler"), R = /* @__PURE__ */ Symbol.for("react.provider"), E = /* @__PURE__ */ Symbol.for("react.context"), x = /* @__PURE__ */ Symbol.for("react.forward_ref"), T = /* @__PURE__ */ Symbol.for("react.suspense"), k = /* @__PURE__ */ Symbol.for("react.suspense_list"), A = /* @__PURE__ */ Symbol.for("react.memo"), q = /* @__PURE__ */ Symbol.for("react.lazy"), z = /* @__PURE__ */ Symbol.for("react.offscreen"), de = Symbol.iterator, X = "@@iterator";
26
+ function U(t) {
27
+ if (t === null || typeof t != "object")
28
+ return null;
29
+ var l = de && t[de] || t[X];
30
+ return typeof l == "function" ? l : null;
31
+ }
32
+ var G = u.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
33
+ function O(t) {
34
+ {
35
+ for (var l = arguments.length, e = new Array(l > 1 ? l - 1 : 0), n = 1; n < l; n++)
36
+ e[n - 1] = arguments[n];
37
+ fe("error", t, e);
38
+ }
39
+ }
40
+ function fe(t, l, e) {
41
+ {
42
+ var n = G.ReactDebugCurrentFrame, r = n.getStackAddendum();
43
+ r !== "" && (l += "%s", e = e.concat([r]));
44
+ var s = e.map(function(i) {
45
+ return String(i);
46
+ });
47
+ s.unshift("Warning: " + l), Function.prototype.apply.call(console[t], console, s);
48
+ }
49
+ }
50
+ var be = !1, oe = !1, me = !1, ot = !1, Ne = !1, ke;
51
+ ke = /* @__PURE__ */ Symbol.for("react.module.reference");
52
+ function Ye(t) {
53
+ return !!(typeof t == "string" || typeof t == "function" || t === d || t === S || Ne || t === g || t === T || t === k || ot || t === z || be || oe || me || typeof t == "object" && t !== null && (t.$$typeof === q || t.$$typeof === A || t.$$typeof === R || t.$$typeof === E || t.$$typeof === x || // This needs to include all possible module reference object
54
+ // types supported by any Flight configuration anywhere since
55
+ // we don't know which Flight build this will end up being used
56
+ // with.
57
+ t.$$typeof === ke || t.getModuleId !== void 0));
58
+ }
59
+ function qe(t, l, e) {
60
+ var n = t.displayName;
61
+ if (n)
62
+ return n;
63
+ var r = l.displayName || l.name || "";
64
+ return r !== "" ? e + "(" + r + ")" : e;
65
+ }
66
+ function Oe(t) {
67
+ return t.displayName || "Context";
68
+ }
69
+ function se(t) {
70
+ if (t == null)
71
+ return null;
72
+ if (typeof t.tag == "number" && O("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
73
+ return t.displayName || t.name || null;
74
+ if (typeof t == "string")
75
+ return t;
76
+ switch (t) {
77
+ case d:
78
+ return "Fragment";
79
+ case m:
80
+ return "Portal";
81
+ case S:
82
+ return "Profiler";
83
+ case g:
84
+ return "StrictMode";
85
+ case T:
86
+ return "Suspense";
87
+ case k:
88
+ return "SuspenseList";
89
+ }
90
+ if (typeof t == "object")
91
+ switch (t.$$typeof) {
92
+ case E:
93
+ var l = t;
94
+ return Oe(l) + ".Consumer";
95
+ case R:
96
+ var e = t;
97
+ return Oe(e._context) + ".Provider";
98
+ case x:
99
+ return qe(t, t.render, "ForwardRef");
100
+ case A:
101
+ var n = t.displayName || null;
102
+ return n !== null ? n : se(t.type) || "Memo";
103
+ case q: {
104
+ var r = t, s = r._payload, i = r._init;
105
+ try {
106
+ return se(i(s));
107
+ } catch {
108
+ return null;
109
+ }
110
+ }
111
+ }
112
+ return null;
113
+ }
114
+ var ae = Object.assign, te = 0, Me, ye, y, j, D, C, F;
115
+ function M() {
116
+ }
117
+ M.__reactDisabledLog = !0;
118
+ function H() {
119
+ {
120
+ if (te === 0) {
121
+ Me = console.log, ye = console.info, y = console.warn, j = console.error, D = console.group, C = console.groupCollapsed, F = console.groupEnd;
122
+ var t = {
123
+ configurable: !0,
124
+ enumerable: !0,
125
+ value: M,
126
+ writable: !0
127
+ };
128
+ Object.defineProperties(console, {
129
+ info: t,
130
+ log: t,
131
+ warn: t,
132
+ error: t,
133
+ group: t,
134
+ groupCollapsed: t,
135
+ groupEnd: t
136
+ });
137
+ }
138
+ te++;
139
+ }
140
+ }
141
+ function Se() {
142
+ {
143
+ if (te--, te === 0) {
144
+ var t = {
145
+ configurable: !0,
146
+ enumerable: !0,
147
+ writable: !0
148
+ };
149
+ Object.defineProperties(console, {
150
+ log: ae({}, t, {
151
+ value: Me
152
+ }),
153
+ info: ae({}, t, {
154
+ value: ye
155
+ }),
156
+ warn: ae({}, t, {
157
+ value: y
158
+ }),
159
+ error: ae({}, t, {
160
+ value: j
161
+ }),
162
+ group: ae({}, t, {
163
+ value: D
164
+ }),
165
+ groupCollapsed: ae({}, t, {
166
+ value: C
167
+ }),
168
+ groupEnd: ae({}, t, {
169
+ value: F
170
+ })
171
+ });
172
+ }
173
+ te < 0 && O("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
174
+ }
175
+ }
176
+ var pe = G.ReactCurrentDispatcher, ce;
177
+ function Pe(t, l, e) {
178
+ {
179
+ if (ce === void 0)
180
+ try {
181
+ throw Error();
182
+ } catch (r) {
183
+ var n = r.stack.trim().match(/\n( *(at )?)/);
184
+ ce = n && n[1] || "";
185
+ }
186
+ return `
187
+ ` + ce + t;
188
+ }
189
+ }
190
+ var Le = !1, ze;
191
+ {
192
+ var ge = typeof WeakMap == "function" ? WeakMap : Map;
193
+ ze = new ge();
194
+ }
195
+ function K(t, l) {
196
+ if (!t || Le)
197
+ return "";
198
+ {
199
+ var e = ze.get(t);
200
+ if (e !== void 0)
201
+ return e;
202
+ }
203
+ var n;
204
+ Le = !0;
205
+ var r = Error.prepareStackTrace;
206
+ Error.prepareStackTrace = void 0;
207
+ var s;
208
+ s = pe.current, pe.current = null, H();
209
+ try {
210
+ if (l) {
211
+ var i = function() {
212
+ throw Error();
213
+ };
214
+ if (Object.defineProperty(i.prototype, "props", {
215
+ set: function() {
216
+ throw Error();
217
+ }
218
+ }), typeof Reflect == "object" && Reflect.construct) {
219
+ try {
220
+ Reflect.construct(i, []);
221
+ } catch (w) {
222
+ n = w;
223
+ }
224
+ Reflect.construct(t, [], i);
225
+ } else {
226
+ try {
227
+ i.call();
228
+ } catch (w) {
229
+ n = w;
230
+ }
231
+ t.call(i.prototype);
232
+ }
233
+ } else {
234
+ try {
235
+ throw Error();
236
+ } catch (w) {
237
+ n = w;
238
+ }
239
+ t();
240
+ }
241
+ } catch (w) {
242
+ if (w && n && typeof w.stack == "string") {
243
+ for (var o = w.stack.split(`
244
+ `), c = n.stack.split(`
245
+ `), f = o.length - 1, p = c.length - 1; f >= 1 && p >= 0 && o[f] !== c[p]; )
246
+ p--;
247
+ for (; f >= 1 && p >= 0; f--, p--)
248
+ if (o[f] !== c[p]) {
249
+ if (f !== 1 || p !== 1)
250
+ do
251
+ if (f--, p--, p < 0 || o[f] !== c[p]) {
252
+ var h = `
253
+ ` + o[f].replace(" at new ", " at ");
254
+ return t.displayName && h.includes("<anonymous>") && (h = h.replace("<anonymous>", t.displayName)), typeof t == "function" && ze.set(t, h), h;
255
+ }
256
+ while (f >= 1 && p >= 0);
257
+ break;
258
+ }
259
+ }
260
+ } finally {
261
+ Le = !1, pe.current = s, Se(), Error.prepareStackTrace = r;
262
+ }
263
+ var b = t ? t.displayName || t.name : "", N = b ? Pe(b) : "";
264
+ return typeof t == "function" && ze.set(t, N), N;
265
+ }
266
+ function ne(t, l, e) {
267
+ return K(t, !1);
268
+ }
269
+ function $e(t) {
270
+ var l = t.prototype;
271
+ return !!(l && l.isReactComponent);
272
+ }
273
+ function Be(t, l, e) {
274
+ if (t == null)
275
+ return "";
276
+ if (typeof t == "function")
277
+ return K(t, $e(t));
278
+ if (typeof t == "string")
279
+ return Pe(t);
280
+ switch (t) {
281
+ case T:
282
+ return Pe("Suspense");
283
+ case k:
284
+ return Pe("SuspenseList");
285
+ }
286
+ if (typeof t == "object")
287
+ switch (t.$$typeof) {
288
+ case x:
289
+ return ne(t.render);
290
+ case A:
291
+ return Be(t.type, l, e);
292
+ case q: {
293
+ var n = t, r = n._payload, s = n._init;
294
+ try {
295
+ return Be(s(r), l, e);
296
+ } catch {
297
+ }
298
+ }
299
+ }
300
+ return "";
301
+ }
302
+ var Ie = Object.prototype.hasOwnProperty, Z = {}, W = G.ReactDebugCurrentFrame;
303
+ function Ce(t) {
304
+ if (t) {
305
+ var l = t._owner, e = Be(t.type, t._source, l ? l.type : null);
306
+ W.setExtraStackFrame(e);
307
+ } else
308
+ W.setExtraStackFrame(null);
309
+ }
310
+ function Ue(t, l, e, n, r) {
311
+ {
312
+ var s = Function.call.bind(Ie);
313
+ for (var i in t)
314
+ if (s(t, i)) {
315
+ var o = void 0;
316
+ try {
317
+ if (typeof t[i] != "function") {
318
+ var c = Error((n || "React class") + ": " + e + " type `" + i + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[i] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
319
+ throw c.name = "Invariant Violation", c;
320
+ }
321
+ o = t[i](l, i, n, e, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
322
+ } catch (f) {
323
+ o = f;
324
+ }
325
+ o && !(o instanceof Error) && (Ce(r), O("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", e, i, typeof o), Ce(null)), o instanceof Error && !(o.message in Z) && (Z[o.message] = !0, Ce(r), O("Failed %s type: %s", e, o.message), Ce(null));
326
+ }
327
+ }
328
+ }
329
+ var Fe = Array.isArray;
330
+ function Ve(t) {
331
+ return Fe(t);
332
+ }
333
+ function he(t) {
334
+ {
335
+ var l = typeof Symbol == "function" && Symbol.toStringTag, e = l && t[Symbol.toStringTag] || t.constructor.name || "Object";
336
+ return e;
337
+ }
338
+ }
339
+ function Xe(t) {
340
+ try {
341
+ return we(t), !1;
342
+ } catch {
343
+ return !0;
344
+ }
345
+ }
346
+ function we(t) {
347
+ return "" + t;
348
+ }
349
+ function st(t) {
350
+ if (Xe(t))
351
+ return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", he(t)), we(t);
352
+ }
353
+ var We = G.ReactCurrentOwner, Je = {
354
+ key: !0,
355
+ ref: !0,
356
+ __self: !0,
357
+ __source: !0
358
+ }, Ge, Ze;
359
+ function at(t) {
360
+ if (Ie.call(t, "ref")) {
361
+ var l = Object.getOwnPropertyDescriptor(t, "ref").get;
362
+ if (l && l.isReactWarning)
363
+ return !1;
364
+ }
365
+ return t.ref !== void 0;
366
+ }
367
+ function yt(t) {
368
+ if (Ie.call(t, "key")) {
369
+ var l = Object.getOwnPropertyDescriptor(t, "key").get;
370
+ if (l && l.isReactWarning)
371
+ return !1;
372
+ }
373
+ return t.key !== void 0;
374
+ }
375
+ function St(t, l) {
376
+ typeof t.ref == "string" && We.current;
377
+ }
378
+ function wt(t, l) {
379
+ {
380
+ var e = function() {
381
+ Ge || (Ge = !0, O("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", l));
382
+ };
383
+ e.isReactWarning = !0, Object.defineProperty(t, "key", {
384
+ get: e,
385
+ configurable: !0
386
+ });
387
+ }
388
+ }
389
+ function He(t, l) {
390
+ {
391
+ var e = function() {
392
+ Ze || (Ze = !0, O("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", l));
393
+ };
394
+ e.isReactWarning = !0, Object.defineProperty(t, "ref", {
395
+ get: e,
396
+ configurable: !0
397
+ });
398
+ }
399
+ }
400
+ var Rt = function(t, l, e, n, r, s, i) {
401
+ var o = {
402
+ // This tag allows us to uniquely identify this as a React Element
403
+ $$typeof: a,
404
+ // Built-in properties that belong on the element
405
+ type: t,
406
+ key: l,
407
+ ref: e,
408
+ props: i,
409
+ // Record the component responsible for creating this element.
410
+ _owner: s
411
+ };
412
+ return o._store = {}, Object.defineProperty(o._store, "validated", {
413
+ configurable: !1,
414
+ enumerable: !1,
415
+ writable: !0,
416
+ value: !1
417
+ }), Object.defineProperty(o, "_self", {
418
+ configurable: !1,
419
+ enumerable: !1,
420
+ writable: !1,
421
+ value: n
422
+ }), Object.defineProperty(o, "_source", {
423
+ configurable: !1,
424
+ enumerable: !1,
425
+ writable: !1,
426
+ value: r
427
+ }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
428
+ };
429
+ function xt(t, l, e, n, r) {
430
+ {
431
+ var s, i = {}, o = null, c = null;
432
+ e !== void 0 && (st(e), o = "" + e), yt(l) && (st(l.key), o = "" + l.key), at(l) && (c = l.ref, St(l, r));
433
+ for (s in l)
434
+ Ie.call(l, s) && !Je.hasOwnProperty(s) && (i[s] = l[s]);
435
+ if (t && t.defaultProps) {
436
+ var f = t.defaultProps;
437
+ for (s in f)
438
+ i[s] === void 0 && (i[s] = f[s]);
439
+ }
440
+ if (o || c) {
441
+ var p = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
442
+ o && wt(i, p), c && He(i, p);
443
+ }
444
+ return Rt(t, o, c, r, n, We.current, i);
445
+ }
446
+ }
447
+ var _e = G.ReactCurrentOwner, ct = G.ReactDebugCurrentFrame;
448
+ function le(t) {
449
+ if (t) {
450
+ var l = t._owner, e = Be(t.type, t._source, l ? l.type : null);
451
+ ct.setExtraStackFrame(e);
452
+ } else
453
+ ct.setExtraStackFrame(null);
454
+ }
455
+ var Ke;
456
+ Ke = !1;
457
+ function Qe(t) {
458
+ return typeof t == "object" && t !== null && t.$$typeof === a;
459
+ }
460
+ function lt() {
461
+ {
462
+ if (_e.current) {
463
+ var t = se(_e.current.type);
464
+ if (t)
465
+ return `
466
+
467
+ Check the render method of \`` + t + "`.";
468
+ }
469
+ return "";
470
+ }
471
+ }
472
+ function Et(t) {
473
+ return "";
474
+ }
475
+ var ut = {};
476
+ function Tt(t) {
477
+ {
478
+ var l = lt();
479
+ if (!l) {
480
+ var e = typeof t == "string" ? t : t.displayName || t.name;
481
+ e && (l = `
482
+
483
+ Check the top-level render call using <` + e + ">.");
484
+ }
485
+ return l;
486
+ }
487
+ }
488
+ function dt(t, l) {
489
+ {
490
+ if (!t._store || t._store.validated || t.key != null)
491
+ return;
492
+ t._store.validated = !0;
493
+ var e = Tt(l);
494
+ if (ut[e])
495
+ return;
496
+ ut[e] = !0;
497
+ var n = "";
498
+ t && t._owner && t._owner !== _e.current && (n = " It was passed a child from " + se(t._owner.type) + "."), le(t), O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', e, n), le(null);
499
+ }
500
+ }
501
+ function ft(t, l) {
502
+ {
503
+ if (typeof t != "object")
504
+ return;
505
+ if (Ve(t))
506
+ for (var e = 0; e < t.length; e++) {
507
+ var n = t[e];
508
+ Qe(n) && dt(n, l);
509
+ }
510
+ else if (Qe(t))
511
+ t._store && (t._store.validated = !0);
512
+ else if (t) {
513
+ var r = U(t);
514
+ if (typeof r == "function" && r !== t.entries)
515
+ for (var s = r.call(t), i; !(i = s.next()).done; )
516
+ Qe(i.value) && dt(i.value, l);
517
+ }
518
+ }
519
+ }
520
+ function At(t) {
521
+ {
522
+ var l = t.type;
523
+ if (l == null || typeof l == "string")
524
+ return;
525
+ var e;
526
+ if (typeof l == "function")
527
+ e = l.propTypes;
528
+ else if (typeof l == "object" && (l.$$typeof === x || // Note: Memo only checks outer props here.
529
+ // Inner props are checked in the reconciler.
530
+ l.$$typeof === A))
531
+ e = l.propTypes;
532
+ else
533
+ return;
534
+ if (e) {
535
+ var n = se(l);
536
+ Ue(e, t.props, "prop", n, t);
537
+ } else if (l.PropTypes !== void 0 && !Ke) {
538
+ Ke = !0;
539
+ var r = se(l);
540
+ O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", r || "Unknown");
541
+ }
542
+ typeof l.getDefaultProps == "function" && !l.getDefaultProps.isReactClassApproved && O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
543
+ }
544
+ }
545
+ function Nt(t) {
546
+ {
547
+ for (var l = Object.keys(t.props), e = 0; e < l.length; e++) {
548
+ var n = l[e];
549
+ if (n !== "children" && n !== "key") {
550
+ le(t), O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), le(null);
551
+ break;
552
+ }
553
+ }
554
+ t.ref !== null && (le(t), O("Invalid attribute `ref` supplied to `React.Fragment`."), le(null));
555
+ }
556
+ }
557
+ var mt = {};
558
+ function pt(t, l, e, n, r, s) {
559
+ {
560
+ var i = Ye(t);
561
+ if (!i) {
562
+ var o = "";
563
+ (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (o += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
564
+ var c = Et();
565
+ c ? o += c : o += lt();
566
+ var f;
567
+ t === null ? f = "null" : Ve(t) ? f = "array" : t !== void 0 && t.$$typeof === a ? (f = "<" + (se(t.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : f = typeof t, O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", f, o);
568
+ }
569
+ var p = xt(t, l, e, r, s);
570
+ if (p == null)
571
+ return p;
572
+ if (i) {
573
+ var h = l.children;
574
+ if (h !== void 0)
575
+ if (n)
576
+ if (Ve(h)) {
577
+ for (var b = 0; b < h.length; b++)
578
+ ft(h[b], t);
579
+ Object.freeze && Object.freeze(h);
580
+ } else
581
+ O("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
582
+ else
583
+ ft(h, t);
584
+ }
585
+ if (Ie.call(l, "key")) {
586
+ var N = se(t), w = Object.keys(l).filter(function(I) {
587
+ return I !== "key";
588
+ }), P = w.length > 0 ? "{key: someKey, " + w.join(": ..., ") + ": ...}" : "{key: someKey}";
589
+ if (!mt[N + P]) {
590
+ var _ = w.length > 0 ? "{" + w.join(": ..., ") + ": ...}" : "{}";
591
+ O(`A props object containing a "key" prop is being spread into JSX:
592
+ let props = %s;
593
+ <%s {...props} />
594
+ React keys must be passed directly to JSX without using spread:
595
+ let props = %s;
596
+ <%s key={someKey} {...props} />`, P, N, _, N), mt[N + P] = !0;
597
+ }
598
+ }
599
+ return t === d ? Nt(p) : At(p), p;
600
+ }
601
+ }
602
+ function kt(t, l, e) {
603
+ return pt(t, l, e, !0);
604
+ }
605
+ function Pt(t, l, e) {
606
+ return pt(t, l, e, !1);
607
+ }
608
+ var Re = Pt, It = kt;
609
+ tt.Fragment = d, tt.jsx = Re, tt.jsxs = It;
610
+ })()), tt;
611
+ }
612
+ var Mt;
613
+ function on() {
614
+ return Mt || (Mt = 1, process.env.NODE_ENV === "production" ? gt.exports = nn() : gt.exports = rn()), gt.exports;
615
+ }
616
+ var v = on();
617
+ const sn = ({ action: u, row: a }) => /* @__PURE__ */ v.jsx("div", { className: "effect0", "data-action-id": u.id, "data-row-id": a.id, children: /* @__PURE__ */ v.jsx("div", { className: "effect0-text", children: `Audio: ${u.data.name}` }) }), an = ({ action: u, row: a }) => /* @__PURE__ */ v.jsx("div", { className: "effect1", "data-action-id": u.id, "data-row-id": a.id, children: /* @__PURE__ */ v.jsx("div", { className: "effect1-text", children: `Video: ${u.data.name}` }) }), cn = ({ action: u, row: a }) => /* @__PURE__ */ v.jsx("div", { className: "effect2", "data-action-id": u.id, "data-row-id": a.id, children: /* @__PURE__ */ v.jsx("div", { className: "effect2-text", children: `Video audio: ${u.data.name}` }) }), ln = (u) => {
618
+ const a = u.toLowerCase();
619
+ return a.endsWith(".mp4") || a.endsWith(".webm") || a.endsWith(".mov") || a.endsWith(".m4v") ? "video" : a.endsWith(".mp3") || a.endsWith(".wav") || a.endsWith(".ogg") || a.endsWith(".m4a") || a.endsWith(".aac") ? "audio" : "other";
620
+ };
621
+ class un {
622
+ blobUrlBySrc = /* @__PURE__ */ new Map();
623
+ pendingBySrc = /* @__PURE__ */ new Map();
624
+ /**
625
+ * Preloads a URL into memory and returns a blob: URL.
626
+ * Useful to avoid runtime buffering/stalls when seeking frequently.
627
+ */
628
+ async preloadToBlobUrl(a) {
629
+ if (!a) return a;
630
+ const m = this.blobUrlBySrc.get(a);
631
+ if (m) return m;
632
+ const d = this.pendingBySrc.get(a);
633
+ if (d) return d;
634
+ const g = (async () => {
635
+ const S = await fetch(a, { cache: "force-cache" });
636
+ if (!S.ok) throw new Error(`Failed to fetch ${a}: ${S.status}`);
637
+ const R = await S.blob(), E = URL.createObjectURL(R);
638
+ return this.blobUrlBySrc.set(a, E), E;
639
+ })().catch((S) => (console.warn("[mediaCache] preload failed:", a, S), a)).finally(() => {
640
+ this.pendingBySrc.delete(a);
641
+ });
642
+ return this.pendingBySrc.set(a, g), g;
643
+ }
644
+ /** Returns a blob URL if available, otherwise the original `src`. */
645
+ resolve(a) {
646
+ return this.blobUrlBySrc.get(a) ?? a;
647
+ }
648
+ /** Starts preload in background (non-blocking). */
649
+ warm(a) {
650
+ this.preloadToBlobUrl(a);
651
+ }
652
+ /** Convenience: preload all unique action.data.src from editor data. */
653
+ warmFromEditorData(a) {
654
+ const m = /* @__PURE__ */ new Set(), d = Array.isArray(a) ? a : [];
655
+ for (const g of d) {
656
+ const S = g?.actions;
657
+ if (Array.isArray(S))
658
+ for (const R of S) {
659
+ const E = R?.data?.src;
660
+ typeof E == "string" && E && m.add(E);
661
+ }
662
+ }
663
+ for (const g of m) {
664
+ const S = ln(g);
665
+ (S === "video" || S === "audio") && this.warm(g);
666
+ }
667
+ }
668
+ }
669
+ const it = new un(), dn = (u) => {
670
+ if (!u) return;
671
+ const m = u.split("#")[0].split("?")[0].toLowerCase(), d = m.lastIndexOf(".");
672
+ if (d < 0) return;
673
+ const g = m.slice(d + 1);
674
+ if (g)
675
+ return g === "m4a" || g === "m4v" ? "mp4" : g;
676
+ };
677
+ class fn {
678
+ howlBySrc = {};
679
+ activeByActionId = {};
680
+ getHowl(a) {
681
+ const m = it.resolve(a), d = m.startsWith("blob:") ? a : m, g = d;
682
+ if (this.howlBySrc[g]) return this.howlBySrc[g];
683
+ const S = dn(a), R = new Yt({
684
+ src: [d],
685
+ format: S ? [S] : void 0,
686
+ loop: !0,
687
+ autoplay: !1,
688
+ preload: !0
689
+ });
690
+ return this.howlBySrc[g] = R, R;
691
+ }
692
+ /**
693
+ * Ensure the underlying WebAudio context is resumed.
694
+ *
695
+ * Some browsers (notably iOS Safari) block audio playback until a user gesture
696
+ * resumes the AudioContext. Timeline engine callbacks may occur outside the
697
+ * original gesture call stack, so we explicitly unlock in the toolbar handler.
698
+ */
699
+ unlock() {
700
+ try {
701
+ const a = qt.ctx;
702
+ a && a.state === "suspended" && a.resume();
703
+ } catch {
704
+ }
705
+ }
706
+ warm(a) {
707
+ a && (it.warm(a), this.getHowl(a));
708
+ }
709
+ seekForEngineTime(a, m, d, g, S) {
710
+ const R = Number(S), E = Number.isFinite(R) ? R : 0, x = a.duration();
711
+ if (!Number.isFinite(x) || x <= 0) {
712
+ a.seek(Math.max(0, g - d + E), m);
713
+ return;
714
+ }
715
+ const T = (g - d + E) % x, k = T < 0 ? T + x : T;
716
+ a.seek(k, m);
717
+ }
718
+ start(a) {
719
+ const { actionId: m, src: d, startTime: g, time: S, engine: R } = a, E = Number(a.offset ?? 0), x = Number.isFinite(E) ? E : 0, T = this.activeByActionId[m];
720
+ if (T) {
721
+ const X = this.getHowl(T.src);
722
+ X.rate(R.getPlayRate(), T.soundId);
723
+ try {
724
+ X.playing(T.soundId) || X.play(T.soundId);
725
+ } catch {
726
+ }
727
+ R.isPlaying || this.seekForEngineTime(X, T.soundId, T.startTime, S, T.offset);
728
+ return;
729
+ }
730
+ const k = this.getHowl(d), A = k.play();
731
+ k.rate(R.getPlayRate(), A), this.seekForEngineTime(k, A, g, S, x);
732
+ let q = performance.now();
733
+ const z = ({ time: X }) => {
734
+ if (!R.isPlaying) {
735
+ this.seekForEngineTime(k, A, g, X, x);
736
+ return;
737
+ }
738
+ const U = performance.now();
739
+ if (!(U - q < 500)) {
740
+ q = U;
741
+ try {
742
+ const G = Math.max(0, X - g + x), O = Number(k.seek(A));
743
+ Number.isFinite(O) && Math.abs(O - G) > 0.25 && this.seekForEngineTime(k, A, g, X, x);
744
+ } catch {
745
+ }
746
+ }
747
+ }, de = ({ rate: X }) => {
748
+ k.rate(X, A);
749
+ };
750
+ R.on("afterSetTime", z), R.on("afterSetPlayRate", de), this.activeByActionId[m] = {
751
+ src: d,
752
+ startTime: g,
753
+ offset: x,
754
+ soundId: A,
755
+ engine: R,
756
+ lastResyncAtMs: q,
757
+ time: z,
758
+ rate: de
759
+ };
760
+ }
761
+ stop(a) {
762
+ const { actionId: m } = a, d = this.activeByActionId[m];
763
+ if (!d) return;
764
+ const g = this.getHowl(d.src);
765
+ try {
766
+ g.stop(d.soundId);
767
+ } catch {
768
+ }
769
+ d.time && d.engine.off("afterSetTime", d.time), d.rate && d.engine.off("afterSetPlayRate", d.rate), delete this.activeByActionId[m];
770
+ }
771
+ }
772
+ const ie = new fn();
773
+ class mn {
774
+ videoEl = null;
775
+ currentSrc = null;
776
+ lastSeekAtMs = 0;
777
+ lastRate = null;
778
+ boundEngine = null;
779
+ boundActionStart = 0;
780
+ vfcHandle = null;
781
+ rafHandle = null;
782
+ attach(a) {
783
+ this.videoEl = a, this.currentSrc = a?.currentSrc || a?.getAttribute("src") || null, this.lastSeekAtMs = 0, this.lastRate = null, this.unbindEngine(), this.setActive(!1);
784
+ }
785
+ setActive(a) {
786
+ this.videoEl && (this.videoEl.style.opacity = a ? "1" : "0");
787
+ }
788
+ bindEngine(a, m) {
789
+ this.unbindEngine(), this.boundEngine = a, this.boundActionStart = m, this.tickFromVideo();
790
+ }
791
+ unbindEngine() {
792
+ const a = this.videoEl;
793
+ if (this.vfcHandle != null && a?.cancelVideoFrameCallback)
794
+ try {
795
+ a.cancelVideoFrameCallback(this.vfcHandle);
796
+ } catch {
797
+ }
798
+ this.rafHandle != null && cancelAnimationFrame(this.rafHandle), this.vfcHandle = null, this.rafHandle = null, this.boundEngine = null;
799
+ }
800
+ tickFromVideo = () => {
801
+ if (!this.videoEl || !this.boundEngine || this.videoEl.paused) return;
802
+ const a = this.boundActionStart + this.videoEl.currentTime;
803
+ Math.abs(this.boundEngine.getTime() - a) > 0.03 && this.boundEngine.setTime(a, !0);
804
+ const m = this.videoEl;
805
+ m?.requestVideoFrameCallback ? this.vfcHandle = m.requestVideoFrameCallback(() => this.tickFromVideo()) : this.rafHandle = requestAnimationFrame(() => this.tickFromVideo());
806
+ };
807
+ setSource(a) {
808
+ if (!this.videoEl || !a) return;
809
+ const m = it.resolve(a);
810
+ if (!((this.videoEl.currentSrc || this.videoEl.getAttribute("src") || "") === m || this.currentSrc === m)) {
811
+ this.currentSrc = m, this.videoEl.preload = "auto", this.videoEl.src = m;
812
+ try {
813
+ this.videoEl.load();
814
+ } catch {
815
+ }
816
+ }
817
+ }
818
+ warm(a) {
819
+ a && it.warm(a);
820
+ }
821
+ setRate(a) {
822
+ this.videoEl && this.lastRate !== a && (this.lastRate = a, this.videoEl.playbackRate = a);
823
+ }
824
+ /**
825
+ * Sync the video to a desired timeline time.
826
+ * To avoid buffering/stutters, we only seek when drift is large or when paused/scrubbing.
827
+ */
828
+ seek(a, m) {
829
+ if (this.videoEl)
830
+ try {
831
+ const d = performance.now(), g = m?.force === !0, S = this.videoEl.currentTime;
832
+ if (!g && !this.videoEl.paused && (Math.abs(S - a) < 0.12 || d - this.lastSeekAtMs < 150))
833
+ return;
834
+ const R = this.videoEl.duration;
835
+ Number.isFinite(R) && R > 0 ? this.videoEl.currentTime = Math.min(a, Math.max(0, R - 0.05)) : this.videoEl.currentTime = Math.max(0, a), this.lastSeekAtMs = d;
836
+ } catch {
837
+ }
838
+ }
839
+ async play() {
840
+ if (this.videoEl)
841
+ try {
842
+ await this.videoEl.play(), this.boundEngine && this.tickFromVideo();
843
+ } catch {
844
+ }
845
+ }
846
+ pause() {
847
+ this.videoEl && this.videoEl.pause();
848
+ }
849
+ }
850
+ const L = new mn(), nt = 160, rt = 5, vt = 20, pn = {
851
+ effect0: {
852
+ id: "effect0",
853
+ name: "Play audio",
854
+ source: {
855
+ start: ({ action: u, engine: a, isPlaying: m, time: d }) => {
856
+ if (m) {
857
+ const { src: g, offset: S } = u.data;
858
+ ie.warm(g), ie.start({ actionId: u.id, src: g, startTime: u.start, engine: a, time: d, offset: S });
859
+ }
860
+ },
861
+ enter: ({ action: u, engine: a, isPlaying: m, time: d }) => {
862
+ if (m) {
863
+ const { src: g, offset: S } = u.data;
864
+ ie.warm(g), ie.start({ actionId: u.id, src: g, startTime: u.start, engine: a, time: d, offset: S });
865
+ }
866
+ },
867
+ leave: ({ action: u }) => {
868
+ ie.stop({ actionId: u.id });
869
+ },
870
+ stop: ({ action: u }) => {
871
+ ie.stop({ actionId: u.id });
872
+ }
873
+ }
874
+ },
875
+ effect2: {
876
+ id: "effect2",
877
+ name: "Play video audio",
878
+ source: {
879
+ start: ({ action: u, engine: a, isPlaying: m, time: d }) => {
880
+ if (m) {
881
+ const { src: g, offset: S } = u.data;
882
+ ie.warm(g), ie.start({ actionId: u.id, src: g, startTime: u.start, engine: a, time: d, offset: S });
883
+ }
884
+ },
885
+ enter: ({ action: u, engine: a, isPlaying: m, time: d }) => {
886
+ if (m) {
887
+ const { src: g, offset: S } = u.data;
888
+ ie.warm(g), ie.start({ actionId: u.id, src: g, startTime: u.start, engine: a, time: d, offset: S });
889
+ }
890
+ },
891
+ leave: ({ action: u }) => {
892
+ ie.stop({ actionId: u.id });
893
+ },
894
+ stop: ({ action: u }) => {
895
+ ie.stop({ actionId: u.id });
896
+ }
897
+ }
898
+ },
899
+ effect1: {
900
+ id: "effect1",
901
+ name: "Play video",
902
+ source: {
903
+ start: ({ action: u, engine: a, isPlaying: m, time: d }) => {
904
+ const { src: g, previewSrc: S, offset: R } = u.data ?? {}, E = S || g;
905
+ E && (L.warm(E), L.setSource(E)), L.setActive(!0), L.setRate(a.getPlayRate());
906
+ const x = Number(R ?? 0);
907
+ L.seek(Math.max(0, d - u.start + (Number.isFinite(x) ? x : 0)), { force: !0 }), m && L.play();
908
+ },
909
+ enter: ({ action: u, engine: a, isPlaying: m, time: d }) => {
910
+ const { src: g, previewSrc: S, offset: R } = u.data ?? {}, E = S || g;
911
+ E && (L.warm(E), L.setSource(E)), L.setActive(!0), L.setRate(a.getPlayRate());
912
+ const x = Number(R ?? 0);
913
+ L.seek(Math.max(0, d - u.start + (Number.isFinite(x) ? x : 0)), { force: !0 }), m && L.play();
914
+ },
915
+ update: ({ action: u, engine: a, time: m, isPlaying: d }) => {
916
+ const { src: g, previewSrc: S, offset: R } = u.data ?? {}, E = S || g;
917
+ if (E && L.setSource(E), L.setActive(!0), L.setRate(a.getPlayRate()), !d) {
918
+ const x = Number(R ?? 0);
919
+ L.seek(Math.max(0, m - u.start + (Number.isFinite(x) ? x : 0)), { force: !0 });
920
+ }
921
+ },
922
+ leave: () => {
923
+ L.pause(), L.unbindEngine(), L.setActive(!1);
924
+ },
925
+ stop: () => {
926
+ L.pause(), L.unbindEngine(), L.setActive(!1);
927
+ }
928
+ }
929
+ }
930
+ }, gn = [
931
+ {
932
+ id: "0",
933
+ actions: [
934
+ {
935
+ id: "action0",
936
+ start: 0,
937
+ end: 10,
938
+ effectId: "effect1",
939
+ data: {
940
+ src: "/footage/Big_Buck_Bunny_720_10s_5MB.mp4",
941
+ name: "Big Buck Bunny (10s)"
942
+ }
943
+ }
944
+ ]
945
+ },
946
+ {
947
+ id: "1",
948
+ actions: []
949
+ },
950
+ {
951
+ id: "2",
952
+ actions: [
953
+ {
954
+ id: "action1",
955
+ start: 0,
956
+ end: 10,
957
+ effectId: "effect0",
958
+ data: {
959
+ src: "/footage/file_example_MP3_700KB.mp3",
960
+ name: "Example MP3 (looped)"
961
+ }
962
+ }
963
+ ]
964
+ },
965
+ {
966
+ id: "3",
967
+ actions: []
968
+ }
969
+ ], { Option: hn } = $t, vn = [0.2, 0.5, 1, 1.5, 2], bn = ({
970
+ timelineState: u,
971
+ autoScrollWhenPlay: a,
972
+ editorData: m,
973
+ selectedActionId: d,
974
+ onDeleteSelectedClip: g,
975
+ onSplitSelectedClip: S,
976
+ canUndo: R,
977
+ canRedo: E,
978
+ onUndo: x,
979
+ onRedo: T
980
+ }) => {
981
+ const [k, A] = J(!1), [q, z] = J(0), [de, X] = J(!1), U = V(0), G = V(0), O = V(0), fe = V(0), be = V(0), oe = V(0), me = !!d, Ne = (() => {
982
+ if (!d) return null;
983
+ const y = Array.isArray(m) ? m : [];
984
+ for (const j of y) {
985
+ const D = j?.actions;
986
+ if (Array.isArray(D))
987
+ for (const C of D) {
988
+ if (String(C?.id) !== d) continue;
989
+ const F = Number(C?.start), M = Number(C?.end);
990
+ return !Number.isFinite(F) || !Number.isFinite(M) ? null : { start: F, end: M };
991
+ }
992
+ }
993
+ return null;
994
+ })(), ke = !!(Ne && q > Ne.start && q < Ne.end), Ye = (y) => {
995
+ const j = Array.isArray(m) ? m : [];
996
+ for (const D of j) {
997
+ const C = D?.actions;
998
+ if (Array.isArray(C))
999
+ for (const F of C) {
1000
+ if (F?.effectId !== "effect1") continue;
1001
+ const M = Number(F?.start), H = Number(F?.end);
1002
+ if (!(!Number.isFinite(M) || !Number.isFinite(H)) && y >= M && y < H)
1003
+ return !0;
1004
+ }
1005
+ }
1006
+ return !1;
1007
+ }, qe = (y) => {
1008
+ Ye(y) || (L.pause(), L.unbindEngine(), L.setActive(!1));
1009
+ };
1010
+ bt(() => {
1011
+ if (!u.current) return;
1012
+ const y = u.current, j = () => A(!0), D = () => A(!1), C = ({ time: M }) => {
1013
+ z(M), qe(M);
1014
+ }, F = ({ time: M }) => {
1015
+ const H = performance.now();
1016
+ if (!(H - U.current < 33) && (U.current = H, z(M), qe(M), a.current)) {
1017
+ const pe = M * (nt / rt) + vt - 500, ce = u.current;
1018
+ ce && ce.setScrollLeft(pe);
1019
+ }
1020
+ };
1021
+ return y.listener.on("play", j), y.listener.on("paused", D), y.listener.on("afterSetTime", C), y.listener.on("setTimeByTick", F), () => {
1022
+ y.listener.off("play", j), y.listener.off("paused", D), y.listener.off("afterSetTime", C), y.listener.off("setTimeByTick", F);
1023
+ };
1024
+ }, [m]);
1025
+ const Oe = () => {
1026
+ u.current && (u.current.isPlaying ? u.current.pause() : (ie.unlock(), u.current.play({ autoEnd: !0 })));
1027
+ }, se = (y) => {
1028
+ u.current && u.current.setPlayRate(y);
1029
+ }, ae = (y) => {
1030
+ const j = (parseInt(y % 1 * 100 + "") + "").padStart(2, "0"), D = (parseInt(y / 60 + "") + "").padStart(2, "0"), C = (parseInt(y % 60 + "") + "").padStart(2, "0");
1031
+ return /* @__PURE__ */ v.jsx(v.Fragment, { children: `${D}:${C}.${j.replace("0.", "")}` });
1032
+ }, te = () => {
1033
+ const y = [], j = /* @__PURE__ */ new Set(), D = Array.isArray(m) ? m : [];
1034
+ for (const C of D) {
1035
+ const F = C?.actions;
1036
+ if (Array.isArray(F))
1037
+ for (const M of F) {
1038
+ const H = M?.data?.src;
1039
+ if (!H) continue;
1040
+ const Se = String(H);
1041
+ j.has(Se) || (j.add(Se), y.push(Se));
1042
+ }
1043
+ }
1044
+ return y;
1045
+ }, Me = (y, j) => {
1046
+ const D = URL.createObjectURL(y), C = document.createElement("a");
1047
+ C.href = D, C.download = j, document.body.appendChild(C), C.click(), C.remove(), setTimeout(() => URL.revokeObjectURL(D), 3e3);
1048
+ }, ye = async () => {
1049
+ if (!de) {
1050
+ X(!0);
1051
+ try {
1052
+ const y = te(), j = new FormData();
1053
+ j.append("timeline", JSON.stringify({ editorData: m }));
1054
+ for (const F of y) {
1055
+ const M = await fetch(F);
1056
+ if (!M.ok) throw new Error(`Failed to fetch asset: ${F} (${M.status})`);
1057
+ const H = await M.blob();
1058
+ j.append("assets", H, encodeURIComponent(F));
1059
+ }
1060
+ const D = await fetch("/export", {
1061
+ method: "POST",
1062
+ body: j
1063
+ });
1064
+ if (!D.ok) {
1065
+ const F = await D.text().catch(() => "");
1066
+ throw new Error(F || `Export failed (${D.status})`);
1067
+ }
1068
+ const C = await D.blob();
1069
+ Me(C, "export.mp4");
1070
+ } finally {
1071
+ X(!1);
1072
+ }
1073
+ }
1074
+ };
1075
+ return /* @__PURE__ */ v.jsxs("div", { className: "timeline-player", children: [
1076
+ /* @__PURE__ */ v.jsx(
1077
+ "div",
1078
+ {
1079
+ className: "play-control",
1080
+ role: "button",
1081
+ tabIndex: 0,
1082
+ "aria-label": k ? "Pause" : "Play",
1083
+ onClick: () => {
1084
+ Date.now() - G.current < 450 || Oe();
1085
+ },
1086
+ onPointerUp: (y) => {
1087
+ y.pointerType !== "mouse" && (G.current = Date.now(), Oe());
1088
+ },
1089
+ children: /* @__PURE__ */ v.jsx(
1090
+ "img",
1091
+ {
1092
+ src: k ? "/pause-button.png" : "/play-button.png",
1093
+ alt: "",
1094
+ draggable: !1
1095
+ }
1096
+ )
1097
+ }
1098
+ ),
1099
+ /* @__PURE__ */ v.jsx("div", { className: "time", children: ae(q) }),
1100
+ /* @__PURE__ */ v.jsxs("div", { className: "history-tools", children: [
1101
+ /* @__PURE__ */ v.jsx(
1102
+ "button",
1103
+ {
1104
+ type: "button",
1105
+ className: "history-tool",
1106
+ disabled: !R,
1107
+ "aria-label": "Undo",
1108
+ onClick: () => {
1109
+ Date.now() - be.current < 450 || R && x();
1110
+ },
1111
+ onPointerUp: (y) => {
1112
+ y.pointerType !== "mouse" && (be.current = Date.now(), R && x());
1113
+ },
1114
+ children: /* @__PURE__ */ v.jsx("img", { src: "/undo.png", alt: "", draggable: !1 })
1115
+ }
1116
+ ),
1117
+ /* @__PURE__ */ v.jsx(
1118
+ "button",
1119
+ {
1120
+ type: "button",
1121
+ className: "history-tool",
1122
+ disabled: !E,
1123
+ "aria-label": "Redo",
1124
+ onClick: () => {
1125
+ Date.now() - oe.current < 450 || E && T();
1126
+ },
1127
+ onPointerUp: (y) => {
1128
+ y.pointerType !== "mouse" && (oe.current = Date.now(), E && T());
1129
+ },
1130
+ children: /* @__PURE__ */ v.jsx("img", { src: "/redo.png", alt: "", draggable: !1 })
1131
+ }
1132
+ )
1133
+ ] }),
1134
+ /* @__PURE__ */ v.jsx("div", { className: "rate-control", children: /* @__PURE__ */ v.jsx($t, { size: "small", defaultValue: 1, style: { width: 120 }, onChange: se, children: vn.map((y) => /* @__PURE__ */ v.jsx(hn, { value: y, children: `${y.toFixed(1)}x` }, y)) }) }),
1135
+ /* @__PURE__ */ v.jsxs("div", { className: "clip-tools", children: [
1136
+ /* @__PURE__ */ v.jsx(
1137
+ "button",
1138
+ {
1139
+ type: "button",
1140
+ className: "clip-tool clip-tool-delete",
1141
+ disabled: !me,
1142
+ "aria-label": "Delete selected clip",
1143
+ onClick: () => {
1144
+ Date.now() - O.current < 450 || me && g();
1145
+ },
1146
+ onPointerUp: (y) => {
1147
+ y.pointerType !== "mouse" && (O.current = Date.now(), me && g());
1148
+ },
1149
+ children: /* @__PURE__ */ v.jsx("img", { src: "/bin.png", alt: "", draggable: !1 })
1150
+ }
1151
+ ),
1152
+ /* @__PURE__ */ v.jsx(
1153
+ "button",
1154
+ {
1155
+ type: "button",
1156
+ className: "clip-tool clip-tool-split",
1157
+ disabled: !ke,
1158
+ "aria-label": "Split selected clip at cursor",
1159
+ onClick: () => {
1160
+ Date.now() - fe.current < 450 || ke && S();
1161
+ },
1162
+ onPointerUp: (y) => {
1163
+ y.pointerType !== "mouse" && (fe.current = Date.now(), ke && S());
1164
+ },
1165
+ children: /* @__PURE__ */ v.jsx("img", { src: "/split.png", alt: "", draggable: !1 })
1166
+ }
1167
+ )
1168
+ ] }),
1169
+ /* @__PURE__ */ v.jsx("div", { className: "export-control", children: /* @__PURE__ */ v.jsx(zt, { size: "small", type: "primary", loading: de, onClick: ye, children: "Export" }) })
1170
+ ] });
1171
+ };
1172
+ function yn() {
1173
+ const u = () => typeof window > "u" ? !1 : typeof navigator < "u" && // maxTouchPoints is the most reliable cross-browser hint.
1174
+ (navigator.maxTouchPoints ?? 0) > 0, [a, m] = J(u);
1175
+ return bt(() => {
1176
+ if (typeof window > "u" || typeof window.matchMedia != "function") return;
1177
+ const d = window.matchMedia("(pointer: coarse)"), g = () => m(!!d.matches || u());
1178
+ return g(), typeof d.addEventListener == "function" ? (d.addEventListener("change", g), () => d.removeEventListener("change", g)) : (d.addListener(g), () => d.removeListener(g));
1179
+ }, []), a;
1180
+ }
1181
+ const Sn = structuredClone(gn), ht = 5, Bt = ({ item: u, hint: a, isDragging: m }) => /* @__PURE__ */ v.jsxs("div", { className: `footage-card${m ? " is-dragging" : ""}`, children: [
1182
+ /* @__PURE__ */ v.jsx("div", { className: "footage-name", children: u.name }),
1183
+ u.kind === "video" ? /* @__PURE__ */ v.jsx(
1184
+ "video",
1185
+ {
1186
+ className: "footage-preview",
1187
+ src: u.src,
1188
+ muted: !0,
1189
+ preload: "metadata",
1190
+ draggable: !1,
1191
+ onDragStart: (d) => d.preventDefault(),
1192
+ playsInline: !0
1193
+ }
1194
+ ) : /* @__PURE__ */ v.jsx(
1195
+ "audio",
1196
+ {
1197
+ className: "footage-audio",
1198
+ src: u.src,
1199
+ controls: !0,
1200
+ preload: "metadata",
1201
+ draggable: !1,
1202
+ onDragStart: (d) => d.preventDefault()
1203
+ }
1204
+ ),
1205
+ /* @__PURE__ */ v.jsx("div", { className: "footage-kind", children: a })
1206
+ ] }), wn = ({ item: u, hint: a }) => {
1207
+ const { attributes: m, listeners: d, setNodeRef: g, transform: S, isDragging: R } = tn({
1208
+ id: `footage-${u.id}`,
1209
+ data: { item: u }
1210
+ }), E = S ? {
1211
+ transform: `translate3d(${S.x}px, ${S.y}px, 0)`
1212
+ } : void 0;
1213
+ return /* @__PURE__ */ v.jsx("div", { ref: g, style: E, ...d, ...m, children: /* @__PURE__ */ v.jsx(Bt, { item: u, hint: a, isDragging: R }) });
1214
+ }, Rn = (u) => String(u ?? "").toLowerCase().match(/\.(mp3|wav|m4a|aac|ogg)(\?|#|$)/) ? "audio" : "video", xn = (u, a) => {
1215
+ try {
1216
+ const m = String(u ?? "").split("/").pop() || "";
1217
+ return decodeURIComponent(m.split("?")[0].split("#")[0]) || `Footage ${a + 1}`;
1218
+ } catch {
1219
+ return `Footage ${a + 1}`;
1220
+ }
1221
+ }, Pn = ({ footageUrls: u }) => {
1222
+ const [a, m] = J(Sn), [d, g] = J(null), [S, R] = J([]), [E, x] = J([]), T = V(a), k = yn(), A = V(null), q = V(null), z = V(null), de = V(!0), X = _t(() => {
1223
+ const e = Array.isArray(u) ? u.filter(Boolean) : [];
1224
+ return e.length ? e.map((n, r) => ({
1225
+ id: `url-${r}`,
1226
+ kind: Rn(n),
1227
+ name: xn(n, r),
1228
+ src: n,
1229
+ defaultDuration: 10
1230
+ })) : [];
1231
+ }, [u]), [U, G] = J(null), [O, fe] = J(null), [be, oe] = J(null), [me, ot] = J(0), [Ne, ke] = J(0), [Ye, qe] = J(0), [Oe, se] = J(0), [ae, te] = J(!1), [Me, ye] = J(null), y = V(null), j = V(null), D = V(null), C = V(null), F = k ? 48 : 32, M = [0, 1], H = [2, 3], Se = ["V1", "V2", "A1", "A2"], pe = (e, n) => {
1232
+ if (n.length === 0) return null;
1233
+ if (e == null) return n[0];
1234
+ let r = n[0], s = Math.abs(e - r);
1235
+ for (const i of n) {
1236
+ const o = Math.abs(e - i);
1237
+ o < s && (r = i, s = o);
1238
+ }
1239
+ return r;
1240
+ }, ce = (e, n) => e ? e.kind === "video" ? pe(n, M) : pe(n, H) : null, Pe = (e) => e === M[1] ? H[1] : H[0];
1241
+ bt(() => {
1242
+ it.warmFromEditorData(a);
1243
+ }, [a]), bt(() => {
1244
+ T.current = a;
1245
+ }, [a]), Wt(() => {
1246
+ const e = z.current;
1247
+ if (!e) return;
1248
+ const n = () => {
1249
+ const s = e.getBoundingClientRect(), i = e.querySelector(".timeline-editor-edit-area");
1250
+ if (!i) return;
1251
+ const o = i.getBoundingClientRect();
1252
+ qe(o.top - s.top), se(o.left - s.left);
1253
+ }, r = requestAnimationFrame(n);
1254
+ return window.addEventListener("resize", n), () => {
1255
+ cancelAnimationFrame(r), window.removeEventListener("resize", n);
1256
+ };
1257
+ }, [k, a.length]);
1258
+ const Le = (e) => {
1259
+ const n = z.current;
1260
+ if (!n || !e) return !1;
1261
+ const r = n.getBoundingClientRect();
1262
+ return e.x >= r.left && e.x <= r.right && e.y >= r.top && e.y <= r.bottom;
1263
+ }, ze = V(0), ge = () => globalThis.crypto?.randomUUID ? globalThis.crypto.randomUUID() : `uid-${++ze.current}`, K = V(null), ne = V(null), $e = V(null), Be = 0.9, Ie = 1.05, Z = V({ actionId: null, edge: null }), W = V({
1264
+ actionId: null,
1265
+ mode: null,
1266
+ dir: null,
1267
+ basePointerTime: null,
1268
+ lastPointerTime: null,
1269
+ initialStart: 0,
1270
+ initialEnd: 0,
1271
+ takeover: !1
1272
+ }), Ce = V(!1), Ue = (e) => e.map((n) => {
1273
+ const r = (n.actions ?? []).map((s) => `${String(s.id)}@${Number(s.start)}-${Number(s.end)}`).join("|");
1274
+ return `${String(n.id)}:${r}`;
1275
+ }).join("||"), Fe = (e) => {
1276
+ const n = structuredClone(e);
1277
+ R((r) => {
1278
+ const s = [...r, n];
1279
+ return s.length > ht && s.splice(0, s.length - ht), s;
1280
+ }), x([]);
1281
+ }, Ve = (e, n, r, s) => e < s && n > r, he = (e, n, r, s) => {
1282
+ const i = Array.isArray(e?.actions) ? e.actions : [];
1283
+ for (const o of i)
1284
+ if (!(!o || o.id === n) && Ve(r, s, Number(o.start), Number(o.end)))
1285
+ return !0;
1286
+ return !1;
1287
+ }, Xe = (e, n) => {
1288
+ for (let r = 0; r < e.length; r++) {
1289
+ const s = e[r], i = Array.isArray(s?.actions) ? s.actions : [];
1290
+ for (let o = 0; o < i.length; o++) {
1291
+ const c = i[o];
1292
+ if (String(c?.id) === n)
1293
+ return { rowIndex: r, actionIndex: o, action: c };
1294
+ }
1295
+ }
1296
+ return null;
1297
+ }, we = (e, n) => {
1298
+ const r = Xe(e, n), s = r?.action?.data?.linkId;
1299
+ if (!r || !s) return null;
1300
+ for (let i = 0; i < e.length; i++) {
1301
+ const o = e[i], c = Array.isArray(o?.actions) ? o.actions : [];
1302
+ for (let f = 0; f < c.length; f++) {
1303
+ const p = c[f];
1304
+ if (p?.data?.linkId && String(p.data.linkId) === String(s) && String(p.id) !== String(n))
1305
+ return { rowIndex: i, actionIndex: f, action: p };
1306
+ }
1307
+ }
1308
+ return null;
1309
+ }, st = (e, n) => {
1310
+ const r = Xe(e, n);
1311
+ if (!r) return e;
1312
+ const s = we(e, n);
1313
+ if (!s) return e;
1314
+ const i = Number(r.action.start), o = Number(r.action.end);
1315
+ if (!Number.isFinite(i) || !Number.isFinite(o) || o <= i || Number(s.action.start) === i && Number(s.action.end) === o) return e;
1316
+ const c = structuredClone(e), f = c[s.rowIndex], p = Array.isArray(f.actions) ? [...f.actions] : [], h = { ...p[s.actionIndex], start: i, end: o };
1317
+ return p.splice(s.actionIndex, 1, h), f.actions = p, c;
1318
+ }, We = (e, n, r, s) => {
1319
+ if (!Number.isFinite(r) || !Number.isFinite(s) || s <= r) return e;
1320
+ const i = Xe(e, n);
1321
+ if (!i) return e;
1322
+ const o = we(e, n);
1323
+ if (!o) return e;
1324
+ const c = structuredClone(e), f = c[i.rowIndex], p = Array.isArray(f.actions) ? [...f.actions] : [], h = { ...p[i.actionIndex], start: r, end: s };
1325
+ p.splice(i.actionIndex, 1, h), f.actions = p;
1326
+ const b = c[o.rowIndex], N = Array.isArray(b.actions) ? [...b.actions] : [], w = { ...N[o.actionIndex], start: r, end: s };
1327
+ return N.splice(o.actionIndex, 1, w), b.actions = N, c;
1328
+ }, Je = (e, n, r, s) => {
1329
+ if (!Number.isFinite(r) || !Number.isFinite(s) || s <= r) return e;
1330
+ const i = Xe(e, n);
1331
+ if (!i) return e;
1332
+ const o = Number(i.action.start), c = Number(i.action.end);
1333
+ if (o === r && c === s) return e;
1334
+ const f = structuredClone(e), p = f[i.rowIndex], h = Array.isArray(p.actions) ? [...p.actions] : [], b = { ...h[i.actionIndex], start: r, end: s };
1335
+ return h.splice(i.actionIndex, 1, b), p.actions = h, f;
1336
+ }, Ge = () => {
1337
+ const e = A.current?.getTime ? Number(A.current.getTime()) : 0;
1338
+ return Number.isFinite(e) ? Math.max(0, e) : 0;
1339
+ }, Ze = (e, n, r) => {
1340
+ const s = Ge(), i = r - n;
1341
+ if (!Number.isFinite(i) || i <= 0)
1342
+ return { start: n, end: r, snapped: !1, edge: null };
1343
+ const o = Math.abs(n - s), c = Math.abs(r - s), f = o <= c ? "start" : "end", p = Math.min(o, c), h = Z.current;
1344
+ if (h.actionId === e && h.edge != null) {
1345
+ if ((h.edge === "start" ? o : c) > Ie)
1346
+ return Z.current = { actionId: e, edge: null }, { start: n, end: r, snapped: !1, edge: null };
1347
+ } else {
1348
+ if (p > Be)
1349
+ return { start: n, end: r, snapped: !1, edge: null };
1350
+ Z.current = { actionId: e, edge: f };
1351
+ }
1352
+ const w = Z.current.edge;
1353
+ if (w === "start") {
1354
+ const I = s, $ = I + i;
1355
+ return { start: Math.max(0, I), end: Math.max(Math.max(0, I), $), snapped: !0, edge: w };
1356
+ }
1357
+ const P = s, _ = P - i;
1358
+ return { start: Math.max(0, _), end: Math.max(0, P), snapped: !0, edge: w };
1359
+ }, at = (e, n, r, s) => {
1360
+ const i = Ge(), o = s === "left" ? "start" : "end", c = Math.abs(o === "start" ? n - i : r - i), f = Z.current;
1361
+ if (f.actionId === e && f.edge === o) {
1362
+ if (c > Ie)
1363
+ return Z.current = { actionId: e, edge: null }, { start: n, end: r, snapped: !1 };
1364
+ } else {
1365
+ if (c > Be)
1366
+ return { start: n, end: r, snapped: !1 };
1367
+ Z.current = { actionId: e, edge: o };
1368
+ }
1369
+ if (o === "start") {
1370
+ const w = Math.max(0, i), P = Math.max(w + 0.01, r);
1371
+ return { start: w, end: P, snapped: !0 };
1372
+ }
1373
+ const b = Math.max(0, i), N = Math.min(n, b - 0.01);
1374
+ return { start: Math.max(0, N), end: b, snapped: !0 };
1375
+ }, yt = (e, n, r) => {
1376
+ const s = e.defaultDuration ?? 10;
1377
+ let i = Math.max(0, n), o = i + s;
1378
+ const c = A.current;
1379
+ c?.isPlaying && c.pause(), m((f) => {
1380
+ Fe(f);
1381
+ const p = structuredClone(f);
1382
+ for (; p.length < 4; ) p.push({ id: `${p.length}`, actions: [] });
1383
+ const h = Number.isFinite(Number(r)) ? Number(r) : null, b = pe(h, M) ?? M[0], N = pe(h, H) ?? H[0], w = (P) => {
1384
+ const _ = [];
1385
+ for (const I of P) {
1386
+ const $ = Array.isArray(p[I]?.actions) ? p[I].actions : [];
1387
+ for (const Q of $) {
1388
+ const ve = Number(Q?.start), xe = Number(Q?.end);
1389
+ !Number.isFinite(ve) || !Number.isFinite(xe) || _.push({ start: ve, end: xe });
1390
+ }
1391
+ }
1392
+ _.sort((I, $) => I.start - $.start);
1393
+ for (const I of _)
1394
+ Ve(i, o, I.start, I.end) && (i = I.end, o = i + s);
1395
+ };
1396
+ if (e.kind === "video") {
1397
+ const P = b, _ = Pe(P);
1398
+ w([P, _]);
1399
+ const I = `link-${ge()}`, $ = `video-${ge()}`, Q = `video-audio-${ge()}`;
1400
+ p[P].actions = [
1401
+ ...p[P].actions ?? [],
1402
+ {
1403
+ id: $,
1404
+ start: i,
1405
+ end: o,
1406
+ effectId: "effect1",
1407
+ data: { src: e.src, previewSrc: e.previewSrc, name: e.name, linkId: I }
1408
+ }
1409
+ ], p[_].actions = [
1410
+ ...p[_].actions ?? [],
1411
+ {
1412
+ id: Q,
1413
+ start: i,
1414
+ end: o,
1415
+ effectId: "effect2",
1416
+ data: { src: e.src, name: e.name, linkId: I }
1417
+ }
1418
+ ];
1419
+ } else {
1420
+ const P = N;
1421
+ w([P]), p[P].actions = [
1422
+ ...p[P].actions ?? [],
1423
+ {
1424
+ id: `audio-${ge()}`,
1425
+ start: i,
1426
+ end: o,
1427
+ effectId: "effect0",
1428
+ data: { src: e.src, name: e.name }
1429
+ }
1430
+ ];
1431
+ }
1432
+ return p;
1433
+ });
1434
+ }, St = () => {
1435
+ const e = z.current;
1436
+ return e ? e.querySelector(".timeline-editor-edit-area .ReactVirtualized__Grid")?.scrollLeft ?? 0 : 0;
1437
+ }, wt = () => me, He = (e) => {
1438
+ const n = z.current;
1439
+ if (!n) return 0;
1440
+ const s = (n.querySelector(".timeline-editor-edit-area") ?? n).getBoundingClientRect(), c = (e - s.x + St() - vt) * rt / nt;
1441
+ return Math.max(0, c);
1442
+ }, Rt = (e) => {
1443
+ const n = Number(e);
1444
+ return Number.isFinite(n) ? vt + n * nt / rt : 0;
1445
+ }, xt = (e, n, r, s) => {
1446
+ const i = e.defaultDuration ?? 10;
1447
+ let o = Math.max(0, n), c = o + i;
1448
+ const f = [];
1449
+ if (e.kind === "video") {
1450
+ const h = r, b = Pe(h);
1451
+ f.push(h, b);
1452
+ } else
1453
+ f.push(r);
1454
+ const p = [];
1455
+ for (const h of f) {
1456
+ const b = Array.isArray(s[h]?.actions) ? s[h].actions : [];
1457
+ for (const N of b) {
1458
+ const w = Number(N?.start), P = Number(N?.end);
1459
+ !Number.isFinite(w) || !Number.isFinite(P) || p.push({ start: w, end: P });
1460
+ }
1461
+ }
1462
+ p.sort((h, b) => h.start - b.start);
1463
+ for (const h of p)
1464
+ Ve(o, c, h.start, h.end) && (o = h.end, c = o + i);
1465
+ return Math.max(0, o);
1466
+ }, _e = (e) => {
1467
+ const n = z.current;
1468
+ if (!n) return null;
1469
+ const r = n.querySelector(".timeline-editor-edit-area");
1470
+ if (!r) return null;
1471
+ const s = r.getBoundingClientRect(), i = e - s.y;
1472
+ if (i < 0 || i > s.height) return null;
1473
+ const o = i + wt(), c = Math.floor(o / F);
1474
+ if (!Number.isFinite(c)) return null;
1475
+ const f = Math.max(0, T.current.length - 1);
1476
+ return Math.min(Math.max(0, c), f);
1477
+ }, ct = (e) => {
1478
+ if (!e) return null;
1479
+ if ("clientX" in e && "clientY" in e) {
1480
+ const i = Number(e.clientX), o = Number(e.clientY);
1481
+ if (Number.isFinite(i) && Number.isFinite(o)) return { x: i, y: o };
1482
+ }
1483
+ const n = e.touches, r = e.changedTouches, s = (n && n.length ? n[0] : null) || (r && r.length ? r[0] : null);
1484
+ if (s) {
1485
+ const i = Number(s.clientX), o = Number(s.clientY);
1486
+ if (Number.isFinite(i) && Number.isFinite(o)) return { x: i, y: o };
1487
+ }
1488
+ return null;
1489
+ }, le = () => {
1490
+ if (Ce.current) return;
1491
+ Ce.current = !0;
1492
+ const e = (r) => {
1493
+ const s = W.current;
1494
+ if (!s.actionId || !s.mode || r.isPrimary === !1) return;
1495
+ const i = He(r.clientX);
1496
+ s.basePointerTime == null && (s.basePointerTime = i), s.lastPointerTime = i;
1497
+ }, n = () => {
1498
+ W.current = {
1499
+ actionId: null,
1500
+ mode: null,
1501
+ dir: null,
1502
+ basePointerTime: null,
1503
+ lastPointerTime: null,
1504
+ initialStart: 0,
1505
+ initialEnd: 0,
1506
+ takeover: !1
1507
+ }, Z.current = { actionId: null, edge: null };
1508
+ };
1509
+ window.addEventListener("pointermove", e, { capture: !0 }), window.addEventListener("pointerup", n, { capture: !0 }), window.addEventListener("pointercancel", n, { capture: !0 }), W.current._removePointerListeners = () => {
1510
+ window.removeEventListener("pointermove", e, { capture: !0 }), window.removeEventListener("pointerup", n, { capture: !0 }), window.removeEventListener("pointercancel", n, { capture: !0 }), Ce.current = !1;
1511
+ };
1512
+ }, Ke = () => {
1513
+ const e = W.current?._removePointerListeners;
1514
+ e?.(), delete W.current._removePointerListeners;
1515
+ }, Qe = (e) => e.map((n) => ({
1516
+ ...n,
1517
+ selected: void 0,
1518
+ actions: (n.actions ?? []).map((r) => ({ ...r, selected: void 0 }))
1519
+ })), lt = _t(() => a.map((e, n) => {
1520
+ const r = d ? (e.actions ?? []).some((c) => String(c.id) === d) : !1, s = U != null && be != null && n === be, i = Array.isArray(e.classNames) ? e.classNames : [], o = s ? [...i, "dnd-drop-hover"] : i;
1521
+ return {
1522
+ ...e,
1523
+ classNames: o,
1524
+ selected: r,
1525
+ actions: (e.actions ?? []).map((c) => ({
1526
+ ...c,
1527
+ selected: d ? String(c.id) === d : !1
1528
+ }))
1529
+ };
1530
+ }), [a, d, U, be]), Et = () => {
1531
+ if (!d) return;
1532
+ const e = A.current;
1533
+ e?.isPlaying && e.pause(), m((n) => {
1534
+ Fe(n);
1535
+ let r = null;
1536
+ for (const i of n) {
1537
+ const o = Array.isArray(i?.actions) ? i.actions : [];
1538
+ for (const c of o) {
1539
+ if (String(c?.id) !== d) continue;
1540
+ const f = c?.data?.linkId;
1541
+ f != null && (r = String(f));
1542
+ break;
1543
+ }
1544
+ if (r != null) break;
1545
+ }
1546
+ return n.map((i) => ({
1547
+ ...i,
1548
+ actions: (i.actions ?? []).filter((o) => !(String(o?.id) === d || r && String(o?.data?.linkId ?? "") === r))
1549
+ }));
1550
+ }), g(null);
1551
+ }, ut = () => {
1552
+ if (!d) return;
1553
+ const e = A.current, n = e?.getTime ? e.getTime() : null;
1554
+ if (n == null) return;
1555
+ const r = Number(n);
1556
+ Number.isFinite(r) && (e?.isPlaying && e.pause(), K.current = null, ne.current = null, m((s) => {
1557
+ let i = -1, o = -1, c = null;
1558
+ for (let B = 0; B < s.length; B++) {
1559
+ const Y = s[B], re = Array.isArray(Y?.actions) ? Y.actions : [];
1560
+ for (let ee = 0; ee < re.length; ee++) {
1561
+ const De = re[ee];
1562
+ if (String(De?.id) === d) {
1563
+ i = B, o = ee, c = De;
1564
+ break;
1565
+ }
1566
+ }
1567
+ if (c) break;
1568
+ }
1569
+ if (!c) return s;
1570
+ const f = c?.data?.linkId ? String(c.data.linkId) : null;
1571
+ let p = -1, h = -1, b = null;
1572
+ if (f)
1573
+ for (let B = 0; B < s.length; B++) {
1574
+ const Y = s[B], re = Array.isArray(Y?.actions) ? Y.actions : [];
1575
+ for (let ee = 0; ee < re.length; ee++) {
1576
+ const De = re[ee];
1577
+ if (String(De?.id) !== d && String(De?.data?.linkId ?? "") === f) {
1578
+ p = B, h = ee, b = De;
1579
+ break;
1580
+ }
1581
+ }
1582
+ if (b) break;
1583
+ }
1584
+ const N = Number(c.start), w = Number(c.end);
1585
+ if (!Number.isFinite(N) || !Number.isFinite(w) || !(N < r && r < w)) return s;
1586
+ Fe(s);
1587
+ const P = f && b ? `link-${ge()}` : f, _ = f && b ? `link-${ge()}` : f, I = `${String(c.id)}-r-${ge()}`, $ = Number(c?.data?.offset ?? 0), Q = Number.isFinite($) ? $ : 0, ve = r - N, xe = Q + (Number.isFinite(ve) ? ve : 0), je = {
1588
+ ...c,
1589
+ start: N,
1590
+ end: r,
1591
+ id: c.id,
1592
+ data: { ...c.data, offset: Q, linkId: P ?? void 0 }
1593
+ }, Ee = {
1594
+ ...c,
1595
+ start: r,
1596
+ end: w,
1597
+ id: I,
1598
+ data: { ...c.data, offset: xe, linkId: _ ?? void 0 }
1599
+ }, Te = structuredClone(s), ue = Te[i], Ae = Array.isArray(ue.actions) ? [...ue.actions] : [];
1600
+ if (Ae.splice(o, 1, je, Ee), Ae.sort((B, Y) => Number(B.start) - Number(Y.start)), ue.actions = Ae, b && p >= 0 && h >= 0) {
1601
+ const B = Number(b.start), Y = Number(b.end);
1602
+ if (Number.isFinite(B) && Number.isFinite(Y) && B === N && Y === w) {
1603
+ const re = `${String(b.id)}-r-${ge()}`, ee = {
1604
+ ...b,
1605
+ start: N,
1606
+ end: r,
1607
+ id: b.id,
1608
+ data: { ...b.data, linkId: P ?? void 0 }
1609
+ }, De = {
1610
+ ...b,
1611
+ start: r,
1612
+ end: w,
1613
+ id: re,
1614
+ data: { ...b.data, linkId: _ ?? void 0 }
1615
+ }, Ct = Te[p], Ft = Array.isArray(Ct.actions) ? [...Ct.actions] : [];
1616
+ Ft.splice(h, 1, ee, De), Ft.sort((Ut, Vt) => Number(Ut.start) - Number(Vt.start)), Ct.actions = Ft;
1617
+ }
1618
+ }
1619
+ return Te;
1620
+ }));
1621
+ }, Tt = () => {
1622
+ const e = A.current, n = e?.getTime ? e.getTime() : null;
1623
+ e?.isPlaying && e.pause(), K.current = null, ne.current = null, g(null), R((r) => {
1624
+ if (r.length === 0) return r;
1625
+ const s = r[r.length - 1], i = structuredClone(T.current);
1626
+ return x((o) => [...o, i]), m(structuredClone(s)), r.slice(0, -1);
1627
+ }), n != null && requestAnimationFrame(() => {
1628
+ const r = A.current;
1629
+ r?.setTime && r.setTime(n);
1630
+ });
1631
+ }, dt = () => {
1632
+ const e = A.current, n = e?.getTime ? e.getTime() : null;
1633
+ e?.isPlaying && e.pause(), K.current = null, ne.current = null, g(null), x((r) => {
1634
+ if (r.length === 0) return r;
1635
+ const s = r[r.length - 1], i = structuredClone(T.current);
1636
+ return R((o) => {
1637
+ const c = [...o, i];
1638
+ return c.length > ht && c.splice(0, c.length - ht), c;
1639
+ }), m(structuredClone(s)), r.slice(0, -1);
1640
+ }), n != null && requestAnimationFrame(() => {
1641
+ const r = A.current;
1642
+ r?.setTime && r.setTime(n);
1643
+ });
1644
+ }, ft = Xt(
1645
+ jt(Jt, { activationConstraint: { distance: 6 } }),
1646
+ // On touch, require a short press-hold before starting drag, so scroll is still possible.
1647
+ jt(Kt, { activationConstraint: { delay: 180, tolerance: 6 } })
1648
+ ), { setNodeRef: At, isOver: Nt } = Gt({ id: "timeline-drop" }), mt = (e) => {
1649
+ const n = e.active.data.current?.item;
1650
+ G(n ?? null);
1651
+ const r = ct(e.activatorEvent);
1652
+ if (y.current = r, j.current = r, ye(r), r) {
1653
+ const i = Le(r);
1654
+ te(i);
1655
+ const o = _e(r.y);
1656
+ oe(i ? ce(n ?? null, o) : null);
1657
+ } else
1658
+ oe(null), te(!1);
1659
+ const s = e.active.rect.current.initial;
1660
+ fe(s ? { width: s.width, height: s.height } : null);
1661
+ }, pt = (e) => {
1662
+ const n = e.active.rect.current.initial;
1663
+ !O && n && fe({ width: n.width, height: n.height });
1664
+ const r = j.current;
1665
+ if (!r) {
1666
+ oe(null);
1667
+ return;
1668
+ }
1669
+ const s = Number(e?.delta?.x ?? 0), i = Number(e?.delta?.y ?? 0), o = { x: r.x + (Number.isFinite(s) ? s : 0), y: r.y + (Number.isFinite(i) ? i : 0) };
1670
+ y.current = o, ye(o);
1671
+ const c = Le(o);
1672
+ te(c);
1673
+ const f = _e(o.y);
1674
+ oe(c ? ce(U, f) : null);
1675
+ }, kt = (e) => {
1676
+ const n = e.active.data.current?.item, r = j.current, s = Number(e?.delta?.x ?? 0), i = Number(e?.delta?.y ?? 0), o = r ? { x: r.x + (Number.isFinite(s) ? s : 0), y: r.y + (Number.isFinite(i) ? i : 0) } : y.current;
1677
+ y.current = o;
1678
+ const f = String(e.over?.id ?? "") === "timeline-drop" || Le(o);
1679
+ if (n && f && o) {
1680
+ const p = He(o.x), h = _e(o.y), b = ce(n, h);
1681
+ oe(b), yt(n, Math.max(0, p), b);
1682
+ }
1683
+ G(null), fe(null), oe(null), te(!1), ye(null), j.current = null;
1684
+ }, Pt = () => {
1685
+ G(null), fe(null), oe(null), te(!1), ye(null), j.current = null;
1686
+ }, Re = _t(() => {
1687
+ if (!U || !ae) return null;
1688
+ const e = Me;
1689
+ if (!e) return null;
1690
+ const n = _e(e.y), r = ce(U, n);
1691
+ if (r == null) return null;
1692
+ const s = He(e.x), i = xt(U, s, r, T.current), o = U.defaultDuration ?? 10;
1693
+ return {
1694
+ laneRow: r,
1695
+ desiredStart: s,
1696
+ start: i,
1697
+ end: i + o,
1698
+ duration: o,
1699
+ kind: U.kind
1700
+ };
1701
+ }, [U, ae, Me, Ne, me, F]), It = (e) => {
1702
+ if (!k || e.pointerType === "mouse" || U) return;
1703
+ if (!!e.target?.closest?.(".timeline-editor-cursor-area, .timeline-editor-cursor")) {
1704
+ C.current = { pointerId: e.pointerId }, D.current = null;
1705
+ try {
1706
+ e.currentTarget.setPointerCapture(e.pointerId);
1707
+ } catch {
1708
+ }
1709
+ e.preventDefault();
1710
+ return;
1711
+ }
1712
+ D.current = { x: e.clientX, y: e.clientY };
1713
+ }, t = (e) => {
1714
+ if (!k || e.pointerType === "mouse" || U || !C.current || C.current.pointerId !== e.pointerId) return;
1715
+ const n = He(e.clientX);
1716
+ A.current && A.current.setTime(n), e.preventDefault();
1717
+ }, l = (e) => {
1718
+ if (!k || e.pointerType === "mouse" || U) return;
1719
+ if (C.current && C.current.pointerId === e.pointerId) {
1720
+ C.current = null;
1721
+ try {
1722
+ e.currentTarget.releasePointerCapture(e.pointerId);
1723
+ } catch {
1724
+ }
1725
+ e.preventDefault();
1726
+ return;
1727
+ }
1728
+ const n = D.current;
1729
+ D.current = null;
1730
+ const r = n ? Math.abs(e.clientX - n.x) : 0, s = n ? Math.abs(e.clientY - n.y) : 0;
1731
+ if (r > 10 || s > 10) return;
1732
+ const o = e.target?.closest?.("[data-action-id]"), c = o?.getAttribute("data-row-id"), f = o?.getAttribute("data-action-id");
1733
+ if (c && f) {
1734
+ g(f);
1735
+ return;
1736
+ }
1737
+ const p = He(e.clientX);
1738
+ g(null), A.current && A.current.setTime(p);
1739
+ };
1740
+ return /* @__PURE__ */ v.jsx(
1741
+ Zt,
1742
+ {
1743
+ sensors: ft,
1744
+ collisionDetection: Qt,
1745
+ onDragStart: mt,
1746
+ onDragMove: pt,
1747
+ onDragEnd: kt,
1748
+ onDragCancel: Pt,
1749
+ children: /* @__PURE__ */ v.jsxs("div", { className: "timeline-editor-engine", children: [
1750
+ /* @__PURE__ */ v.jsx("div", { className: "player-config", children: /* @__PURE__ */ v.jsx("div", { className: "footage-bin", children: X.map((e) => /* @__PURE__ */ v.jsx(
1751
+ wn,
1752
+ {
1753
+ item: e,
1754
+ hint: k ? "Press-hold, then drag into timeline" : "Drag into timeline"
1755
+ },
1756
+ e.id
1757
+ )) }) }),
1758
+ /* @__PURE__ */ v.jsx("div", { className: "player-panel", ref: q, children: /* @__PURE__ */ v.jsx(
1759
+ "video",
1760
+ {
1761
+ className: "player-video",
1762
+ preload: "auto",
1763
+ playsInline: !0,
1764
+ muted: !0,
1765
+ controls: !1,
1766
+ disablePictureInPicture: !0,
1767
+ disableRemotePlayback: !0,
1768
+ controlsList: "nodownload noplaybackrate noremoteplayback",
1769
+ tabIndex: -1,
1770
+ onContextMenu: (e) => e.preventDefault(),
1771
+ ref: (e) => L.attach(e)
1772
+ }
1773
+ ) }),
1774
+ /* @__PURE__ */ v.jsx(
1775
+ bn,
1776
+ {
1777
+ timelineState: A,
1778
+ autoScrollWhenPlay: de,
1779
+ editorData: a,
1780
+ selectedActionId: d,
1781
+ onDeleteSelectedClip: Et,
1782
+ onSplitSelectedClip: ut,
1783
+ canUndo: S.length > 0,
1784
+ canRedo: E.length > 0,
1785
+ onUndo: Tt,
1786
+ onRedo: dt
1787
+ }
1788
+ ),
1789
+ /* @__PURE__ */ v.jsxs(
1790
+ "div",
1791
+ {
1792
+ className: `timeline-drop${Nt ? " is-over" : ""}`,
1793
+ ref: (e) => {
1794
+ z.current = e, At(e);
1795
+ },
1796
+ onPointerDown: It,
1797
+ onPointerMove: t,
1798
+ onPointerUp: l,
1799
+ children: [
1800
+ /* @__PURE__ */ v.jsx(
1801
+ "div",
1802
+ {
1803
+ className: "timeline-lane-labels",
1804
+ style: {
1805
+ top: Ye,
1806
+ transform: `translateY(${-me}px)`,
1807
+ height: F * Se.length
1808
+ },
1809
+ children: Se.map((e, n) => /* @__PURE__ */ v.jsx(
1810
+ "div",
1811
+ {
1812
+ className: `timeline-lane-label${be === n ? " is-hover" : ""}`,
1813
+ style: { height: F },
1814
+ children: e
1815
+ },
1816
+ e
1817
+ ))
1818
+ }
1819
+ ),
1820
+ Re ? /* @__PURE__ */ v.jsx("div", { className: "timeline-ghost-layer", style: { top: Ye, left: Oe }, children: (() => {
1821
+ const e = nt / rt, n = Re.duration * e, r = Rt(Re.start) - Ne, s = [];
1822
+ return Re.kind === "video" ? (s.push({ row: Re.laneRow, kind: "video" }), s.push({ row: Pe(Re.laneRow), kind: "audio" })) : s.push({ row: Re.laneRow, kind: "audio" }), s.map((i) => /* @__PURE__ */ v.jsx(
1823
+ "div",
1824
+ {
1825
+ className: `timeline-ghost-clip${i.kind === "video" ? " is-video" : " is-audio"}`,
1826
+ style: {
1827
+ left: r,
1828
+ top: i.row * F - me,
1829
+ width: n,
1830
+ height: F
1831
+ }
1832
+ },
1833
+ `${i.kind}-${i.row}`
1834
+ ));
1835
+ })() }) : null,
1836
+ /* @__PURE__ */ v.jsx(
1837
+ Ht,
1838
+ {
1839
+ scale: rt,
1840
+ scaleWidth: nt,
1841
+ startLeft: vt,
1842
+ rowHeight: F,
1843
+ autoScroll: !0,
1844
+ ref: A,
1845
+ editorData: lt,
1846
+ effects: pn,
1847
+ onScroll: (e) => {
1848
+ const n = Number(e?.scrollTop ?? 0), r = Number(e?.scrollLeft ?? 0);
1849
+ Number.isFinite(n) && ot(n), Number.isFinite(r) && ke(r);
1850
+ },
1851
+ onClickTimeArea: (e, n) => {
1852
+ g(null);
1853
+ },
1854
+ onClickRow: (e) => {
1855
+ e.target?.closest?.(".timeline-editor-action") || g(null);
1856
+ },
1857
+ onClickActionOnly: (e, { action: n }) => {
1858
+ const r = n;
1859
+ r?.id && g(String(r.id));
1860
+ },
1861
+ onActionMoveStart: ({ action: e }) => {
1862
+ $e.current = String(e?.id ?? ""), Z.current = { actionId: String(e?.id ?? ""), edge: null };
1863
+ const n = Number(e?.start), r = Number(e?.end);
1864
+ W.current = {
1865
+ actionId: String(e?.id ?? ""),
1866
+ mode: "move",
1867
+ dir: null,
1868
+ basePointerTime: null,
1869
+ lastPointerTime: null,
1870
+ initialStart: Number.isFinite(n) ? n : 0,
1871
+ initialEnd: Number.isFinite(r) ? r : 0,
1872
+ takeover: !1
1873
+ }, le(), !K.current && (K.current = structuredClone(a), ne.current = Ue(a));
1874
+ },
1875
+ onActionMoveEnd: () => {
1876
+ const e = K.current, n = ne.current;
1877
+ e && n && Ue(T.current) !== n && Fe(e), K.current = null, ne.current = null, $e.current = null, Z.current = { actionId: null, edge: null }, W.current = {
1878
+ actionId: null,
1879
+ mode: null,
1880
+ dir: null,
1881
+ basePointerTime: null,
1882
+ lastPointerTime: null,
1883
+ initialStart: 0,
1884
+ initialEnd: 0,
1885
+ takeover: !1
1886
+ }, Ke();
1887
+ },
1888
+ onActionResizeStart: ({ action: e }) => {
1889
+ $e.current = String(e?.id ?? ""), Z.current = { actionId: String(e?.id ?? ""), edge: null };
1890
+ const n = Number(e?.start), r = Number(e?.end);
1891
+ W.current = {
1892
+ actionId: String(e?.id ?? ""),
1893
+ mode: "resize",
1894
+ dir: null,
1895
+ basePointerTime: null,
1896
+ lastPointerTime: null,
1897
+ initialStart: Number.isFinite(n) ? n : 0,
1898
+ initialEnd: Number.isFinite(r) ? r : 0,
1899
+ takeover: !1
1900
+ }, le(), !K.current && (K.current = structuredClone(a), ne.current = Ue(a));
1901
+ },
1902
+ onActionResizeEnd: () => {
1903
+ const e = K.current, n = ne.current;
1904
+ e && n && Ue(T.current) !== n && Fe(e), K.current = null, ne.current = null, $e.current = null, Z.current = { actionId: null, edge: null }, W.current = {
1905
+ actionId: null,
1906
+ mode: null,
1907
+ dir: null,
1908
+ basePointerTime: null,
1909
+ lastPointerTime: null,
1910
+ initialStart: 0,
1911
+ initialEnd: 0,
1912
+ takeover: !1
1913
+ }, Ke();
1914
+ },
1915
+ onActionMoving: ({ action: e, row: n, start: r, end: s }) => {
1916
+ const i = String(e?.id ?? ""), o = W.current;
1917
+ if (o.takeover && o.mode === "move" && o.actionId === i) {
1918
+ const _ = o.basePointerTime, I = o.lastPointerTime, $ = _ != null && I != null ? I - _ : 0, Q = o.initialStart + $, ve = o.initialEnd + $, xe = Ze(i, Q, ve), je = xe.start, Ee = xe.end;
1919
+ if (he(n, String(e.id), je, Ee)) return !1;
1920
+ const ue = T.current, Ae = we(ue, String(e.id));
1921
+ if (Ae) {
1922
+ const B = ue[Ae.rowIndex];
1923
+ if (B && he(B, String(Ae.action.id), je, Ee)) return !1;
1924
+ }
1925
+ return m((B) => {
1926
+ const Y = Ae ? We(B, String(e.id), je, Ee) : Je(B, String(e.id), je, Ee);
1927
+ return T.current = Y, Y;
1928
+ }), !1;
1929
+ }
1930
+ const c = Number(r), f = Number(s);
1931
+ if (!Number.isFinite(c) || !Number.isFinite(f) || f <= c) return !1;
1932
+ const p = Ze(i, c, f), h = p.start, b = p.end;
1933
+ if (!Number.isFinite(h) || !Number.isFinite(b) || b <= h || he(n, String(e.id), h, b)) return !1;
1934
+ const w = T.current, P = we(w, String(e.id));
1935
+ if (P) {
1936
+ const _ = w[P.rowIndex];
1937
+ if (_ && he(_, String(P.action.id), h, b)) return !1;
1938
+ }
1939
+ if ((P || p.snapped) && m((_) => {
1940
+ const I = P ? We(_, String(e.id), h, b) : Je(_, String(e.id), h, b);
1941
+ return T.current = I, I;
1942
+ }), p.snapped) {
1943
+ const _ = W.current.lastPointerTime;
1944
+ return W.current = {
1945
+ actionId: i,
1946
+ mode: "move",
1947
+ dir: null,
1948
+ basePointerTime: _,
1949
+ lastPointerTime: W.current.lastPointerTime,
1950
+ initialStart: c,
1951
+ initialEnd: f,
1952
+ takeover: !0
1953
+ }, le(), !1;
1954
+ }
1955
+ },
1956
+ onActionResizing: ({ action: e, row: n, start: r, end: s, dir: i }) => {
1957
+ const o = String(e?.id ?? ""), c = W.current, f = i ?? "right";
1958
+ if (c.takeover && c.mode === "resize" && c.actionId === o) {
1959
+ const $ = c.basePointerTime, Q = c.lastPointerTime, ve = $ != null && Q != null ? Q - $ : 0, xe = f === "left" ? c.initialStart + ve : c.initialStart, je = f === "right" ? c.initialEnd + ve : c.initialEnd, Ee = at(o, xe, je, f), Te = Ee.start, ue = Ee.end;
1960
+ if (he(n, String(e.id), Te, ue)) return !1;
1961
+ const B = T.current, Y = we(B, String(e.id));
1962
+ if (Y) {
1963
+ const re = B[Y.rowIndex];
1964
+ if (re && he(re, String(Y.action.id), Te, ue)) return !1;
1965
+ }
1966
+ return m((re) => {
1967
+ const ee = Y ? We(re, String(e.id), Te, ue) : Je(re, String(e.id), Te, ue);
1968
+ return T.current = ee, ee;
1969
+ }), !1;
1970
+ }
1971
+ const p = Number(r), h = Number(s);
1972
+ if (!Number.isFinite(p) || !Number.isFinite(h) || h <= p) return !1;
1973
+ const b = at(o, p, h, f), N = b.start, w = b.end;
1974
+ if (!Number.isFinite(N) || !Number.isFinite(w) || w <= N || he(n, String(e.id), N, w)) return !1;
1975
+ const _ = T.current, I = we(_, String(e.id));
1976
+ if (I) {
1977
+ const $ = _[I.rowIndex];
1978
+ if ($ && he($, String(I.action.id), N, w)) return !1;
1979
+ }
1980
+ if ((I || b.snapped) && m(($) => {
1981
+ const Q = I ? We($, String(e.id), N, w) : Je($, String(e.id), N, w);
1982
+ return T.current = Q, Q;
1983
+ }), b.snapped) {
1984
+ const $ = W.current.lastPointerTime;
1985
+ return W.current = {
1986
+ actionId: o,
1987
+ mode: "resize",
1988
+ dir: f,
1989
+ basePointerTime: $,
1990
+ lastPointerTime: W.current.lastPointerTime,
1991
+ initialStart: p,
1992
+ initialEnd: h,
1993
+ takeover: !0
1994
+ }, le(), !1;
1995
+ }
1996
+ },
1997
+ onChange: (e) => {
1998
+ const n = Qe(e), r = $e.current, s = r ? st(n, r) : n;
1999
+ m(s);
2000
+ const i = K.current, o = ne.current;
2001
+ i && o && (Ue(s) !== o && Fe(i), K.current = null, ne.current = null);
2002
+ },
2003
+ getActionRender: (e, n) => {
2004
+ if (e.effectId === "effect0")
2005
+ return /* @__PURE__ */ v.jsx(sn, { action: e, row: n });
2006
+ if (e.effectId === "effect2")
2007
+ return /* @__PURE__ */ v.jsx(cn, { action: e, row: n });
2008
+ if (e.effectId === "effect1")
2009
+ return /* @__PURE__ */ v.jsx(an, { action: e, row: n });
2010
+ }
2011
+ }
2012
+ )
2013
+ ]
2014
+ }
2015
+ ),
2016
+ /* @__PURE__ */ v.jsx(en, { children: U ? /* @__PURE__ */ v.jsx(
2017
+ "div",
2018
+ {
2019
+ className: "footage-overlay",
2020
+ style: O ? {
2021
+ width: O.width,
2022
+ height: O.height
2023
+ } : void 0,
2024
+ children: /* @__PURE__ */ v.jsx(Bt, { item: U, hint: "Drop on timeline", isDragging: !0 })
2025
+ }
2026
+ ) : null })
2027
+ ] })
2028
+ }
2029
+ );
2030
+ };
2031
+ export {
2032
+ Pn as MeliesVideoEditor
2033
+ };