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