@workiom/frappe-gantt 1.0.21 → 1.0.22

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,6 +1,6 @@
1
- const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second", W = "millisecond", g = {
2
- parse_duration(r) {
3
- const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(r);
1
+ const E = "year", A = "month", S = "day", Y = "hour", H = "minute", X = "second", q = "millisecond", p = {
2
+ parse_duration(a) {
3
+ const e = /([0-9]+)(y|m|d|h|min|s|ms)/gm.exec(a);
4
4
  if (e !== null) {
5
5
  if (e[2] === "y")
6
6
  return { duration: parseInt(e[1]), scale: "year" };
@@ -18,124 +18,124 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
18
18
  return { duration: parseInt(e[1]), scale: "millisecond" };
19
19
  }
20
20
  },
21
- parse(r, t = "-", e = /[.:]/) {
22
- if (r instanceof Date)
23
- return r;
24
- if (typeof r == "string") {
21
+ parse(a, t = "-", e = /[.:]/) {
22
+ if (a instanceof Date)
23
+ return a;
24
+ if (typeof a == "string") {
25
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;
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);
26
+ const n = a.split(" ");
27
+ i = n[0].split(t).map((o) => parseInt(o, 10)), s = n[1] && n[1].split(e), i[1] = i[1] ? i[1] - 1 : 0;
28
+ let r = i;
29
+ return s && s.length && (s.length === 4 && (s[3] = "0." + s[3], s[3] = parseFloat(s[3]) * 1e3), r = r.concat(s)), new Date(...r);
30
30
  }
31
31
  },
32
- to_string(r, t = !1) {
33
- if (!(r instanceof Date))
32
+ to_string(a, t = !1) {
33
+ if (!(a 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 ? L(n + "", 3, "0") : L(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
35
+ const e = this.get_date_values(a).map((n, r) => (r === 1 && (n = n + 1), r === 6 ? L(n + "", 3, "0") : L(n + "", 2, "0"))), i = `${e[0]}-${e[1]}-${e[2]}`, s = `${e[3]}:${e[4]}:${e[5]}.${e[6]}`;
36
36
  return i + (t ? " " + s : "");
37
37
  },
38
- format(r, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
38
+ format(a, t = "YYYY-MM-DD HH:mm:ss.SSS", e = "en") {
39
39
  const i = new Intl.DateTimeFormat(e, {
40
40
  month: "long"
41
41
  }), s = 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((c) => L(c, 2, 0)), h = {
44
- YYYY: a[0],
45
- MM: L(+a[1] + 1, 2, 0),
46
- DD: a[2],
47
- HH: a[3],
48
- mm: a[4],
49
- ss: a[5],
50
- SSS: a[6],
51
- D: a[2],
52
- MMMM: o,
53
- MMM: s.format(r)
43
+ }), n = i.format(a), r = n.charAt(0).toUpperCase() + n.slice(1), o = this.get_date_values(a).map((l) => L(l, 2, 0)), h = {
44
+ YYYY: o[0],
45
+ MM: L(+o[1] + 1, 2, 0),
46
+ DD: o[2],
47
+ HH: o[3],
48
+ mm: o[4],
49
+ ss: o[5],
50
+ SSS: o[6],
51
+ D: o[2],
52
+ MMMM: r,
53
+ MMM: s.format(a)
54
54
  };
55
- let d = t;
56
- const _ = [];
57
- return Object.keys(h).sort((c, p) => p.length - c.length).forEach((c) => {
58
- d.includes(c) && (d = d.replaceAll(c, `$${_.length}`), _.push(h[c]));
59
- }), _.forEach((c, p) => {
60
- d = d.replaceAll(`$${p}`, c);
61
- }), d;
55
+ let _ = t;
56
+ const d = [];
57
+ return Object.keys(h).sort((l, g) => g.length - l.length).forEach((l) => {
58
+ _.includes(l) && (_ = _.replaceAll(l, `$${d.length}`), d.push(h[l]));
59
+ }), d.forEach((l, g) => {
60
+ _ = _.replaceAll(`$${g}`, l);
61
+ }), _;
62
62
  },
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(), 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(
63
+ diff(a, t, e = "day") {
64
+ let i, s, n, r, o, h, _;
65
+ i = a - t + (t.getTimezoneOffset() - a.getTimezoneOffset()) * 6e4, s = i / 1e3, r = s / 60, n = r / 60, o = n / 24;
66
+ let d = a.getFullYear() - t.getFullYear(), l = a.getMonth() - t.getMonth();
67
+ return l += o % 30 / 30, h = d * 12 + l, a.getDate() < t.getDate() && h--, _ = h / 12, e.endsWith("s") || (e += "s"), Math.round(
68
68
  {
69
69
  milliseconds: i,
70
70
  seconds: s,
71
- minutes: o,
71
+ minutes: r,
72
72
  hours: n,
73
- days: a,
73
+ days: o,
74
74
  months: h,
75
- years: d
75
+ years: _
76
76
  }[e] * 100
77
77
  ) / 100;
78
78
  },
79
79
  today() {
80
- const r = this.get_date_values(/* @__PURE__ */ new Date()).slice(0, 3);
81
- return new Date(...r);
80
+ const a = this.get_date_values(/* @__PURE__ */ new Date()).slice(0, 3);
81
+ return new Date(...a);
82
82
  },
83
83
  now() {
84
84
  return /* @__PURE__ */ new Date();
85
85
  },
86
- add(r, t, e) {
86
+ add(a, t, e) {
87
87
  t = parseInt(t, 10);
88
88
  const i = [
89
- r.getFullYear() + (e === A ? t : 0),
90
- r.getMonth() + (e === E ? t : 0),
91
- r.getDate() + (e === Y ? t : 0),
92
- r.getHours() + (e === S ? t : 0),
93
- r.getMinutes() + (e === H ? t : 0),
94
- r.getSeconds() + (e === X ? t : 0),
95
- r.getMilliseconds() + (e === W ? t : 0)
89
+ a.getFullYear() + (e === E ? t : 0),
90
+ a.getMonth() + (e === A ? t : 0),
91
+ a.getDate() + (e === S ? t : 0),
92
+ a.getHours() + (e === Y ? t : 0),
93
+ a.getMinutes() + (e === H ? t : 0),
94
+ a.getSeconds() + (e === X ? t : 0),
95
+ a.getMilliseconds() + (e === q ? t : 0)
96
96
  ];
97
97
  return new Date(...i);
98
98
  },
99
- start_of(r, t) {
99
+ start_of(a, t) {
100
100
  const e = {
101
- [A]: 6,
102
- [E]: 5,
103
- [Y]: 4,
104
- [S]: 3,
101
+ [E]: 6,
102
+ [A]: 5,
103
+ [S]: 4,
104
+ [Y]: 3,
105
105
  [H]: 2,
106
106
  [X]: 1,
107
- [W]: 0
107
+ [q]: 0
108
108
  };
109
109
  function i(n) {
110
- const o = e[t];
111
- return e[n] <= o;
110
+ const r = e[t];
111
+ return e[n] <= r;
112
112
  }
113
113
  const s = [
114
- r.getFullYear(),
115
- i(A) ? 0 : r.getMonth(),
116
- i(E) ? 1 : r.getDate(),
117
- i(Y) ? 0 : r.getHours(),
118
- i(S) ? 0 : r.getMinutes(),
119
- i(H) ? 0 : r.getSeconds(),
120
- i(X) ? 0 : r.getMilliseconds()
114
+ a.getFullYear(),
115
+ i(E) ? 0 : a.getMonth(),
116
+ i(A) ? 1 : a.getDate(),
117
+ i(S) ? 0 : a.getHours(),
118
+ i(Y) ? 0 : a.getMinutes(),
119
+ i(H) ? 0 : a.getSeconds(),
120
+ i(X) ? 0 : a.getMilliseconds()
121
121
  ];
122
122
  return new Date(...s);
123
123
  },
124
- clone(r) {
125
- return new Date(...this.get_date_values(r));
124
+ clone(a) {
125
+ return new Date(...this.get_date_values(a));
126
126
  },
127
- get_date_values(r) {
127
+ get_date_values(a) {
128
128
  return [
129
- r.getFullYear(),
130
- r.getMonth(),
131
- r.getDate(),
132
- r.getHours(),
133
- r.getMinutes(),
134
- r.getSeconds(),
135
- r.getMilliseconds()
129
+ a.getFullYear(),
130
+ a.getMonth(),
131
+ a.getDate(),
132
+ a.getHours(),
133
+ a.getMinutes(),
134
+ a.getSeconds(),
135
+ a.getMilliseconds()
136
136
  ];
137
137
  },
138
- convert_scales(r, t) {
138
+ convert_scales(a, t) {
139
139
  const e = {
140
140
  millisecond: 11574074074074074e-24,
141
141
  second: 11574074074074073e-21,
@@ -144,51 +144,51 @@ const A = "year", E = "month", Y = "day", S = "hour", H = "minute", X = "second"
144
144
  day: 1,
145
145
  month: 30,
146
146
  year: 365
147
- }, { duration: i, scale: s } = this.parse_duration(r);
147
+ }, { duration: i, scale: s } = this.parse_duration(a);
148
148
  return i * e[s] / e[t];
149
149
  },
150
- get_days_in_month(r) {
151
- const t = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], e = r.getMonth();
150
+ get_days_in_month(a) {
151
+ const t = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], e = a.getMonth();
152
152
  if (e !== 1)
153
153
  return t[e];
154
- const i = r.getFullYear();
154
+ const i = a.getFullYear();
155
155
  return i % 4 === 0 && i % 100 != 0 || i % 400 === 0 ? 29 : 28;
156
156
  },
157
- get_days_in_year(r) {
158
- return r.getFullYear() % 4 ? 365 : 366;
157
+ get_days_in_year(a) {
158
+ return a.getFullYear() % 4 ? 365 : 366;
159
159
  }
160
160
  };
161
- function L(r, t, e) {
162
- return r = r + "", t = t >> 0, e = String(typeof e < "u" ? e : " "), r.length > t ? String(r) : (t = t - r.length, t > e.length && (e += e.repeat(t / e.length)), e.slice(0, t) + String(r));
161
+ function L(a, t, e) {
162
+ return a = a + "", t = t >> 0, e = String(typeof e < "u" ? e : " "), a.length > t ? String(a) : (t = t - a.length, t > e.length && (e += e.repeat(t / e.length)), e.slice(0, t) + String(a));
163
163
  }
164
- function m(r, t) {
165
- return typeof r == "string" ? (t || document).querySelector(r) : r || null;
164
+ function m(a, t) {
165
+ return typeof a == "string" ? (t || document).querySelector(a) : a || null;
166
166
  }
167
- function w(r, t) {
168
- const e = document.createElementNS("http://www.w3.org/2000/svg", r);
167
+ function w(a, t) {
168
+ const e = document.createElementNS("http://www.w3.org/2000/svg", a);
169
169
  for (let i in t)
170
170
  i === "append_to" ? t.append_to.appendChild(e) : i === "innerHTML" ? e.innerHTML = t.innerHTML : i === "clipPath" ? e.setAttribute("clip-path", "url(#" + t[i] + ")") : e.setAttribute(i, t[i]);
171
171
  return e;
172
172
  }
173
- function z(r, t, e, i) {
174
- const s = B(r, t, e, i);
175
- if (s === r) {
173
+ function z(a, t, e, i) {
174
+ const s = B(a, t, e, i);
175
+ if (s === a) {
176
176
  const n = document.createEvent("HTMLEvents");
177
177
  n.initEvent("click", !0, !0), n.eventName = "click", s.dispatchEvent(n);
178
178
  }
179
179
  }
180
- function B(r, t, e, i, s = "0.4s", n = "0.1s") {
181
- const o = r.querySelector("animate");
182
- if (o)
183
- return m.attr(o, {
180
+ function B(a, t, e, i, s = "0.4s", n = "0.1s") {
181
+ const r = a.querySelector("animate");
182
+ if (r)
183
+ return m.attr(r, {
184
184
  attributeName: t,
185
185
  from: e,
186
186
  to: i,
187
187
  dur: s,
188
188
  begin: "click + " + n
189
189
  // artificial click
190
- }), r;
191
- const a = w("animate", {
190
+ }), a;
191
+ const o = w("animate", {
192
192
  attributeName: t,
193
193
  from: e,
194
194
  to: i,
@@ -199,134 +199,134 @@ function B(r, t, e, i, s = "0.4s", n = "0.1s") {
199
199
  keyTimes: "0; 1",
200
200
  keySplines: G("ease-out")
201
201
  });
202
- return r.appendChild(a), r;
202
+ return a.appendChild(o), a;
203
203
  }
204
- function G(r) {
204
+ function G(a) {
205
205
  return {
206
206
  ease: ".25 .1 .25 1",
207
207
  linear: "0 0 1 1",
208
208
  "ease-in": ".42 0 1 1",
209
209
  "ease-out": "0 0 .58 1",
210
210
  "ease-in-out": ".42 0 .58 1"
211
- }[r];
211
+ }[a];
212
212
  }
213
- m.on = (r, t, e, i) => {
214
- i ? m.delegate(r, t, e, i) : (i = e, m.bind(r, t, i));
213
+ m.on = (a, t, e, i) => {
214
+ i ? m.delegate(a, t, e, i) : (i = e, m.bind(a, t, i));
215
215
  };
216
- m.off = (r, t, e) => {
217
- r.removeEventListener(t, e);
216
+ m.off = (a, t, e) => {
217
+ a.removeEventListener(t, e);
218
218
  };
219
- m.bind = (r, t, e) => {
219
+ m.bind = (a, t, e) => {
220
220
  t.split(/\s+/).forEach(function(i) {
221
- r.addEventListener(i, e);
221
+ a.addEventListener(i, e);
222
222
  });
223
223
  };
224
- m.delegate = (r, t, e, i) => {
225
- r.addEventListener(t, function(s) {
224
+ m.delegate = (a, t, e, i) => {
225
+ a.addEventListener(t, function(s) {
226
226
  const n = s.target.closest(e);
227
227
  n && (s.delegatedTarget = n, i.call(this, s, n));
228
228
  });
229
229
  };
230
- m.closest = (r, t) => t ? t.matches(r) ? t : m.closest(r, t.parentNode) : null;
231
- m.attr = (r, t, e) => {
230
+ m.closest = (a, t) => t ? t.matches(a) ? t : m.closest(a, t.parentNode) : null;
231
+ m.attr = (a, t, e) => {
232
232
  if (!e && typeof t == "string")
233
- return r.getAttribute(t);
233
+ return a.getAttribute(t);
234
234
  if (typeof t == "object") {
235
235
  for (let i in t)
236
- m.attr(r, i, t[i]);
236
+ m.attr(a, i, t[i]);
237
237
  return;
238
238
  }
239
- r.setAttribute(t, e);
239
+ a.setAttribute(t, e);
240
240
  };
241
- function I(r, t, e, i, s = "downstream") {
241
+ function I(a, t, e, i, s = "downstream") {
242
242
  if (i === "none" || e === 0) return /* @__PURE__ */ new Map();
243
243
  ["upstream", "downstream", "both"].includes(s) || (console.warn(`[frappe-gantt] compute_dependency_shifts: unknown direction "${s}", falling back to "downstream"`), s = "downstream");
244
- const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map();
245
- for (const h of r)
246
- h._has_no_dates || (n.set(h.id, h), o.set(h.id, []), a.set(h.id, []));
247
- for (const h of r)
244
+ const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
245
+ for (const h of a)
246
+ h._has_no_dates || (n.set(h.id, h), r.set(h.id, []), o.set(h.id, []));
247
+ for (const h of a)
248
248
  if (!h._has_no_dates)
249
- for (const d of h.dependencies || []) {
250
- if (!n.has(d.id)) continue;
251
- const _ = d.type || "finish-to-start";
252
- o.get(h.id).push({ id: d.id, type: _ }), a.get(d.id).push({ id: h.id, type: _ });
249
+ for (const _ of h.dependencies || []) {
250
+ if (!n.has(_.id)) continue;
251
+ const d = _.type || "finish-to-start";
252
+ r.get(h.id).push({ id: _.id, type: d }), o.get(_.id).push({ id: h.id, type: d });
253
253
  }
254
- return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? q(t, e, o, a, s === "both", s === "upstream") : i === "consume_buffer" ? R(t, e, n, o, a, s) : /* @__PURE__ */ new Map();
254
+ return i === "maintain_buffer_all" || i === "maintain_buffer_downstream" ? W(t, e, r, o, s === "both", s === "upstream") : i === "consume_buffer" ? R(t, e, n, r, o, s) : /* @__PURE__ */ new Map();
255
255
  }
256
- function q(r, t, e, i, s, n) {
257
- const o = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set([r]), h = [], d = (_) => {
258
- for (const { id: c } of _)
259
- a.has(c) || (a.add(c), h.push(c));
256
+ function W(a, t, e, i, s, n) {
257
+ const r = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([a]), h = [], _ = (d) => {
258
+ for (const { id: l } of d)
259
+ o.has(l) || (o.add(l), h.push(l));
260
260
  };
261
- for (n && !s ? d(e.get(r) || []) : (d(i.get(r) || []), s && d(e.get(r) || [])); h.length > 0; ) {
262
- const _ = h.shift();
263
- o.set(_, t), n && !s ? d(e.get(_) || []) : (d(i.get(_) || []), s && d(e.get(_) || []));
261
+ for (n && !s ? _(e.get(a) || []) : (_(i.get(a) || []), s && _(e.get(a) || [])); h.length > 0; ) {
262
+ const d = h.shift();
263
+ r.set(d, t), n && !s ? _(e.get(d) || []) : (_(i.get(d) || []), s && _(e.get(d) || []));
264
264
  }
265
- return o;
265
+ return r;
266
266
  }
267
- function R(r, t, e, i, s, n) {
268
- const o = /* @__PURE__ */ new Map();
269
- for (const [l] of e)
270
- o.set(l, (i.get(l) || []).length);
271
- const a = [], h = [];
272
- for (const [l, f] of o)
273
- f === 0 && h.push(l);
267
+ function R(a, t, e, i, s, n) {
268
+ const r = /* @__PURE__ */ new Map();
269
+ for (const [c] of e)
270
+ r.set(c, (i.get(c) || []).length);
271
+ const o = [], h = [];
272
+ for (const [c, f] of r)
273
+ f === 0 && h.push(c);
274
274
  for (; h.length > 0; ) {
275
- const l = h.shift();
276
- a.push(l);
277
- for (const { id: f } of s.get(l) || []) {
278
- const u = o.get(f) - 1;
279
- o.set(f, u), u === 0 && h.push(f);
275
+ const c = h.shift();
276
+ o.push(c);
277
+ for (const { id: f } of s.get(c) || []) {
278
+ const u = r.get(f) - 1;
279
+ r.set(f, u), u === 0 && h.push(f);
280
280
  }
281
281
  }
282
- const d = /* @__PURE__ */ new Map([[r, 0]]), _ = (l) => e.get(l)._start.getTime() + (d.get(l) || 0), c = (l) => e.get(l)._end.getTime() + (d.get(l) || 0);
282
+ const _ = /* @__PURE__ */ new Map([[a, 0]]), d = (c) => e.get(c)._start.getTime() + (_.get(c) || 0), l = (c) => e.get(c)._end.getTime() + (_.get(c) || 0);
283
283
  if (n === "downstream" || n === "both")
284
- for (const l of a) {
285
- if (l === r) continue;
284
+ for (const c of o) {
285
+ if (c === a) continue;
286
286
  let f = 0;
287
- for (const { id: u, type: b } of i.get(l) || []) {
288
- const y = F(u, l, b, _, c);
287
+ for (const { id: u, type: b } of i.get(c) || []) {
288
+ const y = F(u, c, b, d, l);
289
289
  y > f && (f = y);
290
290
  }
291
- f > 0 && d.set(l, (d.get(l) || 0) + f);
291
+ f > 0 && _.set(c, (_.get(c) || 0) + f);
292
292
  }
293
293
  if (n === "upstream" || n === "both")
294
- for (let l = a.length - 1; l >= 0; l--) {
295
- const f = a[l];
296
- if (f === r) continue;
294
+ for (let c = o.length - 1; c >= 0; c--) {
295
+ const f = o[c];
296
+ if (f === a) continue;
297
297
  let u = 0;
298
298
  for (const { id: b, type: y } of s.get(f) || []) {
299
- const k = F(f, b, y, _, c);
300
- if (k > 0) {
301
- const $ = -k;
299
+ const v = F(f, b, y, d, l);
300
+ if (v > 0) {
301
+ const $ = -v;
302
302
  $ < u && (u = $);
303
303
  }
304
304
  }
305
- u < 0 && d.set(f, (d.get(f) || 0) + u);
305
+ u < 0 && _.set(f, (_.get(f) || 0) + u);
306
306
  }
307
- const p = /* @__PURE__ */ new Map();
308
- for (const [l, f] of d)
309
- l !== r && f !== 0 && p.set(l, f);
310
- return p;
307
+ const g = /* @__PURE__ */ new Map();
308
+ for (const [c, f] of _)
309
+ c !== a && f !== 0 && g.set(c, f);
310
+ return g;
311
311
  }
312
- function F(r, t, e, i, s) {
313
- const n = i(r), o = s(r), a = i(t), h = s(t);
312
+ function F(a, t, e, i, s) {
313
+ const n = i(a), r = s(a), o = i(t), h = s(t);
314
314
  switch (e) {
315
315
  case "finish-to-start":
316
- return o > a ? o - a : 0;
316
+ return r > o ? r - o : 0;
317
317
  case "start-to-start":
318
- return n > a ? n - a : 0;
318
+ return n > o ? n - o : 0;
319
319
  case "finish-to-finish":
320
- return o > h ? o - h : 0;
320
+ return r > h ? r - h : 0;
321
321
  case "start-to-finish":
322
322
  return n > h ? n - h : 0;
323
323
  default:
324
- return o > a ? o - a : 0;
324
+ return r > o ? r - o : 0;
325
325
  }
326
326
  }
327
327
  class U {
328
328
  constructor(t, e, i, s) {
329
- this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type = s, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.is_hovered = !1, this.calculate_path(), this.draw();
329
+ this.gantt = t, this.from_task = e, this.to_task = i, this.dependency_type = s, this.is_critical = this.check_critical_path(), this.is_invalid = this.check_invalid_dependency(), this.is_hovered = !1, this.is_active = !1, this.calculate_path(), this.draw();
330
330
  }
331
331
  check_critical_path() {
332
332
  return this.gantt.options.critical_path ? this.from_task.task._is_critical === !0 && this.to_task.task._is_critical === !0 : !1;
@@ -346,125 +346,125 @@ class U {
346
346
  return !1;
347
347
  }
348
348
  calculate_path() {
349
- const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve, s = t.padding, n = this.from_task.$bar.getX() + this.from_task.$bar.getWidth(), o = this.from_task.$bar.getX(), a = this.to_task.$bar.getX() + this.to_task.$bar.getWidth(), h = this.to_task.$bar.getX(), d = (l) => e.header_height + t.bar_height / 2 + (t.padding + t.bar_height) * l.task._index + t.padding / 2, _ = d(this.from_task), c = d(this.to_task), p = (_ + c) / 2;
349
+ const t = this.gantt.options, e = this.gantt.config, i = t.arrow_curve, s = t.padding, n = this.from_task.$bar.getX() + this.from_task.$bar.getWidth(), r = this.from_task.$bar.getX(), o = this.to_task.$bar.getX() + this.to_task.$bar.getWidth(), h = this.to_task.$bar.getX(), _ = (c) => e.header_height + t.bar_height / 2 + (t.padding + t.bar_height) * c.task._index + t.padding / 2, d = _(this.from_task), l = _(this.to_task), g = (d + l) / 2;
350
350
  switch (this.dependency_type) {
351
351
  case "finish-to-start":
352
352
  this.path = this._path_finish_to_start(
353
353
  n,
354
+ r,
354
355
  o,
355
- a,
356
356
  h,
357
- _,
358
- c,
359
- p,
357
+ d,
358
+ l,
359
+ g,
360
360
  s,
361
361
  i
362
- );
362
+ ), this.label_pos = { x: h, y: l, side: "left" };
363
363
  break;
364
364
  case "start-to-start":
365
365
  this.path = this._path_start_to_start(
366
- o,
366
+ r,
367
367
  h,
368
- _,
369
- c,
368
+ d,
369
+ l,
370
370
  s,
371
371
  i
372
- );
372
+ ), this.label_pos = { x: h, y: l, side: "left" };
373
373
  break;
374
374
  case "finish-to-finish":
375
375
  this.path = this._path_finish_to_finish(
376
376
  n,
377
- a,
378
- _,
379
- c,
377
+ o,
378
+ d,
379
+ l,
380
380
  s,
381
381
  i
382
- );
382
+ ), this.label_pos = { x: o, y: l, side: "right" };
383
383
  break;
384
384
  case "start-to-finish":
385
385
  this.path = this._path_start_to_finish(
386
+ r,
386
387
  o,
387
- a,
388
- _,
389
- c,
390
- p,
388
+ d,
389
+ l,
390
+ g,
391
391
  s,
392
392
  i
393
- );
393
+ ), this.label_pos = { x: o, y: l, side: "right" };
394
394
  break;
395
395
  default:
396
396
  this.path = this._path_finish_to_start(
397
397
  n,
398
+ r,
398
399
  o,
399
- a,
400
400
  h,
401
- _,
402
- c,
403
- p,
401
+ d,
402
+ l,
403
+ g,
404
404
  s,
405
405
  i
406
- );
406
+ ), this.label_pos = { x: h, y: l, side: "left" };
407
407
  }
408
408
  }
409
- _path_finish_to_start(t, e, i, s, n, o, a, h, d) {
410
- const _ = t + h;
411
- if (_ < s)
409
+ _path_finish_to_start(t, e, i, s, n, r, o, h, _) {
410
+ const d = t + h;
411
+ if (d < s)
412
412
  return `
413
413
  M ${t} ${n}
414
- H ${_ - d}
415
- a ${d} ${d} 0 0 1 ${d} ${d}
416
- V ${o - d}
417
- a ${d} ${d} 0 0 0 ${d} ${d}
414
+ H ${d - _}
415
+ a ${_} ${_} 0 0 1 ${_} ${_}
416
+ V ${r - _}
417
+ a ${_} ${_} 0 0 0 ${_} ${_}
418
418
  H ${s}
419
419
  m -5 -5 l 5 5 l -5 5`;
420
- const c = s - h;
420
+ const l = s - h;
421
421
  return `
422
422
  M ${t} ${n}
423
- H ${_ - d}
424
- a ${d} ${d} 0 0 1 ${d} ${d}
425
- V ${a - d}
426
- a ${d} ${d} 0 0 1 ${-d} ${d}
427
- H ${c + d}
428
- a ${d} ${d} 0 0 0 ${-d} ${d}
429
- V ${o - d}
430
- a ${d} ${d} 0 0 0 ${d} ${d}
423
+ H ${d - _}
424
+ a ${_} ${_} 0 0 1 ${_} ${_}
425
+ V ${o - _}
426
+ a ${_} ${_} 0 0 1 ${-_} ${_}
427
+ H ${l + _}
428
+ a ${_} ${_} 0 0 0 ${-_} ${_}
429
+ V ${r - _}
430
+ a ${_} ${_} 0 0 0 ${_} ${_}
431
431
  H ${s}
432
432
  m -5 -5 l 5 5 l -5 5`;
433
433
  }
434
- _path_start_to_start(t, e, i, s, n, o) {
435
- const a = Math.min(t, e) - n;
434
+ _path_start_to_start(t, e, i, s, n, r) {
435
+ const o = Math.min(t, e) - n;
436
436
  return `
437
437
  M ${t} ${i}
438
- H ${a + o}
439
- a ${o} ${o} 0 0 0 ${-o} ${o}
440
- V ${s - o}
441
- a ${o} ${o} 0 0 0 ${o} ${o}
438
+ H ${o + r}
439
+ a ${r} ${r} 0 0 0 ${-r} ${r}
440
+ V ${s - r}
441
+ a ${r} ${r} 0 0 0 ${r} ${r}
442
442
  H ${e}
443
443
  m -5 -5 l 5 5 l -5 5`;
444
444
  }
445
- _path_finish_to_finish(t, e, i, s, n, o) {
446
- const a = Math.max(t, e) + n;
445
+ _path_finish_to_finish(t, e, i, s, n, r) {
446
+ const o = Math.max(t, e) + n;
447
447
  return `
448
448
  M ${t} ${i}
449
- H ${a - o}
450
- a ${o} ${o} 0 0 1 ${o} ${o}
451
- V ${s - o}
452
- a ${o} ${o} 0 0 1 ${-o} ${o}
449
+ H ${o - r}
450
+ a ${r} ${r} 0 0 1 ${r} ${r}
451
+ V ${s - r}
452
+ a ${r} ${r} 0 0 1 ${-r} ${r}
453
453
  H ${e}
454
454
  m 5 -5 l -5 5 l 5 5`;
455
455
  }
456
- _path_start_to_finish(t, e, i, s, n, o, a) {
457
- const h = t - o, d = e + o;
456
+ _path_start_to_finish(t, e, i, s, n, r, o) {
457
+ const h = t - r, _ = e + r;
458
458
  return `
459
459
  M ${t} ${i}
460
- H ${h + a}
461
- a ${a} ${a} 0 0 0 ${-a} ${a}
462
- V ${n - a}
463
- a ${a} ${a} 0 0 0 ${a} ${a}
464
- H ${d - a}
465
- a ${a} ${a} 0 0 1 ${a} ${a}
466
- V ${s - a}
467
- a ${a} ${a} 0 0 1 ${-a} ${a}
460
+ H ${h + o}
461
+ a ${o} ${o} 0 0 0 ${-o} ${o}
462
+ V ${n - o}
463
+ a ${o} ${o} 0 0 0 ${o} ${o}
464
+ H ${_ - o}
465
+ a ${o} ${o} 0 0 1 ${o} ${o}
466
+ V ${s - o}
467
+ a ${o} ${o} 0 0 1 ${-o} ${o}
468
468
  H ${e}
469
469
  m 5 -5 l -5 5 l 5 5`;
470
470
  }
@@ -495,18 +495,69 @@ class U {
495
495
  this._get_connected_bars().forEach((i) => {
496
496
  const s = i.querySelector(".bar");
497
497
  s && s.classList.add(e);
498
- });
498
+ }), this._show_label();
499
499
  }), this.hit_element.addEventListener("mouseleave", () => {
500
500
  this.is_hovered = !1, this.element.classList.remove("arrow-hover"), this._get_connected_bars().forEach((e) => {
501
501
  const i = e.querySelector(".bar");
502
- i && i.classList.remove("bar-arrow-hover", "bar-arrow-critical", "bar-arrow-invalid");
503
- });
502
+ i && (i.classList.remove("bar-arrow-hover"), this.is_active || i.classList.remove("bar-arrow-critical", "bar-arrow-invalid"));
503
+ }), !this.is_active && !this.is_hovered && this._hide_label();
504
+ }), this.hit_element.addEventListener("click", (e) => {
505
+ e.stopPropagation(), this.is_active ? this.gantt.set_active_arrow(null) : this.gantt.set_active_arrow(this);
506
+ });
507
+ }
508
+ _get_type_abbr() {
509
+ return {
510
+ "finish-to-start": "FS",
511
+ "start-to-start": "SS",
512
+ "finish-to-finish": "FF",
513
+ "start-to-finish": "SF"
514
+ }[this.dependency_type] || "FS";
515
+ }
516
+ _show_label() {
517
+ if (this.label_element) return;
518
+ const t = this._get_type_abbr(), e = 21, i = 20, { x: s, y: n, side: r } = this.label_pos, o = r === "left" ? s - 10 - e / 2 : s + 10 + e / 2, h = n;
519
+ this.label_element = w("g", { class: "arrow-type-label" });
520
+ const _ = w("rect", {
521
+ x: o - e / 2,
522
+ y: h - i / 2,
523
+ width: e,
524
+ height: i,
525
+ rx: 3
526
+ }), d = w("text", {
527
+ x: o,
528
+ y: h,
529
+ "dominant-baseline": "middle",
530
+ "text-anchor": "middle"
531
+ });
532
+ d.textContent = t, this.label_element.appendChild(_), this.label_element.appendChild(d), this.label_element.addEventListener("mouseenter", () => {
533
+ this.hit_element.dispatchEvent(new MouseEvent("mouseenter", { bubbles: !1 }));
534
+ }), this.label_element.addEventListener("mouseleave", () => {
535
+ this.hit_element.dispatchEvent(new MouseEvent("mouseleave", { bubbles: !1 }));
536
+ }), this.label_element.addEventListener("click", (l) => {
537
+ l.stopPropagation(), this.hit_element.dispatchEvent(new MouseEvent("click", { bubbles: !1 }));
538
+ }), this.gantt.layers.arrow.appendChild(this.label_element);
539
+ }
540
+ _hide_label() {
541
+ this.label_element && (this.label_element.remove(), this.label_element = null);
542
+ }
543
+ activate() {
544
+ this.is_active = !0, this.element.classList.add("arrow-active"), this._show_label();
545
+ const t = this.is_invalid ? "bar-arrow-invalid" : this.is_critical ? "bar-arrow-critical" : "bar-arrow-active";
546
+ this._get_connected_bars().forEach((e) => {
547
+ const i = e.querySelector(".bar");
548
+ i && i.classList.add(t);
549
+ });
550
+ }
551
+ deactivate() {
552
+ this.is_active = !1, this.element.classList.remove("arrow-active"), this._hide_label(), this._get_connected_bars().forEach((t) => {
553
+ const e = t.querySelector(".bar");
554
+ e && e.classList.remove("bar-arrow-active", "bar-arrow-critical", "bar-arrow-invalid");
504
555
  });
505
556
  }
506
557
  update() {
507
558
  this.calculate_path(), this.element.setAttribute("d", this.path), this.hit_element.setAttribute("d", this.path), this.is_invalid = this.check_invalid_dependency();
508
559
  let t = "";
509
- this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.is_hovered && (t += " arrow-hover"), this.element.setAttribute("class", t.trim());
560
+ this.is_invalid ? t = "arrow-invalid" : this.is_critical && (t = "arrow-critical"), this.is_hovered && (t += " arrow-hover"), this.is_active && (t += " arrow-active"), this.element.setAttribute("class", t.trim());
510
561
  }
511
562
  }
512
563
  class Q {
@@ -596,7 +647,7 @@ class Q {
596
647
  class: "bar-progress",
597
648
  append_to: this.bar_group
598
649
  }), this.task.color_progress && (this.$bar_progress.style.fill = this.task.color_progress);
599
- const e = g.diff(
650
+ const e = p.diff(
600
651
  this.task._start,
601
652
  this.gantt.gantt_start,
602
653
  this.gantt.config.unit
@@ -610,15 +661,15 @@ class Q {
610
661
  this.$date_highlight = i, this.gantt.$lower_header.prepend(this.$date_highlight), z(this.$bar_progress, "width", 0, this.progress_width);
611
662
  }
612
663
  calculate_progress_width() {
613
- 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;
664
+ const t = this.$bar.getWidth(), e = this.x + t, i = this.gantt.config.ignored_positions.reduce((h, _) => h + (_ >= this.x && _ < e), 0) * this.gantt.config.column_width;
614
665
  let s = (t - i) * this.task.progress / 100;
615
- 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;
616
- s += o;
617
- let a = this.gantt.get_ignored_region(
666
+ const n = this.x + s, r = this.gantt.config.ignored_positions.reduce((h, _) => h + (_ >= this.x && _ < n), 0) * this.gantt.config.column_width;
667
+ s += r;
668
+ let o = this.gantt.get_ignored_region(
618
669
  this.x + s
619
670
  );
620
- for (; a.length; )
621
- s += this.gantt.config.column_width, a = this.gantt.get_ignored_region(
671
+ for (; o.length; )
672
+ s += this.gantt.config.column_width, o = this.gantt.get_ignored_region(
622
673
  this.x + s
623
674
  );
624
675
  return this.progress_width = s, s;
@@ -759,89 +810,89 @@ class Q {
759
810
  setup_click_event() {
760
811
  this.event_listeners = [];
761
812
  let t = this.task.id;
762
- const e = (p) => {
813
+ const e = (g) => {
763
814
  this.gantt.trigger_event("hover", [
764
815
  this.task,
765
- p.screenX,
766
- p.screenY,
767
- p
816
+ g.screenX,
817
+ g.screenY,
818
+ g
768
819
  ]);
769
820
  };
770
821
  if (m.on(this.group, "mouseover", e), this.event_listeners.push({ event: "mouseover", handler: e }), this.gantt.options.popup_on === "click") {
771
- const p = (l) => {
772
- const f = l.offsetX || l.layerX;
822
+ const g = (c) => {
823
+ const f = c.offsetX || c.layerX;
773
824
  if (this.$handle_progress) {
774
825
  const u = +this.$handle_progress.getAttribute("cx");
775
826
  if (u > f - 1 && u < f + 1 || this.gantt.bar_being_dragged) return;
776
827
  }
777
828
  this.gantt.show_popup({
778
- x: l.offsetX || l.layerX,
779
- y: l.offsetY || l.layerY,
829
+ x: c.offsetX || c.layerX,
830
+ y: c.offsetY || c.layerY,
780
831
  task: this.task,
781
832
  target: this.$bar
782
833
  });
783
834
  };
784
- m.on(this.group, "click", p), this.event_listeners.push({ event: "click", handler: p });
835
+ m.on(this.group, "click", g), this.event_listeners.push({ event: "click", handler: g });
785
836
  }
786
837
  let i;
787
- const s = (p) => {
838
+ const s = (g) => {
788
839
  i = setTimeout(() => {
789
840
  this.gantt.options.popup_on === "hover" && this.gantt.show_popup({
790
- x: p.offsetX || p.layerX,
791
- y: p.offsetY || p.layerY,
841
+ x: g.offsetX || g.layerX,
842
+ y: g.offsetY || g.layerY,
792
843
  task: this.task,
793
844
  target: this.$bar
794
845
  });
795
- const l = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
796
- l && l.classList.remove("hide");
846
+ const c = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
847
+ c && c.classList.remove("hide");
797
848
  }, 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"));
798
849
  };
799
850
  m.on(this.group, "mouseenter", s), this.event_listeners.push({ event: "mouseenter", handler: s });
800
851
  const n = () => {
801
- var l, f;
802
- clearTimeout(i), this.gantt.options.popup_on === "hover" && ((f = (l = this.gantt.popup) == null ? void 0 : l.hide) == null || f.call(l));
803
- const p = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
804
- p && p.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(() => {
852
+ var c, f;
853
+ clearTimeout(i), this.gantt.options.popup_on === "hover" && ((f = (c = this.gantt.popup) == null ? void 0 : c.hide) == null || f.call(c));
854
+ const g = this.gantt.$container.querySelector(`.highlight-${CSS.escape(t)}`);
855
+ g && g.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(() => {
805
856
  this.is_hovering_icon || this.$add_icon_group.classList.add("hide");
806
857
  }, 200));
807
858
  };
808
859
  m.on(this.group, "mouseleave", n), this.event_listeners.push({ event: "mouseleave", handler: n });
809
- const o = () => {
860
+ const r = () => {
810
861
  this.is_dragging = !0, this.hide_add_icon();
811
862
  };
812
- m.on(this.group, "mousedown", o), this.event_listeners.push({ event: "mousedown", handler: o });
813
- const a = () => {
863
+ m.on(this.group, "mousedown", r), this.event_listeners.push({ event: "mousedown", handler: r });
864
+ const o = () => {
814
865
  setTimeout(() => {
815
866
  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"));
816
867
  }, 0);
817
868
  };
818
- m.on(this.group, "mouseup", a), this.event_listeners.push({ event: "mouseup", handler: a });
869
+ m.on(this.group, "mouseup", o), this.event_listeners.push({ event: "mouseup", handler: o });
819
870
  const h = () => {
820
871
  this.action_completed || this.gantt.bar_being_dragged || this.gantt.trigger_event("click", [this.task]);
821
872
  };
822
873
  m.on(this.group, "click", h), this.event_listeners.push({ event: "click", handler: h });
823
- const d = () => {
874
+ const _ = () => {
824
875
  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]));
825
876
  };
826
- m.on(this.group, "dblclick", d), this.event_listeners.push({ event: "dblclick", handler: d });
827
- let _ = !1;
828
- const c = (p) => {
829
- if (!_)
830
- return _ = !0, setTimeout(function() {
831
- _ = !1;
877
+ m.on(this.group, "dblclick", _), this.event_listeners.push({ event: "dblclick", handler: _ });
878
+ let d = !1;
879
+ const l = (g) => {
880
+ if (!d)
881
+ return d = !0, setTimeout(function() {
882
+ d = !1;
832
883
  }, 300), !1;
833
- p.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]));
884
+ 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]));
834
885
  };
835
- m.on(this.group, "touchstart", c), this.event_listeners.push({ event: "touchstart", handler: c });
886
+ m.on(this.group, "touchstart", l), this.event_listeners.push({ event: "touchstart", handler: l });
836
887
  }
837
888
  update_bar_position({ x: t = null, width: e = null }) {
838
889
  const i = this.$bar;
839
890
  t && (this.update_attr(i, "x", t), this.x = t, this.$date_highlight.style.left = t + "px"), e > 0 && (this.update_attr(i, "width", e), this.$date_highlight.style.width = e + "px"), this.update_label_position(), this.update_handle_position(), this.update_add_icon_position(), this.date_changed(), this.compute_duration(), this.gantt.options.show_expected_progress && this.update_expected_progressbar_position(), this.update_progressbar_position(), this.update_arrow_position();
840
891
  }
841
892
  update_label_position_on_horizontal_scroll({ x: t, sx: e }) {
842
- const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", o = this.bar_group.querySelector(".img_mask") || "";
843
- let a = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, d = n && n.getX() + t || 0, _ = n && n.getBBox().width + 7 || 7, c = h + s.getBBox().width + 7, p = e + i.clientWidth / 2;
844
- s.classList.contains("big") || (c < a && t > 0 && c < p || h - _ > this.$bar.getX() && t < 0 && c > p) && (s.setAttribute("x", h), n && (n.setAttribute("x", d), o.setAttribute("x", d)));
893
+ const i = this.gantt.$container, s = this.group.querySelector(".bar-label"), n = this.group.querySelector(".bar-img") || "", r = this.bar_group.querySelector(".img_mask") || "";
894
+ let o = this.$bar.getX() + this.$bar.getWidth(), h = s.getX() + t, _ = n && n.getX() + t || 0, d = n && n.getBBox().width + 7 || 7, l = h + s.getBBox().width + 7, g = e + i.clientWidth / 2;
895
+ s.classList.contains("big") || (l < o && t > 0 && l < g || h - d > this.$bar.getX() && t < 0 && l > g) && (s.setAttribute("x", h), n && (n.setAttribute("x", _), r.setAttribute("x", _)));
845
896
  }
846
897
  date_changed() {
847
898
  let t = !1;
@@ -849,7 +900,7 @@ class Q {
849
900
  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", [
850
901
  this.task,
851
902
  e,
852
- g.add(i, -1, "second")
903
+ p.add(i, -1, "second")
853
904
  ]);
854
905
  }
855
906
  progress_changed() {
@@ -863,12 +914,12 @@ class Q {
863
914
  }
864
915
  compute_start_end_date() {
865
916
  const t = this.$bar, e = t.getX() / this.gantt.config.column_width;
866
- let i = g.add(
917
+ let i = p.add(
867
918
  this.gantt.gantt_start,
868
919
  e * this.gantt.config.step,
869
920
  this.gantt.config.unit
870
921
  );
871
- const s = t.getWidth() / this.gantt.config.column_width, n = g.add(
922
+ const s = t.getWidth() / this.gantt.config.column_width, n = p.add(
872
923
  i,
873
924
  s * this.gantt.config.step,
874
925
  this.gantt.config.unit
@@ -883,11 +934,11 @@ class Q {
883
934
  return parseInt(e / i * 100, 10);
884
935
  }
885
936
  compute_expected_progress() {
886
- this.expected_progress = g.diff(g.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;
937
+ this.expected_progress = p.diff(p.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;
887
938
  }
888
939
  compute_x() {
889
940
  const { column_width: t } = this.gantt.config, e = this.task._start, i = this.gantt.gantt_start;
890
- let n = g.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
941
+ let n = p.diff(e, i, this.gantt.config.unit) / this.gantt.config.step * t;
891
942
  this.x = n;
892
943
  }
893
944
  compute_y() {
@@ -899,10 +950,10 @@ class Q {
899
950
  e++, !this.gantt.config.ignored_dates.find(
900
951
  (s) => s.getTime() === i.getTime()
901
952
  ) && (!this.gantt.config.ignored_function || !this.gantt.config.ignored_function(i)) && t++;
902
- this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = g.convert_scales(
953
+ this.task.actual_duration = t, this.task.ignored_duration = e - t, this.duration = p.convert_scales(
903
954
  e + "d",
904
955
  this.gantt.config.unit
905
- ) / this.gantt.config.step, this.actual_duration_raw = g.convert_scales(
956
+ ) / this.gantt.config.step, this.actual_duration_raw = p.convert_scales(
906
957
  t + "d",
907
958
  this.gantt.config.unit
908
959
  ) / this.gantt.config.step, this.ignored_duration_raw = this.duration - this.actual_duration_raw;
@@ -924,14 +975,14 @@ class Q {
924
975
  }
925
976
  update_label_position() {
926
977
  const t = this.bar_group.querySelector(".img_mask") || "", e = this.$bar, i = this.group.querySelector(".bar-label"), s = this.group.querySelector(".bar-img");
927
- let n = 5, o = this.image_size + 10;
928
- const a = i.getBBox().width, h = e.getWidth();
929
- 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(
978
+ let n = 5, r = this.image_size + 10;
979
+ const o = i.getBBox().width, h = e.getWidth();
980
+ o > h ? (i.classList.add("big"), s ? (s.setAttribute("x", e.getEndX() + n), t.setAttribute("x", e.getEndX() + n), i.setAttribute("x", e.getEndX() + r)) : 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(
930
981
  "x",
931
- e.getX() + h / 2 + o
982
+ e.getX() + h / 2 + r
932
983
  )) : i.setAttribute(
933
984
  "x",
934
- e.getX() + h / 2 - a / 2
985
+ e.getX() + h / 2 - o / 2
935
986
  ));
936
987
  }
937
988
  update_handle_position() {
@@ -981,18 +1032,18 @@ class K {
981
1032
  task: i,
982
1033
  chart: this.gantt,
983
1034
  get_title: () => this.title,
984
- set_title: (o) => this.title.innerHTML = o,
1035
+ set_title: (r) => this.title.innerHTML = r,
985
1036
  get_subtitle: () => this.subtitle,
986
- set_subtitle: (o) => this.subtitle.innerHTML = o,
1037
+ set_subtitle: (r) => this.subtitle.innerHTML = r,
987
1038
  get_details: () => this.details,
988
- set_details: (o) => this.details.innerHTML = o,
989
- add_action: (o, a) => {
1039
+ set_details: (r) => this.details.innerHTML = r,
1040
+ add_action: (r, o) => {
990
1041
  let h = this.gantt.create_el({
991
1042
  classes: "action-btn",
992
1043
  type: "button",
993
1044
  append_to: this.actions
994
1045
  });
995
- typeof o == "function" && (o = o(i)), h.innerHTML = o, h.onclick = (d) => a(i, this.gantt, d);
1046
+ typeof r == "function" && (r = r(i)), h.innerHTML = r, h.onclick = (_) => o(i, this.gantt, _);
996
1047
  }
997
1048
  });
998
1049
  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"));
@@ -1001,13 +1052,13 @@ class K {
1001
1052
  this.parent.classList.add("hide");
1002
1053
  }
1003
1054
  }
1004
- function C(r) {
1005
- const t = r.getFullYear();
1055
+ function C(a) {
1056
+ const t = a.getFullYear();
1006
1057
  return t - t % 10 + "";
1007
1058
  }
1008
- function J(r, t, e) {
1009
- let i = g.add(r, 6, "day"), s = i.getMonth() !== r.getMonth() ? "D MMM" : "D", n = !t || r.getMonth() !== t.getMonth() ? "D MMM" : "D";
1010
- return `${g.format(r, n, e)} - ${g.format(i, s, e)}`;
1059
+ function J(a, t, e) {
1060
+ let i = p.add(a, 6, "day"), s = i.getMonth() !== a.getMonth() ? "D MMM" : "D", n = !t || a.getMonth() !== t.getMonth() ? "D MMM" : "D";
1061
+ return `${p.format(a, n, e)} - ${p.format(i, s, e)}`;
1011
1062
  }
1012
1063
  const x = [
1013
1064
  {
@@ -1016,7 +1067,7 @@ const x = [
1016
1067
  step: "1h",
1017
1068
  date_format: "YYYY-MM-DD HH:",
1018
1069
  lower_text: "HH",
1019
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? g.format(r, "D MMMM", e) : "",
1070
+ upper_text: (a, t, e) => !t || a.getDate() !== t.getDate() ? p.format(a, "D MMMM", e) : "",
1020
1071
  upper_text_frequency: 24
1021
1072
  },
1022
1073
  {
@@ -1025,7 +1076,7 @@ const x = [
1025
1076
  step: "6h",
1026
1077
  date_format: "YYYY-MM-DD HH:",
1027
1078
  lower_text: "HH",
1028
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? g.format(r, "D MMM", e) : "",
1079
+ upper_text: (a, t, e) => !t || a.getDate() !== t.getDate() ? p.format(a, "D MMM", e) : "",
1029
1080
  upper_text_frequency: 4
1030
1081
  },
1031
1082
  {
@@ -1034,7 +1085,7 @@ const x = [
1034
1085
  step: "12h",
1035
1086
  date_format: "YYYY-MM-DD HH:",
1036
1087
  lower_text: "HH",
1037
- upper_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? r.getMonth() !== r.getMonth() ? g.format(r, "D MMM", e) : g.format(r, "D", e) : "",
1088
+ upper_text: (a, t, e) => !t || a.getDate() !== t.getDate() ? a.getMonth() !== a.getMonth() ? p.format(a, "D MMM", e) : p.format(a, "D", e) : "",
1038
1089
  upper_text_frequency: 2
1039
1090
  },
1040
1091
  {
@@ -1042,9 +1093,9 @@ const x = [
1042
1093
  padding: "7d",
1043
1094
  date_format: "YYYY-MM-DD",
1044
1095
  step: "1d",
1045
- lower_text: (r, t, e) => !t || r.getDate() !== t.getDate() ? g.format(r, "D", e) : "",
1046
- upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? g.format(r, "MMMM", e) : "",
1047
- thick_line: (r) => r.getDay() === 1
1096
+ lower_text: (a, t, e) => !t || a.getDate() !== t.getDate() ? p.format(a, "D", e) : "",
1097
+ upper_text: (a, t, e) => !t || a.getMonth() !== t.getMonth() ? p.format(a, "MMMM", e) : "",
1098
+ thick_line: (a) => a.getDay() === 1
1048
1099
  },
1049
1100
  {
1050
1101
  name: "Week",
@@ -1053,8 +1104,8 @@ const x = [
1053
1104
  date_format: "YYYY-MM-DD",
1054
1105
  column_width: 140,
1055
1106
  lower_text: J,
1056
- upper_text: (r, t, e) => !t || r.getMonth() !== t.getMonth() ? g.format(r, "MMMM", e) : "",
1057
- thick_line: (r) => r.getDate() >= 1 && r.getDate() <= 7,
1107
+ upper_text: (a, t, e) => !t || a.getMonth() !== t.getMonth() ? p.format(a, "MMMM", e) : "",
1108
+ thick_line: (a) => a.getDate() >= 1 && a.getDate() <= 7,
1058
1109
  upper_text_frequency: 4
1059
1110
  },
1060
1111
  {
@@ -1064,8 +1115,8 @@ const x = [
1064
1115
  column_width: 120,
1065
1116
  date_format: "YYYY-MM",
1066
1117
  lower_text: "MMMM",
1067
- upper_text: (r, t, e) => !t || r.getFullYear() !== t.getFullYear() ? g.format(r, "YYYY", e) : "",
1068
- thick_line: (r) => r.getMonth() % 3 === 0,
1118
+ upper_text: (a, t, e) => !t || a.getFullYear() !== t.getFullYear() ? p.format(a, "YYYY", e) : "",
1119
+ thick_line: (a) => a.getMonth() % 3 === 0,
1069
1120
  snap_at: "7d"
1070
1121
  },
1071
1122
  {
@@ -1074,7 +1125,7 @@ const x = [
1074
1125
  step: "1y",
1075
1126
  column_width: 120,
1076
1127
  date_format: "YYYY",
1077
- upper_text: (r, t, e) => !t || C(r) !== C(t) ? C(r) : "",
1128
+ upper_text: (a, t, e) => !t || C(a) !== C(t) ? C(a) : "",
1078
1129
  lower_text: "YYYY",
1079
1130
  snap_at: "30d"
1080
1131
  }
@@ -1100,19 +1151,19 @@ const x = [
1100
1151
  language: "en",
1101
1152
  lines: "both",
1102
1153
  padding: 18,
1103
- popup: (r) => {
1104
- r.set_title(r.task.name), r.task.description ? r.set_subtitle(r.task.description) : r.set_subtitle("");
1105
- const t = g.format(
1106
- r.task._start,
1154
+ popup: (a) => {
1155
+ a.set_title(a.task.name), a.task.description ? a.set_subtitle(a.task.description) : a.set_subtitle("");
1156
+ const t = p.format(
1157
+ a.task._start,
1107
1158
  "MMM D",
1108
- r.chart.options.language
1109
- ), e = g.format(
1110
- g.add(r.task._end, -1, "second"),
1159
+ a.chart.options.language
1160
+ ), e = p.format(
1161
+ p.add(a.task._end, -1, "second"),
1111
1162
  "MMM D",
1112
- r.chart.options.language
1163
+ a.chart.options.language
1113
1164
  );
1114
- r.set_details(
1115
- `${t} - ${e} (${r.task.actual_duration} days${r.task.ignored_duration ? " + " + r.task.ignored_duration + " excluded" : ""})<br/>Progress: ${Math.floor(r.task.progress * 100) / 100}%`
1165
+ a.set_details(
1166
+ `${t} - ${e} (${a.task.actual_duration} days${a.task.ignored_duration ? " + " + a.task.ignored_duration + " excluded" : ""})<br/>Progress: ${Math.floor(a.task.progress * 100) / 100}%`
1116
1167
  );
1117
1168
  },
1118
1169
  popup_on: "click",
@@ -1126,7 +1177,7 @@ const x = [
1126
1177
  view_mode: "Day",
1127
1178
  view_mode_select: !1,
1128
1179
  view_modes: x,
1129
- is_weekend: (r) => r.getDay() === 0 || r.getDay() === 6,
1180
+ is_weekend: (a) => a.getDay() === 0 || a.getDay() === 6,
1130
1181
  task_column: {
1131
1182
  enabled: !1,
1132
1183
  width: 200,
@@ -1178,7 +1229,7 @@ class tt {
1178
1229
  this.original_options = t, t != null && t.view_modes && (t.view_modes = t.view_modes.map((s) => {
1179
1230
  if (typeof s == "string") {
1180
1231
  const n = x.find(
1181
- (o) => o.name === s
1232
+ (r) => r.name === s
1182
1233
  );
1183
1234
  return n || console.error(
1184
1235
  `The view mode "${s}" is not predefined in Frappe Gantt. Please define the view mode object instead.`
@@ -1246,18 +1297,18 @@ class tt {
1246
1297
  return console.error(`task "${e.id}" doesn't have an end date`), !1;
1247
1298
  }
1248
1299
  if (!e._has_no_dates) {
1249
- if (e._start = g.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((h) => {
1250
- let { duration: d, scale: _ } = g.parse_duration(h);
1251
- e.end = g.add(e.end, d, _);
1252
- })), e._end = g.parse(e.end), g.diff(e._end, e._start, "year") < 0)
1300
+ if (e._start = p.parse(e.start), e.end === void 0 && e.duration !== void 0 && (e.end = e._start, e.duration.split(" ").forEach((h) => {
1301
+ let { duration: _, scale: d } = p.parse_duration(h);
1302
+ e.end = p.add(e.end, _, d);
1303
+ })), e._end = p.parse(e.end), p.diff(e._end, e._start, "year") < 0)
1253
1304
  return console.error(
1254
1305
  `start of task can't be after end of task: in task "${e.id}"`
1255
1306
  ), !1;
1256
- if (g.diff(e._end, e._start, "year") > 10)
1307
+ if (p.diff(e._end, e._start, "year") > 10)
1257
1308
  return console.error(
1258
1309
  `the duration of task "${e.id}" is too long (above ten years)`
1259
1310
  ), !1;
1260
- e._index = i, g.get_date_values(e._end).slice(3).every((a) => a === 0) && (e._end = g.add(e._end, 24, "hour"));
1311
+ e._index = i, p.get_date_values(e._end).slice(3).every((o) => o === 0) && (e._end = p.add(e._end, 24, "hour"));
1261
1312
  }
1262
1313
  return (typeof e.dependencies == "string" || Array.isArray(e.dependencies) && e.dependencies.some((n) => typeof n == "string")) && console.warn(`[frappe-gantt] Task "${e.id}": dependencies must be an array of {id, type?} objects. String format is no longer supported.`), Array.isArray(e.dependencies) || (e.dependencies = []), e.dependencies = e.dependencies.filter((n) => n && typeof n.id == "string").map((n) => ({ ...n, id: n.id.replaceAll(" ", "_") })), e.id ? typeof e.id == "string" ? e.id = e.id.replaceAll(" ", "_") : e.id = `${e.id}` : e.id = et(e), e;
1263
1314
  }).filter((e) => e).map((e, i) => (e._index = i, e)), this.setup_dependencies();
@@ -1272,9 +1323,9 @@ class tt {
1272
1323
  this.setup_tasks(t), this.change_view_mode(this.options.view_mode, e);
1273
1324
  }
1274
1325
  update_task(t, e) {
1275
- let i = this.tasks.find((o) => o.id === t), s = this.bars[i._index];
1326
+ let i = this.tasks.find((r) => r.id === t), s = this.bars[i._index];
1276
1327
  const n = e.dependencies !== void 0;
1277
- Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((o) => o && typeof o.id == "string").map((o) => ({ ...o, id: o.id.replaceAll(" ", "_") })), this.setup_dependencies(), this.layers.arrow.innerHTML = "", this.make_arrows(), this.map_arrows_on_bars()), s.refresh();
1328
+ Object.assign(i, e), n && (Array.isArray(i.dependencies) || (i.dependencies = []), i.dependencies = i.dependencies.filter((r) => r && typeof r.id == "string").map((r) => ({ ...r, id: r.id.replaceAll(" ", "_") })), this.setup_dependencies(), this.layers.arrow.innerHTML = "", this.make_arrows(), this.map_arrows_on_bars()), s.refresh();
1278
1329
  }
1279
1330
  change_view_mode(t = this.options.view_mode, e = !1) {
1280
1331
  typeof t == "string" && (t = this.options.view_modes.find((n) => n.name === t));
@@ -1282,7 +1333,7 @@ class tt {
1282
1333
  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]);
1283
1334
  }
1284
1335
  update_view_scale(t) {
1285
- let { duration: e, scale: i } = g.parse_duration(t.step);
1336
+ let { duration: e, scale: i } = p.parse_duration(t.step);
1286
1337
  this.config.step = e, this.config.unit = i, this.config.column_width = this.options.column_width || t.column_width || 45, this.$container.style.setProperty(
1287
1338
  "--gv-column-width",
1288
1339
  this.config.column_width + "px"
@@ -1296,13 +1347,13 @@ class tt {
1296
1347
  this.tasks.length || (e = /* @__PURE__ */ new Date(), i = /* @__PURE__ */ new Date());
1297
1348
  for (let s of this.tasks)
1298
1349
  (!e || s._start < e) && (e = s._start), (!i || s._end > i) && (i = s._end);
1299
- if (e = g.start_of(e, this.config.unit), i = g.start_of(i, this.config.unit), !t)
1350
+ if (e = p.start_of(e, this.config.unit), i = p.start_of(i, this.config.unit), !t)
1300
1351
  if (this.options.infinite_padding)
1301
- this.gantt_start = g.add(
1352
+ this.gantt_start = p.add(
1302
1353
  e,
1303
1354
  -this.config.extend_by_units * 3,
1304
1355
  this.config.unit
1305
- ), this.gantt_end = g.add(
1356
+ ), this.gantt_end = p.add(
1306
1357
  i,
1307
1358
  this.config.extend_by_units * 3,
1308
1359
  this.config.unit
@@ -1313,13 +1364,13 @@ class tt {
1313
1364
  this.config.view_mode.padding
1314
1365
  ]);
1315
1366
  let [s, n] = this.config.view_mode.padding.map(
1316
- g.parse_duration
1367
+ p.parse_duration
1317
1368
  );
1318
- this.gantt_start = g.add(
1369
+ this.gantt_start = p.add(
1319
1370
  e,
1320
1371
  -s.duration,
1321
1372
  s.scale
1322
- ), this.gantt_end = g.add(
1373
+ ), this.gantt_end = p.add(
1323
1374
  i,
1324
1375
  n.duration,
1325
1376
  n.scale
@@ -1330,7 +1381,7 @@ class tt {
1330
1381
  setup_date_values() {
1331
1382
  let t = this.gantt_start;
1332
1383
  for (this.dates = [t]; t < this.gantt_end; )
1333
- t = g.add(
1384
+ t = p.add(
1334
1385
  t,
1335
1386
  this.config.step,
1336
1387
  this.config.unit
@@ -1431,12 +1482,12 @@ class tt {
1431
1482
  }
1432
1483
  }
1433
1484
  make_task_column() {
1434
- var i, s, n, o, a, h, d, _, c, p;
1485
+ var i, s, n, r, o, h, _, d, l, g;
1435
1486
  if ((i = this.$task_column) == null || i.remove(), !((s = this.options.task_column) != null && s.enabled)) {
1436
- (o = (n = this.$wrapper) == null ? void 0 : n.classList) == null || o.remove("has-task-column");
1487
+ (r = (n = this.$wrapper) == null ? void 0 : n.classList) == null || r.remove("has-task-column");
1437
1488
  return;
1438
1489
  }
1439
- (h = (a = this.$wrapper) == null ? void 0 : a.classList) == null || h.add("has-task-column"), this.$task_column = this.create_el({
1490
+ (h = (o = this.$wrapper) == null ? void 0 : o.classList) == null || h.add("has-task-column"), this.$task_column = this.create_el({
1440
1491
  classes: "task-column",
1441
1492
  append_to: this.$wrapper
1442
1493
  }), this.$wrapper.insertBefore(this.$task_column, this.$container), this.$task_column_header = this.create_el({
@@ -1456,21 +1507,21 @@ class tt {
1456
1507
  ), this.$container.style.setProperty(
1457
1508
  "--gv-task-column-content-height",
1458
1509
  e + "px"
1459
- ), this.tasks.forEach((l) => {
1510
+ ), this.tasks.forEach((c) => {
1460
1511
  const f = this.options.bar_height + this.options.padding, u = this.create_el({
1461
1512
  classes: "task-row",
1462
1513
  append_to: this.$task_column_content
1463
1514
  });
1464
- if (u.style.top = l._index * f - 1 + "px", u.style.height = f + "px", this.options.task_column.content && typeof this.options.task_column.content == "function") {
1465
- const b = this.options.task_column.content(l);
1515
+ if (u.style.top = c._index * f - 1 + "px", u.style.height = f + "px", this.options.task_column.content && typeof this.options.task_column.content == "function") {
1516
+ const b = this.options.task_column.content(c);
1466
1517
  typeof b == "string" ? u.innerHTML = b : b instanceof HTMLElement && u.appendChild(b);
1467
1518
  } else
1468
- u.textContent = l.name, u.title = l.name;
1469
- u.setAttribute("data-task-id", l.id);
1519
+ u.textContent = c.name, u.title = c.name;
1520
+ u.setAttribute("data-task-id", c.id);
1470
1521
  }), this.$task_column.style.width = this.options.task_column.width + "px", this.$task_column_resize_handle = this.create_el({
1471
1522
  classes: "task-column-resize-handle",
1472
1523
  append_to: this.$task_column
1473
- }), this.options.isRTL ? (_ = (d = this.$wrapper) == null ? void 0 : d.classList) == null || _.add("rtl") : (p = (c = this.$wrapper) == null ? void 0 : c.classList) == null || p.remove("rtl");
1524
+ }), this.options.isRTL ? (d = (_ = this.$wrapper) == null ? void 0 : _.classList) == null || d.add("rtl") : (g = (l = this.$wrapper) == null ? void 0 : l.classList) == null || g.remove("rtl");
1474
1525
  }
1475
1526
  make_grid_ticks() {
1476
1527
  if (this.options.lines === "none") return;
@@ -1478,25 +1529,25 @@ class tt {
1478
1529
  class: "lines_layer",
1479
1530
  append_to: this.layers.grid
1480
1531
  }), n = this.config.header_height;
1481
- const o = this.dates.length * this.config.column_width, a = this.options.bar_height + this.options.padding;
1532
+ const r = this.dates.length * this.config.column_width, o = this.options.bar_height + this.options.padding;
1482
1533
  if (this.options.lines !== "vertical")
1483
- for (let h = this.config.header_height; h < this.grid_height; h += a)
1534
+ for (let h = this.config.header_height; h < this.grid_height; h += o)
1484
1535
  w("line", {
1485
1536
  x1: 0,
1486
- y1: n + a,
1487
- x2: o,
1488
- y2: n + a,
1537
+ y1: n + o,
1538
+ x2: r,
1539
+ y2: n + o,
1489
1540
  class: "row-line",
1490
1541
  append_to: s
1491
- }), n += a;
1542
+ }), n += o;
1492
1543
  if (this.options.lines !== "horizontal")
1493
1544
  for (let h of this.dates) {
1494
- let d = "tick";
1495
- this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (d += " thick"), w("path", {
1545
+ let _ = "tick";
1546
+ this.config.view_mode.thick_line && this.config.view_mode.thick_line(h) && (_ += " thick"), w("path", {
1496
1547
  d: `M ${t} ${e} v ${i}`,
1497
- class: d,
1548
+ class: _,
1498
1549
  append_to: this.layers.grid
1499
- }), this.view_is("month") ? t += g.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += g.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1550
+ }), this.view_is("month") ? t += p.get_days_in_month(h) * this.config.column_width / 30 : this.view_is("year") ? t += p.get_days_in_year(h) * this.config.column_width / 365 : t += this.config.column_width;
1500
1551
  }
1501
1552
  }
1502
1553
  highlight_holidays() {
@@ -1507,43 +1558,43 @@ class tt {
1507
1558
  i === "weekend" && (i = this.options.is_weekend);
1508
1559
  let s;
1509
1560
  if (typeof i == "object") {
1510
- let n = i.find((o) => typeof o == "function");
1561
+ let n = i.find((r) => typeof r == "function");
1511
1562
  if (n && (s = n), this.options.holidays.name) {
1512
- let o = /* @__PURE__ */ new Date(i.date + " ");
1513
- i = (a) => o.getTime() === a.getTime(), t[o] = i.name;
1563
+ let r = /* @__PURE__ */ new Date(i.date + " ");
1564
+ i = (o) => r.getTime() === o.getTime(), t[r] = i.name;
1514
1565
  } else
1515
- i = (o) => this.options.holidays[e].filter((a) => typeof a != "function").map((a) => {
1516
- if (a.name) {
1517
- let h = /* @__PURE__ */ new Date(a.date + " ");
1518
- return t[h] = a.name, h.getTime();
1566
+ i = (r) => this.options.holidays[e].filter((o) => typeof o != "function").map((o) => {
1567
+ if (o.name) {
1568
+ let h = /* @__PURE__ */ new Date(o.date + " ");
1569
+ return t[h] = o.name, h.getTime();
1519
1570
  }
1520
- return (/* @__PURE__ */ new Date(a + " ")).getTime();
1521
- }).includes(o.getTime());
1571
+ return (/* @__PURE__ */ new Date(o + " ")).getTime();
1572
+ }).includes(r.getTime());
1522
1573
  }
1523
1574
  for (let n = new Date(this.gantt_start); n <= this.gantt_end; n.setDate(n.getDate() + 1))
1524
1575
  if (!(this.config.ignored_dates.find(
1525
- (o) => o.getTime() == n.getTime()
1576
+ (r) => r.getTime() == n.getTime()
1526
1577
  ) || this.config.ignored_function && this.config.ignored_function(n)) && (i(n) || s && s(n))) {
1527
- const o = g.diff(
1578
+ const r = p.diff(
1528
1579
  n,
1529
1580
  this.gantt_start,
1530
1581
  this.config.unit
1531
- ) / this.config.step * this.config.column_width, a = this.grid_height - this.config.header_height, h = g.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1582
+ ) / this.config.step * this.config.column_width, o = this.grid_height - this.config.header_height, h = p.format(n, "YYYY-MM-DD", this.options.language).replace(" ", "_");
1532
1583
  if (t[n]) {
1533
- let d = this.create_el({
1584
+ let _ = this.create_el({
1534
1585
  classes: "holiday-label label_" + h,
1535
1586
  append_to: this.$extras
1536
1587
  });
1537
- d.textContent = t[n];
1588
+ _.textContent = t[n];
1538
1589
  }
1539
1590
  w("rect", {
1540
- x: Math.round(o),
1591
+ x: Math.round(r),
1541
1592
  y: this.config.header_height,
1542
- width: this.config.column_width / g.convert_scales(
1593
+ width: this.config.column_width / p.convert_scales(
1543
1594
  this.config.view_mode.step,
1544
1595
  "day"
1545
1596
  ),
1546
- height: a,
1597
+ height: o,
1547
1598
  class: "holiday-highlight " + h,
1548
1599
  style: `fill: ${e};`,
1549
1600
  append_to: this.layers.grid
@@ -1561,7 +1612,7 @@ class tt {
1561
1612
  if (!t) return;
1562
1613
  const [e, i] = t;
1563
1614
  i.classList.add("current-date-highlight");
1564
- const n = g.diff(
1615
+ const n = p.diff(
1565
1616
  /* @__PURE__ */ new Date(),
1566
1617
  this.gantt_start,
1567
1618
  this.config.unit
@@ -1595,8 +1646,8 @@ class tt {
1595
1646
  (n) => n.getTime() == i.getTime()
1596
1647
  ) && (!this.config.ignored_function || !this.config.ignored_function(i)))
1597
1648
  continue;
1598
- let s = g.convert_scales(
1599
- g.diff(i, this.gantt_start) + "d",
1649
+ let s = p.convert_scales(
1650
+ p.diff(i, this.gantt_start) + "d",
1600
1651
  this.config.unit
1601
1652
  ) / this.config.step;
1602
1653
  this.config.ignored_positions.push(s * this.config.column_width), w("rect", {
@@ -1613,10 +1664,10 @@ class tt {
1613
1664
  this.config.view_mode
1614
1665
  );
1615
1666
  }
1616
- create_el({ left: t, top: e, width: i, height: s, id: n, classes: o, append_to: a, type: h }) {
1617
- let d = document.createElement(h || "div");
1618
- for (let _ of o.split(" ")) d.classList.add(_);
1619
- 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;
1667
+ create_el({ left: t, top: e, width: i, height: s, id: n, classes: r, append_to: o, type: h }) {
1668
+ let _ = document.createElement(h || "div");
1669
+ for (let d of r.split(" ")) _.classList.add(d);
1670
+ return _.style.top = e + "px", _.style.left = t + "px", n && (_.id = n), i && (_.style.width = i + "px"), s && (_.style.height = s + "px"), o && o.appendChild(_), _;
1620
1671
  }
1621
1672
  make_dates() {
1622
1673
  this.get_dates_to_draw().forEach((t, e) => {
@@ -1653,11 +1704,11 @@ class tt {
1653
1704
  let i = e ? e.date : null;
1654
1705
  this.config.column_width;
1655
1706
  const s = e ? e.x + e.column_width : 0;
1656
- let n = this.config.view_mode.upper_text, o = this.config.view_mode.lower_text;
1657
- return n ? typeof n == "string" && (this.config.view_mode.upper_text = (a) => g.format(a, n, this.options.language)) : this.config.view_mode.upper_text = () => "", o ? typeof o == "string" && (this.config.view_mode.lower_text = (a) => g.format(a, o, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1707
+ let n = this.config.view_mode.upper_text, r = this.config.view_mode.lower_text;
1708
+ return n ? typeof n == "string" && (this.config.view_mode.upper_text = (o) => p.format(o, n, this.options.language)) : this.config.view_mode.upper_text = () => "", r ? typeof r == "string" && (this.config.view_mode.lower_text = (o) => p.format(o, r, this.options.language)) : this.config.view_mode.lower_text = () => "", {
1658
1709
  date: t,
1659
1710
  formatted_date: D(
1660
- g.format(
1711
+ p.format(
1661
1712
  t,
1662
1713
  this.config.date_format,
1663
1714
  this.options.language
@@ -1688,19 +1739,19 @@ class tt {
1688
1739
  }).filter((t) => t !== null);
1689
1740
  }
1690
1741
  make_arrows() {
1691
- this.arrows = [], this.options.critical_path && this.calculate_critical_path();
1742
+ this.arrows = [], this.active_arrow = null, this.options.critical_path && this.calculate_critical_path();
1692
1743
  for (let t of this.tasks) {
1693
1744
  let e = [];
1694
1745
  e = t.dependencies.map((i) => {
1695
1746
  const s = this.get_task(i.id);
1696
1747
  if (!s) return;
1697
- const n = this.bars[s._index], o = this.bars[t._index];
1698
- if (!n || !o) return;
1699
- const a = i.type || this.options.dependencies_type || "finish-to-start", h = new U(
1748
+ const n = this.bars[s._index], r = this.bars[t._index];
1749
+ if (!n || !r) return;
1750
+ const o = i.type || this.options.dependencies_type || "finish-to-start", h = new U(
1700
1751
  this,
1701
1752
  n,
1702
- o,
1703
- a
1753
+ r,
1754
+ o
1704
1755
  );
1705
1756
  return this.layers.arrow.appendChild(h.element), this.layers.arrow.appendChild(h.hit_element), h;
1706
1757
  }).filter(Boolean), this.arrows = this.arrows.concat(e);
@@ -1714,35 +1765,35 @@ class tt {
1714
1765
  });
1715
1766
  const e = (n) => {
1716
1767
  if (t[n.id].ef > 0) return t[n.id];
1717
- let o = 0;
1768
+ let r = 0;
1718
1769
  n.dependencies && n.dependencies.length > 0 && n.dependencies.forEach((h) => {
1719
- const d = this.get_task(h.id);
1720
- if (d) {
1721
- const _ = e(d);
1722
- o = Math.max(o, _.ef);
1770
+ const _ = this.get_task(h.id);
1771
+ if (_) {
1772
+ const d = e(_);
1773
+ r = Math.max(r, d.ef);
1723
1774
  }
1724
- }), t[n.id].es = o;
1725
- const a = g.diff(n._end, n._start, "hour") / 24;
1726
- return t[n.id].ef = o + a, t[n.id];
1775
+ }), t[n.id].es = r;
1776
+ const o = p.diff(n._end, n._start, "hour") / 24;
1777
+ return t[n.id].ef = r + o, t[n.id];
1727
1778
  };
1728
1779
  this.tasks.forEach((n) => e(n));
1729
1780
  const i = Math.max(...Object.values(t).map((n) => n.ef)), s = (n) => {
1730
1781
  if (t[n.id].ls > 0 || t[n.id].lf > 0)
1731
1782
  return t[n.id];
1732
- const o = this.tasks.filter(
1733
- (d) => d.dependencies && d.dependencies.some((_) => _.id === n.id)
1783
+ const r = this.tasks.filter(
1784
+ (_) => _.dependencies && _.dependencies.some((d) => d.id === n.id)
1734
1785
  );
1735
- let a = i;
1736
- o.length > 0 && o.forEach((d) => {
1737
- const _ = s(d);
1738
- a = Math.min(a, _.ls);
1786
+ let o = i;
1787
+ r.length > 0 && r.forEach((_) => {
1788
+ const d = s(_);
1789
+ o = Math.min(o, d.ls);
1739
1790
  });
1740
- const h = g.diff(n._end, n._start, "hour") / 24;
1741
- return t[n.id].lf = a, t[n.id].ls = a - h, t[n.id];
1791
+ const h = p.diff(n._end, n._start, "hour") / 24;
1792
+ return t[n.id].lf = o, t[n.id].ls = o - h, t[n.id];
1742
1793
  };
1743
1794
  this.tasks.forEach((n) => s(n)), this.tasks.forEach((n) => {
1744
- const o = t[n.id], a = o.ls - o.es;
1745
- n._is_critical = Math.abs(a) < 0.01;
1795
+ const r = t[n.id], o = r.ls - r.es;
1796
+ n._is_critical = Math.abs(o) < 0.01;
1746
1797
  });
1747
1798
  }
1748
1799
  update_arrow_critical_path() {
@@ -1760,8 +1811,8 @@ class tt {
1760
1811
  }
1761
1812
  set_scroll_position(t) {
1762
1813
  if (this.options.infinite_padding && (!t || t === "start")) {
1763
- let [o, ...a] = this.get_start_end_positions();
1764
- this.$container.scrollLeft = o;
1814
+ let [r, ...o] = this.get_start_end_positions();
1815
+ this.$container.scrollLeft = r;
1765
1816
  return;
1766
1817
  }
1767
1818
  if (!t || t === "start")
@@ -1771,9 +1822,9 @@ class tt {
1771
1822
  else {
1772
1823
  if (t === "today")
1773
1824
  return this.scroll_current();
1774
- typeof t == "string" && (t = g.parse(t));
1825
+ typeof t == "string" && (t = p.parse(t));
1775
1826
  }
1776
- const i = g.diff(
1827
+ const i = p.diff(
1777
1828
  t,
1778
1829
  this.gantt_start,
1779
1830
  this.config.unit
@@ -1781,7 +1832,7 @@ class tt {
1781
1832
  this.$container.scrollTo({
1782
1833
  left: i - this.config.column_width / 6,
1783
1834
  behavior: "smooth"
1784
- }), this.$current && this.$current.classList.remove("current-upper"), this.current_date = g.add(
1835
+ }), this.$current && this.$current.classList.remove("current-upper"), this.current_date = p.add(
1785
1836
  this.gantt_start,
1786
1837
  this.$container.scrollLeft / this.config.column_width,
1787
1838
  this.config.unit
@@ -1791,9 +1842,9 @@ class tt {
1791
1842
  null,
1792
1843
  this.options.language
1793
1844
  ), n = this.upperTexts.find(
1794
- (o) => o.textContent === s
1845
+ (r) => r.textContent === s
1795
1846
  );
1796
- this.current_date = g.add(
1847
+ this.current_date = p.add(
1797
1848
  this.gantt_start,
1798
1849
  (this.$container.scrollLeft + n.clientWidth) / this.config.column_width,
1799
1850
  this.config.unit
@@ -1801,7 +1852,7 @@ class tt {
1801
1852
  this.current_date,
1802
1853
  null,
1803
1854
  this.options.language
1804
- ), n = this.upperTexts.find((o) => o.textContent === s), n.classList.add("current-upper"), this.$current = n;
1855
+ ), n = this.upperTexts.find((r) => r.textContent === s), n.classList.add("current-upper"), this.$current = n;
1805
1856
  }
1806
1857
  scroll_current() {
1807
1858
  let t = this.get_closest_date();
@@ -1812,7 +1863,7 @@ class tt {
1812
1863
  if (t < this.gantt_start || t > this.gantt_end) return null;
1813
1864
  let e = /* @__PURE__ */ new Date(), i = this.$container.querySelector(
1814
1865
  ".date_" + D(
1815
- g.format(
1866
+ p.format(
1816
1867
  e,
1817
1868
  this.config.date_format,
1818
1869
  this.options.language
@@ -1820,9 +1871,9 @@ class tt {
1820
1871
  )
1821
1872
  ), s = 0;
1822
1873
  for (; !i && s < this.config.step; )
1823
- e = g.add(e, -1, this.config.unit), i = this.$container.querySelector(
1874
+ e = p.add(e, -1, this.config.unit), i = this.$container.querySelector(
1824
1875
  ".date_" + D(
1825
- g.format(
1876
+ p.format(
1826
1877
  e,
1827
1878
  this.config.date_format,
1828
1879
  this.options.language
@@ -1831,7 +1882,7 @@ class tt {
1831
1882
  ), s++;
1832
1883
  return [
1833
1884
  /* @__PURE__ */ new Date(
1834
- g.format(
1885
+ p.format(
1835
1886
  e,
1836
1887
  this.config.date_format,
1837
1888
  this.options.language
@@ -1849,14 +1900,14 @@ class tt {
1849
1900
  if (e && e.classList.contains("grid-row")) {
1850
1901
  const i = this.$svg, s = i.createSVGPoint();
1851
1902
  s.x = t.clientX, s.y = t.clientY;
1852
- const n = s.matrixTransform(i.getScreenCTM().inverse()), o = this.options.bar_height + this.options.padding, a = Math.floor((n.y - this.config.header_height) / o), h = this.tasks[a];
1903
+ const n = s.matrixTransform(i.getScreenCTM().inverse()), r = this.options.bar_height + this.options.padding, o = Math.floor((n.y - this.config.header_height) / r), h = this.tasks[o];
1853
1904
  if (h && h._has_no_dates) {
1854
- const d = n.x / this.config.column_width, _ = Math.floor(d * this.config.step), c = g.add(
1905
+ const _ = n.x / this.config.column_width, d = Math.floor(_ * this.config.step), l = p.add(
1855
1906
  this.gantt_start,
1856
- _,
1907
+ d,
1857
1908
  this.config.unit
1858
1909
  );
1859
- h._start = c, h._end = g.add(c, 1, "day"), h.start = c, h.end = h._end, delete h._has_no_dates, this.refresh(this.tasks, !0), this.trigger_event("date_change", [
1910
+ h._start = l, h._end = p.add(l, 1, "day"), h.start = l, h.end = h._end, delete h._has_no_dates, this.refresh(this.tasks, !0), this.trigger_event("date_change", [
1860
1911
  h,
1861
1912
  h._start,
1862
1913
  h._end
@@ -1892,61 +1943,61 @@ class tt {
1892
1943
  get_start_end_positions() {
1893
1944
  if (!this.bars.length) return [0, 0, 0];
1894
1945
  let { x: t, width: e } = this.bars[0].group.getBBox(), i = t, s = t, n = t + e;
1895
- return Array.prototype.forEach.call(this.bars, function({ group: o }, a) {
1896
- let { x: h, width: d } = o.getBBox();
1897
- h < i && (i = h), h > s && (s = h), h + d > n && (n = h + d);
1946
+ return Array.prototype.forEach.call(this.bars, function({ group: r }, o) {
1947
+ let { x: h, width: _ } = r.getBBox();
1948
+ h < i && (i = h), h > s && (s = h), h + _ > n && (n = h + _);
1898
1949
  }), [i, s, n];
1899
1950
  }
1900
1951
  bind_bar_events() {
1901
- let t = !1, e = 0, i = 0, s = !1, n = !1, o = null, a = [];
1902
- this.bar_being_dragged = null;
1952
+ let t = !1, e = 0, i = 0, s = !1, n = !1, r = null, o = [];
1953
+ this.bar_being_dragged = null, this.active_arrow = null;
1903
1954
  const h = () => t || s || n;
1904
- this.$svg.onclick = (_) => {
1905
- _.target.classList.contains("grid-row") && this.unselect_all();
1906
- };
1907
- let d = 0;
1908
- if (m.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (_) => {
1909
- this.bar_being_dragged === !1 && Math.abs((_.offsetX || _.layerX) - d) > 10 && (this.bar_being_dragged = !0);
1910
- }), m.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (_, c) => {
1911
- const p = m.closest(".bar-wrapper", c);
1912
- c.classList.contains("left") ? (s = !0, c.classList.add("visible")) : c.classList.contains("right") ? (n = !0, c.classList.add("visible")) : c.classList.contains("bar-wrapper") && (t = !0), this.popup && this.popup.hide(), e = _.offsetX || _.layerX, o = p.getAttribute("data-id"), a = [this.get_bar(o)], this.bar_being_dragged = !1, d = e, a.forEach((l) => {
1913
- const f = l.$bar;
1955
+ this.$svg.onclick = (d) => {
1956
+ d.target.classList.contains("grid-row") && this.unselect_all();
1957
+ }, this._document_click_handler || (this._document_click_handler = () => this.set_active_arrow(null), document.addEventListener("click", this._document_click_handler));
1958
+ let _ = 0;
1959
+ if (m.on(this.$svg, "mousemove", ".bar-wrapper, .handle", (d) => {
1960
+ this.bar_being_dragged === !1 && Math.abs((d.offsetX || d.layerX) - _) > 10 && (this.bar_being_dragged = !0);
1961
+ }), m.on(this.$svg, "mousedown", ".bar-wrapper, .handle", (d, l) => {
1962
+ const g = m.closest(".bar-wrapper", l);
1963
+ 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 = d.offsetX || d.layerX, r = g.getAttribute("data-id"), o = [this.get_bar(r)], this.bar_being_dragged = !1, _ = e, o.forEach((c) => {
1964
+ const f = c.$bar;
1914
1965
  f.ox = f.getX(), f.oy = f.getY(), f.owidth = f.getWidth(), f.finaldx = 0;
1915
1966
  });
1916
1967
  }), this.options.infinite_padding) {
1917
- let _ = !1;
1918
- m.on(this.$container, "mousewheel", (c) => {
1919
- let p = this.$container.scrollWidth / 2;
1920
- if (!_ && c.currentTarget.scrollLeft <= p) {
1921
- let l = c.currentTarget.scrollLeft;
1922
- _ = !0, this.gantt_start = g.add(
1968
+ let d = !1;
1969
+ m.on(this.$container, "mousewheel", (l) => {
1970
+ let g = this.$container.scrollWidth / 2;
1971
+ if (!d && l.currentTarget.scrollLeft <= g) {
1972
+ let c = l.currentTarget.scrollLeft;
1973
+ d = !0, this.gantt_start = p.add(
1923
1974
  this.gantt_start,
1924
1975
  -this.config.extend_by_units,
1925
1976
  this.config.unit
1926
- ), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l + this.config.column_width * this.config.extend_by_units, setTimeout(() => _ = !1, 300);
1977
+ ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = c + this.config.column_width * this.config.extend_by_units, setTimeout(() => d = !1, 300);
1927
1978
  }
1928
- if (!_ && c.currentTarget.scrollWidth - (c.currentTarget.scrollLeft + c.currentTarget.clientWidth) <= p) {
1929
- let l = c.currentTarget.scrollLeft;
1930
- _ = !0, this.gantt_end = g.add(
1979
+ if (!d && l.currentTarget.scrollWidth - (l.currentTarget.scrollLeft + l.currentTarget.clientWidth) <= g) {
1980
+ let c = l.currentTarget.scrollLeft;
1981
+ d = !0, this.gantt_end = p.add(
1931
1982
  this.gantt_end,
1932
1983
  this.config.extend_by_units,
1933
1984
  this.config.unit
1934
- ), this.setup_date_values(), this.render(), c.currentTarget.scrollLeft = l, setTimeout(() => _ = !1, 300);
1985
+ ), this.setup_date_values(), this.render(), l.currentTarget.scrollLeft = c, setTimeout(() => d = !1, 300);
1935
1986
  }
1936
1987
  });
1937
1988
  }
1938
- m.on(this.$container, "scroll", (_) => {
1939
- this.$task_column && !this._syncing_scroll && (this._syncing_scroll = !0, this.$task_column.scrollTop = _.currentTarget.scrollTop, requestAnimationFrame(() => {
1989
+ m.on(this.$container, "scroll", (d) => {
1990
+ this.$task_column && !this._syncing_scroll && (this._syncing_scroll = !0, this.$task_column.scrollTop = d.currentTarget.scrollTop, requestAnimationFrame(() => {
1940
1991
  this._syncing_scroll = !1;
1941
1992
  }));
1942
- let c = [];
1943
- const p = this.bars.map(
1993
+ let l = [];
1994
+ const g = this.bars.map(
1944
1995
  ({ group: $ }) => $.getAttribute("data-id")
1945
1996
  );
1946
- let l;
1947
- i && (l = _.currentTarget.scrollLeft - i), this.current_date = g.add(
1997
+ let c;
1998
+ i && (c = d.currentTarget.scrollLeft - i), this.current_date = p.add(
1948
1999
  this.gantt_start,
1949
- _.currentTarget.scrollLeft / this.config.column_width * this.config.step,
2000
+ d.currentTarget.scrollLeft / this.config.column_width * this.config.step,
1950
2001
  this.config.unit
1951
2002
  );
1952
2003
  let f = this.config.view_mode.upper_text(
@@ -1956,9 +2007,9 @@ class tt {
1956
2007
  ), u = this.upperTexts.find(
1957
2008
  ($) => $.textContent === f
1958
2009
  );
1959
- this.current_date = g.add(
2010
+ this.current_date = p.add(
1960
2011
  this.gantt_start,
1961
- (_.currentTarget.scrollLeft + u.clientWidth) / this.config.column_width * this.config.step,
2012
+ (d.currentTarget.scrollLeft + u.clientWidth) / this.config.column_width * this.config.step,
1962
2013
  this.config.unit
1963
2014
  ), f = this.config.view_mode.upper_text(
1964
2015
  this.current_date,
@@ -1966,61 +2017,61 @@ class tt {
1966
2017
  this.options.language
1967
2018
  ), u = this.upperTexts.find(
1968
2019
  ($) => $.textContent === f
1969
- ), u !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), u.classList.add("current-upper"), this.$current = u), i = _.currentTarget.scrollLeft;
1970
- let [b, y, k] = this.get_start_end_positions();
1971
- i > k + 100 ? (this.$adjust.innerHTML = "&larr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
2020
+ ), u !== this.$current && (this.$current && this.$current.classList.remove("current-upper"), u.classList.add("current-upper"), this.$current = u), i = d.currentTarget.scrollLeft;
2021
+ let [b, y, v] = this.get_start_end_positions();
2022
+ i > v + 100 ? (this.$adjust.innerHTML = "&larr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1972
2023
  this.$container.scrollTo({
1973
2024
  left: y,
1974
2025
  behavior: "smooth"
1975
2026
  });
1976
- }) : i + _.currentTarget.offsetWidth < b - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
2027
+ }) : i + d.currentTarget.offsetWidth < b - 100 ? (this.$adjust.innerHTML = "&rarr;", this.$adjust.classList.remove("hide"), this.$adjust.onclick = () => {
1977
2028
  this.$container.scrollTo({
1978
2029
  left: b,
1979
2030
  behavior: "smooth"
1980
2031
  });
1981
- }) : this.$adjust.classList.add("hide"), l && (c = p.map(($) => this.get_bar($)), this.options.auto_move_label && c.forEach(($) => {
2032
+ }) : this.$adjust.classList.add("hide"), c && (l = g.map(($) => this.get_bar($)), this.options.auto_move_label && l.forEach(($) => {
1982
2033
  $.update_label_position_on_horizontal_scroll({
1983
- x: l,
1984
- sx: _.currentTarget.scrollLeft
2034
+ x: c,
2035
+ sx: d.currentTarget.scrollLeft
1985
2036
  });
1986
2037
  }));
1987
- }), m.on(this.$svg, "mousemove", (_) => {
2038
+ }), m.on(this.$svg, "mousemove", (d) => {
1988
2039
  if (!h()) return;
1989
- const c = (_.offsetX || _.layerX) - e;
1990
- a.forEach((p) => {
1991
- const l = p.$bar;
1992
- l.finaldx = this.get_snap_position(c, l.ox), this.hide_popup(), s ? o === p.task.id ? p.update_bar_position({
1993
- x: l.ox + l.finaldx,
1994
- width: l.owidth - l.finaldx
1995
- }) : p.update_bar_position({
1996
- x: l.ox + l.finaldx
1997
- }) : n ? o === p.task.id && p.update_bar_position({
1998
- width: l.owidth + l.finaldx
1999
- }) : t && !this.options.readonly && !this.options.readonly_dates && p.update_bar_position({ x: l.ox + l.finaldx });
2040
+ const l = (d.offsetX || d.layerX) - e;
2041
+ o.forEach((g) => {
2042
+ const c = g.$bar;
2043
+ c.finaldx = this.get_snap_position(l, c.ox), this.hide_popup(), s ? r === g.task.id ? g.update_bar_position({
2044
+ x: c.ox + c.finaldx,
2045
+ width: c.owidth - c.finaldx
2046
+ }) : g.update_bar_position({
2047
+ x: c.ox + c.finaldx
2048
+ }) : n ? r === g.task.id && g.update_bar_position({
2049
+ width: c.owidth + c.finaldx
2050
+ }) : t && !this.options.readonly && !this.options.readonly_dates && g.update_bar_position({ x: c.ox + c.finaldx });
2000
2051
  });
2001
2052
  }), document.addEventListener("mouseup", () => {
2002
- var p, l, f;
2003
- const _ = this.bar_being_dragged === !0;
2053
+ var g, c, f;
2054
+ const d = this.bar_being_dragged === !0;
2004
2055
  this.bar_being_dragged = null;
2005
- const c = [];
2006
- if (a.forEach((u) => {
2056
+ const l = [];
2057
+ if (o.forEach((u) => {
2007
2058
  if (!u.$bar.finaldx) {
2008
- _ && u.set_action_completed();
2059
+ d && u.set_action_completed();
2009
2060
  return;
2010
2061
  }
2011
- u.date_changed(), u.compute_progress(), u.set_action_completed(), c.push({
2062
+ u.date_changed(), u.compute_progress(), u.set_action_completed(), l.push({
2012
2063
  task: u.task,
2013
2064
  start: u.task._start,
2014
- end: g.add(u.task._end, -1, "second")
2065
+ end: p.add(u.task._end, -1, "second")
2015
2066
  });
2016
- }), this.options.critical_path && a.some((u) => u.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), c.length > 0 && this.options.dependency_shifting !== "none") {
2067
+ }), this.options.critical_path && o.some((u) => u.$bar.finaldx) && (this.calculate_critical_path(), this.update_arrow_critical_path()), l.length > 0 && this.options.dependency_shifting !== "none") {
2017
2068
  const u = this.options.dependency_shifting;
2018
2069
  let b;
2019
- s ? b = u === "maintain_buffer_downstream" ? "none" : "upstream" : n ? b = "downstream" : b = u === "maintain_buffer_downstream" ? "downstream" : "both", c.forEach(({ task: y }) => {
2070
+ s ? b = u === "maintain_buffer_downstream" ? "none" : "upstream" : n ? b = "downstream" : b = u === "maintain_buffer_downstream" ? "downstream" : "both", l.forEach(({ task: y }) => {
2020
2071
  if (b === "none") return;
2021
- const k = a.find((T) => T.task.id === y.id);
2022
- if (!k || !k.$bar.finaldx) return;
2023
- const $ = k.$bar.finaldx / this.config.column_width, P = this.config.unit === "hour" ? 36e5 : this.config.unit === "day" ? 864e5 : this.config.unit === "month" ? 30 * 864e5 : this.config.unit === "year" ? 365 * 864e5 : 864e5, O = $ * this.config.step * P;
2072
+ const v = o.find((T) => T.task.id === y.id);
2073
+ if (!v || !v.$bar.finaldx) return;
2074
+ const $ = v.$bar.finaldx / this.config.column_width, P = this.config.unit === "hour" ? 36e5 : this.config.unit === "day" ? 864e5 : this.config.unit === "month" ? 30 * 864e5 : this.config.unit === "year" ? 365 * 864e5 : 864e5, O = $ * this.config.step * P;
2024
2075
  I(
2025
2076
  this.tasks,
2026
2077
  y.id,
@@ -2028,35 +2079,35 @@ class tt {
2028
2079
  this.options.dependency_shifting,
2029
2080
  b
2030
2081
  ).forEach((T, N) => {
2031
- const v = this.get_bar(N);
2032
- if (!v) return;
2033
- const M = v.task, j = new Date(M._start.getTime() + T), V = g.diff(j, this.gantt_start, this.config.unit) / this.config.step * this.config.column_width;
2034
- v.update_bar_position({ x: V }), v.update_arrow_position(), this.trigger_event("after_date_change", [
2082
+ const k = this.get_bar(N);
2083
+ if (!k) return;
2084
+ const M = k.task, j = new Date(M._start.getTime() + T), V = p.diff(j, this.gantt_start, this.config.unit) / this.config.step * this.config.column_width;
2085
+ k.update_bar_position({ x: V }), k.update_arrow_position(), this.trigger_event("after_date_change", [
2035
2086
  M,
2036
2087
  M._start,
2037
- g.add(M._end, -1, "second")
2088
+ p.add(M._end, -1, "second")
2038
2089
  ]);
2039
2090
  });
2040
2091
  });
2041
2092
  }
2042
- c.length > 0 && c.forEach(({ task: u, start: b, end: y }) => {
2093
+ l.length > 0 && l.forEach(({ task: u, start: b, end: y }) => {
2043
2094
  this.trigger_event("after_date_change", [u, b, y]);
2044
- }), a.forEach((u) => {
2095
+ }), o.forEach((u) => {
2045
2096
  u.$bar.finaldx = 0;
2046
- }), t = !1, s = !1, n = !1, (f = (l = (p = this.$container.querySelector(".visible")) == null ? void 0 : p.classList) == null ? void 0 : l.remove) == null || f.call(l, "visible");
2097
+ }), t = !1, s = !1, n = !1, (f = (c = (g = this.$container.querySelector(".visible")) == null ? void 0 : g.classList) == null ? void 0 : c.remove) == null || f.call(c, "visible");
2047
2098
  }), this.bind_bar_progress();
2048
2099
  }
2049
2100
  bind_task_column_resize() {
2050
2101
  if (!this.$task_column_resize_handle) return;
2051
2102
  let t = !1, e = 0, i = 0;
2052
2103
  const s = 100, n = 600;
2053
- m.on(this.$task_column_resize_handle, "mousedown", (o) => {
2054
- t = !0, e = o.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), o.preventDefault();
2055
- }), m.on(document, "mousemove", (o) => {
2104
+ m.on(this.$task_column_resize_handle, "mousedown", (r) => {
2105
+ t = !0, e = r.clientX, i = this.options.task_column.width, this.$task_column.classList.add("resizing"), r.preventDefault();
2106
+ }), m.on(document, "mousemove", (r) => {
2056
2107
  if (!t) return;
2057
- let a = o.clientX - e;
2058
- this.options.isRTL && (a = -a);
2059
- let h = i + a;
2108
+ let o = r.clientX - e;
2109
+ this.options.isRTL && (o = -o);
2110
+ let h = i + o;
2060
2111
  h = Math.max(s, Math.min(n, h)), this.options.task_column.width = h, this.$task_column.style.width = h + "px", this.$wrapper.style.setProperty(
2061
2112
  "--gv-task-column-width",
2062
2113
  h + "px"
@@ -2077,37 +2128,37 @@ class tt {
2077
2128
  }
2078
2129
  bind_bar_progress() {
2079
2130
  let t = 0, e = null, i = null, s = null, n = null;
2080
- m.on(this.$svg, "mousedown", ".handle.progress", (a, h) => {
2081
- e = !0, t = a.offsetX || a.layerX;
2082
- const _ = m.closest(".bar-wrapper", h).getAttribute("data-id");
2083
- 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();
2131
+ m.on(this.$svg, "mousedown", ".handle.progress", (o, h) => {
2132
+ e = !0, t = o.offsetX || o.layerX;
2133
+ const d = m.closest(".bar-wrapper", h).getAttribute("data-id");
2134
+ i = this.get_bar(d), 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();
2084
2135
  });
2085
- const o = this.config.ignored_positions.map((a) => [
2086
- a,
2087
- a + this.config.column_width
2136
+ const r = this.config.ignored_positions.map((o) => [
2137
+ o,
2138
+ o + this.config.column_width
2088
2139
  ]);
2089
- m.on(this.$svg, "mousemove", (a) => {
2140
+ m.on(this.$svg, "mousemove", (o) => {
2090
2141
  if (!e) return;
2091
- let h = a.offsetX || a.layerX;
2142
+ let h = o.offsetX || o.layerX;
2092
2143
  if (h > t) {
2093
- let c = o.find(
2094
- ([p, l]) => h >= p && h < l
2144
+ let l = r.find(
2145
+ ([g, c]) => h >= g && h < c
2095
2146
  );
2096
- for (; c; )
2097
- h = c[1], c = o.find(
2098
- ([p, l]) => h >= p && h < l
2147
+ for (; l; )
2148
+ h = l[1], l = r.find(
2149
+ ([g, c]) => h >= g && h < c
2099
2150
  );
2100
2151
  } else {
2101
- let c = o.find(
2102
- ([p, l]) => h > p && h <= l
2152
+ let l = r.find(
2153
+ ([g, c]) => h > g && h <= c
2103
2154
  );
2104
- for (; c; )
2105
- h = c[0], c = o.find(
2106
- ([p, l]) => h > p && h <= l
2155
+ for (; l; )
2156
+ h = l[0], l = r.find(
2157
+ ([g, c]) => h > g && h <= c
2107
2158
  );
2108
2159
  }
2109
- let _ = h - t;
2110
- console.log(s), _ > s.max_dx && (_ = s.max_dx), _ < s.min_dx && (_ = s.min_dx), s.setAttribute("width", s.owidth + _), m.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = _;
2160
+ let d = h - t;
2161
+ console.log(s), d > s.max_dx && (d = s.max_dx), d < s.min_dx && (d = s.min_dx), s.setAttribute("width", s.owidth + d), m.attr(i.$handle_progress, "cx", s.getEndX()), s.finaldx = d;
2111
2162
  }), m.on(this.$svg, "mouseup", () => {
2112
2163
  e = !1, s && s.finaldx && (s.finaldx = 0, i.progress_changed(), i.set_action_completed(), i = null, s = null, n = null);
2113
2164
  });
@@ -2115,7 +2166,7 @@ class tt {
2115
2166
  get_all_dependent_tasks(t) {
2116
2167
  let e = [], i = [t];
2117
2168
  for (; i.length; ) {
2118
- const s = i.reduce((n, o) => (n = n.concat(this.dependency_map[o]), n), []);
2169
+ const s = i.reduce((n, r) => (n = n.concat(this.dependency_map[r]), n), []);
2119
2170
  e = e.concat(s), i = s.filter((n) => !i.includes(n));
2120
2171
  }
2121
2172
  return e.filter(Boolean);
@@ -2124,22 +2175,25 @@ class tt {
2124
2175
  let i = 1;
2125
2176
  const s = this.options.snap_at || this.config.view_mode.snap_at || "1d";
2126
2177
  if (s !== "unit") {
2127
- const { duration: _, scale: c } = g.parse_duration(s);
2128
- i = g.convert_scales(this.config.view_mode.step, c) / _;
2178
+ const { duration: d, scale: l } = p.parse_duration(s);
2179
+ i = p.convert_scales(this.config.view_mode.step, l) / d;
2129
2180
  }
2130
2181
  const n = t % (this.config.column_width / i);
2131
- let o = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), a = e + o;
2132
- const h = o > 0 ? 1 : -1;
2133
- let d = this.get_ignored_region(a, h);
2134
- for (; d.length; )
2135
- a += this.config.column_width * h, d = this.get_ignored_region(a, h), d.length || (a -= this.config.column_width * h);
2136
- return a - e;
2182
+ let r = t - n + (n < this.config.column_width / i * 2 ? 0 : this.config.column_width / i), o = e + r;
2183
+ const h = r > 0 ? 1 : -1;
2184
+ let _ = this.get_ignored_region(o, h);
2185
+ for (; _.length; )
2186
+ o += this.config.column_width * h, _ = this.get_ignored_region(o, h), _.length || (o -= this.config.column_width * h);
2187
+ return o - e;
2137
2188
  }
2138
2189
  get_ignored_region(t, e = 1) {
2139
2190
  return e === 1 ? this.config.ignored_positions.filter((i) => t > i && t <= i + this.config.column_width) : this.config.ignored_positions.filter(
2140
2191
  (i) => t >= i && t < i + this.config.column_width
2141
2192
  );
2142
2193
  }
2194
+ set_active_arrow(t) {
2195
+ this.active_arrow !== t && (this.active_arrow && this.active_arrow.deactivate(), this.active_arrow = t, t && (t.activate(), this.options.on_arrow_click && this.options.on_arrow_click(t.from_task.task, t.to_task.task)));
2196
+ }
2143
2197
  unselect_all() {
2144
2198
  this.popup && this.popup.parent.classList.add("hide"), this.$container.querySelectorAll(".date-range-highlight").forEach((t) => t.classList.add("hide"));
2145
2199
  }
@@ -2182,8 +2236,8 @@ class tt {
2182
2236
  * @memberof Gantt
2183
2237
  */
2184
2238
  clear() {
2185
- var t, e, i, s, n, o, a, h, d, _, c, p, l, f, u, b;
2186
- 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.$task_column) == null ? void 0 : n.remove) == null || o.call(n), (h = (a = this.$current_highlight) == null ? void 0 : a.remove) == null || h.call(a), (_ = (d = this.$extras) == null ? void 0 : d.remove) == null || _.call(d), (p = (c = this.popup) == null ? void 0 : c.hide) == null || p.call(c), (f = (l = this.$wrapper) == null ? void 0 : l.classList) == null || f.remove("has-task-column"), (b = (u = this.$wrapper) == null ? void 0 : u.classList) == null || b.remove("rtl");
2239
+ var t, e, i, s, n, r, o, h, _, d, l, g, c, f, u, b;
2240
+ 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), (r = (n = this.$task_column) == null ? void 0 : n.remove) == null || r.call(n), (h = (o = this.$current_highlight) == null ? void 0 : o.remove) == null || h.call(o), (d = (_ = this.$extras) == null ? void 0 : _.remove) == null || d.call(_), (g = (l = this.popup) == null ? void 0 : l.hide) == null || g.call(l), (f = (c = this.$wrapper) == null ? void 0 : c.classList) == null || f.remove("has-task-column"), (b = (u = this.$wrapper) == null ? void 0 : u.classList) == null || b.remove("rtl");
2187
2241
  }
2188
2242
  }
2189
2243
  tt.VIEW_MODE = {
@@ -2195,11 +2249,11 @@ tt.VIEW_MODE = {
2195
2249
  MONTH: x[5],
2196
2250
  YEAR: x[6]
2197
2251
  };
2198
- function et(r) {
2199
- return r.name + "_" + Math.random().toString(36).slice(2, 12);
2252
+ function et(a) {
2253
+ return a.name + "_" + Math.random().toString(36).slice(2, 12);
2200
2254
  }
2201
- function D(r) {
2202
- return r.replaceAll(" ", "_").replaceAll(":", "_").replaceAll(".", "_");
2255
+ function D(a) {
2256
+ return a.replaceAll(" ", "_").replaceAll(":", "_").replaceAll(".", "_");
2203
2257
  }
2204
2258
  export {
2205
2259
  tt as default