UNPKG

vue3-interactjs

Version:

interactjs component for Vue3

929 lines 141 kB
import { defineComponent as Wr, ref as In, onMounted as Ur, watchEffect as Hr, onBeforeUnmount as $r, onUnmounted as Kr, createBlock as Nr, openBlock as Jr, resolveDynamicComponent as Qr, withCtx as Zr, renderSlot as ei } from "vue"; const wt = [ "dragstart", "dragmove", "draginertiastart", "dragend" ], Et = [ "resizestart", "resizemove", "resizeinertiastart", "resizeend" ], Tt = [ "dropactivate", "dropdeactivate", "dragenter", "dragleave", "dropmove", "drop" ], _t = ["gesturestart", "gesturemove", "gestureend"], St = [ "down", "move", "up", "cancel", "tap", "doubletap", "hold" ], We = /* @__PURE__ */ new WeakMap(); function Se(O, F, X) { let D = We.get(O); D || (D = /* @__PURE__ */ new Map(), We.set(O, D)), F.forEach((P) => { if (D.has(P)) return; const I = (...se) => X(P, ...se); D.set(P, I), O.on(P, I); }); } function Oe(O, F) { const X = We.get(O); X && (F.forEach((D) => { const P = X.get(D); P && (O.off(D, P), X.delete(D)); }), X.size === 0 && We.delete(O)); } function ti(O, F) { return { enablePointer: () => Se(O.value, St, F), disablePointer: () => Oe(O.value, St), enableDrag: () => Se(O.value, wt, F), disableDrag: () => Oe(O.value, wt), enableDrop: () => Se(O.value, Tt, F), disableDrop: () => Oe(O.value, Tt), enableResize: () => Se(O.value, Et, F), disableResize: () => Oe(O.value, Et), enableGesture: () => Se(O.value, _t, F), disableGesture: () => Oe(O.value, _t) }; } function ni(O) { return O && O.__esModule && Object.prototype.hasOwnProperty.call(O, "default") ? O.default : O; } var Pe = { exports: {} }, ri = Pe.exports, Mn; function ii() { return Mn || (Mn = 1, function(O, F) { (function(X, D) { O.exports = D(); })(ri, function() { function X(t, e) { var n = Object.keys(t); if (Object.getOwnPropertySymbols) { var r = Object.getOwnPropertySymbols(t); e && (r = r.filter(function(i) { return Object.getOwnPropertyDescriptor(t, i).enumerable; })), n.push.apply(n, r); } return n; } function D(t) { for (var e = 1; e < arguments.length; e++) { var n = arguments[e] != null ? arguments[e] : {}; e % 2 ? X(Object(n), !0).forEach(function(r) { Ue(t, r, n[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(n)) : X(Object(n)).forEach(function(r) { Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(n, r)); }); } return t; } function P(t) { return P = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) { return typeof e; } : function(e) { return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e; }, P(t); } function I(t, e) { if (!(t instanceof e)) throw new TypeError("Cannot call a class as a function"); } function se(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; r.enumerable = r.enumerable || !1, r.configurable = !0, "value" in r && (r.writable = !0), Object.defineProperty(t, Ot(r.key), r); } } function k(t, e, n) { return e && se(t.prototype, e), Object.defineProperty(t, "prototype", { writable: !1 }), t; } function Ue(t, e, n) { return (e = Ot(e)) in t ? Object.defineProperty(t, e, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : t[e] = n, t; } function te(t, e) { if (typeof e != "function" && e !== null) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && pe(t, e); } function G(t) { return G = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(e) { return e.__proto__ || Object.getPrototypeOf(e); }, G(t); } function pe(t, e) { return pe = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(n, r) { return n.__proto__ = r, n; }, pe(t, e); } function K(t) { if (t === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return t; } function z(t) { var e = function() { if (typeof Reflect > "u" || !Reflect.construct || Reflect.construct.sham) return !1; if (typeof Proxy == "function") return !0; try { return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() { })), !0; } catch { return !1; } }(); return function() { var n, r = G(t); if (e) { var i = G(this).constructor; n = Reflect.construct(r, arguments, i); } else n = r.apply(this, arguments); return function(o, a) { if (a && (typeof a == "object" || typeof a == "function")) return a; if (a !== void 0) throw new TypeError("Derived constructors may only return object or undefined"); return K(o); }(this, n); }; } function fe() { return fe = typeof Reflect < "u" && Reflect.get ? Reflect.get.bind() : function(t, e, n) { var r = function(o, a) { for (; !Object.prototype.hasOwnProperty.call(o, a) && (o = G(o)) !== null; ) ; return o; }(t, e); if (r) { var i = Object.getOwnPropertyDescriptor(r, e); return i.get ? i.get.call(arguments.length < 3 ? t : n) : i.value; } }, fe.apply(this, arguments); } function Ot(t) { var e = function(n, r) { if (typeof n != "object" || n === null) return n; var i = n[Symbol.toPrimitive]; if (i !== void 0) { var o = i.call(n, r); if (typeof o != "object") return o; throw new TypeError("@@toPrimitive must return a primitive value."); } return String(n); }(t, "string"); return typeof e == "symbol" ? e : e + ""; } var Pt = function(t) { return !(!t || !t.Window) && t instanceof t.Window; }, kt = void 0, ne = void 0; function Dt(t) { kt = t; var e = t.document.createTextNode(""); e.ownerDocument !== t.document && typeof t.wrap == "function" && t.wrap(e) === e && (t = t.wrap(t)), ne = t; } function V(t) { return Pt(t) ? t : (t.ownerDocument || t).defaultView || ne.window; } typeof window < "u" && window && Dt(window); var ke = function(t) { return !!t && P(t) === "object"; }, It = function(t) { return typeof t == "function"; }, d = { window: function(t) { return t === ne || Pt(t); }, docFrag: function(t) { return ke(t) && t.nodeType === 11; }, object: ke, func: It, number: function(t) { return typeof t == "number"; }, bool: function(t) { return typeof t == "boolean"; }, string: function(t) { return typeof t == "string"; }, element: function(t) { if (!t || P(t) !== "object") return !1; var e = V(t) || ne; return /object|function/.test(typeof Element > "u" ? "undefined" : P(Element)) ? t instanceof Element || t instanceof e.Element : t.nodeType === 1 && typeof t.nodeName == "string"; }, plainObject: function(t) { return ke(t) && !!t.constructor && /function Object\b/.test(t.constructor.toString()); }, array: function(t) { return ke(t) && t.length !== void 0 && It(t.splice); } }; function He(t) { var e = t.interaction; if (e.prepared.name === "drag") { var n = e.prepared.axis; n === "x" ? (e.coords.cur.page.y = e.coords.start.page.y, e.coords.cur.client.y = e.coords.start.client.y, e.coords.velocity.client.y = 0, e.coords.velocity.page.y = 0) : n === "y" && (e.coords.cur.page.x = e.coords.start.page.x, e.coords.cur.client.x = e.coords.start.client.x, e.coords.velocity.client.x = 0, e.coords.velocity.page.x = 0); } } function Mt(t) { var e = t.iEvent, n = t.interaction; if (n.prepared.name === "drag") { var r = n.prepared.axis; if (r === "x" || r === "y") { var i = r === "x" ? "y" : "x"; e.page[i] = n.coords.start.page[i], e.client[i] = n.coords.start.client[i], e.delta[i] = 0; } } } var De = { id: "actions/drag", install: function(t) { var e = t.actions, n = t.Interactable, r = t.defaults; n.prototype.draggable = De.draggable, e.map.drag = De, e.methodDict.drag = "draggable", r.actions.drag = De.defaults; }, listeners: { "interactions:before-action-move": He, "interactions:action-resume": He, "interactions:action-move": Mt, "auto-start:check": function(t) { var e = t.interaction, n = t.interactable, r = t.buttons, i = n.options.drag; if (i && i.enabled && (!e.pointerIsDown || !/mouse|pointer/.test(e.pointerType) || (r & n.options.drag.mouseButtons) != 0)) return t.action = { name: "drag", axis: i.lockAxis === "start" ? i.startAxis : i.lockAxis }, !1; } }, draggable: function(t) { return d.object(t) ? (this.options.drag.enabled = t.enabled !== !1, this.setPerAction("drag", t), this.setOnEvents("drag", t), /^(xy|x|y|start)$/.test(t.lockAxis) && (this.options.drag.lockAxis = t.lockAxis), /^(xy|x|y)$/.test(t.startAxis) && (this.options.drag.startAxis = t.startAxis), this) : d.bool(t) ? (this.options.drag.enabled = t, this) : this.options.drag; }, beforeMove: He, move: Mt, defaults: { startAxis: "xy", lockAxis: "xy" }, getCursor: function() { return "move"; }, filterEventType: function(t) { return t.search("drag") === 0; } }, zt = De, Y = { init: function(t) { var e = t; Y.document = e.document, Y.DocumentFragment = e.DocumentFragment || ce, Y.SVGElement = e.SVGElement || ce, Y.SVGSVGElement = e.SVGSVGElement || ce, Y.SVGElementInstance = e.SVGElementInstance || ce, Y.Element = e.Element || ce, Y.HTMLElement = e.HTMLElement || Y.Element, Y.Event = e.Event, Y.Touch = e.Touch || ce, Y.PointerEvent = e.PointerEvent || e.MSPointerEvent; }, document: null, DocumentFragment: null, SVGElement: null, SVGSVGElement: null, SVGElementInstance: null, Element: null, HTMLElement: null, Event: null, Touch: null, PointerEvent: null }; function ce() { } var A = Y, B = { init: function(t) { var e = A.Element, n = t.navigator || {}; B.supportsTouch = "ontouchstart" in t || d.func(t.DocumentTouch) && A.document instanceof t.DocumentTouch, B.supportsPointerEvent = n.pointerEnabled !== !1 && !!A.PointerEvent, B.isIOS = /iP(hone|od|ad)/.test(n.platform), B.isIOS7 = /iP(hone|od|ad)/.test(n.platform) && /OS 7[^\d]/.test(n.appVersion), B.isIe9 = /MSIE 9/.test(n.userAgent), B.isOperaMobile = n.appName === "Opera" && B.supportsTouch && /Presto/.test(n.userAgent), B.prefixedMatchesSelector = "matches" in e.prototype ? "matches" : "webkitMatchesSelector" in e.prototype ? "webkitMatchesSelector" : "mozMatchesSelector" in e.prototype ? "mozMatchesSelector" : "oMatchesSelector" in e.prototype ? "oMatchesSelector" : "msMatchesSelector", B.pEventTypes = B.supportsPointerEvent ? A.PointerEvent === t.MSPointerEvent ? { up: "MSPointerUp", down: "MSPointerDown", over: "mouseover", out: "mouseout", move: "MSPointerMove", cancel: "MSPointerCancel" } : { up: "pointerup", down: "pointerdown", over: "pointerover", out: "pointerout", move: "pointermove", cancel: "pointercancel" } : null, B.wheelEvent = A.document && "onmousewheel" in A.document ? "mousewheel" : "wheel"; }, supportsTouch: null, supportsPointerEvent: null, isIOS7: null, isIOS: null, isIe9: null, isOperaMobile: null, prefixedMatchesSelector: null, pEventTypes: null, wheelEvent: null }, q = B; function re(t, e) { if (t.contains) return t.contains(e); for (; e; ) { if (e === t) return !0; e = e.parentNode; } return !1; } function At(t, e) { for (; d.element(t); ) { if (N(t, e)) return t; t = W(t); } return null; } function W(t) { var e = t.parentNode; if (d.docFrag(e)) { for (; (e = e.host) && d.docFrag(e); ) ; return e; } return e; } function N(t, e) { return ne !== kt && (e = e.replace(/\/deep\//g, " ")), t[q.prefixedMatchesSelector](e); } var $e = function(t) { return t.parentNode || t.host; }; function Rt(t, e) { for (var n, r = [], i = t; (n = $e(i)) && i !== e && n !== i.ownerDocument; ) r.unshift(i), i = n; return r; } function Ke(t, e, n) { for (; d.element(t); ) { if (N(t, e)) return !0; if ((t = W(t)) === n) return N(t, e); } return !1; } function Ct(t) { return t.correspondingUseElement || t; } function Ne(t) { var e = t instanceof A.SVGElement ? t.getBoundingClientRect() : t.getClientRects()[0]; return e && { left: e.left, right: e.right, top: e.top, bottom: e.bottom, width: e.width || e.right - e.left, height: e.height || e.bottom - e.top }; } function Je(t) { var e, n = Ne(t); if (!q.isIOS7 && n) { var r = { x: (e = (e = V(t)) || ne).scrollX || e.document.documentElement.scrollLeft, y: e.scrollY || e.document.documentElement.scrollTop }; n.left += r.x, n.right += r.x, n.top += r.y, n.bottom += r.y; } return n; } function jt(t) { for (var e = []; t; ) e.push(t), t = W(t); return e; } function Ft(t) { return !!d.string(t) && (A.document.querySelector(t), !0); } function x(t, e) { for (var n in e) t[n] = e[n]; return t; } function Xt(t, e, n) { return t === "parent" ? W(n) : t === "self" ? e.getRect(n) : At(n, t); } function de(t, e, n, r) { var i = t; return d.string(i) ? i = Xt(i, e, n) : d.func(i) && (i = i.apply(void 0, r)), d.element(i) && (i = Je(i)), i; } function Ie(t) { return t && { x: "x" in t ? t.x : t.left, y: "y" in t ? t.y : t.top }; } function Qe(t) { return !t || "x" in t && "y" in t || ((t = x({}, t)).x = t.left || 0, t.y = t.top || 0, t.width = t.width || (t.right || 0) - t.x, t.height = t.height || (t.bottom || 0) - t.y), t; } function Me(t, e, n) { t.left && (e.left += n.x), t.right && (e.right += n.x), t.top && (e.top += n.y), t.bottom && (e.bottom += n.y), e.width = e.right - e.left, e.height = e.bottom - e.top; } function ve(t, e, n) { var r = n && t.options[n]; return Ie(de(r && r.origin || t.options.origin, t, e, [t && e])) || { x: 0, y: 0 }; } function ie(t, e) { var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : function(c) { return !0; }, r = arguments.length > 3 ? arguments[3] : void 0; if (r = r || {}, d.string(t) && t.search(" ") !== -1 && (t = Yt(t)), d.array(t)) return t.forEach(function(c) { return ie(c, e, n, r); }), r; if (d.object(t) && (e = t, t = ""), d.func(e) && n(t)) r[t] = r[t] || [], r[t].push(e); else if (d.array(e)) for (var i = 0, o = e; i < o.length; i++) { var a = o[i]; ie(t, a, n, r); } else if (d.object(e)) for (var s in e) ie(Yt(s).map(function(c) { return "".concat(t).concat(c); }), e[s], n, r); return r; } function Yt(t) { return t.trim().split(/ +/); } var he = function(t, e) { return Math.sqrt(t * t + e * e); }, zn = ["webkit", "moz"]; function ze(t, e) { t.__set || (t.__set = {}); var n = function(i) { if (zn.some(function(o) { return i.indexOf(o) === 0; })) return 1; typeof t[i] != "function" && i !== "__set" && Object.defineProperty(t, i, { get: function() { return i in t.__set ? t.__set[i] : t.__set[i] = e[i]; }, set: function(o) { t.__set[i] = o; }, configurable: !0 }); }; for (var r in e) n(r); return t; } function Ae(t, e) { t.page = t.page || {}, t.page.x = e.page.x, t.page.y = e.page.y, t.client = t.client || {}, t.client.x = e.client.x, t.client.y = e.client.y, t.timeStamp = e.timeStamp; } function Bt(t) { t.page.x = 0, t.page.y = 0, t.client.x = 0, t.client.y = 0; } function qt(t) { return t instanceof A.Event || t instanceof A.Touch; } function Re(t, e, n) { return t = t || "page", (n = n || {}).x = e[t + "X"], n.y = e[t + "Y"], n; } function Lt(t, e) { return e = e || { x: 0, y: 0 }, q.isOperaMobile && qt(t) ? (Re("screen", t, e), e.x += window.scrollX, e.y += window.scrollY) : Re("page", t, e), e; } function ge(t) { return d.number(t.pointerId) ? t.pointerId : t.identifier; } function An(t, e, n) { var r = e.length > 1 ? Gt(e) : e[0]; Lt(r, t.page), function(i, o) { o = o || {}, q.isOperaMobile && qt(i) ? Re("screen", i, o) : Re("client", i, o); }(r, t.client), t.timeStamp = n; } function Ze(t) { var e = []; return d.array(t) ? (e[0] = t[0], e[1] = t[1]) : t.type === "touchend" ? t.touches.length === 1 ? (e[0] = t.touches[0], e[1] = t.changedTouches[0]) : t.touches.length === 0 && (e[0] = t.changedTouches[0], e[1] = t.changedTouches[1]) : (e[0] = t.touches[0], e[1] = t.touches[1]), e; } function Gt(t) { for (var e = { pageX: 0, pageY: 0, clientX: 0, clientY: 0, screenX: 0, screenY: 0 }, n = 0; n < t.length; n++) { var r = t[n]; for (var i in e) e[i] += r[i]; } for (var o in e) e[o] /= t.length; return e; } function et(t) { if (!t.length) return null; var e = Ze(t), n = Math.min(e[0].pageX, e[1].pageX), r = Math.min(e[0].pageY, e[1].pageY), i = Math.max(e[0].pageX, e[1].pageX), o = Math.max(e[0].pageY, e[1].pageY); return { x: n, y: r, left: n, top: r, right: i, bottom: o, width: i - n, height: o - r }; } function tt(t, e) { var n = e + "X", r = e + "Y", i = Ze(t), o = i[0][n] - i[1][n], a = i[0][r] - i[1][r]; return he(o, a); } function nt(t, e) { var n = e + "X", r = e + "Y", i = Ze(t), o = i[1][n] - i[0][n], a = i[1][r] - i[0][r]; return 180 * Math.atan2(a, o) / Math.PI; } function Vt(t) { return d.string(t.pointerType) ? t.pointerType : d.number(t.pointerType) ? [void 0, void 0, "touch", "pen", "mouse"][t.pointerType] : /touch/.test(t.type || "") || t instanceof A.Touch ? "touch" : "mouse"; } function Wt(t) { var e = d.func(t.composedPath) ? t.composedPath() : t.path; return [Ct(e ? e[0] : t.target), Ct(t.currentTarget)]; } var Ce = function() { function t(e) { I(this, t), this.immediatePropagationStopped = !1, this.propagationStopped = !1, this._interaction = e; } return k(t, [{ key: "preventDefault", value: function() { } }, { key: "stopPropagation", value: function() { this.propagationStopped = !0; } }, { key: "stopImmediatePropagation", value: function() { this.immediatePropagationStopped = this.propagationStopped = !0; } }]), t; }(); Object.defineProperty(Ce.prototype, "interaction", { get: function() { return this._interaction._proxy; }, set: function() { } }); var Ut = function(t, e) { for (var n = 0; n < e.length; n++) { var r = e[n]; t.push(r); } return t; }, Ht = function(t) { return Ut([], t); }, me = function(t, e) { for (var n = 0; n < t.length; n++) if (e(t[n], n, t)) return n; return -1; }, ye = function(t, e) { return t[me(t, e)]; }, le = function(t) { te(n, t); var e = z(n); function n(r, i, o) { var a; I(this, n), (a = e.call(this, i._interaction)).dropzone = void 0, a.dragEvent = void 0, a.relatedTarget = void 0, a.draggable = void 0, a.propagationStopped = !1, a.immediatePropagationStopped = !1; var s = o === "dragleave" ? r.prev : r.cur, c = s.element, u = s.dropzone; return a.type = o, a.target = c, a.currentTarget = c, a.dropzone = u, a.dragEvent = i, a.relatedTarget = i.target, a.draggable = i.interactable, a.timeStamp = i.timeStamp, a; } return k(n, [{ key: "reject", value: function() { var r = this, i = this._interaction.dropState; if (this.type === "dropactivate" || this.dropzone && i.cur.dropzone === this.dropzone && i.cur.element === this.target) if (i.prev.dropzone = this.dropzone, i.prev.element = this.target, i.rejected = !0, i.events.enter = null, this.stopImmediatePropagation(), this.type === "dropactivate") { var o = i.activeDrops, a = me(o, function(c) { var u = c.dropzone, l = c.element; return u === r.dropzone && l === r.target; }); i.activeDrops.splice(a, 1); var s = new n(i, this.dragEvent, "dropdeactivate"); s.dropzone = this.dropzone, s.target = this.target, this.dropzone.fire(s); } else this.dropzone.fire(new n(i, this.dragEvent, "dragleave")); } }, { key: "preventDefault", value: function() { } }, { key: "stopPropagation", value: function() { this.propagationStopped = !0; } }, { key: "stopImmediatePropagation", value: function() { this.immediatePropagationStopped = this.propagationStopped = !0; } }]), n; }(Ce); function $t(t, e) { for (var n = 0, r = t.slice(); n < r.length; n++) { var i = r[n], o = i.dropzone, a = i.element; e.dropzone = o, e.target = a, o.fire(e), e.propagationStopped = e.immediatePropagationStopped = !1; } } function rt(t, e) { for (var n = function(o, a) { for (var s = [], c = 0, u = o.interactables.list; c < u.length; c++) { var l = u[c]; if (l.options.drop.enabled) { var p = l.options.drop.accept; if (!(d.element(p) && p !== a || d.string(p) && !N(a, p) || d.func(p) && !p({ dropzone: l, draggableElement: a }))) for (var f = 0, h = l.getAllElements(); f < h.length; f++) { var v = h[f]; v !== a && s.push({ dropzone: l, element: v, rect: l.getRect(v) }); } } } return s; }(t, e), r = 0; r < n.length; r++) { var i = n[r]; i.rect = i.dropzone.getRect(i.element); } return n; } function Kt(t, e, n) { for (var r = t.dropState, i = t.interactable, o = t.element, a = [], s = 0, c = r.activeDrops; s < c.length; s++) { var u = c[s], l = u.dropzone, p = u.element, f = u.rect, h = l.dropCheck(e, n, i, o, p, f); a.push(h ? p : null); } var v = function(g) { for (var y, m, b, T = [], S = 0; S < g.length; S++) { var w = g[S], _ = g[y]; if (w && S !== y) if (_) { var C = $e(w), M = $e(_); if (C !== w.ownerDocument) if (M !== w.ownerDocument) if (C !== M) { T = T.length ? T : Rt(_); var j = void 0; if (_ instanceof A.HTMLElement && w instanceof A.SVGElement && !(w instanceof A.SVGSVGElement)) { if (w === M) continue; j = w.ownerSVGElement; } else j = w; for (var L = Rt(j, _.ownerDocument), $ = 0; L[$] && L[$] === T[$]; ) $++; var Ve = [L[$ - 1], L[$], T[$]]; if (Ve[0]) for (var _e = Ve[0].lastChild; _e; ) { if (_e === Ve[1]) { y = S, T = L; break; } if (_e === Ve[2]) break; _e = _e.previousSibling; } } else b = _, (parseInt(V(m = w).getComputedStyle(m).zIndex, 10) || 0) >= (parseInt(V(b).getComputedStyle(b).zIndex, 10) || 0) && (y = S); else y = S; } else y = S; } return y; }(a); return r.activeDrops[v] || null; } function it(t, e, n) { var r = t.dropState, i = { enter: null, leave: null, activate: null, deactivate: null, move: null, drop: null }; return n.type === "dragstart" && (i.activate = new le(r, n, "dropactivate"), i.activate.target = null, i.activate.dropzone = null), n.type === "dragend" && (i.deactivate = new le(r, n, "dropdeactivate"), i.deactivate.target = null, i.deactivate.dropzone = null), r.rejected || (r.cur.element !== r.prev.element && (r.prev.dropzone && (i.leave = new le(r, n, "dragleave"), n.dragLeave = i.leave.target = r.prev.element, n.prevDropzone = i.leave.dropzone = r.prev.dropzone), r.cur.dropzone && (i.enter = new le(r, n, "dragenter"), n.dragEnter = r.cur.element, n.dropzone = r.cur.dropzone)), n.type === "dragend" && r.cur.dropzone && (i.drop = new le(r, n, "drop"), n.dropzone = r.cur.dropzone, n.relatedTarget = r.cur.element), n.type === "dragmove" && r.cur.dropzone && (i.move = new le(r, n, "dropmove"), n.dropzone = r.cur.dropzone)), i; } function ot(t, e) { var n = t.dropState, r = n.activeDrops, i = n.cur, o = n.prev; e.leave && o.dropzone.fire(e.leave), e.enter && i.dropzone.fire(e.enter), e.move && i.dropzone.fire(e.move), e.drop && i.dropzone.fire(e.drop), e.deactivate && $t(r, e.deactivate), n.prev.dropzone = i.dropzone, n.prev.element = i.element; } function Nt(t, e) { var n = t.interaction, r = t.iEvent, i = t.event; if (r.type === "dragmove" || r.type === "dragend") { var o = n.dropState; e.dynamicDrop && (o.activeDrops = rt(e, n.element)); var a = r, s = Kt(n, a, i); o.rejected = o.rejected && !!s && s.dropzone === o.cur.dropzone && s.element === o.cur.element, o.cur.dropzone = s && s.dropzone, o.cur.element = s && s.element, o.events = it(n, 0, a); } } var Jt = { id: "actions/drop", install: function(t) { var e = t.actions, n = t.interactStatic, r = t.Interactable, i = t.defaults; t.usePlugin(zt), r.prototype.dropzone = function(o) { return function(a, s) { if (d.object(s)) { if (a.options.drop.enabled = s.enabled !== !1, s.listeners) { var c = ie(s.listeners), u = Object.keys(c).reduce(function(p, f) { return p[/^(enter|leave)/.test(f) ? "drag".concat(f) : /^(activate|deactivate|move)/.test(f) ? "drop".concat(f) : f] = c[f], p; }, {}), l = a.options.drop.listeners; l && a.off(l), a.on(u), a.options.drop.listeners = u; } return d.func(s.ondrop) && a.on("drop", s.ondrop), d.func(s.ondropactivate) && a.on("dropactivate", s.ondropactivate), d.func(s.ondropdeactivate) && a.on("dropdeactivate", s.ondropdeactivate), d.func(s.ondragenter) && a.on("dragenter", s.ondragenter), d.func(s.ondragleave) && a.on("dragleave", s.ondragleave), d.func(s.ondropmove) && a.on("dropmove", s.ondropmove), /^(pointer|center)$/.test(s.overlap) ? a.options.drop.overlap = s.overlap : d.number(s.overlap) && (a.options.drop.overlap = Math.max(Math.min(1, s.overlap), 0)), "accept" in s && (a.options.drop.accept = s.accept), "checker" in s && (a.options.drop.checker = s.checker), a; } return d.bool(s) ? (a.options.drop.enabled = s, a) : a.options.drop; }(this, o); }, r.prototype.dropCheck = function(o, a, s, c, u, l) { return function(p, f, h, v, g, y, m) { var b = !1; if (!(m = m || p.getRect(y))) return !!p.options.drop.checker && p.options.drop.checker(f, h, b, p, y, v, g); var T = p.options.drop.overlap; if (T === "pointer") { var S = ve(v, g, "drag"), w = Lt(f); w.x += S.x, w.y += S.y; var _ = w.x > m.left && w.x < m.right, C = w.y > m.top && w.y < m.bottom; b = _ && C; } var M = v.getRect(g); if (M && T === "center") { var j = M.left + M.width / 2, L = M.top + M.height / 2; b = j >= m.left && j <= m.right && L >= m.top && L <= m.bottom; } return M && d.number(T) && (b = Math.max(0, Math.min(m.right, M.right) - Math.max(m.left, M.left)) * Math.max(0, Math.min(m.bottom, M.bottom) - Math.max(m.top, M.top)) / (M.width * M.height) >= T), p.options.drop.checker && (b = p.options.drop.checker(f, h, b, p, y, v, g)), b; }(this, o, a, s, c, u, l); }, n.dynamicDrop = function(o) { return d.bool(o) ? (t.dynamicDrop = o, n) : t.dynamicDrop; }, x(e.phaselessTypes, { dragenter: !0, dragleave: !0, dropactivate: !0, dropdeactivate: !0, dropmove: !0, drop: !0 }), e.methodDict.drop = "dropzone", t.dynamicDrop = !1, i.actions.drop = Jt.defaults; }, listeners: { "interactions:before-action-start": function(t) { var e = t.interaction; e.prepared.name === "drag" && (e.dropState = { cur: { dropzone: null, element: null }, prev: { dropzone: null, element: null }, rejected: null, events: null, activeDrops: [] }); }, "interactions:after-action-start": function(t, e) { var n = t.interaction, r = (t.event, t.iEvent); if (n.prepared.name === "drag") { var i = n.dropState; i.activeDrops = [], i.events = {}, i.activeDrops = rt(e, n.element), i.events = it(n, 0, r), i.events.activate && ($t(i.activeDrops, i.events.activate), e.fire("actions/drop:start", { interaction: n, dragEvent: r })); } }, "interactions:action-move": Nt, "interactions:after-action-move": function(t, e) { var n = t.interaction, r = t.iEvent; if (n.prepared.name === "drag") { var i = n.dropState; ot(n, i.events), e.fire("actions/drop:move", { interaction: n, dragEvent: r }), i.events = {}; } }, "interactions:action-end": function(t, e) { if (t.interaction.prepared.name === "drag") { var n = t.interaction, r = t.iEvent; Nt(t, e), ot(n, n.dropState.events), e.fire("actions/drop:end", { interaction: n, dragEvent: r }); } }, "interactions:stop": function(t) { var e = t.interaction; if (e.prepared.name === "drag") { var n = e.dropState; n && (n.activeDrops = null, n.events = null, n.cur.dropzone = null, n.cur.element = null, n.prev.dropzone = null, n.prev.element = null, n.rejected = !1); } } }, getActiveDrops: rt, getDrop: Kt, getDropEvents: it, fireDropEvents: ot, filterEventType: function(t) { return t.search("drag") === 0 || t.search("drop") === 0; }, defaults: { enabled: !1, accept: null, overlap: "pointer" } }, Rn = Jt; function at(t) { var e = t.interaction, n = t.iEvent, r = t.phase; if (e.prepared.name === "gesture") { var i = e.pointers.map(function(u) { return u.pointer; }), o = r === "start", a = r === "end", s = e.interactable.options.deltaSource; if (n.touches = [i[0], i[1]], o) n.distance = tt(i, s), n.box = et(i), n.scale = 1, n.ds = 0, n.angle = nt(i, s), n.da = 0, e.gesture.startDistance = n.distance, e.gesture.startAngle = n.angle; else if (a || e.pointers.length < 2) { var c = e.prevEvent; n.distance = c.distance, n.box = c.box, n.scale = c.scale, n.ds = 0, n.angle = c.angle, n.da = 0; } else n.distance = tt(i, s), n.box = et(i), n.scale = n.distance / e.gesture.startDistance, n.angle = nt(i, s), n.ds = n.scale - e.gesture.scale, n.da = n.angle - e.gesture.angle; e.gesture.distance = n.distance, e.gesture.angle = n.angle, d.number(n.scale) && n.scale !== 1 / 0 && !isNaN(n.scale) && (e.gesture.scale = n.scale); } } var st = { id: "actions/gesture", before: ["actions/drag", "actions/resize"], install: function(t) { var e = t.actions, n = t.Interactable, r = t.defaults; n.prototype.gesturable = function(i) { return d.object(i) ? (this.options.gesture.enabled = i.enabled !== !1, this.setPerAction("gesture", i), this.setOnEvents("gesture", i), this) : d.bool(i) ? (this.options.gesture.enabled = i, this) : this.options.gesture; }, e.map.gesture = st, e.methodDict.gesture = "gesturable", r.actions.gesture = st.defaults; }, listeners: { "interactions:action-start": at, "interactions:action-move": at, "interactions:action-end": at, "interactions:new": function(t) { t.interaction.gesture = { angle: 0, distance: 0, scale: 1, startAngle: 0, startDistance: 0 }; }, "auto-start:check": function(t) { if (!(t.interaction.pointers.length < 2)) { var e = t.interactable.options.gesture; if (e && e.enabled) return t.action = { name: "gesture" }, !1; } } }, defaults: {}, getCursor: function() { return ""; }, filterEventType: function(t) { return t.search("gesture") === 0; } }, Cn = st; function jn(t, e, n, r, i, o, a) { if (!e) return !1; if (e === !0) { var s = d.number(o.width) ? o.width : o.right - o.left, c = d.number(o.height) ? o.height : o.bottom - o.top; if (a = Math.min(a, Math.abs((t === "left" || t === "right" ? s : c) / 2)), s < 0 && (t === "left" ? t = "right" : t === "right" && (t = "left")), c < 0 && (t === "top" ? t = "bottom" : t === "bottom" && (t = "top")), t === "left") { var u = s >= 0 ? o.left : o.right; return n.x < u + a; } if (t === "top") { var l = c >= 0 ? o.top : o.bottom; return n.y < l + a; } if (t === "right") return n.x > (s >= 0 ? o.right : o.left) - a; if (t === "bottom") return n.y > (c >= 0 ? o.bottom : o.top) - a; } return !!d.element(r) && (d.element(e) ? e === r : Ke(r, e, i)); } function Qt(t) { var e = t.iEvent, n = t.interaction; if (n.prepared.name === "resize" && n.resizeAxes) { var r = e; n.interactable.options.resize.square ? (n.resizeAxes === "y" ? r.delta.x = r.delta.y : r.delta.y = r.delta.x, r.axes = "xy") : (r.axes = n.resizeAxes, n.resizeAxes === "x" ? r.delta.y = 0 : n.resizeAxes === "y" && (r.delta.x = 0)); } } var U, oe, H = { id: "actions/resize", before: ["actions/drag"], install: function(t) { var e = t.actions, n = t.browser, r = t.Interactable, i = t.defaults; H.cursors = function(o) { return o.isIe9 ? { x: "e-resize", y: "s-resize", xy: "se-resize", top: "n-resize", left: "w-resize", bottom: "s-resize", right: "e-resize", topleft: "se-resize", bottomright: "se-resize", topright: "ne-resize", bottomleft: "ne-resize" } : { x: "ew-resize", y: "ns-resize", xy: "nwse-resize", top: "ns-resize", left: "ew-resize", bottom: "ns-resize", right: "ew-resize", topleft: "nwse-resize", bottomright: "nwse-resize", topright: "nesw-resize", bottomleft: "nesw-resize" }; }(n), H.defaultMargin = n.supportsTouch || n.supportsPointerEvent ? 20 : 10, r.prototype.resizable = function(o) { return function(a, s, c) { return d.object(s) ? (a.options.resize.enabled = s.enabled !== !1, a.setPerAction("resize", s), a.setOnEvents("resize", s), d.string(s.axis) && /^x$|^y$|^xy$/.test(s.axis) ? a.options.resize.axis = s.axis : s.axis === null && (a.options.resize.axis = c.defaults.actions.resize.axis), d.bool(s.preserveAspectRatio) ? a.options.resize.preserveAspectRatio = s.preserveAspectRatio : d.bool(s.square) && (a.options.resize.square = s.square), a) : d.bool(s) ? (a.options.resize.enabled = s, a) : a.options.resize; }(this, o, t); }, e.map.resize = H, e.methodDict.resize = "resizable", i.actions.resize = H.defaults; }, listeners: { "interactions:new": function(t) { t.interaction.resizeAxes = "xy"; }, "interactions:action-start": function(t) { (function(e) { var n = e.iEvent, r = e.interaction; if (r.prepared.name === "resize" && r.prepared.edges) { var i = n, o = r.rect; r._rects = { start: x({}, o), corrected: x({}, o), previous: x({}, o), delta: { left: 0, right: 0, width: 0, top: 0, bottom: 0, height: 0 } }, i.edges = r.prepared.edges, i.rect = r._rects.corrected, i.deltaRect = r._rects.delta; } })(t), Qt(t); }, "interactions:action-move": function(t) { (function(e) { var n = e.iEvent, r = e.interaction; if (r.prepared.name === "resize" && r.prepared.edges) { var i = n, o = r.interactable.options.resize.invert, a = o === "reposition" || o === "negate", s = r.rect, c = r._rects, u = c.start, l = c.corrected, p = c.delta, f = c.previous; if (x(f, l), a) { if (x(l, s), o === "reposition") { if (l.top > l.bottom) { var h = l.top; l.top = l.bottom, l.bottom = h; } if (l.left > l.right) { var v = l.left; l.left = l.right, l.right = v; } } } else l.top = Math.min(s.top, u.bottom), l.bottom = Math.max(s.bottom, u.top), l.left = Math.min(s.left, u.right), l.right = Math.max(s.right, u.left); for (var g in l.width = l.right - l.left, l.height = l.bottom - l.top, l) p[g] = l[g] - f[g]; i.edges = r.prepared.edges, i.rect = l, i.deltaRect = p; } })(t), Qt(t); }, "interactions:action-end": function(t) { var e = t.iEvent, n = t.interaction; if (n.prepared.name === "resize" && n.prepared.edges) { var r = e; r.edges = n.prepared.edges, r.rect = n._rects.corrected, r.deltaRect = n._rects.delta; } }, "auto-start:check": function(t) { var e = t.interaction, n = t.interactable, r = t.element, i = t.rect, o = t.buttons; if (i) { var a = x({}, e.coords.cur.page), s = n.options.resize; if (s && s.enabled && (!e.pointerIsDown || !/mouse|pointer/.test(e.pointerType) || (o & s.mouseButtons) != 0)) { if (d.object(s.edges)) { var c = { left: !1, right: !1, top: !1, bottom: !1 }; for (var u in c) c[u] = jn(u, s.edges[u], a, e._latestPointer.eventTarget, r, i, s.margin || H.defaultMargin); c.left = c.left && !c.right, c.top = c.top && !c.bottom, (c.left || c.right || c.top || c.bottom) && (t.action = { name: "resize", edges: c }); } else { var l = s.axis !== "y" && a.x > i.right - H.defaultMargin, p = s.axis !== "x" && a.y > i.bottom - H.defaultMargin; (l || p) && (t.action = { name: "resize", axes: (l ? "x" : "") + (p ? "y" : "") }); } return !t.action && void 0; } } } }, defaults: { square: !1, preserveAspectRatio: !1, axis: "xy", margin: NaN, edges: null, invert: "none" }, cursors: null, getCursor: function(t) { var e = t.edges, n = t.axis, r = t.name, i = H.cursors, o = null; if (n) o = i[r + n]; else if (e) { for (var a = "", s = 0, c = ["top", "bottom", "left", "right"]; s < c.length; s++) { var u = c[s]; e[u] && (a += u); } o = i[a]; } return o; }, filterEventType: function(t) { return t.search("resize") === 0; }, defaultMargin: null }, Fn = H, Xn = { id: "actions", install: function(t) { t.usePlugin(Cn), t.usePlugin(Fn), t.usePlugin(zt), t.usePlugin(Rn); } }, Zt = 0, J = { request: function(t) { return U(t); }, cancel: function(t) { return oe(t); }, init: function(t) { if (U = t.requestAnimationFrame, oe = t.cancelAnimationFrame, !U) for (var e = ["ms", "moz", "webkit", "o"], n = 0; n < e.length; n++) { var r = e[n]; U = t["".concat(r, "RequestAnimationFrame")], oe = t["".concat(r, "CancelAnimationFrame")] || t["".concat(r, "CancelRequestAnimationFrame")]; } U = U && U.bind(t), oe = oe && oe.bind(t), U || (U = function(i) { var o = Date.now(), a = Math.max(0, 16 - (o - Zt)), s = t.setTimeout(function() { i(o + a); }, a); return Zt = o + a, s; }, oe = function(i) { return clearTimeout(i); }); } }, E = { defaults: { enabled: !1, margin: 60, container: null, speed: 300 }, now: Date.now, interaction: null, i: 0, x: 0, y: 0, isScrolling: !1, prevTime: 0, margin: 0, speed: 0, start: function(t) { E.isScrolling = !0, J.cancel(E.i), t.autoScroll = E, E.interaction = t, E.prevTime = E.now(), E.i = J.request(E.scroll); }, stop: function() { E.isScrolling = !1, E.interaction && (E.interaction.autoScroll = null), J.cancel(E.i); }, scroll: function() { var t = E.interaction, e = t.interactable, n = t.element, r = t.prepared.name, i = e.options[r].autoScroll, o = en(i.container, e, n), a = E.now(), s = (a - E.prevTime) / 1e3, c = i.speed * s; if (c >= 1) { var u = { x: E.x * c, y: E.y * c }; if (u.x || u.y) { var l = tn(o); d.window(o) ? o.scrollBy(u.x, u.y) : o && (o.scrollLeft += u.x, o.scrollTop += u.y); var p = tn(o), f = { x: p.x - l.x, y: p.y - l.y }; (f.x || f.y) && e.fire({ type: "autoscroll", target: n, interactable: e, delta: f, interaction: t, container: o }); } E.prevTime = a; } E.isScrolling && (J.cancel(E.i), E.i = J.request(E.scroll)); }, check: function(t, e) { var n; return (n = t.options[e].autoScroll) == null ? void 0 : n.enabled; }, onInteractionMove: function(t) { var e = t.interaction, n = t.pointer; if (e.interacting() && E.check(e.interactable, e.prepared.name)) if (e.simulation) E.x = E.y = 0; else { var r, i, o, a, s = e.interactable, c = e.element, u = e.prepared.name, l = s.options[u].autoScroll, p = en(l.container, s, c); if (d.window(p)) a = n.clientX < E.margin, r = n.clientY < E.margin, i = n.clientX > p.innerWidth - E.margin, o = n.clientY > p.innerHeight - E.margin; else { var f = Ne(p); a = n.clientX < f.left + E.margin, r = n.clientY < f.top + E.margin, i = n.clientX > f.right - E.margin, o = n.clientY > f.bottom - E.margin; } E.x = i ? 1 : a ? -1 : 0, E.y = o ? 1 : r ? -1 : 0, E.isScrolling || (E.margin = l.margin, E.speed = l.speed, E.start(e)); } } }; function en(t, e, n) { return (d.string(t) ? Xt(t, e, n) : t) || V(n); } function tn(t) { return d.window(t) && (t = window.document.body), { x: t.scrollLeft, y: t.scrollTop }; } var Yn = { id: "auto-scroll", install: function(t) { var e = t.defaults, n = t.actions; t.autoScroll = E, E.now = function() { return t.now(); }, n.phaselessTypes.autoscroll = !0, e.perAction.autoScroll = E.defaults; }, listeners: { "interactions:new": function(t) { t.interaction.autoScroll = null; }, "interactions:destroy": function(t) { t.interaction.autoScroll = null, E.stop(), E.interaction && (E.interaction = null); }, "interactions:stop": E.stop, "interactions:action-move": function(t) { return E.onInteractionMove(t); } } }, Bn = Yn; function be(t, e) { var n = !1; return function() { return n || (ne.console.warn(e), n = !0), t.apply(this, arguments); }; } function ct(t, e) { return t.name = e.name, t.axis = e.axis, t.edges = e.edges, t; } function qn(t) { return d.bool(t) ? (this.options.styleCursor = t, this) : t === null ? (delete this.options.styleCursor, this) : this.options.styleCursor; } function Ln(t) { return d.func(t) ? (this.options.actionChecker = t, this) : t === null ? (delete this.options.actionChecker, this) : this.options.actionChecker; } var Gn = { id: "auto-start/interactableMethods", install: function(t) { var e = t.Interactable; e.prototype.getAction = function(n, r, i, o) { var a = function(s, c, u, l, p) { var f = s.getRect(l), h = c.buttons || { 0: 1, 1: 4, 3: 8, 4: 16 }[c.button], v = { action: null, interactable: s, interaction: u, element: l, rect: f, buttons: h }; return p.fire("auto-start:check", v), v.action; }(this, r, i, o, t); return this.options.actionChecker ? this.options.actionChecker(n, r, a, this, o, i) : a; }, e.prototype.ignoreFrom = be(function(n) { return this._backCompatOption("ignoreFrom", n); }, "Interactable.ignoreFrom() has been deprecated. Use Interactble.draggable({ignoreFrom: newValue})."), e.prototype.allowFrom = be(function(n) { return this._backCompatOption("allowFrom", n); }, "Interactable.allowFrom() has been deprecated. Use Interactble.draggable({allowFrom: newValue})."), e.prototype.actionChecker = Ln, e.prototype.styleCursor = qn; } }; function nn(t, e, n, r, i) { return e.testIgnoreAllow(e.options[t.name], n, r) && e.options[t.name].enabled && je(e, n, t, i) ? t : null; } function Vn(t, e, n, r, i, o, a) { for (var s = 0, c = r.length; s < c; s++) { var u = r[s], l = i[s], p = u.getAction(e, n, t, l); if (p) { var f = nn(p, u, l, o, a); if (f) return { action: f, interactable: u, element: l }; } } return { action: null, interactable: null, element: null }; } function rn(t, e, n, r, i) { var o = [], a = [], s = r; function c(l) { o.push(l), a.push(s); } for (; d.element(s); ) { o = [], a = [], i.interactables.forEachMatch(s, c); var u = Vn(t, e, n, o, a, r, i); if (u.action && !u.interactable.options[u.action.name].manualStart) return u; s = W(s); } return { action: null, interactable: null, element: null }; } function on(t, e, n) { var r = e.action, i = e.interactable, o = e.element; r = r || { name: null }, t.interactable = i, t.element = o, ct(t.prepared, r), t.rect = i && r.name ? i.getRect(o) : null, sn(t, n), n.fire("autoStart:prepared", { interaction: t }); } function je(t, e, n, r) { var i = t.options, o = i[n.name].max, a = i[n.name].maxPerElement, s = r.autoStart.maxInteractions, c = 0, u = 0, l = 0; if (!(o && a && s)) return !1; for (var p = 0, f = r.interactions.list; p < f.length; p++) { var h = f[p], v = h.prepared.name; if (h.interacting() && (++c >= s || h.interactable === t && ((u += v === n.name ? 1 : 0) >= o || h.element === e && (l++, v === n.name && l >= a)))) return !1; } return s > 0; } function an(t, e) { return d.number(t) ? (e.autoStart.maxInteractions = t, this) : e.autoStart.maxInteractions; } function lt(t, e, n) { var r = n.autoStart.cursorElement; r && r !== t && (r.style.cursor = ""), t.ownerDocument.documentElement.style.cursor = e, t.style.cursor = e, n.autoStart.cursorElement = e ? t : null; } function sn(t, e) { var n = t.interactable, r = t.element, i = t.prepared; if (t.pointerType === "mouse" && n && n.options.styleCursor) { var o = ""; if (i.name) { var a = n.options[i.name].cursorChecker; o = d.func(a) ? a(i, n, r, t._interacting) : e.actions.map[i.name].getCursor(i); } lt(t.element, o || "", e); } else e.autoStart.cursorElement && lt(e.autoStart.cursorElement, "", e); } var Wn = { id: "auto-start/base", before: ["actions"], install: function(t) { var e = t.interactStatic, n = t.defaults; t.usePlugin(Gn), n.base.actionChecker = null, n.base.styleCursor = !0, x(n.perAction, { manualStart: !1, max: 1 / 0, maxPerElement: 1, allowFrom: null, ignoreFrom: null, mouseButtons: 1 }), e.maxInteractions = function(r) { return an(r, t); }, t.autoStart = { maxInteractions: 1 / 0, withinInteractionLimit: je, cursorElement: null }; }, listeners: { "interactions:down": function(t, e) { var n = t.interaction, r = t.pointer, i = t.event, o = t.eventTarget; n.interacting() || on(n, rn(n, r, i, o, e), e); }, "interactions:move": function(t, e) { (function(n, r) { var i = n.interaction, o = n.pointer, a = n.event, s = n.eventTarget; i.pointerType !== "mouse" || i.pointerIsDown || i.interacting() || on(i, rn(i, o, a, s, r), r); })(t, e), function(n, r) { var i = n.interaction; if (i.pointerIsDown && !i.interacting() && i.po