naive-ui-table
Version:
基于naive-ui封装的表格组件
1,320 lines • 72.6 kB
JavaScript
import { reactive as At, onMounted as Pt, isRef as qe, ref as Se, nextTick as Nt, onUnmounted as cn, defineComponent as It, computed as ae, toRefs as Fn, unref as b, h as jn, getCurrentInstance as Mt, watch as un, openBlock as fe, createBlock as Ne, withCtx as B, createVNode as U, createElementBlock as et, Fragment as dn, renderList as fn, createTextVNode as Hn, toDisplayString as Vn, pushScopeId as hn, popScopeId as pn, createElementVNode as Ee, useCssVars as Un, useSlots as jt, createSlots as Yn, renderSlot as dt, createCommentVNode as Pe, mergeProps as Ln } from "vue";
import { NPopover as Wn, NTooltip as St, NButton as Et, NIcon as tt, NCheckbox as $n, NSpace as qn, NDropdown as Gn, NDataTable as Jn } from "naive-ui";
import { SettingsOutline as Kn, Move as Qn, SyncOutline as Zn, BarbellOutline as eo } from "@vicons/ionicons5";
import { useForm as to, BasicForm as no } from "naive-ui-form";
const Ht = "current", Vt = "size", oo = "records", ro = "total", Ut = 10, Yt = [10, 20, 30, 40, 50];
function io({ requestApi: e, requestAuto: n, initParams: t, isPageApi: o, dataCallback: r, requestError: i }, a, s) {
const l = At({
tableData: [],
// 表格数据
loading: !!(e && n),
// 分页数据
pageAble: {
current: 1,
size: Ut,
total: 0
}
});
function d() {
l.tableData = [], l.loading = !1, l.pageAble = {
current: 1,
size: Ut,
total: 0
};
}
Pt(() => {
n && u();
});
async function u() {
var S;
if (e) {
try {
const O = o ? {
[Ht]: l.pageAble.current,
[Vt]: l.pageAble.size
} : {};
let H = {};
a.value && (await a.value.validate(), H = (S = a.value) == null ? void 0 : S.getValue()), l.loading = !0;
const G = { ...t, ...O, ...H }, p = Object.fromEntries(
Object.entries(G).filter(([T, A]) => A != null)
);
let _ = await e(p);
r && (_ = r(_)), l.tableData = o ? _[oo] : _, o && Object.assign(l.pageAble, {
current: _[Ht],
size: _[Vt],
total: _[ro]
});
} catch (O) {
if (f(), d(), i)
return i(O);
throw new Error(O || "请求失败!");
}
f(), s();
}
}
function f() {
var S;
l.loading = !1, (S = a.value) == null || S.setLoading(!1);
}
function y() {
l.pageAble.current = 1, u();
}
function h() {
l.pageAble.current = 1, u();
}
function k(S) {
l.pageAble.current = S, u();
}
function w(S) {
l.pageAble.size = S, l.pageAble.current = 1, u();
}
function F() {
return l.tableData;
}
function x() {
return l.pageAble;
}
function z(S) {
l.loading = S;
}
return {
state: l,
refresh: u,
resetState: d,
handleSearch: y,
handleReset: h,
onUpdatePage: k,
onUpdatePageSize: w,
getTableValue: F,
getPageValue: x,
setLoading: z
};
}
function ao(e) {
return typeof e == "function";
}
function lo(e, n) {
let t = null;
return function(...o) {
t && clearTimeout(t), t = setTimeout(() => {
e(...o);
}, n);
};
}
function so(e) {
const n = [];
return e == null || e.forEach((t) => {
n.push({ ...t });
}), n;
}
function co(e) {
return qe(e.vif) ? e.vif.value : typeof e.vif == "boolean" ? e.vif : typeof e.vif == "function" ? e.vif() : !0;
}
function uo(e, n) {
return e._show = !0, e.ellipsis === void 0 && (e.ellipsis = { tooltip: !0 }), e.type === "selection" && !e.title && (e.title = "勾选"), Array.isArray(e.children) && (e.children = Ct(e.children, n)), e.render || n[e.key] && ao(n[e.key]) && (e.render = (t, o) => n[e.key]({ row: t, index: o })), e;
}
function Ct(e, n) {
return so(e).filter(co).map((t) => uo(t, n)) || [];
}
function fo(e, n) {
const t = Se(0);
function o() {
const i = window.document.documentElement.clientHeight, a = window.pageYOffset || document.documentElement.scrollTop, s = e.value.$el.querySelector(".n-data-table-thead "), { top: l, height: d } = s.getBoundingClientRect(), u = i - (l + a);
let f = 24, y = 0;
const h = e.value.$el.querySelector(
".n-data-table__pagination"
);
h && (y = h.offsetHeight), t.value = u - d - y - f - n;
}
const r = lo(o, 280);
return Pt(() => {
Nt(() => {
o();
}), window.addEventListener("resize", r);
}), cn(() => {
window.removeEventListener("resize", r);
}), {
tableMaxHeight: t
};
}
function ho(e) {
function n() {
return {
keys: [],
rows: []
};
}
const t = At(n());
function o() {
Object.assign(t, n());
}
function r(a, s, l) {
t.keys = a, t.rows = s, e("update:checked-row-keys", a, s, l);
}
function i() {
return t;
}
return {
checkState: t,
clearCheck: o,
handleCheck: r,
getCheckValue: i
};
}
var po = Object.defineProperty, nt = Object.getOwnPropertySymbols, gn = Object.prototype.hasOwnProperty, mn = Object.prototype.propertyIsEnumerable, Lt = (e, n, t) => n in e ? po(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, ke = (e, n) => {
for (var t in n || (n = {}))
gn.call(n, t) && Lt(e, t, n[t]);
if (nt)
for (var t of nt(n))
mn.call(n, t) && Lt(e, t, n[t]);
return e;
}, vn = (e, n) => {
var t = {};
for (var o in e)
gn.call(e, o) && n.indexOf(o) < 0 && (t[o] = e[o]);
if (e != null && nt)
for (var o of nt(e))
n.indexOf(o) < 0 && mn.call(e, o) && (t[o] = e[o]);
return t;
};
function Wt(e, n, t) {
return t >= 0 && t < e.length && e.splice(t, 0, e.splice(n, 1)[0]), e;
}
function go(e) {
return e.replace(/-(\w)/g, (n, t) => t ? t.toUpperCase() : "");
}
function mo(e) {
return Object.keys(e).reduce((n, t) => (typeof e[t] < "u" && (n[go(t)] = e[t]), n), {});
}
function $t(e, n) {
return Array.isArray(e) && e.splice(n, 1), e;
}
function qt(e, n, t) {
return Array.isArray(e) && e.splice(n, 0, t), e;
}
function vo(e) {
return typeof e > "u";
}
function bo(e) {
return typeof e == "string";
}
function Gt(e, n, t) {
const o = e.children[t];
e.insertBefore(n, o);
}
function ft(e) {
e.parentNode && e.parentNode.removeChild(e);
}
function yo(e, n = document) {
var t;
let o = null;
return typeof (n == null ? void 0 : n.querySelector) == "function" ? o = (t = n == null ? void 0 : n.querySelector) == null ? void 0 : t.call(n, e) : o = document.querySelector(e), o || (`${e}`, void 0), o;
}
function wo(e, n, t = null) {
return function(...o) {
return e.apply(t, o), n.apply(t, o);
};
}
function _o(e, n) {
const t = ke({}, e);
return Object.keys(n).forEach((o) => {
t[o] ? t[o] = wo(e[o], n[o]) : t[o] = n[o];
}), t;
}
function So(e) {
return e instanceof HTMLElement;
}
function Jt(e, n) {
Object.keys(e).forEach((t) => {
n(t, e[t]);
});
}
function Eo(e) {
return e.charCodeAt(0) === 111 && e.charCodeAt(1) === 110 && // uppercase letter
(e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97);
}
const Co = Object.assign;
/**!
* Sortable 1.15.2
* @author RubaXa <trash@rubaxa.org>
* @author owenm <owen23355@gmail.com>
* @license MIT
*/
function Kt(e, n) {
var t = Object.keys(e);
if (Object.getOwnPropertySymbols) {
var o = Object.getOwnPropertySymbols(e);
n && (o = o.filter(function(r) {
return Object.getOwnPropertyDescriptor(e, r).enumerable;
})), t.push.apply(t, o);
}
return t;
}
function se(e) {
for (var n = 1; n < arguments.length; n++) {
var t = arguments[n] != null ? arguments[n] : {};
n % 2 ? Kt(Object(t), !0).forEach(function(o) {
Do(e, o, t[o]);
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : Kt(Object(t)).forEach(function(o) {
Object.defineProperty(e, o, Object.getOwnPropertyDescriptor(t, o));
});
}
return e;
}
function Ge(e) {
"@babel/helpers - typeof";
return typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? Ge = function(n) {
return typeof n;
} : Ge = function(n) {
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
}, Ge(e);
}
function Do(e, n, t) {
return n in e ? Object.defineProperty(e, n, {
value: t,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[n] = t, e;
}
function pe() {
return pe = Object.assign || function(e) {
for (var n = 1; n < arguments.length; n++) {
var t = arguments[n];
for (var o in t)
Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o]);
}
return e;
}, pe.apply(this, arguments);
}
function To(e, n) {
if (e == null)
return {};
var t = {}, o = Object.keys(e), r, i;
for (i = 0; i < o.length; i++)
r = o[i], !(n.indexOf(r) >= 0) && (t[r] = e[r]);
return t;
}
function ko(e, n) {
if (e == null)
return {};
var t = To(e, n), o, r;
if (Object.getOwnPropertySymbols) {
var i = Object.getOwnPropertySymbols(e);
for (r = 0; r < i.length; r++)
o = i[r], !(n.indexOf(o) >= 0) && Object.prototype.propertyIsEnumerable.call(e, o) && (t[o] = e[o]);
}
return t;
}
var Oo = "1.15.2";
function he(e) {
if (typeof window < "u" && window.navigator)
return !!/* @__PURE__ */ navigator.userAgent.match(e);
}
var ge = he(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i), He = he(/Edge/i), Qt = he(/firefox/i), Re = he(/safari/i) && !he(/chrome/i) && !he(/android/i), bn = he(/iP(ad|od|hone)/i), yn = he(/chrome/i) && he(/android/i), wn = {
capture: !1,
passive: !1
};
function D(e, n, t) {
e.addEventListener(n, t, !ge && wn);
}
function C(e, n, t) {
e.removeEventListener(n, t, !ge && wn);
}
function ot(e, n) {
if (n) {
if (n[0] === ">" && (n = n.substring(1)), e)
try {
if (e.matches)
return e.matches(n);
if (e.msMatchesSelector)
return e.msMatchesSelector(n);
if (e.webkitMatchesSelector)
return e.webkitMatchesSelector(n);
} catch {
return !1;
}
return !1;
}
}
function xo(e) {
return e.host && e !== document && e.host.nodeType ? e.host : e.parentNode;
}
function re(e, n, t, o) {
if (e) {
t = t || document;
do {
if (n != null && (n[0] === ">" ? e.parentNode === t && ot(e, n) : ot(e, n)) || o && e === t)
return e;
if (e === t)
break;
} while (e = xo(e));
}
return null;
}
var Zt = /\s+/g;
function K(e, n, t) {
if (e && n)
if (e.classList)
e.classList[t ? "add" : "remove"](n);
else {
var o = (" " + e.className + " ").replace(Zt, " ").replace(" " + n + " ", " ");
e.className = (o + (t ? " " + n : "")).replace(Zt, " ");
}
}
function g(e, n, t) {
var o = e && e.style;
if (o) {
if (t === void 0)
return document.defaultView && document.defaultView.getComputedStyle ? t = document.defaultView.getComputedStyle(e, "") : e.currentStyle && (t = e.currentStyle), n === void 0 ? t : t[n];
!(n in o) && n.indexOf("webkit") === -1 && (n = "-webkit-" + n), o[n] = t + (typeof t == "string" ? "" : "px");
}
}
function xe(e, n) {
var t = "";
if (typeof e == "string")
t = e;
else
do {
var o = g(e, "transform");
o && o !== "none" && (t = o + " " + t);
} while (!n && (e = e.parentNode));
var r = window.DOMMatrix || window.WebKitCSSMatrix || window.CSSMatrix || window.MSCSSMatrix;
return r && new r(t);
}
function _n(e, n, t) {
if (e) {
var o = e.getElementsByTagName(n), r = 0, i = o.length;
if (t)
for (; r < i; r++)
t(o[r], r);
return o;
}
return [];
}
function le() {
var e = document.scrollingElement;
return e || document.documentElement;
}
function R(e, n, t, o, r) {
if (!(!e.getBoundingClientRect && e !== window)) {
var i, a, s, l, d, u, f;
if (e !== window && e.parentNode && e !== le() ? (i = e.getBoundingClientRect(), a = i.top, s = i.left, l = i.bottom, d = i.right, u = i.height, f = i.width) : (a = 0, s = 0, l = window.innerHeight, d = window.innerWidth, u = window.innerHeight, f = window.innerWidth), (n || t) && e !== window && (r = r || e.parentNode, !ge))
do
if (r && r.getBoundingClientRect && (g(r, "transform") !== "none" || t && g(r, "position") !== "static")) {
var y = r.getBoundingClientRect();
a -= y.top + parseInt(g(r, "border-top-width")), s -= y.left + parseInt(g(r, "border-left-width")), l = a + i.height, d = s + i.width;
break;
}
while (r = r.parentNode);
if (o && e !== window) {
var h = xe(r || e), k = h && h.a, w = h && h.d;
h && (a /= w, s /= k, f /= k, u /= w, l = a + u, d = s + f);
}
return {
top: a,
left: s,
bottom: l,
right: d,
width: f,
height: u
};
}
}
function en(e, n, t) {
for (var o = be(e, !0), r = R(e)[n]; o; ) {
var i = R(o)[t], a = void 0;
if (a = r >= i, !a)
return o;
if (o === le())
break;
o = be(o, !1);
}
return !1;
}
function Ae(e, n, t, o) {
for (var r = 0, i = 0, a = e.children; i < a.length; ) {
if (a[i].style.display !== "none" && a[i] !== m.ghost && (o || a[i] !== m.dragged) && re(a[i], t.draggable, e, !1)) {
if (r === n)
return a[i];
r++;
}
i++;
}
return null;
}
function Bt(e, n) {
for (var t = e.lastElementChild; t && (t === m.ghost || g(t, "display") === "none" || n && !ot(t, n)); )
t = t.previousElementSibling;
return t || null;
}
function ne(e, n) {
var t = 0;
if (!e || !e.parentNode)
return -1;
for (; e = e.previousElementSibling; )
e.nodeName.toUpperCase() !== "TEMPLATE" && e !== m.clone && (!n || ot(e, n)) && t++;
return t;
}
function tn(e) {
var n = 0, t = 0, o = le();
if (e)
do {
var r = xe(e), i = r.a, a = r.d;
n += e.scrollLeft * i, t += e.scrollTop * a;
} while (e !== o && (e = e.parentNode));
return [n, t];
}
function Ao(e, n) {
for (var t in e)
if (e.hasOwnProperty(t)) {
for (var o in n)
if (n.hasOwnProperty(o) && n[o] === e[t][o])
return Number(t);
}
return -1;
}
function be(e, n) {
if (!e || !e.getBoundingClientRect)
return le();
var t = e, o = !1;
do
if (t.clientWidth < t.scrollWidth || t.clientHeight < t.scrollHeight) {
var r = g(t);
if (t.clientWidth < t.scrollWidth && (r.overflowX == "auto" || r.overflowX == "scroll") || t.clientHeight < t.scrollHeight && (r.overflowY == "auto" || r.overflowY == "scroll")) {
if (!t.getBoundingClientRect || t === document.body)
return le();
if (o || n)
return t;
o = !0;
}
}
while (t = t.parentNode);
return le();
}
function Po(e, n) {
if (e && n)
for (var t in n)
n.hasOwnProperty(t) && (e[t] = n[t]);
return e;
}
function ht(e, n) {
return Math.round(e.top) === Math.round(n.top) && Math.round(e.left) === Math.round(n.left) && Math.round(e.height) === Math.round(n.height) && Math.round(e.width) === Math.round(n.width);
}
var ze;
function Sn(e, n) {
return function() {
if (!ze) {
var t = arguments, o = this;
t.length === 1 ? e.call(o, t[0]) : e.apply(o, t), ze = setTimeout(function() {
ze = void 0;
}, n);
}
};
}
function No() {
clearTimeout(ze), ze = void 0;
}
function En(e, n, t) {
e.scrollLeft += n, e.scrollTop += t;
}
function Cn(e) {
var n = window.Polymer, t = window.jQuery || window.Zepto;
return n && n.dom ? n.dom(e).cloneNode(!0) : t ? t(e).clone(!0)[0] : e.cloneNode(!0);
}
function Dn(e, n, t) {
var o = {};
return Array.from(e.children).forEach(function(r) {
var i, a, s, l;
if (!(!re(r, n.draggable, e, !1) || r.animated || r === t)) {
var d = R(r);
o.left = Math.min((i = o.left) !== null && i !== void 0 ? i : 1 / 0, d.left), o.top = Math.min((a = o.top) !== null && a !== void 0 ? a : 1 / 0, d.top), o.right = Math.max((s = o.right) !== null && s !== void 0 ? s : -1 / 0, d.right), o.bottom = Math.max((l = o.bottom) !== null && l !== void 0 ? l : -1 / 0, d.bottom);
}
}), o.width = o.right - o.left, o.height = o.bottom - o.top, o.x = o.left, o.y = o.top, o;
}
var Z = "Sortable" + (/* @__PURE__ */ new Date()).getTime();
function Io() {
var e = [], n;
return {
captureAnimationState: function() {
if (e = [], !!this.options.animation) {
var t = [].slice.call(this.el.children);
t.forEach(function(o) {
if (!(g(o, "display") === "none" || o === m.ghost)) {
e.push({
target: o,
rect: R(o)
});
var r = se({}, e[e.length - 1].rect);
if (o.thisAnimationDuration) {
var i = xe(o, !0);
i && (r.top -= i.f, r.left -= i.e);
}
o.fromRect = r;
}
});
}
},
addAnimationState: function(t) {
e.push(t);
},
removeAnimationState: function(t) {
e.splice(Ao(e, {
target: t
}), 1);
},
animateAll: function(t) {
var o = this;
if (!this.options.animation) {
clearTimeout(n), typeof t == "function" && t();
return;
}
var r = !1, i = 0;
e.forEach(function(a) {
var s = 0, l = a.target, d = l.fromRect, u = R(l), f = l.prevFromRect, y = l.prevToRect, h = a.rect, k = xe(l, !0);
k && (u.top -= k.f, u.left -= k.e), l.toRect = u, l.thisAnimationDuration && ht(f, u) && !ht(d, u) && // Make sure animatingRect is on line between toRect & fromRect
(h.top - u.top) / (h.left - u.left) === (d.top - u.top) / (d.left - u.left) && (s = Bo(h, f, y, o.options)), ht(u, d) || (l.prevFromRect = d, l.prevToRect = u, s || (s = o.options.animation), o.animate(l, h, u, s)), s && (r = !0, i = Math.max(i, s), clearTimeout(l.animationResetTimer), l.animationResetTimer = setTimeout(function() {
l.animationTime = 0, l.prevFromRect = null, l.fromRect = null, l.prevToRect = null, l.thisAnimationDuration = null;
}, s), l.thisAnimationDuration = s);
}), clearTimeout(n), r ? n = setTimeout(function() {
typeof t == "function" && t();
}, i) : typeof t == "function" && t(), e = [];
},
animate: function(t, o, r, i) {
if (i) {
g(t, "transition", ""), g(t, "transform", "");
var a = xe(this.el), s = a && a.a, l = a && a.d, d = (o.left - r.left) / (s || 1), u = (o.top - r.top) / (l || 1);
t.animatingX = !!d, t.animatingY = !!u, g(t, "transform", "translate3d(" + d + "px," + u + "px,0)"), this.forRepaintDummy = Mo(t), g(t, "transition", "transform " + i + "ms" + (this.options.easing ? " " + this.options.easing : "")), g(t, "transform", "translate3d(0,0,0)"), typeof t.animated == "number" && clearTimeout(t.animated), t.animated = setTimeout(function() {
g(t, "transition", ""), g(t, "transform", ""), t.animated = !1, t.animatingX = !1, t.animatingY = !1;
}, i);
}
}
};
}
function Mo(e) {
return e.offsetWidth;
}
function Bo(e, n, t, o) {
return Math.sqrt(Math.pow(n.top - e.top, 2) + Math.pow(n.left - e.left, 2)) / Math.sqrt(Math.pow(n.top - t.top, 2) + Math.pow(n.left - t.left, 2)) * o.animation;
}
var Ce = [], pt = {
initializeByDefault: !0
}, Ve = {
mount: function(e) {
for (var n in pt)
pt.hasOwnProperty(n) && !(n in e) && (e[n] = pt[n]);
Ce.forEach(function(t) {
if (t.pluginName === e.pluginName)
throw "Sortable: Cannot mount plugin ".concat(e.pluginName, " more than once");
}), Ce.push(e);
},
pluginEvent: function(e, n, t) {
var o = this;
this.eventCanceled = !1, t.cancel = function() {
o.eventCanceled = !0;
};
var r = e + "Global";
Ce.forEach(function(i) {
n[i.pluginName] && (n[i.pluginName][r] && n[i.pluginName][r](se({
sortable: n
}, t)), n.options[i.pluginName] && n[i.pluginName][e] && n[i.pluginName][e](se({
sortable: n
}, t)));
});
},
initializePlugins: function(e, n, t, o) {
Ce.forEach(function(a) {
var s = a.pluginName;
if (!(!e.options[s] && !a.initializeByDefault)) {
var l = new a(e, n, e.options);
l.sortable = e, l.options = e.options, e[s] = l, pe(t, l.defaults);
}
});
for (var r in e.options)
if (e.options.hasOwnProperty(r)) {
var i = this.modifyOption(e, r, e.options[r]);
typeof i < "u" && (e.options[r] = i);
}
},
getEventProperties: function(e, n) {
var t = {};
return Ce.forEach(function(o) {
typeof o.eventProperties == "function" && pe(t, o.eventProperties.call(n[o.pluginName], e));
}), t;
},
modifyOption: function(e, n, t) {
var o;
return Ce.forEach(function(r) {
e[r.pluginName] && r.optionListeners && typeof r.optionListeners[n] == "function" && (o = r.optionListeners[n].call(e[r.pluginName], t));
}), o;
}
};
function Ro(e) {
var n = e.sortable, t = e.rootEl, o = e.name, r = e.targetEl, i = e.cloneEl, a = e.toEl, s = e.fromEl, l = e.oldIndex, d = e.newIndex, u = e.oldDraggableIndex, f = e.newDraggableIndex, y = e.originalEvent, h = e.putSortable, k = e.extraEventProperties;
if (n = n || t && t[Z], !!n) {
var w, F = n.options, x = "on" + o.charAt(0).toUpperCase() + o.substr(1);
window.CustomEvent && !ge && !He ? w = new CustomEvent(o, {
bubbles: !0,
cancelable: !0
}) : (w = document.createEvent("Event"), w.initEvent(o, !0, !0)), w.to = a || t, w.from = s || t, w.item = r || t, w.clone = i, w.oldIndex = l, w.newIndex = d, w.oldDraggableIndex = u, w.newDraggableIndex = f, w.originalEvent = y, w.pullMode = h ? h.lastPutMode : void 0;
var z = se(se({}, k), Ve.getEventProperties(o, n));
for (var S in z)
w[S] = z[S];
t && t.dispatchEvent(w), F[x] && F[x].call(n, w);
}
}
var zo = ["evt"], q = function(e, n) {
var t = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, o = t.evt, r = ko(t, zo);
Ve.pluginEvent.bind(m)(e, n, se({
dragEl: c,
parentEl: I,
ghostEl: v,
rootEl: P,
nextEl: _e,
lastDownEl: Je,
cloneEl: N,
cloneHidden: ve,
dragStarted: Ie,
putSortable: V,
activeSortable: m.active,
originalEvent: o,
oldIndex: Oe,
oldDraggableIndex: Xe,
newIndex: Q,
newDraggableIndex: me,
hideGhostForTarget: xn,
unhideGhostForTarget: An,
cloneNowHidden: function() {
ve = !0;
},
cloneNowShown: function() {
ve = !1;
},
dispatchSortableEvent: function(i) {
L({
sortable: n,
name: i,
originalEvent: o
});
}
}, r));
};
function L(e) {
Ro(se({
putSortable: V,
cloneEl: N,
targetEl: c,
rootEl: P,
oldIndex: Oe,
oldDraggableIndex: Xe,
newIndex: Q,
newDraggableIndex: me
}, e));
}
var c, I, v, P, _e, Je, N, ve, Oe, Q, Xe, me, Ye, V, Te = !1, rt = !1, it = [], ye, oe, gt, mt, nn, on, Ie, De, Fe, je = !1, Le = !1, Ke, Y, vt = [], Dt = !1, at = [], st = typeof document < "u", We = bn, rn = He || ge ? "cssFloat" : "float", Xo = st && !yn && !bn && "draggable" in document.createElement("div"), Tn = function() {
if (st) {
if (ge)
return !1;
var e = document.createElement("x");
return e.style.cssText = "pointer-events:auto", e.style.pointerEvents === "auto";
}
}(), kn = function(e, n) {
var t = g(e), o = parseInt(t.width) - parseInt(t.paddingLeft) - parseInt(t.paddingRight) - parseInt(t.borderLeftWidth) - parseInt(t.borderRightWidth), r = Ae(e, 0, n), i = Ae(e, 1, n), a = r && g(r), s = i && g(i), l = a && parseInt(a.marginLeft) + parseInt(a.marginRight) + R(r).width, d = s && parseInt(s.marginLeft) + parseInt(s.marginRight) + R(i).width;
if (t.display === "flex")
return t.flexDirection === "column" || t.flexDirection === "column-reverse" ? "vertical" : "horizontal";
if (t.display === "grid")
return t.gridTemplateColumns.split(" ").length <= 1 ? "vertical" : "horizontal";
if (r && a.float && a.float !== "none") {
var u = a.float === "left" ? "left" : "right";
return i && (s.clear === "both" || s.clear === u) ? "vertical" : "horizontal";
}
return r && (a.display === "block" || a.display === "flex" || a.display === "table" || a.display === "grid" || l >= o && t[rn] === "none" || i && t[rn] === "none" && l + d > o) ? "vertical" : "horizontal";
}, Fo = function(e, n, t) {
var o = t ? e.left : e.top, r = t ? e.right : e.bottom, i = t ? e.width : e.height, a = t ? n.left : n.top, s = t ? n.right : n.bottom, l = t ? n.width : n.height;
return o === a || r === s || o + i / 2 === a + l / 2;
}, jo = function(e, n) {
var t;
return it.some(function(o) {
var r = o[Z].options.emptyInsertThreshold;
if (!(!r || Bt(o))) {
var i = R(o), a = e >= i.left - r && e <= i.right + r, s = n >= i.top - r && n <= i.bottom + r;
if (a && s)
return t = o;
}
}), t;
}, On = function(e) {
function n(r, i) {
return function(a, s, l, d) {
var u = a.options.group.name && s.options.group.name && a.options.group.name === s.options.group.name;
if (r == null && (i || u))
return !0;
if (r == null || r === !1)
return !1;
if (i && r === "clone")
return r;
if (typeof r == "function")
return n(r(a, s, l, d), i)(a, s, l, d);
var f = (i ? a : s).options.group.name;
return r === !0 || typeof r == "string" && r === f || r.join && r.indexOf(f) > -1;
};
}
var t = {}, o = e.group;
(!o || Ge(o) != "object") && (o = {
name: o
}), t.name = o.name, t.checkPull = n(o.pull, !0), t.checkPut = n(o.put), t.revertClone = o.revertClone, e.group = t;
}, xn = function() {
!Tn && v && g(v, "display", "none");
}, An = function() {
!Tn && v && g(v, "display", "");
};
st && !yn && document.addEventListener("click", function(e) {
if (rt)
return e.preventDefault(), e.stopPropagation && e.stopPropagation(), e.stopImmediatePropagation && e.stopImmediatePropagation(), rt = !1, !1;
}, !0);
var we = function(e) {
if (c) {
e = e.touches ? e.touches[0] : e;
var n = jo(e.clientX, e.clientY);
if (n) {
var t = {};
for (var o in e)
e.hasOwnProperty(o) && (t[o] = e[o]);
t.target = t.rootEl = n, t.preventDefault = void 0, t.stopPropagation = void 0, n[Z]._onDragOver(t);
}
}
}, Ho = function(e) {
c && c.parentNode[Z]._isOutsideThisEl(e.target);
};
function m(e, n) {
if (!(e && e.nodeType && e.nodeType === 1))
throw "Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(e));
this.el = e, this.options = n = pe({}, n), e[Z] = this;
var t = {
group: null,
sort: !0,
disabled: !1,
store: null,
handle: null,
draggable: /^[uo]l$/i.test(e.nodeName) ? ">li" : ">*",
swapThreshold: 1,
// percentage; 0 <= x <= 1
invertSwap: !1,
// invert always
invertedSwapThreshold: null,
// will be set to same as swapThreshold if default
removeCloneOnHide: !0,
direction: function() {
return kn(e, this.options);
},
ghostClass: "sortable-ghost",
chosenClass: "sortable-chosen",
dragClass: "sortable-drag",
ignore: "a, img",
filter: null,
preventOnFilter: !0,
animation: 0,
easing: null,
setData: function(i, a) {
i.setData("Text", a.textContent);
},
dropBubble: !1,
dragoverBubble: !1,
dataIdAttr: "data-id",
delay: 0,
delayOnTouchOnly: !1,
touchStartThreshold: (Number.parseInt ? Number : window).parseInt(window.devicePixelRatio, 10) || 1,
forceFallback: !1,
fallbackClass: "sortable-fallback",
fallbackOnBody: !1,
fallbackTolerance: 0,
fallbackOffset: {
x: 0,
y: 0
},
supportPointer: m.supportPointer !== !1 && "PointerEvent" in window && !Re,
emptyInsertThreshold: 5
};
Ve.initializePlugins(this, e, t);
for (var o in t)
!(o in n) && (n[o] = t[o]);
On(n);
for (var r in this)
r.charAt(0) === "_" && typeof this[r] == "function" && (this[r] = this[r].bind(this));
this.nativeDraggable = n.forceFallback ? !1 : Xo, this.nativeDraggable && (this.options.touchStartThreshold = 1), n.supportPointer ? D(e, "pointerdown", this._onTapStart) : (D(e, "mousedown", this._onTapStart), D(e, "touchstart", this._onTapStart)), this.nativeDraggable && (D(e, "dragover", this), D(e, "dragenter", this)), it.push(this.el), n.store && n.store.get && this.sort(n.store.get(this) || []), pe(this, Io());
}
m.prototype = /** @lends Sortable.prototype */
{
constructor: m,
_isOutsideThisEl: function(e) {
!this.el.contains(e) && e !== this.el && (De = null);
},
_getDirection: function(e, n) {
return typeof this.options.direction == "function" ? this.options.direction.call(this, e, n, c) : this.options.direction;
},
_onTapStart: function(e) {
if (e.cancelable) {
var n = this, t = this.el, o = this.options, r = o.preventOnFilter, i = e.type, a = e.touches && e.touches[0] || e.pointerType && e.pointerType === "touch" && e, s = (a || e).target, l = e.target.shadowRoot && (e.path && e.path[0] || e.composedPath && e.composedPath()[0]) || s, d = o.filter;
if (Go(t), !c && !(/mousedown|pointerdown/.test(i) && e.button !== 0 || o.disabled) && !l.isContentEditable && !(!this.nativeDraggable && Re && s && s.tagName.toUpperCase() === "SELECT") && (s = re(s, o.draggable, t, !1), !(s && s.animated) && Je !== s)) {
if (Oe = ne(s), Xe = ne(s, o.draggable), typeof d == "function") {
if (d.call(this, e, s, this)) {
L({
sortable: n,
rootEl: l,
name: "filter",
targetEl: s,
toEl: t,
fromEl: t
}), q("filter", n, {
evt: e
}), r && e.cancelable && e.preventDefault();
return;
}
} else if (d && (d = d.split(",").some(function(u) {
if (u = re(l, u.trim(), t, !1), u)
return L({
sortable: n,
rootEl: u,
name: "filter",
targetEl: s,
fromEl: t,
toEl: t
}), q("filter", n, {
evt: e
}), !0;
}), d)) {
r && e.cancelable && e.preventDefault();
return;
}
o.handle && !re(l, o.handle, t, !1) || this._prepareDragStart(e, a, s);
}
}
},
_prepareDragStart: function(e, n, t) {
var o = this, r = o.el, i = o.options, a = r.ownerDocument, s;
if (t && !c && t.parentNode === r) {
var l = R(t);
if (P = r, c = t, I = c.parentNode, _e = c.nextSibling, Je = t, Ye = i.group, m.dragged = c, ye = {
target: c,
clientX: (n || e).clientX,
clientY: (n || e).clientY
}, nn = ye.clientX - l.left, on = ye.clientY - l.top, this._lastX = (n || e).clientX, this._lastY = (n || e).clientY, c.style["will-change"] = "all", s = function() {
if (q("delayEnded", o, {
evt: e
}), m.eventCanceled) {
o._onDrop();
return;
}
o._disableDelayedDragEvents(), !Qt && o.nativeDraggable && (c.draggable = !0), o._triggerDragStart(e, n), L({
sortable: o,
name: "choose",
originalEvent: e
}), K(c, i.chosenClass, !0);
}, i.ignore.split(",").forEach(function(d) {
_n(c, d.trim(), bt);
}), D(a, "dragover", we), D(a, "mousemove", we), D(a, "touchmove", we), D(a, "mouseup", o._onDrop), D(a, "touchend", o._onDrop), D(a, "touchcancel", o._onDrop), Qt && this.nativeDraggable && (this.options.touchStartThreshold = 4, c.draggable = !0), q("delayStart", this, {
evt: e
}), i.delay && (!i.delayOnTouchOnly || n) && (!this.nativeDraggable || !(He || ge))) {
if (m.eventCanceled) {
this._onDrop();
return;
}
D(a, "mouseup", o._disableDelayedDrag), D(a, "touchend", o._disableDelayedDrag), D(a, "touchcancel", o._disableDelayedDrag), D(a, "mousemove", o._delayedDragTouchMoveHandler), D(a, "touchmove", o._delayedDragTouchMoveHandler), i.supportPointer && D(a, "pointermove", o._delayedDragTouchMoveHandler), o._dragStartTimer = setTimeout(s, i.delay);
} else
s();
}
},
_delayedDragTouchMoveHandler: function(e) {
var n = e.touches ? e.touches[0] : e;
Math.max(Math.abs(n.clientX - this._lastX), Math.abs(n.clientY - this._lastY)) >= Math.floor(this.options.touchStartThreshold / (this.nativeDraggable && window.devicePixelRatio || 1)) && this._disableDelayedDrag();
},
_disableDelayedDrag: function() {
c && bt(c), clearTimeout(this._dragStartTimer), this._disableDelayedDragEvents();
},
_disableDelayedDragEvents: function() {
var e = this.el.ownerDocument;
C(e, "mouseup", this._disableDelayedDrag), C(e, "touchend", this._disableDelayedDrag), C(e, "touchcancel", this._disableDelayedDrag), C(e, "mousemove", this._delayedDragTouchMoveHandler), C(e, "touchmove", this._delayedDragTouchMoveHandler), C(e, "pointermove", this._delayedDragTouchMoveHandler);
},
_triggerDragStart: function(e, n) {
n = n || e.pointerType == "touch" && e, !this.nativeDraggable || n ? this.options.supportPointer ? D(document, "pointermove", this._onTouchMove) : n ? D(document, "touchmove", this._onTouchMove) : D(document, "mousemove", this._onTouchMove) : (D(c, "dragend", this), D(P, "dragstart", this._onDragStart));
try {
document.selection ? Qe(function() {
document.selection.empty();
}) : window.getSelection().removeAllRanges();
} catch {
}
},
_dragStarted: function(e, n) {
if (Te = !1, P && c) {
q("dragStarted", this, {
evt: n
}), this.nativeDraggable && D(document, "dragover", Ho);
var t = this.options;
!e && K(c, t.dragClass, !1), K(c, t.ghostClass, !0), m.active = this, e && this._appendGhost(), L({
sortable: this,
name: "start",
originalEvent: n
});
} else
this._nulling();
},
_emulateDragOver: function() {
if (oe) {
this._lastX = oe.clientX, this._lastY = oe.clientY, xn();
for (var e = document.elementFromPoint(oe.clientX, oe.clientY), n = e; e && e.shadowRoot && (e = e.shadowRoot.elementFromPoint(oe.clientX, oe.clientY), e !== n); )
n = e;
if (c.parentNode[Z]._isOutsideThisEl(e), n)
do {
if (n[Z]) {
var t = void 0;
if (t = n[Z]._onDragOver({
clientX: oe.clientX,
clientY: oe.clientY,
target: e,
rootEl: n
}), t && !this.options.dragoverBubble)
break;
}
e = n;
} while (n = n.parentNode);
An();
}
},
_onTouchMove: function(e) {
if (ye) {
var n = this.options, t = n.fallbackTolerance, o = n.fallbackOffset, r = e.touches ? e.touches[0] : e, i = v && xe(v, !0), a = v && i && i.a, s = v && i && i.d, l = We && Y && tn(Y), d = (r.clientX - ye.clientX + o.x) / (a || 1) + (l ? l[0] - vt[0] : 0) / (a || 1), u = (r.clientY - ye.clientY + o.y) / (s || 1) + (l ? l[1] - vt[1] : 0) / (s || 1);
if (!m.active && !Te) {
if (t && Math.max(Math.abs(r.clientX - this._lastX), Math.abs(r.clientY - this._lastY)) < t)
return;
this._onDragStart(e, !0);
}
if (v) {
i ? (i.e += d - (gt || 0), i.f += u - (mt || 0)) : i = {
a: 1,
b: 0,
c: 0,
d: 1,
e: d,
f: u
};
var f = "matrix(".concat(i.a, ",").concat(i.b, ",").concat(i.c, ",").concat(i.d, ",").concat(i.e, ",").concat(i.f, ")");
g(v, "webkitTransform", f), g(v, "mozTransform", f), g(v, "msTransform", f), g(v, "transform", f), gt = d, mt = u, oe = r;
}
e.cancelable && e.preventDefault();
}
},
_appendGhost: function() {
if (!v) {
var e = this.options.fallbackOnBody ? document.body : P, n = R(c, !0, We, !0, e), t = this.options;
if (We) {
for (Y = e; g(Y, "position") === "static" && g(Y, "transform") === "none" && Y !== document; )
Y = Y.parentNode;
Y !== document.body && Y !== document.documentElement ? (Y === document && (Y = le()), n.top += Y.scrollTop, n.left += Y.scrollLeft) : Y = le(), vt = tn(Y);
}
v = c.cloneNode(!0), K(v, t.ghostClass, !1), K(v, t.fallbackClass, !0), K(v, t.dragClass, !0), g(v, "transition", ""), g(v, "transform", ""), g(v, "box-sizing", "border-box"), g(v, "margin", 0), g(v, "top", n.top), g(v, "left", n.left), g(v, "width", n.width), g(v, "height", n.height), g(v, "opacity", "0.8"), g(v, "position", We ? "absolute" : "fixed"), g(v, "zIndex", "100000"), g(v, "pointerEvents", "none"), m.ghost = v, e.appendChild(v), g(v, "transform-origin", nn / parseInt(v.style.width) * 100 + "% " + on / parseInt(v.style.height) * 100 + "%");
}
},
_onDragStart: function(e, n) {
var t = this, o = e.dataTransfer, r = t.options;
if (q("dragStart", this, {
evt: e
}), m.eventCanceled) {
this._onDrop();
return;
}
q("setupClone", this), m.eventCanceled || (N = Cn(c), N.removeAttribute("id"), N.draggable = !1, N.style["will-change"] = "", this._hideClone(), K(N, this.options.chosenClass, !1), m.clone = N), t.cloneId = Qe(function() {
q("clone", t), !m.eventCanceled && (t.options.removeCloneOnHide || P.insertBefore(N, c), t._hideClone(), L({
sortable: t,
name: "clone"
}));
}), !n && K(c, r.dragClass, !0), n ? (rt = !0, t._loopId = setInterval(t._emulateDragOver, 50)) : (C(document, "mouseup", t._onDrop), C(document, "touchend", t._onDrop), C(document, "touchcancel", t._onDrop), o && (o.effectAllowed = "move", r.setData && r.setData.call(t, o, c)), D(document, "drop", t), g(c, "transform", "translateZ(0)")), Te = !0, t._dragStartId = Qe(t._dragStarted.bind(t, n, e)), D(document, "selectstart", t), Ie = !0, Re && g(document.body, "user-select", "none");
},
// Returns true - if no further action is needed (either inserted or another condition)
_onDragOver: function(e) {
var n = this.el, t = e.target, o, r, i, a = this.options, s = a.group, l = m.active, d = Ye === s, u = a.sort, f = V || l, y, h = this, k = !1;
if (Dt)
return;
function w(ue, ct) {
q(ue, h, se({
evt: e,
isOwner: d,
axis: y ? "vertical" : "horizontal",
revert: i,
dragRect: o,
targetRect: r,
canSort: u,
fromSortable: f,
target: t,
completed: x,
onMove: function(Ue, ut) {
return $e(P, n, c, o, Ue, R(Ue), e, ut);
},
changed: z
}, ct));
}
function F() {
w("dragOverAnimationCapture"), h.captureAnimationState(), h !== f && f.captureAnimationState();
}
function x(ue) {
return w("dragOverCompleted", {
insertion: ue
}), ue && (d ? l._hideClone() : l._showClone(h), h !== f && (K(c, V ? V.options.ghostClass : l.options.ghostClass, !1), K(c, a.ghostClass, !0)), V !== h && h !== m.active ? V = h : h === m.active && V && (V = null), f === h && (h._ignoreWhileAnimating = t), h.animateAll(function() {
w("dragOverAnimationComplete"), h._ignoreWhileAnimating = null;
}), h !== f && (f.animateAll(), f._ignoreWhileAnimating = null)), (t === c && !c.animated || t === n && !t.animated) && (De = null), !a.dragoverBubble && !e.rootEl && t !== document && (c.parentNode[Z]._isOutsideThisEl(e.target), !ue && we(e)), !a.dragoverBubble && e.stopPropagation && e.stopPropagation(), k = !0;
}
function z() {
Q = ne(c), me = ne(c, a.draggable), L({
sortable: h,
name: "change",
toEl: n,
newIndex: Q,
newDraggableIndex: me,
originalEvent: e
});
}
if (e.preventDefault !== void 0 && e.cancelable && e.preventDefault(), t = re(t, a.draggable, n, !0), w("dragOver"), m.eventCanceled)
return k;
if (c.contains(e.target) || t.animated && t.animatingX && t.animatingY || h._ignoreWhileAnimating === t)
return x(!1);
if (rt = !1, l && !a.disabled && (d ? u || (i = I !== P) : V === this || (this.lastPutMode = Ye.checkPull(this, l, c, e)) && s.checkPut(this, l, c, e))) {
if (y = this._getDirection(e, t) === "vertical", o = R(c), w("dragOverValid"), m.eventCanceled)
return k;
if (i)
return I = P, F(), this._hideClone(), w("revert"), m.eventCanceled || (_e ? P.insertBefore(c, _e) : P.appendChild(c)), x(!0);
var S = Bt(n, a.draggable);
if (!S || Lo(e, y, this) && !S.animated) {
if (S === c)
return x(!1);
if (S && n === e.target && (t = S), t && (r = R(t)), $e(P, n, c, o, t, r, e, !!t) !== !1)
return F(), S && S.nextSibling ? n.insertBefore(c, S.nextSibling) : n.appendChild(c), I = n, z(), x(!0);
} else if (S && Yo(e, y, this)) {
var O = Ae(n, 0, a, !0);
if (O === c)
return x(!1);
if (t = O, r = R(t), $e(P, n, c, o, t, r, e, !1) !== !1)
return F(), n.insertBefore(c, O), I = n, z(), x(!0);
} else if (t.parentNode === n) {
r = R(t);
var H = 0, G, p = c.parentNode !== n, _ = !Fo(c.animated && c.toRect || o, t.animated && t.toRect || r, y), T = y ? "top" : "left", A = en(t, "top", "top") || en(c, "top", "top"), W = A ? A.scrollTop : void 0;
De !== t && (G = r[T], je = !1, Le = !_ && a.invertSwap || p), H = Wo(e, t, r, y, _ ? 1 : a.swapThreshold, a.invertedSwapThreshold == null ? a.swapThreshold : a.invertedSwapThreshold, Le, De === t);
var j;
if (H !== 0) {
var ee = ne(c);
do
ee -= H, j = I.children[ee];
while (j && (g(j, "display") === "none" || j === v));
}
if (H === 0 || j === t)
return x(!1);
De = t, Fe = H;
var J = t.nextElementSibling, ie = !1;
ie = H === 1;
var ce = $e(P, n, c, o, t, r, e, ie);
if (ce !== !1)
return (ce === 1 || ce === -1) && (ie = ce === 1), Dt = !0, setTimeout(Uo, 30), F(), ie && !J ? n.appendChild(c) : t.parentNode.insertBefore(c, ie ? J : t), A && En(A, 0, W - A.scrollTop), I = c.parentNode, G !== void 0 && !Le && (Ke = Math.abs(G - R(t)[T])), z(), x(!0);
}
if (n.contains(c))
return x(!1);
}
return !1;
},
_ignoreWhileAnimating: null,
_offMoveEvents: function() {
C(document, "mousemove", this._onTouchMove), C(document, "touchmove", this._onTouchMove), C(document, "pointermove", this._onTouchMove), C(document, "dragover", we), C(document, "mousemove", we), C(document, "touchmove", we);
},
_offUpEvents: function() {
var e = this.el.ownerDocument;
C(e, "mouseup", this._onDrop), C(e, "touchend", this._onDrop), C(e, "pointerup", this._onDrop), C(e, "touchcancel", this._onDrop), C(document, "selectstart", this);
},
_onDrop: function(e) {
var n = this.el, t = this.options;
if (Q = ne(c), me = ne(c, t.draggable), q("drop", this, {
evt: e
}), I = c && c.parentNode, Q = ne(c), me = ne(c, t.draggable), m.eventCanceled) {
this._nulling();
return;
}
Te = !1, Le = !1, je = !1, clearInterval(this._loopId), clearTimeout(this._dragStartTimer), Tt(this.cloneId), Tt(this._dragStartId), this.nativeDraggable && (C(document, "drop", this), C(n, "dragstart", this._onDragStart)), this._offMoveEvents(), this._offUpEvents(), Re && g(document.body, "user-select", ""), g(c, "transform", ""), e && (Ie && (e.cancelable && e.preventDefault(), !t.dropBubble && e.stopPropagation()), v && v.parentNode && v.parentNode.removeChild(v), (P === I || V && V.lastPutMode !== "clone") && N && N.parentNode && N.parentNode.removeChild(N), c && (this.nativeDraggable && C(c, "dragend", this), bt(c), c.style["will-change"] = "", Ie && !Te && K(c, V ? V.options.ghostClass : this.options.ghostClass, !1), K(c, this.options.chosenClass, !1), L({
sortable: this,
name: "unchoose",
toEl: I,
newIndex: null,
newDraggableIndex: null,
originalEvent: e
}), P !== I ? (Q >= 0 && (L({
rootEl: I,
name: "add",
toEl: I,
fromEl: P,
originalEvent: e
}), L({
sortable: this,
name: "remove",
toEl: I,
originalEvent: e
}), L({
rootEl: I,
name: "sort",
toEl: I,
fromEl: P,
originalEvent: e
}), L({
sortable: this,
name: "sort",
toEl: I,
originalEvent: e
})), V && V.save()) : Q !== Oe && Q >= 0 && (L({
sortable: this,
name: "update",
toEl: I,
originalEvent: e
}), L({
sortable: this,
name: "sort",
toEl: I,
originalEvent: e
})), m.active && ((Q == null || Q === -1) && (Q = Oe, me = Xe), L({
sortable: this,
name: "end",
toEl: I,
originalEvent: e
}), this.save()))), this._nulling();
},
_nulling: function() {
q("nulling", this), P = c = I = v = _e = N = Je = ve = ye = oe = Ie = Q = me = Oe = Xe = De = Fe = V = Ye = m.dragged = m.ghost = m.clone = m.active = null, at.forEach(function(e) {
e.checked = !0;
}), at.length = gt = mt = 0;
},
handleEvent: function(e) {
switch (e.type) {
case "drop":
case "dragend":
this._onDrop(e);
break;
case "dragenter":
case "dragover":
c && (this._onDragOver(e), Vo(e));
break;
case "selectstart":
e.preventDefault();
break;
}
},
/**
* Serializes the item into an array of string.
* @returns {String[]}
*/
toArray: function() {
for (var e = [], n, t = this.el.children, o = 0, r = t.length, i = this.options; o < r; o++)
n = t[o], re(n, i.draggable, this.el, !1) && e.push(n.getAttribute(i.dataIdAttr) || qo(n));
return e;
},
/**
* Sorts the elements according to the array.
* @param {String[]} order order of the items
*/
sort: function(e, n) {
var t = {}, o = this.el;
this.toArray().forEach(function(r, i) {
var a = o.children[i];
re(a, this.options.draggable, o, !1) && (t[r] = a);
}, this), n && this.captureAnimationState(), e.forEach(function(r) {
t[r] && (o.removeChild(t[r]), o.appendChild(t[r]));
}), n && this.animateAll();
},
/**
* Save the current sorting
*/
save: function() {
var e = this.options.store;
e && e.set && e.set(this);
},
/**
* For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
* @param {HTMLElement} el
* @param {String} [selector] default: `options.draggable`
* @returns {HTMLElement|null}
*/
closest: function(e, n) {
return re(e, n || this.options.draggable, this.el, !1);
},
/**
* Set/get option
* @param {string} name
* @param {*} [value]
* @returns {*}
*/
option: function(e, n) {
var t = this.options;
if (n === void 0)
return t[e];
var o = Ve.modifyOption(this, e, n);
typeof o < "u" ? t[e] = o : t[e] = n, e === "group" && On(t);
},
/**
* Destroy
*/
destroy: function() {
q("destroy", this);
var e = this.el;
e[Z] = null, C(e, "mousedown", this._onTapStart), C(e, "touchstart", this._onTapStart), C(e, "pointerdown", this._onTapStart), this.nativeDraggable && (C(e, "dragover", this), C(e, "dragenter", this)), Array.prototype.forEach.call(e.querySelectorAll("[draggable]"), function(n) {
n.removeAttribute("draggable");
}), this._onDrop(), this._disableDelayedDragEvents(), it.splice(it.indexOf(this.el), 1), this.el = e = null;
},
_hideClone: function() {
if (!ve) {
if (q("hideClone", this), m.eventCanceled)
return;
g(N, "display", "none"), this.options.removeCloneOnHide && N.parentNode && N.parentNode.removeChild(N), ve = !0;
}
},
_showClone: function(e) {
if (e.lastPutMode !== "clone") {
this._hideClone();
return;
}
if (ve) {
if (q("showClone", this), m.eventCanceled)
return;
c.parentNode == P && !this.options.group.revertClone ? P.insertBefore(N, c) : _e ? P.insertBefore(N, _e) : P.appendChild(N), this.options.group.revertClone && this.animate(c, N), g(N, "display", ""), ve = !1;
}
}
};
function Vo(e) {
e.dataTransfer && (e.dataTransfer.dropEffect = "move"), e.cancelable && e.preventDefault();
}
function $e(e, n, t, o, r, i, a, s) {
var l, d = e[Z], u = d.options.onMove, f;
return window.CustomEvent && !ge && !He ? l = new CustomEvent("move", {
bubbles: !0,
cancelable: !0
}) : (l = document.createEvent("Event"), l.initEvent("move", !0, !0)), l.to = n, l.from = e, l.dragged = t, l.draggedRect = o, l.related = r || n, l.relatedRect = i || R(n), l.willInsertAfter = s, l.originalEvent = a, e.dispatchEvent(l), u && (f = u.call(d, l, a)), f;
}
function bt(e) {
e.draggable = !1;
}
function Uo() {
Dt = !1;
}
function Yo(e, n, t) {
var o = R(Ae(t.el, 0, t.options, !0)), r = Dn(t.el, t.options, v), i = 10;
return n ? e.clientX < r.left - i || e.clientY < o.top && e.clientX < o.right : e.clientY < r.top - i || e.clientY < o.bottom && e.clientX < o.left;
}
function Lo(e, n, t) {
var o = R(Bt(t.el, t.options.draggable)), r = Dn(t.el, t.options, v), i = 10;
return n ? e.clientX > r.right + i || e.clientY > o.bottom && e.clientX > o.left : e.clientY > r.bottom + i || e.clientX > o.right && e.clientY > o.top;
}
function Wo(e, n, t, o, r, i, a, s) {
var l = o ? e.clientY : e.clientX, d = o ? t.height : t.width, u = o ? t.top : t.left, f = o ? t.bottom : t.right, y = !1;
if (!a) {
if (s && Ke < d * r) {
if (!je && (Fe === 1 ? l > u + d * i / 2 : l < f - d * i / 2) && (je = !0), je)
y = !0;
else if (Fe === 1 ? l < u + Ke : l > f - Ke)
return -Fe;
} else if (l > u + d * (1 - r) / 2 && l < f - d * (1 - r) / 2)
return $o(n);
}
return y = y || a, y && (l < u + d * i / 2 || l > f - d * i / 2) ? l > u + d / 2 ? 1 : -1 : 0;
}
function $o(e) {
return ne(c) < ne(e) ? 1 : -1;