@workiom/frappe-gantt 1.0.12 → 1.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second", H = "millisecond", c = {
1
+ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second", S = "millisecond", l = {
2
2
  parse_duration(r) {
3
3
  const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(r);
4
4
  if (e !== null) {
@@ -22,25 +22,25 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
22
22
  if (r instanceof Date)
23
23
  return r;
24
24
  if (typeof r == "string") {
25
- let i, s;
26
- const n = r.split(" ");
27
- i = n[0].split(t).map((a) => parseInt(a, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
25
+ let i, n;
26
+ const s = r.split(" ");
27
+ i = s[0].split(t).map((a) => parseInt(a, 10)), n = s[1] && s[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
28
28
  let o = i;
29
- return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3), o = o.concat(s)), new Date(...o);
29
+ return n && n.length && (n.length === 4 && (n[3] = "0." + n[3], n[3] = parseFloat(n[3]) * 1e3), o = o.concat(n)), new Date(...o);
30
30
  }
31
31
  },
32
32
  to_string(r, t = !1) {
33
33
  if (!(r instanceof Date))
34
34
  throw new TypeError("Invalid argument type");
35
- const e = this.get_date_values(r).map((n, o) => (o === 1 && (n = n + 1), o === 6 ? v(n + "", 3, "0") : v(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
36
- return i + (t ? " " + s : "");
35
+ const e = this.get_date_values(r).map((s, o) => (o === 1 && (s = s + 1), o === 6 ? v(s + "", 3, "0") : v(s + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, n = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
36
+ return i + (t ? " " + n : "");
37
37
  },
38
38
  format(r, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
39
39
  const i = new Intl.DateTimeFormat(e, {
40
40
  month: "long"
41
- }), s = new Intl.DateTimeFormat(e, {
41
+ }), n = new Intl.DateTimeFormat(e, {
42
42
  month: "short"
43
- }), n = i.format(r), o = n.charAt(0).toUpperCase() + n.slice(1), a = this.get_date_values(r).map((l) => v(l, 2, 0)), h = {
43
+ }), s = i.format(r), o = s.charAt(0).toUpperCase() + s.slice(1), a = this.get_date_values(r).map((c) => v(c, 2, 0)), h = {
44
44
  YYYY: a[0],
45
45
  MM: v(+a[1] + 1, 2, 0),
46
46
  DD: a[2],
@@ -50,26 +50,26 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
50
50
  SSS: a[6],
51
51
  D: a[2],
52
52
  MMMM: o,
53
- MMM: s.format(r)
53
+ MMM: n.format(r)
54
54
  };
55
55
  let d = t;
56
56
  const _ = [];
57
- return Object.keys(h).sort((l, p) => p.length - l.length).forEach((l) => {
58
- d.includes(l) && (d = d.replaceAll(l, `$${_.length}`), _.push(h[l]));
59
- }), _.forEach((l, p) => {
60
- d = d.replaceAll(`$${p}`, l);
57
+ return Object.keys(h).sort((c, g) => g.length - c.length).forEach((c) => {
58
+ d.includes(c) && (d = d.replaceAll(c, `$${_.length}`), _.push(h[c]));
59
+ }), _.forEach((c, g) => {
60
+ d = d.replaceAll(`$${g}`, c);
61
61
  }), d;
62
62
  },
63
63
  diff(r, t, e = "day") {
64
- let i, s, n, o, a, h, d;
65
- i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, s = i / 1e3, o = s / 60, n = o / 60, a = n / 24;
66
- let _ = r.getFullYear() - t.getFullYear(), l = r.getMonth() - t.getMonth();
67
- return l += a % 30 / 30, h = _ * 12 + l, r.getDate() < t.getDate() && h--, d = h / 12, e.endsWith("s") || (e += "s"), Math.round(
64
+ let i, n, s, o, a, h, d;
65
+ i = r - t + (t.getTimezoneOffset() - r.getTimezoneOffset()) * 6e4, n = i / 1e3, o = n / 60, s = o / 60, a = s / 24;
66
+ let _ = r.getFullYear() - t.getFullYear(), c = r.getMonth() - t.getMonth();
67
+ return c += a % 30 / 30, h = _ * 12 + c, r.getDate() < t.getDate() && h--, d = h / 12, e.endsWith("s") || (e += "s"), Math.round(
68
68
  {
69
69
  milliseconds: i,
70
- seconds: s,
70
+ seconds: n,
71
71
  minutes: o,
72
- hours: n,
72
+ hours: s,
73
73
  days: a,
74
74
  months: h,
75
75
  years: d
@@ -92,7 +92,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
92
92
  r.getHours() + (e === T ? t : 0),
93
93
  r.getMinutes() + (e === Y ? t : 0),
94
94
  r.getSeconds() + (e === A ? t : 0),
95
- r.getMilliseconds() + (e === H ? t : 0)
95
+ r.getMilliseconds() + (e === S ? t : 0)
96
96
  ];
97
97
  return new Date(...i);
98
98
  },
@@ -104,13 +104,13 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
104
104
  [T]: 3,
105
105
  [Y]: 2,
106
106
  [A]: 1,
107
- [H]: 0
107
+ [S]: 0
108
108
  };
109
- function i(n) {
109
+ function i(s) {
110
110
  const o = e[t];
111
- return e[n] <= o;
111
+ return e[s] <= o;
112
112
  }
113
- const s = [
113
+ const n = [
114
114
  r.getFullYear(),
115
115
  i(M) ? 0 : r.getMonth(),
116
116
  i(D) ? 1 : r.getDate(),
@@ -119,7 +119,7 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
119
119
  i(Y) ? 0 : r.getSeconds(),
120
120
  i(A) ? 0 : r.getMilliseconds()
121
121
  ];
122
- return new Date(...s);
122
+ return new Date(...n);
123
123
  },
124
124
  clone(r) {
125
125
  return new Date(...this.get_date_values(r));
@@ -144,8 +144,8 @@ const M = "year", D = "month", L = "day", T = "hour", Y = "minute", A = "second"
144
144
  day: 1,
145
145
  month: 30,
146
146
  year: 365
147
- }, { duration: i, scale: s } = this.parse_duration(r);
148
- return i * e[s] / e[t];
147
+ }, { duration: i, scale: n } = this.parse_duration(r);
148
+ return i * e[n] / e[t];
149
149
  },
150
150
  get_days_in_month(r) {
151
151
  const t = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], e = r.getMonth();
@@ -171,29 +171,29 @@ function f(r, t) {
171
171
  return e;
172
172
  }
173
173
  function E(r, t, e, i) {
174
- const s = z(r, t, e, i);
175
- if (s === r) {
176
- const n = document.createEvent("HTMLEvents");
177
- n.initEvent("click", !0, !0), n.eventName = "click", s.dispatchEvent(n);
174
+ const n = z(r, t, e, i);
175
+ if (n === r) {
176
+ const s = document.createEvent("HTMLEvents");
177
+ s.initEvent("click", !0, !0), s.eventName = "click", n.dispatchEvent(s);
178
178
  }
179
179
  }
180
- function z(r, t, e, i, s = "0.4s", n = "0.1s") {
180
+ function z(r, t, e, i, n = "0.4s", s = "0.1s") {
181
181
  const o = r.querySelector("animate");
182
182
  if (o)
183
183
  return u.attr(o, {
184
184
  attributeName: t,
185
185
  from: e,
186
186
  to: i,
187
- dur: s,
188
- begin: "click + " + n
187
+ dur: n,
188
+ begin: "click + " + s
189
189
  // artificial click
190
190
  }), r;
191
191
  const a = f("animate", {
192
192
  attributeName: t,
193
193
  from: e,
194
194
  to: i,
195
- dur: s,
196
- begin: n,
195
+ dur: n,
196
+ begin: s,
197
197
  calcMode: "spline",
198
198
  values: e + ";" + i,
199
199
  keyTimes: "0; 1",
@@ -222,9 +222,9 @@ u.bind = (r, t, e) => {
222
222
  });
223
223
  };
224
224
  u.delegate = (r, t, e, i) => {
225
- r.addEventListener(t, function(s) {
226
- const n = s.target.closest(e);
227
- n && (s.delegatedTarget = n, i.call(this, s, n));
225
+ r.addEventListener(t, function(n) {
226
+ const s = n.target.closest(e);
227
+ s && (n.delegatedTarget = s, i.call(this, n, s));
228
228
  });
229
229
  };
230
230
  u.closest = (r, t) => t ? t.matches(r) ? t : u.closest(r, t.parentNode) : null;
@@ -251,7 +251,7 @@ class C {
251
251
  for (; e(); )
252
252
  t -= 10;
253
253
  t -= 10;
254
- let i = this.gantt.config.header_height + this.gantt.options.bar_height + (this.gantt.options.padding + this.gantt.options.bar_height) * this.from_task.task._index + this.gantt.options.padding / 2, s = this.to_task.$bar.getX() - 13, n = this.gantt.config.header_height + this.gantt.options.bar_height / 2 + (this.gantt.options.padding + this.gantt.options.bar_height) * this.to_task.task._index + this.gantt.options.padding / 2;
254
+ let i = this.gantt.config.header_height + this.gantt.options.bar_height + (this.gantt.options.padding + this.gantt.options.bar_height) * this.from_task.task._index + this.gantt.options.padding / 2, n = this.to_task.$bar.getX() - 13, s = this.gantt.config.header_height + this.gantt.options.bar_height / 2 + (this.gantt.options.padding + this.gantt.options.bar_height) * this.to_task.task._index + this.gantt.options.padding / 2;
255
255
  const o = this.from_task.task._index > this.to_task.task._index;
256
256
  let a = this.gantt.options.arrow_curve;
257
257
  const h = o ? 1 : 0;
@@ -259,27 +259,27 @@ class C {
259
259
  if (this.to_task.$bar.getX() <= this.from_task.$bar.getX() + this.gantt.options.padding) {
260
260
  let _ = this.gantt.options.padding / 2 - a;
261
261
  _ < 0 && (_ = 0, a = this.gantt.options.padding / 2, d = o ? -a : a);
262
- const l = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - d, p = this.to_task.$bar.getX() - this.gantt.options.padding;
262
+ const c = this.to_task.$bar.getY() + this.to_task.$bar.getHeight() / 2 - d, g = this.to_task.$bar.getX() - this.gantt.options.padding;
263
263
  this.path = `
264
264
  M ${t} ${i}
265
265
  v ${_}
266
266
  a ${a} ${a} 0 0 1 ${-a} ${a}
267
- H ${p}
267
+ H ${g}
268
268
  a ${a} ${a} 0 0 ${h} ${-a} ${d}
269
- V ${l}
269
+ V ${c}
270
270
  a ${a} ${a} 0 0 ${h} ${a} ${d}
271
- L ${s} ${n}
271
+ L ${n} ${s}
272
272
  m -5 -5
273
273
  l 5 5
274
274
  l -5 5`;
275
275
  } else {
276
- s < t + a && (a = s - t);
277
- let _ = o ? n + a : n - a;
276
+ n < t + a && (a = n - t);
277
+ let _ = o ? s + a : s - a;
278
278
  this.path = `
279
279
  M ${t} ${i}
280
280
  V ${_}
281
281
  a ${a} ${a} 0 0 ${h} ${a} ${a}
282
- L ${s} ${n}
282
+ L ${n} ${s}
283
283
  m -5 -5
284
284
  l 5 5
285
285
  l -5 5`;
@@ -302,7 +302,7 @@ class q {
302
302
  this.set_defaults(t, e), this.prepare_wrappers(), this.prepare_helpers(), this.refresh();
303
303
  }
304
304
  refresh() {
305
- this.bar_group.innerHTML = "", this.handle_group.innerHTML = "", this.task.custom_class ? this.group.classList.add(this.task.custom_class) : this.group.classList = ["bar-wrapper"], this.prepare_values(), this.draw(), this.bind();
305
+ this.bar_group.innerHTML = "", this.handle_group.innerHTML = "", this.task.custom_class ? this.group.classList.add(this.task.custom_class) : this.group.classList = ["bar-wrapper"], this.unbind(), this.prepare_values(), this.draw(), this.bind();
306
306
  }
307
307
  set_defaults(t, e) {
308
308
  this.action_completed = !1, this.gantt = t, this.task = e, this.name = this.name || "", this.is_dragging = !1, this.is_hovering_bar = !1, this.is_hovering_icon = !1, this.add_icon_hide_timeout = null;
@@ -384,7 +384,7 @@ class q {
384
384
  class: "bar-progress",
385
385
  append_to: this.bar_group
386
386
  }), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
387
- const e = c.diff(
387
+ const e = l.diff(
388
388
  this.task._start,
389
389
  this.gantt.gantt_start,
390
390
  this.gantt.config.unit
@@ -398,17 +398,17 @@ class q {
398
398
  }
399
399
  calculate_progress_width() {
400
400
  const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < e), 0) * this.gantt.config.column_width;
401
- let s = (t - i) * this.task.progress / 100;
402
- const n = this.x + s, o = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < n), 0) * this.gantt.config.column_width;
403
- s += o;
401
+ let n = (t - i) * this.task.progress / 100;
402
+ const s = this.x + n, o = this.gantt.config.ignored_positions.reduce((h, d) => h + (d >= this.x && d < s), 0) * this.gantt.config.column_width;
403
+ n += o;
404
404
  let a = this.gantt.get_ignored_region(
405
- this.x + s
405
+ this.x + n
406
406
  );
407
407
  for (; a.length; )
408
- s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
409
- this.x + s
408
+ n += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
409
+ this.x + n
410
410
  );
411
- return this.progress_width = s, s;
411
+ return this.progress_width = n, n;
412
412
  }
413
413
  draw_label() {
414
414
  let t = this.x + this.$bar.getWidth() / 2;
@@ -421,7 +421,7 @@ class q {
421
421
  }), this.task.color_text && (this.$bar_label.style.fill = this.task.color_text), requestAnimationFrame(() => this.update_label_position());
422
422
  }
423
423
  draw_thumbnail() {
424
- let t = 10, e = 2, i, s;
424
+ let t = 10, e = 2, i, n;
425
425
  i = f("defs", {
426
426
  append_to: this.bar_group
427
427
  }), f("rect", {
@@ -433,12 +433,12 @@ class q {
433
433
  rx: "15",
434
434
  class: "img_mask",
435
435
  append_to: i
436
- }), s = f("clipPath", {
436
+ }), n = f("clipPath", {
437
437
  id: "clip_" + this.task.id,
438
438
  append_to: i
439
439
  }), f("use", {
440
440
  href: "#rect_" + this.task.id,
441
- append_to: s
441
+ append_to: n
442
442
  }), f("image", {
443
443
  x: this.x + t,
444
444
  y: this.y + e,
@@ -459,38 +459,38 @@ class q {
459
459
  i = this.x + this.$bar.getWidth() + 5;
460
460
  else
461
461
  return;
462
- const s = this.y + (this.height - 20) / 2;
462
+ const n = this.y + (this.height - 20) / 2;
463
463
  this.$add_icon_group = f("g", {
464
464
  class: "add-task-icon hide",
465
465
  append_to: this.handle_group
466
466
  }), this.$add_icon_circle = f("circle", {
467
467
  cx: i + 20 / 2,
468
- cy: s + 20 / 2,
468
+ cy: n + 20 / 2,
469
469
  r: 20 / 2,
470
470
  class: "add-task-icon-bg",
471
471
  append_to: this.$add_icon_group
472
472
  }), this.$add_icon_vertical = f("line", {
473
473
  x1: i + 20 / 2,
474
- y1: s + 5,
474
+ y1: n + 5,
475
475
  x2: i + 20 / 2,
476
- y2: s + 20 - 5,
476
+ y2: n + 20 - 5,
477
477
  class: "add-task-icon-plus",
478
478
  append_to: this.$add_icon_group
479
479
  }), this.$add_icon_horizontal = f("line", {
480
480
  x1: i + 5,
481
- y1: s + 20 / 2,
481
+ y1: n + 20 / 2,
482
482
  x2: i + 20 - 5,
483
- y2: s + 20 / 2,
483
+ y2: n + 20 / 2,
484
484
  class: "add-task-icon-plus",
485
485
  append_to: this.$add_icon_group
486
- }), u.on(this.$add_icon_group, "mousedown", (n) => {
487
- n.stopPropagation();
488
- }), u.on(this.$add_icon_group, "mouseup", (n) => {
489
- n.stopPropagation();
490
- }), u.on(this.$add_icon_group, "click", (n) => {
491
- n.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
492
- }), u.on(this.$add_icon_group, "mouseenter", (n) => {
493
- this.is_hovering_icon = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.$add_icon_group.classList.add("active"), this.$add_icon_group.classList.remove("hide"), n.stopPropagation();
486
+ }), u.on(this.$add_icon_group, "mousedown", (s) => {
487
+ s.stopPropagation();
488
+ }), u.on(this.$add_icon_group, "mouseup", (s) => {
489
+ s.stopPropagation();
490
+ }), u.on(this.$add_icon_group, "click", (s) => {
491
+ s.stopPropagation(), this.gantt.trigger_event("task_add", [this.task]);
492
+ }), u.on(this.$add_icon_group, "mouseenter", (s) => {
493
+ this.is_hovering_icon = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.$add_icon_group.classList.add("active"), this.$add_icon_group.classList.remove("hide"), s.stopPropagation();
494
494
  }), u.on(this.$add_icon_group, "mouseleave", () => {
495
495
  this.is_hovering_icon = !1, this.$add_icon_group.classList.remove("active"), this.is_hovering_bar || this.$add_icon_group.classList.add("hide");
496
496
  });
@@ -536,62 +536,84 @@ class q {
536
536
  bind() {
537
537
  this.invalid || this.setup_click_event();
538
538
  }
539
+ unbind() {
540
+ this.invalid || this.group && this.event_listeners && (this.event_listeners.forEach(({ event: t, handler: e }) => {
541
+ u.off(this.group, t, e);
542
+ }), this.event_listeners = []);
543
+ }
539
544
  setup_click_event() {
545
+ this.event_listeners = [];
540
546
  let t = this.task.id;
541
- u.on(this.group, "mouseover", (s) => {
547
+ const e = (g) => {
542
548
  this.gantt.trigger_event("hover", [
543
549
  this.task,
544
- s.screenX,
545
- s.screenY,
546
- s
550
+ g.screenX,
551
+ g.screenY,
552
+ g
547
553
  ]);
548
- }), this.gantt.options.popup_on === "click" && u.on(this.group, "mouseup", (s) => {
549
- const n = s.offsetX || s.layerX;
550
- if (this.$handle_progress) {
551
- const o = +this.$handle_progress.getAttribute("cx");
552
- if (o > n - 1 && o < n + 1 || this.gantt.bar_being_dragged) return;
553
- }
554
- this.gantt.show_popup({
555
- x: s.offsetX || s.layerX,
556
- y: s.offsetY || s.layerY,
557
- task: this.task,
558
- target: this.$bar
559
- });
560
- });
561
- let e;
562
- u.on(this.group, "mouseenter", (s) => {
563
- e = setTimeout(() => {
554
+ };
555
+ if (u.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
556
+ const g = (p) => {
557
+ const w = p.offsetX || p.layerX;
558
+ if (this.$handle_progress) {
559
+ const m = +this.$handle_progress.getAttribute("cx");
560
+ if (m > w - 1 && m < w + 1 || this.gantt.bar_being_dragged) return;
561
+ }
562
+ this.gantt.show_popup({
563
+ x: p.offsetX || p.layerX,
564
+ y: p.offsetY || p.layerY,
565
+ task: this.task,
566
+ target: this.$bar
567
+ });
568
+ };
569
+ u.on(this.group, "click", g), this.event_listeners.push({ event: "click", handler: g });
570
+ }
571
+ let i;
572
+ const n = (g) => {
573
+ i = setTimeout(() => {
564
574
  this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
565
- x: s.offsetX || s.layerX,
566
- y: s.offsetY || s.layerY,
575
+ x: g.offsetX || g.layerX,
576
+ y: g.offsetY || g.layerY,
567
577
  task: this.task,
568
578
  target: this.$bar
569
579
  }), this.gantt.$container.querySelector(`.highlight-${t}`).classList.remove("hide");
570
580
  }, 200), this.$add_icon_group && (this.is_hovering_bar = !0, this.add_icon_hide_timeout && (clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = null), this.is_dragging || this.$add_icon_group.classList.remove("hide"));
571
- }), u.on(this.group, "mouseleave", () => {
572
- var s, n;
573
- clearTimeout(e), this.gantt.options.popup_on === "hover" && ((n = (s = this.gantt.popup) == null ? void 0 : s.hide) == null || n.call(s)), this.gantt.$container.querySelector(`.highlight-${t}`).classList.add("hide"), this.$add_icon_group && (this.is_hovering_bar = !1, this.add_icon_hide_timeout && clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = setTimeout(() => {
581
+ };
582
+ u.on(this.group, "mouseenter", n), this.event_listeners.push({ event: "mouseenter", handler: n });
583
+ const s = () => {
584
+ var g, p;
585
+ clearTimeout(i), this.gantt.options.popup_on === "hover" && ((p = (g = this.gantt.popup) == null ? void 0 : g.hide) == null || p.call(g)), this.gantt.$container.querySelector(`.highlight-${t}`).classList.add("hide"), this.$add_icon_group && (this.is_hovering_bar = !1, this.add_icon_hide_timeout && clearTimeout(this.add_icon_hide_timeout), this.add_icon_hide_timeout = setTimeout(() => {
574
586
  this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
575
587
  }, 200));
576
- }), u.on(this.group, "mousedown", () => {
588
+ };
589
+ u.on(this.group, "mouseleave", s), this.event_listeners.push({ event: "mouseleave", handler: s });
590
+ const o = () => {
577
591
  this.is_dragging = !0, this.hide_add_icon();
578
- }), u.on(this.group, "mouseup", () => {
592
+ };
593
+ u.on(this.group, "mousedown", o), this.event_listeners.push({ event: "mousedown", handler: o });
594
+ const a = () => {
579
595
  setTimeout(() => {
580
596
  this.gantt.bar_being_dragged !== !0 && (this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide"));
581
597
  }, 0);
582
- }), u.on(this.group, "click", () => {
598
+ };
599
+ u.on(this.group, "mouseup", a), this.event_listeners.push({ event: "mouseup", handler: a });
600
+ const h = () => {
583
601
  this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
584
- }), u.on(this.group, "dblclick", (s) => {
602
+ };
603
+ u.on(this.group, "click", h), this.event_listeners.push({ event: "click", handler: h });
604
+ const d = () => {
585
605
  this.action_completed || (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
586
- });
587
- let i = !1;
588
- u.on(this.group, "touchstart", (s) => {
589
- if (!i)
590
- return i = !0, setTimeout(function() {
591
- i = !1;
606
+ };
607
+ u.on(this.group, "dblclick", d), this.event_listeners.push({ event: "dblclick", handler: d });
608
+ let _ = !1;
609
+ const c = (g) => {
610
+ if (!_)
611
+ return _ = !0, setTimeout(function() {
612
+ _ = !1;
592
613
  }, 300), !1;
593
- s.preventDefault(), !this.action_completed && (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
594
- });
614
+ g.preventDefault(), !this.action_completed && (this.group.classList.remove("active"), this.gantt.popup && this.gantt.popup.parent.classList.remove("hide"), this.gantt.trigger_event("double_click", [this.task]));
615
+ };
616
+ u.on(this.group, "touchstart", c), this.event_listeners.push({ event: "touchstart", handler: c });
595
617
  }
596
618
  update_bar_position({ x: t = null, width: e = null }) {
597
619
  const i = this.$bar;
@@ -605,35 +627,35 @@ class q {
605
627
  validate_dependency_constraints(t, e = null) {
606
628
  const i = this.task.dependencies_type || this.gantt.options.dependencies_type;
607
629
  if (i === "fixed")
608
- return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_, l) => _ && t >= l, !0);
609
- const s = t / this.gantt.config.column_width, n = c.add(
630
+ return this.task.dependencies.map((_) => this.gantt.get_bar(_).$bar.getX()).reduce((_, c) => _ && t >= c, !0);
631
+ const n = t / this.gantt.config.column_width, s = l.add(
610
632
  this.gantt.gantt_start,
611
- s * this.gantt.config.step,
633
+ n * this.gantt.config.step,
612
634
  this.gantt.config.unit
613
- ), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = c.add(
614
- n,
635
+ ), a = (e || this.$bar.getWidth()) / this.gantt.config.column_width, h = l.add(
636
+ s,
615
637
  a * this.gantt.config.step,
616
638
  this.gantt.config.unit
617
639
  );
618
640
  for (const d of this.task.dependencies) {
619
641
  const _ = this.gantt.get_bar(d);
620
642
  if (!_) continue;
621
- const l = _.task;
643
+ const c = _.task;
622
644
  switch (i) {
623
645
  case "finish-to-start":
624
- if (n < l._end)
646
+ if (s < c._end)
625
647
  return !1;
626
648
  break;
627
649
  case "start-to-start":
628
- if (n < l._start)
650
+ if (s < c._start)
629
651
  return !1;
630
652
  break;
631
653
  case "finish-to-finish":
632
- if (h < l._end)
654
+ if (h < c._end)
633
655
  return !1;
634
656
  break;
635
657
  case "start-to-finish":
636
- if (h < l._start)
658
+ if (h < c._start)
637
659
  return !1;
638
660
  break;
639
661
  }
@@ -641,9 +663,9 @@ class q {
641
663
  return !0;
642
664
  }
643
665
  update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
644
- const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
645
- let a = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, d = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, l = h + s.getBBox().width + 7, p = e + i.clientWidth / 2;
646
- s.classList.contains("big") || (l < a && t > 0 && l < p || h - _ > this.$bar.getX() && t < 0 && l > p) && (s.setAttribute("x", h), n && (n.setAttribute("x", d), o.setAttribute("x", d)));
666
+ const i = this.gantt.$container, n = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
667
+ let a = this.$bar.getX() + this.$bar.getWidth(), h = n.getX() + t, d = s && s.getX() + t || 0, _ = s && s.getBBox().width + 7 || 7, c = h + n.getBBox().width + 7, g = e + i.clientWidth / 2;
668
+ n.classList.contains("big") || (c < a && t > 0 && c < g || h - _ > this.$bar.getX() && t < 0 && c > g) && (n.setAttribute("x", h), s && (s.setAttribute("x", d), o.setAttribute("x", d)));
647
669
  }
648
670
  date_changed() {
649
671
  let t = !1;
@@ -651,7 +673,7 @@ class q {
651
673
  Number(this.task._start) !== Number(e) && (t = !0, this.task._start = e), Number(this.task._end) !== Number(i) && (t = !0, this.task._end = i), t && this.gantt.trigger_event("date_change", [
652
674
  this.task,
653
675
  e,
654
- c.add(i, -1, "second")
676
+ l.add(i, -1, "second")
655
677
  ]);
656
678
  }
657
679
  progress_changed() {
@@ -661,36 +683,36 @@ class q {
661
683
  ]);
662
684
  }
663
685
  set_action_completed() {
664
- this.action_completed = !0, setTimeout(() => this.action_completed = !1, 1e3), this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide");
686
+ this.action_completed = !0, setTimeout(() => this.action_completed = !1, 10), this.is_dragging = !1, this.$add_icon_group && this.is_hovering_bar && this.$add_icon_group.classList.remove("hide");
665
687
  }
666
688
  compute_start_end_date() {
667
689
  const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
668
- let i = c.add(
690
+ let i = l.add(
669
691
  this.gantt.gantt_start,
670
692
  e * this.gantt.config.step,
671
693
  this.gantt.config.unit
672
694
  );
673
- const s = t.getWidth() / this.gantt.config.column_width, n = c.add(
695
+ const n = t.getWidth() / this.gantt.config.column_width, s = l.add(
674
696
  i,
675
- s * this.gantt.config.step,
697
+ n * this.gantt.config.step,
676
698
  this.gantt.config.unit
677
699
  );
678
- return { new_start_date: i, new_end_date: n };
700
+ return { new_start_date: i, new_end_date: s };
679
701
  }
680
702
  compute_progress() {
681
703
  this.progress_width = this.$bar_progress.getWidth(), this.x = this.$bar_progress.getBBox().x;
682
- const t = this.x + this.progress_width, e = this.progress_width - this.gantt.config.ignored_positions.reduce((s, n) => s + (n >= this.x && n <= t), 0) * this.gantt.config.column_width;
704
+ const t = this.x + this.progress_width, e = this.progress_width - this.gantt.config.ignored_positions.reduce((n, s) => n + (s >= this.x && s <= t), 0) * this.gantt.config.column_width;
683
705
  if (e < 0) return 0;
684
706
  const i = this.$bar.getWidth() - this.ignored_duration_raw * this.gantt.config.column_width;
685
707
  return parseInt(e / i * 100, 10);
686
708
  }
687
709
  compute_expected_progress() {
688
- this.expected_progress = c.diff(c.today(), this.task._start, "hour") / this.gantt.config.step, this.expected_progress = (this.expected_progress < this.duration ? this.expected_progress : this.duration) * 100 / this.duration;
710
+ this.expected_progress = l.diff(l.today(), this.task._start, "hour") / this.gantt.config.step, this.expected_progress = (this.expected_progress < this.duration ? this.expected_progress : this.duration) * 100 / this.duration;
689
711
  }
690
712
  compute_x() {
691
713
  const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
692
- let n = c.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
693
- this.x = n;
714
+ let s = l.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
715
+ this.x = s;
694
716
  }
695
717
  compute_y() {
696
718
  this.y = this.gantt.config.header_height + this.gantt.options.padding / 2 + this.task._index * (this.height + this.gantt.options.padding);
@@ -699,12 +721,12 @@ class q {
699
721
  let t = 0, e = 0;
700
722
  for (let i = new Date(this.task._start); i < this.task._end; i.setDate(i.getDate() + 1))
701
723
  e++, !this.gantt.config.ignored_dates.find(
702
- (s) => s.getTime() === i.getTime()
724
+ (n) => n.getTime() === i.getTime()
703
725
  ) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
704
- this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = c.convert_scales(
726
+ this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = l.convert_scales(
705
727
  e + "d",
706
728
  this.gantt.config.unit
707
- ) / this.gantt.config.step, this.actual_duration_raw = c.convert_scales(
729
+ ) / this.gantt.config.step, this.actual_duration_raw = l.convert_scales(
708
730
  t + "d",
709
731
  this.gantt.config.unit
710
732
  ) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
@@ -725,10 +747,10 @@ class q {
725
747
  ));
726
748
  }
727
749
  update_label_position() {
728
- const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img");
729
- let n = 5, o = this.image_size + 10;
750
+ const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img");
751
+ let s = 5, o = this.image_size + 10;
730
752
  const a = i.getBBox().width, h = e.getWidth();
731
- a > h ? (i.classList.add("big"), s ? (s.setAttribute("x", e.getEndX() + n), t.setAttribute("x", e.getEndX() + n), i.setAttribute("x", e.getEndX() + o)) : i.setAttribute("x", e.getEndX() + n)) : (i.classList.remove("big"), s ? (s.setAttribute("x", e.getX() + n), t.setAttribute("x", e.getX() + n), i.setAttribute(
753
+ a > h ? (i.classList.add("big"), n ? (n.setAttribute("x", e.getEndX() + s), t.setAttribute("x", e.getEndX() + s), i.setAttribute("x", e.getEndX() + o)) : i.setAttribute("x", e.getEndX() + s)) : (i.classList.remove("big"), n ? (n.setAttribute("x", e.getX() + s), t.setAttribute("x", e.getX() + s), i.setAttribute(
732
754
  "x",
733
755
  e.getX() + h / 2 + o
734
756
  )) : i.setAttribute(
@@ -753,8 +775,8 @@ class q {
753
775
  i = this.x + this.$bar.getWidth() + e;
754
776
  else
755
777
  return;
756
- const s = this.y + (this.height - t) / 2;
757
- this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy", s + t / 2), this.$add_icon_vertical.setAttribute("x1", i + t / 2), this.$add_icon_vertical.setAttribute("y1", s + 5), this.$add_icon_vertical.setAttribute("x2", i + t / 2), this.$add_icon_vertical.setAttribute("y2", s + t - 5), this.$add_icon_horizontal.setAttribute("x1", i + 5), this.$add_icon_horizontal.setAttribute("y1", s + t / 2), this.$add_icon_horizontal.setAttribute("x2", i + t - 5), this.$add_icon_horizontal.setAttribute("y2", s + t / 2);
778
+ const n = this.y + (this.height - t) / 2;
779
+ this.$add_icon_circle.setAttribute("cx", i + t / 2), this.$add_icon_circle.setAttribute("cy", n + t / 2), this.$add_icon_vertical.setAttribute("x1", i + t / 2), this.$add_icon_vertical.setAttribute("y1", n + 5), this.$add_icon_vertical.setAttribute("x2", i + t / 2), this.$add_icon_vertical.setAttribute("y2", n + t - 5), this.$add_icon_horizontal.setAttribute("x1", i + 5), this.$add_icon_horizontal.setAttribute("y1", n + t / 2), this.$add_icon_horizontal.setAttribute("x2", i + t - 5), this.$add_icon_horizontal.setAttribute("y2", n + t / 2);
758
780
  }
759
781
  hide_add_icon() {
760
782
  this.$add_icon_group && this.$add_icon_group.classList.add("hide");
@@ -777,9 +799,9 @@ class F {
777
799
  <div class="actions"></div>
778
800
  `, this.hide(), this.title = this.parent.querySelector(".title"), this.subtitle = this.parent.querySelector(".subtitle"), this.details = this.parent.querySelector(".details"), this.actions = this.parent.querySelector(".actions");
779
801
  }
780
- show({ x: t, y: e, task: i, target: s }) {
802
+ show({ x: t, y: e, task: i, target: n }) {
781
803
  this.actions.innerHTML = "";
782
- let n = this.popup_func({
804
+ let s = this.popup_func({
783
805
  task: i,
784
806
  chart: this.gantt,
785
807
  get_title: () => this.title,
@@ -797,28 +819,28 @@ class F {
797
819
  typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
798
820
  }
799
821
  });
800
- n !== !1 && (n && (this.parent.innerHTML = n), this.actions.innerHTML === "" ? this.actions.remove() : this.parent.appendChild(this.actions), this.parent.style.left = t + 10 + "px", this.parent.style.top = e - 10 + "px", this.parent.classList.remove("hide"));
822
+ s !== !1 && (s && (this.parent.innerHTML = s), this.actions.innerHTML === "" ? this.actions.remove() : this.parent.appendChild(this.actions), this.parent.style.left = t + 10 + "px", this.parent.style.top = e - 10 + "px", this.parent.classList.remove("hide"));
801
823
  }
802
824
  hide() {
803
825
  this.parent.classList.add("hide");
804
826
  }
805
827
  }
806
- function S(r) {
828
+ function H(r) {
807
829
  const t = r.getFullYear();
808
830
  return t - t % 10 + "";
809
831
  }
810
832
  function O(r, t, e) {
811
- let i = c.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
812
- return `${c.format(r, n, e)} - ${c.format(i, s, e)}`;
833
+ let i = l.add(r, 6, "day"), n = i.getMonth() !== r.getMonth() ? "D MMM" : "D", s = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
834
+ return `${l.format(r, s, e)} - ${l.format(i, n, e)}`;
813
835
  }
814
- const y = [
836
+ const $ = [
815
837
  {
816
838
  name: "Hour",
817
839
  padding: "7d",
818
840
  step: "1h",
819
841
  date_format: "YYYY-MM-DD HH:",
820
842
  lower_text: "HH",
821
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D MMMM", e) : "",
843
+ upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? l.format(r, "D MMMM", e) : "",
822
844
  upper_text_frequency: 24
823
845
  },
824
846
  {
@@ -827,7 +849,7 @@ const y = [
827
849
  step: "6h",
828
850
  date_format: "YYYY-MM-DD HH:",
829
851
  lower_text: "HH",
830
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D MMM", e) : "",
852
+ upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? l.format(r, "D MMM", e) : "",
831
853
  upper_text_frequency: 4
832
854
  },
833
855
  {
@@ -836,7 +858,7 @@ const y = [
836
858
  step: "12h",
837
859
  date_format: "YYYY-MM-DD HH:",
838
860
  lower_text: "HH",
839
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? c.format(r, "D MMM", e) : c.format(r, "D", e) : "",
861
+ upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? l.format(r, "D MMM", e) : l.format(r, "D", e) : "",
840
862
  upper_text_frequency: 2
841
863
  },
842
864
  {
@@ -844,8 +866,8 @@ const y = [
844
866
  padding: "7d",
845
867
  date_format: "YYYY-MM-DD",
846
868
  step: "1d",
847
- lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? c.format(r, "D", e) : "",
848
- upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? c.format(r, "MMMM", e) : "",
869
+ lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? l.format(r, "D", e) : "",
870
+ upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? l.format(r, "MMMM", e) : "",
849
871
  thick_line: (r) => r.getDay() === 1
850
872
  },
851
873
  {
@@ -855,7 +877,7 @@ const y = [
855
877
  date_format: "YYYY-MM-DD",
856
878
  column_width: 140,
857
879
  lower_text: O,
858
- upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? c.format(r, "MMMM", e) : "",
880
+ upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? l.format(r, "MMMM", e) : "",
859
881
  thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
860
882
  upper_text_frequency: 4
861
883
  },
@@ -866,7 +888,7 @@ const y = [
866
888
  column_width: 120,
867
889
  date_format: "YYYY-MM",
868
890
  lower_text: "MMMM",
869
- upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? c.format(r, "YYYY", e) : "",
891
+ upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? l.format(r, "YYYY", e) : "",
870
892
  thick_line: (r) => r.getMonth() % 3 === 0,
871
893
  snap_at: "7d"
872
894
  },
@@ -876,7 +898,7 @@ const y = [
876
898
  step: "1y",
877
899
  column_width: 120,
878
900
  date_format: "YYYY",
879
- upper_text: (r, t, e) => !t || S(r) !== S(t) ? S(r) : "",
901
+ upper_text: (r, t, e) => !t || H(r) !== H(t) ? H(r) : "",
880
902
  lower_text: "YYYY",
881
903
  snap_at: "30d"
882
904
  }
@@ -903,12 +925,12 @@ const y = [
903
925
  padding: 18,
904
926
  popup: (r) => {
905
927
  r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
906
- const t = c.format(
928
+ const t = l.format(
907
929
  r.task._start,
908
930
  "MMM D",
909
931
  r.chart.options.language
910
- ), e = c.format(
911
- c.add(r.task._end, -1, "second"),
932
+ ), e = l.format(
933
+ l.add(r.task._end, -1, "second"),
912
934
  "MMM D",
913
935
  r.chart.options.language
914
936
  );
@@ -926,7 +948,7 @@ const y = [
926
948
  today_button: !0,
927
949
  view_mode: "Day",
928
950
  view_mode_select: !1,
929
- view_modes: y,
951
+ view_modes: $,
930
952
  is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6
931
953
  };
932
954
  class j {
@@ -936,12 +958,12 @@ class j {
936
958
  setup_wrapper(t) {
937
959
  let e, i;
938
960
  if (typeof t == "string") {
939
- let s = document.querySelector(t);
940
- if (!s)
961
+ let n = document.querySelector(t);
962
+ if (!n)
941
963
  throw new ReferenceError(
942
964
  `CSS selector "${t}" could not be found in DOM`
943
965
  );
944
- t = s;
966
+ t = n;
945
967
  }
946
968
  if (t instanceof HTMLElement)
947
969
  i = t, e = t.querySelector("svg");
@@ -968,12 +990,12 @@ class j {
968
990
  setup_options(t) {
969
991
  this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((i) => {
970
992
  if (typeof i == "string") {
971
- const s = y.find(
972
- (n) => n.name === i
993
+ const n = $.find(
994
+ (s) => s.name === i
973
995
  );
974
- return s || console.error(
996
+ return n || console.error(
975
997
  `The view mode "${i}" is not predefined in Frappe Gantt. Please define the view mode object instead.`
976
- ), s;
998
+ ), n;
977
999
  }
978
1000
  return i;
979
1001
  }), t.view_mode = t.view_modes[0]), this.options = { ...I, ...t };
@@ -984,10 +1006,10 @@ class j {
984
1006
  "upper-header-height": "upper_header_height"
985
1007
  };
986
1008
  for (let i in e) {
987
- let s = this.options[e[i]];
988
- s !== "auto" && this.$container.style.setProperty(
1009
+ let n = this.options[e[i]];
1010
+ n !== "auto" && this.$container.style.setProperty(
989
1011
  "--gv-" + i,
990
- s + "px"
1012
+ n + "px"
991
1013
  );
992
1014
  }
993
1015
  if (this.config = {
@@ -1001,7 +1023,7 @@ class j {
1001
1023
  this.config.ignored_function = i;
1002
1024
  continue;
1003
1025
  }
1004
- typeof i == "string" && (i === "weekend" ? this.config.ignored_function = (s) => s.getDay() == 6 || s.getDay() == 0 : this.config.ignored_dates.push(/* @__PURE__ */ new Date(i + " ")));
1026
+ typeof i == "string" && (i === "weekend" ? this.config.ignored_function = (n) => n.getDay() == 6 || n.getDay() == 0 : this.config.ignored_dates.push(/* @__PURE__ */ new Date(i + " ")));
1005
1027
  }
1006
1028
  } else
1007
1029
  this.config.ignored_function = this.options.ignore;
@@ -1015,20 +1037,20 @@ class j {
1015
1037
  return console.error(
1016
1038
  `task "${e.id}" doesn't have a start date`
1017
1039
  ), !1;
1018
- if (e._start = c.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
1019
- let { duration: h, scale: d } = c.parse_duration(a);
1020
- e.end = c.add(e.end, h, d);
1040
+ if (e._start = l.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((a) => {
1041
+ let { duration: h, scale: d } = l.parse_duration(a);
1042
+ e.end = l.add(e.end, h, d);
1021
1043
  })), !e.end)
1022
1044
  return console.error(`task "${e.id}" doesn't have an end date`), !1;
1023
- if (e._end = c.parse(e.end), c.diff(e._end, e._start, "year") < 0)
1045
+ if (e._end = l.parse(e.end), l.diff(e._end, e._start, "year") < 0)
1024
1046
  return console.error(
1025
1047
  `start of task can't be after end of task: in task "${e.id}"`
1026
1048
  ), !1;
1027
- if (c.diff(e._end, e._start, "year") > 10)
1049
+ if (l.diff(e._end, e._start, "year") > 10)
1028
1050
  return console.error(
1029
1051
  `the duration of task "${e.id}" is too long (above ten years)`
1030
1052
  ), !1;
1031
- if (e._index = i, c.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = c.add(e._end, 24, "hour")), typeof e.dependencies == "string" || !e.dependencies) {
1053
+ if (e._index = i, l.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = l.add(e._end, 24, "hour")), typeof e.dependencies == "string" || !e.dependencies) {
1032
1054
  let o = [];
1033
1055
  e.dependencies && (o = e.dependencies.split(",").map((a) => a.trim().replaceAll(" ", "_")).filter((a) => a)), e.dependencies = o;
1034
1056
  }
@@ -1045,16 +1067,16 @@ class j {
1045
1067
  this.setup_tasks(t), this.change_view_mode();
1046
1068
  }
1047
1069
  update_task(t, e) {
1048
- let i = this.tasks.find((n) => n.id === t), s = this.bars[i._index];
1049
- Object.assign(i, e), s.refresh();
1070
+ let i = this.tasks.find((s) => s.id === t), n = this.bars[i._index];
1071
+ Object.assign(i, e), n.refresh();
1050
1072
  }
1051
1073
  change_view_mode(t = this.options.view_mode, e = !1) {
1052
- typeof t == "string" && (t = this.options.view_modes.find((n) => n.name === t));
1053
- let i, s;
1054
- e && (i = this.$container.scrollLeft, s = this.options.scroll_to, this.options.scroll_to = null), this.options.view_mode = t.name, this.config.view_mode = t, this.update_view_scale(t), this.setup_dates(e), this.render(), e && (this.$container.scrollLeft = i, this.options.scroll_to = s), this.trigger_event("view_change", [t]);
1074
+ typeof t == "string" && (t = this.options.view_modes.find((s) => s.name === t));
1075
+ let i, n;
1076
+ e && (i = this.$container.scrollLeft, n = this.options.scroll_to, this.options.scroll_to = null), this.options.view_mode = t.name, this.config.view_mode = t, this.update_view_scale(t), this.setup_dates(e), this.render(), e && (this.$container.scrollLeft = i, this.options.scroll_to = n), this.trigger_event("view_change", [t]);
1055
1077
  }
1056
1078
  update_view_scale(t) {
1057
- let { duration: e, scale: i } = c.parse_duration(t.step);
1079
+ let { duration: e, scale: i } = l.parse_duration(t.step);
1058
1080
  this.config.step = e, this.config.unit = i, this.config.column_width = this.options.column_width || t.column_width || 45, this.$container.style.setProperty(
1059
1081
  "--gv-column-width",
1060
1082
  this.config.column_width + "px"
@@ -1066,15 +1088,15 @@ class j {
1066
1088
  setup_gantt_dates(t) {
1067
1089
  let e, i;
1068
1090
  this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
1069
- for (let s of this.tasks)
1070
- (!e || s._start < e) && (e = s._start), (!i || s._end > i) && (i = s._end);
1071
- if (e = c.start_of(e, this.config.unit), i = c.start_of(i, this.config.unit), !t)
1091
+ for (let n of this.tasks)
1092
+ (!e || n._start < e) && (e = n._start), (!i || n._end > i) && (i = n._end);
1093
+ if (e = l.start_of(e, this.config.unit), i = l.start_of(i, this.config.unit), !t)
1072
1094
  if (this.options.infinite_padding)
1073
- this.gantt_start = c.add(
1095
+ this.gantt_start = l.add(
1074
1096
  e,
1075
1097
  -this.config.extend_by_units * 3,
1076
1098
  this.config.unit
1077
- ), this.gantt_end = c.add(
1099
+ ), this.gantt_end = l.add(
1078
1100
  i,
1079
1101
  this.config.extend_by_units * 3,
1080
1102
  this.config.unit
@@ -1084,17 +1106,17 @@ class j {
1084
1106
  this.config.view_mode.padding,
1085
1107
  this.config.view_mode.padding
1086
1108
  ]);
1087
- let [s, n] = this.config.view_mode.padding.map(
1088
- c.parse_duration
1109
+ let [n, s] = this.config.view_mode.padding.map(
1110
+ l.parse_duration
1089
1111
  );
1090
- this.gantt_start = c.add(
1112
+ this.gantt_start = l.add(
1091
1113
  e,
1092
- -s.duration,
1093
- s.scale
1094
- ), this.gantt_end = c.add(
1095
- i,
1096
- n.duration,
1114
+ -n.duration,
1097
1115
  n.scale
1116
+ ), this.gantt_end = l.add(
1117
+ i,
1118
+ s.duration,
1119
+ s.scale
1098
1120
  );
1099
1121
  }
1100
1122
  this.config.date_format = this.config.view_mode.date_format || this.options.date_format, this.gantt_start.setHours(0, 0, 0, 0);
@@ -1102,7 +1124,7 @@ class j {
1102
1124
  setup_date_values() {
1103
1125
  let t = this.gantt_start;
1104
1126
  for (this.dates = [t]; t < this.gantt_end; )
1105
- t = c.add(
1127
+ t = l.add(
1106
1128
  t,
1107
1129
  this.config.step,
1108
1130
  this.config.unit
@@ -1157,10 +1179,10 @@ class j {
1157
1179
  make_grid_rows() {
1158
1180
  const t = f("g", { append_to: this.layers.grid }), e = this.dates.length * this.config.column_width, i = this.options.bar_height + this.options.padding;
1159
1181
  this.config.header_height;
1160
- for (let s = this.config.header_height; s < this.grid_height; s += i)
1182
+ for (let n = this.config.header_height; n < this.grid_height; n += i)
1161
1183
  f("rect", {
1162
1184
  x: 0,
1163
- y: s,
1185
+ y: n,
1164
1186
  width: e,
1165
1187
  height: i,
1166
1188
  class: "grid-row",
@@ -1187,8 +1209,8 @@ class j {
1187
1209
  const e = document.createElement("option");
1188
1210
  e.selected = !0, e.disabled = !0, e.textContent = "Mode", t.appendChild(e);
1189
1211
  for (const i of this.options.view_modes) {
1190
- const s = document.createElement("option");
1191
- s.value = i.name, s.textContent = i.name, i.name === this.config.view_mode.name && (s.selected = !0), t.appendChild(s);
1212
+ const n = document.createElement("option");
1213
+ n.value = i.name, n.textContent = i.name, i.name === this.config.view_mode.name && (n.selected = !0), t.appendChild(n);
1192
1214
  }
1193
1215
  t.addEventListener(
1194
1216
  "change",
@@ -1204,21 +1226,21 @@ class j {
1204
1226
  }
1205
1227
  make_grid_ticks() {
1206
1228
  if (this.options.lines === "none") return;
1207
- let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, s = f("g", {
1229
+ let t = 0, e = this.config.header_height, i = this.grid_height - this.config.header_height, n = f("g", {
1208
1230
  class: "lines_layer",
1209
1231
  append_to: this.layers.grid
1210
- }), n = this.config.header_height;
1232
+ }), s = this.config.header_height;
1211
1233
  const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
1212
1234
  if (this.options.lines !== "vertical")
1213
1235
  for (let h = this.config.header_height; h < this.grid_height; h += a)
1214
1236
  f("line", {
1215
1237
  x1: 0,
1216
- y1: n + a,
1238
+ y1: s + a,
1217
1239
  x2: o,
1218
- y2: n + a,
1240
+ y2: s + a,
1219
1241
  class: "row-line",
1220
- append_to: s
1221
- }), n += a;
1242
+ append_to: n
1243
+ }), s += a;
1222
1244
  if (this.options.lines !== "horizontal")
1223
1245
  for (let h of this.dates) {
1224
1246
  let d = "tick";
@@ -1226,7 +1248,7 @@ class j {
1226
1248
  d: `M ${t} ${e} v ${i}`,
1227
1249
  class: d,
1228
1250
  append_to: this.layers.grid
1229
- }), this.view_is("month") ? t += c.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += c.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1251
+ }), this.view_is("month") ? t += l.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += l.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1230
1252
  }
1231
1253
  }
1232
1254
  highlight_holidays() {
@@ -1235,10 +1257,10 @@ class j {
1235
1257
  for (let e in this.options.holidays) {
1236
1258
  let i = this.options.holidays[e];
1237
1259
  i === "weekend" && (i = this.options.is_weekend);
1238
- let s;
1260
+ let n;
1239
1261
  if (typeof i == "object") {
1240
- let n = i.find((o) => typeof o == "function");
1241
- if (n && (s = n), this.options.holidays.name) {
1262
+ let s = i.find((o) => typeof o == "function");
1263
+ if (s && (n = s), this.options.holidays.name) {
1242
1264
  let o = /* @__PURE__ */ new Date(i.date + " ");
1243
1265
  i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
1244
1266
  } else
@@ -1250,26 +1272,26 @@ class j {
1250
1272
  return (/* @__PURE__ */ new Date(a + " ")).getTime();
1251
1273
  }).includes(o.getTime());
1252
1274
  }
1253
- for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
1275
+ for (let s = new Date(this.gantt_start); s <= this.gantt_end; s.setDate(s.getDate() + 1))
1254
1276
  if (!(this.config.ignored_dates.find(
1255
- (o) => o.getTime() == n.getTime()
1256
- ) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
1257
- const o = c.diff(
1258
- n,
1277
+ (o) => o.getTime() == s.getTime()
1278
+ ) || this.config.ignored_function && this.config.ignored_function(s)) && (i(s) || n && n(s))) {
1279
+ const o = l.diff(
1280
+ s,
1259
1281
  this.gantt_start,
1260
1282
  this.config.unit
1261
- ) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = c.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1262
- if (t[n]) {
1283
+ ) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = l.format(s, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1284
+ if (t[s]) {
1263
1285
  let d = this.create_el({
1264
1286
  classes: "holiday-label label_" + h,
1265
1287
  append_to: this.$extras
1266
1288
  });
1267
- d.textContent = t[n];
1289
+ d.textContent = t[s];
1268
1290
  }
1269
1291
  f("rect", {
1270
1292
  x: Math.round(o),
1271
1293
  y: this.config.header_height,
1272
- width: this.config.column_width / c.convert_scales(
1294
+ width: this.config.column_width / l.convert_scales(
1273
1295
  this.config.view_mode.step,
1274
1296
  "day"
1275
1297
  ),
@@ -1291,20 +1313,20 @@ class j {
1291
1313
  if (!t) return;
1292
1314
  const [e, i] = t;
1293
1315
  i.classList.add("current-date-highlight");
1294
- const n = c.diff(
1316
+ const s = l.diff(
1295
1317
  /* @__PURE__ */ new Date(),
1296
1318
  this.gantt_start,
1297
1319
  this.config.unit
1298
1320
  ) / this.config.step * this.config.column_width;
1299
1321
  this.$current_highlight = this.create_el({
1300
1322
  top: this.config.header_height,
1301
- left: n,
1323
+ left: s,
1302
1324
  height: this.grid_height - this.config.header_height,
1303
1325
  classes: "current-highlight",
1304
1326
  append_to: this.$container
1305
1327
  }), this.$current_ball_highlight = this.create_el({
1306
1328
  top: this.config.header_height - 6,
1307
- left: n - 2.5,
1329
+ left: s - 2.5,
1308
1330
  width: 6,
1309
1331
  height: 6,
1310
1332
  classes: "current-ball-highlight",
@@ -1322,15 +1344,15 @@ class j {
1322
1344
  </pattern>`;
1323
1345
  for (let i = new Date(this.gantt_start); i <= this.gantt_end; i.setDate(i.getDate() + 1)) {
1324
1346
  if (!this.config.ignored_dates.find(
1325
- (n) => n.getTime() == i.getTime()
1347
+ (s) => s.getTime() == i.getTime()
1326
1348
  ) && (!this.config.ignored_function || !this.config.ignored_function(i)))
1327
1349
  continue;
1328
- let s = c.convert_scales(
1329
- c.diff(i, this.gantt_start) + "d",
1350
+ let n = l.convert_scales(
1351
+ l.diff(i, this.gantt_start) + "d",
1330
1352
  this.config.unit
1331
1353
  ) / this.config.step;
1332
- this.config.ignored_positions.push(s * this.config.column_width), f("rect", {
1333
- x: s * this.config.column_width,
1354
+ this.config.ignored_positions.push(n * this.config.column_width), f("rect", {
1355
+ x: n * this.config.column_width,
1334
1356
  y: this.config.header_height,
1335
1357
  width: this.config.column_width,
1336
1358
  height: t,
@@ -1343,10 +1365,10 @@ class j {
1343
1365
  this.config.view_mode
1344
1366
  );
1345
1367
  }
1346
- create_el({ left: t, top: e, width: i, height: s, id: n, classes: o, append_to: a, type: h }) {
1368
+ create_el({ left: t, top: e, width: i, height: n, id: s, classes: o, append_to: a, type: h }) {
1347
1369
  let d = document.createElement(h || "div");
1348
1370
  for (let _ of o.split(" ")) d.classList.add(_);
1349
- return d.style.top = e + "px", d.style.left = t + "px", n && (d.id = n), i && (d.style.width = i + "px"), s && (d.style.height = s + "px"), a && a.appendChild(d), d;
1371
+ return d.style.top = e + "px", d.style.left = t + "px", s && (d.id = s), i && (d.style.width = i + "px"), n && (d.style.height = n + "px"), a && a.appendChild(d), d;
1350
1372
  }
1351
1373
  make_dates() {
1352
1374
  this.get_dates_to_draw().forEach((t, e) => {
@@ -1374,27 +1396,27 @@ class j {
1374
1396
  }
1375
1397
  get_dates_to_draw() {
1376
1398
  let t = null;
1377
- return this.dates.map((i, s) => {
1378
- const n = this.get_date_info(i, t, s);
1379
- return t = n, n;
1399
+ return this.dates.map((i, n) => {
1400
+ const s = this.get_date_info(i, t, n);
1401
+ return t = s, s;
1380
1402
  });
1381
1403
  }
1382
1404
  get_date_info(t, e) {
1383
1405
  let i = e ? e.date : null;
1384
1406
  this.config.column_width;
1385
- const s = e ? e.x + e.column_width : 0;
1386
- let n = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
1387
- return n ? typeof n == "string" && (this.config.view_mode.upper_text = (a) => c.format(a, n, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => c.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1407
+ const n = e ? e.x + e.column_width : 0;
1408
+ let s = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
1409
+ return s ? typeof s == "string" && (this.config.view_mode.upper_text = (a) => l.format(a, s, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => l.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1388
1410
  date: t,
1389
1411
  formatted_date: k(
1390
- c.format(
1412
+ l.format(
1391
1413
  t,
1392
1414
  this.config.date_format,
1393
1415
  this.options.language
1394
1416
  )
1395
1417
  ),
1396
1418
  column_width: this.config.column_width,
1397
- x: s,
1419
+ x: n,
1398
1420
  upper_text: this.config.view_mode.upper_text(
1399
1421
  t,
1400
1422
  i,
@@ -1420,56 +1442,56 @@ class j {
1420
1442
  for (let t of this.tasks) {
1421
1443
  let e = [];
1422
1444
  e = t.dependencies.map((i) => {
1423
- const s = this.get_task(i);
1424
- if (!s) return;
1425
- const n = new C(
1445
+ const n = this.get_task(i);
1446
+ if (!n) return;
1447
+ const s = new C(
1426
1448
  this,
1427
- this.bars[s._index],
1449
+ this.bars[n._index],
1428
1450
  // from_task
1429
1451
  this.bars[t._index]
1430
1452
  // to_task
1431
1453
  );
1432
- return this.layers.arrow.appendChild(n.element), n;
1454
+ return this.layers.arrow.appendChild(s.element), s;
1433
1455
  }).filter(Boolean), this.arrows = this.arrows.concat(e);
1434
1456
  }
1435
1457
  }
1436
1458
  calculate_critical_path() {
1437
- this.tasks.forEach((n) => n._is_critical = !1);
1459
+ this.tasks.forEach((s) => s._is_critical = !1);
1438
1460
  const t = {};
1439
- this.tasks.forEach((n) => {
1440
- t[n.id] = { es: 0, ef: 0, ls: 0, lf: 0 };
1461
+ this.tasks.forEach((s) => {
1462
+ t[s.id] = { es: 0, ef: 0, ls: 0, lf: 0 };
1441
1463
  });
1442
- const e = (n) => {
1443
- if (t[n.id].ef > 0) return t[n.id];
1464
+ const e = (s) => {
1465
+ if (t[s.id].ef > 0) return t[s.id];
1444
1466
  let o = 0;
1445
- n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
1467
+ s.dependencies && s.dependencies.length > 0 && s.dependencies.forEach((h) => {
1446
1468
  const d = this.get_task(h);
1447
1469
  if (d) {
1448
1470
  const _ = e(d);
1449
1471
  o = Math.max(o, _.ef);
1450
1472
  }
1451
- }), t[n.id].es = o;
1452
- const a = c.diff(n._end, n._start, "hour") / 24;
1453
- return t[n.id].ef = o + a, t[n.id];
1473
+ }), t[s.id].es = o;
1474
+ const a = l.diff(s._end, s._start, "hour") / 24;
1475
+ return t[s.id].ef = o + a, t[s.id];
1454
1476
  };
1455
- this.tasks.forEach((n) => e(n));
1456
- const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
1457
- if (t[n.id].ls > 0 || t[n.id].lf > 0)
1458
- return t[n.id];
1477
+ this.tasks.forEach((s) => e(s));
1478
+ const i = Math.max(...Object.values(t).map((s) => s.ef)), n = (s) => {
1479
+ if (t[s.id].ls > 0 || t[s.id].lf > 0)
1480
+ return t[s.id];
1459
1481
  const o = this.tasks.filter(
1460
- (d) => d.dependencies && d.dependencies.includes(n.id)
1482
+ (d) => d.dependencies && d.dependencies.includes(s.id)
1461
1483
  );
1462
1484
  let a = i;
1463
1485
  o.length > 0 && o.forEach((d) => {
1464
- const _ = s(d);
1486
+ const _ = n(d);
1465
1487
  a = Math.min(a, _.ls);
1466
1488
  });
1467
- const h = c.diff(n._end, n._start, "hour") / 24;
1468
- return t[n.id].lf = a, t[n.id].ls = a - h, t[n.id];
1489
+ const h = l.diff(s._end, s._start, "hour") / 24;
1490
+ return t[s.id].lf = a, t[s.id].ls = a - h, t[s.id];
1469
1491
  };
1470
- this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
1471
- const o = t[n.id], a = o.ls - o.es;
1472
- n._is_critical = Math.abs(a) < 0.01;
1492
+ this.tasks.forEach((s) => n(s)), this.tasks.forEach((s) => {
1493
+ const o = t[s.id], a = o.ls - o.es;
1494
+ s._is_critical = Math.abs(a) < 0.01;
1473
1495
  });
1474
1496
  }
1475
1497
  update_arrow_critical_path() {
@@ -1498,9 +1520,9 @@ class j {
1498
1520
  else {
1499
1521
  if (t === "today")
1500
1522
  return this.scroll_current();
1501
- typeof t == "string" && (t = c.parse(t));
1523
+ typeof t == "string" && (t = l.parse(t));
1502
1524
  }
1503
- const i = c.diff(
1525
+ const i = l.diff(
1504
1526
  t,
1505
1527
  this.gantt_start,
1506
1528
  this.config.unit
@@ -1508,27 +1530,27 @@ class j {
1508
1530
  this.$container.scrollTo({
1509
1531
  left: i - this.config.column_width / 6,
1510
1532
  behavior: "smooth"
1511
- }), this.$current && this.$current.classList.remove("current-upper"), this.current_date = c.add(
1533
+ }), this.$current && this.$current.classList.remove("current-upper"), this.current_date = l.add(
1512
1534
  this.gantt_start,
1513
1535
  this.$container.scrollLeft / this.config.column_width,
1514
1536
  this.config.unit
1515
1537
  );
1516
- let s = this.config.view_mode.upper_text(
1538
+ let n = this.config.view_mode.upper_text(
1517
1539
  this.current_date,
1518
1540
  null,
1519
1541
  this.options.language
1520
- ), n = this.upperTexts.find(
1521
- (o) => o.textContent === s
1542
+ ), s = this.upperTexts.find(
1543
+ (o) => o.textContent === n
1522
1544
  );
1523
- this.current_date = c.add(
1545
+ this.current_date = l.add(
1524
1546
  this.gantt_start,
1525
- (this.$container.scrollLeft + n.clientWidth) / this.config.column_width,
1547
+ (this.$container.scrollLeft + s.clientWidth) / this.config.column_width,
1526
1548
  this.config.unit
1527
- ), s = this.config.view_mode.upper_text(
1549
+ ), n = this.config.view_mode.upper_text(
1528
1550
  this.current_date,
1529
1551
  null,
1530
1552
  this.options.language
1531
- ), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
1553
+ ), s = this.upperTexts.find((o) => o.textContent === n), s.classList.add("current-upper"), this.$current = s;
1532
1554
  }
1533
1555
  scroll_current() {
1534
1556
  let t = this.get_closest_date();
@@ -1539,26 +1561,26 @@ class j {
1539
1561
  if (t < this.gantt_start || t > this.gantt_end) return null;
1540
1562
  let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
1541
1563
  ".date_" + k(
1542
- c.format(
1564
+ l.format(
1543
1565
  e,
1544
1566
  this.config.date_format,
1545
1567
  this.options.language
1546
1568
  )
1547
1569
  )
1548
- ), s = 0;
1549
- for (; !i && s < this.config.step; )
1550
- e = c.add(e, -1, this.config.unit), i = this.$container.querySelector(
1570
+ ), n = 0;
1571
+ for (; !i && n < this.config.step; )
1572
+ e = l.add(e, -1, this.config.unit), i = this.$container.querySelector(
1551
1573
  ".date_" + k(
1552
- c.format(
1574
+ l.format(
1553
1575
  e,
1554
1576
  this.config.date_format,
1555
1577
  this.options.language
1556
1578
  )
1557
1579
  )
1558
- ), s++;
1580
+ ), n++;
1559
1581
  return [
1560
1582
  /* @__PURE__ */ new Date(
1561
- c.format(
1583
+ l.format(
1562
1584
  e,
1563
1585
  this.config.date_format,
1564
1586
  this.options.language
@@ -1584,101 +1606,101 @@ class j {
1584
1606
  ".label_" + e.classList[1]
1585
1607
  );
1586
1608
  if (!i) continue;
1587
- let s;
1588
- e.onmouseenter = (n) => {
1589
- s = setTimeout(() => {
1590
- i.classList.add("show"), i.style.left = (n.offsetX || n.layerX) + "px", i.style.top = (n.offsetY || n.layerY) + "px";
1609
+ let n;
1610
+ e.onmouseenter = (s) => {
1611
+ n = setTimeout(() => {
1612
+ i.classList.add("show"), i.style.left = (s.offsetX || s.layerX) + "px", i.style.top = (s.offsetY || s.layerY) + "px";
1591
1613
  }, 300);
1592
- }, e.onmouseleave = (n) => {
1593
- clearTimeout(s), i.classList.remove("show");
1614
+ }, e.onmouseleave = (s) => {
1615
+ clearTimeout(n), i.classList.remove("show");
1594
1616
  };
1595
1617
  }
1596
1618
  }
1597
1619
  get_start_end_positions() {
1598
1620
  if (!this.bars.length) return [0, 0, 0];
1599
- let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
1621
+ let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, n = t, s = t + e;
1600
1622
  return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
1601
1623
  let { x: h, width: d } = o.getBBox();
1602
- h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
1603
- }), [i, s, n];
1624
+ h < i && (i = h), h > n && (n = h), h + d > s && (s = h + d);
1625
+ }), [i, n, s];
1604
1626
  }
1605
1627
  bind_bar_events() {
1606
- let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
1628
+ let t = !1, e = 0, i = 0, n = !1, s = !1, o = null, a = [];
1607
1629
  this.bar_being_dragged = null;
1608
- const h = () => t || s || n;
1630
+ const h = () => t || n || s;
1609
1631
  this.$svg.onclick = (_) => {
1610
1632
  _.target.classList.contains("grid-row") && this.unselect_all();
1611
1633
  };
1612
1634
  let d = 0;
1613
1635
  if (u.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
1614
1636
  this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
1615
- }), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, l) => {
1616
- const p = u.closest(".bar-wrapper", l);
1617
- l.classList.contains("left") ? (s = !0, l.classList.add("visible")) : l.classList.contains("right") ? (n = !0, l.classList.add("visible")) : l.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = p.getAttribute("data-id");
1618
- const $ = this.get_bar(o).task.dependencies_type || this.options.dependencies_type;
1637
+ }), u.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, c) => {
1638
+ const g = u.closest(".bar-wrapper", c);
1639
+ c.classList.contains("left") ? (n = !0, c.classList.add("visible")) : c.classList.contains("right") ? (s = !0, c.classList.add("visible")) : c.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = g.getAttribute("data-id");
1640
+ const w = this.get_bar(o).task.dependencies_type || this.options.dependencies_type;
1619
1641
  let m;
1620
- this.options.move_dependencies && $ === "fixed" ? m = [
1642
+ this.options.move_dependencies && w === "fixed" ? m = [
1621
1643
  o,
1622
1644
  ...this.get_all_dependent_tasks(o)
1623
1645
  ] : m = [o], a = m.map((x) => this.get_bar(x)), this.bar_being_dragged = !1, d = e, a.forEach((x) => {
1624
- const w = x.$bar;
1625
- w.ox = w.getX(), w.oy = w.getY(), w.owidth = w.getWidth(), w.finaldx = 0;
1646
+ const b = x.$bar;
1647
+ b.ox = b.getX(), b.oy = b.getY(), b.owidth = b.getWidth(), b.finaldx = 0;
1626
1648
  });
1627
1649
  }), this.options.infinite_padding) {
1628
1650
  let _ = !1;
1629
- u.on(this.$container, "mousewheel", (l) => {
1630
- let p = this.$container.scrollWidth / 2;
1631
- if (!_ && l.currentTarget.scrollLeft <= p) {
1632
- let g = l.currentTarget.scrollLeft;
1633
- _ = !0, this.gantt_start = c.add(
1651
+ u.on(this.$container, "mousewheel", (c) => {
1652
+ let g = this.$container.scrollWidth / 2;
1653
+ if (!_ && c.currentTarget.scrollLeft <= g) {
1654
+ let p = c.currentTarget.scrollLeft;
1655
+ _ = !0, this.gantt_start = l.add(
1634
1656
  this.gantt_start,
1635
1657
  -this.config.extend_by_units,
1636
1658
  this.config.unit
1637
- ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = g + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
1659
+ ), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = p + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
1638
1660
  }
1639
- if (!_ && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= p) {
1640
- let g = l.currentTarget.scrollLeft;
1641
- _ = !0, this.gantt_end = c.add(
1661
+ if (!_ && c.currentTarget.scrollWidth - (c.currentTarget.scrollLeft + c.currentTarget.clientWidth) <= g) {
1662
+ let p = c.currentTarget.scrollLeft;
1663
+ _ = !0, this.gantt_end = l.add(
1642
1664
  this.gantt_end,
1643
1665
  this.config.extend_by_units,
1644
1666
  this.config.unit
1645
- ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = g, setTimeout(() => _ = !1, 300);
1667
+ ), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = p, setTimeout(() => _ = !1, 300);
1646
1668
  }
1647
1669
  });
1648
1670
  }
1649
1671
  u.on(this.$container, "scroll", (_) => {
1650
- let l = [];
1651
- const p = this.bars.map(
1652
- ({ group: b }) => b.getAttribute("data-id")
1672
+ let c = [];
1673
+ const g = this.bars.map(
1674
+ ({ group: y }) => y.getAttribute("data-id")
1653
1675
  );
1654
- let g;
1655
- i && (g = _.currentTarget.scrollLeft - i), this.current_date = c.add(
1676
+ let p;
1677
+ i && (p = _.currentTarget.scrollLeft - i), this.current_date = l.add(
1656
1678
  this.gantt_start,
1657
1679
  _.currentTarget.scrollLeft / this.config.column_width * this.config.step,
1658
1680
  this.config.unit
1659
1681
  );
1660
- let $ = this.config.view_mode.upper_text(
1682
+ let w = this.config.view_mode.upper_text(
1661
1683
  this.current_date,
1662
1684
  null,
1663
1685
  this.options.language
1664
1686
  ), m = this.upperTexts.find(
1665
- (b) => b.textContent === $
1687
+ (y) => y.textContent === w
1666
1688
  );
1667
- this.current_date = c.add(
1689
+ this.current_date = l.add(
1668
1690
  this.gantt_start,
1669
1691
  (_.currentTarget.scrollLeft + m.clientWidth) / this.config.column_width * this.config.step,
1670
1692
  this.config.unit
1671
- ), $ = this.config.view_mode.upper_text(
1693
+ ), w = this.config.view_mode.upper_text(
1672
1694
  this.current_date,
1673
1695
  null,
1674
1696
  this.options.language
1675
1697
  ), m = this.upperTexts.find(
1676
- (b) => b.textContent === $
1698
+ (y) => y.textContent === w
1677
1699
  ), m !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), m.classList.add("current-upper"), this.$current = m), i = _.currentTarget.scrollLeft;
1678
- let [x, w, X] = this.get_start_end_positions();
1700
+ let [x, b, X] = this.get_start_end_positions();
1679
1701
  i > X + 100 ? (this.$adjust.innerHTML = "&larr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1680
1702
  this.$container.scrollTo({
1681
- left: w,
1703
+ left: b,
1682
1704
  behavior: "smooth"
1683
1705
  });
1684
1706
  }) : i + _.currentTarget.offsetWidth < x - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
@@ -1686,55 +1708,55 @@ class j {
1686
1708
  left: x,
1687
1709
  behavior: "smooth"
1688
1710
  });
1689
- }) : this.$adjust.classList.add("hide"), g && (l = p.map((b) => this.get_bar(b)), this.options.auto_move_label && l.forEach((b) => {
1690
- b.update_label_position_on_horizontal_scroll({
1691
- x: g,
1711
+ }) : this.$adjust.classList.add("hide"), p && (c = g.map((y) => this.get_bar(y)), this.options.auto_move_label && c.forEach((y) => {
1712
+ y.update_label_position_on_horizontal_scroll({
1713
+ x: p,
1692
1714
  sx: _.currentTarget.scrollLeft
1693
1715
  });
1694
1716
  }));
1695
1717
  }), u.on(this.$svg, "mousemove", (_) => {
1696
1718
  if (!h()) return;
1697
- const l = (_.offsetX || _.layerX) - e;
1698
- a.forEach((p) => {
1699
- const g = p.$bar;
1700
- g.finaldx = this.get_snap_position(l, g.ox), this.hide_popup(), s ? o === p.task.id ? p.update_bar_position({
1701
- x: g.ox + g.finaldx,
1702
- width: g.owidth - g.finaldx
1703
- }) : p.update_bar_position({
1704
- x: g.ox + g.finaldx
1705
- }) : n ? o === p.task.id && p.update_bar_position({
1706
- width: g.owidth + g.finaldx
1707
- }) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: g.ox + g.finaldx });
1719
+ const c = (_.offsetX || _.layerX) - e;
1720
+ a.forEach((g) => {
1721
+ const p = g.$bar;
1722
+ p.finaldx = this.get_snap_position(c, p.ox), this.hide_popup(), n ? o === g.task.id ? g.update_bar_position({
1723
+ x: p.ox + p.finaldx,
1724
+ width: p.owidth - p.finaldx
1725
+ }) : g.update_bar_position({
1726
+ x: p.ox + p.finaldx
1727
+ }) : s ? o === g.task.id && g.update_bar_position({
1728
+ width: p.owidth + p.finaldx
1729
+ }) : t && !this.options.readonly && !this.options.readonly_dates && g.update_bar_position({ x: p.ox + p.finaldx });
1708
1730
  });
1709
1731
  }), document.addEventListener("mouseup", () => {
1710
- var _, l, p;
1711
- t = !1, s = !1, n = !1, (p = (l = (_ = this.$container.querySelector(".visible")) == null ? void 0 : _.classList) == null ? void 0 : l.remove) == null || p.call(l, "visible");
1732
+ var _, c, g;
1733
+ t = !1, n = !1, s = !1, (g = (c = (_ = this.$container.querySelector(".visible")) == null ? void 0 : _.classList) == null ? void 0 : c.remove) == null || g.call(c, "visible");
1712
1734
  }), u.on(this.$svg, "mouseup", (_) => {
1713
1735
  this.bar_being_dragged = null;
1714
- const l = [];
1715
- a.forEach((g) => {
1716
- g.$bar.finaldx && (g.date_changed(), g.compute_progress(), g.set_action_completed(), l.push({
1717
- task: g.task,
1718
- start: g.task._start,
1719
- end: c.add(g.task._end, -1, "second")
1736
+ const c = [];
1737
+ a.forEach((p) => {
1738
+ p.$bar.finaldx && (p.date_changed(), p.compute_progress(), p.set_action_completed(), c.push({
1739
+ task: p.task,
1740
+ start: p.task._start,
1741
+ end: l.add(p.task._end, -1, "second")
1720
1742
  }));
1721
1743
  });
1722
- const p = this.get_bar(o);
1723
- if (p && p.$bar.finaldx) {
1724
- const g = this.update_dependent_tasks_by_type(p);
1725
- l.push(...g);
1744
+ const g = this.get_bar(o);
1745
+ if (g && g.$bar.finaldx) {
1746
+ const p = this.update_dependent_tasks_by_type(g);
1747
+ c.push(...p);
1726
1748
  }
1727
- this.options.critical_path && a.some((g) => g.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), l.length > 0 && l.forEach(({ task: g, start: $, end: m }) => {
1728
- this.trigger_event("after_date_change", [g, $, m]);
1749
+ this.options.critical_path && a.some((p) => p.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), c.length > 0 && c.forEach(({ task: p, start: w, end: m }) => {
1750
+ this.trigger_event("after_date_change", [p, w, m]);
1729
1751
  });
1730
1752
  }), this.bind_bar_progress();
1731
1753
  }
1732
1754
  bind_bar_progress() {
1733
- let t = 0, e = null, i = null, s = null, n = null;
1755
+ let t = 0, e = null, i = null, n = null, s = null;
1734
1756
  u.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
1735
1757
  e = !0, t = a.offsetX || a.layerX;
1736
1758
  const _ = u.closest(".bar-wrapper", h).getAttribute("data-id");
1737
- i = this.get_bar(_), s = i.$bar_progress, n = i.$bar, s.finaldx = 0, s.owidth = s.getWidth(), s.min_dx = -s.owidth, s.max_dx = n.getWidth() - s.getWidth();
1759
+ i = this.get_bar(_), n = i.$bar_progress, s = i.$bar, n.finaldx = 0, n.owidth = n.getWidth(), n.min_dx = -n.owidth, n.max_dx = s.getWidth() - n.getWidth();
1738
1760
  });
1739
1761
  const o = this.config.ignored_positions.map((a) => [
1740
1762
  a,
@@ -1744,87 +1766,87 @@ class j {
1744
1766
  if (!e) return;
1745
1767
  let h = a.offsetX || a.layerX;
1746
1768
  if (h > t) {
1747
- let l = o.find(
1748
- ([p, g]) => h >= p && h < g
1769
+ let c = o.find(
1770
+ ([g, p]) => h >= g && h < p
1749
1771
  );
1750
- for (; l; )
1751
- h = l[1], l = o.find(
1752
- ([p, g]) => h >= p && h < g
1772
+ for (; c; )
1773
+ h = c[1], c = o.find(
1774
+ ([g, p]) => h >= g && h < p
1753
1775
  );
1754
1776
  } else {
1755
- let l = o.find(
1756
- ([p, g]) => h > p && h <= g
1777
+ let c = o.find(
1778
+ ([g, p]) => h > g && h <= p
1757
1779
  );
1758
- for (; l; )
1759
- h = l[0], l = o.find(
1760
- ([p, g]) => h > p && h <= g
1780
+ for (; c; )
1781
+ h = c[0], c = o.find(
1782
+ ([g, p]) => h > g && h <= p
1761
1783
  );
1762
1784
  }
1763
1785
  let _ = h - t;
1764
- console.log(s), _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), u.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
1786
+ console.log(n), _ > n.max_dx && (_ = n.max_dx), _ < n.min_dx && (_ = n.min_dx), n.setAttribute("width", n.owidth + _), u.attr(i.$handle_progress, "cx", n.getEndX()), n.finaldx = _;
1765
1787
  }), u.on(this.$svg, "mouseup", () => {
1766
- e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
1788
+ e = !1, n && n.finaldx && (n.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, n = null, s = null);
1767
1789
  });
1768
1790
  }
1769
1791
  get_all_dependent_tasks(t) {
1770
1792
  let e = [], i = [t];
1771
1793
  for (; i.length; ) {
1772
- const s = i.reduce((n, o) => (n = n.concat(this.dependency_map[o]), n), []);
1773
- e = e.concat(s), i = s.filter((n) => !i.includes(n));
1794
+ const n = i.reduce((s, o) => (s = s.concat(this.dependency_map[o]), s), []);
1795
+ e = e.concat(n), i = n.filter((s) => !i.includes(s));
1774
1796
  }
1775
1797
  return e.filter(Boolean);
1776
1798
  }
1777
1799
  update_dependent_tasks_by_type(t) {
1778
1800
  const e = t.task.dependencies_type || this.options.dependencies_type, i = [];
1779
- return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((n) => {
1780
- const o = this.get_bar(n);
1801
+ return e === "fixed" || (this.dependency_map[t.task.id] || []).forEach((s) => {
1802
+ const o = this.get_bar(s);
1781
1803
  if (!o) return;
1782
1804
  const a = o.task, h = a.dependencies_type || this.options.dependencies_type;
1783
1805
  let d, _;
1784
- const l = c.diff(a._end, a._start, "hour");
1785
- let p = !1;
1806
+ const c = l.diff(a._end, a._start, "hour");
1807
+ let g = !1;
1786
1808
  switch (h) {
1787
1809
  case "finish-to-start":
1788
- t.task._end > a._start && (d = new Date(t.task._end), _ = c.add(d, l, "hour"), p = !0);
1810
+ t.task._end > a._start && (d = new Date(t.task._end), _ = l.add(d, c, "hour"), g = !0);
1789
1811
  break;
1790
1812
  case "start-to-start":
1791
- t.task._start > a._start && (d = new Date(t.task._start), _ = c.add(d, l, "hour"), p = !0);
1813
+ t.task._start > a._start && (d = new Date(t.task._start), _ = l.add(d, c, "hour"), g = !0);
1792
1814
  break;
1793
1815
  case "finish-to-finish":
1794
- t.task._end > a._end && (_ = new Date(t.task._end), d = c.add(_, -l, "hour"), p = !0);
1816
+ t.task._end > a._end && (_ = new Date(t.task._end), d = l.add(_, -c, "hour"), g = !0);
1795
1817
  break;
1796
1818
  case "start-to-finish":
1797
- t.task._start > a._end && (_ = new Date(t.task._start), d = c.add(_, -l, "hour"), p = !0);
1819
+ t.task._start > a._end && (_ = new Date(t.task._start), d = l.add(_, -c, "hour"), g = !0);
1798
1820
  break;
1799
1821
  default:
1800
1822
  return;
1801
1823
  }
1802
- if (!p) return;
1824
+ if (!g) return;
1803
1825
  a._start = d, a._end = _, o.compute_x(), o.compute_duration(), o.update_bar_position({
1804
1826
  x: o.x,
1805
1827
  width: o.width
1806
1828
  }), this.trigger_event("date_change", [
1807
1829
  a,
1808
1830
  d,
1809
- c.add(_, -1, "second")
1831
+ l.add(_, -1, "second")
1810
1832
  ]), i.push({
1811
1833
  task: a,
1812
1834
  start: d,
1813
- end: c.add(_, -1, "second")
1835
+ end: l.add(_, -1, "second")
1814
1836
  });
1815
- const g = this.update_dependent_tasks_by_type(o);
1816
- i.push(...g);
1837
+ const p = this.update_dependent_tasks_by_type(o);
1838
+ i.push(...p);
1817
1839
  }), i;
1818
1840
  }
1819
1841
  get_snap_position(t, e) {
1820
1842
  let i = 1;
1821
- const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
1822
- if (s !== "unit") {
1823
- const { duration: _, scale: l } = c.parse_duration(s);
1824
- i = c.convert_scales(this.config.view_mode.step, l) / _;
1843
+ const n = this.options.snap_at || this.config.view_mode.snap_at || "1d";
1844
+ if (n !== "unit") {
1845
+ const { duration: _, scale: c } = l.parse_duration(n);
1846
+ i = l.convert_scales(this.config.view_mode.step, c) / _;
1825
1847
  }
1826
- const n = t % (this.config.column_width / i);
1827
- let o = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
1848
+ const s = t % (this.config.column_width / i);
1849
+ let o = t - s + (s < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
1828
1850
  const h = o > 0 ? 1 : -1;
1829
1851
  let d = this.get_ignored_region(a, h);
1830
1852
  for (; d.length; )
@@ -1878,18 +1900,18 @@ class j {
1878
1900
  * @memberof Gantt
1879
1901
  */
1880
1902
  clear() {
1881
- var t, e, i, s, n, o, a, h, d, _;
1882
- this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (s = (i = this.$side_header) == null ? void 0 : i.remove) == null || s.call(i), (o = (n = this.$current_highlight) == null ? void 0 : n.remove) == null || o.call(n), (h = (a = this.$extras) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.popup) == null ? void 0 : d.hide) == null || _.call(d);
1903
+ var t, e, i, n, s, o, a, h, d, _;
1904
+ this.$svg.innerHTML = "", (e = (t = this.$header) == null ? void 0 : t.remove) == null || e.call(t), (n = (i = this.$side_header) == null ? void 0 : i.remove) == null || n.call(i), (o = (s = this.$current_highlight) == null ? void 0 : s.remove) == null || o.call(s), (h = (a = this.$extras) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.popup) == null ? void 0 : d.hide) == null || _.call(d);
1883
1905
  }
1884
1906
  }
1885
1907
  j.VIEW_MODE = {
1886
- HOUR: y[0],
1887
- QUARTER_DAY: y[1],
1888
- HALF_DAY: y[2],
1889
- DAY: y[3],
1890
- WEEK: y[4],
1891
- MONTH: y[5],
1892
- YEAR: y[6]
1908
+ HOUR: $[0],
1909
+ QUARTER_DAY: $[1],
1910
+ HALF_DAY: $[2],
1911
+ DAY: $[3],
1912
+ WEEK: $[4],
1913
+ MONTH: $[5],
1914
+ YEAR: $[6]
1893
1915
  };
1894
1916
  function B(r) {
1895
1917
  return r.name + "_" + Math.random().toString(36).slice(2, 12);