vue3-time-playbar 0.1.3 → 0.1.4

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,4 +1,5 @@
1
1
  import { TickLabelMode, FormatTooltipFn } from './types';
2
+ /***********************Props 与事件*********************/
2
3
  type __VLS_Props = {
3
4
  modelValue: number | string;
4
5
  startTime: number | string;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,5 @@
1
1
  import { TimeInput, TickLabelMode, FormatTooltipFn, TimeChangePayload } from './types';
2
+ /***********************Props 与事件*********************/
2
3
  interface Props {
3
4
  modelValue?: TimeInput;
4
5
  startTime: TimeInput;
@@ -14,6 +15,7 @@ interface Props {
14
15
  tickLabelMode?: TickLabelMode;
15
16
  formatTooltip?: FormatTooltipFn;
16
17
  }
18
+ /***********************播放控制*********************/
17
19
  declare function togglePlay(): void;
18
20
  declare function play(): void;
19
21
  declare function pause(): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue3-time-playbar",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A Vue 3 time player component with interactive timeline, playback controls and tick marks",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/style.css CHANGED
@@ -1 +1 @@
1
- .player-controls[data-v-55e12a8d]{display:flex;align-items:center}.player-controls .btn-group[data-v-55e12a8d]{display:flex;align-items:center;gap:6px}.player-controls .control-btn[data-v-55e12a8d]{background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:50%;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#fffc;cursor:pointer;transition:background .2s,border-color .2s,transform .15s}.player-controls .control-btn[data-v-55e12a8d]:hover{background:#fff3;border-color:#fff6;color:#fff;transform:scale(1.08)}.player-controls .control-btn[data-v-55e12a8d]:active{transform:scale(.95)}.player-controls .control-btn svg[data-v-55e12a8d]{width:14px;height:14px}.player-controls .control-btn.play-btn[data-v-55e12a8d]{width:40px;height:40px;background:#409eff;border-color:transparent;color:#fff}.player-controls .control-btn.play-btn[data-v-55e12a8d]:hover{background:#66b1ff}.player-controls .control-btn.play-btn svg[data-v-55e12a8d]{width:16px;height:16px}.time-timeline[data-v-d7d9fd3b]{position:relative;width:100%;height:52px;cursor:pointer}.time-timeline .handle-group[data-v-d7d9fd3b]{position:absolute;left:0;top:0;width:0;height:100%;z-index:20;pointer-events:none;transition:transform .2s ease-out;will-change:transform}.time-timeline .handle-group.dragging[data-v-d7d9fd3b]{transition:none}.time-timeline .handle-group .floating-tooltip[data-v-d7d9fd3b]{position:absolute;top:-33px;left:0;transform:translate(-50%);background:#409eff;color:#fff;padding:5px 10px;border-radius:50px;font-size:14px;font-weight:500;white-space:nowrap;box-shadow:0 2px 6px #0000004d;pointer-events:auto;cursor:grab}.time-timeline .handle-group .floating-tooltip[data-v-d7d9fd3b]:active{cursor:grabbing}.time-timeline .handle-group .floating-tooltip[data-v-d7d9fd3b]:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#409eff}.time-timeline .handle-group .handle-visual[data-v-d7d9fd3b]{position:absolute;top:10px;left:0;transform:translate(-50%,-50%);width:8px;height:8px;background:#fff;border-radius:50%;border:2px solid #409eff;box-shadow:0 0 0 3px #409eff40}.time-timeline .scroll-container[data-v-d7d9fd3b]{width:100%;height:100%;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.time-timeline .scroll-container[data-v-d7d9fd3b]::-webkit-scrollbar{display:none}.time-timeline .timeline-inner[data-v-d7d9fd3b]{position:relative;min-width:100%;height:100%}.time-timeline .track-bg[data-v-d7d9fd3b]{position:absolute;top:8px;height:4px;background:#ffffff2e;border-radius:2px}.time-timeline .track-active[data-v-d7d9fd3b]{position:absolute;top:8px;height:4px;background:#409eff;border-radius:2px;pointer-events:none;transition:width .15s ease-out;z-index:2}.time-timeline .ticks-container[data-v-d7d9fd3b]{position:absolute;top:0;bottom:0;pointer-events:none}.time-timeline .tick-item[data-v-d7d9fd3b]{position:absolute;top:0;transform:translate(-50%);display:flex;flex-direction:column;align-items:center}.time-timeline .tick-item .tick-mark[data-v-d7d9fd3b]{margin-top:14px;width:1px;height:5px;background:#ffffff59;flex-shrink:0}.time-timeline .tick-item .tick-label[data-v-d7d9fd3b]{margin-top:2px;font-size:11px;color:#fff9;line-height:1}.time-timeline .tick-item .day-label[data-v-d7d9fd3b]{margin-top:3px;font-size:11px;font-weight:600;color:#ffffffe6;white-space:nowrap;line-height:1}.time-timeline .tick-item.is-day-boundary .tick-mark[data-v-d7d9fd3b]{margin-top:14px;width:2px;height:18px;background:#fffc}.speed-selector[data-v-30c5e152]{flex-shrink:0;margin-left:10px;padding-left:10px;border-left:1px solid rgba(255,255,255,.12);position:relative}.speed-selector .speed-trigger[data-v-30c5e152]{display:inline-flex;align-items:center;gap:4px;min-width:36px;height:28px;padding:0 8px;background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:4px;color:#fffc;font-size:13px;font-weight:500;cursor:pointer;transition:background .2s,border-color .2s,color .2s}.speed-selector .speed-trigger[data-v-30c5e152]:hover{background:#fff3;border-color:#fff6;color:#fff}.speed-selector .speed-trigger .arrow-icon[data-v-30c5e152]{width:10px;height:10px;transition:transform .2s}.speed-selector .speed-trigger .arrow-icon.open[data-v-30c5e152]{transform:rotate(180deg)}.speed-selector .speed-dropdown[data-v-30c5e152]{position:absolute;left:16px;min-width:56px;background:#083082f2;border:1px solid rgba(255,255,255,.2);border-radius:4px;padding:4px 0;box-shadow:0 4px 12px #0006;z-index:30}.speed-selector .speed-dropdown.is-up[data-v-30c5e152]{bottom:calc(100% + 6px)}.speed-selector .speed-dropdown.is-down[data-v-30c5e152]{top:calc(100% + 6px)}.speed-selector .speed-dropdown .speed-option[data-v-30c5e152]{padding:6px 12px;font-size:13px;color:#ffffffb3;cursor:pointer;text-align:center;transition:background .15s,color .15s}.speed-selector .speed-dropdown .speed-option[data-v-30c5e152]:hover{background:#ffffff26;color:#fff}.speed-selector .speed-dropdown .speed-option.active[data-v-30c5e152]{color:#409eff;font-weight:600}.dropdown-up-enter-active[data-v-30c5e152],.dropdown-up-leave-active[data-v-30c5e152]{transition:opacity .15s,transform .15s}.dropdown-up-enter-from[data-v-30c5e152],.dropdown-up-leave-to[data-v-30c5e152]{opacity:0;transform:translateY(4px)}.dropdown-down-enter-active[data-v-30c5e152],.dropdown-down-leave-active[data-v-30c5e152]{transition:opacity .15s,transform .15s}.dropdown-down-enter-from[data-v-30c5e152],.dropdown-down-leave-to[data-v-30c5e152]{opacity:0;transform:translateY(-4px)}.g-time-player[data-v-98cef505]{display:flex;align-items:center;width:100%;height:72px;filter:drop-shadow(rgba(0,0,0,.8) 0px 0px 2px);background:#083082aa;box-shadow:0 0 16px #0193fa99 inset;border-radius:4px;padding:0 24px;box-sizing:border-box;color:#fff;-webkit-user-select:none;user-select:none;box-shadow:0 4px 20px #00000059}.g-time-player .controls-wrapper[data-v-98cef505]{flex-shrink:0;margin-right:10px;border-right:1px solid rgba(255,255,255,.12);padding-right:10px}.g-time-player .timeline-wrapper[data-v-98cef505]{flex:1;min-width:0;height:100%;display:flex;align-items:center;overflow:visible;position:relative}
1
+ .player-controls[data-v-55e12a8d]{display:flex;align-items:center}.player-controls .btn-group[data-v-55e12a8d]{display:flex;align-items:center;gap:6px}.player-controls .control-btn[data-v-55e12a8d]{background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:50%;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#fffc;cursor:pointer;transition:background .2s,border-color .2s,transform .15s}.player-controls .control-btn[data-v-55e12a8d]:hover{background:#fff3;border-color:#fff6;color:#fff;transform:scale(1.08)}.player-controls .control-btn[data-v-55e12a8d]:active{transform:scale(.95)}.player-controls .control-btn svg[data-v-55e12a8d]{width:14px;height:14px}.player-controls .control-btn.play-btn[data-v-55e12a8d]{width:40px;height:40px;background:#409eff;border-color:transparent;color:#fff}.player-controls .control-btn.play-btn[data-v-55e12a8d]:hover{background:#66b1ff}.player-controls .control-btn.play-btn svg[data-v-55e12a8d]{width:16px;height:16px}.time-timeline[data-v-0f78dcee]{position:relative;width:100%;height:52px;cursor:pointer}.time-timeline .handle-group[data-v-0f78dcee]{position:absolute;left:0;top:0;width:0;height:100%;z-index:20;pointer-events:none;transition:transform .2s ease-out;will-change:transform}.time-timeline .handle-group.dragging[data-v-0f78dcee]{transition:none}.time-timeline .handle-group .floating-tooltip[data-v-0f78dcee]{position:absolute;top:-33px;left:0;transform:translate(-50%);background:#409eff;color:#fff;padding:5px 10px;border-radius:50px;font-size:14px;font-weight:500;white-space:nowrap;box-shadow:0 2px 6px #0000004d;pointer-events:auto;cursor:grab}.time-timeline .handle-group .floating-tooltip[data-v-0f78dcee]:active{cursor:grabbing}.time-timeline .handle-group .floating-tooltip[data-v-0f78dcee]:after{content:"";position:absolute;top:100%;left:50%;transform:translate(-50%);border:4px solid transparent;border-top-color:#409eff}.time-timeline .handle-group .handle-visual[data-v-0f78dcee]{position:absolute;top:10px;left:0;transform:translate(-50%,-50%);width:8px;height:8px;background:#fff;border-radius:50%;border:2px solid #409eff;box-shadow:0 0 0 3px #409eff40}.time-timeline .scroll-container[data-v-0f78dcee]{width:100%;height:100%;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}.time-timeline .scroll-container[data-v-0f78dcee]::-webkit-scrollbar{display:none}.time-timeline .timeline-inner[data-v-0f78dcee]{position:relative;min-width:100%;height:100%}.time-timeline .track-bg[data-v-0f78dcee]{position:absolute;top:8px;height:4px;background:#ffffff2e;border-radius:2px}.time-timeline .track-active[data-v-0f78dcee]{position:absolute;top:8px;height:4px;background:#409eff;border-radius:2px;pointer-events:none;transition:width .15s ease-out;z-index:2}.time-timeline .ticks-container[data-v-0f78dcee]{position:absolute;top:0;bottom:0;pointer-events:none}.time-timeline .tick-item[data-v-0f78dcee]{position:absolute;top:0;transform:translate(-50%);display:flex;flex-direction:column;align-items:center}.time-timeline .tick-item .tick-mark[data-v-0f78dcee]{margin-top:14px;width:1px;height:5px;background:#ffffff59;flex-shrink:0}.time-timeline .tick-item .tick-label[data-v-0f78dcee]{margin-top:2px;font-size:11px;color:#fff9;line-height:1}.time-timeline .tick-item .day-label[data-v-0f78dcee]{margin-top:3px;font-size:11px;font-weight:600;color:#ffffffe6;white-space:nowrap;line-height:1}.time-timeline .tick-item.is-day-boundary .tick-mark[data-v-0f78dcee]{margin-top:14px;width:2px;height:18px;background:#fffc}.speed-selector[data-v-30c5e152]{flex-shrink:0;margin-left:10px;padding-left:10px;border-left:1px solid rgba(255,255,255,.12);position:relative}.speed-selector .speed-trigger[data-v-30c5e152]{display:inline-flex;align-items:center;gap:4px;min-width:36px;height:28px;padding:0 8px;background:#ffffff1a;border:1px solid rgba(255,255,255,.15);border-radius:4px;color:#fffc;font-size:13px;font-weight:500;cursor:pointer;transition:background .2s,border-color .2s,color .2s}.speed-selector .speed-trigger[data-v-30c5e152]:hover{background:#fff3;border-color:#fff6;color:#fff}.speed-selector .speed-trigger .arrow-icon[data-v-30c5e152]{width:10px;height:10px;transition:transform .2s}.speed-selector .speed-trigger .arrow-icon.open[data-v-30c5e152]{transform:rotate(180deg)}.speed-selector .speed-dropdown[data-v-30c5e152]{position:absolute;left:16px;min-width:56px;background:#083082f2;border:1px solid rgba(255,255,255,.2);border-radius:4px;padding:4px 0;box-shadow:0 4px 12px #0006;z-index:30}.speed-selector .speed-dropdown.is-up[data-v-30c5e152]{bottom:calc(100% + 6px)}.speed-selector .speed-dropdown.is-down[data-v-30c5e152]{top:calc(100% + 6px)}.speed-selector .speed-dropdown .speed-option[data-v-30c5e152]{padding:6px 12px;font-size:13px;color:#ffffffb3;cursor:pointer;text-align:center;transition:background .15s,color .15s}.speed-selector .speed-dropdown .speed-option[data-v-30c5e152]:hover{background:#ffffff26;color:#fff}.speed-selector .speed-dropdown .speed-option.active[data-v-30c5e152]{color:#409eff;font-weight:600}.dropdown-up-enter-active[data-v-30c5e152],.dropdown-up-leave-active[data-v-30c5e152]{transition:opacity .15s,transform .15s}.dropdown-up-enter-from[data-v-30c5e152],.dropdown-up-leave-to[data-v-30c5e152]{opacity:0;transform:translateY(4px)}.dropdown-down-enter-active[data-v-30c5e152],.dropdown-down-leave-active[data-v-30c5e152]{transition:opacity .15s,transform .15s}.dropdown-down-enter-from[data-v-30c5e152],.dropdown-down-leave-to[data-v-30c5e152]{opacity:0;transform:translateY(-4px)}.g-time-player[data-v-55b5dfa2]{display:flex;align-items:center;width:100%;height:72px;filter:drop-shadow(rgba(0,0,0,.8) 0px 0px 2px);background:#083082aa;box-shadow:0 0 16px #0193fa99 inset;border-radius:4px;padding:0 24px;box-sizing:border-box;color:#fff;-webkit-user-select:none;user-select:none;box-shadow:0 4px 20px #00000059}.g-time-player .controls-wrapper[data-v-55b5dfa2]{flex-shrink:0;margin-right:10px;border-right:1px solid rgba(255,255,255,.12);padding-right:10px}.g-time-player .timeline-wrapper[data-v-55b5dfa2]{flex:1;min-width:0;height:100%;display:flex;align-items:center;overflow:visible;position:relative}
@@ -1,30 +1,30 @@
1
- import { defineComponent as ne, openBlock as T, createElementBlock as x, createElementVNode as c, renderSlot as F, ref as $, computed as v, watch as _, onMounted as ge, nextTick as ce, onUnmounted as fe, withDirectives as Pe, normalizeStyle as A, normalizeClass as j, withModifiers as de, toDisplayString as z, vShow as Ee, Fragment as ye, renderList as he, createCommentVNode as ve, createVNode as ee, Transition as Ie, withCtx as te, createSlots as Re } from "vue";
2
- const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["title"], Ne = {
1
+ import { defineComponent as ne, openBlock as b, createElementBlock as $, createElementVNode as u, renderSlot as X, useTemplateRef as fe, ref as V, computed as f, watch as B, onMounted as Te, nextTick as me, onUnmounted as ye, withDirectives as Ie, normalizeStyle as W, normalizeClass as U, withModifiers as pe, toDisplayString as j, vShow as _e, Fragment as xe, renderList as we, createCommentVNode as ge, createVNode as ee, Transition as Be, withCtx as te, createSlots as He } from "vue";
2
+ const Ne = { class: "player-controls" }, Ae = { class: "btn-group" }, We = ["title"], Fe = {
3
3
  key: 0,
4
4
  viewBox: "0 0 24 24",
5
5
  fill: "currentColor",
6
6
  stroke: "none"
7
- }, Ae = {
7
+ }, Xe = {
8
8
  key: 1,
9
9
  viewBox: "0 0 24 24",
10
10
  fill: "currentColor",
11
11
  stroke: "none"
12
- }, We = /* @__PURE__ */ ne({
12
+ }, ze = /* @__PURE__ */ ne({
13
13
  __name: "PlayerControls",
14
14
  props: {
15
15
  isPlaying: { type: Boolean }
16
16
  },
17
17
  emits: ["toggle-play", "prev", "next"],
18
18
  setup(e) {
19
- return (n, a) => (T(), x("div", _e, [
20
- c("div", Be, [
21
- c("button", {
19
+ return (n, a) => (b(), $("div", Ne, [
20
+ u("div", Ae, [
21
+ u("button", {
22
22
  class: "control-btn",
23
23
  onClick: a[0] || (a[0] = (t) => n.$emit("prev")),
24
24
  title: "上一时刻"
25
25
  }, [
26
- F(n.$slots, "prev", {}, () => [
27
- a[3] || (a[3] = c("svg", {
26
+ X(n.$slots, "prev", {}, () => [
27
+ a[3] || (a[3] = u("svg", {
28
28
  viewBox: "0 0 24 24",
29
29
  fill: "none",
30
30
  stroke: "currentColor",
@@ -32,8 +32,8 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
32
32
  "stroke-linecap": "round",
33
33
  "stroke-linejoin": "round"
34
34
  }, [
35
- c("polygon", { points: "19 20 9 12 19 4 19 20" }),
36
- c("line", {
35
+ u("polygon", { points: "19 20 9 12 19 4 19 20" }),
36
+ u("line", {
37
37
  x1: "5",
38
38
  y1: "19",
39
39
  x2: "5",
@@ -42,39 +42,39 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
42
42
  ], -1))
43
43
  ], !0)
44
44
  ]),
45
- c("button", {
45
+ u("button", {
46
46
  class: "control-btn play-btn",
47
47
  onClick: a[1] || (a[1] = (t) => n.$emit("toggle-play")),
48
48
  title: e.isPlaying ? "暂停" : "播放"
49
49
  }, [
50
- F(n.$slots, "play", { isPlaying: e.isPlaying }, () => [
51
- e.isPlaying ? (T(), x("svg", Ae, [...a[5] || (a[5] = [
52
- c("rect", {
50
+ X(n.$slots, "play", { isPlaying: e.isPlaying }, () => [
51
+ e.isPlaying ? (b(), $("svg", Xe, [...a[5] || (a[5] = [
52
+ u("rect", {
53
53
  x: "6",
54
54
  y: "4",
55
55
  width: "4",
56
56
  height: "16",
57
57
  rx: "1"
58
58
  }, null, -1),
59
- c("rect", {
59
+ u("rect", {
60
60
  x: "14",
61
61
  y: "4",
62
62
  width: "4",
63
63
  height: "16",
64
64
  rx: "1"
65
65
  }, null, -1)
66
- ])])) : (T(), x("svg", Ne, [...a[4] || (a[4] = [
67
- c("polygon", { points: "5 3 19 12 5 21 5 3" }, null, -1)
66
+ ])])) : (b(), $("svg", Fe, [...a[4] || (a[4] = [
67
+ u("polygon", { points: "5 3 19 12 5 21 5 3" }, null, -1)
68
68
  ])]))
69
69
  ], !0)
70
- ], 8, He),
71
- c("button", {
70
+ ], 8, We),
71
+ u("button", {
72
72
  class: "control-btn",
73
73
  onClick: a[2] || (a[2] = (t) => n.$emit("next")),
74
74
  title: "下一时刻"
75
75
  }, [
76
- F(n.$slots, "next", {}, () => [
77
- a[6] || (a[6] = c("svg", {
76
+ X(n.$slots, "next", {}, () => [
77
+ a[6] || (a[6] = u("svg", {
78
78
  viewBox: "0 0 24 24",
79
79
  fill: "none",
80
80
  stroke: "currentColor",
@@ -82,8 +82,8 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
82
82
  "stroke-linecap": "round",
83
83
  "stroke-linejoin": "round"
84
84
  }, [
85
- c("polygon", { points: "5 4 15 12 5 20 5 4" }),
86
- c("line", {
85
+ u("polygon", { points: "5 4 15 12 5 20 5 4" }),
86
+ u("line", {
87
87
  x1: "19",
88
88
  y1: "5",
89
89
  x2: "19",
@@ -100,8 +100,8 @@ const _e = { class: "player-controls" }, Be = { class: "btn-group" }, He = ["tit
100
100
  for (const [t, d] of n)
101
101
  a[t] = d;
102
102
  return a;
103
- }, Fe = /* @__PURE__ */ le(We, [["__scopeId", "data-v-55e12a8d"]]), Xe = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
104
- function h(e) {
103
+ }, Oe = /* @__PURE__ */ le(ze, [["__scopeId", "data-v-55e12a8d"]]), Ge = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
104
+ function x(e) {
105
105
  if (typeof e == "number") return e;
106
106
  if (e instanceof Date) return e.getTime();
107
107
  const n = Date.parse(e);
@@ -110,75 +110,75 @@ function h(e) {
110
110
  function K(e, n = 2) {
111
111
  return String(e).padStart(n, "0");
112
112
  }
113
- function Oe(e) {
113
+ function Ue(e) {
114
114
  return new Date(e).getHours();
115
115
  }
116
- function Ge(e) {
116
+ function je(e) {
117
117
  return new Date(e).getDay();
118
118
  }
119
- function ke(e) {
120
- return Xe[Ge(e)] ?? "";
119
+ function be(e) {
120
+ return Ge[je(e)] ?? "";
121
121
  }
122
- function Ue(e) {
122
+ function Ke(e) {
123
123
  return K(new Date(e).getHours());
124
124
  }
125
- function we(e) {
125
+ function $e(e) {
126
126
  const n = new Date(e);
127
127
  return `${n.getMonth() + 1}月${n.getDate()}日`;
128
128
  }
129
- function je(e) {
129
+ function Ye(e) {
130
130
  const n = new Date(e);
131
131
  return `${K(n.getHours())}:${K(n.getMinutes())}`;
132
132
  }
133
- function ze(e) {
134
- return `${we(e)} ${ke(e)} ${je(e)}`;
133
+ function qe(e) {
134
+ return `${$e(e)} ${be(e)} ${Ye(e)}`;
135
135
  }
136
- function pe(e) {
136
+ function ke(e) {
137
137
  const n = new Date(e);
138
138
  return `${n.getFullYear()}${K(n.getMonth() + 1)}${K(n.getDate())}`;
139
139
  }
140
- function Ke(e) {
141
- return `${we(e)} ${ke(e)}`;
140
+ function Je(e) {
141
+ return `${$e(e)} ${be(e)}`;
142
142
  }
143
- function W(e, n) {
143
+ function F(e, n) {
144
144
  return e + n * 36e5;
145
145
  }
146
- function ft(e, n) {
147
- return (h(n) - h(e)) / 36e5;
146
+ function mt(e, n) {
147
+ return (x(n) - x(e)) / 36e5;
148
148
  }
149
- function Ye(e) {
149
+ function Qe(e) {
150
150
  const n = new Date(e);
151
151
  return n.setHours(24, 0, 0, 0), n.getTime();
152
152
  }
153
- function qe(e, n) {
153
+ function Le(e, n) {
154
154
  if (e.length === 0) return -1;
155
155
  if (e.length === 1) return 0;
156
156
  let a = 0, t = e.length - 1;
157
157
  if (n <= e[a]) return a;
158
158
  if (n >= e[t]) return t;
159
159
  for (; a <= t; ) {
160
- const d = a + t >>> 1, f = e[d];
161
- if (f === n) return d;
162
- f < n ? a = d + 1 : t = d - 1;
160
+ const d = a + t >>> 1, p = e[d];
161
+ if (p === n) return d;
162
+ p < n ? a = d + 1 : t = d - 1;
163
163
  }
164
164
  return a >= e.length ? t : t < 0 || Math.abs(e[a] - n) < Math.abs(e[t] - n) ? a : t;
165
165
  }
166
- function Je(e, n) {
166
+ function pt(e, n) {
167
167
  let a = 0, t = e.length - 1;
168
168
  for (; a <= t; ) {
169
- const d = a + t >>> 1, f = e[d];
170
- if (f === n) return d;
171
- f < n ? a = d + 1 : t = d - 1;
169
+ const d = a + t >>> 1, p = e[d];
170
+ if (p === n) return d;
171
+ p < n ? a = d + 1 : t = d - 1;
172
172
  }
173
173
  return -1;
174
174
  }
175
- const Qe = {
175
+ const Ze = {
176
176
  key: 0,
177
177
  class: "tick-label"
178
- }, Ze = {
178
+ }, et = {
179
179
  key: 1,
180
180
  class: "day-label"
181
- }, et = 35, tt = 35, nt = /* @__PURE__ */ ne({
181
+ }, tt = 35, nt = 35, lt = /* @__PURE__ */ ne({
182
182
  __name: "TimeTimeline",
183
183
  props: {
184
184
  modelValue: {},
@@ -191,187 +191,190 @@ const Qe = {
191
191
  },
192
192
  emits: ["update:modelValue", "change", "playing-pause"],
193
193
  setup(e, { emit: n }) {
194
- const a = [2, 8, 14, 20], t = e, d = n, f = $(null), u = $(null), X = $(null), k = $(0), E = $(0), i = $(0);
195
- let y = !1, p = 0, w = !1, C = !1, B = null;
196
- const O = $(!1), G = v(() => {
197
- const o = h(t.startTime), r = h(t.endTime), s = r - o;
198
- if (s <= 0) return [];
199
- const b = [];
194
+ const a = [2, 8, 14, 20], t = e, d = n, p = fe("timelineRef"), c = fe("scrollRef"), z = fe("innerRef"), w = V(0), P = V(0), i = V(0);
195
+ let y = !1, g = 0, T = !1, S = !1, R = null;
196
+ const L = V(!1), H = f(() => {
197
+ const o = x(t.startTime), s = x(t.endTime), r = s - o;
198
+ if (r <= 0) return [];
199
+ const D = [];
200
200
  let m = o;
201
- for (; m <= r; ) {
202
- const P = (m - o) / s * 100, M = Oe(m), R = b.length === 0, se = pe(m), re = R ? null : pe(b[b.length - 1].time), Z = !R && re !== se || R && M === 0;
203
- let H = !1;
204
- if (M === 0)
205
- H = !0;
206
- else if (R) {
207
- const N = Ye(m);
208
- (W(m, t.interval) > N || r < N) && (H = !0);
201
+ for (; m <= s; ) {
202
+ const E = (m - o) / r * 100, C = Ue(m), _ = D.length === 0, ce = ke(m), de = _ ? null : ke(D[D.length - 1].time), Z = !_ && de !== ce || _ && C === 0;
203
+ let N = !1;
204
+ if (C === 0)
205
+ N = !0;
206
+ else if (_) {
207
+ const A = Qe(m);
208
+ (F(m, t.interval) > A || s < A) && (N = !0);
209
209
  }
210
- const ue = M === 0 && H ? !1 : t.tickLabelMode === "all" || a.includes(M);
211
- b.push({
210
+ const ve = C === 0 && N ? !1 : t.tickLabelMode === "all" || a.includes(C);
211
+ D.push({
212
212
  time: m,
213
- percent: P,
214
- label: Ue(m),
215
- showLabel: ue,
216
- dayLabel: Ke(m),
217
- showDayLabel: H,
213
+ percent: E,
214
+ label: Ke(m),
215
+ showLabel: ve,
216
+ dayLabel: Je(m),
217
+ showDayLabel: N,
218
218
  isDayBoundary: Z
219
- }), m = W(m, t.interval);
219
+ }), m = F(m, t.interval);
220
220
  }
221
- return b;
222
- }), Y = v(() => G.value.map((o) => o.time)), q = v(() => t.minTickSpacing !== void 0 ? t.minTickSpacing : t.tickLabelMode === "major" ? 5 : 15), L = v(() => {
223
- const o = G.value.length;
224
- return o < 2 ? k.value || 0 : (o - 1) * q.value;
225
- }), I = v(() => L.value > k.value && k.value > 0), D = v(() => I.value ? et : tt), S = v(() => I.value ? L.value : Math.max(0, k.value - D.value * 2)), J = v(() => S.value + D.value * 2), l = v(() => k.value && I.value ? J.value + "px" : "100%"), g = v(() => ({
226
- left: D.value + "px",
227
- width: S.value + "px"
228
- })), V = v(() => ({
229
- left: D.value + "px",
230
- width: S.value + "px"
231
- })), Q = v(() => {
232
- const o = h(t.startTime), r = h(t.endTime), s = h(t.modelValue);
233
- return s <= o ? 0 : s >= r ? 100 : (s - o) / (r - o) * 100;
234
- }), Te = v(() => ({
235
- left: D.value + "px",
236
- width: Q.value / 100 * S.value + "px"
237
- })), xe = v(() => {
238
- const o = h(t.modelValue);
239
- return t.formatTooltip ? t.formatTooltip(o) : ze(o);
240
- }), oe = v(() => D.value + Q.value / 100 * S.value - i.value), be = v(() => oe.value > -50 && oe.value < k.value + 50), $e = v(() => ({
241
- transform: `translateX(${oe.value}px)`
221
+ return D;
222
+ }), oe = f(() => H.value.map((o) => o.time)), ae = f(() => t.minTickSpacing !== void 0 ? t.minTickSpacing : t.tickLabelMode === "major" ? 5 : 15), Y = f(() => {
223
+ const o = H.value.length;
224
+ return o < 2 ? w.value || 0 : (o - 1) * ae.value;
225
+ }), I = f(() => Y.value > w.value && w.value > 0), M = f(() => I.value ? tt : nt), h = f(() => I.value ? Y.value : Math.max(0, w.value - M.value * 2)), O = f(() => h.value + M.value * 2), q = f(() => w.value && I.value ? O.value + "px" : "100%"), J = f(() => ({
226
+ left: M.value + "px",
227
+ width: h.value + "px"
228
+ })), ie = f(() => ({
229
+ left: M.value + "px",
230
+ width: h.value + "px"
231
+ })), l = f(() => {
232
+ const o = x(t.startTime), s = x(t.endTime), r = x(t.modelValue);
233
+ return r <= o ? 0 : r >= s ? 100 : (r - o) / (s - o) * 100;
234
+ }), v = f(() => ({
235
+ left: M.value + "px",
236
+ width: l.value / 100 * h.value + "px"
237
+ })), k = f(() => {
238
+ const o = x(t.modelValue);
239
+ return t.formatTooltip ? t.formatTooltip(o) : qe(o);
240
+ }), re = f(() => M.value + l.value / 100 * h.value - i.value), De = f(() => re.value > -50 && re.value < w.value + 50), Me = f(() => ({
241
+ transform: `translateX(${re.value}px)`
242
242
  }));
243
- function Le() {
244
- u.value && (E.value = u.value.scrollLeft, w || (i.value = u.value.scrollLeft));
243
+ function Q() {
244
+ g && (cancelAnimationFrame(g), g = 0), T = !1;
245
+ }
246
+ function Se() {
247
+ c.value && (P.value = c.value.scrollLeft, T || (i.value = c.value.scrollLeft));
245
248
  }
246
- function De(o) {
247
- !u.value || !I.value || (u.value.scrollLeft += o.deltaY || o.deltaX);
249
+ function Ce(o) {
250
+ !c.value || !I.value || (c.value.scrollLeft += o.deltaY || o.deltaX);
248
251
  }
249
- function U(o = !1) {
250
- if (!I.value || !u.value || y) return;
251
- const r = D.value + Q.value / 100 * S.value, s = k.value, b = J.value - s, m = Math.max(0, Math.min(r - s / 2, b));
252
+ function G(o = !1) {
253
+ if (!I.value || !c.value || y) return;
254
+ const s = M.value + l.value / 100 * h.value, r = w.value, D = O.value - r, m = Math.max(0, Math.min(s - r / 2, D));
252
255
  i.value = m;
253
- const P = u.value;
254
- if (o || Math.abs(P.scrollLeft - m) < 1) {
255
- P.scrollLeft = m, E.value = m;
256
+ const E = c.value;
257
+ if (o || Math.abs(E.scrollLeft - m) < 1) {
258
+ E.scrollLeft = m, P.value = m;
256
259
  return;
257
260
  }
258
- p && cancelAnimationFrame(p);
259
- const M = P.scrollLeft, R = m - M;
260
- w = !0;
261
- const se = 200, re = performance.now();
262
- function Z(H) {
263
- const ue = H - re, N = Math.min(ue / se, 1), me = 1 - (1 - N) * (1 - N);
264
- P.scrollLeft = M + R * me, E.value = P.scrollLeft, N < 1 ? p = requestAnimationFrame(Z) : (p = 0, w = !1);
261
+ Q();
262
+ const C = E.scrollLeft, _ = m - C;
263
+ T = !0;
264
+ const ce = 200, de = performance.now();
265
+ function Z(N) {
266
+ const ve = N - de, A = Math.min(ve / ce, 1), he = 1 - (1 - A) * (1 - A);
267
+ E.scrollLeft = C + _ * he, P.value = E.scrollLeft, A < 1 ? g = requestAnimationFrame(Z) : (g = 0, T = !1);
265
268
  }
266
- p = requestAnimationFrame(Z);
269
+ g = requestAnimationFrame(Z);
267
270
  }
268
- _(Q, () => U()), _(k, () => U());
269
- function ae(o) {
270
- if (!u.value) return h(t.startTime);
271
- const r = u.value.getBoundingClientRect(), s = u.value.scrollLeft, m = o.clientX - r.left + s - D.value, P = Math.max(0, Math.min(m, S.value)), M = h(t.startTime), R = h(t.endTime);
272
- return M + (R - M) * (P / (S.value || 1));
271
+ B(l, () => G()), B(w, () => G());
272
+ function se(o) {
273
+ if (!c.value) return x(t.startTime);
274
+ const s = c.value.getBoundingClientRect(), r = c.value.scrollLeft, m = o.clientX - s.left + r - M.value, E = Math.max(0, Math.min(m, h.value)), C = x(t.startTime), _ = x(t.endTime);
275
+ return C + (_ - C) * (E / (h.value || 1));
273
276
  }
274
- function Se(o) {
275
- const r = Y.value;
276
- if (r.length === 0) return { time: o, index: -1 };
277
- const s = qe(r, o);
278
- return { time: r[s] ?? o, index: s };
277
+ function Ve(o) {
278
+ const s = oe.value;
279
+ if (s.length === 0) return { time: o, index: -1 };
280
+ const r = Le(s, o);
281
+ return { time: s[r] ?? o, index: r };
279
282
  }
280
- function ie(o) {
281
- const { time: r, index: s } = Se(o);
282
- r !== h(t.modelValue) && (d("update:modelValue", r), d("change", r, s));
283
+ function ue(o) {
284
+ const { time: s, index: r } = Ve(o);
285
+ s !== x(t.modelValue) && (d("update:modelValue", s), d("change", s, r));
283
286
  }
284
- function Me(o) {
285
- if (C) {
286
- C = !1;
287
+ function Pe(o) {
288
+ if (S) {
289
+ S = !1;
287
290
  return;
288
291
  }
289
- ie(ae(o));
292
+ ue(se(o));
290
293
  }
291
- function Ce(o) {
292
- const r = o.clientX;
293
- C = !1, y = !0, d("playing-pause");
294
- const s = (m) => {
295
- Math.abs(m.clientX - r) > 3 && (C = !0), ie(ae(m));
296
- }, b = () => {
297
- y = !1, document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", b), ce(() => U());
294
+ function Ee(o) {
295
+ const s = o.clientX;
296
+ S = !1, y = !0, Q(), d("playing-pause");
297
+ const r = (m) => {
298
+ Math.abs(m.clientX - s) > 3 && (S = !0), ue(se(m));
299
+ }, D = () => {
300
+ y = !1, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", D), me(() => G());
298
301
  };
299
- document.addEventListener("mousemove", s), document.addEventListener("mouseup", b);
302
+ document.addEventListener("mousemove", r), document.addEventListener("mouseup", D);
300
303
  }
301
- function Ve(o) {
302
- y = !0, C = !1, O.value = !0, document.body.style.cursor = "grabbing", d("playing-pause");
303
- const r = (b) => {
304
- C = !0, ie(ae(b));
305
- }, s = () => {
306
- y = !1, O.value = !1, document.body.style.cursor = "", document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", s), ce(() => U());
304
+ function Re(o) {
305
+ y = !0, Q(), S = !1, L.value = !0, document.body.style.cursor = "grabbing", d("playing-pause");
306
+ const s = (D) => {
307
+ S = !0, ue(se(D));
308
+ }, r = () => {
309
+ y = !1, L.value = !1, document.body.style.cursor = "", document.removeEventListener("mousemove", s), document.removeEventListener("mouseup", r), me(() => G());
307
310
  };
308
- document.addEventListener("mousemove", r), document.addEventListener("mouseup", s);
311
+ document.addEventListener("mousemove", s), document.addEventListener("mouseup", r);
309
312
  }
310
- return ge(() => {
311
- u.value && (k.value = u.value.clientWidth, B = new ResizeObserver((o) => {
312
- o[0] && (k.value = o[0].contentRect.width);
313
- }), B.observe(u.value)), ce(() => U());
314
- }), fe(() => {
315
- p && cancelAnimationFrame(p), B == null || B.disconnect();
316
- }), (o, r) => (T(), x("div", {
313
+ return Te(() => {
314
+ c.value && (w.value = c.value.clientWidth, R = new ResizeObserver((o) => {
315
+ o[0] && (w.value = o[0].contentRect.width);
316
+ }), R.observe(c.value)), me(() => G());
317
+ }), ye(() => {
318
+ Q(), R == null || R.disconnect();
319
+ }), (o, s) => (b(), $("div", {
317
320
  class: "time-timeline",
318
321
  ref_key: "timelineRef",
319
- ref: f
322
+ ref: p
320
323
  }, [
321
- Pe(c("div", {
322
- class: j(["handle-group", { dragging: O.value }]),
323
- style: A($e.value)
324
+ Ie(u("div", {
325
+ class: U(["handle-group", { dragging: L.value }]),
326
+ style: W(Me.value)
324
327
  }, [
325
- c("div", {
328
+ u("div", {
326
329
  class: "floating-tooltip",
327
- onMousedown: de(Ve, ["prevent", "stop"])
328
- }, z(xe.value), 33),
329
- r[0] || (r[0] = c("div", { class: "handle-visual" }, null, -1))
330
+ onMousedown: pe(Re, ["prevent", "stop"])
331
+ }, j(k.value), 33),
332
+ s[0] || (s[0] = u("div", { class: "handle-visual" }, null, -1))
330
333
  ], 6), [
331
- [Ee, be.value]
334
+ [_e, De.value]
332
335
  ]),
333
- c("div", {
336
+ u("div", {
334
337
  class: "scroll-container",
335
338
  ref_key: "scrollRef",
336
- ref: u,
337
- onScroll: Le,
338
- onWheel: de(De, ["prevent"])
339
+ ref: c,
340
+ onScroll: Se,
341
+ onWheel: pe(Ce, ["prevent"])
339
342
  }, [
340
- c("div", {
343
+ u("div", {
341
344
  class: "timeline-inner",
342
345
  ref_key: "innerRef",
343
- ref: X,
344
- style: A({ width: l.value }),
345
- onMousedown: de(Ce, ["prevent"]),
346
- onClick: Me
346
+ ref: z,
347
+ style: W({ width: q.value }),
348
+ onMousedown: pe(Ee, ["prevent"]),
349
+ onClick: Pe
347
350
  }, [
348
- c("div", {
351
+ u("div", {
349
352
  class: "track-bg",
350
- style: A(g.value)
353
+ style: W(J.value)
351
354
  }, null, 4),
352
- c("div", {
355
+ u("div", {
353
356
  class: "track-active",
354
- style: A(Te.value)
357
+ style: W(v.value)
355
358
  }, null, 4),
356
- c("div", {
359
+ u("div", {
357
360
  class: "ticks-container",
358
- style: A(V.value)
361
+ style: W(ie.value)
359
362
  }, [
360
- (T(!0), x(ye, null, he(G.value, (s) => (T(), x("div", {
361
- key: s.time,
362
- class: j(["tick-item", { "is-day-boundary": s.isDayBoundary }]),
363
- style: A({ left: s.percent + "%" })
363
+ (b(!0), $(xe, null, we(H.value, (r) => (b(), $("div", {
364
+ key: r.time,
365
+ class: U(["tick-item", { "is-day-boundary": r.isDayBoundary }]),
366
+ style: W({ left: r.percent + "%" })
364
367
  }, [
365
- r[1] || (r[1] = c("div", { class: "tick-mark" }, null, -1)),
366
- s.showLabel ? (T(), x("div", Qe, z(s.label), 1)) : ve("", !0),
367
- s.showDayLabel ? (T(), x("div", Ze, z(s.dayLabel), 1)) : ve("", !0)
368
+ s[1] || (s[1] = u("div", { class: "tick-mark" }, null, -1)),
369
+ r.showLabel ? (b(), $("div", Ze, j(r.label), 1)) : ge("", !0),
370
+ r.showDayLabel ? (b(), $("div", et, j(r.dayLabel), 1)) : ge("", !0)
368
371
  ], 6))), 128))
369
372
  ], 4)
370
373
  ], 36)
371
374
  ], 544)
372
375
  ], 512));
373
376
  }
374
- }), lt = /* @__PURE__ */ le(nt, [["__scopeId", "data-v-d7d9fd3b"]]), ot = { class: "speed-value" }, at = ["onClick"], it = /* @__PURE__ */ ne({
377
+ }), ot = /* @__PURE__ */ le(lt, [["__scopeId", "data-v-0f78dcee"]]), at = { class: "speed-value" }, it = ["onClick"], rt = /* @__PURE__ */ ne({
375
378
  __name: "SpeedSelector",
376
379
  props: {
377
380
  modelValue: {},
@@ -379,37 +382,37 @@ const Qe = {
379
382
  },
380
383
  emits: ["update:modelValue"],
381
384
  setup(e, { emit: n }) {
382
- const a = n, t = $(!1), d = $(!0), f = $(null);
383
- function u() {
384
- if (!f.value) return;
385
- const i = f.value.getBoundingClientRect(), y = i.top, p = window.innerHeight - i.bottom;
386
- d.value = y >= p;
385
+ const a = n, t = V(!1), d = V(!0), p = V(null);
386
+ function c() {
387
+ if (!p.value) return;
388
+ const i = p.value.getBoundingClientRect(), y = i.top, g = window.innerHeight - i.bottom;
389
+ d.value = y >= g;
387
390
  }
388
- function X() {
389
- t.value || u(), t.value = !t.value;
391
+ function z() {
392
+ t.value || c(), t.value = !t.value;
390
393
  }
391
- function k(i) {
394
+ function w(i) {
392
395
  a("update:modelValue", i), t.value = !1;
393
396
  }
394
- function E(i) {
395
- f.value && !f.value.contains(i.target) && (t.value = !1);
397
+ function P(i) {
398
+ p.value && !p.value.contains(i.target) && (t.value = !1);
396
399
  }
397
- return ge(() => document.addEventListener("mousedown", E)), fe(() => document.removeEventListener("mousedown", E)), (i, y) => (T(), x("div", {
400
+ return Te(() => document.addEventListener("mousedown", P)), ye(() => document.removeEventListener("mousedown", P)), (i, y) => (b(), $("div", {
398
401
  class: "speed-selector",
399
402
  ref_key: "selectorRef",
400
- ref: f
403
+ ref: p
401
404
  }, [
402
- c("div", {
405
+ u("div", {
403
406
  class: "speed-trigger",
404
- onClick: X
407
+ onClick: z
405
408
  }, [
406
- c("span", ot, z(e.modelValue) + "x", 1),
407
- (T(), x("svg", {
408
- class: j(["arrow-icon", { open: t.value }]),
409
+ u("span", at, j(e.modelValue) + "x", 1),
410
+ (b(), $("svg", {
411
+ class: U(["arrow-icon", { open: t.value }]),
409
412
  viewBox: "0 0 12 12",
410
413
  fill: "currentColor"
411
414
  }, [...y[0] || (y[0] = [
412
- c("path", {
415
+ u("path", {
413
416
  d: "M2.5 4.5L6 8L9.5 4.5",
414
417
  stroke: "currentColor",
415
418
  "stroke-width": "1.5",
@@ -419,26 +422,26 @@ const Qe = {
419
422
  }, null, -1)
420
423
  ])], 2))
421
424
  ]),
422
- ee(Ie, {
425
+ ee(Be, {
423
426
  name: d.value ? "dropdown-up" : "dropdown-down"
424
427
  }, {
425
428
  default: te(() => [
426
- t.value ? (T(), x("div", {
429
+ t.value ? (b(), $("div", {
427
430
  key: 0,
428
- class: j(["speed-dropdown", d.value ? "is-up" : "is-down"])
431
+ class: U(["speed-dropdown", d.value ? "is-up" : "is-down"])
429
432
  }, [
430
- (T(!0), x(ye, null, he(e.options, (p) => (T(), x("div", {
431
- key: p,
432
- class: j(["speed-option", { active: p === e.modelValue }]),
433
- onClick: (w) => k(p)
434
- }, z(p) + "x ", 11, at))), 128))
435
- ], 2)) : ve("", !0)
433
+ (b(!0), $(xe, null, we(e.options, (g) => (b(), $("div", {
434
+ key: g,
435
+ class: U(["speed-option", { active: g === e.modelValue }]),
436
+ onClick: (T) => w(g)
437
+ }, j(g) + "x ", 11, it))), 128))
438
+ ], 2)) : ge("", !0)
436
439
  ]),
437
440
  _: 1
438
441
  }, 8, ["name"])
439
442
  ], 512));
440
443
  }
441
- }), st = /* @__PURE__ */ le(it, [["__scopeId", "data-v-30c5e152"]]), rt = { class: "g-time-player" }, ut = { class: "controls-wrapper" }, ct = { class: "timeline-wrapper" }, dt = /* @__PURE__ */ ne({
444
+ }), st = /* @__PURE__ */ le(rt, [["__scopeId", "data-v-30c5e152"]]), ut = { class: "g-time-player" }, ct = { class: "controls-wrapper" }, dt = { class: "timeline-wrapper" }, vt = /* @__PURE__ */ ne({
442
445
  __name: "index",
443
446
  props: {
444
447
  modelValue: {},
@@ -454,151 +457,165 @@ const Qe = {
454
457
  },
455
458
  emits: ["update:modelValue", "change"],
456
459
  setup(e, { expose: n, emit: a }) {
457
- const t = e, d = a, f = v(() => h(t.startTime)), u = v(() => h(t.endTime)), X = v(() => f.value), k = v(() => u.value), E = v(() => {
460
+ const t = e, d = a, p = f(() => x(t.startTime)), c = f(() => x(t.endTime)), z = f(() => p.value), w = f(() => c.value), P = f(() => {
458
461
  const l = [];
459
- let g = f.value;
460
- for (; g <= u.value; )
461
- l.push(g), g = W(g, t.interval);
462
+ let v = p.value;
463
+ for (; v <= c.value; )
464
+ l.push(v), v = F(v, t.interval);
462
465
  return l;
463
- }), i = $(h(t.modelValue ?? t.startTime)), y = $(!1), p = $(t.speed);
464
- let w = null;
465
- const C = v(() => t.playInterval / p.value);
466
- _(() => t.speed, (l) => {
467
- p.value = l;
466
+ }), i = V(H(t.modelValue ?? t.startTime)), y = V(!1), g = V(t.speed);
467
+ let T = null, S = i.value;
468
+ const R = f(() => t.playInterval / g.value);
469
+ B(() => t.speed, (l) => {
470
+ g.value = l;
468
471
  });
469
- function B(l) {
470
- const g = Je(E.value, l);
471
- return g >= 0 ? g : 0;
472
+ function L(l) {
473
+ return Math.max(p.value, Math.min(l, c.value));
472
474
  }
473
- function O(l, g) {
474
- d("update:modelValue", l), d("change", { time: l, index: B(l) });
475
+ function H(l) {
476
+ return L(x(l));
475
477
  }
476
- function G(l, g) {
477
- d("change", { time: l, index: g });
478
+ function oe(l) {
479
+ const v = P.value;
480
+ if (!v.length) return -1;
481
+ const k = Le(v, L(l));
482
+ return Math.max(0, Math.min(k, v.length - 1));
478
483
  }
479
- _(
484
+ function ae(l, v) {
485
+ const k = L(l);
486
+ k !== S && (S = k, d("update:modelValue", k), d("change", { time: k, index: oe(k) }));
487
+ }
488
+ function Y(l, v) {
489
+ const k = L(l);
490
+ d("change", { time: k, index: Math.max(0, Math.min(v, P.value.length - 1)) });
491
+ }
492
+ B(
480
493
  () => t.modelValue,
481
494
  (l) => {
482
- l !== void 0 && !y.value && (i.value = h(l));
495
+ l !== void 0 && !y.value && (i.value = H(l));
483
496
  }
484
- ), _(f, () => {
485
- L(), i.value = f.value;
486
- }), _(u, (l) => {
487
- i.value > l && (i.value = l, L());
488
- }), _(i, (l) => {
489
- O(l), l >= u.value && L();
497
+ ), B(p, () => {
498
+ h(), i.value = p.value, S = i.value;
499
+ }), B(c, (l) => {
500
+ i.value > l && (i.value = l, h());
501
+ }), B(i, (l) => {
502
+ const v = L(l);
503
+ if (v !== l) {
504
+ i.value = v;
505
+ return;
506
+ }
507
+ ae(v), v >= c.value && h();
490
508
  });
491
- function Y() {
492
- y.value ? L() : q();
509
+ function I() {
510
+ y.value ? h() : M();
493
511
  }
494
- function q() {
495
- i.value >= u.value && (i.value = f.value), y.value = !0, w && clearInterval(w), w = setInterval(I, C.value);
512
+ function M() {
513
+ i.value >= c.value && (i.value = p.value), y.value = !0, T && clearInterval(T), T = setInterval(O, R.value);
496
514
  }
497
- function L() {
498
- y.value = !1, w && (clearInterval(w), w = null);
515
+ function h() {
516
+ y.value = !1, T && (clearInterval(T), T = null);
499
517
  }
500
- _(C, (l) => {
501
- y.value && (w && clearInterval(w), w = setInterval(I, l));
518
+ B(R, (l) => {
519
+ y.value && (T && clearInterval(T), T = setInterval(O, l));
502
520
  });
503
- function I() {
504
- const l = W(i.value, t.interval);
505
- if (l > u.value) {
506
- i.value = u.value, L();
521
+ function O() {
522
+ const l = F(i.value, t.interval);
523
+ if (l > c.value) {
524
+ i.value = L(c.value), h();
507
525
  return;
508
526
  }
509
- i.value = l;
527
+ i.value = L(l);
510
528
  }
511
- function D() {
512
- const l = W(i.value, -t.interval);
513
- i.value = l < f.value ? f.value : l;
529
+ function q() {
530
+ const l = F(i.value, -t.interval);
531
+ i.value = L(l);
514
532
  }
515
- function S() {
516
- const l = W(i.value, t.interval);
517
- i.value = l > u.value ? u.value : l;
533
+ function J() {
534
+ const l = F(i.value, t.interval);
535
+ i.value = L(l);
518
536
  }
519
- function J(l) {
520
- const g = h(l), V = Math.max(f.value, Math.min(g, u.value));
521
- i.value = V;
537
+ function ie(l) {
538
+ i.value = H(l);
522
539
  }
523
540
  return n({
524
- play: q,
525
- pause: L,
526
- togglePlay: Y,
527
- prev: D,
528
- next: S,
529
- seekTo: J,
541
+ play: M,
542
+ pause: h,
543
+ togglePlay: I,
544
+ prev: q,
545
+ next: J,
546
+ seekTo: ie,
530
547
  isPlaying: y,
531
548
  currentTime: i,
532
- speedMultiplier: p
533
- }), fe(() => L()), (l, g) => (T(), x("div", rt, [
534
- c("div", ut, [
535
- ee(Fe, {
549
+ speedMultiplier: g
550
+ }), ye(() => h()), (l, v) => (b(), $("div", ut, [
551
+ u("div", ct, [
552
+ ee(Oe, {
536
553
  "is-playing": y.value,
537
- onTogglePlay: Y,
538
- onPrev: D,
539
- onNext: S
540
- }, Re({ _: 2 }, [
554
+ onTogglePlay: I,
555
+ onPrev: q,
556
+ onNext: J
557
+ }, He({ _: 2 }, [
541
558
  l.$slots.prev ? {
542
559
  name: "prev",
543
560
  fn: te(() => [
544
- F(l.$slots, "prev", {}, void 0, !0)
561
+ X(l.$slots, "prev", {}, void 0, !0)
545
562
  ]),
546
563
  key: "0"
547
564
  } : void 0,
548
565
  l.$slots.play ? {
549
566
  name: "play",
550
- fn: te(({ isPlaying: V }) => [
551
- F(l.$slots, "play", { isPlaying: V }, void 0, !0)
567
+ fn: te(({ isPlaying: k }) => [
568
+ X(l.$slots, "play", { isPlaying: k }, void 0, !0)
552
569
  ]),
553
570
  key: "1"
554
571
  } : void 0,
555
572
  l.$slots.next ? {
556
573
  name: "next",
557
574
  fn: te(() => [
558
- F(l.$slots, "next", {}, void 0, !0)
575
+ X(l.$slots, "next", {}, void 0, !0)
559
576
  ]),
560
577
  key: "2"
561
578
  } : void 0
562
579
  ]), 1032, ["is-playing"])
563
580
  ]),
564
- c("div", ct, [
565
- ee(lt, {
581
+ u("div", dt, [
582
+ ee(ot, {
566
583
  modelValue: i.value,
567
- "onUpdate:modelValue": g[0] || (g[0] = (V) => i.value = V),
568
- "start-time": X.value,
569
- "end-time": k.value,
584
+ "onUpdate:modelValue": v[0] || (v[0] = (k) => i.value = k),
585
+ "start-time": z.value,
586
+ "end-time": w.value,
570
587
  interval: e.interval,
571
588
  "min-tick-spacing": e.minTickSpacing,
572
589
  "tick-label-mode": e.tickLabelMode,
573
590
  "format-tooltip": e.formatTooltip,
574
- onPlayingPause: L,
575
- onChange: G
591
+ onPlayingPause: h,
592
+ onChange: Y
576
593
  }, null, 8, ["modelValue", "start-time", "end-time", "interval", "min-tick-spacing", "tick-label-mode", "format-tooltip"])
577
594
  ]),
578
595
  ee(st, {
579
- modelValue: p.value,
580
- "onUpdate:modelValue": g[1] || (g[1] = (V) => p.value = V),
596
+ modelValue: g.value,
597
+ "onUpdate:modelValue": v[1] || (v[1] = (k) => g.value = k),
581
598
  options: e.speedOptions
582
599
  }, null, 8, ["modelValue", "options"])
583
600
  ]));
584
601
  }
585
- }), mt = /* @__PURE__ */ le(dt, [["__scopeId", "data-v-98cef505"]]);
602
+ }), gt = /* @__PURE__ */ le(vt, [["__scopeId", "data-v-55b5dfa2"]]);
586
603
  export {
587
- W as addHours,
588
- mt as default,
589
- ze as defaultTooltipFormat,
590
- ft as diffHours,
591
- qe as findNearestTickIndex,
592
- Je as findTickIndex,
593
- Ke as formatDayLabel,
594
- Ue as formatHH,
595
- je as formatHHmm,
596
- we as formatMD,
597
- pe as getDateKey,
598
- Ge as getDayOfWeek,
599
- Oe as getHour,
600
- Ye as getNextMidnight,
601
- ke as getWeekdayShort,
602
- h as toTimestamp,
603
- mt as vue3TimePlaybar
604
+ F as addHours,
605
+ gt as default,
606
+ qe as defaultTooltipFormat,
607
+ mt as diffHours,
608
+ Le as findNearestTickIndex,
609
+ pt as findTickIndex,
610
+ Je as formatDayLabel,
611
+ Ke as formatHH,
612
+ Ye as formatHHmm,
613
+ $e as formatMD,
614
+ ke as getDateKey,
615
+ je as getDayOfWeek,
616
+ Ue as getHour,
617
+ Qe as getNextMidnight,
618
+ be as getWeekdayShort,
619
+ x as toTimestamp,
620
+ gt as vue3TimePlaybar
604
621
  };
@@ -1 +1 @@
1
- (function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.Vue3TimePlaybar={},m.Vue))})(this,(function(m,e){"use strict";const fe={class:"player-controls"},pe={class:"btn-group"},ge=["title"],ye={key:0,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},ve={key:1,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},he=e.defineComponent({__name:"PlayerControls",props:{isPlaying:{type:Boolean}},emits:["toggle-play","prev","next"],setup(t){return(o,r)=>(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("div",pe,[e.createElementVNode("button",{class:"control-btn",onClick:r[0]||(r[0]=n=>o.$emit("prev")),title:"上一时刻"},[e.renderSlot(o.$slots,"prev",{},()=>[r[3]||(r[3]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"19 20 9 12 19 4 19 20"}),e.createElementVNode("line",{x1:"5",y1:"19",x2:"5",y2:"5"})],-1))],!0)]),e.createElementVNode("button",{class:"control-btn play-btn",onClick:r[1]||(r[1]=n=>o.$emit("toggle-play")),title:t.isPlaying?"暂停":"播放"},[e.renderSlot(o.$slots,"play",{isPlaying:t.isPlaying},()=>[t.isPlaying?(e.openBlock(),e.createElementBlock("svg",ve,[...r[5]||(r[5]=[e.createElementVNode("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"},null,-1),e.createElementVNode("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",ye,[...r[4]||(r[4]=[e.createElementVNode("polygon",{points:"5 3 19 12 5 21 5 3"},null,-1)])]))],!0)],8,ge),e.createElementVNode("button",{class:"control-btn",onClick:r[2]||(r[2]=n=>o.$emit("next")),title:"下一时刻"},[e.renderSlot(o.$slots,"next",{},()=>[r[6]||(r[6]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"5 4 15 12 5 20 5 4"}),e.createElementVNode("line",{x1:"19",y1:"5",x2:"19",y2:"19"})],-1))],!0)])])]))}}),A=(t,o)=>{const r=t.__vccOpts||t;for(const[n,u]of o)r[n]=u;return r},ke=A(he,[["__scopeId","data-v-55e12a8d"]]),we=["周日","周一","周二","周三","周四","周五","周六"];function v(t){if(typeof t=="number")return t;if(t instanceof Date)return t.getTime();const o=Date.parse(t);return Number.isNaN(o)?(console.warn(`[GTimePlayer] 无法解析时间: "${t}"`),0):o}function H(t,o=2){return String(t).padStart(o,"0")}function ne(t){return new Date(t).getHours()}function oe(t){return new Date(t).getDay()}function j(t){return we[oe(t)]??""}function le(t){return H(new Date(t).getHours())}function K(t){const o=new Date(t);return`${o.getMonth()+1}月${o.getDate()}日`}function ae(t){const o=new Date(t);return`${H(o.getHours())}:${H(o.getMinutes())}`}function re(t){return`${K(t)} ${j(t)} ${ae(t)}`}function q(t){const o=new Date(t);return`${o.getFullYear()}${H(o.getMonth()+1)}${H(o.getDate())}`}function ie(t){return`${K(t)} ${j(t)}`}function L(t,o){return t+o*36e5}function Te(t,o){return(v(o)-v(t))/36e5}function se(t){const o=new Date(t);return o.setHours(24,0,0,0),o.getTime()}function ce(t,o){if(t.length===0)return-1;if(t.length===1)return 0;let r=0,n=t.length-1;if(o<=t[r])return r;if(o>=t[n])return n;for(;r<=n;){const u=r+n>>>1,f=t[u];if(f===o)return u;f<o?r=u+1:n=u-1}return r>=t.length?n:n<0||Math.abs(t[r]-o)<Math.abs(t[n]-o)?r:n}function de(t,o){let r=0,n=t.length-1;for(;r<=n;){const u=r+n>>>1,f=t[u];if(f===o)return u;f<o?r=u+1:n=u-1}return-1}const Ve={key:0,class:"tick-label"},Ee={key:1,class:"day-label"},be=35,Se=35,xe=A(e.defineComponent({__name:"TimeTimeline",props:{modelValue:{},startTime:{},endTime:{},interval:{},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change","playing-pause"],setup(t,{emit:o}){const r=[2,8,14,20],n=t,u=o,f=e.ref(null),d=e.ref(null),I=e.ref(null),k=e.ref(0),$=e.ref(0),i=e.ref(0);let h=!1,g=0,w=!1,x=!1,M=null;const R=e.ref(!1),z=e.computed(()=>{const a=v(n.startTime),c=v(n.endTime),s=c-a;if(s<=0)return[];const T=[];let p=a;for(;p<=c;){const D=(p-a)/s*100,S=ne(p),C=T.length===0,Z=q(p),ee=C?null:q(T[T.length-1].time),G=!C&&ee!==Z||C&&S===0;let P=!1;if(S===0)P=!0;else if(C){const _=se(p);(L(p,n.interval)>_||c<_)&&(P=!0)}const te=S===0&&P?!1:n.tickLabelMode==="all"||r.includes(S);T.push({time:p,percent:D,label:le(p),showLabel:te,dayLabel:ie(p),showDayLabel:P,isDayBoundary:G}),p=L(p,n.interval)}return T}),F=e.computed(()=>z.value.map(a=>a.time)),O=e.computed(()=>n.minTickSpacing!==void 0?n.minTickSpacing:n.tickLabelMode==="major"?5:15),V=e.computed(()=>{const a=z.value.length;return a<2?k.value||0:(a-1)*O.value}),B=e.computed(()=>V.value>k.value&&k.value>0),E=e.computed(()=>B.value?be:Se),b=e.computed(()=>B.value?V.value:Math.max(0,k.value-E.value*2)),U=e.computed(()=>b.value+E.value*2),l=e.computed(()=>k.value&&B.value?U.value+"px":"100%"),y=e.computed(()=>({left:E.value+"px",width:b.value+"px"})),N=e.computed(()=>({left:E.value+"px",width:b.value+"px"})),X=e.computed(()=>{const a=v(n.startTime),c=v(n.endTime),s=v(n.modelValue);return s<=a?0:s>=c?100:(s-a)/(c-a)*100}),Me=e.computed(()=>({left:E.value+"px",width:X.value/100*b.value+"px"})),Pe=e.computed(()=>{const a=v(n.modelValue);return n.formatTooltip?n.formatTooltip(a):re(a)}),Y=e.computed(()=>E.value+X.value/100*b.value-i.value),_e=e.computed(()=>Y.value>-50&&Y.value<k.value+50),He=e.computed(()=>({transform:`translateX(${Y.value}px)`}));function Ie(){d.value&&($.value=d.value.scrollLeft,w||(i.value=d.value.scrollLeft))}function Re(a){!d.value||!B.value||(d.value.scrollLeft+=a.deltaY||a.deltaX)}function W(a=!1){if(!B.value||!d.value||h)return;const c=E.value+X.value/100*b.value,s=k.value,T=U.value-s,p=Math.max(0,Math.min(c-s/2,T));i.value=p;const D=d.value;if(a||Math.abs(D.scrollLeft-p)<1){D.scrollLeft=p,$.value=p;return}g&&cancelAnimationFrame(g);const S=D.scrollLeft,C=p-S;w=!0;const Z=200,ee=performance.now();function G(P){const te=P-ee,_=Math.min(te/Z,1),me=1-(1-_)*(1-_);D.scrollLeft=S+C*me,$.value=D.scrollLeft,_<1?g=requestAnimationFrame(G):(g=0,w=!1)}g=requestAnimationFrame(G)}e.watch(X,()=>W()),e.watch(k,()=>W());function J(a){if(!d.value)return v(n.startTime);const c=d.value.getBoundingClientRect(),s=d.value.scrollLeft,p=a.clientX-c.left+s-E.value,D=Math.max(0,Math.min(p,b.value)),S=v(n.startTime),C=v(n.endTime);return S+(C-S)*(D/(b.value||1))}function ze(a){const c=F.value;if(c.length===0)return{time:a,index:-1};const s=ce(c,a);return{time:c[s]??a,index:s}}function Q(a){const{time:c,index:s}=ze(a);c!==v(n.modelValue)&&(u("update:modelValue",c),u("change",c,s))}function We(a){if(x){x=!1;return}Q(J(a))}function Ae(a){const c=a.clientX;x=!1,h=!0,u("playing-pause");const s=p=>{Math.abs(p.clientX-c)>3&&(x=!0),Q(J(p))},T=()=>{h=!1,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",T),e.nextTick(()=>W())};document.addEventListener("mousemove",s),document.addEventListener("mouseup",T)}function Fe(a){h=!0,x=!1,R.value=!0,document.body.style.cursor="grabbing",u("playing-pause");const c=T=>{x=!0,Q(J(T))},s=()=>{h=!1,R.value=!1,document.body.style.cursor="",document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s),e.nextTick(()=>W())};document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)}return e.onMounted(()=>{d.value&&(k.value=d.value.clientWidth,M=new ResizeObserver(a=>{a[0]&&(k.value=a[0].contentRect.width)}),M.observe(d.value)),e.nextTick(()=>W())}),e.onUnmounted(()=>{g&&cancelAnimationFrame(g),M==null||M.disconnect()}),(a,c)=>(e.openBlock(),e.createElementBlock("div",{class:"time-timeline",ref_key:"timelineRef",ref:f},[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["handle-group",{dragging:R.value}]),style:e.normalizeStyle(He.value)},[e.createElementVNode("div",{class:"floating-tooltip",onMousedown:e.withModifiers(Fe,["prevent","stop"])},e.toDisplayString(Pe.value),33),c[0]||(c[0]=e.createElementVNode("div",{class:"handle-visual"},null,-1))],6),[[e.vShow,_e.value]]),e.createElementVNode("div",{class:"scroll-container",ref_key:"scrollRef",ref:d,onScroll:Ie,onWheel:e.withModifiers(Re,["prevent"])},[e.createElementVNode("div",{class:"timeline-inner",ref_key:"innerRef",ref:I,style:e.normalizeStyle({width:l.value}),onMousedown:e.withModifiers(Ae,["prevent"]),onClick:We},[e.createElementVNode("div",{class:"track-bg",style:e.normalizeStyle(y.value)},null,4),e.createElementVNode("div",{class:"track-active",style:e.normalizeStyle(Me.value)},null,4),e.createElementVNode("div",{class:"ticks-container",style:e.normalizeStyle(N.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(z.value,s=>(e.openBlock(),e.createElementBlock("div",{key:s.time,class:e.normalizeClass(["tick-item",{"is-day-boundary":s.isDayBoundary}]),style:e.normalizeStyle({left:s.percent+"%"})},[c[1]||(c[1]=e.createElementVNode("div",{class:"tick-mark"},null,-1)),s.showLabel?(e.openBlock(),e.createElementBlock("div",Ve,e.toDisplayString(s.label),1)):e.createCommentVNode("",!0),s.showDayLabel?(e.openBlock(),e.createElementBlock("div",Ee,e.toDisplayString(s.dayLabel),1)):e.createCommentVNode("",!0)],6))),128))],4)],36)],544)],512))}}),[["__scopeId","data-v-d7d9fd3b"]]),Ne={class:"speed-value"},De=["onClick"],$e=A(e.defineComponent({__name:"SpeedSelector",props:{modelValue:{},options:{}},emits:["update:modelValue"],setup(t,{emit:o}){const r=o,n=e.ref(!1),u=e.ref(!0),f=e.ref(null);function d(){if(!f.value)return;const i=f.value.getBoundingClientRect(),h=i.top,g=window.innerHeight-i.bottom;u.value=h>=g}function I(){n.value||d(),n.value=!n.value}function k(i){r("update:modelValue",i),n.value=!1}function $(i){f.value&&!f.value.contains(i.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("mousedown",$)),e.onUnmounted(()=>document.removeEventListener("mousedown",$)),(i,h)=>(e.openBlock(),e.createElementBlock("div",{class:"speed-selector",ref_key:"selectorRef",ref:f},[e.createElementVNode("div",{class:"speed-trigger",onClick:I},[e.createElementVNode("span",Ne,e.toDisplayString(t.modelValue)+"x",1),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["arrow-icon",{open:n.value}]),viewBox:"0 0 12 12",fill:"currentColor"},[...h[0]||(h[0]=[e.createElementVNode("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))]),e.createVNode(e.Transition,{name:u.value?"dropdown-up":"dropdown-down"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["speed-dropdown",u.value?"is-up":"is-down"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,g=>(e.openBlock(),e.createElementBlock("div",{key:g,class:e.normalizeClass(["speed-option",{active:g===t.modelValue}]),onClick:w=>k(g)},e.toDisplayString(g)+"x ",11,De))),128))],2)):e.createCommentVNode("",!0)]),_:1},8,["name"])],512))}}),[["__scopeId","data-v-30c5e152"]]),Be={class:"g-time-player"},Ce={class:"controls-wrapper"},Le={class:"timeline-wrapper"},ue=A(e.defineComponent({__name:"index",props:{modelValue:{},startTime:{},endTime:{},interval:{default:1},playInterval:{default:1e3},speed:{default:1},speedOptions:{default:()=>[.5,1,2,3]},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change"],setup(t,{expose:o,emit:r}){const n=t,u=r,f=e.computed(()=>v(n.startTime)),d=e.computed(()=>v(n.endTime)),I=e.computed(()=>f.value),k=e.computed(()=>d.value),$=e.computed(()=>{const l=[];let y=f.value;for(;y<=d.value;)l.push(y),y=L(y,n.interval);return l}),i=e.ref(v(n.modelValue??n.startTime)),h=e.ref(!1),g=e.ref(n.speed);let w=null;const x=e.computed(()=>n.playInterval/g.value);e.watch(()=>n.speed,l=>{g.value=l});function M(l){const y=de($.value,l);return y>=0?y:0}function R(l,y){u("update:modelValue",l),u("change",{time:l,index:M(l)})}function z(l,y){u("change",{time:l,index:y})}e.watch(()=>n.modelValue,l=>{l!==void 0&&!h.value&&(i.value=v(l))}),e.watch(f,()=>{V(),i.value=f.value}),e.watch(d,l=>{i.value>l&&(i.value=l,V())}),e.watch(i,l=>{R(l),l>=d.value&&V()});function F(){h.value?V():O()}function O(){i.value>=d.value&&(i.value=f.value),h.value=!0,w&&clearInterval(w),w=setInterval(B,x.value)}function V(){h.value=!1,w&&(clearInterval(w),w=null)}e.watch(x,l=>{h.value&&(w&&clearInterval(w),w=setInterval(B,l))});function B(){const l=L(i.value,n.interval);if(l>d.value){i.value=d.value,V();return}i.value=l}function E(){const l=L(i.value,-n.interval);i.value=l<f.value?f.value:l}function b(){const l=L(i.value,n.interval);i.value=l>d.value?d.value:l}function U(l){const y=v(l),N=Math.max(f.value,Math.min(y,d.value));i.value=N}return o({play:O,pause:V,togglePlay:F,prev:E,next:b,seekTo:U,isPlaying:h,currentTime:i,speedMultiplier:g}),e.onUnmounted(()=>V()),(l,y)=>(e.openBlock(),e.createElementBlock("div",Be,[e.createElementVNode("div",Ce,[e.createVNode(ke,{"is-playing":h.value,onTogglePlay:F,onPrev:E,onNext:b},e.createSlots({_:2},[l.$slots.prev?{name:"prev",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"prev",{},void 0,!0)]),key:"0"}:void 0,l.$slots.play?{name:"play",fn:e.withCtx(({isPlaying:N})=>[e.renderSlot(l.$slots,"play",{isPlaying:N},void 0,!0)]),key:"1"}:void 0,l.$slots.next?{name:"next",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"next",{},void 0,!0)]),key:"2"}:void 0]),1032,["is-playing"])]),e.createElementVNode("div",Le,[e.createVNode(xe,{modelValue:i.value,"onUpdate:modelValue":y[0]||(y[0]=N=>i.value=N),"start-time":I.value,"end-time":k.value,interval:t.interval,"min-tick-spacing":t.minTickSpacing,"tick-label-mode":t.tickLabelMode,"format-tooltip":t.formatTooltip,onPlayingPause:V,onChange:z},null,8,["modelValue","start-time","end-time","interval","min-tick-spacing","tick-label-mode","format-tooltip"])]),e.createVNode($e,{modelValue:g.value,"onUpdate:modelValue":y[1]||(y[1]=N=>g.value=N),options:t.speedOptions},null,8,["modelValue","options"])]))}}),[["__scopeId","data-v-98cef505"]]);m.addHours=L,m.default=ue,m.defaultTooltipFormat=re,m.diffHours=Te,m.findNearestTickIndex=ce,m.findTickIndex=de,m.formatDayLabel=ie,m.formatHH=le,m.formatHHmm=ae,m.formatMD=K,m.getDateKey=q,m.getDayOfWeek=oe,m.getHour=ne,m.getNextMidnight=se,m.getWeekdayShort=j,m.toTimestamp=v,m.vue3TimePlaybar=ue,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(m,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],e):(m=typeof globalThis<"u"?globalThis:m||self,e(m.Vue3TimePlaybar={},m.Vue))})(this,(function(m,e){"use strict";const ge={class:"player-controls"},ye={class:"btn-group"},he=["title"],ve={key:0,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},ke={key:1,viewBox:"0 0 24 24",fill:"currentColor",stroke:"none"},Te=e.defineComponent({__name:"PlayerControls",props:{isPlaying:{type:Boolean}},emits:["toggle-play","prev","next"],setup(t){return(o,i)=>(e.openBlock(),e.createElementBlock("div",ge,[e.createElementVNode("div",ye,[e.createElementVNode("button",{class:"control-btn",onClick:i[0]||(i[0]=n=>o.$emit("prev")),title:"上一时刻"},[e.renderSlot(o.$slots,"prev",{},()=>[i[3]||(i[3]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"19 20 9 12 19 4 19 20"}),e.createElementVNode("line",{x1:"5",y1:"19",x2:"5",y2:"5"})],-1))],!0)]),e.createElementVNode("button",{class:"control-btn play-btn",onClick:i[1]||(i[1]=n=>o.$emit("toggle-play")),title:t.isPlaying?"暂停":"播放"},[e.renderSlot(o.$slots,"play",{isPlaying:t.isPlaying},()=>[t.isPlaying?(e.openBlock(),e.createElementBlock("svg",ke,[...i[5]||(i[5]=[e.createElementVNode("rect",{x:"6",y:"4",width:"4",height:"16",rx:"1"},null,-1),e.createElementVNode("rect",{x:"14",y:"4",width:"4",height:"16",rx:"1"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",ve,[...i[4]||(i[4]=[e.createElementVNode("polygon",{points:"5 3 19 12 5 21 5 3"},null,-1)])]))],!0)],8,he),e.createElementVNode("button",{class:"control-btn",onClick:i[2]||(i[2]=n=>o.$emit("next")),title:"下一时刻"},[e.renderSlot(o.$slots,"next",{},()=>[i[6]||(i[6]=e.createElementVNode("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[e.createElementVNode("polygon",{points:"5 4 15 12 5 20 5 4"}),e.createElementVNode("line",{x1:"19",y1:"5",x2:"19",y2:"19"})],-1))],!0)])])]))}}),A=(t,o)=>{const i=t.__vccOpts||t;for(const[n,u]of o)i[n]=u;return i},we=A(Te,[["__scopeId","data-v-55e12a8d"]]),Ve=["周日","周一","周二","周三","周四","周五","周六"];function T(t){if(typeof t=="number")return t;if(t instanceof Date)return t.getTime();const o=Date.parse(t);return Number.isNaN(o)?(console.warn(`[GTimePlayer] 无法解析时间: "${t}"`),0):o}function R(t,o=2){return String(t).padStart(o,"0")}function ie(t){return new Date(t).getHours()}function re(t){return new Date(t).getDay()}function j(t){return Ve[re(t)]??""}function se(t){return R(new Date(t).getHours())}function K(t){const o=new Date(t);return`${o.getMonth()+1}月${o.getDate()}日`}function ce(t){const o=new Date(t);return`${R(o.getHours())}:${R(o.getMinutes())}`}function de(t){return`${K(t)} ${j(t)} ${ce(t)}`}function q(t){const o=new Date(t);return`${o.getFullYear()}${R(o.getMonth()+1)}${R(o.getDate())}`}function ue(t){return`${K(t)} ${j(t)}`}function L(t,o){return t+o*36e5}function Ee(t,o){return(T(o)-T(t))/36e5}function me(t){const o=new Date(t);return o.setHours(24,0,0,0),o.getTime()}function Y(t,o){if(t.length===0)return-1;if(t.length===1)return 0;let i=0,n=t.length-1;if(o<=t[i])return i;if(o>=t[n])return n;for(;i<=n;){const u=i+n>>>1,g=t[u];if(g===o)return u;g<o?i=u+1:n=u-1}return i>=t.length?n:n<0||Math.abs(t[i]-o)<Math.abs(t[n]-o)?i:n}function Se(t,o){let i=0,n=t.length-1;for(;i<=n;){const u=i+n>>>1,g=t[u];if(g===o)return u;g<o?i=u+1:n=u-1}return-1}const be={key:0,class:"tick-label"},xe={key:1,class:"day-label"},Ne=35,De=35,Me=A(e.defineComponent({__name:"TimeTimeline",props:{modelValue:{},startTime:{},endTime:{},interval:{},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change","playing-pause"],setup(t,{emit:o}){const i=[2,8,14,20],n=t,u=o,g=e.useTemplateRef("timelineRef"),d=e.useTemplateRef("scrollRef"),I=e.useTemplateRef("innerRef"),V=e.ref(0),D=e.ref(0),r=e.ref(0);let h=!1,y=0,w=!1,x=!1,$=null;const E=e.ref(!1),P=e.computed(()=>{const a=T(n.startTime),c=T(n.endTime),s=c-a;if(s<=0)return[];const S=[];let p=a;for(;p<=c;){const M=(p-a)/s*100,N=ie(p),C=S.length===0,oe=q(p),le=C?null:q(S[S.length-1].time),G=!C&&le!==oe||C&&N===0;let _=!1;if(N===0)_=!0;else if(C){const H=me(p);(L(p,n.interval)>H||c<H)&&(_=!0)}const ae=N===0&&_?!1:n.tickLabelMode==="all"||i.includes(N);S.push({time:p,percent:M,label:se(p),showLabel:ae,dayLabel:ue(p),showDayLabel:_,isDayBoundary:G}),p=L(p,n.interval)}return S}),J=e.computed(()=>P.value.map(a=>a.time)),Q=e.computed(()=>n.minTickSpacing!==void 0?n.minTickSpacing:n.tickLabelMode==="major"?5:15),F=e.computed(()=>{const a=P.value.length;return a<2?V.value||0:(a-1)*Q.value}),B=e.computed(()=>F.value>V.value&&V.value>0),b=e.computed(()=>B.value?Ne:De),v=e.computed(()=>B.value?F.value:Math.max(0,V.value-b.value*2)),z=e.computed(()=>v.value+b.value*2),O=e.computed(()=>V.value&&B.value?z.value+"px":"100%"),U=e.computed(()=>({left:b.value+"px",width:v.value+"px"})),Z=e.computed(()=>({left:b.value+"px",width:v.value+"px"})),l=e.computed(()=>{const a=T(n.startTime),c=T(n.endTime),s=T(n.modelValue);return s<=a?0:s>=c?100:(s-a)/(c-a)*100}),f=e.computed(()=>({left:b.value+"px",width:l.value/100*v.value+"px"})),k=e.computed(()=>{const a=T(n.modelValue);return n.formatTooltip?n.formatTooltip(a):de(a)}),ee=e.computed(()=>b.value+l.value/100*v.value-r.value),He=e.computed(()=>ee.value>-50&&ee.value<V.value+50),Re=e.computed(()=>({transform:`translateX(${ee.value}px)`}));function X(){y&&(cancelAnimationFrame(y),y=0),w=!1}function Ie(){d.value&&(D.value=d.value.scrollLeft,w||(r.value=d.value.scrollLeft))}function ze(a){!d.value||!B.value||(d.value.scrollLeft+=a.deltaY||a.deltaX)}function W(a=!1){if(!B.value||!d.value||h)return;const c=b.value+l.value/100*v.value,s=V.value,S=z.value-s,p=Math.max(0,Math.min(c-s/2,S));r.value=p;const M=d.value;if(a||Math.abs(M.scrollLeft-p)<1){M.scrollLeft=p,D.value=p;return}X();const N=M.scrollLeft,C=p-N;w=!0;const oe=200,le=performance.now();function G(_){const ae=_-le,H=Math.min(ae/oe,1),pe=1-(1-H)*(1-H);M.scrollLeft=N+C*pe,D.value=M.scrollLeft,H<1?y=requestAnimationFrame(G):(y=0,w=!1)}y=requestAnimationFrame(G)}e.watch(l,()=>W()),e.watch(V,()=>W());function te(a){if(!d.value)return T(n.startTime);const c=d.value.getBoundingClientRect(),s=d.value.scrollLeft,p=a.clientX-c.left+s-b.value,M=Math.max(0,Math.min(p,v.value)),N=T(n.startTime),C=T(n.endTime);return N+(C-N)*(M/(v.value||1))}function We(a){const c=J.value;if(c.length===0)return{time:a,index:-1};const s=Y(c,a);return{time:c[s]??a,index:s}}function ne(a){const{time:c,index:s}=We(a);c!==T(n.modelValue)&&(u("update:modelValue",c),u("change",c,s))}function Ae(a){if(x){x=!1;return}ne(te(a))}function Fe(a){const c=a.clientX;x=!1,h=!0,X(),u("playing-pause");const s=p=>{Math.abs(p.clientX-c)>3&&(x=!0),ne(te(p))},S=()=>{h=!1,document.removeEventListener("mousemove",s),document.removeEventListener("mouseup",S),e.nextTick(()=>W())};document.addEventListener("mousemove",s),document.addEventListener("mouseup",S)}function Oe(a){h=!0,X(),x=!1,E.value=!0,document.body.style.cursor="grabbing",u("playing-pause");const c=S=>{x=!0,ne(te(S))},s=()=>{h=!1,E.value=!1,document.body.style.cursor="",document.removeEventListener("mousemove",c),document.removeEventListener("mouseup",s),e.nextTick(()=>W())};document.addEventListener("mousemove",c),document.addEventListener("mouseup",s)}return e.onMounted(()=>{d.value&&(V.value=d.value.clientWidth,$=new ResizeObserver(a=>{a[0]&&(V.value=a[0].contentRect.width)}),$.observe(d.value)),e.nextTick(()=>W())}),e.onUnmounted(()=>{X(),$==null||$.disconnect()}),(a,c)=>(e.openBlock(),e.createElementBlock("div",{class:"time-timeline",ref_key:"timelineRef",ref:g},[e.withDirectives(e.createElementVNode("div",{class:e.normalizeClass(["handle-group",{dragging:E.value}]),style:e.normalizeStyle(Re.value)},[e.createElementVNode("div",{class:"floating-tooltip",onMousedown:e.withModifiers(Oe,["prevent","stop"])},e.toDisplayString(k.value),33),c[0]||(c[0]=e.createElementVNode("div",{class:"handle-visual"},null,-1))],6),[[e.vShow,He.value]]),e.createElementVNode("div",{class:"scroll-container",ref_key:"scrollRef",ref:d,onScroll:Ie,onWheel:e.withModifiers(ze,["prevent"])},[e.createElementVNode("div",{class:"timeline-inner",ref_key:"innerRef",ref:I,style:e.normalizeStyle({width:O.value}),onMousedown:e.withModifiers(Fe,["prevent"]),onClick:Ae},[e.createElementVNode("div",{class:"track-bg",style:e.normalizeStyle(U.value)},null,4),e.createElementVNode("div",{class:"track-active",style:e.normalizeStyle(f.value)},null,4),e.createElementVNode("div",{class:"ticks-container",style:e.normalizeStyle(Z.value)},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(P.value,s=>(e.openBlock(),e.createElementBlock("div",{key:s.time,class:e.normalizeClass(["tick-item",{"is-day-boundary":s.isDayBoundary}]),style:e.normalizeStyle({left:s.percent+"%"})},[c[1]||(c[1]=e.createElementVNode("div",{class:"tick-mark"},null,-1)),s.showLabel?(e.openBlock(),e.createElementBlock("div",be,e.toDisplayString(s.label),1)):e.createCommentVNode("",!0),s.showDayLabel?(e.openBlock(),e.createElementBlock("div",xe,e.toDisplayString(s.dayLabel),1)):e.createCommentVNode("",!0)],6))),128))],4)],36)],544)],512))}}),[["__scopeId","data-v-0f78dcee"]]),$e={class:"speed-value"},Be=["onClick"],Ce=A(e.defineComponent({__name:"SpeedSelector",props:{modelValue:{},options:{}},emits:["update:modelValue"],setup(t,{emit:o}){const i=o,n=e.ref(!1),u=e.ref(!0),g=e.ref(null);function d(){if(!g.value)return;const r=g.value.getBoundingClientRect(),h=r.top,y=window.innerHeight-r.bottom;u.value=h>=y}function I(){n.value||d(),n.value=!n.value}function V(r){i("update:modelValue",r),n.value=!1}function D(r){g.value&&!g.value.contains(r.target)&&(n.value=!1)}return e.onMounted(()=>document.addEventListener("mousedown",D)),e.onUnmounted(()=>document.removeEventListener("mousedown",D)),(r,h)=>(e.openBlock(),e.createElementBlock("div",{class:"speed-selector",ref_key:"selectorRef",ref:g},[e.createElementVNode("div",{class:"speed-trigger",onClick:I},[e.createElementVNode("span",$e,e.toDisplayString(t.modelValue)+"x",1),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["arrow-icon",{open:n.value}]),viewBox:"0 0 12 12",fill:"currentColor"},[...h[0]||(h[0]=[e.createElementVNode("path",{d:"M2.5 4.5L6 8L9.5 4.5",stroke:"currentColor","stroke-width":"1.5",fill:"none","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))]),e.createVNode(e.Transition,{name:u.value?"dropdown-up":"dropdown-down"},{default:e.withCtx(()=>[n.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["speed-dropdown",u.value?"is-up":"is-down"])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,y=>(e.openBlock(),e.createElementBlock("div",{key:y,class:e.normalizeClass(["speed-option",{active:y===t.modelValue}]),onClick:w=>V(y)},e.toDisplayString(y)+"x ",11,Be))),128))],2)):e.createCommentVNode("",!0)]),_:1},8,["name"])],512))}}),[["__scopeId","data-v-30c5e152"]]),Le={class:"g-time-player"},Pe={class:"controls-wrapper"},_e={class:"timeline-wrapper"},fe=A(e.defineComponent({__name:"index",props:{modelValue:{},startTime:{},endTime:{},interval:{default:1},playInterval:{default:1e3},speed:{default:1},speedOptions:{default:()=>[.5,1,2,3]},minTickSpacing:{},tickLabelMode:{default:"all"},formatTooltip:{}},emits:["update:modelValue","change"],setup(t,{expose:o,emit:i}){const n=t,u=i,g=e.computed(()=>T(n.startTime)),d=e.computed(()=>T(n.endTime)),I=e.computed(()=>g.value),V=e.computed(()=>d.value),D=e.computed(()=>{const l=[];let f=g.value;for(;f<=d.value;)l.push(f),f=L(f,n.interval);return l}),r=e.ref(P(n.modelValue??n.startTime)),h=e.ref(!1),y=e.ref(n.speed);let w=null,x=r.value;const $=e.computed(()=>n.playInterval/y.value);e.watch(()=>n.speed,l=>{y.value=l});function E(l){return Math.max(g.value,Math.min(l,d.value))}function P(l){return E(T(l))}function J(l){const f=D.value;if(!f.length)return-1;const k=Y(f,E(l));return Math.max(0,Math.min(k,f.length-1))}function Q(l,f){const k=E(l);k!==x&&(x=k,u("update:modelValue",k),u("change",{time:k,index:J(k)}))}function F(l,f){const k=E(l);u("change",{time:k,index:Math.max(0,Math.min(f,D.value.length-1))})}e.watch(()=>n.modelValue,l=>{l!==void 0&&!h.value&&(r.value=P(l))}),e.watch(g,()=>{v(),r.value=g.value,x=r.value}),e.watch(d,l=>{r.value>l&&(r.value=l,v())}),e.watch(r,l=>{const f=E(l);if(f!==l){r.value=f;return}Q(f),f>=d.value&&v()});function B(){h.value?v():b()}function b(){r.value>=d.value&&(r.value=g.value),h.value=!0,w&&clearInterval(w),w=setInterval(z,$.value)}function v(){h.value=!1,w&&(clearInterval(w),w=null)}e.watch($,l=>{h.value&&(w&&clearInterval(w),w=setInterval(z,l))});function z(){const l=L(r.value,n.interval);if(l>d.value){r.value=E(d.value),v();return}r.value=E(l)}function O(){const l=L(r.value,-n.interval);r.value=E(l)}function U(){const l=L(r.value,n.interval);r.value=E(l)}function Z(l){r.value=P(l)}return o({play:b,pause:v,togglePlay:B,prev:O,next:U,seekTo:Z,isPlaying:h,currentTime:r,speedMultiplier:y}),e.onUnmounted(()=>v()),(l,f)=>(e.openBlock(),e.createElementBlock("div",Le,[e.createElementVNode("div",Pe,[e.createVNode(we,{"is-playing":h.value,onTogglePlay:B,onPrev:O,onNext:U},e.createSlots({_:2},[l.$slots.prev?{name:"prev",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"prev",{},void 0,!0)]),key:"0"}:void 0,l.$slots.play?{name:"play",fn:e.withCtx(({isPlaying:k})=>[e.renderSlot(l.$slots,"play",{isPlaying:k},void 0,!0)]),key:"1"}:void 0,l.$slots.next?{name:"next",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"next",{},void 0,!0)]),key:"2"}:void 0]),1032,["is-playing"])]),e.createElementVNode("div",_e,[e.createVNode(Me,{modelValue:r.value,"onUpdate:modelValue":f[0]||(f[0]=k=>r.value=k),"start-time":I.value,"end-time":V.value,interval:t.interval,"min-tick-spacing":t.minTickSpacing,"tick-label-mode":t.tickLabelMode,"format-tooltip":t.formatTooltip,onPlayingPause:v,onChange:F},null,8,["modelValue","start-time","end-time","interval","min-tick-spacing","tick-label-mode","format-tooltip"])]),e.createVNode(Ce,{modelValue:y.value,"onUpdate:modelValue":f[1]||(f[1]=k=>y.value=k),options:t.speedOptions},null,8,["modelValue","options"])]))}}),[["__scopeId","data-v-55b5dfa2"]]);m.addHours=L,m.default=fe,m.defaultTooltipFormat=de,m.diffHours=Ee,m.findNearestTickIndex=Y,m.findTickIndex=Se,m.formatDayLabel=ue,m.formatHH=se,m.formatHHmm=ce,m.formatMD=K,m.getDateKey=q,m.getDayOfWeek=re,m.getHour=ie,m.getNextMidnight=me,m.getWeekdayShort=j,m.toTimestamp=T,m.vue3TimePlaybar=fe,Object.defineProperties(m,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));