@video-editor/ui 0.0.1-beta.13 → 0.0.1-beta.15

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.
@@ -0,0 +1,759 @@
1
+ import { defineComponent as ke, createElementBlock as k, openBlock as b, withModifiers as ie, normalizeStyle as D, createStaticVNode as Ce, createElementVNode as c, Fragment as pe, renderList as xe, normalizeClass as De, createCommentVNode as te, toDisplayString as V, renderSlot as L, computed as M, ref as z, watch as he, toRef as Ze, onMounted as Ve, onBeforeUnmount as Le, createVNode as $e, withDirectives as Oe, unref as K, vShow as Ye } from "vue";
2
+ const He = /* @__PURE__ */ ke({
3
+ name: "TimelinePlayhead",
4
+ __name: "TimelinePlayhead",
5
+ props: {
6
+ left: {}
7
+ },
8
+ emits: ["dragStart"],
9
+ setup(o, { emit: f }) {
10
+ const s = f;
11
+ return (i, l) => (b(), k("div", {
12
+ class: "ve-playhead",
13
+ style: D({ left: `${o.left}px` }),
14
+ onMousedown: l[0] || (l[0] = ie((_) => s("dragStart", _), ["stop", "prevent"]))
15
+ }, [...l[1] || (l[1] = [
16
+ Ce('<svg class="ve-playhead__icon" width="12" height="18" viewBox="0 0 12 18" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-601eb0b9><g filter="url(#ve_playhead_drop_shadow)" data-v-601eb0b9><path d="M2 3C2 1.89543 2.89543 1 4 1H8C9.10457 1 10 1.89543 10 3V11.0925C10 11.6692 9.75104 12.2178 9.31701 12.5976L7.31701 14.3476C6.56296 15.0074 5.43704 15.0074 4.68299 14.3476L2.68299 12.5976C2.24896 12.2178 2 11.6692 2 11.0925V3Z" fill="white" data-v-601eb0b9></path><path d="M4 1.5H8C8.82843 1.5 9.5 2.17157 9.5 3V11.0928C9.49991 11.5252 9.31275 11.9369 8.9873 12.2217L6.9873 13.9717C6.42191 14.466 5.57809 14.466 5.0127 13.9717L3.0127 12.2217C2.68725 11.9369 2.50009 11.5252 2.5 11.0928V3C2.5 2.17157 3.17157 1.5 4 1.5Z" stroke="currentColor" data-v-601eb0b9></path></g><defs data-v-601eb0b9><filter id="ve_playhead_drop_shadow" x="0" y="0" width="12" height="17.8428" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB" data-v-601eb0b9><feFlood flood-opacity="0" result="BackgroundImageFix" data-v-601eb0b9></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha" data-v-601eb0b9></feColorMatrix><feOffset dy="1" data-v-601eb0b9></feOffset><feGaussianBlur stdDeviation="1" data-v-601eb0b9></feGaussianBlur><feComposite in2="hardAlpha" operator="out" data-v-601eb0b9></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.08 0" data-v-601eb0b9></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow" data-v-601eb0b9></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape" data-v-601eb0b9></feBlend></filter></defs></svg><div class="ve-playhead__line" data-v-601eb0b9></div>', 2)
17
+ ])], 36));
18
+ }
19
+ }), be = (o, f) => {
20
+ const s = o.__vccOpts || o;
21
+ for (const [i, l] of f)
22
+ s[i] = l;
23
+ return s;
24
+ }, We = /* @__PURE__ */ be(He, [["__scopeId", "data-v-601eb0b9"]]), Ae = { class: "ve-ruler" }, je = { class: "ve-ruler__ticks" }, Ue = {
25
+ key: 0,
26
+ class: "ve-ruler__label"
27
+ }, Ke = /* @__PURE__ */ ke({
28
+ name: "TimelineRuler",
29
+ __name: "TimelineRuler",
30
+ props: {
31
+ ticks: {}
32
+ },
33
+ setup(o) {
34
+ return (f, s) => (b(), k("div", Ae, [
35
+ c("div", je, [
36
+ (b(!0), k(pe, null, xe(o.ticks, (i) => (b(), k("div", {
37
+ key: i.timeMs,
38
+ class: De(["ve-ruler__tick", { "ve-ruler__tick--major": i.isMajor }]),
39
+ style: D({
40
+ left: `${i.position}px`,
41
+ transform: "translateX(-50%)"
42
+ })
43
+ }, [
44
+ s[0] || (s[0] = c("div", { class: "ve-ruler__line" }, null, -1)),
45
+ i.isMajor && i.label ? (b(), k("div", Ue, V(i.label), 1)) : te("", !0)
46
+ ], 6))), 128))
47
+ ])
48
+ ]));
49
+ }
50
+ }), qe = /* @__PURE__ */ be(Ke, [["__scopeId", "data-v-30f91636"]]), Je = { class: "ve-toolbar" }, Qe = { class: "ve-toolbar__group" }, et = ["disabled"], tt = { class: "ve-toolbar__group" }, nt = { class: "ve-zoom" }, at = { class: "ve-toolbar__group" }, st = ["disabled"], ot = { class: "ve-toolbar__time" }, it = /* @__PURE__ */ ke({
51
+ name: "TimelineToolbar",
52
+ __name: "TimelineToolbar",
53
+ props: {
54
+ zoom: {},
55
+ minZoom: { default: 0.25 },
56
+ maxZoom: { default: 10 },
57
+ currentTime: { default: 0 },
58
+ duration: { default: 0 },
59
+ formatTime: { type: Function, default: (o) => `${(o / 1e3).toFixed(2)}s` }
60
+ },
61
+ emits: ["zoomIn", "zoomOut"],
62
+ setup(o, { emit: f }) {
63
+ const s = f;
64
+ return (i, l) => (b(), k("div", Je, [
65
+ c("div", Qe, [
66
+ L(i.$slots, "left-actions", {}, () => [
67
+ c("button", {
68
+ class: "ve-btn",
69
+ type: "button",
70
+ disabled: o.zoom <= o.minZoom,
71
+ onClick: l[0] || (l[0] = (_) => s("zoomOut"))
72
+ }, " - ", 8, et)
73
+ ], !0)
74
+ ]),
75
+ c("div", tt, [
76
+ L(i.$slots, "center", {}, () => [
77
+ c("div", nt, V((o.zoom * 100).toFixed(0)) + "% ", 1)
78
+ ], !0)
79
+ ]),
80
+ c("div", at, [
81
+ L(i.$slots, "right-actions", {}, () => [
82
+ c("button", {
83
+ class: "ve-btn",
84
+ type: "button",
85
+ disabled: o.zoom >= o.maxZoom,
86
+ onClick: l[1] || (l[1] = (_) => s("zoomIn"))
87
+ }, " + ", 8, st)
88
+ ], !0)
89
+ ]),
90
+ c("div", ot, [
91
+ L(i.$slots, "time", {
92
+ currentTime: o.currentTime,
93
+ duration: o.duration
94
+ }, () => [
95
+ c("span", null, V(o.formatTime?.(o.currentTime || 0)), 1),
96
+ l[2] || (l[2] = c("span", { class: "ve-toolbar__time-divider" }, "/", -1)),
97
+ c("span", null, V(o.formatTime?.(o.duration || 0)), 1)
98
+ ], !0)
99
+ ])
100
+ ]));
101
+ }
102
+ }), lt = /* @__PURE__ */ be(it, [["__scopeId", "data-v-85ddeb0f"]]);
103
+ function rt(o, f, s, i) {
104
+ function l(Z) {
105
+ if (!o.value || !f.value.length)
106
+ return null;
107
+ const h = o.value.getBoundingClientRect(), I = Z - h.top, r = s.value + i.value, p = i.value;
108
+ if (I < p / 2)
109
+ return { isGap: !0, insertIndex: 0 };
110
+ for (let g = 0; g < f.value.length; g++) {
111
+ const d = (g + 1) * r - p / 2, ne = (g + 1) * r + p / 2;
112
+ if (I >= d && I < ne)
113
+ return { isGap: !0, insertIndex: g + 1 };
114
+ }
115
+ return null;
116
+ }
117
+ function _(Z) {
118
+ if (!o.value || !f.value.length)
119
+ return -1;
120
+ const h = o.value.getBoundingClientRect(), I = Z - h.top, r = s.value + i.value;
121
+ return I < 0 ? -1 : Math.min(
122
+ f.value.length - 1,
123
+ Math.max(0, Math.floor(I / r))
124
+ );
125
+ }
126
+ return {
127
+ detectTrackGap: l,
128
+ resolveTrackIndexFromClientY: _
129
+ };
130
+ }
131
+ function ut(o, f, s) {
132
+ return {
133
+ snapGuides: M(() => {
134
+ if (!o.value)
135
+ return [];
136
+ const l = /* @__PURE__ */ new Set(), _ = o.value.startTime, Z = o.value.endTime, h = 100;
137
+ return ("value" in f ? f.value : f).forEach((r) => {
138
+ r.segments.forEach((p) => {
139
+ p.id !== o.value?.segment.id && (Math.abs(p.start - _) < h && l.add(p.start), Math.abs(p.end - _) < h && l.add(p.end), Math.abs(p.start - Z) < h && l.add(p.start), Math.abs(p.end - Z) < h && l.add(p.end));
140
+ });
141
+ }), Array.from(l).map((r) => ({
142
+ time: r,
143
+ left: r * s.value
144
+ }));
145
+ })
146
+ };
147
+ }
148
+ function dt(o) {
149
+ const {
150
+ tracks: f,
151
+ tracksRef: s,
152
+ trackHeightPx: i,
153
+ trackGapPx: l,
154
+ pixelsPerMs: _,
155
+ disableInteraction: Z,
156
+ snap: h,
157
+ onDragStart: I,
158
+ onDrag: r,
159
+ onDragEnd: p
160
+ } = o, g = z(null), d = z(null), { detectTrackGap: ne, resolveTrackIndexFromClientY: _e } = rt(
161
+ s,
162
+ f,
163
+ i,
164
+ l
165
+ ), { snapGuides: le } = ut(
166
+ d,
167
+ f,
168
+ _
169
+ );
170
+ function re(v, q) {
171
+ Z.value || (g.value = {
172
+ layout: v,
173
+ initialX: q.clientX,
174
+ initialY: q.clientY,
175
+ moved: !1
176
+ });
177
+ }
178
+ function ue(v, q, X, $) {
179
+ const { layout: u, initialX: Me, initialY: Te } = v, de = q - Me, Y = X - Te, H = Math.abs(de) > 5 || Math.abs(Y) > 5;
180
+ if (!v.moved && H) {
181
+ v.moved = !0;
182
+ const R = {
183
+ segment: u.segment,
184
+ track: u.track,
185
+ trackIndex: u.trackIndex,
186
+ segmentIndex: u.segmentIndex,
187
+ startTime: u.segment.start,
188
+ endTime: u.segment.end,
189
+ targetTrackIndex: u.trackIndex,
190
+ targetTrackId: u.track.id,
191
+ isNewTrack: !1,
192
+ visualTrackIndex: u.trackIndex,
193
+ isValidTarget: !0,
194
+ mouseDeltaY: 0
195
+ };
196
+ I(R);
197
+ }
198
+ const W = u.segment.end - u.segment.start, A = u.segment.type || u.track.type, J = _e(X), w = J >= 0 ? J : u.trackIndex, O = f.value[w];
199
+ let x, Q, j, B = !1, ae, E = !0;
200
+ if (O && O.type === A) {
201
+ const R = ne(X);
202
+ R ? (B = !0, ae = R.insertIndex, x = R.insertIndex, Q = R.insertIndex, j = u.track.id, E = !0) : (x = w, Q = w, j = O.id, E = !0);
203
+ } else if (!s.value)
204
+ x = u.trackIndex, Q = w, j = u.track.id, E = !1;
205
+ else {
206
+ const R = s.value.getBoundingClientRect(), ce = X - R.top, me = i.value + l.value, ve = w * me + i.value / 2, fe = ce < ve;
207
+ B = !0, ae = fe ? w : w + 1, x = ae, Q = w, j = u.track.id, E = !0;
208
+ }
209
+ const we = h(u.segment.start + de / Math.max(_.value, 1e-4)), U = Math.max(0, we), ye = U + W, oe = {
210
+ segment: u.segment,
211
+ track: u.track,
212
+ trackIndex: u.trackIndex,
213
+ segmentIndex: u.segmentIndex,
214
+ startTime: U,
215
+ endTime: ye,
216
+ targetTrackIndex: x,
217
+ targetTrackId: j,
218
+ isNewTrack: B,
219
+ newTrackInsertIndex: ae,
220
+ visualTrackIndex: Q,
221
+ isValidTarget: E,
222
+ mouseDeltaY: Y
223
+ };
224
+ v.moved && (d.value = oe, $ === "drag" ? r(oe) : $ === "end" && p(oe));
225
+ }
226
+ function S(v) {
227
+ g.value && ue(g.value, v.clientX, v.clientY, "drag");
228
+ }
229
+ function T(v) {
230
+ g.value && (ue(g.value, v.clientX, v.clientY, "end"), g.value = null, d.value = null);
231
+ }
232
+ return {
233
+ // State
234
+ draggingState: g,
235
+ dragPreview: d,
236
+ snapGuides: le,
237
+ // Methods
238
+ startDrag: re,
239
+ handleDragMove: S,
240
+ handleDragEnd: T
241
+ };
242
+ }
243
+ const ct = { class: "ve-timeline" }, mt = { class: "ve-track__body" }, vt = ["onMousedown", "onClick"], ft = { class: "ve-segment__content" }, gt = { class: "ve-segment__title" }, ht = { class: "ve-segment__time" }, pt = {
244
+ key: 0,
245
+ class: "ve-segment__selection"
246
+ }, xt = ["onMousedown"], kt = ["onMousedown"], bt = { class: "ve-segment__content" }, _t = { class: "ve-segment__title" }, Mt = { class: "ve-segment__time" }, Tt = 120, Fe = 10, It = /* @__PURE__ */ ke({
247
+ name: "VideoTimeline",
248
+ __name: "index",
249
+ props: {
250
+ tracks: {},
251
+ currentTime: {},
252
+ duration: {},
253
+ zoom: {},
254
+ minZoom: { default: 0.25 },
255
+ maxZoom: { default: 10 },
256
+ snapStep: { default: 0 },
257
+ trackHeight: { default: 56 },
258
+ trackGap: { default: 8 },
259
+ rulerHeight: { default: 28 },
260
+ minSegmentDuration: { default: 60 },
261
+ selectedSegmentId: { default: null },
262
+ disableInteraction: { type: Boolean, default: !1 },
263
+ fps: { default: 30 }
264
+ },
265
+ emits: ["update:currentTime", "update:zoom", "segmentClick", "segmentDragStart", "segmentDrag", "segmentDragEnd", "segmentResizeStart", "segmentResize", "segmentResizeEnd", "backgroundClick"],
266
+ setup(o, { emit: f }) {
267
+ const s = o, i = f, l = z(null), _ = z(null), Z = z(null), h = z(0);
268
+ let I = null;
269
+ const r = z(B(s.zoom ?? s.minZoom)), p = z(!1);
270
+ he(() => s.zoom, (e) => {
271
+ typeof e == "number" && (r.value = B(e));
272
+ }), he(r, (e) => i("update:zoom", e));
273
+ const g = M(() => typeof s.duration == "number" ? Math.max(s.duration, 0) : Math.max(
274
+ 0,
275
+ ...s.tracks.flatMap(
276
+ (a) => a.segments.map((n) => n.end)
277
+ )
278
+ ));
279
+ he(g, (e, a) => {
280
+ if (!a || !e || a <= 0 || e <= 0 || !p.value || !h.value)
281
+ return;
282
+ const n = h.value * r.value / a;
283
+ if (!Number.isFinite(n) || n <= 0)
284
+ return;
285
+ const t = B(n * e / h.value);
286
+ Math.abs(t - r.value) > 1e-6 && (r.value = t);
287
+ });
288
+ const d = M(() => {
289
+ const e = Math.max(g.value, 1);
290
+ return Math.max(h.value, 1) * r.value / e;
291
+ }), ne = M(() => {
292
+ const e = g.value * d.value, a = Number.isFinite(e) ? Math.max(e, 0) : 0;
293
+ return Math.max(Math.ceil(a), Math.ceil(h.value || 0));
294
+ }), _e = M(() => {
295
+ const e = Math.max(d.value, 1e-4), n = (ne.value || h.value || 0) / e;
296
+ return Math.max(g.value, n);
297
+ }), le = M(() => s.currentTime * d.value), re = M(() => we(_e.value, d.value)), ue = M(() => 1e3 / Math.max(s.fps || 30, 1)), S = M(() => s.trackHeight), T = M(() => s.trackGap), v = M(() => s.rulerHeight), q = M(() => s.tracks.map((e, a) => ({
298
+ track: e,
299
+ trackIndex: a,
300
+ segments: e.segments.map((n, t) => {
301
+ const m = Math.max((n.end - n.start) * d.value, 6), C = n.start * d.value;
302
+ return {
303
+ track: e,
304
+ trackIndex: a,
305
+ segment: n,
306
+ segmentIndex: t,
307
+ left: C,
308
+ width: m,
309
+ isSelected: s.selectedSegmentId === n.id
310
+ };
311
+ })
312
+ }))), {
313
+ draggingState: X,
314
+ dragPreview: $,
315
+ snapGuides: u,
316
+ startDrag: Me,
317
+ handleDragMove: Te,
318
+ handleDragEnd: de
319
+ } = dt({
320
+ tracks: Ze(s, "tracks"),
321
+ tracksRef: Z,
322
+ trackHeightPx: S,
323
+ trackGapPx: T,
324
+ pixelsPerMs: d,
325
+ disableInteraction: Ze(s, "disableInteraction"),
326
+ snap: U,
327
+ onDragStart: (e) => {
328
+ i("segmentDragStart", e);
329
+ },
330
+ onDrag: (e) => {
331
+ i("segmentDrag", e);
332
+ },
333
+ onDragEnd: (e) => {
334
+ i("segmentDragEnd", e);
335
+ }
336
+ }), Y = z(null), H = M(() => $.value), W = M(() => Y.value), A = z(null), J = z(!1), w = z(!1), O = z(!1), x = M(() => {
337
+ if (!$.value)
338
+ return null;
339
+ const e = $.value, n = q.value.find((y) => y.track.id === e.track.id)?.segments.find((y) => y.segment.id === e.segment.id);
340
+ if (!n)
341
+ return null;
342
+ const t = (e.startTime - e.segment.start) * d.value, C = v.value + e.trackIndex * (S.value + T.value) + T.value + e.mouseDeltaY;
343
+ return {
344
+ ...n,
345
+ left: n.left + t,
346
+ top: C
347
+ };
348
+ }), Q = M(() => {
349
+ if (!$.value)
350
+ return 0;
351
+ const e = $.value;
352
+ return e.isNewTrack && e.newTrackInsertIndex === 0 ? v.value + T.value : v.value + e.targetTrackIndex * (S.value + T.value) + T.value;
353
+ });
354
+ Ve(() => {
355
+ l.value && (I = new ResizeObserver((e) => {
356
+ const a = e[0];
357
+ h.value = a?.contentRect.width || l.value?.clientWidth || 0;
358
+ }), I.observe(l.value), h.value = l.value.clientWidth || 0), window.addEventListener("mousemove", ve), window.addEventListener("mouseup", fe), ae();
359
+ }), Le(() => {
360
+ I?.disconnect(), I = null, window.removeEventListener("mousemove", ve), window.removeEventListener("mouseup", fe);
361
+ }), he(r, () => {
362
+ j();
363
+ });
364
+ function j() {
365
+ const e = l.value;
366
+ if (!e)
367
+ return;
368
+ const a = e.clientWidth / 2, n = s.currentTime * d.value - a;
369
+ e.scrollLeft = Math.max(0, n);
370
+ }
371
+ function B(e) {
372
+ return Number.isFinite(e) ? Math.min(Math.max(e, s.minZoom), s.maxZoom) : s.minZoom;
373
+ }
374
+ function ae() {
375
+ if (p.value)
376
+ return;
377
+ if (s.zoom !== void 0) {
378
+ p.value = !0;
379
+ return;
380
+ }
381
+ if (!h.value || g.value <= 0)
382
+ return;
383
+ const e = B(1 / 3);
384
+ r.value = e, p.value = !0;
385
+ }
386
+ function E(e) {
387
+ const a = Math.max(e, 0), n = Math.floor(a / 1e3), t = Math.floor(n / 60).toString().padStart(2, "0"), m = (n % 60).toString().padStart(2, "0"), C = Math.floor(a % 1e3 / 10).toString().padStart(2, "0");
388
+ return `${t}:${m}.${C}`;
389
+ }
390
+ function Ie(e) {
391
+ const a = Math.max(e, 0), n = Math.floor(a / 1e3), t = Math.floor(n / 60).toString().padStart(2, "0"), m = (n % 60).toString().padStart(2, "0");
392
+ return `${t}:${m}`;
393
+ }
394
+ function we(e, a) {
395
+ if (!e || !a)
396
+ return [];
397
+ const n = Xe(a, s.fps || 30), t = Math.max(1, Math.round(n.mainMs / n.minorMs)), m = Math.max(e, 1), C = Math.ceil(m / n.minorMs), y = [];
398
+ for (let F = 0; F <= C; F += 1) {
399
+ const P = Math.min(m, F * n.minorMs), G = P * a, N = F % t === 0;
400
+ y.push({
401
+ position: G,
402
+ timeMs: P,
403
+ isMajor: N,
404
+ label: N ? Ge(P, s.fps || 30, n) : void 0
405
+ });
406
+ }
407
+ return y;
408
+ }
409
+ function U(e) {
410
+ const a = s.snapStep, n = a && a > 0 ? a : ue.value;
411
+ return Math.max(Math.round(e / n) * n, 0);
412
+ }
413
+ function ye(e) {
414
+ if (!_.value)
415
+ return;
416
+ if (O.value) {
417
+ O.value = !1;
418
+ return;
419
+ }
420
+ const a = _.value.getBoundingClientRect(), n = e.clientX - a.left, t = U(n / Math.max(d.value, 1e-4));
421
+ i("update:currentTime", t), i("backgroundClick", e), w.value = !0;
422
+ }
423
+ function oe(e) {
424
+ s.disableInteraction || (e.preventDefault(), J.value = !0, w.value = !0, R(e.clientX), j());
425
+ }
426
+ function R(e) {
427
+ if (!_.value)
428
+ return;
429
+ const a = _.value.getBoundingClientRect(), n = e - a.left, t = U(n / Math.max(d.value, 1e-4));
430
+ i("update:currentTime", t);
431
+ }
432
+ function ce(e, a, n) {
433
+ if (s.disableInteraction)
434
+ return;
435
+ n.stopPropagation(), n.preventDefault(), A.value = {
436
+ layout: e,
437
+ edge: a,
438
+ initialX: n.clientX
439
+ };
440
+ const t = {
441
+ segment: e.segment,
442
+ track: e.track,
443
+ trackIndex: e.trackIndex,
444
+ segmentIndex: e.segmentIndex,
445
+ startTime: e.segment.start,
446
+ endTime: e.segment.end,
447
+ edge: a
448
+ };
449
+ Y.value = t, i("segmentResizeStart", t);
450
+ }
451
+ function me(e, a, n) {
452
+ const { layout: t, edge: m, initialX: C } = e, F = (a - C) / Math.max(d.value, 1e-4), P = Math.max(s.minSegmentDuration, 10);
453
+ let G = t.segment.start, N = t.segment.end;
454
+ if (m === "start")
455
+ G = U(Math.max(0, t.segment.start + F)), t.segment.end - G < P && (G = t.segment.end - P);
456
+ else {
457
+ N = U(Math.max(t.segment.start + P, t.segment.end + F));
458
+ const { sourceDurationMs: ee, fromTime: ge } = t.segment;
459
+ if (typeof ee == "number" && Number.isFinite(ee) && ee > 0 && typeof ge == "number" && Number.isFinite(ge) && ge >= 0) {
460
+ const Ne = Math.max(0, ee - ge), Re = G + Ne;
461
+ N > Re && (N = Re);
462
+ }
463
+ }
464
+ const se = {
465
+ segment: t.segment,
466
+ track: t.track,
467
+ trackIndex: t.trackIndex,
468
+ segmentIndex: t.segmentIndex,
469
+ startTime: G,
470
+ endTime: N,
471
+ edge: m
472
+ };
473
+ Y.value = se, n === "drag" ? i("segmentResize", se) : n === "end" && i("segmentResizeEnd", se);
474
+ }
475
+ function Se(e, a) {
476
+ X.value?.layout.segment.id === e.segment.id && X.value.moved || i("segmentClick", e, a);
477
+ }
478
+ function ve(e) {
479
+ if (J.value) {
480
+ R(e.clientX);
481
+ return;
482
+ }
483
+ if (A.value) {
484
+ me(A.value, e.clientX, "drag");
485
+ return;
486
+ }
487
+ Te(e);
488
+ }
489
+ function fe(e) {
490
+ if (J.value) {
491
+ J.value = !1, w.value = !1, R(e.clientX), O.value = !0;
492
+ return;
493
+ }
494
+ if (A.value) {
495
+ me(A.value, e.clientX, "end"), A.value = null, Y.value = null, w.value = !1, O.value = !0;
496
+ return;
497
+ }
498
+ if (X.value)
499
+ if (X.value.moved)
500
+ O.value = !0;
501
+ else {
502
+ const { layout: a } = X.value;
503
+ Se(a, e);
504
+ }
505
+ de(e), w.value = !1;
506
+ }
507
+ function ze() {
508
+ r.value = B(r.value * 1.25);
509
+ }
510
+ function Ee() {
511
+ r.value = B(r.value / 1.25);
512
+ }
513
+ function Xe(e, a) {
514
+ const t = 1e3 / (Number.isFinite(a) && a > 0 ? a : 30), m = e * t, C = Be(t), y = Pe(t), F = m >= Fe ? [...y, ...C] : C;
515
+ let P = null, G = 1 / 0;
516
+ for (const N of F) {
517
+ const se = N.mainMs * e;
518
+ if (se < Fe)
519
+ continue;
520
+ const ee = Math.abs(se - Tt);
521
+ ee < G && (P = N, G = ee);
522
+ }
523
+ return P || F[F.length - 1] || y[y.length - 1];
524
+ }
525
+ function Be(e) {
526
+ return [600, 300, 180, 120, 60, 30, 20, 15, 10, 5, 3, 2, 1].map((n) => {
527
+ const t = n * 1e3;
528
+ return {
529
+ mainMs: t,
530
+ minorMs: Math.max(t / 10, e),
531
+ mode: "time",
532
+ label: "time"
533
+ };
534
+ });
535
+ }
536
+ function Pe(e) {
537
+ return [
538
+ {
539
+ mainMs: Math.max(e * 2, 1),
540
+ minorMs: Math.max(e, 1),
541
+ mode: "frame",
542
+ label: "frame"
543
+ },
544
+ {
545
+ mainMs: Math.max(e * 10, 1),
546
+ minorMs: Math.max(e * 2, 1),
547
+ mode: "frame",
548
+ label: "frame"
549
+ },
550
+ {
551
+ mainMs: 1e3,
552
+ minorMs: Math.max(e * 10, 1),
553
+ mode: "frame",
554
+ label: "frame"
555
+ }
556
+ ];
557
+ }
558
+ function Ge(e, a, n) {
559
+ if (n.label === "frame") {
560
+ const t = Number.isFinite(a) && a > 0 ? a : 30, m = 1e3 / t, y = Math.round(e / m) % t;
561
+ return y === 0 ? Ie(e) : `${y}f`;
562
+ }
563
+ return Ie(e);
564
+ }
565
+ return (e, a) => (b(), k("div", ct, [
566
+ L(e.$slots, "toolbar", {
567
+ zoom: r.value,
568
+ canZoomIn: r.value < o.maxZoom,
569
+ canZoomOut: r.value > o.minZoom,
570
+ zoomIn: ze,
571
+ zoomOut: Ee,
572
+ currentTime: o.currentTime,
573
+ duration: g.value,
574
+ formatTime: E
575
+ }, () => [
576
+ $e(lt, {
577
+ zoom: r.value,
578
+ "min-zoom": o.minZoom,
579
+ "max-zoom": o.maxZoom,
580
+ "current-time": o.currentTime,
581
+ duration: g.value,
582
+ "format-time": E,
583
+ onZoomIn: ze,
584
+ onZoomOut: Ee
585
+ }, null, 8, ["zoom", "min-zoom", "max-zoom", "current-time", "duration"])
586
+ ], !0),
587
+ c("div", {
588
+ ref_key: "viewportRef",
589
+ ref: l,
590
+ class: "ve-timeline__viewport",
591
+ onClick: ye
592
+ }, [
593
+ c("div", {
594
+ ref_key: "contentRef",
595
+ ref: _,
596
+ class: "ve-timeline__content",
597
+ style: D({ width: `${ne.value}px` })
598
+ }, [
599
+ L(e.$slots, "ruler", {
600
+ ticks: re.value,
601
+ pixelsPerMs: d.value
602
+ }, () => [
603
+ $e(qe, {
604
+ ticks: re.value,
605
+ style: D({ height: `${v.value}px` })
606
+ }, null, 8, ["ticks", "style"])
607
+ ], !0),
608
+ L(e.$slots, "playhead", {
609
+ left: le.value,
610
+ currentTime: o.currentTime
611
+ }, () => [
612
+ $e(We, {
613
+ class: "top-0",
614
+ left: le.value,
615
+ onDragStart: oe
616
+ }, null, 8, ["left"])
617
+ ], !0),
618
+ c("div", {
619
+ ref_key: "tracksRef",
620
+ ref: Z,
621
+ class: "ve-timeline__tracks",
622
+ style: D({ gap: `${T.value}px`, paddingTop: `${T.value}px` })
623
+ }, [
624
+ (b(!0), k(pe, null, xe(q.value, (n) => (b(), k("div", {
625
+ key: n.track.id,
626
+ class: De(["ve-track", { "ve-track--main": n.track.isMain }]),
627
+ style: D({ height: `${S.value}px` })
628
+ }, [
629
+ L(e.$slots, "track", {
630
+ track: n.track,
631
+ index: n.trackIndex,
632
+ segments: n.segments,
633
+ pixelsPerMs: d.value,
634
+ height: S.value
635
+ }, () => [
636
+ c("div", mt, [
637
+ (b(!0), k(pe, null, xe(n.segments, (t) => Oe((b(), k("div", {
638
+ key: t.segment.id,
639
+ class: De(["ve-segment", {
640
+ "ve-segment--selected": t.isSelected
641
+ }]),
642
+ style: D({
643
+ left: `${t.left}px`,
644
+ width: `${t.width}px`,
645
+ backgroundColor: t.segment.color || n.track.color || "var(--ve-primary)"
646
+ }),
647
+ onMousedown: ie((m) => K(Me)(t, m), ["prevent", "stop"]),
648
+ onClick: ie((m) => Se(t, m), ["stop"])
649
+ }, [
650
+ L(e.$slots, "segment", {
651
+ layout: t,
652
+ segment: t.segment,
653
+ track: t.track,
654
+ isSelected: t.isSelected
655
+ }, () => [
656
+ c("div", ft, [
657
+ c("div", gt, V(t.segment.type || "segment"), 1),
658
+ c("div", ht, V(E(t.segment.start)) + " - " + V(E(t.segment.end)), 1)
659
+ ])
660
+ ], !0),
661
+ t.isSelected ? (b(), k("div", pt, [
662
+ c("div", {
663
+ class: "ve-segment__handle ve-segment__handle--left",
664
+ onMousedown: ie((m) => ce(t, "start", m), ["stop"])
665
+ }, [...a[0] || (a[0] = [
666
+ Ce('<div class="ve-segment__handle-dots" data-v-70b46d01><div class="ve-segment__handle-dot" data-v-70b46d01></div><div class="ve-segment__handle-dot" data-v-70b46d01></div><div class="ve-segment__handle-dot" data-v-70b46d01></div><div class="ve-segment__handle-dot" data-v-70b46d01></div></div>', 1)
667
+ ])], 40, xt),
668
+ c("div", {
669
+ class: "ve-segment__handle ve-segment__handle--right",
670
+ onMousedown: ie((m) => ce(t, "end", m), ["stop"])
671
+ }, [...a[1] || (a[1] = [
672
+ Ce('<div class="ve-segment__handle-dots" data-v-70b46d01><div class="ve-segment__handle-dot" data-v-70b46d01></div><div class="ve-segment__handle-dot" data-v-70b46d01></div><div class="ve-segment__handle-dot" data-v-70b46d01></div><div class="ve-segment__handle-dot" data-v-70b46d01></div></div>', 1)
673
+ ])], 40, kt)
674
+ ])) : te("", !0)
675
+ ], 46, vt)), [
676
+ [Ye, K($)?.segment.id !== t.segment.id && Y.value?.segment.id !== t.segment.id]
677
+ ])), 128))
678
+ ])
679
+ ], !0)
680
+ ], 6))), 128))
681
+ ], 4),
682
+ x.value ? (b(), k("div", {
683
+ key: 0,
684
+ class: "ve-segment ve-segment--dragging",
685
+ style: D({
686
+ left: `${x.value.left}px`,
687
+ width: `${x.value.width}px`,
688
+ top: `${x.value.top}px`,
689
+ height: `${S.value}px`,
690
+ backgroundColor: x.value.segment.color || "var(--ve-primary)"
691
+ })
692
+ }, [
693
+ L(e.$slots, "segment", {
694
+ layout: x.value,
695
+ segment: x.value.segment,
696
+ track: x.value.track,
697
+ isSelected: x.value.isSelected
698
+ }, () => [
699
+ c("div", bt, [
700
+ c("div", _t, V(x.value.segment.type || "segment"), 1),
701
+ c("div", Mt, V(E(x.value.segment.start)) + " - " + V(E(x.value.segment.end)), 1)
702
+ ])
703
+ ], !0)
704
+ ], 4)) : te("", !0),
705
+ H.value && !H.value.isNewTrack ? (b(), k("div", {
706
+ key: 1,
707
+ class: "ve-segment ve-segment--placeholder",
708
+ style: D({
709
+ left: `${H.value.startTime * d.value}px`,
710
+ width: `${(H.value.endTime - H.value.startTime) * d.value}px`,
711
+ top: `${Q.value}px`,
712
+ height: `${S.value}px`
713
+ })
714
+ }, [
715
+ c("div", {
716
+ class: "ve-segment--placeholder-inner",
717
+ style: D({
718
+ backgroundColor: H.value.segment.color || "var(--ve-primary)"
719
+ })
720
+ }, null, 4)
721
+ ], 4)) : te("", !0),
722
+ W.value ? (b(), k("div", {
723
+ key: 2,
724
+ class: "ve-segment ve-segment--preview",
725
+ style: D({
726
+ left: `${W.value.startTime * d.value}px`,
727
+ width: `${(W.value.endTime - W.value.startTime) * d.value}px`,
728
+ top: `${v.value + W.value.trackIndex * (S.value + T.value) + T.value}px`,
729
+ height: `${S.value}px`,
730
+ backgroundColor: W.value.segment.color || "var(--ve-primary)"
731
+ })
732
+ }, null, 4)) : te("", !0),
733
+ K($) && K(u).length ? (b(!0), k(pe, { key: 3 }, xe(K(u), (n) => (b(), k("div", {
734
+ key: `snap-${n.time}`,
735
+ class: "ve-snap-guide",
736
+ style: D({
737
+ left: `${n.left}px`,
738
+ top: `${v.value}px`,
739
+ height: `calc(100% - ${v.value}px)`
740
+ })
741
+ }, null, 4))), 128)) : te("", !0),
742
+ K($) && K($).isNewTrack ? (b(), k("div", {
743
+ key: 4,
744
+ class: "ve-new-track-line",
745
+ style: D({
746
+ top: `${v.value + K($).targetTrackIndex * (S.value + T.value)}px`,
747
+ left: "0",
748
+ right: "0"
749
+ })
750
+ }, null, 4)) : te("", !0)
751
+ ], 4)
752
+ ], 512)
753
+ ]));
754
+ }
755
+ }), yt = /* @__PURE__ */ be(It, [["__scopeId", "data-v-70b46d01"]]);
756
+ export {
757
+ yt as V,
758
+ be as _
759
+ };