dhtmlx-gantt
Version:
An open source JavaScript Gantt chart that helps you illustrate a project schedule in a nice-looking chart.
1,127 lines (1,121 loc) • 710 kB
JavaScript
/** @license
dhtmlxGantt v.9.0.11 Standard
This version of dhtmlxGantt is distributed under GPL 2.0 license and can be legally used in GPL projects.
To use dhtmlxGantt in non-GPL projects (and get Pro version of the product), please obtain Individual, Commercial, Enterprise or Ultimate license on our site https://dhtmlx.com/docs/products/dhtmlxGantt/#licensing or contact us at info@dhtmlx.com
(c) XB Software
*/
function V(t) {
var e = 0, n = 0, i = 0, a = 0;
if (t.getBoundingClientRect) {
var r = t.getBoundingClientRect(), s = document.body, o = document.documentElement || document.body.parentNode || document.body, l = window.pageYOffset || o.scrollTop || s.scrollTop, d = window.pageXOffset || o.scrollLeft || s.scrollLeft, c = o.clientTop || s.clientTop || 0, u = o.clientLeft || s.clientLeft || 0;
e = r.top + l - c, n = r.left + d - u, i = document.body.offsetWidth - r.right, a = document.body.offsetHeight - r.bottom;
} else {
for (; t; ) e += parseInt(t.offsetTop, 10), n += parseInt(t.offsetLeft, 10), t = t.offsetParent;
i = document.body.offsetWidth - t.offsetWidth - n, a = document.body.offsetHeight - t.offsetHeight - e;
}
return { y: Math.round(e), x: Math.round(n), width: t.offsetWidth, height: t.offsetHeight, right: Math.round(i), bottom: Math.round(a) };
}
function Dn(t) {
var e = !1, n = !1;
if (window.getComputedStyle) {
var i = window.getComputedStyle(t, null);
e = i.display, n = i.visibility;
} else t.currentStyle && (e = t.currentStyle.display, n = t.currentStyle.visibility);
return e != "none" && n != "hidden";
}
function An(t) {
return !isNaN(t.getAttribute("tabindex")) && 1 * t.getAttribute("tabindex") >= 0;
}
function In(t) {
return !{ a: !0, area: !0 }[t.nodeName.loLowerCase()] || !!t.getAttribute("href");
}
function Mn(t) {
return !{ input: !0, select: !0, textarea: !0, button: !0, object: !0 }[t.nodeName.toLowerCase()] || !t.hasAttribute("disabled");
}
function Lt(t) {
for (var e = t.querySelectorAll(["a[href]", "area[href]", "input", "select", "textarea", "button", "iframe", "object", "embed", "[tabindex]", "[contenteditable]"].join(", ")), n = Array.prototype.slice.call(e, 0), i = 0; i < n.length; i++) n[i].$position = i;
for (n.sort(function(r, s) {
return r.tabIndex === 0 && s.tabIndex !== 0 ? 1 : r.tabIndex !== 0 && s.tabIndex === 0 ? -1 : r.tabIndex === s.tabIndex ? r.$position - s.$position : r.tabIndex < s.tabIndex ? -1 : 1;
}), i = 0; i < n.length; i++) {
var a = n[i];
(An(a) || Mn(a) || In(a)) && Dn(a) || (n.splice(i, 1), i--);
}
return n;
}
function Xe() {
var t = document.createElement("div");
t.style.cssText = "visibility:hidden;position:absolute;left:-1000px;width:100px;padding:0px;margin:0px;height:110px;min-height:100px;overflow-y:scroll;", document.body.appendChild(t);
var e = t.offsetWidth - t.clientWidth;
return document.body.removeChild(t), Math.max(e, 15);
}
function X(t) {
if (!t) return "";
var e = t.className || "";
return e.baseVal && (e = e.baseVal), e.indexOf || (e = ""), _e(e);
}
function wt(t, e) {
e && t.className.indexOf(e) === -1 && (t.className += " " + e);
}
function Gt(t, e) {
e = e.split(" ");
for (var n = 0; n < e.length; n++) {
var i = new RegExp("\\s?\\b" + e[n] + "\\b(?![-_.])", "");
t.className = t.className.replace(i, "");
}
}
function we(t) {
return typeof t == "string" ? document.getElementById(t) || document.querySelector(t) || document.body : t || document.body;
}
var Bt;
function Ze(t, e) {
Bt || (Bt = document.createElement("div")), Bt.innerHTML = e;
var n = Bt.firstChild;
return t.appendChild(n), n;
}
function Qe(t) {
t && t.parentNode && t.parentNode.removeChild(t);
}
function tn(t, e) {
for (var n = t.childNodes, i = n.length, a = [], r = 0; r < i; r++) {
var s = n[r];
s.className && s.className.indexOf(e) !== -1 && a.push(s);
}
return a;
}
function yt(t) {
var e;
return t.tagName ? e = t : (e = (t = t || window.event).target || t.srcElement).shadowRoot && t.composedPath && (e = t.composedPath()[0]), e;
}
function nt(t, e) {
if (e) {
for (var n = yt(t); n; ) {
if (n.getAttribute && n.getAttribute(e)) return n;
n = n.parentNode;
}
return null;
}
}
function _e(t) {
return (String.prototype.trim || function() {
return this.replace(/^\s+|\s+$/g, "");
}).apply(t);
}
function pt(t, e, n) {
var i = yt(t), a = "";
for (n === void 0 && (n = !0); i; ) {
if (a = X(i)) {
var r = a.indexOf(e);
if (r >= 0) {
if (!n) return i;
var s = r === 0 || !_e(a.charAt(r - 1)), o = r + e.length >= a.length || !_e(a.charAt(r + e.length));
if (s && o) return i;
}
}
i = i.parentNode;
}
return null;
}
function rt(t, e) {
var n = document.documentElement, i = V(e);
return { x: t.clientX + n.scrollLeft - n.clientLeft - i.x + e.scrollLeft, y: t.clientY + n.scrollTop - n.clientTop - i.y + e.scrollTop };
}
function en(t, e) {
const n = V(t), i = V(e);
return { x: n.x - i.x, y: n.y - i.y };
}
function Y(t, e) {
if (!t || !e) return !1;
for (; t && t != e; ) t = t.parentNode;
return t === e;
}
function dt(t, e) {
if (t.closest) return t.closest(e);
if (t.matches || t.msMatchesSelector || t.webkitMatchesSelector) {
var n = t;
if (!document.documentElement.contains(n)) return null;
do {
if ((n.matches || n.msMatchesSelector || n.webkitMatchesSelector).call(n, e)) return n;
n = n.parentElement || n.parentNode;
} while (n !== null && n.nodeType === 1);
return null;
}
return console.error("Your browser is not supported"), null;
}
function nn(t) {
for (; t; ) {
if (t.offsetWidth > 0 && t.offsetHeight > 0) return t;
t = t.parentElement;
}
return null;
}
function an() {
return document.head.createShadowRoot || document.head.attachShadow;
}
function ge() {
var t = document.activeElement;
return t.shadowRoot && (t = t.shadowRoot.activeElement), t === document.body && document.getSelection && (t = document.getSelection().focusNode || document.body), t;
}
function vt(t) {
if (!t || !an()) return document.body;
for (; t.parentNode && (t = t.parentNode); ) if (t instanceof ShadowRoot) return t.host;
return document.body;
}
const rn = Object.freeze(Object.defineProperty({ __proto__: null, addClassName: wt, closest: dt, getActiveElement: ge, getChildNodes: tn, getClassName: X, getClosestSizedElement: nn, getFocusableNodes: Lt, getNodePosition: V, getRelativeEventPosition: rt, getRelativeNodePosition: en, getRootNode: vt, getScrollSize: Xe, getTargetNode: yt, hasClass: function(t, e) {
return "classList" in t ? t.classList.contains(e) : new RegExp("\\b" + e + "\\b").test(t.className);
}, hasShadowParent: function(t) {
return !!vt(t);
}, insertNode: Ze, isChildOf: Y, isShadowDomSupported: an, locateAttribute: nt, locateClassName: pt, removeClassName: Gt, removeNode: Qe, toNode: we }, Symbol.toStringTag, { value: "Module" })), Z = typeof window < "u" ? window : global;
let Nn = class {
constructor(t) {
this._mouseDown = !1, this._touchStarts = !1, this._touchActive = !1, this._longTapTimer = !1, this._gantt = t, this._domEvents = t._createDomEventScope();
}
attach(t, e, n) {
const i = this._gantt, a = t.getViewPort();
this._originPosition = Z.getComputedStyle(a).display, this._restoreOriginPosition = () => {
a.style.position = this._originPosition;
}, this._originPosition === "static" && (a.style.position = "relative");
const r = i.$services.getService("state");
r.registerProvider("clickDrag", () => ({ autoscroll: !1 }));
let s = null;
const o = () => {
s && (this._mouseDown = !0, t.setStart(i.copy(s)), t.setPosition(i.copy(s)), t.setEnd(i.copy(s)), s = null);
};
this._domEvents.attach(a, "mousedown", (p) => {
u(p);
});
const l = vt(i.$root) || document.body;
function d(p) {
return p.changedTouches && p.changedTouches[0] || p;
}
this._domEvents.attach(l, "mouseup", (p) => {
h(p);
}), this._domEvents.attach(a, "mousemove", (p) => {
g(p);
}), this._domEvents.attach(a, "touchstart", (p) => {
this._touchStarts = !0, this._longTapTimer = setTimeout(() => {
this._touchStarts && (u(d(p)), this._touchStarts = !1, this._touchActive = !0);
}, this._gantt.config.touch_drag);
}), this._domEvents.attach(l, "touchend", (p) => {
this._touchStarts = !1, this._touchActive = !1, clearTimeout(this._longTapTimer), h(d(p));
}), this._domEvents.attach(a, "touchmove", (p) => {
if (this._touchActive) {
let y = c();
if (y && i.utils.dom.closest(p.target, y)) return;
g(d(p)), p.preventDefault();
} else this._touchStarts = !1, clearTimeout(this._longTapTimer);
});
const c = () => {
let p = ".gantt_task_line, .gantt_task_link";
return n !== void 0 && (p = n instanceof Array ? n.join(", ") : n), p;
}, u = (p) => {
s = null;
let y = c();
y && i.utils.dom.closest(p.target, y) || (r.registerProvider("clickDrag", () => ({ autoscroll: this._mouseDown })), e && p[e] !== !0 || (s = this._getCoordinates(p, t)));
}, h = (p) => {
if (s = null, (!e || p[e] === !0) && this._mouseDown === !0) {
this._mouseDown = !1;
const y = this._getCoordinates(p, t);
t.dragEnd(y);
}
}, g = (p) => {
if (e && p[e] !== !0) return;
const y = this._gantt.ext.clickDrag, v = (this._gantt.config.drag_timeline || {}).useKey;
if (y && v && !e && p[v]) return;
let b = null;
if (!this._mouseDown && s) return b = this._getCoordinates(p, t), void (Math.abs(s.relative.left - b.relative.left) > 5 && o());
this._mouseDown === !0 && (b = this._getCoordinates(p, t), t.setEnd(b), t.render());
};
}
detach() {
const t = this._gantt;
this._domEvents.detachAll(), this._restoreOriginPosition && this._restoreOriginPosition(), t.$services.getService("state").unregisterProvider("clickDrag");
}
destructor() {
this.detach();
}
_getCoordinates(t, e) {
const n = e.getViewPort(), i = n.getBoundingClientRect(), { clientX: a, clientY: r } = t;
return { absolute: { left: a, top: r }, relative: { left: a - i.left + n.scrollLeft, top: r - i.top + n.scrollTop } };
}
};
var sn = function() {
this._silent_mode = !1, this.listeners = {};
};
sn.prototype = { _silentStart: function() {
this._silent_mode = !0;
}, _silentEnd: function() {
this._silent_mode = !1;
} };
function ot(t) {
var e = new sn();
t.attachEvent = function(n, i, a) {
n = "ev_" + n.toLowerCase(), e.listeners[n] || (e.listeners[n] = function(s) {
var o = {}, l = 0, d = function() {
var c = !0;
for (var u in o) {
var h = o[u].apply(s, arguments);
c = c && h;
}
return c;
};
return d.addEvent = function(c, u) {
if (typeof c == "function") {
var h;
if (u && u.id ? h = u.id : (h = l, l++), u && u.once) {
var g = c;
c = function() {
g(), d.removeEvent(h);
};
}
return o[h] = c, h;
}
return !1;
}, d.removeEvent = function(c) {
delete o[c];
}, d.clear = function() {
o = {};
}, d;
}(this)), a && a.thisObject && (i = i.bind(a.thisObject));
var r = n + ":" + e.listeners[n].addEvent(i, a);
return a && a.id && (r = a.id), r;
}, t.attachAll = function(n) {
this.attachEvent("listen_all", n);
}, t.callEvent = function(n, i) {
if (e._silent_mode) return !0;
var a = "ev_" + n.toLowerCase(), r = e.listeners;
return r.ev_listen_all && r.ev_listen_all.apply(this, [n].concat(i)), !r[a] || r[a].apply(this, i);
}, t.checkEvent = function(n) {
return !!e.listeners["ev_" + n.toLowerCase()];
}, t.detachEvent = function(n) {
if (n) {
var i = e.listeners;
for (var a in i) i[a].removeEvent(n);
var r = n.split(":");
if (i = e.listeners, r.length === 2) {
var s = r[0], o = r[1];
i[s] && i[s].removeEvent(o);
}
}
}, t.detachAllEvents = function() {
for (var n in e.listeners) e.listeners[n].clear();
};
}
var Ce = { second: 1, minute: 60, hour: 3600, day: 86400, week: 604800, month: 2592e3, quarter: 7776e3, year: 31536e3 };
function Vt(t) {
return Ce[t] || Ce.hour;
}
function kt(t, e) {
if (t.forEach) t.forEach(e);
else for (var n = t.slice(), i = 0; i < n.length; i++) e(n[i], i);
}
function Ln(t, e) {
if (t.find) return t.find(e);
for (var n = 0; n < t.length; n++) if (e(t[n], n)) return t[n];
}
function zt(t, e) {
if (t.includes) return t.includes(e);
for (var n = 0; n < t.length; n++) if (t[n] === e) return !0;
return !1;
}
function fe(t) {
return Array.isArray ? Array.isArray(t) : t && t.length !== void 0 && t.pop && t.push;
}
function Q(t) {
return !(!t || typeof t != "object") && !!(t.getFullYear && t.getMonth && t.getDate);
}
function bt(t) {
return Q(t) && !isNaN(t.getTime());
}
function De(t, e) {
var n, i = function() {
i.$cancelTimeout(), i.$pending = !0;
var a = Array.prototype.slice.call(arguments);
n = setTimeout(function() {
t.apply(this, a), i.$pending = !1;
}, e);
};
return i.$pending = !1, i.$cancelTimeout = function() {
clearTimeout(n), i.$pending = !1;
}, i.$execute = function() {
var a = Array.prototype.slice.call(arguments);
t.apply(this, a), i.$cancelTimeout();
}, i;
}
function at(t, e) {
return Ae(t) && !Ae(e) && (t = "0"), t;
}
function Ae(t) {
return t === 0;
}
function At(t, e) {
for (var n, i, a, r = 0, s = t.length - 1; r <= s; ) if (i = +t[n = Math.floor((r + s) / 2)], a = +t[n - 1], i < e) r = n + 1;
else {
if (!(i > e)) {
for (; +t[n] == +t[n + 1]; ) n++;
return n;
}
if (!isNaN(a) && a < e) return n - 1;
s = n - 1;
}
return t.length - 1;
}
class Pn {
constructor(e, n, i) {
var a;
this._el = document.createElement("div"), this.defaultRender = (r, s) => {
this._el || (this._el = document.createElement("div"));
const o = this._el, l = Math.min(r.relative.top, s.relative.top), d = Math.max(r.relative.top, s.relative.top), c = Math.min(r.relative.left, s.relative.left), u = Math.max(r.relative.left, s.relative.left);
if (this._singleRow) {
const h = this._getTaskPositionByTop(this._startPoint.relative.top);
o.style.height = h.height + "px", o.style.top = h.top + "px";
} else o.style.height = Math.abs(d - l) + "px", o.style.top = l + "px";
return o.style.width = Math.abs(u - c) + "px", o.style.left = c + "px", o;
}, this._gantt = n, this._view = i, this._viewPort = e.viewPort, this._el.classList.add(e.className), typeof e.callback == "function" && (this._callback = e.callback), this.render = () => {
let r;
r = e.render ? e.render(this._startPoint, this._endPoint) : this.defaultRender(this._startPoint, this._endPoint), r !== this._el && (this._el && this._el.parentNode && this._el.parentNode.removeChild(this._el), this._el = r), e.className !== "" && this._el.classList.add(e.className), this.draw();
}, (a = this._viewPort).attachEvent && a.detachEvent || ot(this._viewPort), this._singleRow = e.singleRow, this._useRequestAnimationFrame = e.useRequestAnimationFrame;
}
draw() {
if (this._useRequestAnimationFrame) return requestAnimationFrame(() => {
this._viewPort.appendChild(this.getElement());
});
this._viewPort.appendChild(this.getElement());
}
clear() {
if (this._useRequestAnimationFrame) return requestAnimationFrame(() => {
this._el.parentNode && this._viewPort.removeChild(this._el);
});
this._el.parentNode && this._viewPort.removeChild(this._el);
}
getElement() {
return this._el;
}
getViewPort() {
return this._viewPort;
}
setStart(e) {
const n = this._gantt;
this._startPoint = e, this._startDate = n.dateFromPos(this._startPoint.relative.left), this._viewPort.callEvent("onBeforeDrag", [this._startPoint]);
}
setEnd(e) {
const n = this._gantt;
if (this._endPoint = e, this._singleRow) {
const i = this._getTaskPositionByTop(this._startPoint.relative.top);
this._endPoint.relative.top = i.top;
}
this._endDate = n.dateFromPos(this._endPoint.relative.left), this._startPoint.relative.left > this._endPoint.relative.left && (this._positionPoint = { relative: { left: this._endPoint.relative.left, top: this._positionPoint.relative.top }, absolute: { left: this._endPoint.absolute.left, top: this._positionPoint.absolute.top } }), this._startPoint.relative.top > this._endPoint.relative.top && (this._positionPoint = { relative: { left: this._positionPoint.relative.left, top: this._endPoint.relative.top }, absolute: { left: this._positionPoint.absolute.left, top: this._endPoint.absolute.top } }), this._viewPort.callEvent("onDrag", [this._startPoint, this._endPoint]);
}
setPosition(e) {
this._positionPoint = e;
}
dragEnd(e) {
const n = this._gantt;
e.relative.left < 0 && (e.relative.left = 0), this._viewPort.callEvent("onBeforeDragEnd", [this._startPoint, e]), this.setEnd(e), this._endDate = this._endDate || n.getState().max_date, this._startDate.valueOf() > this._endDate.valueOf() && ([this._startDate, this._endDate] = [this._endDate, this._startDate]), this.clear();
const i = n.getTaskByTime(this._startDate, this._endDate), a = this._getTasksByTop(this._startPoint.relative.top, this._endPoint.relative.top);
this._viewPort.callEvent("onDragEnd", [this._startPoint, this._endPoint]), this._callback && this._callback(this._startPoint, this._endPoint, this._startDate, this._endDate, i, a);
}
getInBounds() {
return this._singleRow;
}
_getTasksByTop(e, n) {
const i = this._gantt;
let a = e, r = n;
e > n && (a = n, r = e);
const s = this._getTaskPositionByTop(a).index, o = this._getTaskPositionByTop(r).index, l = [];
for (let d = s; d <= o; d++)
i.getTaskByIndex(d) && l.push(i.getTaskByIndex(d));
return l;
}
_getTaskPositionByTop(e) {
const n = this._gantt, i = this._view, a = i.getItemIndexByTopPosition(e), r = n.getTaskByIndex(a);
if (r) {
const s = i.getItemHeight(r.id);
return { top: i.getItemTop(r.id) || 0, height: s || 0, index: a };
}
{
const s = i.getTotalHeight();
return { top: e > s ? s : 0, height: n.config.row_height, index: e > s ? n.getTaskCount() : 0 };
}
}
}
let te = !1;
class Yt {
constructor(e) {
this._mouseDown = !1, this._calculateDirectionVector = () => {
if (this._trace.length >= 10) {
const n = this._trace.slice(this._trace.length - 10), i = [];
for (let r = 1; r < n.length; r++) i.push({ x: n[r].x - n[r - 1].x, y: n[r].y - n[r - 1].y });
const a = { x: 0, y: 0 };
return i.forEach((r) => {
a.x += r.x, a.y += r.y;
}), { magnitude: Math.sqrt(a.x * a.x + a.y * a.y), angleDegrees: 180 * Math.atan2(Math.abs(a.y), Math.abs(a.x)) / Math.PI };
}
return null;
}, this._applyDndReadyStyles = () => {
this._timeline.$task.classList.add("gantt_timeline_move_available");
}, this._clearDndReadyStyles = () => {
this._timeline.$task.classList.remove("gantt_timeline_move_available");
}, this._getScrollPosition = (n) => {
const i = this._gantt;
return { x: i.$ui.getView(n.$config.scrollX).getScrollState().position, y: i.$ui.getView(n.$config.scrollY).getScrollState().position };
}, this._countNewScrollPosition = (n) => {
const i = this._calculateDirectionVector();
let a = this._startPoint.x - n.x, r = this._startPoint.y - n.y;
return i && (i.angleDegrees < 15 ? r = 0 : i.angleDegrees > 75 && (a = 0)), { x: this._scrollState.x + a, y: this._scrollState.y + r };
}, this._setScrollPosition = (n, i) => {
const a = this._gantt;
requestAnimationFrame(() => {
a.scrollLayoutCell(n.$id, i.x, i.y);
});
}, this._stopDrag = (n) => {
const i = this._gantt;
if (this._trace = [], i.$root.classList.remove("gantt_noselect"), this._originalReadonly !== void 0 && this._mouseDown && (i.config.readonly = this._originalReadonly, i.config.drag_timeline && i.config.drag_timeline.render && i.render()), this._originAutoscroll !== void 0 && (i.config.autoscroll = this._originAutoscroll), i.config.drag_timeline) {
const { useKey: a } = i.config.drag_timeline;
if (a && n[a] !== !0) return;
}
this._mouseDown = !1, te = !1;
}, this._startDrag = (n) => {
const i = this._gantt;
this._originAutoscroll = i.config.autoscroll, i.config.autoscroll = !1, te = !0, i.$root.classList.add("gantt_noselect"), this._originalReadonly = i.config.readonly, i.config.readonly = !0, i.config.drag_timeline && i.config.drag_timeline.render && i.render(), this._trace = [], this._mouseDown = !0;
const { x: a, y: r } = this._getScrollPosition(this._timeline);
this._scrollState = { x: a, y: r }, this._startPoint = { x: n.clientX, y: n.clientY }, this._trace.push(this._startPoint);
}, this._gantt = e, this._domEvents = e._createDomEventScope(), this._trace = [];
}
static create(e) {
return new Yt(e);
}
static _isDragInProgress() {
return te;
}
destructor() {
this._domEvents.detachAll();
}
attach(e) {
this._timeline = e;
const n = this._gantt;
this._domEvents.attach(e.$task, "mousedown", (i) => {
if (!n.config.drag_timeline) return;
const { useKey: a, ignore: r, enabled: s } = n.config.drag_timeline;
if (s === !1) return;
let o = ".gantt_task_line, .gantt_task_link";
r !== void 0 && (o = r instanceof Array ? r.join(", ") : r), o && n.utils.dom.closest(i.target, o) || a && i[a] !== !0 || this._startDrag(i);
}), this._domEvents.attach(document, "keydown", (i) => {
if (!n.config.drag_timeline) return;
const { useKey: a } = n.config.drag_timeline;
a && i[a] === !0 && this._applyDndReadyStyles();
}), this._domEvents.attach(document, "keyup", (i) => {
if (!n.config.drag_timeline) return;
const { useKey: a } = n.config.drag_timeline;
a && i[a] === !1 && (this._clearDndReadyStyles(), this._stopDrag(i));
}), this._domEvents.attach(document, "mouseup", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(n.$root, "mouseup", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(document, "mouseleave", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(n.$root, "mouseleave", (i) => {
this._stopDrag(i);
}), this._domEvents.attach(n.$root, "mousemove", (i) => {
if (!n.config.drag_timeline) return;
const { useKey: a } = n.config.drag_timeline;
if (a && i[a] !== !0) return;
const r = this._gantt.ext.clickDrag, s = (this._gantt.config.click_drag || {}).useKey;
if ((!r || !s || a || !i[s]) && this._mouseDown === !0) {
this._trace.push({ x: i.clientX, y: i.clientY });
const o = this._countNewScrollPosition({ x: i.clientX, y: i.clientY });
this._setScrollPosition(e, o), this._scrollState = o, this._startPoint = { x: i.clientX, y: i.clientY };
}
});
}
}
function Rn(t) {
(function() {
var e = [];
function n() {
return !!e.length;
}
function i(d) {
setTimeout(function() {
n() || t.$destroyed || t.focus();
}, 1);
}
function a(d) {
t.eventRemove(d, "keydown", s), t.event(d, "keydown", s), e.push(d);
}
function r() {
var d = e.pop();
d && t.eventRemove(d, "keydown", s), i();
}
function s(d) {
var c = d.currentTarget;
c == e[e.length - 1] && t.$keyboardNavigation.trapFocus(c, d);
}
function o() {
a(t.getLightbox());
}
t.attachEvent("onLightbox", o), t.attachEvent("onAfterLightbox", r), t.attachEvent("onLightboxChange", function() {
r(), o();
}), t.attachEvent("onAfterQuickInfo", function() {
i();
}), t.attachEvent("onMessagePopup", function(d) {
l = t.utils.dom.getActiveElement(), a(d);
}), t.attachEvent("onAfterMessagePopup", function() {
r(), setTimeout(function() {
l && (l.focus(), l = null);
}, 1);
});
var l = null;
t.$keyboardNavigation.isModal = n;
})();
}
class Hn {
constructor(e) {
this.show = (n, i) => {
i === void 0 ? this._showForTask(n) : this._showAtCoordinates(n, i);
}, this.hide = (n) => {
const i = this._gantt, a = this._quickInfoBox;
this._quickInfoBoxId = 0;
const r = this._quickInfoTask;
if (this._quickInfoTask = null, a && a.parentNode) {
if (i.config.quick_info_detached) return i.callEvent("onAfterQuickInfo", [r]), a.parentNode.removeChild(a);
a.className += " gantt_qi_hidden", a.style.right === "auto" ? a.style.left = "-350px" : a.style.right = "-350px", n && (a.style.left = a.style.right = "", a.parentNode.removeChild(a)), i.callEvent("onAfterQuickInfo", [r]);
}
}, this.getNode = () => this._quickInfoBox ? this._quickInfoBox : null, this.setContainer = (n) => {
n && (this._container = typeof n == "string" ? document.getElementById(n) : n);
}, this.setContent = (n) => {
const i = this._gantt, a = { taskId: null, header: { title: "", date: "" }, content: "", buttons: i.config.quickinfo_buttons };
n || (n = a), n.taskId || (n.taskId = a.taskId), n.header || (n.header = a.header), n.header.title || (n.header.title = a.header.title), n.header.date || (n.header.date = a.header.date), n.content || (n.content = a.content), n.buttons || (n.buttons = a.buttons);
let r = this.getNode();
r || (r = this._createQuickInfoElement()), n.taskId && (this._quickInfoBoxId = n.taskId);
const s = r.querySelector(".gantt_cal_qi_title"), o = s.querySelector(".gantt_cal_qi_tcontent"), l = s.querySelector(".gantt_cal_qi_tdate"), d = r.querySelector(".gantt_cal_qi_content"), c = r.querySelector(".gantt_cal_qi_controls");
i._waiAria.quickInfoHeader(r, [n.header.title, n.header.date].join(" ")), o.innerHTML = n.header.title, l.innerHTML = n.header.date, n.header.title || n.header.date ? s.style.display = "" : s.style.display = "none", d.innerHTML = n.content;
const u = n.buttons;
u.length ? c.style.display = "" : c.style.display = "none";
let h = "";
for (let g = 0; g < u.length; g++) {
const p = i._waiAria.quickInfoButtonAttrString(i.locale.labels[u[g]]);
h += `<div class="gantt_qi_big_icon ${u[g]} dhx_gantt_${u[g]}" title="${i.locale.labels[u[g]]}" ${p}>
<div class='dhx_menu_icon dhx_gantt_icon ${u[g]} gantt_menu_icon dhx_gantt_${u[g]}'></div>
<div>${i.locale.labels[u[g]]}</div>
</div>`;
}
c.innerHTML = h, i.eventRemove(r, "click", this._qiButtonClickHandler), i.eventRemove(r, "keypress", this._qiKeyPressHandler), i.event(r, "click", this._qiButtonClickHandler), i.event(r, "keypress", this._qiKeyPressHandler);
}, this._qiButtonClickHandler = (n) => {
this._qi_button_click(n.target);
}, this._qiKeyPressHandler = (n) => {
const i = n.which;
i !== 13 && i !== 32 || setTimeout(() => {
this._qi_button_click(n.target);
}, 1);
}, this._gantt = e;
}
_showAtCoordinates(e, n) {
this.hide(!0), this._quickInfoBoxId = 0, this._quickInfoTask = null, this._quickInfoBox || (this._createQuickInfoElement(), this.setContent()), this._appendAtCoordinates(e, n), this._gantt.callEvent("onQuickInfo", [null]);
}
_showForTask(e) {
const n = this._gantt;
if (e === this._quickInfoBoxId && n.utils.dom.isChildOf(this._quickInfoBox, document.body) || !n.config.show_quick_info) return;
this.hide(!0);
const i = this._getContainer(), a = this._get_event_counter_part(e, 6, i.xViewport, i.yViewport);
a && (this._quickInfoBox = this._init_quick_info(e), this._quickInfoTask = e, this._quickInfoBox.className = this._prepare_quick_info_classname(e), this._fill_quick_data(e), this._show_quick_info(a, 6), n.callEvent("onQuickInfo", [e]));
}
_get_event_counter_part(e, n, i, a) {
const r = this._gantt;
let s = r.getTaskNode(e);
if (!s && (s = r.getTaskRowNode(e), !s)) return null;
let o = 0;
const l = n + s.offsetTop + s.offsetHeight;
let d = s;
if (r.utils.dom.isChildOf(d, i)) for (; d && d !== i; ) o += d.offsetLeft, d = d.offsetParent;
const c = r.getScrollState();
return d ? { left: o, top: l, dx: o + s.offsetWidth / 2 - c.x > i.offsetWidth / 2 ? 1 : 0, dy: l + s.offsetHeight / 2 - c.y > a.offsetHeight / 2 ? 1 : 0, width: s.offsetWidth, height: s.offsetHeight } : null;
}
_createQuickInfoElement() {
const e = this._gantt, n = document.createElement("div");
n.className += "gantt_cal_quick_info", e._waiAria.quickInfoAttr(n);
var i = `
<div class="gantt_cal_qi_tcontrols">
<a class="gantt_cal_qi_close_btn dhx_gantt_icon dhx_gantt_icon_close"></a>
</div>
<div class="gantt_cal_qi_title" ${e._waiAria.quickInfoHeaderAttrString()}>
<div class="gantt_cal_qi_tcontent"></div>
<div class="gantt_cal_qi_tdate"></div>
</div>
<div class="gantt_cal_qi_content"></div>`;
if (i += '<div class="gantt_cal_qi_controls">', i += "</div>", n.innerHTML = i, e.config.quick_info_detached) {
const a = this._getContainer();
e.event(a.parent, "scroll", () => {
this.hide();
});
}
return this._quickInfoBox = n, n;
}
_init_quick_info(e) {
const n = this._gantt, i = n.getTask(e);
return typeof this._quickInfoReadonly == "boolean" && n.isReadonly(i) !== this._quickInfoReadonly && (this.hide(!0), this._quickInfoBox = null), this._quickInfoReadonly = n.isReadonly(i), this._quickInfoBox || (this._quickInfoBox = this._createQuickInfoElement()), this._quickInfoBox;
}
_prepare_quick_info_classname(e) {
const n = this._gantt, i = n.getTask(e);
let a = `gantt_cal_quick_info gantt_${n.getTaskType(i)}`;
const r = n.templates.quick_info_class(i.start_date, i.end_date, i);
return r && (a += " " + r), a;
}
_fill_quick_data(e) {
const n = this._gantt, i = n.getTask(e);
this._quickInfoBoxId = e;
let a = [];
if (this._quickInfoReadonly) {
const r = n.config.quickinfo_buttons, s = { icon_delete: !0, icon_edit: !0 };
for (let o = 0; o < r.length; o++) this._quickInfoReadonly && s[r[o]] || a.push(r[o]);
} else a = n.config.quickinfo_buttons;
this.setContent({ header: { title: n.templates.quick_info_title(i.start_date, i.end_date, i), date: n.templates.quick_info_date(i.start_date, i.end_date, i) }, content: n.templates.quick_info_content(i.start_date, i.end_date, i), buttons: a });
}
_appendAtCoordinates(e, n) {
const i = this._quickInfoBox, a = this._getContainer();
i.parentNode && i.parentNode.nodeName.toLowerCase() !== "#document-fragment" || a.parent.appendChild(i), i.style.left = e + "px", i.style.top = n + "px";
}
_show_quick_info(e, n) {
const i = this._gantt, a = this._quickInfoBox;
if (i.config.quick_info_detached) {
const r = this._getContainer();
a.parentNode && a.parentNode.nodeName.toLowerCase() !== "#document-fragment" || r.parent.appendChild(a);
const s = a.offsetWidth, o = a.offsetHeight, l = i.getScrollState(), d = r.xViewport, c = r.yViewport, u = d.offsetWidth + l.x - s, h = e.top - l.y + o;
let g = e.top;
h > c.offsetHeight / 2 && (g = e.top - (o + e.height + 2 * n), g < l.y && h <= c.offsetHeight && (g = e.top)), g < l.y && (g = l.y);
const p = Math.min(Math.max(l.x, e.left - e.dx * (s - e.width)), u), y = g;
this._appendAtCoordinates(p, y);
} else a.style.top = "20px", e.dx === 1 ? (a.style.right = "auto", a.style.left = "-300px", setTimeout(() => {
a.style.left = "10px";
}, 1)) : (a.style.left = "auto", a.style.right = "-300px", setTimeout(() => {
a.style.right = "10px";
}, 1)), a.className += " gantt_qi_" + (e.dx === 1 ? "left" : "right"), i.$root.appendChild(a);
}
_qi_button_click(e) {
const n = this._gantt, i = this._quickInfoBox;
if (!e || e === i) return;
if (e.closest(".gantt_cal_qi_close_btn")) return void this.hide();
const a = e.className;
if (a.indexOf("_icon") !== -1) {
const r = this._quickInfoBoxId;
n.$click.buttons[a.split(" ")[1].replace("icon_", "")](r);
} else this._qi_button_click(e.parentNode);
}
_getContainer() {
const e = this._gantt;
let n = this._container ? this._container : e.$task_data;
return n && n.offsetHeight && n.offsetWidth ? { parent: n, xViewport: e.$task, yViewport: e.$task_data } : (n = this._container ? this._container : e.$grid_data, n && n.offsetHeight && n.offsetWidth ? { parent: n, xViewport: e.$grid, yViewport: e.$grid_data } : { parent: this._container ? this._container : e.$layout, xViewport: e.$layout, yViewport: e.$layout });
}
}
var ee, On = {}.constructor.toString();
function q(t) {
var e, n;
if (t && typeof t == "object") switch (!0) {
case Q(t):
n = new Date(t);
break;
case fe(t):
for (n = new Array(t.length), e = 0; e < t.length; e++) n[e] = q(t[e]);
break;
default:
if (function(i) {
return i.constructor.toString() !== On;
}(t)) n = Object.create(t);
else {
if (function(i) {
return i.$$typeof && i.$$typeof.toString().includes("react.");
}(t)) return n = t;
n = {};
}
for (e in t) Object.prototype.hasOwnProperty.apply(t, [e]) && (n[e] = q(t[e]));
}
return n || t;
}
function P(t, e, n) {
for (var i in e) (t[i] === void 0 || n) && (t[i] = e[i]);
return t;
}
function W(t) {
return t !== void 0;
}
function st() {
return ee || (ee = (/* @__PURE__ */ new Date()).valueOf()), ++ee;
}
function R(t, e) {
return t.bind ? t.bind(e) : function() {
return t.apply(e, arguments);
};
}
function on(t, e, n, i) {
t.addEventListener ? t.addEventListener(e, n, i !== void 0 && i) : t.attachEvent && t.attachEvent("on" + e, n);
}
function ln(t, e, n, i) {
t.removeEventListener ? t.removeEventListener(e, n, i !== void 0 && i) : t.detachEvent && t.detachEvent("on" + e, n);
}
const Bn = Object.freeze(Object.defineProperty({ __proto__: null, bind: R, copy: q, defined: W, event: on, eventRemove: ln, mixin: P, uid: st }, Symbol.toStringTag, { value: "Module" }));
function Se(t, e) {
t = t || on, e = e || ln;
var n = [], i = { attach: function(a, r, s, o) {
n.push({ element: a, event: r, callback: s, capture: o }), t(a, r, s, o);
}, detach: function(a, r, s, o) {
e(a, r, s, o);
for (var l = 0; l < n.length; l++) {
var d = n[l];
d.element === a && d.event === r && d.callback === s && d.capture === o && (n.splice(l, 1), l--);
}
}, detachAll: function() {
for (var a = n.slice(), r = 0; r < a.length; r++) {
var s = a[r];
i.detach(s.element, s.event, s.callback, s.capture), i.detach(s.element, s.event, s.callback, void 0), i.detach(s.element, s.event, s.callback, !1), i.detach(s.element, s.event, s.callback, !0);
}
n.splice(0, n.length);
}, extend: function() {
return Se(this.event, this.eventRemove);
} };
return i;
}
class zn {
constructor(e) {
this._gantt = e;
}
getNode() {
const e = this._gantt;
return this._tooltipNode || (this._tooltipNode = document.createElement("div"), this._tooltipNode.className = "gantt_tooltip", e._waiAria.tooltipAttr(this._tooltipNode)), this._tooltipNode;
}
setViewport(e) {
return this._root = e, this;
}
show(e, n) {
const i = this._gantt, a = document.body, r = this.getNode();
if (Y(r, a) || (this.hide(), r.style.top = r.style.top || "0px", r.style.left = r.style.left || "0px", a.appendChild(r)), this._isLikeMouseEvent(e)) {
const s = this._calculateTooltipPosition(e);
n = s.top, e = s.left;
}
return r.style.top = n + "px", r.style.left = e + "px", i._waiAria.tooltipVisibleAttr(r), this;
}
hide() {
const e = this._gantt, n = this.getNode();
return n && n.parentNode && n.parentNode.removeChild(n), e._waiAria.tooltipHiddenAttr(n), this;
}
setContent(e) {
return this.getNode().innerHTML = e, this;
}
_isLikeMouseEvent(e) {
return !(!e || typeof e != "object") && "clientX" in e && "clientY" in e;
}
_getViewPort() {
return this._root || document.body;
}
_calculateTooltipPosition(e) {
const n = this._gantt, i = this._getViewPortSize(), a = this.getNode(), r = { top: 0, left: 0, width: a.offsetWidth, height: a.offsetHeight, bottom: 0, right: 0 }, s = n.config.tooltip_offset_x, o = n.config.tooltip_offset_y, l = document.body, d = rt(e, l), c = V(l);
d.y += c.y, r.top = d.y, r.left = d.x, r.top += o, r.left += s, r.bottom = r.top + r.height, r.right = r.left + r.width;
const u = window.scrollY + l.scrollTop;
return r.top < i.top - u ? (r.top = i.top, r.bottom = r.top + r.height) : r.bottom > i.bottom && (r.bottom = i.bottom, r.top = r.bottom - r.height), r.left < i.left ? (r.left = i.left, r.right = i.left + r.width) : r.right > i.right && (r.right = i.right, r.left = r.right - r.width), d.x >= r.left && d.x <= r.right && (r.left = d.x - r.width - s, r.right = r.left + r.width), d.y >= r.top && d.y <= r.bottom && (r.top = d.y - r.height - o, r.bottom = r.top + r.height), r;
}
_getViewPortSize() {
const e = this._gantt, n = this._getViewPort();
let i, a = n, r = window.scrollY + document.body.scrollTop, s = window.scrollX + document.body.scrollLeft;
return n === e.$task_data ? (a = e.$task, r = 0, s = 0, i = V(e.$task)) : i = V(a), { left: i.x + s, top: i.y + r, width: i.width, height: i.height, bottom: i.y + i.height + r, right: i.x + i.width + s };
}
}
class Wn {
constructor(e) {
this._listeners = {}, this.tooltip = new zn(e), this._gantt = e, this._domEvents = Se(), this._initDelayedFunctions();
}
destructor() {
this.tooltip.hide(), this._domEvents.detachAll();
}
hideTooltip() {
this.delayHide();
}
attach(e) {
let n = document.body;
const i = this._gantt;
e.global || (n = i.$root);
let a = null;
const r = (s) => {
const o = yt(s), l = dt(o, e.selector);
if (Y(o, this.tooltip.getNode())) return;
const d = () => {
a = l, e.onmouseenter(s, l);
};
a ? l && l === a ? e.onmousemove(s, l) : (e.onmouseleave(s, a), a = null, l && l !== a && d()) : l && d();
};
this.detach(e.selector), this._domEvents.attach(n, "mousemove", r), this._listeners[e.selector] = { node: n, handler: r };
}
detach(e) {
const n = this._listeners[e];
n && this._domEvents.detach(n.node, "mousemove", n.handler);
}
tooltipFor(e) {
const n = (i) => {
let a = i;
return document.createEventObject && !document.createEvent && (a = document.createEventObject(i)), a;
};
this._initDelayedFunctions(), this.attach({ selector: e.selector, global: e.global, onmouseenter: (i, a) => {
const r = e.html(i, a);
r && this.delayShow(n(i), r);
}, onmousemove: (i, a) => {
const r = e.html(i, a);
r ? this.delayShow(n(i), r) : (this.delayShow.$cancelTimeout(), this.delayHide());
}, onmouseleave: () => {
this.delayShow.$cancelTimeout(), this.delayHide();
} });
}
_initDelayedFunctions() {
const e = this._gantt;
this.delayShow && this.delayShow.$cancelTimeout(), this.delayHide && this.delayHide.$cancelTimeout(), this.tooltip.hide(), this.delayShow = De((n, i) => {
e.callEvent("onBeforeTooltip", [n]) === !1 ? this.tooltip.hide() : (this.tooltip.setContent(i), this.tooltip.show(n));
}, e.config.tooltip_timeout || 1), this.delayHide = De(() => {
this.delayShow.$cancelTimeout(), this.tooltip.hide();
}, e.config.tooltip_hide_timeout || 1);
}
}
const Ie = { onBeforeUndo: "onAfterUndo", onBeforeRedo: "onAfterRedo" }, Me = ["onTaskDragStart", "onAfterTaskUpdate", "onAfterParentExpand", "onAfterTaskDelete", "onBeforeBatchUpdate"];
class jn {
constructor(e, n) {
this._batchAction = null, this._batchMode = !1, this._ignore = !1, this._ignoreMoveEvents = !1, this._initialTasks = {}, this._initialLinks = {}, this._nestedTasks = {}, this._nestedLinks = {}, this._undo = e, this._gantt = n, this._attachEvents();
}
store(e, n, i = !1) {
return n === this._gantt.config.undo_types.task ? this._storeTask(e, i) : n === this._gantt.config.undo_types.link && this._storeLink(e, i);
}
isMoveEventsIgnored() {
return this._ignoreMoveEvents;
}
toggleIgnoreMoveEvents(e) {
this._ignoreMoveEvents = e || !1;
}
startIgnore() {
this._ignore = !0;
}
stopIgnore() {
this._ignore = !1;
}
startBatchAction() {
this._timeout || (this._timeout = setTimeout(() => {
this.stopBatchAction(), this._timeout = null;
}, 10)), this._ignore || this._batchMode || (this._batchMode = !0, this._batchAction = this._undo.action.create());
}
stopBatchAction() {
if (this._ignore) return;
const e = this._undo;
this._batchAction && e.logAction(this._batchAction), this._batchMode = !1, this._batchAction = null;
}
onTaskAdded(e) {
this._ignore || this._storeTaskCommand(e, this._undo.command.type.add);
}
onTaskUpdated(e) {
this._ignore || this._storeTaskCommand(e, this._undo.command.type.update);
}
onTaskMoved(e) {
this._ignore || (e.$local_index = this._gantt.getTaskIndex(e.id), this._storeEntityCommand(e, this.getInitialTask(e.id), this._undo.command.type.move, this._undo.command.entity.task));
}
onTaskDeleted(e) {
if (!this._ignore) {
if (this._storeTaskCommand(e, this._undo.command.type.remove), this._nestedTasks[e.id]) {
const n = this._nestedTasks[e.id];
for (let i = 0; i < n.length; i++) this._storeTaskCommand(n[i], this._undo.command.type.remove);
}
if (this._nestedLinks[e.id]) {
const n = this._nestedLinks[e.id];
for (let i = 0; i < n.length; i++) this._storeLinkCommand(n[i], this._undo.command.type.remove);
}
}
}
onLinkAdded(e) {
this._ignore || this._storeLinkCommand(e, this._undo.command.type.add);
}
onLinkUpdated(e) {
this._ignore || this._storeLinkCommand(e, this._undo.command.type.update);
}
onLinkDeleted(e) {
this._ignore || this._storeLinkCommand(e, this._undo.command.type.remove);
}
setNestedTasks(e, n) {
const i = this._gantt;
let a = null;
const r = [];
let s = this._getLinks(i.getTask(e));
for (let d = 0; d < n.length; d++) a = this.setInitialTask(n[d]), s = s.concat(this._getLinks(a)), r.push(a);
const o = {};
for (let d = 0; d < s.length; d++) o[s[d]] = !0;
const l = [];
for (const d in o) l.push(this.setInitialLink(d));
this._nestedTasks[e] = r, this._nestedLinks[e] = l;
}
setInitialTask(e, n) {
const i = this._gantt;
if (n || !this._initialTasks[e] || !this._batchMode) {
const a = i.copy(i.getTask(e));
a.$index = i.getGlobalTaskIndex(e), a.$local_index = i.getTaskIndex(e), this.setInitialTaskObject(e, a);
}
return this._initialTasks[e];
}
getInitialTask(e) {
return this._initialTasks[e];
}
clearInitialTasks() {
this._initialTasks = {};
}
setInitialTaskObject(e, n) {
this._initialTasks[e] = n;
}
setInitialLink(e, n) {
return this._initialLinks[e] && this._batchMode || (this._initialLinks[e] = this._gantt.copy(this._gantt.getLink(e))), this._initialLinks[e];
}
getInitialLink(e) {
return this._initialLinks[e];
}
clearInitialLinks() {
this._initialLinks = {};
}
_attachEvents() {
let e = null;
const n = this._gantt, i = () => {
e || (e = setTimeout(() => {
e = null;
}), this.clearInitialTasks(), n.eachTask((l) => {
this.setInitialTask(l.id);
}), this.clearInitialLinks(), n.getLinks().forEach((l) => {
this.setInitialLink(l.id);
}));
}, a = (l) => n.copy(n.getTask(l));
for (const l in Ie) n.attachEvent(l, () => (this.startIgnore(), !0)), n.attachEvent(Ie[l], () => (this.stopIgnore(), !0));
for (let l = 0; l < Me.length; l++) n.attachEvent(Me[l], () => (this.startBatchAction(), !0));
n.attachEvent("onParse", () => {
this._undo.clearUndoStack(), this._undo.clearRedoStack(), i();
}), n.attachEvent("onAfterTaskAdd", (l, d) => {
this.setInitialTask(l, !0), this.onTaskAdded(d);
}), n.attachEvent("onAfterTaskUpdate", (l, d) => {
this.onTaskUpdated(d);
}), n.attachEvent("onAfterParentExpand", (l, d) => {
this.onTaskUpdated(d);
}), n.attachEvent("onAfterTaskDelete", (l, d) => {
this.onTaskDeleted(d);
}), n.attachEvent("onAfterLinkAdd", (l, d) => {
this.setInitialLink(l, !0), this.onLinkAdded(d);
}), n.attachEvent("onAfterLinkUpdate", (l, d) => {
this.onLinkUpdated(d);
}), n.attachEvent("onAfterLinkDelete", (l, d) => {
this.onLinkDeleted(d);
}), n.attachEvent("onRowDragEnd", (l, d) => (this.onTaskMoved(a(l)), this.toggleIgnoreMoveEvents(), !0)), n.attachEvent("onBeforeTaskDelete", (l) => {
this.store(l, n.config.undo_types.task);
const d = [];
return i(), n.eachTask((c) => {
d.push(c.id);
}, l), this.setNestedTasks(l, d), !0;
});
const r = n.getDatastore("task");
r.attachEvent("onBeforeItemMove", (l, d, c) => (this.isMoveEventsIgnored() || i(), !0)), r.attachEvent("onAfterItemMove", (l, d, c) => (this.isMoveEventsIgnored() || this.onTaskMoved(a(l)), !0)), n.attachEvent("onRowDragStart", (l, d, c) => (this.toggleIgnoreMoveEvents(!0), i(), !0));
let s = null, o = !1;
if (n.attachEvent("onBeforeTaskDrag", (l) => {
if (s = n.getState().drag_id, s === l) {
const d = n.getTask(l);
n.isSummaryTask(d) && n.config.drag_project && (o = !0);
}
if (n.plugins().multiselect) {
const d = n.getSelectedTasks();
d.length > 1 && d.forEach((c) => {
this.store(c, n.config.undo_types.task, !0);
});
}
return this.store(l, n.config.undo_types.task);
}), n.attachEvent("onAfterTaskDrag", (l) => {
(o || n.plugins().multiselect && n.getSelectedTasks().length > 1) && s === l && (o = !1, s = null, this.stopBatchAction()), this.store(l, n.config.undo_types.task, !0);
}), n.attachEvent("onLightbox", (l) => this.store(l, n.config.undo_types.task)), n.attachEvent("onBeforeTaskAutoSchedule", (l) => (this.store(l.id, n.config.undo_types.task, !0), !0)), n.ext.inlineEditors) {
let l = null, d = null;
n.attachEvent("onGanttLayoutReady", () => {
l && n.ext.inlineEditors.detachEvent(l), d && n.ext.inlineEditors.detachEvent(d), d = n.ext.inlineEditors.attachEvent("onEditStart", (c) => {
this.store(c.id, n.config.undo_types.task);
}), l = n.ext.inlineEditors.attachEvent("onBeforeEditStart", (c) => (this.stopBatchAction(), !0));
});
}
}
_storeCommand(e) {
const n = this._undo;
if (n.updateConfigs(), n.undoEnabled) if (this._batchMode) this._batchAction.commands.push(e);
else {
const i = n.action.create([e]);
n.logAction(i);
}
}
_storeEntityCommand(e, n, i, a) {
const r = this._undo.command.create(e, n, i, a);
this._storeCommand(r);
}
_storeTaskCommand(e, n) {
this._gantt.isTaskExists(e.id) && (e.$local_index = this._gantt.getTaskIndex(e.id)), this._storeEntityCommand(e, this.getInitialTask(e.id), n, this._undo.command.entity.task);
}
_storeLinkCommand(e, n) {
this._storeEntityCommand(e, this.getInitialLink(e.id), n, this._undo.command.entity.link);
}
_getLinks(e) {
return e.$source.concat(e.$target);
}
_storeTask(e, n = !1) {
const i = this._gantt;
return this.setInitialTask(e, n), i.eachTask((a) => {
this.setInitialTask(a.id);
}, e), !0;
}
_storeLink(e, n = !1) {
return this.setInitialLink(e, n), !0;
}
}
class Fn {
constructor(e) {
this.maxSteps = 100, this.undoEnabled = !0, this.redoEnabled = !0, this.action = { create: (n) => ({ commands: n ? n.slice() : [] }), invert: (n) => {
const i = this._gantt.copy(n), a = this.command;
for (let r = 0; r < n.commands.length; r++) {
const s = i.commands[r] = a.invert(i.commands[r]);
s.type !== a.type.update && s.type !== a.type.move || ([s.value, s.oldValue] = [s.oldValue, s.value]);
}
return i;
} }, this.command = { entity: null, type: null, create: (n, i, a, r) => {
const s = this._gantt;
return { entity: r, type: a, value: s.copy(n), oldValue: s.copy(i || n) };
}, invert: (n) => {
const i = this._gantt.copy(n);
return i.type = this.command.inverseCommands(n.type), i;
}, inverseCommands: (n) => {
const i = this._gantt, a = this.command.type;
switch (n) {
case a.update:
return a.update;
case a.remove:
return a.add;
case a.add:
return a.remove;
case a.move:
return a.move;
default:
return i.assert(!1, "Invalid command " + n), null;
}
} }, this._undoStack = [], this._redoStack = [], this._gantt = e;
}
getUndoStack() {
return this._undoStack;
}
setUndoStack(e) {
this._undoStack = e;
}
getRedoStack() {
return this._redoStack;
}
setRedoStack(e) {
this._redoStack = e;
}
clearUndoStack() {
this._undoStack = [];
}
clearRedoStack() {
this._redoStack = [];
}
updateConfigs() {
const e = this._gantt;
this.maxSteps = e.config.undo_steps || 100, this.command.entity = e.config.undo_types, this.command.type = e.config.undo_actions, this.undoEnabled = !!e.config.undo, this.redoEnabled = !!e.config.redo;
}
undo() {
const e = this._gantt;
if (this.updateConfigs(), !this.undoEnabled) return;
const n = this._pop(this._undoStack);
if (n && this._reorderCommands(n), e.callEv