UNPKG

@jxstjh/jhvideo

Version:

HTML5 jhvideo base on MPEG2-TS Stream Player

261 lines 25.4 kB
var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; (function (m, d) { typeof exports == "object" && typeof module < "u" ? d(exports) : typeof define == "function" && define.amd ? define(["exports"], d) : (m = typeof globalThis < "u" ? globalThis : m || self, d(m.$timeline = {})); })(this, function (m) { "use strict"; var _a; var At = Object.defineProperty; var Pt = function (m, d, b) { return d in m ? At(m, d, { enumerable: !0, configurable: !0, writable: !0, value: b }) : m[d] = b; }; var st = function (m, d, b) { return (Pt(m, typeof d != "symbol" ? d + "" : d, b), b); }, Tt = function (m, d, b) { if (!d.has(m)) throw TypeError("Cannot " + b); }; var r = function (m, d, b) { return (Tt(m, d, "read from private field"), b ? b.call(m) : d.get(m)); }, C = function (m, d, b) { if (d.has(m)) throw TypeError("Cannot add the same private member more than once"); d instanceof WeakSet ? d.add(m) : d.set(m, b); }, O = function (m, d, b, nt) { return (Tt(m, d, "write to private field"), nt ? nt.call(m, b) : d.set(m, b), b); }; var Z = function (m, d, b) { return (Tt(m, d, "access private method"), b); }; var U, F, W, $, R, j, P, at, xt, ot, Yt, ht, Ft, ct, Ct, ut, Ht, lt, Q, q, K, Dt; function d(f) { return { all: f = f || new Map, on: function (i, n) { var o = f.get(i); o ? o.push(n) : f.set(i, [n]); }, off: function (i, n) { var o = f.get(i); o && (n ? o.splice(o.indexOf(n) >>> 0, 1) : f.set(i, [])); }, emit: function (i, n) { var o = f.get(i); o && o.slice().map(function (l) { l(n); }), (o = f.get("*")) && o.slice().map(function (l) { l(i, n); }); } }; } var b = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}; function nt(f) { return f && f.__esModule && Object.prototype.hasOwnProperty.call(f, "default") ? f.default : f; } var wt = { exports: {} }; (function (f, i) { (function (n, o) { f.exports = o(); })(b, function () { var n = 1e3, o = 6e4, l = 36e5, p = "millisecond", v = "second", D = "minute", T = "hour", S = "day", H = "week", w = "month", z = "quarter", _ = "year", N = "date", ft = "Invalid Date", pt = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/, vt = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g, mt = { name: "en", weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"), ordinal: function (h) { var s = ["th", "st", "nd", "rd"], t = h % 100; return "[" + h + (s[(t - 20) % 10] || s[t] || s[0]) + "]"; } }, tt = function (h, s, t) { var a = String(h); return !a || a.length >= s ? h : "" + Array(s + 1 - a.length).join(t) + h; }, V = { s: tt, z: function (h) { var s = -h.utcOffset(), t = Math.abs(s), a = Math.floor(t / 60), e = t % 60; return (s <= 0 ? "+" : "-") + tt(a, 2, "0") + ":" + tt(e, 2, "0"); }, m: function h(s, t) { if (s.date() < t.date()) return -h(t, s); var a = 12 * (t.year() - s.year()) + (t.month() - s.month()), e = s.clone().add(a, w), c = t - e < 0, u = s.clone().add(a + (c ? -1 : 1), w); return +(-(a + (t - e) / (c ? e - u : u - e)) || 0); }, a: function (h) { return h < 0 ? Math.ceil(h) || 0 : Math.floor(h); }, p: function (h) { return { M: w, y: _, w: H, d: S, D: N, h: T, m: D, s: v, ms: p, Q: z }[h] || String(h || "").toLowerCase().replace(/s$/, ""); }, u: function (h) { return h === void 0; } }, I = "en", A = {}; A[I] = mt; var bt = "$isDayjsObject", Mt = function (h) { return h instanceof gt || !(!h || !h[bt]); }, dt = function h(s, t, a) { var e; if (!s) return I; if (typeof s == "string") { var c = s.toLowerCase(); A[c] && (e = c), t && (A[c] = t, e = c); var u = s.split("-"); if (!e && u.length > 1) return h(u[0]); } else { var M = s.name; A[M] = s, e = M; } return !a && e && (I = e), e || !a && I; }, x = function (h, s) { if (Mt(h)) return h.clone(); var t = typeof s == "object" ? s : {}; return t.date = h, t.args = arguments, new gt(t); }, g = V; g.l = dt, g.i = Mt, g.w = function (h, s) { return x(h, { locale: s.$L, utc: s.$u, x: s.$x, $offset: s.$offset }); }; var gt = function () { function h(t) { this.$L = dt(t.locale, null, !0), this.parse(t), this.$x = this.$x || t.x || {}, this[bt] = !0; } var s = h.prototype; return s.parse = function (t) { this.$d = function (a) { var e = a.date, c = a.utc; if (e === null) return new Date(NaN); if (g.u(e)) return new Date; if (e instanceof Date) return new Date(e); if (typeof e == "string" && !/Z$/i.test(e)) { var u = e.match(pt); if (u) { var M = u[2] - 1 || 0, y = (u[7] || "0").substring(0, 3); return c ? new Date(Date.UTC(u[1], M, u[3] || 1, u[4] || 0, u[5] || 0, u[6] || 0, y)) : new Date(u[1], M, u[3] || 1, u[4] || 0, u[5] || 0, u[6] || 0, y); } } return new Date(e); }(t), this.init(); }, s.init = function () { var t = this.$d; this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds(); }, s.$utils = function () { return g; }, s.isValid = function () { return this.$d.toString() !== ft; }, s.isSame = function (t, a) { var e = x(t); return this.startOf(a) <= e && e <= this.endOf(a); }, s.isAfter = function (t, a) { return x(t) < this.startOf(a); }, s.isBefore = function (t, a) { return this.endOf(a) < x(t); }, s.$g = function (t, a, e) { return g.u(t) ? this[a] : this.set(e, t); }, s.unix = function () { return Math.floor(this.valueOf() / 1e3); }, s.valueOf = function () { return this.$d.getTime(); }, s.startOf = function (t, a) { var e = this, c = !!g.u(a) || a, u = g.p(t), M = function (J, E) { var X = g.w(e.$u ? Date.UTC(e.$y, E, J) : new Date(e.$y, E, J), e); return c ? X : X.endOf(S); }, y = function (J, E) { return g.w(e.toDate()[J].apply(e.toDate("s"), (c ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(E)), e); }, Y = this.$W, L = this.$M, k = this.$D, G = "set" + (this.$u ? "UTC" : ""); switch (u) { case _: return c ? M(1, 0) : M(31, 11); case w: return c ? M(1, L) : M(0, L + 1); case H: var B = this.$locale().weekStart || 0, et = (Y < B ? Y + 7 : Y) - B; return M(c ? k - et : k + (6 - et), L); case S: case N: return y(G + "Hours", 0); case T: return y(G + "Minutes", 1); case D: return y(G + "Seconds", 2); case v: return y(G + "Milliseconds", 3); default: return this.clone(); } }, s.endOf = function (t) { return this.startOf(t, !1); }, s.$set = function (t, a) { var e, c = g.p(t), u = "set" + (this.$u ? "UTC" : ""), M = (e = {}, e[S] = u + "Date", e[N] = u + "Date", e[w] = u + "Month", e[_] = u + "FullYear", e[T] = u + "Hours", e[D] = u + "Minutes", e[v] = u + "Seconds", e[p] = u + "Milliseconds", e)[c], y = c === S ? this.$D + (a - this.$W) : a; if (c === w || c === _) { var Y = this.clone().set(N, 1); Y.$d[M](y), Y.init(), this.$d = Y.set(N, Math.min(this.$D, Y.daysInMonth())).$d; } else M && this.$d[M](y); return this.init(), this; }, s.set = function (t, a) { return this.clone().$set(t, a); }, s.get = function (t) { return this[g.p(t)](); }, s.add = function (t, a) { var e, c = this; t = Number(t); var u = g.p(a), M = function (L) { var k = x(c); return g.w(k.date(k.date() + Math.round(L * t)), c); }; if (u === w) return this.set(w, this.$M + t); if (u === _) return this.set(_, this.$y + t); if (u === S) return M(1); if (u === H) return M(7); var y = (e = {}, e[D] = o, e[T] = l, e[v] = n, e)[u] || 1, Y = this.$d.getTime() + t * y; return g.w(Y, this); }, s.subtract = function (t, a) { return this.add(-1 * t, a); }, s.format = function (t) { var a = this, e = this.$locale(); if (!this.isValid()) return e.invalidDate || ft; var c = t || "YYYY-MM-DDTHH:mm:ssZ", u = g.z(this), M = this.$H, y = this.$m, Y = this.$M, L = e.weekdays, k = e.months, G = e.meridiem, B = function (E, X, it, $t) { return E && (E[X] || E(a, c)) || it[X].slice(0, $t); }, et = function (E) { return g.s(M % 12 || 12, E, "0"); }, J = G || function (E, X, it) { var $t = E < 12 ? "AM" : "PM"; return it ? $t.toLowerCase() : $t; }; return c.replace(vt, function (E, X) { return X || function (it) { switch (it) { case "YY": return String(a.$y).slice(-2); case "YYYY": return g.s(a.$y, 4, "0"); case "M": return Y + 1; case "MM": return g.s(Y + 1, 2, "0"); case "MMM": return B(e.monthsShort, Y, k, 3); case "MMMM": return B(k, Y); case "D": return a.$D; case "DD": return g.s(a.$D, 2, "0"); case "d": return String(a.$W); case "dd": return B(e.weekdaysMin, a.$W, L, 2); case "ddd": return B(e.weekdaysShort, a.$W, L, 3); case "dddd": return L[a.$W]; case "H": return String(M); case "HH": return g.s(M, 2, "0"); case "h": return et(1); case "hh": return et(2); case "a": return J(M, y, !0); case "A": return J(M, y, !1); case "m": return String(y); case "mm": return g.s(y, 2, "0"); case "s": return String(a.$s); case "ss": return g.s(a.$s, 2, "0"); case "SSS": return g.s(a.$ms, 3, "0"); case "Z": return u; } return null; }(E) || u.replace(":", ""); }); }, s.utcOffset = function () { return 15 * -Math.round(this.$d.getTimezoneOffset() / 15); }, s.diff = function (t, a, e) { var c, u = this, M = g.p(a), y = x(t), Y = (y.utcOffset() - this.utcOffset()) * o, L = this - y, k = function () { return g.m(u, y); }; switch (M) { case _: c = k() / 12; break; case w: c = k(); break; case z: c = k() / 3; break; case H: c = (L - Y) / 6048e5; break; case S: c = (L - Y) / 864e5; break; case T: c = L / l; break; case D: c = L / o; break; case v: c = L / n; break; default: c = L; } return e ? c : g.a(c); }, s.daysInMonth = function () { return this.endOf(w).$D; }, s.$locale = function () { return A[this.$L]; }, s.locale = function (t, a) { if (!t) return this.$L; var e = this.clone(), c = dt(t, a, !0); return c && (e.$L = c), e; }, s.clone = function () { return g.w(this.$d, this); }, s.toDate = function () { return new Date(this.valueOf()); }, s.toJSON = function () { return this.isValid() ? this.toISOString() : null; }, s.toISOString = function () { return this.$d.toISOString(); }, s.toString = function () { return this.$d.toUTCString(); }, h; }(), St = gt.prototype; return x.prototype = St, [["$ms", p], ["$s", v], ["$m", D], ["$H", T], ["$W", S], ["$M", w], ["$y", _], ["$D", N]].forEach(function (h) { St[h[1]] = function (s) { return this.$g(s, h[0], h[1]); }; }), x.extend = function (h, s) { return h.$i || (h(s, gt, x), h.$i = !0), x; }, x.locale = dt, x.isDayjs = Mt, x.unix = function (h) { return x(1e3 * h); }, x.en = A[I], x.Ls = A, x.p = {}, x; }); })(wt); var Lt = wt.exports; var Ot = nt(Lt), rt = function (f, i) { if (i === void 0) { i = "MM/DD HH:mm"; } return Ot(f).format(i); }, yt = function (f, i) { var n, o = 0; return function () { var l = []; for (var _i = 0; _i < arguments.length; _i++) { l[_i] = arguments[_i]; } var p = Date.now(), v = p - o; !o || v >= i ? (o = p, f.apply(void 0, l)) : n || (n = setTimeout(function () { o = p, f.apply(void 0, l), n = null; }, i - v)); }; }, _t = function (f, i) { var n = document.createElement("canvas"); n.width = n.height = 1; var o = n.getContext("2d"); o.fillStyle = f, o.fillRect(0, 0, 1, 1); var l = o.getImageData(0, 0, 1, 1).data; return "rgba(".concat(l[0], ", ").concat(l[1], ", ").concat(l[2], ", ").concat(i, ")"); }, Et = function (_a) { var f = _a.xCenterPoint, i = _a.cfg, n = _a.timePerPixel, o = _a.timeSpacing, l = _a.currentTime, p = _a.$canvas, v = _a.screenScaleCount, D = _a.scaleHeight, T = _a.startTime, S = _a.drawLine, H = _a.drawText, w = _a.drawArea; var z = function (_a) { var N = _a.space, ft = _a.scaleTimeFormat, pt = _a.bgTimeFormat, vt = _a.pointerTimeFormat; H({ x: p.width - f / 10, y: 6, text: rt(l, pt), fontSize: "".concat(p.height - 5, "px"), align: "right", baseLine: "top", color: i.bgTextColor }); var mt = T % o, tt = mt / n; for (var V = 0; V < v; V++) { var I = V * i.scaleSpacing - tt - i.pointerWidth / 2, A = T + V * o - mt; if (A % (o * N) === 0) { S({ x: I, y: D.long }), H({ x: I, y: p.height - D.long - 5, text: rt(A, ft), baseLine: "bottom" }); continue; } S({ x: I, y: D.short }); } S({ x: f - i.pointerWidth / 2, y: p.height, width: i.pointerWidth, color: i.pointerColor }), w({ startX: f - i.pointerDisplayWidth / 2, startY: 4, endX: f + i.pointerDisplayWidth / 2, endY: 4 + i.pointerDisplayHeight, bgColor: i.pointerColor }), H({ x: f, y: i.pointerDisplayHeight / 2 + 5, text: rt(l, vt), align: "center", baseLine: "middle" }); }, _ = i.thresholdsConfig[o]; _ && z({ space: _.space, scaleTimeFormat: _.scaleTimeFormat, bgTimeFormat: _.bgTimeFormat, pointerTimeFormat: _.pointerTimeFormat }); }, Wt = { fill: !0, width: 1e3, height: 60, bgColor: "rgba(0,0,0,0.5)", textColor: "#ffffff", fontFamily: "Arial", scaleColor: "#ffffff", scaleSpacing: 7, areaBgColor: "#ffffff55", pointerColor: "#00aeec", pointerWidth: 3, pointerDisplayWidth: 100, pointerDisplayHeight: 14, fps: 60, zoom: 3, isDrawScale: !1, timeNumber: 600, timeSpacingList: [5e3, 1e4, 6e4, 6e5, 36e5], thresholdsConfig: { 10: { scaleTimeFormat: "mm:ss:SSS", bgTimeFormat: "YYYY/MM/DD", pointerTimeFormat: "HH:mm:ss:SSS", space: 10 }, 100: { scaleTimeFormat: "mm:ss", bgTimeFormat: "YYYY/MM/DD", pointerTimeFormat: "HH:mm:ss:SSS", space: 10 }, 5e3: { scaleTimeFormat: "mm:ss", bgTimeFormat: "YYYY/MM/DD", pointerTimeFormat: "HH:mm:ss", space: 10 }, 1e4: { scaleTimeFormat: "HH:mm:ss", bgTimeFormat: "YYYY/MM/DD", pointerTimeFormat: "HH:mm:ss", space: 12 }, 6e4: { scaleTimeFormat: "HH:mm", bgTimeFormat: "YYYY/MM/DD", pointerTimeFormat: "HH:mm:ss", space: 10 }, 6e5: { scaleTimeFormat: "HH:mm", bgTimeFormat: "YYYY/MM/DD", pointerTimeFormat: "HH:mm:ss", space: 10 }, 36e5: { scaleTimeFormat: "MM/DD HH:mm", bgTimeFormat: "YYYY/MM", pointerTimeFormat: "MM/DD HH:mm", space: 12 }, 864e5: { scaleTimeFormat: "MM/DD HH:mm", bgTimeFormat: "YYYY/MM", pointerTimeFormat: "YYYY/MM/DD HH:mm", space: 12 }, 6048e5: { scaleTimeFormat: "YYYY/MM/DD", bgTimeFormat: "YYYY", pointerTimeFormat: "YYYY/MM/DD", space: 10 } } }; var kt = /** @class */ (function () { function kt(i, n) { var _this = this; C(this, at); C(this, ot); C(this, ht); C(this, ct); C(this, ut); C(this, K); st(this, "$canvas"); st(this, "$canvasParent"); st(this, "ctx"); st(this, "cfg"); C(this, U, d()); C(this, F, 0); C(this, W, void 0); C(this, $, void 0); C(this, R, void 0); C(this, j, !1); C(this, P, null); C(this, lt, function (_a) { var i = _a.x, n = _a.y, _b = _a.width, o = _b === void 0 ? 1 : _b, _c = _a.color, l = _c === void 0 ? _this.cfg.scaleColor : _c; _this.ctx.beginPath(), _this.ctx.moveTo(i, _this.$canvas.height), _this.ctx.lineTo(i, _this.$canvas.height - n), _this.ctx.closePath(), _this.ctx.strokeStyle = l, _this.ctx.lineWidth = o, _this.ctx.stroke(); }); C(this, Q, function (_a) { var i = _a.x, n = _a.y, o = _a.text, _b = _a.color, l = _b === void 0 ? _this.cfg.textColor : _b, _c = _a.fontSize, p = _c === void 0 ? "11px" : _c, _d = _a.align, v = _d === void 0 ? "center" : _d, _e = _a.baseLine, D = _e === void 0 ? "alphabetic" : _e; _this.ctx.beginPath(), _this.ctx.font = "".concat(p, " ").concat(_this.cfg.fontFamily), _this.ctx.fillStyle = l, _this.ctx.textAlign = v, _this.ctx.textBaseline = D, _this.ctx.fillText(o, i, n); }); C(this, q, function (_a) { var i = _a.startX, n = _a.startY, o = _a.endX, l = _a.endY, p = _a.bgColor; _this.ctx.beginPath(), _this.ctx.rect(i, n, o - i, l - n), _this.ctx.fillStyle = p, _this.ctx.fill(); }); if (!i) throw new Error("canvas Element Or Element ID is required!"); typeof i == "string" ? this.$canvas = document.querySelector(i) : this.$canvas = i, this.ctx = this.$canvas.getContext("2d"), this.cfg = __assign(__assign({}, Wt), n), n != null && n.pointColor && (this.cfg.pointerColor = n.pointColor), n != null && n.pointWidth && (this.cfg.pointerWidth = n.pointWidth); var _a = this.cfg, o = _a.fill, l = _a.width, p = _a.height, v = _a.zoom, D = _a.timeSpacingList, T = _a.scaleHeight, S = _a.textColor, H = _a.bgTextColor; if (H || (this.cfg.bgTextColor = _t(S, .18)), v < 0 || v >= D.length || v % 1 !== 0) throw new Error("zoom must be 0 ~ ".concat(D.length - 1, ", and must be an integer")); if (o) { var w = this.$canvas.parentElement; this.$canvasParent = w, this.$canvas.width = w.clientWidth, this.$canvas.height = w.clientHeight, new ResizeObserver(yt(Z(this, ht, Ft).bind(this), 200)).observe(w); } else this.$canvas.width = l, this.$canvas.height = p; O(this, $, D[v]), T != null && T.long && (T != null && T.short) ? O(this, R, T) : O(this, R, { long: this.$canvas.height / 3, medium: this.$canvas.height / 6, short: this.$canvas.height / 10 }), this.draw(), this.$canvas.addEventListener("wheel", Z(this, ot, Yt).bind(this), { passive: !1 }), this.$canvas.addEventListener("mousedown", Z(this, at, xt).bind(this)); } kt.prototype.setTimeMove = function (_a, o) { var i = _a.timestamp, n = _a.direction; if (o === void 0) { o = !0; } if (!r(this, P) && !r(this, j)) { var l = i; o || (l = n ? r(this, F) + i : r(this, F) - i), this.draw({ currentTime: l, areas: r(this, W), _privateFlag: !0 }); } }; kt.prototype.draw = function (_a) { var _this = this; var _b = _a === void 0 ? {} : _a, i = _b.currentTime, n = _b.areas, o = _b._privateFlag; if (r(this, j) && !o) return; O(this, F, i || Date.now()), O(this, W, n || []); var l = Math.ceil(this.$canvas.width / this.cfg.scaleSpacing), p = l * r(this, $), v = r(this, F) - p / 2, D = r(this, F) + p / 2, T = this.$canvas.width / 2, S = p / this.$canvas.width; Z(this, ct, Ct).call(this), r(this, q).call(this, { startX: 0, startY: 0, endX: this.$canvas.width, endY: this.$canvas.height, bgColor: this.cfg.bgColor }), r(this, W).forEach(function (H) { var w = H.startTime <= v ? 0 : Math.round((H.startTime - v) / S), z = H.endTime >= D ? _this.$canvas.width : Math.round((H.endTime - v) / S); w < _this.$canvas.width && z > 0 && r(_this, q).call(_this, { startX: w, startY: 0, endX: z, endY: _this.$canvas.height, bgColor: H.bgColor || _this.cfg.areaBgColor }); }), Et.bind(this)({ xCenterPoint: T, screenScaleCount: l, startTime: v, timePerPixel: S, scaleHeight: r(this, R), timeSpacing: r(this, $), currentTime: r(this, F), $canvas: this.$canvas, cfg: this.cfg, drawLine: r(this, lt).bind(this), drawText: r(this, Q).bind(this), drawArea: r(this, q).bind(this) }), this.cfg.isDrawScale && Z(this, ut, Ht).call(this); }; kt.prototype.getCurrentTime = function () { return r(this, F); }; kt.prototype.setZoom = function (i) { var _this = this; if (i === void 0) { i = !0; } var n = this.cfg.timeSpacingList.findIndex(function (o) { return o === r(_this, $); }); return n > 0 && i && (O(this, $, this.cfg.timeSpacingList[n - 1]), this.draw({ currentTime: r(this, F), areas: r(this, W), _privateFlag: !0 })), n < this.cfg.timeSpacingList.length - 1 && !i && (O(this, $, this.cfg.timeSpacingList[n + 1]), this.draw({ currentTime: r(this, F), areas: r(this, W), _privateFlag: !0 })), r(this, $); }; kt.prototype.clear = function () { this.ctx && this.ctx.clearRect(0, 0, this.$canvas.width, this.$canvas.height); }; kt.prototype.on = function (i, n) { r(this, U).on(i, n); }; kt.prototype.off = function (i, n) { r(this, U).off(i, n); }; return kt; }()); U = new WeakMap, F = new WeakMap, W = new WeakMap, $ = new WeakMap, R = new WeakMap, j = new WeakMap, P = new WeakMap, at = new WeakSet, xt = function (i) { var _this = this; O(this, j, !0); var n = 0, o = r(this, F); var l = yt(function (_a) { var D = _a.offsetX; if (!r(_this, j)) return; var T = D - i.offsetX; o = Math.round(r(_this, F) - r(_this, $) / _this.cfg.scaleSpacing * (T - n)), n = T, _this.draw({ currentTime: o, areas: r(_this, W), _privateFlag: !0 }); }, 1e3 / this.cfg.fps), p = function (_a) { var D = _a.offsetX, T = _a.offsetY; (D < 3 || D > _this.$canvas.width - 3 || T < 3 || T > _this.$canvas.height - 3) && (_this.$canvas.removeEventListener("mousemove", l), _this.$canvas.removeEventListener("mousemove", p)); }, v = function () { _this.$canvas.removeEventListener("mousemove", l), _this.$canvas.removeEventListener("mousemove", p), document.removeEventListener("mouseup", v), O(_this, j, !1), r(_this, P) && (clearTimeout(r(_this, P)), O(_this, P, null)), O(_this, P, setTimeout(function () { Z(_this, K, Dt).call(_this, "dragged", o), O(_this, P, null); }, _this.cfg.timeNumber)); }; this.$canvas.addEventListener("mousemove", l), this.$canvas.addEventListener("mousemove", p), document.addEventListener("mouseup", v); }, ot = new WeakSet, Yt = function (i) { var _this = this; i.preventDefault(); var n = this.cfg.timeSpacingList.findIndex(function (o) { return o === r(_this, $); }); i.deltaY < 0 && n > 0 ? (O(this, $, this.cfg.timeSpacingList[n - 1]), this.draw({ currentTime: r(this, F), areas: r(this, W), _privateFlag: !0 })) : i.deltaY > 0 && n < this.cfg.timeSpacingList.length - 1 && (O(this, $, this.cfg.timeSpacingList[n + 1]), this.draw({ currentTime: r(this, F), areas: r(this, W), _privateFlag: !0 })), Z(this, K, Dt).call(this, "zoom", r(this, $)); }, ht = new WeakSet, Ft = function () { this.$canvasParent && (this.$canvas.width = this.$canvasParent.clientWidth, this.$canvas.height = this.$canvasParent.clientHeight, this.cfg.scaleHeight || O(this, R, { long: this.$canvas.height / 3, medium: this.$canvas.height / 6, short: this.$canvas.height / 10 }), this.draw({ currentTime: r(this, F), areas: r(this, W) })); }, ct = new WeakSet, Ct = function () { this.ctx.clearRect(0, 0, this.$canvas.width, this.$canvas.height); }, ut = new WeakSet, Ht = function () { var _this = this; var i = function () { return r(_this, $) < 1e3 ? "".concat(r(_this, $), "ms") : r(_this, $) < 6e4 ? "".concat(Math.round(r(_this, $) / 100) / 10, "sec") : r(_this, $) < 36e5 ? "".concat(Math.round(r(_this, $) / 100 / 60) / 10, "min") : r(_this, $) < 864e5 ? "".concat(Math.round(r(_this, $) / 100 / 60 / 60) / 10, "hours") : r(_this, $) < 6048e5 ? "".concat(Math.round(r(_this, $) / 100 / 60 / 60 / 24) / 10, "days") : "".concat(Math.round(r(_this, $) / 100 / 60 / 60 / 24 / 7) / 10, "weeks"); }; r(this, Q).call(this, { x: this.cfg.scaleSpacing + 12, y: 9, text: i(), align: "left", baseLine: "middle" }), this.ctx.beginPath(), this.ctx.moveTo(5, 6), this.ctx.lineTo(5, 10), this.ctx.lineTo(this.cfg.scaleSpacing + 6, 10), this.ctx.lineTo(this.cfg.scaleSpacing + 6, 6), this.ctx.strokeStyle = this.cfg.scaleColor, this.ctx.lineWidth = 1.5, this.ctx.stroke(); }, lt = new WeakMap, Q = new WeakMap, q = new WeakMap, K = new WeakSet, Dt = function () { var _a; var i = []; for (var _i = 0; _i < arguments.length; _i++) { i[_i] = arguments[_i]; } (_a = r(this, U)).emit.apply(_a, i); }, m.default = kt, m.format = rt, Object.defineProperties(m, (_a = { __esModule: { value: !0 } }, _a[Symbol.toStringTag] = { value: "Module" }, _a)); }); //# sourceMappingURL=timeline.umd.js.map