@taskctrl/canvas-timeline 0.2.0 → 0.3.0

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,8 +1,8 @@
1
- import { jsx as re, jsxs as Ne, Fragment as _t } from "react/jsx-runtime";
2
- import he, { useRef as z, useCallback as ee, useEffect as ue, forwardRef as si, useMemo as ce, useState as xe, useImperativeHandle as li } from "react";
3
- import { flushSync as ai } from "react-dom";
4
- import me from "dayjs";
5
- const Se = {
1
+ import { jsx as se, jsxs as Ze, Fragment as At } from "react/jsx-runtime";
2
+ import ge, { useRef as z, useCallback as ie, useEffect as he, forwardRef as ci, useMemo as oe, useState as xe, useImperativeHandle as ui } from "react";
3
+ import { flushSync as di } from "react-dom";
4
+ import pe from "dayjs";
5
+ const we = {
6
6
  primary: "#269bf7",
7
7
  trainColors: {},
8
8
  status: { red: "#EF5350", yellow: "#FBBF24", green: "#31c48d" },
@@ -12,7 +12,7 @@ const Se = {
12
12
  sidebar: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" },
13
13
  header: { bg: "#F9FAFB", border: "#E5E7EB", text: "#6c737f" }
14
14
  };
15
- class nt {
15
+ class lt {
16
16
  constructor(e) {
17
17
  Object.defineProperty(this, "visibleTimeStart", {
18
18
  enumerable: !0,
@@ -95,8 +95,8 @@ class nt {
95
95
  };
96
96
  }
97
97
  getVisibleGroupRange() {
98
- const e = Math.max(0, Math.floor(this.scrollTop / this.lineHeight)), t = Math.ceil(this.canvasHeight / this.lineHeight), s = Math.min(this.groupCount - 1, e + t);
99
- return { firstVisible: e, lastVisible: s };
98
+ const e = Math.max(0, Math.floor(this.scrollTop / this.lineHeight)), t = Math.ceil(this.canvasHeight / this.lineHeight), n = Math.min(this.groupCount - 1, e + t);
99
+ return { firstVisible: e, lastVisible: n };
100
100
  }
101
101
  isScrollInBuffer(e) {
102
102
  const t = this.visibleDuration * 1.5 * this.pixelsPerMs;
@@ -106,7 +106,7 @@ class nt {
106
106
  return this.groupCount * this.lineHeight;
107
107
  }
108
108
  }
109
- class ci {
109
+ class hi {
110
110
  constructor() {
111
111
  Object.defineProperty(this, "root", {
112
112
  enumerable: !0,
@@ -115,43 +115,43 @@ class ci {
115
115
  value: null
116
116
  });
117
117
  }
118
- buildFromItems(e, t, s) {
119
- const l = e.map((c) => ({
120
- item: c,
121
- start: t(c),
122
- end: s(c)
118
+ buildFromItems(e, t, n) {
119
+ const r = e.map((d) => ({
120
+ item: d,
121
+ start: t(d),
122
+ end: n(d)
123
123
  }));
124
- this.root = this.buildNode(l);
124
+ this.root = this.buildNode(r);
125
125
  }
126
126
  buildNode(e) {
127
127
  if (e.length === 0)
128
128
  return null;
129
- let t = 1 / 0, s = -1 / 0;
130
- for (const u of e)
131
- u.start < t && (t = u.start), u.end > s && (s = u.end);
132
- const l = (t + s) / 2, c = [], a = [], m = [];
133
- for (const u of e)
134
- u.end < l ? c.push(u) : u.start > l ? a.push(u) : m.push(u);
129
+ let t = 1 / 0, n = -1 / 0;
130
+ for (const c of e)
131
+ c.start < t && (t = c.start), c.end > n && (n = c.end);
132
+ const r = (t + n) / 2, d = [], l = [], u = [];
133
+ for (const c of e)
134
+ c.end < r ? d.push(c) : c.start > r ? l.push(c) : u.push(c);
135
135
  return {
136
- center: l,
137
- left: this.buildNode(c),
138
- right: this.buildNode(a),
139
- overlapping: m
136
+ center: r,
137
+ left: this.buildNode(d),
138
+ right: this.buildNode(l),
139
+ overlapping: u
140
140
  };
141
141
  }
142
142
  query(e, t) {
143
- const s = [];
144
- return this.queryNode(this.root, e, t, s), s;
143
+ const n = [];
144
+ return this.queryNode(this.root, e, t, n), n;
145
145
  }
146
- queryNode(e, t, s, l) {
146
+ queryNode(e, t, n, r) {
147
147
  if (e !== null) {
148
- for (const c of e.overlapping)
149
- c.start <= s && c.end >= t && l.push(c.item);
150
- t <= e.center && e.left !== null && this.queryNode(e.left, t, s, l), s >= e.center && e.right !== null && this.queryNode(e.right, t, s, l);
148
+ for (const d of e.overlapping)
149
+ d.start <= n && d.end >= t && r.push(d.item);
150
+ t <= e.center && e.left !== null && this.queryNode(e.left, t, n, r), n >= e.center && e.right !== null && this.queryNode(e.right, t, n, r);
151
151
  }
152
152
  }
153
153
  }
154
- class ui {
154
+ class fi {
155
155
  constructor(e, t) {
156
156
  Object.defineProperty(this, "lineHeight", {
157
157
  enumerable: !0,
@@ -175,39 +175,68 @@ class ui {
175
175
  value: /* @__PURE__ */ new Map()
176
176
  }), this.lineHeight = e, this.itemHeightRatio = t;
177
177
  }
178
- computeLayout(e, t) {
179
- if (this.layoutCache = /* @__PURE__ */ new Map(), this.groupMaxStack = /* @__PURE__ */ new Map(), !t) {
180
- const c = this.lineHeight * this.itemHeightRatio;
181
- for (const a of e)
182
- this.layoutCache.set(a.id, { stackLevel: 0, itemHeight: c }), this.groupMaxStack.set(a.group, 0);
178
+ computeLayout(e, t, n) {
179
+ this.layoutCache = /* @__PURE__ */ new Map(), this.groupMaxStack = /* @__PURE__ */ new Map();
180
+ const r = this.lineHeight * this.itemHeightRatio, d = r * 0.6;
181
+ if (!t) {
182
+ for (const u of e) {
183
+ const c = (n == null ? void 0 : n.isParent(u.id)) ?? !1;
184
+ this.layoutCache.set(u.id, { stackLevel: 0, itemHeight: c ? d : r }), this.groupMaxStack.set(u.group, 0);
185
+ }
183
186
  return this.layoutCache;
184
187
  }
185
- const s = /* @__PURE__ */ new Map();
186
- for (const c of e) {
187
- let a = s.get(c.group);
188
- a || (a = [], s.set(c.group, a)), a.push(c);
189
- }
190
- const l = this.lineHeight * this.itemHeightRatio;
191
- for (const [c, a] of s) {
192
- a.sort((v, T) => {
193
- const p = v.start_time - T.start_time;
194
- return p !== 0 ? p : T.end_time - T.start_time - (v.end_time - v.start_time);
195
- });
196
- const m = [];
197
- let u = 0;
198
- for (const v of a) {
199
- let T = -1;
200
- for (let p = 0; p < m.length; p++)
201
- if (m[p] <= v.start_time) {
202
- T = p;
203
- break;
204
- }
205
- T === -1 ? (T = m.length, m.push(v.end_time)) : m[T] = v.end_time, T > u && (u = T), this.layoutCache.set(v.id, { stackLevel: T, itemHeight: l });
206
- }
207
- this.groupMaxStack.set(c, u);
188
+ const l = /* @__PURE__ */ new Map();
189
+ for (const u of e) {
190
+ let c = l.get(u.group);
191
+ c || (c = [], l.set(u.group, c)), c.push(u);
208
192
  }
193
+ for (const [u, c] of l)
194
+ n ? this.computeHierarchyLayout(c, n, r, d, u) : this.computeFlatLayout(c, r, u);
209
195
  return this.layoutCache;
210
196
  }
197
+ computeFlatLayout(e, t, n) {
198
+ e.sort((l, u) => {
199
+ const c = l.start_time - u.start_time;
200
+ return c !== 0 ? c : u.end_time - u.start_time - (l.end_time - l.start_time);
201
+ });
202
+ const r = [];
203
+ let d = 0;
204
+ for (const l of e) {
205
+ let u = -1;
206
+ for (let c = 0; c < r.length; c++)
207
+ if (r[c] <= l.start_time) {
208
+ u = c;
209
+ break;
210
+ }
211
+ u === -1 ? (u = r.length, r.push(l.end_time)) : r[u] = l.end_time, u > d && (d = u), this.layoutCache.set(l.id, { stackLevel: u, itemHeight: t });
212
+ }
213
+ this.groupMaxStack.set(n, d);
214
+ }
215
+ computeHierarchyLayout(e, t, n, r, d) {
216
+ const l = [], u = [];
217
+ for (const g of e)
218
+ t.isParent(g.id) ? u.push(g) : l.push(g);
219
+ l.sort((g, b) => {
220
+ const T = g.start_time - b.start_time;
221
+ return T !== 0 ? T : b.end_time - b.start_time - (g.end_time - g.start_time);
222
+ });
223
+ const c = [];
224
+ let v = 0;
225
+ for (const g of l) {
226
+ let b = -1;
227
+ for (let T = 0; T < c.length; T++)
228
+ if (c[T] <= g.start_time) {
229
+ b = T;
230
+ break;
231
+ }
232
+ b === -1 ? (b = c.length, c.push(g.end_time)) : c[b] = g.end_time, b > v && (v = b), this.layoutCache.set(g.id, { stackLevel: b, itemHeight: n });
233
+ }
234
+ u.sort((g, b) => t.getNestingDepth(b.id) - t.getNestingDepth(g.id));
235
+ let M = l.length > 0 ? v + 1 : 0;
236
+ for (const g of u)
237
+ this.layoutCache.set(g.id, { stackLevel: M, itemHeight: r }), M > v && (v = M), M++;
238
+ this.groupMaxStack.set(d, v);
239
+ }
211
240
  getLayout(e) {
212
241
  return this.layoutCache.get(e);
213
242
  }
@@ -215,46 +244,186 @@ class ui {
215
244
  return ((this.groupMaxStack.get(e) ?? 0) + 1) * this.lineHeight;
216
245
  }
217
246
  }
218
- function Oe(i, e, t, s, l, c) {
219
- const a = t.xToTime(i), m = /* @__PURE__ */ new Map();
220
- for (let p = 0; p < c.length; p++)
221
- m.set(c[p].id, p);
222
- const u = s.query(a, a);
223
- let v = null, T = -1 / 0;
224
- for (const p of u) {
225
- const H = m.get(p.group);
226
- if (H === void 0)
247
+ class mi {
248
+ constructor() {
249
+ Object.defineProperty(this, "parentToChildren", {
250
+ enumerable: !0,
251
+ configurable: !0,
252
+ writable: !0,
253
+ value: /* @__PURE__ */ new Map()
254
+ }), Object.defineProperty(this, "childToParent", {
255
+ enumerable: !0,
256
+ configurable: !0,
257
+ writable: !0,
258
+ value: /* @__PURE__ */ new Map()
259
+ }), Object.defineProperty(this, "itemMap", {
260
+ enumerable: !0,
261
+ configurable: !0,
262
+ writable: !0,
263
+ value: /* @__PURE__ */ new Map()
264
+ }), Object.defineProperty(this, "depthCache", {
265
+ enumerable: !0,
266
+ configurable: !0,
267
+ writable: !0,
268
+ value: /* @__PURE__ */ new Map()
269
+ });
270
+ }
271
+ rebuild(e) {
272
+ this.parentToChildren = /* @__PURE__ */ new Map(), this.childToParent = /* @__PURE__ */ new Map(), this.itemMap = /* @__PURE__ */ new Map(), this.depthCache = /* @__PURE__ */ new Map();
273
+ for (const t of e)
274
+ this.itemMap.set(t.id, t);
275
+ for (const t of e)
276
+ if (t.parentId !== void 0 && this.itemMap.has(t.parentId)) {
277
+ this.childToParent.set(t.id, t.parentId);
278
+ let n = this.parentToChildren.get(t.parentId);
279
+ n || (n = [], this.parentToChildren.set(t.parentId, n)), n.push(t.id);
280
+ }
281
+ for (const t of this.childToParent.keys()) {
282
+ const n = /* @__PURE__ */ new Set();
283
+ let r = t;
284
+ for (; r !== void 0; ) {
285
+ if (n.has(r)) {
286
+ const d = this.childToParent.get(t);
287
+ this.childToParent.delete(t);
288
+ const l = this.parentToChildren.get(d);
289
+ if (l) {
290
+ const u = l.indexOf(t);
291
+ u !== -1 && l.splice(u, 1), l.length === 0 && this.parentToChildren.delete(d);
292
+ }
293
+ break;
294
+ }
295
+ n.add(r), r = this.childToParent.get(r);
296
+ }
297
+ }
298
+ }
299
+ isParent(e) {
300
+ const t = this.parentToChildren.get(e);
301
+ return t !== void 0 && t.length > 0;
302
+ }
303
+ getParent(e) {
304
+ return this.childToParent.get(e);
305
+ }
306
+ getChildren(e) {
307
+ return this.parentToChildren.get(e) ?? [];
308
+ }
309
+ getDescendants(e) {
310
+ const t = [], n = [...this.getChildren(e)];
311
+ for (; n.length > 0; ) {
312
+ const r = n.pop();
313
+ t.push(r);
314
+ const d = this.parentToChildren.get(r);
315
+ d && n.push(...d);
316
+ }
317
+ return t;
318
+ }
319
+ getEffectiveSpan(e) {
320
+ const t = this.itemMap.get(e);
321
+ if (!t)
322
+ return { start: 0, end: 0 };
323
+ let n = t.start_time, r = t.end_time;
324
+ const d = this.getDescendants(e);
325
+ for (const l of d) {
326
+ const u = this.itemMap.get(l);
327
+ u && (u.start_time < n && (n = u.start_time), u.end_time > r && (r = u.end_time));
328
+ }
329
+ return { start: n, end: r };
330
+ }
331
+ getNestingDepth(e) {
332
+ const t = this.depthCache.get(e);
333
+ if (t !== void 0)
334
+ return t;
335
+ let n = 0, r = this.childToParent.get(e);
336
+ for (; r !== void 0; )
337
+ n++, r = this.childToParent.get(r);
338
+ return this.depthCache.set(e, n), n;
339
+ }
340
+ getMoveDelta(e, t) {
341
+ const n = this.itemMap.get(e);
342
+ if (!n)
343
+ return [];
344
+ const r = t - n.start_time;
345
+ return this.getDescendants(e).map((l) => {
346
+ const u = this.itemMap.get(l);
347
+ return { itemId: l, newStart: u.start_time + r };
348
+ });
349
+ }
350
+ getResizeConstraint(e, t) {
351
+ const n = this.getDescendants(e);
352
+ if (n.length === 0)
353
+ return t === "left" ? { min: -1 / 0, max: 1 / 0 } : { min: -1 / 0, max: 1 / 0 };
354
+ if (t === "left") {
355
+ let r = 1 / 0;
356
+ for (const d of n) {
357
+ const l = this.itemMap.get(d);
358
+ l && l.start_time < r && (r = l.start_time);
359
+ }
360
+ return { min: -1 / 0, max: r };
361
+ } else {
362
+ let r = -1 / 0;
363
+ for (const d of n) {
364
+ const l = this.itemMap.get(d);
365
+ l && l.end_time > r && (r = l.end_time);
366
+ }
367
+ return { min: r, max: 1 / 0 };
368
+ }
369
+ }
370
+ }
371
+ function gi(i, e, t, n, r, d) {
372
+ const { x: l, y: u, width: c, height: v } = t, M = d.primary;
373
+ i.globalAlpha = 0.15, i.fillStyle = M, i.fillRect(l, u, c, v), i.globalAlpha = 1, i.strokeStyle = M, i.lineWidth = 1.5, i.strokeRect(l, u, c, v);
374
+ const g = Math.min(v * 0.5, 6), b = u + v / 2;
375
+ i.fillStyle = M, i.beginPath(), i.moveTo(l, b), i.lineTo(l + g, b - g), i.lineTo(l + g * 2, b), i.lineTo(l + g, b + g), i.closePath(), i.fill(), i.beginPath(), i.moveTo(l + c, b), i.lineTo(l + c - g, b - g), i.lineTo(l + c - g * 2, b), i.lineTo(l + c - g, b + g), i.closePath(), i.fill();
376
+ const T = e.title;
377
+ if (T && c > 30) {
378
+ i.fillStyle = d.item.text, i.font = '500 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', i.textBaseline = "middle";
379
+ const C = i.measureText(T).width, I = c - g * 4 - 4;
380
+ if (I > 20) {
381
+ const W = C > I ? T.slice(0, Math.floor(T.length * I / C)) + "..." : T;
382
+ i.fillText(W, l + c / 2 - Math.min(C, I) / 2, b);
383
+ }
384
+ }
385
+ n.selected && (i.strokeStyle = d.item.selectedRing, i.lineWidth = 2, i.strokeRect(l - 1, u - 1, c + 2, v + 2));
386
+ }
387
+ function Le(i, e, t, n, r, d) {
388
+ const l = t.xToTime(i), u = /* @__PURE__ */ new Map();
389
+ for (let g = 0; g < d.length; g++)
390
+ u.set(d[g].id, g);
391
+ const c = n.query(l, l);
392
+ let v = null, M = -1 / 0;
393
+ for (const g of c) {
394
+ const b = u.get(g.group);
395
+ if (b === void 0)
227
396
  continue;
228
- const S = l.getLayout(p.id);
229
- if (!S)
397
+ const T = r.getLayout(g.id);
398
+ if (!T)
230
399
  continue;
231
- const I = t.timeToX(p.start_time), W = t.timeToX(p.end_time) - I;
232
- if (i < I || i > I + W)
400
+ const C = t.timeToX(g.start_time), I = t.timeToX(g.end_time) - C;
401
+ if (i < C || i > C + I)
233
402
  continue;
234
- const j = t.groupIndexToY(H) + S.stackLevel * t.lineHeight + (t.lineHeight - S.itemHeight) / 2, y = S.itemHeight;
235
- e < j || e > j + y || j > T && (T = j, v = p);
403
+ const $ = t.groupIndexToY(b) + T.stackLevel * t.lineHeight + (t.lineHeight - T.itemHeight) / 2, S = T.itemHeight;
404
+ e < $ || e > $ + S || $ > M && (M = $, v = g);
236
405
  }
237
406
  return v;
238
407
  }
239
- function ot(i, e, t) {
240
- const s = e.yToGroupIndex(i);
241
- return t[s] ?? null;
408
+ function at(i, e, t) {
409
+ const n = e.yToGroupIndex(i);
410
+ return t[n] ?? null;
242
411
  }
243
- function Rt(i, e, t, s = 6) {
244
- const l = t.timeToX(e.start_time), c = t.timeToX(e.end_time);
245
- return i - l <= s ? "left" : c - i <= s ? "right" : "body";
412
+ function Dt(i, e, t, n = 6) {
413
+ const r = t.timeToX(e.start_time), d = t.timeToX(e.end_time);
414
+ return i - r <= n ? "left" : d - i <= n ? "right" : "body";
246
415
  }
247
- function st(i, e, t) {
248
- const s = window.devicePixelRatio || 1, l = Math.round(e * s), c = Math.round(t * s);
249
- (i.width !== l || i.height !== c) && (i.width = l, i.height = c, i.style.width = `${e}px`, i.style.height = `${t}px`);
250
- const a = i.getContext("2d");
251
- return a.setTransform(s, 0, 0, s, 0, 0), a;
416
+ function ct(i, e, t) {
417
+ const n = window.devicePixelRatio || 1, r = Math.round(e * n), d = Math.round(t * n);
418
+ (i.width !== r || i.height !== d) && (i.width = r, i.height = d, i.style.width = `${e}px`, i.style.height = `${t}px`);
419
+ const l = i.getContext("2d");
420
+ return l.setTransform(n, 0, 0, n, 0, 0), l;
252
421
  }
253
- function lt(i, e) {
422
+ function ut(i, e) {
254
423
  const t = window.devicePixelRatio || 1;
255
424
  i.clearRect(0, 0, e.width / t, e.height / t);
256
425
  }
257
- class di {
426
+ class pi {
258
427
  constructor(e) {
259
428
  Object.defineProperty(this, "dirty", {
260
429
  enumerable: !0,
@@ -290,231 +459,232 @@ class di {
290
459
  }));
291
460
  }
292
461
  }
293
- class hi {
294
- draw(e, t, s, l, c, a, m) {
295
- const { firstVisible: u, lastVisible: v } = t.getVisibleGroupRange();
296
- for (let y = u; y <= v; y++) {
297
- const D = t.groupIndexToY(y), B = s[y];
462
+ class vi {
463
+ draw(e, t, n, r, d, l, u) {
464
+ const { firstVisible: c, lastVisible: v } = t.getVisibleGroupRange();
465
+ for (let S = c; S <= v; S++) {
466
+ const _ = t.groupIndexToY(S), B = n[S];
298
467
  if (!B)
299
468
  continue;
300
- let $;
301
- const w = a == null ? void 0 : a(B);
302
- w != null && w.backgroundColor ? $ = w.backgroundColor : $ = y % 2 === 0 ? "#FFFFFF" : l.grid.rowAlt, e.fillStyle = $, e.fillRect(0, D, t.canvasWidth, t.lineHeight), e.strokeStyle = (w == null ? void 0 : w.borderBottomColor) ?? l.grid.line, e.lineWidth = 0.5, e.beginPath(), e.moveTo(0, D + t.lineHeight), e.lineTo(t.canvasWidth, D + t.lineHeight), e.stroke();
469
+ let Y;
470
+ const x = l == null ? void 0 : l(B);
471
+ x != null && x.backgroundColor ? Y = x.backgroundColor : Y = S % 2 === 0 ? "#FFFFFF" : r.grid.rowAlt, e.fillStyle = Y, e.fillRect(0, _, t.canvasWidth, t.lineHeight), e.strokeStyle = (x == null ? void 0 : x.borderBottomColor) ?? r.grid.line, e.lineWidth = 0.5, e.beginPath(), e.moveTo(0, _ + t.lineHeight), e.lineTo(t.canvasWidth, _ + t.lineHeight), e.stroke();
303
472
  }
304
- if (m && m.length > 0)
305
- for (const y of m) {
306
- const D = t.timeToX(y.start), B = t.timeToX(y.end);
307
- if (B < 0 || D > t.canvasWidth)
473
+ if (u && u.length > 0)
474
+ for (const S of u) {
475
+ const _ = t.timeToX(S.start), B = t.timeToX(S.end);
476
+ if (B < 0 || _ > t.canvasWidth)
308
477
  continue;
309
- const $ = Math.max(0, D), w = Math.min(t.canvasWidth, B) - $, Y = y.opacity ?? 0.12, V = parseInt(y.color.slice(1, 3), 16), Z = parseInt(y.color.slice(3, 5), 16), ne = parseInt(y.color.slice(5, 7), 16);
310
- e.fillStyle = `rgb(${Math.round(V * Y + 255 * (1 - Y))},${Math.round(Z * Y + 255 * (1 - Y))},${Math.round(ne * Y + 255 * (1 - Y))})`, e.fillRect($, 0, w, t.canvasHeight);
478
+ const Y = Math.max(0, _), x = Math.min(t.canvasWidth, B) - Y, ne = S.opacity ?? 0.12, P = parseInt(S.color.slice(1, 3), 16), L = parseInt(S.color.slice(3, 5), 16), Z = parseInt(S.color.slice(5, 7), 16);
479
+ e.fillStyle = `rgb(${Math.round(P * ne + 255 * (1 - ne))},${Math.round(L * ne + 255 * (1 - ne))},${Math.round(Z * ne + 255 * (1 - ne))})`, e.fillRect(Y, 0, x, t.canvasHeight);
311
480
  }
312
- const T = t.visibleTimeStart, p = t.visibleTimeEnd, I = 864e5 / (p - T) * t.canvasWidth;
313
- let W = "day";
314
- I < 2 ? W = "month" : I < 8 && (W = "week");
481
+ const M = t.visibleTimeStart, g = t.visibleTimeEnd, C = 864e5 / (g - M) * t.canvasWidth;
482
+ let I = "day";
483
+ C < 2 ? I = "month" : C < 8 && (I = "week");
315
484
  {
316
- let y = me(T).startOf("day");
317
- const D = me(p).endOf("day");
318
- let B = null, $ = 1, w = 0;
319
- const Y = [], V = (Z) => {
320
- B !== null && (e.fillStyle = B, $ !== 1 && (e.globalAlpha = $), e.fillRect(w, 0, Z - w, t.canvasHeight), $ !== 1 && (e.globalAlpha = 1), B = null, $ = 1);
485
+ let S = pe(M).startOf("day");
486
+ const _ = pe(g).endOf("day");
487
+ let B = null, Y = 1, x = 0;
488
+ const ne = [], P = (L) => {
489
+ B !== null && (e.fillStyle = B, Y !== 1 && (e.globalAlpha = Y), e.fillRect(x, 0, L - x, t.canvasHeight), Y !== 1 && (e.globalAlpha = 1), B = null, Y = 1);
321
490
  };
322
- for (; y.isBefore(D); ) {
323
- const Z = t.timeToX(y.valueOf()), ne = y.toDate(), N = c == null ? void 0 : c(ne);
324
- let le = null, ve = 1;
325
- if (N != null && N.backgroundColor)
326
- le = N.backgroundColor, ve = N.opacity ?? 1;
491
+ for (; S.isBefore(_); ) {
492
+ const L = t.timeToX(S.valueOf()), Z = S.toDate(), K = d == null ? void 0 : d(Z);
493
+ let te = null, ue = 1;
494
+ if (K != null && K.backgroundColor)
495
+ te = K.backgroundColor, ue = K.opacity ?? 1;
327
496
  else {
328
- const fe = y.day();
329
- (fe === 0 || fe === 6) && (le = l.grid.weekend);
497
+ const ve = S.day();
498
+ (ve === 0 || ve === 6) && (te = r.grid.weekend);
330
499
  }
331
- N != null && N.borderColor && Y.push({ x: Z, color: N.borderColor }), le === B && ve === $ || (V(Z), le !== null && (B = le, $ = ve, w = Z)), y = y.add(1, "day");
500
+ K != null && K.borderColor && ne.push({ x: L, color: K.borderColor }), te === B && ue === Y || (P(L), te !== null && (B = te, Y = ue, x = L)), S = S.add(1, "day");
332
501
  }
333
- B !== null && V(t.timeToX(y.valueOf()));
334
- for (const Z of Y)
335
- e.strokeStyle = Z.color, e.lineWidth = 0.5, e.beginPath(), e.moveTo(Z.x, 0), e.lineTo(Z.x, t.canvasHeight), e.stroke();
502
+ B !== null && P(t.timeToX(S.valueOf()));
503
+ for (const L of ne)
504
+ e.strokeStyle = L.color, e.lineWidth = 0.5, e.beginPath(), e.moveTo(L.x, 0), e.lineTo(L.x, t.canvasHeight), e.stroke();
336
505
  }
337
- let L = me(T).startOf(W);
338
- const j = me(p).add(1, W);
339
- for (e.strokeStyle = l.grid.line, e.lineWidth = 0.5, e.beginPath(); L.isBefore(j); ) {
340
- const y = t.timeToX(L.valueOf());
341
- e.moveTo(y, 0), e.lineTo(y, t.canvasHeight), L = L.add(1, W);
506
+ let W = pe(M).startOf(I);
507
+ const $ = pe(g).add(1, I);
508
+ for (e.strokeStyle = r.grid.line, e.lineWidth = 0.5, e.beginPath(); W.isBefore($); ) {
509
+ const S = t.timeToX(W.valueOf());
510
+ e.moveTo(S, 0), e.lineTo(S, t.canvasHeight), W = W.add(1, I);
342
511
  }
343
- if (e.stroke(), m && m.length > 0)
344
- for (const y of m) {
345
- const D = t.timeToX(y.start), B = t.timeToX(y.end);
346
- if (!(B < 0 || D > t.canvasWidth) && (e.strokeStyle = y.color, e.globalAlpha = 0.4, e.lineWidth = 1, e.beginPath(), D >= 0 && D <= t.canvasWidth && (e.moveTo(D, 0), e.lineTo(D, t.canvasHeight)), B >= 0 && B <= t.canvasWidth && (e.moveTo(B, 0), e.lineTo(B, t.canvasHeight)), e.stroke(), e.globalAlpha = 1, y.label)) {
347
- const $ = Math.max(0, D), w = Math.min(t.canvasWidth, B) - $;
512
+ if (e.stroke(), u && u.length > 0)
513
+ for (const S of u) {
514
+ const _ = t.timeToX(S.start), B = t.timeToX(S.end);
515
+ if (!(B < 0 || _ > t.canvasWidth) && (e.strokeStyle = S.color, e.globalAlpha = 0.4, e.lineWidth = 1, e.beginPath(), _ >= 0 && _ <= t.canvasWidth && (e.moveTo(_, 0), e.lineTo(_, t.canvasHeight)), B >= 0 && B <= t.canvasWidth && (e.moveTo(B, 0), e.lineTo(B, t.canvasHeight)), e.stroke(), e.globalAlpha = 1, S.label)) {
516
+ const Y = Math.max(0, _), x = Math.min(t.canvasWidth, B) - Y;
348
517
  e.save(), e.font = '600 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
349
- const Y = e.measureText(y.label).width, V = 6, Z = Y + V * 2, ne = 18, N = $ + (w - Z) / 2, le = 4;
350
- e.fillStyle = y.color, e.globalAlpha = 0.9, e.beginPath(), e.roundRect(N, le, Z, ne, 3), e.fill(), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.fillText(y.label, N + V, le + ne / 2), e.restore();
518
+ const ne = e.measureText(S.label).width, P = 6, L = ne + P * 2, Z = 18, K = Y + (x - L) / 2, te = 4;
519
+ e.fillStyle = S.color, e.globalAlpha = 0.9, e.beginPath(), e.roundRect(K, te, L, Z, 3), e.fill(), e.globalAlpha = 1, e.fillStyle = "#FFFFFF", e.textBaseline = "middle", e.fillText(S.label, K + P, te + Z / 2), e.restore();
351
520
  }
352
521
  }
353
522
  }
354
523
  }
355
- const Dt = '500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
356
- function Lt(i, e) {
524
+ const Ot = '500 12px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
525
+ function Yt(i, e) {
357
526
  return {
358
527
  /**
359
528
  * Draws a filled rounded rectangle.
360
529
  * Default corner radius is 3px.
361
530
  */
362
- roundRect(t, s, l, c, a = 3) {
363
- i.beginPath(), i.roundRect(t, s, l, c, a), i.fill();
531
+ roundRect(t, n, r, d, l = 3) {
532
+ i.beginPath(), i.roundRect(t, n, r, d, l), i.fill();
364
533
  },
365
534
  /**
366
535
  * Draws text at (x, y) using the standard item font.
367
536
  * If maxWidth is provided and the text is too wide, binary-search truncates it
368
537
  * and appends '...' so it fits within maxWidth.
369
538
  */
370
- fillText(t, s, l, c) {
371
- if (i.font = Dt, c !== void 0 && i.measureText(t).width > c) {
372
- let a = 0, m = t.length;
373
- for (; a < m; ) {
374
- const u = Math.ceil((a + m) / 2), v = t.slice(0, u) + "...";
375
- i.measureText(v).width <= c ? a = u : m = u - 1;
539
+ fillText(t, n, r, d) {
540
+ if (i.font = Ot, d !== void 0 && i.measureText(t).width > d) {
541
+ let l = 0, u = t.length;
542
+ for (; l < u; ) {
543
+ const c = Math.ceil((l + u) / 2), v = t.slice(0, c) + "...";
544
+ i.measureText(v).width <= d ? l = c : u = c - 1;
376
545
  }
377
- i.fillText(t.slice(0, a) + "...", s, l);
546
+ i.fillText(t.slice(0, l) + "...", n, r);
378
547
  } else
379
- i.fillText(t, s, l);
548
+ i.fillText(t, n, r);
380
549
  },
381
550
  /**
382
551
  * Creates a 50/50 linear gradient from color1 (0%–50%) to color2 (50%–100%)
383
552
  * spanning the given x position and width.
384
553
  */
385
- gradient(t, s, l, c) {
386
- const a = i.createLinearGradient(t, 0, t + s, 0);
387
- return a.addColorStop(0, l), a.addColorStop(0.5, l), a.addColorStop(0.5, c), a.addColorStop(1, c), a;
554
+ gradient(t, n, r, d) {
555
+ const l = i.createLinearGradient(t, 0, t + n, 0);
556
+ return l.addColorStop(0, r), l.addColorStop(0.5, r), l.addColorStop(0.5, d), l.addColorStop(1, d), l;
388
557
  },
389
558
  /**
390
559
  * Draws a vertical colored bar on the left edge of the item bounds.
391
560
  * Does nothing if no bounds were provided.
392
561
  */
393
- leftBar(t, s = 3) {
394
- e && (i.save(), i.fillStyle = t, i.fillRect(e.x, e.y, s, e.height), i.restore());
562
+ leftBar(t, n = 3) {
563
+ e && (i.save(), i.fillStyle = t, i.fillRect(e.x, e.y, n, e.height), i.restore());
395
564
  },
396
565
  /**
397
566
  * Draws a vector icon centered at (x, y).
398
567
  * Supported types: 'check', 'danger-red', 'danger-yellow'.
399
568
  * Default size is 14px.
400
569
  */
401
- icon(t, s, l, c = 14) {
570
+ icon(t, n, r, d = 14) {
402
571
  i.save();
403
- const a = c / 2;
572
+ const l = d / 2;
404
573
  if (t === "check") {
405
- i.fillStyle = "#31c48d", i.beginPath(), i.arc(s + a, l + a, a, 0, Math.PI * 2), i.fill(), i.strokeStyle = "#ffffff", i.lineWidth = c * 0.12, i.beginPath();
406
- const m = s + a, u = l + a;
407
- i.moveTo(m - a * 0.45, u), i.lineTo(m - a * 0.1, u + a * 0.42), i.lineTo(m + a * 0.45, u - a * 0.35), i.stroke();
574
+ i.fillStyle = "#31c48d", i.beginPath(), i.arc(n + l, r + l, l, 0, Math.PI * 2), i.fill(), i.strokeStyle = "#ffffff", i.lineWidth = d * 0.12, i.beginPath();
575
+ const u = n + l, c = r + l;
576
+ i.moveTo(u - l * 0.45, c), i.lineTo(u - l * 0.1, c + l * 0.42), i.lineTo(u + l * 0.45, c - l * 0.35), i.stroke();
408
577
  } else if (t === "danger-red" || t === "danger-yellow") {
409
- const m = t === "danger-red" ? "#EF5350" : "#FBBF24";
410
- i.fillStyle = m, i.beginPath(), i.moveTo(s + a, l), i.lineTo(s + c, l + c), i.lineTo(s, l + c), i.closePath(), i.fill(), i.fillStyle = "#ffffff";
411
- const u = c * 0.12, v = s + a - u / 2;
412
- i.fillRect(v, l + c * 0.35, u, c * 0.35), i.beginPath(), i.arc(s + a, l + c * 0.82, u * 0.7, 0, Math.PI * 2), i.fill();
578
+ const u = t === "danger-red" ? "#EF5350" : "#FBBF24";
579
+ i.fillStyle = u, i.beginPath(), i.moveTo(n + l, r), i.lineTo(n + d, r + d), i.lineTo(n, r + d), i.closePath(), i.fill(), i.fillStyle = "#ffffff";
580
+ const c = d * 0.12, v = n + l - c / 2;
581
+ i.fillRect(v, r + d * 0.35, c, d * 0.35), i.beginPath(), i.arc(n + l, r + d * 0.82, c * 0.7, 0, Math.PI * 2), i.fill();
413
582
  }
414
583
  i.restore();
415
584
  },
416
585
  /**
417
586
  * Draws a pill-shaped badge with centered white text on a colored background.
418
587
  */
419
- badge(t, s, l, c) {
420
- i.save(), i.font = Dt;
421
- const m = i.measureText(t).width, u = 8, T = 12 + 3 * 2, p = m + u * 2, H = T / 2;
422
- i.fillStyle = c, i.beginPath(), i.roundRect(s, l, p, T, H), i.fill(), i.fillStyle = "#ffffff", i.textAlign = "center", i.textBaseline = "middle", i.fillText(t, s + p / 2, l + T / 2), i.restore();
588
+ badge(t, n, r, d) {
589
+ i.save(), i.font = Ot;
590
+ const u = i.measureText(t).width, c = 8, M = 12 + 3 * 2, g = u + c * 2, b = M / 2;
591
+ i.fillStyle = d, i.beginPath(), i.roundRect(n, r, g, M, b), i.fill(), i.fillStyle = "#ffffff", i.textAlign = "center", i.textBaseline = "middle", i.fillText(t, n + g / 2, r + M / 2), i.restore();
423
592
  }
424
593
  };
425
594
  }
426
- class fi {
427
- draw(e, t, s, l, c, a, m, u, v, T, p, H) {
428
- const S = (t.visibleTimeEnd - t.visibleTimeStart) * 0.1, I = t.visibleTimeStart - S, W = t.visibleTimeEnd + S, L = c.query(I, W), j = /* @__PURE__ */ new Map();
429
- for (let w = 0; w < s.length; w++)
430
- j.set(s[w].id, w);
431
- const y = new Set(T), D = /* @__PURE__ */ new Map(), B = -t.lineHeight, $ = t.canvasHeight + t.lineHeight;
432
- for (const w of L) {
433
- const Y = j.get(w.group);
434
- if (Y === void 0)
595
+ class bi {
596
+ draw(e, t, n, r, d, l, u, c, v, M, g, b, T, C) {
597
+ const I = (t.visibleTimeEnd - t.visibleTimeStart) * 0.1, W = t.visibleTimeStart - I, $ = t.visibleTimeEnd + I, S = d.query(W, $), _ = /* @__PURE__ */ new Map();
598
+ for (let P = 0; P < n.length; P++)
599
+ _.set(n[P].id, P);
600
+ const B = new Set(M), Y = /* @__PURE__ */ new Map(), x = -t.lineHeight, ne = t.canvasHeight + t.lineHeight;
601
+ for (const P of S) {
602
+ const L = _.get(P.group);
603
+ if (L === void 0)
435
604
  continue;
436
- const V = a.getLayout(w.id);
437
- if (!V)
605
+ const Z = l.getLayout(P.id);
606
+ if (!Z)
438
607
  continue;
439
- const ne = t.groupIndexToY(Y) + V.stackLevel * t.lineHeight + (t.lineHeight - V.itemHeight) / 2, N = V.itemHeight;
440
- if (ne + N < B || ne > $)
608
+ const te = t.groupIndexToY(L) + Z.stackLevel * t.lineHeight + (t.lineHeight - Z.itemHeight) / 2, ue = Z.itemHeight;
609
+ if (te + ue < x || te > ne)
441
610
  continue;
442
- const le = t.timeToX(w.start_time), ve = t.timeToX(w.end_time) - le, fe = { x: le, y: ne, width: ve, height: N };
443
- D.set(w.id, fe);
444
- const Me = {
445
- selected: y.has(w.id),
446
- hovered: p === w.id,
611
+ const ve = t.timeToX(P.start_time), He = t.timeToX(P.end_time) - ve, be = { x: ve, y: te, width: He, height: ue };
612
+ Y.set(P.id, be);
613
+ const Ie = {
614
+ selected: B.has(P.id),
615
+ hovered: g === P.id,
447
616
  dragging: !1,
448
- filtered: w.filtered !== !1
617
+ filtered: P.filtered !== !1
449
618
  };
450
619
  e.save();
451
- const We = Lt(e, fe);
452
- (u && (w.type === "control_area_group" || w.type === "construction_train") ? u : m)(e, w, fe, Me, We), e.restore();
620
+ const Ae = Yt(e, be);
621
+ let Ee;
622
+ T && (C != null && C.isParent(P.id)) ? Ee = T : c && (P.type === "control_area_group" || P.type === "construction_train") ? Ee = c : Ee = u, Ee(e, P, be, Ie, Ae), e.restore();
453
623
  }
454
- if (H && H.length > 0) {
455
- const w = /* @__PURE__ */ new Set();
456
- for (const Y of H)
457
- D.has(Y.fromItemId) || w.add(Y.fromItemId), D.has(Y.toItemId) || w.add(Y.toItemId);
458
- if (w.size > 0) {
459
- const Y = /* @__PURE__ */ new Map();
460
- for (const V of l)
461
- w.has(V.id) && Y.set(V.id, V);
462
- for (const [V, Z] of Y) {
463
- const ne = j.get(Z.group);
464
- if (ne === void 0)
624
+ if (b && b.length > 0) {
625
+ const P = /* @__PURE__ */ new Set();
626
+ for (const L of b)
627
+ Y.has(L.fromItemId) || P.add(L.fromItemId), Y.has(L.toItemId) || P.add(L.toItemId);
628
+ if (P.size > 0) {
629
+ const L = /* @__PURE__ */ new Map();
630
+ for (const Z of r)
631
+ P.has(Z.id) && L.set(Z.id, Z);
632
+ for (const [Z, K] of L) {
633
+ const te = _.get(K.group);
634
+ if (te === void 0)
465
635
  continue;
466
- const N = a.getLayout(V);
467
- if (!N)
636
+ const ue = l.getLayout(Z);
637
+ if (!ue)
468
638
  continue;
469
- const ve = t.groupIndexToY(ne) + N.stackLevel * t.lineHeight + (t.lineHeight - N.itemHeight) / 2, fe = t.timeToX(Z.start_time), Me = t.timeToX(Z.end_time) - fe;
470
- D.set(V, { x: fe, y: ve, width: Me, height: N.itemHeight });
639
+ const He = t.groupIndexToY(te) + ue.stackLevel * t.lineHeight + (t.lineHeight - ue.itemHeight) / 2, be = t.timeToX(K.start_time), Ie = t.timeToX(K.end_time) - be;
640
+ Y.set(Z, { x: be, y: He, width: Ie, height: ue.itemHeight });
471
641
  }
472
642
  }
473
- this.drawDependencies(e, H, D, p, v);
643
+ this.drawDependencies(e, b, Y, g, v);
474
644
  }
475
645
  }
476
- drawDependencies(e, t, s, l, c) {
477
- for (const a of t) {
478
- const m = s.get(a.fromItemId), u = s.get(a.toItemId);
479
- if (!m || !u)
646
+ drawDependencies(e, t, n, r, d) {
647
+ for (const l of t) {
648
+ const u = n.get(l.fromItemId), c = n.get(l.toItemId);
649
+ if (!u || !c)
480
650
  continue;
481
- const v = l === a.fromItemId || l === a.toItemId;
482
- e.strokeStyle = v ? c.primary : a.color ?? "#94A3B8", e.lineWidth = v ? 2 : 1.5, e.setLineDash([]);
483
- const T = m.x + m.width, p = m.y + m.height / 2, H = u.x, S = u.y + u.height / 2, I = Math.abs(H - T), W = Math.max(I * 0.4, 30);
484
- e.beginPath(), e.moveTo(T, p), e.bezierCurveTo(T + W, p, H - W, S, H, S), e.stroke();
485
- const L = 6;
486
- e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(H, S), e.lineTo(H - L, S - L / 2), e.lineTo(H - L, S + L / 2), e.closePath(), e.fill();
651
+ const v = r === l.fromItemId || r === l.toItemId;
652
+ e.strokeStyle = v ? d.primary : l.color ?? "#94A3B8", e.lineWidth = v ? 2 : 1.5, e.setLineDash([]);
653
+ const M = u.x + u.width, g = u.y + u.height / 2, b = c.x, T = c.y + c.height / 2, C = Math.abs(b - M), I = Math.max(C * 0.4, 30);
654
+ e.beginPath(), e.moveTo(M, g), e.bezierCurveTo(M + I, g, b - I, T, b, T), e.stroke();
655
+ const W = 6;
656
+ e.fillStyle = e.strokeStyle, e.beginPath(), e.moveTo(b, T), e.lineTo(b - W, T - W / 2), e.lineTo(b - W, T + W / 2), e.closePath(), e.fill();
487
657
  }
488
658
  }
489
659
  }
490
- class mi {
491
- draw(e, t, s, l) {
492
- const { cursorX: c, snapX: a, markers: m, interaction: u } = l;
493
- if (m)
494
- for (const v of m) {
495
- const T = t.timeToX(v.date);
496
- if (e.fillStyle = v.color, e.fillRect(T - v.width / 2, 0, v.width, t.canvasHeight), v.label) {
660
+ class yi {
661
+ draw(e, t, n, r) {
662
+ const { cursorX: d, snapX: l, markers: u, interaction: c } = r;
663
+ if (u)
664
+ for (const v of u) {
665
+ const M = t.timeToX(v.date);
666
+ if (e.fillStyle = v.color, e.fillRect(M - v.width / 2, 0, v.width, t.canvasHeight), v.label) {
497
667
  e.save(), e.font = '500 10px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
498
- const p = e.measureText(v.label).width, H = 8, S = 200, I = Math.min(p + H * 2, S), W = 20, L = T - I / 2, j = 4;
499
- e.fillStyle = v.color, e.beginPath(), e.roundRect(L, j, I, W, 3), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle";
500
- const y = S - H * 2, D = p > y ? v.label.slice(0, Math.floor(v.label.length * y / p)) + "…" : v.label;
501
- e.fillText(D, L + H, j + W / 2), e.restore();
668
+ const g = e.measureText(v.label).width, b = 8, T = 200, C = Math.min(g + b * 2, T), I = 20, W = M - C / 2, $ = 4;
669
+ e.fillStyle = v.color, e.beginPath(), e.roundRect(W, $, C, I, 3), e.fill(), e.fillStyle = "#FFFFFF", e.textBaseline = "middle";
670
+ const S = T - b * 2, _ = g > S ? v.label.slice(0, Math.floor(v.label.length * S / g)) + "…" : v.label;
671
+ e.fillText(_, W + b, $ + I / 2), e.restore();
502
672
  }
503
673
  }
504
- if (c != null && (e.strokeStyle = s.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(c, 0), e.lineTo(c, t.canvasHeight), e.stroke()), a != null && (e.strokeStyle = s.primary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(a, 0), e.lineTo(a, t.canvasHeight), e.stroke(), e.setLineDash([])), u) {
505
- u.groupChanged && u.targetGroupY !== void 0 && (e.fillStyle = "rgba(59, 130, 246, 0.08)", e.fillRect(0, u.targetGroupY, t.canvasWidth, t.lineHeight)), e.save(), e.globalAlpha = 0.5;
506
- const v = Lt(e, u.bounds);
507
- u.renderer(e, u.item, u.bounds, { selected: !1, hovered: !1, dragging: !0, filtered: !0 }, v), e.restore();
674
+ if (d != null && (e.strokeStyle = n.marker.cursor, e.lineWidth = 1, e.beginPath(), e.moveTo(d, 0), e.lineTo(d, t.canvasHeight), e.stroke()), l != null && (e.strokeStyle = n.primary, e.lineWidth = 1, e.setLineDash([4, 4]), e.beginPath(), e.moveTo(l, 0), e.lineTo(l, t.canvasHeight), e.stroke(), e.setLineDash([])), c) {
675
+ c.groupChanged && c.targetGroupY !== void 0 && (e.fillStyle = "rgba(59, 130, 246, 0.08)", e.fillRect(0, c.targetGroupY, t.canvasWidth, t.lineHeight)), e.save(), e.globalAlpha = 0.5;
676
+ const v = Yt(e, c.bounds);
677
+ c.renderer(e, c.item, c.bounds, { selected: !1, hovered: !1, dragging: !0, filtered: !0 }, v), e.restore();
508
678
  }
509
679
  }
510
680
  }
511
- const Pt = 120;
512
- function gi(i) {
681
+ const _t = 120;
682
+ function Ti(i) {
513
683
  let e = i.deltaY || i.deltaX;
514
- return i.deltaMode === 1 ? e *= 15 : i.deltaMode === 2 && (e *= 800), Math.max(-Pt, Math.min(Pt, e));
684
+ return i.deltaMode === 1 ? e *= 15 : i.deltaMode === 2 && (e *= 800), Math.max(-_t, Math.min(_t, e));
515
685
  }
516
- class vi {
517
- constructor(e, t, s, l, c) {
686
+ class Si {
687
+ constructor(e, t, n, r, d) {
518
688
  Object.defineProperty(this, "onZoom", {
519
689
  enumerable: !0,
520
690
  configurable: !0,
@@ -540,21 +710,21 @@ class vi {
540
710
  configurable: !0,
541
711
  writable: !0,
542
712
  value: void 0
543
- }), this.onZoom = e, this.visibleTimeStart = t, this.visibleTimeEnd = s, this.minZoom = l, this.maxZoom = c;
713
+ }), this.onZoom = e, this.visibleTimeStart = t, this.visibleTimeEnd = n, this.minZoom = r, this.maxZoom = d;
544
714
  }
545
715
  updateBounds(e, t) {
546
716
  this.visibleTimeStart = e, this.visibleTimeEnd = t;
547
717
  }
548
718
  handleWheelZoom(e, t) {
549
- const s = gi(e), l = e.ctrlKey ? 10 : e.metaKey ? 3 : 1, c = s > 0 ? 1 + l * s / 500 : 1 / (1 + l * -s / 500), a = this.visibleTimeEnd - this.visibleTimeStart;
550
- let m = Math.round(a * c);
551
- m = Math.max(this.minZoom, Math.min(this.maxZoom, m));
552
- const u = Math.round(this.visibleTimeStart + (a - m) * t), v = u + m;
553
- this.onZoom(u, v);
719
+ const n = Ti(e), r = e.ctrlKey ? 10 : e.metaKey ? 3 : 1, d = n > 0 ? 1 + r * n / 500 : 1 / (1 + r * -n / 500), l = this.visibleTimeEnd - this.visibleTimeStart;
720
+ let u = Math.round(l * d);
721
+ u = Math.max(this.minZoom, Math.min(this.maxZoom, u));
722
+ const c = Math.round(this.visibleTimeStart + (l - u) * t), v = c + u;
723
+ this.onZoom(c, v);
554
724
  }
555
725
  }
556
- const bi = 4;
557
- class pi {
726
+ const ki = 4;
727
+ class Mi {
558
728
  constructor(e) {
559
729
  Object.defineProperty(this, "state", {
560
730
  enumerable: !0,
@@ -573,21 +743,21 @@ class pi {
573
743
  value: !1
574
744
  }), this.dragSnap = e;
575
745
  }
576
- startInteraction(e, t, s, l) {
746
+ startInteraction(e, t, n, r) {
577
747
  this.state = {
578
748
  item: e,
579
749
  mode: t,
580
- startX: s,
581
- startY: l,
582
- currentX: s,
583
- currentY: l,
750
+ startX: n,
751
+ startY: r,
752
+ currentX: n,
753
+ currentY: r,
584
754
  deltaX: 0,
585
755
  originalGroup: e.group,
586
756
  currentGroup: e.group
587
757
  }, this.activated = !1;
588
758
  }
589
759
  update(e, t) {
590
- this.state && (this.state.currentX = e, this.state.currentY = t, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >= bi && (this.activated = !0));
760
+ this.state && (this.state.currentX = e, this.state.currentY = t, this.state.deltaX = e - this.state.startX, !this.activated && Math.abs(this.state.deltaX) >= ki && (this.activated = !0));
591
761
  }
592
762
  setCurrentGroup(e) {
593
763
  this.state && (this.state.currentGroup = e);
@@ -595,14 +765,14 @@ class pi {
595
765
  endMove(e) {
596
766
  if (!this.state)
597
767
  return null;
598
- const t = this.state.deltaX / e, s = this.state.item.start_time + t, l = Math.round(s / this.dragSnap) * this.dragSnap, c = this.state.currentGroup;
599
- return this.state = null, this.activated = !1, { newStartTime: l, newGroupId: c };
768
+ const t = this.state.deltaX / e, n = this.state.item.start_time + t, r = Math.round(n / this.dragSnap) * this.dragSnap, d = this.state.currentGroup;
769
+ return this.state = null, this.activated = !1, { newStartTime: r, newGroupId: d };
600
770
  }
601
771
  endResize(e) {
602
772
  if (!this.state)
603
773
  return null;
604
- const t = this.state.deltaX / e, s = this.state.mode === "resize-left" ? "left" : "right", c = (s === "left" ? this.state.item.start_time : this.state.item.end_time) + t, a = Math.round(c / this.dragSnap) * this.dragSnap;
605
- return this.state = null, this.activated = !1, { newTime: a, edge: s };
774
+ const t = this.state.deltaX / e, n = this.state.mode === "resize-left" ? "left" : "right", d = (n === "left" ? this.state.item.start_time : this.state.item.end_time) + t, l = Math.round(d / this.dragSnap) * this.dragSnap;
775
+ return this.state = null, this.activated = !1, { newTime: l, edge: n };
606
776
  }
607
777
  cancel() {
608
778
  this.state = null, this.activated = !1;
@@ -621,105 +791,105 @@ class pi {
621
791
  return this.state !== null;
622
792
  }
623
793
  }
624
- function at(i, e, t) {
625
- const s = [];
626
- for (const l of i)
627
- l.id !== e && (s.push(t(l.start_time)), s.push(t(l.end_time)));
628
- return s;
794
+ function dt(i, e, t) {
795
+ const n = [];
796
+ for (const r of i)
797
+ r.id !== e && (n.push(t(r.start_time)), n.push(t(r.end_time)));
798
+ return n;
629
799
  }
630
- function $e(i, e, t, s, l) {
800
+ function Ve(i, e, t, n, r) {
631
801
  if (e.length === 0)
632
802
  return null;
633
- let c = e[0], a = Math.abs(i - c);
634
- for (let m = 1; m < e.length; m++) {
635
- const u = Math.abs(i - e[m]);
636
- u < a && (a = u, c = e[m]);
803
+ let d = e[0], l = Math.abs(i - d);
804
+ for (let u = 1; u < e.length; u++) {
805
+ const c = Math.abs(i - e[u]);
806
+ c < l && (l = c, d = e[u]);
637
807
  }
638
- return a <= t ? c : null;
808
+ return l <= t ? d : null;
639
809
  }
640
- var At = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
641
- function Yt(i) {
810
+ var jt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
811
+ function Nt(i) {
642
812
  return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
643
813
  }
644
- var jt = { exports: {} };
814
+ var $t = { exports: {} };
645
815
  (function(i, e) {
646
- (function(t, s) {
647
- i.exports = s();
648
- })(At, function() {
816
+ (function(t, n) {
817
+ i.exports = n();
818
+ })(jt, function() {
649
819
  var t = "day";
650
- return function(s, l, c) {
651
- var a = function(v) {
820
+ return function(n, r, d) {
821
+ var l = function(v) {
652
822
  return v.add(4 - v.isoWeekday(), t);
653
- }, m = l.prototype;
654
- m.isoWeekYear = function() {
655
- return a(this).year();
656
- }, m.isoWeek = function(v) {
823
+ }, u = r.prototype;
824
+ u.isoWeekYear = function() {
825
+ return l(this).year();
826
+ }, u.isoWeek = function(v) {
657
827
  if (!this.$utils().u(v)) return this.add(7 * (v - this.isoWeek()), t);
658
- var T, p, H, S, I = a(this), W = (T = this.isoWeekYear(), p = this.$u, H = (p ? c.utc : c)().year(T).startOf("year"), S = 4 - H.isoWeekday(), H.isoWeekday() > 4 && (S += 7), H.add(S, t));
659
- return I.diff(W, "week") + 1;
660
- }, m.isoWeekday = function(v) {
828
+ var M, g, b, T, C = l(this), I = (M = this.isoWeekYear(), g = this.$u, b = (g ? d.utc : d)().year(M).startOf("year"), T = 4 - b.isoWeekday(), b.isoWeekday() > 4 && (T += 7), b.add(T, t));
829
+ return C.diff(I, "week") + 1;
830
+ }, u.isoWeekday = function(v) {
661
831
  return this.$utils().u(v) ? this.day() || 7 : this.day(this.day() % 7 ? v : v - 7);
662
832
  };
663
- var u = m.startOf;
664
- m.startOf = function(v, T) {
665
- var p = this.$utils(), H = !!p.u(T) || T;
666
- return p.p(v) === "isoweek" ? H ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : u.bind(this)(v, T);
833
+ var c = u.startOf;
834
+ u.startOf = function(v, M) {
835
+ var g = this.$utils(), b = !!g.u(M) || M;
836
+ return g.p(v) === "isoweek" ? b ? this.date(this.date() - (this.isoWeekday() - 1)).startOf("day") : this.date(this.date() - 1 - (this.isoWeekday() - 1) + 7).endOf("day") : c.bind(this)(v, M);
667
837
  };
668
838
  };
669
839
  });
670
- })(jt);
671
- var yi = jt.exports;
672
- const Ti = /* @__PURE__ */ Yt(yi), Xt = 5;
673
- function Ft({ groups: i, width: e, lineHeight: t, scrollTop: s, canvasHeight: l, theme: c, groupRenderer: a, onScroll: m }) {
674
- var L;
675
- const u = z(null), v = z(!1), T = i.length * t, p = l, H = Math.max(0, Math.floor(s / t) - Xt), S = Math.min(i.length - 1, Math.ceil((s + l) / t) + Xt), I = ee((j) => {
676
- v.current || m(j.currentTarget.scrollTop);
677
- }, [m]);
678
- ue(() => {
679
- u.current && (v.current = !0, u.current.scrollTop = s, requestAnimationFrame(() => {
840
+ })($t);
841
+ var wi = $t.exports;
842
+ const Ei = /* @__PURE__ */ Nt(wi), Ft = 5;
843
+ function Wt({ groups: i, width: e, lineHeight: t, scrollTop: n, canvasHeight: r, theme: d, groupRenderer: l, onScroll: u }) {
844
+ var W;
845
+ const c = z(null), v = z(!1), M = i.length * t, g = r, b = Math.max(0, Math.floor(n / t) - Ft), T = Math.min(i.length - 1, Math.ceil((n + r) / t) + Ft), C = ie(($) => {
846
+ v.current || u($.currentTarget.scrollTop);
847
+ }, [u]);
848
+ he(() => {
849
+ c.current && (v.current = !0, c.current.scrollTop = n, requestAnimationFrame(() => {
680
850
  v.current = !1;
681
851
  }));
682
- }, [s]);
683
- const W = [];
684
- for (let j = H; j <= S; j++) {
685
- const y = i[j];
686
- y && W.push(re("div", { style: {
852
+ }, [n]);
853
+ const I = [];
854
+ for (let $ = b; $ <= T; $++) {
855
+ const S = i[$];
856
+ S && I.push(se("div", { style: {
687
857
  position: "absolute",
688
- top: j * t,
858
+ top: $ * t,
689
859
  height: t,
690
860
  width: "100%",
691
861
  overflow: "hidden",
692
862
  display: "flex",
693
863
  alignItems: "stretch",
694
- borderBottom: `1px solid ${((L = c.grid) == null ? void 0 : L.line) ?? "#E5E5E5"}`,
864
+ borderBottom: `1px solid ${((W = d.grid) == null ? void 0 : W.line) ?? "#E5E5E5"}`,
695
865
  boxSizing: "border-box"
696
- }, children: a(y) }, y.id));
866
+ }, children: l(S) }, S.id));
697
867
  }
698
- return re("div", { ref: u, onScroll: I, style: {
868
+ return se("div", { ref: c, onScroll: C, style: {
699
869
  width: e,
700
- height: p,
701
- overflowY: T > l ? "auto" : "hidden",
870
+ height: g,
871
+ overflowY: M > r ? "auto" : "hidden",
702
872
  overflowX: "hidden",
703
873
  position: "relative",
704
- borderRight: `1px solid ${c.sidebar.border}`,
705
- backgroundColor: c.sidebar.bg
706
- }, children: re("div", { style: { height: T, position: "relative" }, children: W }) });
874
+ borderRight: `1px solid ${d.sidebar.border}`,
875
+ backgroundColor: d.sidebar.bg
876
+ }, children: se("div", { style: { height: M, position: "relative" }, children: I }) });
707
877
  }
708
- function ki(i) {
878
+ function Ci(i) {
709
879
  return null;
710
880
  }
711
- ki.displayName = "TodayMarker";
712
- function Ot(i) {
881
+ Ci.displayName = "TodayMarker";
882
+ function Xt(i) {
713
883
  return { date: Math.floor(Date.now() / 6e4) * 6e4, color: i.color ?? "#FD7171", width: i.width ?? 6, label: i.label };
714
884
  }
715
- function Si(i) {
885
+ function Hi(i) {
716
886
  return i.interval ?? 1e4;
717
887
  }
718
- function Ei(i) {
888
+ function Ii(i) {
719
889
  return null;
720
890
  }
721
- Ei.displayName = "CustomMarker";
722
- function Wt(i) {
891
+ Ii.displayName = "CustomMarker";
892
+ function Bt(i) {
723
893
  return {
724
894
  date: i.date,
725
895
  color: i.color ?? "#3B82F6",
@@ -727,550 +897,563 @@ function Wt(i) {
727
897
  label: i.label
728
898
  };
729
899
  }
730
- me.extend(Ti);
731
- function Mi(i) {
900
+ pe.extend(Ei);
901
+ function Ri(i) {
732
902
  return i ? {
733
- ...Se,
903
+ ...we,
734
904
  ...i,
735
- status: { ...Se.status, ...i.status },
736
- grid: { ...Se.grid, ...i.grid },
737
- item: { ...Se.item, ...i.item },
738
- marker: { ...Se.marker, ...i.marker },
739
- sidebar: { ...Se.sidebar, ...i.sidebar },
740
- header: { ...Se.header, ...i.header }
741
- } : Se;
905
+ status: { ...we.status, ...i.status },
906
+ grid: { ...we.grid, ...i.grid },
907
+ item: { ...we.item, ...i.item },
908
+ marker: { ...we.marker, ...i.marker },
909
+ sidebar: { ...we.sidebar, ...i.sidebar },
910
+ header: { ...we.header, ...i.header }
911
+ } : we;
742
912
  }
743
- const Bt = 32, Li = he.memo(si(function(e, t) {
744
- const { groups: s, items: l, defaultTimeStart: c, defaultTimeEnd: a, sidebarWidth: m, lineHeight: u, itemHeightRatio: v, stackItems: T, canMove: p, canChangeGroup: H, canResize: S, dragSnap: I, minZoom: W, maxZoom: L, theme: j, dayStyle: y, rowStyle: D, showCursorLine: B, itemRenderer: $, groupRenderer: w, sidebarGroupRenderer: Y, dependencies: V, highlights: Z, onItemClick: ne, onItemDoubleClick: N, onItemContextMenu: le, onItemMove: ve, onItemResize: fe, moveResizeValidator: Me, onItemHover: We, onCanvasDoubleClick: Ge, onCanvasContextMenu: ct, onTimeChange: ut, onZoom: dt, selected: ht = [], rightSidebarWidth: ze, rightSidebarGroupRenderer: ft, onReady: Be, children: be } = e, Ee = ce(() => Mi(j), [j]), mt = ee((o, r) => {
745
- for (let d = 0; d < r.length; d++)
746
- if (r[d].id === o)
747
- return d;
913
+ const Lt = 32, $i = ge.memo(ci(function(e, t) {
914
+ const { groups: n, items: r, defaultTimeStart: d, defaultTimeEnd: l, sidebarWidth: u, lineHeight: c, itemHeightRatio: v, stackItems: M, canMove: g, canChangeGroup: b, canResize: T, dragSnap: C, minZoom: I, maxZoom: W, theme: $, dayStyle: S, rowStyle: _, showCursorLine: B, itemRenderer: Y, groupRenderer: x, sidebarGroupRenderer: ne, dependencies: P, highlights: L, onItemClick: Z, onItemDoubleClick: K, onItemContextMenu: te, onItemMove: ue, onItemResize: ve, moveResizeValidator: He, onItemHover: be, onCanvasDoubleClick: Ie, onCanvasContextMenu: Ae, onTimeChange: Ee, onZoom: ht, selected: ft = [], rightSidebarWidth: qe, rightSidebarGroupRenderer: mt, onReady: Ye, children: Te } = e, ye = oe(() => Ri($), [$]), gt = ie((a, o) => {
915
+ for (let h = 0; h < o.length; h++)
916
+ if (o[h].id === a)
917
+ return h;
748
918
  return 0;
749
- }, []), $t = ht.join(","), Ve = ce(() => ht, [$t]), gt = z(null), vt = z(null), bt = z(null), Re = z(null), pt = z(null), Nt = z(null), [Gt, zt] = xe(800);
750
- ue(() => {
751
- const o = pt.current;
752
- if (!o)
919
+ }, []), zt = ft.join(","), Ue = oe(() => ft, [zt]), pt = z(null), vt = z(null), bt = z(null), _e = z(null), yt = z(null), xt = z(null), [Vt, Zt] = xe(800);
920
+ he(() => {
921
+ const a = yt.current;
922
+ if (!a)
753
923
  return;
754
- const r = new ResizeObserver((d) => {
755
- const h = d[0];
756
- h && zt(h.contentRect.width);
924
+ const o = new ResizeObserver((h) => {
925
+ const f = h[0];
926
+ f && Zt(f.contentRect.width);
757
927
  });
758
- return r.observe(o), () => r.disconnect();
928
+ return o.observe(a), () => o.disconnect();
759
929
  }, []);
760
- const pe = Math.max(0, Gt - m - (ze ?? 0)), ye = s.length * u, R = z(new nt({
761
- visibleTimeStart: e.visibleTimeStart ?? c,
762
- visibleTimeEnd: e.visibleTimeEnd ?? a,
763
- canvasWidth: pe,
764
- canvasHeight: ye,
765
- sidebarWidth: m,
766
- lineHeight: u,
767
- groupCount: s.length,
930
+ const Se = Math.max(0, Vt - u - (qe ?? 0)), ke = n.length * c, D = z(new lt({
931
+ visibleTimeStart: e.visibleTimeStart ?? d,
932
+ visibleTimeEnd: e.visibleTimeEnd ?? l,
933
+ canvasWidth: Se,
934
+ canvasHeight: ke,
935
+ sidebarWidth: u,
936
+ lineHeight: c,
937
+ groupCount: n.length,
768
938
  buffer: e.buffer ?? 3,
769
939
  scrollTop: 0
770
- })), Ze = z(null), De = z(void 0), [yt, Vt] = xe(e.visibleTimeStart ?? c), [Tt, Zt] = xe(e.visibleTimeEnd ?? a), [kt, _e] = xe(0), Pe = z(null), we = ee(() => {
771
- const o = R.current;
772
- Vt(o.visibleTimeStart), Zt(o.visibleTimeEnd), _e(o.scrollTop), Pe.current = null;
773
- }, []), qe = ee(() => {
774
- Pe.current === null && (Pe.current = setTimeout(we, Bt));
775
- }, [we]);
776
- ue(() => () => {
777
- Pe.current !== null && clearTimeout(Pe.current);
940
+ })), Ke = z(null), Fe = z(void 0), [Tt, qt] = xe(e.visibleTimeStart ?? d), [St, Ut] = xe(e.visibleTimeEnd ?? l), [kt, je] = xe(0), We = z(null), Re = ie(() => {
941
+ const a = D.current;
942
+ qt(a.visibleTimeStart), Ut(a.visibleTimeEnd), je(a.scrollTop), We.current = null;
943
+ }, []), Je = ie(() => {
944
+ We.current === null && (We.current = setTimeout(Re, Lt));
945
+ }, [Re]);
946
+ he(() => () => {
947
+ We.current !== null && clearTimeout(We.current);
778
948
  }, []);
779
- const Ke = ce(() => {
780
- const o = new ci();
781
- return o.buildFromItems(l, (r) => r.start_time, (r) => r.end_time), o;
782
- }, [l]), Ue = ce(() => {
783
- const o = new ui(u, v);
784
- return o.computeLayout(l, T), o;
785
- }, [l, u, v, T]), He = ce(() => new hi(), []), Ce = ce(() => new fi(), []), Ie = ce(() => new mi(), []), J = ce(() => new pi(I), [I]), Le = ce(() => {
786
- const o = [];
787
- return he.Children.forEach(be, (r) => {
788
- var h;
789
- if (!he.isValidElement(r))
949
+ const Ce = oe(() => {
950
+ const a = new mi();
951
+ return a.rebuild(r), a;
952
+ }, [r]), Qe = oe(() => {
953
+ const a = new hi();
954
+ return a.buildFromItems(r, (o) => Ce.getEffectiveSpan(o.id).start, (o) => Ce.getEffectiveSpan(o.id).end), a;
955
+ }, [r, Ce]), et = oe(() => {
956
+ const a = new fi(c, v);
957
+ return a.computeLayout(r, M, Ce), a;
958
+ }, [r, c, v, M, Ce]), Mt = oe(() => e.summaryRenderer ? e.summaryRenderer : (a, o, h, f, s) => {
959
+ gi(a, o, h, f, s, ye);
960
+ }, [e.summaryRenderer, ye]), Pe = oe(() => new vi(), []), De = oe(() => new bi(), []), Oe = oe(() => new yi(), []), Q = oe(() => new Mi(C), [C]), Ne = oe(() => {
961
+ const a = [];
962
+ return ge.Children.forEach(Te, (o) => {
963
+ var f;
964
+ if (!ge.isValidElement(o))
790
965
  return;
791
- const d = (h = r.type) == null ? void 0 : h.displayName;
792
- d === "TodayMarker" ? o.push(Ot(r.props)) : d === "CustomMarker" && o.push(Wt(r.props));
793
- }), o;
794
- }, [be]), Ae = ce(() => Le.map((o) => `${o.date}|${o.color}|${o.width}|${o.label ?? ""}`).join(";"), [Le]), Xe = z(Le);
795
- Xe.current = Le;
796
- const Je = ce(() => {
797
- let o = 0;
798
- return he.Children.forEach(be, (r) => {
799
- var h;
800
- if (!he.isValidElement(r))
966
+ const h = (f = o.type) == null ? void 0 : f.displayName;
967
+ h === "TodayMarker" ? a.push(Xt(o.props)) : h === "CustomMarker" && a.push(Bt(o.props));
968
+ }), a;
969
+ }, [Te]), $e = oe(() => Ne.map((a) => `${a.date}|${a.color}|${a.width}|${a.label ?? ""}`).join(";"), [Ne]), Xe = z(Ne);
970
+ Xe.current = Ne;
971
+ const tt = oe(() => {
972
+ let a = 0;
973
+ return ge.Children.forEach(Te, (o) => {
974
+ var f;
975
+ if (!ge.isValidElement(o))
801
976
  return;
802
- ((h = r.type) == null ? void 0 : h.displayName) === "TodayMarker" && (o = Si(r.props));
803
- }), o;
804
- }, [be]), F = z({
805
- groups: s,
806
- items: l,
807
- intervalTree: Ke,
808
- layoutEngine: Ue,
809
- itemRenderer: $,
810
- groupRenderer: w,
811
- theme: Ee,
812
- selected: Ve,
813
- dependencies: V,
814
- highlights: Z,
815
- dayStyle: y,
816
- rowStyle: D,
977
+ ((f = o.type) == null ? void 0 : f.displayName) === "TodayMarker" && (a = Hi(o.props));
978
+ }), a;
979
+ }, [Te]), O = z({
980
+ groups: n,
981
+ items: r,
982
+ intervalTree: Qe,
983
+ layoutEngine: et,
984
+ itemRenderer: Y,
985
+ groupRenderer: x,
986
+ theme: ye,
987
+ selected: Ue,
988
+ dependencies: P,
989
+ highlights: L,
990
+ dayStyle: S,
991
+ rowStyle: _,
817
992
  showCursorLine: B,
818
- canvasWidth: pe,
819
- canvasHeight: ye,
820
- lineHeight: u,
993
+ canvasWidth: Se,
994
+ canvasHeight: ke,
995
+ lineHeight: c,
821
996
  itemHeightRatio: v,
822
- onTimeChange: ut,
823
- onZoom: dt,
824
- onItemHover: We,
825
- onItemClick: ne,
826
- onItemDoubleClick: N,
827
- onItemContextMenu: le,
828
- onItemMove: ve,
829
- onItemResize: fe,
830
- onCanvasDoubleClick: Ge,
831
- onCanvasContextMenu: ct,
832
- canMove: p,
833
- canResize: S,
834
- canChangeGroup: H,
835
- dragSnap: I,
836
- sidebarWidth: m,
837
- moveResizeValidator: Me
997
+ onTimeChange: Ee,
998
+ onZoom: ht,
999
+ onItemHover: be,
1000
+ onItemClick: Z,
1001
+ onItemDoubleClick: K,
1002
+ onItemContextMenu: te,
1003
+ onItemMove: ue,
1004
+ onItemResize: ve,
1005
+ onCanvasDoubleClick: Ie,
1006
+ onCanvasContextMenu: Ae,
1007
+ canMove: g,
1008
+ canResize: T,
1009
+ canChangeGroup: b,
1010
+ dragSnap: C,
1011
+ sidebarWidth: u,
1012
+ moveResizeValidator: He,
1013
+ summaryRenderer: Mt,
1014
+ hierarchyEngine: Ce
838
1015
  });
839
- F.current = {
840
- groups: s,
841
- items: l,
842
- intervalTree: Ke,
843
- layoutEngine: Ue,
844
- itemRenderer: $,
845
- groupRenderer: w,
846
- theme: Ee,
847
- selected: Ve,
848
- dependencies: V,
849
- highlights: Z,
850
- dayStyle: y,
851
- rowStyle: D,
1016
+ O.current = {
1017
+ groups: n,
1018
+ items: r,
1019
+ intervalTree: Qe,
1020
+ layoutEngine: et,
1021
+ itemRenderer: Y,
1022
+ groupRenderer: x,
1023
+ theme: ye,
1024
+ selected: Ue,
1025
+ dependencies: P,
1026
+ highlights: L,
1027
+ dayStyle: S,
1028
+ rowStyle: _,
852
1029
  showCursorLine: B,
853
- canvasWidth: pe,
854
- canvasHeight: ye,
855
- lineHeight: u,
1030
+ canvasWidth: Se,
1031
+ canvasHeight: ke,
1032
+ lineHeight: c,
856
1033
  itemHeightRatio: v,
857
- onTimeChange: ut,
858
- onZoom: dt,
859
- onItemHover: We,
860
- onItemClick: ne,
861
- onItemDoubleClick: N,
862
- onItemContextMenu: le,
863
- onItemMove: ve,
864
- onItemResize: fe,
865
- onCanvasDoubleClick: Ge,
866
- onCanvasContextMenu: ct,
867
- canMove: p,
868
- canResize: S,
869
- canChangeGroup: H,
870
- dragSnap: I,
871
- sidebarWidth: m,
872
- moveResizeValidator: Me
1034
+ onTimeChange: Ee,
1035
+ onZoom: ht,
1036
+ onItemHover: be,
1037
+ onItemClick: Z,
1038
+ onItemDoubleClick: K,
1039
+ onItemContextMenu: te,
1040
+ onItemMove: ue,
1041
+ onItemResize: ve,
1042
+ onCanvasDoubleClick: Ie,
1043
+ onCanvasContextMenu: Ae,
1044
+ canMove: g,
1045
+ canResize: T,
1046
+ canChangeGroup: b,
1047
+ dragSnap: C,
1048
+ sidebarWidth: u,
1049
+ moveResizeValidator: He,
1050
+ summaryRenderer: Mt,
1051
+ hierarchyEngine: Ce
873
1052
  };
874
- const qt = ee(() => {
875
- const o = gt.current;
876
- if (!o)
1053
+ const Kt = ie(() => {
1054
+ const a = pt.current;
1055
+ if (!a)
877
1056
  return;
878
- const r = F.current, d = st(o, r.canvasWidth, r.canvasHeight);
879
- lt(d, o), He.draw(d, R.current, r.groups, r.theme, r.dayStyle, r.rowStyle, r.highlights);
880
- }, [He]), Kt = ee(() => {
881
- const o = vt.current;
882
- if (!o)
1057
+ const o = O.current, h = ct(a, o.canvasWidth, o.canvasHeight);
1058
+ ut(h, a), Pe.draw(h, D.current, o.groups, o.theme, o.dayStyle, o.rowStyle, o.highlights);
1059
+ }, [Pe]), Jt = ie(() => {
1060
+ const a = vt.current;
1061
+ if (!a)
883
1062
  return;
884
- const r = F.current, d = st(o, r.canvasWidth, r.canvasHeight);
885
- lt(d, o), Ce.draw(d, R.current, r.groups, r.items, r.intervalTree, r.layoutEngine, r.itemRenderer, r.groupRenderer, r.theme, r.selected, De.current, r.dependencies);
886
- }, [Ce]), St = ee((o, r, d) => {
887
- const h = R.current, n = F.current, f = n.canvasWidth / (h.visibleTimeEnd - h.visibleTimeStart), b = r / f, k = [];
888
- d === "move" ? (k.push(h.timeToX(o.start_time + b)), k.push(h.timeToX(o.end_time + b))) : d === "resize-left" ? k.push(h.timeToX(o.start_time + b)) : k.push(h.timeToX(o.end_time + b));
889
- const C = (h.visibleTimeEnd - h.visibleTimeStart) * 0.1, X = n.intervalTree.query(h.visibleTimeStart - C, h.visibleTimeEnd + C), q = at(X, o.id, (te) => h.timeToX(te));
890
- for (const te of k) {
891
- const G = $e(te, q, 8, f, n.dragSnap);
1063
+ const o = O.current, h = ct(a, o.canvasWidth, o.canvasHeight);
1064
+ ut(h, a), De.draw(h, D.current, o.groups, o.items, o.intervalTree, o.layoutEngine, o.itemRenderer, o.groupRenderer, o.theme, o.selected, Fe.current, o.dependencies, o.summaryRenderer, o.hierarchyEngine);
1065
+ }, [De]), wt = ie((a, o, h) => {
1066
+ const f = D.current, s = O.current, m = s.canvasWidth / (f.visibleTimeEnd - f.visibleTimeStart), y = o / m, k = [];
1067
+ h === "move" ? (k.push(f.timeToX(a.start_time + y)), k.push(f.timeToX(a.end_time + y))) : h === "resize-left" ? k.push(f.timeToX(a.start_time + y)) : k.push(f.timeToX(a.end_time + y));
1068
+ const H = (f.visibleTimeEnd - f.visibleTimeStart) * 0.1, F = s.intervalTree.query(f.visibleTimeStart - H, f.visibleTimeEnd + H), V = dt(F, a.id, (re) => f.timeToX(re));
1069
+ for (const re of k) {
1070
+ const G = Ve(re, V, 8, m, s.dragSnap);
892
1071
  if (G !== null)
893
1072
  return G;
894
1073
  }
895
- const U = o.start_time + b, P = Math.round(U / n.dragSnap) * n.dragSnap;
896
- return h.timeToX(P);
897
- }, []), Ut = ee(() => {
898
- const o = bt.current;
899
- if (!o)
1074
+ const J = a.start_time + y, R = Math.round(J / s.dragSnap) * s.dragSnap;
1075
+ return f.timeToX(R);
1076
+ }, []), Qt = ie(() => {
1077
+ const a = bt.current;
1078
+ if (!a)
900
1079
  return;
901
- const r = F.current, d = st(o, r.canvasWidth, r.canvasHeight);
902
- lt(d, o);
903
- const h = R.current, n = J.getState();
904
- let f = null;
905
- if (n) {
906
- const b = h.timeToX(n.item.start_time), k = h.timeToX(n.item.end_time) - b;
907
- let C, X;
908
- n.mode === "resize-left" ? (C = b + n.deltaX, X = k - n.deltaX) : n.mode === "resize-right" ? (C = b, X = k + n.deltaX) : (C = b + n.deltaX, X = k);
909
- const q = mt(n.currentGroup, r.groups), U = h.groupIndexToY(q), P = n.currentGroup !== n.originalGroup;
910
- f = {
911
- item: n.item,
912
- mode: n.mode,
913
- bounds: { x: C, y: U + (r.lineHeight - r.lineHeight * r.itemHeightRatio) / 2, width: X, height: r.lineHeight * r.itemHeightRatio },
914
- renderer: r.itemRenderer,
915
- targetGroupY: U,
916
- groupChanged: P
1080
+ const o = O.current, h = ct(a, o.canvasWidth, o.canvasHeight);
1081
+ ut(h, a);
1082
+ const f = D.current, s = Q.getState();
1083
+ let m = null;
1084
+ if (s) {
1085
+ const y = f.timeToX(s.item.start_time), k = f.timeToX(s.item.end_time) - y;
1086
+ let H, F;
1087
+ s.mode === "resize-left" ? (H = y + s.deltaX, F = k - s.deltaX) : s.mode === "resize-right" ? (H = y, F = k + s.deltaX) : (H = y + s.deltaX, F = k);
1088
+ const V = gt(s.currentGroup, o.groups), J = f.groupIndexToY(V), R = s.currentGroup !== s.originalGroup;
1089
+ m = {
1090
+ item: s.item,
1091
+ mode: s.mode,
1092
+ bounds: { x: H, y: J + (o.lineHeight - o.lineHeight * o.itemHeightRatio) / 2, width: F, height: o.lineHeight * o.itemHeightRatio },
1093
+ renderer: o.itemRenderer,
1094
+ targetGroupY: J,
1095
+ groupChanged: R
917
1096
  };
918
1097
  }
919
- Ie.draw(d, h, r.theme, {
920
- cursorX: r.showCursorLine ? Ze.current : null,
921
- snapX: n ? St(n.item, n.deltaX, n.mode) : null,
1098
+ Oe.draw(h, f, o.theme, {
1099
+ cursorX: o.showCursorLine ? Ke.current : null,
1100
+ snapX: s ? wt(s.item, s.deltaX, s.mode) : null,
922
1101
  markers: Xe.current,
923
- interaction: f
1102
+ interaction: m
924
1103
  });
925
- }, [Ie, J, St, mt]), Qe = z(null);
926
- Qe.current || (Qe.current = new di((o) => {
927
- o.grid && qt(), o.items && Kt(), o.overlay && Ut();
1104
+ }, [Oe, Q, wt, gt]), it = z(null);
1105
+ it.current || (it.current = new pi((a) => {
1106
+ a.grid && Kt(), a.items && Jt(), a.overlay && Qt();
928
1107
  }));
929
- const M = Qe.current;
930
- ue(() => () => M.dispose(), [M]), ue(() => {
931
- if (!Je)
1108
+ const E = it.current;
1109
+ he(() => () => E.dispose(), [E]), he(() => {
1110
+ if (!tt)
932
1111
  return;
933
- const o = setInterval(() => {
934
- const r = [];
935
- he.Children.forEach(be, (d) => {
936
- var n;
937
- if (!he.isValidElement(d))
1112
+ const a = setInterval(() => {
1113
+ const o = [];
1114
+ ge.Children.forEach(Te, (h) => {
1115
+ var s;
1116
+ if (!ge.isValidElement(h))
938
1117
  return;
939
- const h = (n = d.type) == null ? void 0 : n.displayName;
940
- h === "TodayMarker" ? r.push(Ot(d.props)) : h === "CustomMarker" && r.push(Wt(d.props));
941
- }), Xe.current = r, M.markDirty("overlay");
942
- }, Je);
943
- return () => clearInterval(o);
944
- }, [Je, be, M]), ue(() => {
945
- R.current.update({ canvasWidth: pe, canvasHeight: ye, sidebarWidth: m, lineHeight: u, groupCount: s.length }), M.markAllDirty();
946
- }, [pe, ye, m, u, s.length, M]), ue(() => {
947
- M.markDirty("grid"), M.markDirty("items");
948
- }, [l, s, Ve, Ee, y, D, Ke, Ue, M]);
949
- const Ye = ce(() => {
950
- var o;
951
- return ((o = e.highlights) == null ? void 0 : o.map((r) => `${r.start}|${r.end}|${r.color}|${r.label ?? ""}|${r.opacity ?? ""}`).join(";")) ?? "";
952
- }, [e.highlights]), Et = z(Ye);
953
- ue(() => {
954
- Ye !== Et.current && (Et.current = Ye, M.markDirty("grid"));
955
- }, [Ye, M]);
956
- const Mt = z(Ae);
957
- ue(() => {
958
- Ae !== Mt.current && (Mt.current = Ae, M.markDirty("overlay"));
959
- }, [Ae, M]);
960
- const wt = z(e.visibleTimeStart), Ht = z(e.visibleTimeEnd);
961
- e.visibleTimeStart !== void 0 && e.visibleTimeStart !== wt.current && (wt.current = e.visibleTimeStart, R.current.update({ visibleTimeStart: e.visibleTimeStart }), M.markAllDirty()), e.visibleTimeEnd !== void 0 && e.visibleTimeEnd !== Ht.current && (Ht.current = e.visibleTimeEnd, R.current.update({ visibleTimeEnd: e.visibleTimeEnd }), M.markAllDirty());
962
- const Fe = z(null), et = ee((o) => {
963
- Fe.current === null && (Fe.current = setTimeout(() => {
964
- var h, n;
965
- Fe.current = null;
966
- const r = R.current, d = F.current;
967
- o === "zoom" ? (h = d.onZoom) == null || h.call(d, r.visibleTimeStart, r.visibleTimeEnd) : (n = d.onTimeChange) == null || n.call(d, r.visibleTimeStart, r.visibleTimeEnd);
968
- }, Bt));
1118
+ const f = (s = h.type) == null ? void 0 : s.displayName;
1119
+ f === "TodayMarker" ? o.push(Xt(h.props)) : f === "CustomMarker" && o.push(Bt(h.props));
1120
+ }), Xe.current = o, E.markDirty("overlay");
1121
+ }, tt);
1122
+ return () => clearInterval(a);
1123
+ }, [tt, Te, E]), he(() => {
1124
+ D.current.update({ canvasWidth: Se, canvasHeight: ke, sidebarWidth: u, lineHeight: c, groupCount: n.length }), E.markAllDirty();
1125
+ }, [Se, ke, u, c, n.length, E]), he(() => {
1126
+ E.markDirty("grid"), E.markDirty("items");
1127
+ }, [r, n, Ue, ye, S, _, Qe, et, E]);
1128
+ const Ge = oe(() => {
1129
+ var a;
1130
+ return ((a = e.highlights) == null ? void 0 : a.map((o) => `${o.start}|${o.end}|${o.color}|${o.label ?? ""}|${o.opacity ?? ""}`).join(";")) ?? "";
1131
+ }, [e.highlights]), Et = z(Ge);
1132
+ he(() => {
1133
+ Ge !== Et.current && (Et.current = Ge, E.markDirty("grid"));
1134
+ }, [Ge, E]);
1135
+ const Ct = z($e);
1136
+ he(() => {
1137
+ $e !== Ct.current && (Ct.current = $e, E.markDirty("overlay"));
1138
+ }, [$e, E]);
1139
+ const Ht = z(e.visibleTimeStart), It = z(e.visibleTimeEnd);
1140
+ e.visibleTimeStart !== void 0 && e.visibleTimeStart !== Ht.current && (Ht.current = e.visibleTimeStart, D.current.update({ visibleTimeStart: e.visibleTimeStart }), E.markAllDirty()), e.visibleTimeEnd !== void 0 && e.visibleTimeEnd !== It.current && (It.current = e.visibleTimeEnd, D.current.update({ visibleTimeEnd: e.visibleTimeEnd }), E.markAllDirty());
1141
+ const Be = z(null), nt = ie((a) => {
1142
+ Be.current === null && (Be.current = setTimeout(() => {
1143
+ var f, s;
1144
+ Be.current = null;
1145
+ const o = D.current, h = O.current;
1146
+ a === "zoom" ? (f = h.onZoom) == null || f.call(h, o.visibleTimeStart, o.visibleTimeEnd) : (s = h.onTimeChange) == null || s.call(h, o.visibleTimeStart, o.visibleTimeEnd);
1147
+ }, Lt));
969
1148
  }, []);
970
- ue(() => () => {
971
- Fe.current !== null && clearTimeout(Fe.current);
1149
+ he(() => () => {
1150
+ Be.current !== null && clearTimeout(Be.current);
972
1151
  }, []);
973
- const je = z(null), tt = ce(() => new vi((o, r) => {
974
- var d;
975
- R.current.update({ visibleTimeStart: o, visibleTimeEnd: r }), (d = je.current) == null || d.updateBounds(o, r), M.markAllDirty(), qe(), et("zoom");
976
- }, c, a, W, L), []);
977
- je.current = tt;
978
- const Ct = ee((o) => {
979
- const r = R.current, d = r.groupCount * r.lineHeight, h = Math.max(0, d - r.canvasHeight), n = Math.max(0, Math.min(h, r.scrollTop + o));
980
- n !== r.scrollTop && (r.update({ scrollTop: n }), M.markDirty("grid"), M.markDirty("items"), M.markDirty("overlay"), _e(n));
981
- }, [M]), it = ee((o) => {
982
- var b, k, C;
983
- const r = R.current, d = r.canvasWidth / (r.visibleTimeEnd - r.visibleTimeStart), h = o / d, n = r.visibleTimeStart + h, f = r.visibleTimeEnd + h;
984
- r.update({ visibleTimeStart: n, visibleTimeEnd: f }), (b = je.current) == null || b.updateBounds(n, f), M.markAllDirty(), ai(() => we()), (C = (k = F.current).onTimeChange) == null || C.call(k, n, f);
985
- }, [M, we]);
986
- ue(() => {
987
- const o = Re.current;
988
- if (!o)
1152
+ const ze = z(null), rt = oe(() => new Si((a, o) => {
1153
+ var h;
1154
+ D.current.update({ visibleTimeStart: a, visibleTimeEnd: o }), (h = ze.current) == null || h.updateBounds(a, o), E.markAllDirty(), Je(), nt("zoom");
1155
+ }, d, l, I, W), []);
1156
+ ze.current = rt;
1157
+ const Rt = ie((a) => {
1158
+ const o = D.current, h = o.groupCount * o.lineHeight, f = Math.max(0, h - o.canvasHeight), s = Math.max(0, Math.min(f, o.scrollTop + a));
1159
+ s !== o.scrollTop && (o.update({ scrollTop: s }), E.markDirty("grid"), E.markDirty("items"), E.markDirty("overlay"), je(s));
1160
+ }, [E]), ot = ie((a) => {
1161
+ var y, k, H;
1162
+ const o = D.current, h = o.canvasWidth / (o.visibleTimeEnd - o.visibleTimeStart), f = a / h, s = o.visibleTimeStart + f, m = o.visibleTimeEnd + f;
1163
+ o.update({ visibleTimeStart: s, visibleTimeEnd: m }), (y = ze.current) == null || y.updateBounds(s, m), E.markAllDirty(), di(() => Re()), (H = (k = O.current).onTimeChange) == null || H.call(k, s, m);
1164
+ }, [E, Re]);
1165
+ he(() => {
1166
+ const a = _e.current;
1167
+ if (!a)
989
1168
  return;
990
- const r = (d) => {
991
- if (d.ctrlKey || d.metaKey || d.altKey) {
992
- d.preventDefault();
993
- const h = o.getBoundingClientRect(), n = (d.clientX - h.left) / h.width;
994
- tt.handleWheelZoom(d, n);
995
- } else if (d.shiftKey)
996
- d.preventDefault(), it(d.deltaY);
1169
+ const o = (h) => {
1170
+ if (h.ctrlKey || h.metaKey || h.altKey) {
1171
+ h.preventDefault();
1172
+ const f = a.getBoundingClientRect(), s = (h.clientX - f.left) / f.width;
1173
+ rt.handleWheelZoom(h, s);
1174
+ } else if (h.shiftKey)
1175
+ h.preventDefault(), ot(h.deltaY);
997
1176
  else {
998
- const h = d.deltaX;
999
- h !== 0 && Math.abs(h) > Math.abs(d.deltaY) ? (d.preventDefault(), it(h)) : d.deltaY !== 0 && Ct(d.deltaY);
1177
+ const f = h.deltaX;
1178
+ f !== 0 && Math.abs(f) > Math.abs(h.deltaY) ? (h.preventDefault(), ot(f)) : h.deltaY !== 0 && Rt(h.deltaY);
1000
1179
  }
1001
1180
  };
1002
- return o.addEventListener("wheel", r, { passive: !1 }), () => o.removeEventListener("wheel", r);
1003
- }, [tt, Ct, it]);
1004
- const Te = z({ lastDistance: null, lastCenter: null });
1005
- ue(() => {
1006
- const o = Re.current;
1007
- if (!o)
1181
+ return a.addEventListener("wheel", o, { passive: !1 }), () => a.removeEventListener("wheel", o);
1182
+ }, [rt, Rt, ot]);
1183
+ const Me = z({ lastDistance: null, lastCenter: null });
1184
+ he(() => {
1185
+ const a = _e.current;
1186
+ if (!a)
1008
1187
  return;
1009
- const r = (b, k) => Math.abs(b.clientX - k.clientX), d = (b, k, C) => (b.clientX + k.clientX) / 2 - C.left, h = (b) => {
1010
- b.touches.length === 2 && (b.preventDefault(), Te.current.lastDistance = r(b.touches[0], b.touches[1]), Te.current.lastCenter = null);
1011
- }, n = (b) => {
1188
+ const o = (y, k) => Math.abs(y.clientX - k.clientX), h = (y, k, H) => (y.clientX + k.clientX) / 2 - H.left, f = (y) => {
1189
+ y.touches.length === 2 && (y.preventDefault(), Me.current.lastDistance = o(y.touches[0], y.touches[1]), Me.current.lastCenter = null);
1190
+ }, s = (y) => {
1012
1191
  var k;
1013
- if (b.touches.length === 2 && Te.current.lastDistance !== null) {
1014
- b.preventDefault();
1015
- const C = r(b.touches[0], b.touches[1]), X = o.getBoundingClientRect(), U = d(b.touches[0], b.touches[1], X) / X.width;
1016
- if (C !== 0 && Te.current.lastDistance !== 0) {
1017
- const P = Te.current.lastDistance / C, te = R.current, G = te.visibleTimeEnd - te.visibleTimeStart;
1018
- let E = G * P;
1019
- E = Math.max(W, Math.min(L, E));
1020
- const g = te.visibleTimeStart + G * U, A = g - E * U, _ = g + E * (1 - U);
1021
- te.update({ visibleTimeStart: A, visibleTimeEnd: _ }), (k = je.current) == null || k.updateBounds(A, _), M.markAllDirty(), qe(), et("zoom");
1192
+ if (y.touches.length === 2 && Me.current.lastDistance !== null) {
1193
+ y.preventDefault();
1194
+ const H = o(y.touches[0], y.touches[1]), F = a.getBoundingClientRect(), J = h(y.touches[0], y.touches[1], F) / F.width;
1195
+ if (H !== 0 && Me.current.lastDistance !== 0) {
1196
+ const R = Me.current.lastDistance / H, re = D.current, G = re.visibleTimeEnd - re.visibleTimeStart;
1197
+ let w = G * R;
1198
+ w = Math.max(I, Math.min(W, w));
1199
+ const p = re.visibleTimeStart + G * J, j = p - w * J, A = p + w * (1 - J);
1200
+ re.update({ visibleTimeStart: j, visibleTimeEnd: A }), (k = ze.current) == null || k.updateBounds(j, A), E.markAllDirty(), Je(), nt("zoom");
1022
1201
  }
1023
- Te.current.lastDistance = C;
1202
+ Me.current.lastDistance = H;
1024
1203
  }
1025
- }, f = () => {
1026
- Te.current.lastDistance = null, Te.current.lastCenter = null;
1204
+ }, m = () => {
1205
+ Me.current.lastDistance = null, Me.current.lastCenter = null;
1027
1206
  };
1028
- return o.addEventListener("touchstart", h, { passive: !1 }), o.addEventListener("touchmove", n, { passive: !1 }), o.addEventListener("touchend", f), () => {
1029
- o.removeEventListener("touchstart", h), o.removeEventListener("touchmove", n), o.removeEventListener("touchend", f);
1207
+ return a.addEventListener("touchstart", f, { passive: !1 }), a.addEventListener("touchmove", s, { passive: !1 }), a.addEventListener("touchend", m), () => {
1208
+ a.removeEventListener("touchstart", f), a.removeEventListener("touchmove", s), a.removeEventListener("touchend", m);
1030
1209
  };
1031
- }, [M, qe, et]);
1032
- const Jt = ee((o) => {
1033
- var C;
1034
- const r = o.currentTarget, d = r.getBoundingClientRect(), h = o.clientX - d.left, n = o.clientY - d.top;
1035
- if (Ze.current = h, J.isPending()) {
1036
- if (J.update(h, n), J.isActive()) {
1037
- const X = J.getState();
1038
- if (X && X.mode === "move" && F.current.canChangeGroup) {
1039
- const q = ot(n, R.current, F.current.groups);
1040
- q && J.setCurrentGroup(q.id);
1210
+ }, [E, Je, nt]);
1211
+ const ei = ie((a) => {
1212
+ var H;
1213
+ const o = a.currentTarget, h = o.getBoundingClientRect(), f = a.clientX - h.left, s = a.clientY - h.top;
1214
+ if (Ke.current = f, Q.isPending()) {
1215
+ if (Q.update(f, s), Q.isActive()) {
1216
+ const F = Q.getState();
1217
+ if (F && F.mode === "move" && O.current.canChangeGroup) {
1218
+ const V = at(s, D.current, O.current.groups);
1219
+ V && Q.setCurrentGroup(V.id);
1041
1220
  }
1042
- M.markDirty("overlay");
1221
+ E.markDirty("overlay");
1043
1222
  }
1044
1223
  return;
1045
1224
  }
1046
- F.current.showCursorLine && M.markDirty("overlay");
1047
- const f = F.current, b = Oe(h, n, R.current, f.intervalTree, f.layoutEngine, f.groups), k = b == null ? void 0 : b.id;
1048
- if (k !== De.current && (De.current = k, M.markDirty("items"), (C = f.onItemHover) == null || C.call(f, k ?? null, o.nativeEvent)), b) {
1049
- const X = Rt(h, b, R.current), q = f.canResize;
1050
- X === "left" && (q === "left" || q === "both") || X === "right" && (q === "right" || q === "both") ? r.style.cursor = "col-resize" : f.canMove ? r.style.cursor = "grab" : r.style.cursor = "default";
1225
+ O.current.showCursorLine && E.markDirty("overlay");
1226
+ const m = O.current, y = Le(f, s, D.current, m.intervalTree, m.layoutEngine, m.groups), k = y == null ? void 0 : y.id;
1227
+ if (k !== Fe.current && (Fe.current = k, E.markDirty("items"), (H = m.onItemHover) == null || H.call(m, k ?? null, a.nativeEvent)), y) {
1228
+ const F = Dt(f, y, D.current), V = m.canResize;
1229
+ F === "left" && (V === "left" || V === "both") || F === "right" && (V === "right" || V === "both") ? o.style.cursor = "col-resize" : m.canMove ? o.style.cursor = "grab" : o.style.cursor = "default";
1051
1230
  } else
1052
- r.style.cursor = "default";
1053
- }, [J, M]), Qt = ee((o) => {
1054
- const r = F.current, d = o.currentTarget.getBoundingClientRect(), h = o.clientX - d.left, n = o.clientY - d.top, f = Oe(h, n, R.current, r.intervalTree, r.layoutEngine, r.groups);
1055
- if (!f)
1231
+ o.style.cursor = "default";
1232
+ }, [Q, E]), ti = ie((a) => {
1233
+ const o = O.current, h = a.currentTarget.getBoundingClientRect(), f = a.clientX - h.left, s = a.clientY - h.top, m = Le(f, s, D.current, o.intervalTree, o.layoutEngine, o.groups);
1234
+ if (!m)
1056
1235
  return;
1057
- const b = Rt(h, f, R.current), k = r.canResize;
1058
- b === "left" && (k === "left" || k === "both") ? J.startInteraction(f, "resize-left", h, n) : b === "right" && (k === "right" || k === "both") ? J.startInteraction(f, "resize-right", h, n) : r.canMove && J.startInteraction(f, "move", h, n);
1059
- }, [J]), ei = ee((o) => {
1060
- var b, k, C, X, q, U;
1061
- const r = o.currentTarget;
1062
- if (J.isActive()) {
1063
- const P = J.getState(), te = R.current, G = te.canvasWidth / (te.visibleTimeEnd - te.visibleTimeStart);
1064
- if (P) {
1065
- const E = F.current.moveResizeValidator;
1066
- if (P.mode === "move") {
1067
- const g = J.endMove(G);
1068
- if (g) {
1069
- const A = R.current, _ = F.current, ae = P.deltaX / G, de = A.timeToX(P.item.start_time + ae), O = A.timeToX(P.item.end_time + ae), K = (A.visibleTimeEnd - A.visibleTimeStart) * 0.1, Q = _.intervalTree.query(A.visibleTimeStart - K, A.visibleTimeEnd + K), x = at(Q, P.item.id, (se) => A.timeToX(se));
1070
- let oe = g.newStartTime;
1071
- const ie = $e(de, x, 8, G, _.dragSnap);
1072
- if (ie !== null)
1073
- oe = A.xToTime(ie);
1236
+ const y = Dt(f, m, D.current), k = o.canResize;
1237
+ y === "left" && (k === "left" || k === "both") ? Q.startInteraction(m, "resize-left", f, s) : y === "right" && (k === "right" || k === "both") ? Q.startInteraction(m, "resize-right", f, s) : o.canMove && Q.startInteraction(m, "move", f, s);
1238
+ }, [Q]), ii = ie((a) => {
1239
+ var y, k, H, F, V, J;
1240
+ const o = a.currentTarget;
1241
+ if (Q.isActive()) {
1242
+ const R = Q.getState(), re = D.current, G = re.canvasWidth / (re.visibleTimeEnd - re.visibleTimeStart);
1243
+ if (R) {
1244
+ const w = O.current.moveResizeValidator;
1245
+ if (R.mode === "move") {
1246
+ const p = Q.endMove(G);
1247
+ if (p) {
1248
+ const j = D.current, A = O.current, ae = R.deltaX / G, fe = j.timeToX(R.item.start_time + ae), X = j.timeToX(R.item.end_time + ae), q = (j.visibleTimeEnd - j.visibleTimeStart) * 0.1, ee = A.intervalTree.query(j.visibleTimeStart - q, j.visibleTimeEnd + q), N = dt(ee, R.item.id, (me) => j.timeToX(me));
1249
+ let le = p.newStartTime;
1250
+ const U = Ve(fe, N, 8, G, A.dragSnap);
1251
+ if (U !== null)
1252
+ le = j.xToTime(U);
1074
1253
  else {
1075
- const se = $e(O, x, 8, G, _.dragSnap);
1076
- if (se !== null) {
1077
- const ke = P.item.end_time - P.item.start_time;
1078
- oe = A.xToTime(se) - ke;
1254
+ const me = Ve(X, N, 8, G, A.dragSnap);
1255
+ if (me !== null) {
1256
+ const ai = R.item.end_time - R.item.start_time;
1257
+ le = j.xToTime(me) - ai;
1079
1258
  }
1080
1259
  }
1081
- const ge = E ? E("move", P.item.id, oe) : oe;
1082
- (k = (b = F.current).onItemMove) == null || k.call(b, P.item.id, ge, g.newGroupId);
1260
+ const ce = w ? w("move", R.item.id, le) : le, de = O.current.hierarchyEngine.getMoveDelta(R.item.id, ce);
1261
+ (k = (y = O.current).onItemMove) == null || k.call(y, R.item.id, ce, p.newGroupId, de.length > 0 ? de : void 0);
1083
1262
  }
1084
1263
  } else {
1085
- const g = J.endResize(G);
1086
- if (g) {
1087
- const A = R.current, _ = F.current, ae = P.deltaX / G, de = g.edge === "left" ? P.item.start_time + ae : P.item.end_time + ae, O = A.timeToX(de), K = (A.visibleTimeEnd - A.visibleTimeStart) * 0.1, Q = _.intervalTree.query(A.visibleTimeStart - K, A.visibleTimeEnd + K), x = at(Q, P.item.id, (se) => A.timeToX(se)), oe = $e(O, x, 8, G, _.dragSnap), ie = oe !== null ? A.xToTime(oe) : g.newTime, ge = E ? E("resize", P.item.id, ie, g.edge) : ie;
1088
- (X = (C = F.current).onItemResize) == null || X.call(C, P.item.id, ge, g.edge);
1264
+ const p = Q.endResize(G);
1265
+ if (p) {
1266
+ const j = D.current, A = O.current, ae = R.deltaX / G, fe = p.edge === "left" ? R.item.start_time + ae : R.item.end_time + ae, X = j.timeToX(fe), q = (j.visibleTimeEnd - j.visibleTimeStart) * 0.1, ee = A.intervalTree.query(j.visibleTimeStart - q, j.visibleTimeEnd + q), N = dt(ee, R.item.id, (me) => j.timeToX(me)), le = Ve(X, N, 8, G, A.dragSnap);
1267
+ let U = le !== null ? j.xToTime(le) : p.newTime;
1268
+ const ce = O.current.hierarchyEngine.getResizeConstraint(R.item.id, p.edge);
1269
+ p.edge === "left" && U > ce.max ? U = ce.max : p.edge === "right" && U < ce.min && (U = ce.min);
1270
+ const de = w ? w("resize", R.item.id, U, p.edge) : U;
1271
+ (F = (H = O.current).onItemResize) == null || F.call(H, R.item.id, de, p.edge);
1089
1272
  }
1090
1273
  }
1091
1274
  }
1092
- r.style.cursor = "default", M.markDirty("overlay");
1275
+ o.style.cursor = "default", E.markDirty("overlay");
1093
1276
  return;
1094
1277
  }
1095
- J.isPending() && J.cancel();
1096
- const d = r.getBoundingClientRect(), h = o.clientX - d.left, n = o.clientY - d.top, f = Oe(h, n, R.current, F.current.intervalTree, F.current.layoutEngine, F.current.groups);
1097
- f && ((U = (q = F.current).onItemClick) == null || U.call(q, f.id, o.nativeEvent));
1098
- }, [J, M]), ti = ee((o) => {
1099
- var b, k;
1100
- const r = o.currentTarget.getBoundingClientRect(), d = o.clientX - r.left, h = o.clientY - r.top, n = F.current, f = Oe(d, h, R.current, n.intervalTree, n.layoutEngine, n.groups);
1101
- if (f)
1102
- (b = n.onItemDoubleClick) == null || b.call(n, f.id, o.nativeEvent);
1278
+ Q.isPending() && Q.cancel();
1279
+ const h = o.getBoundingClientRect(), f = a.clientX - h.left, s = a.clientY - h.top, m = Le(f, s, D.current, O.current.intervalTree, O.current.layoutEngine, O.current.groups);
1280
+ m && ((J = (V = O.current).onItemClick) == null || J.call(V, m.id, a.nativeEvent));
1281
+ }, [Q, E]), ni = ie((a) => {
1282
+ var y, k;
1283
+ const o = a.currentTarget.getBoundingClientRect(), h = a.clientX - o.left, f = a.clientY - o.top, s = O.current, m = Le(h, f, D.current, s.intervalTree, s.layoutEngine, s.groups);
1284
+ if (m)
1285
+ (y = s.onItemDoubleClick) == null || y.call(s, m.id, a.nativeEvent);
1103
1286
  else {
1104
- const C = ot(h, R.current, n.groups), X = R.current.xToTime(d);
1105
- C && ((k = n.onCanvasDoubleClick) == null || k.call(n, C.id, X));
1287
+ const H = at(f, D.current, s.groups), F = D.current.xToTime(h);
1288
+ H && ((k = s.onCanvasDoubleClick) == null || k.call(s, H.id, F));
1106
1289
  }
1107
- }, []), ii = ee((o) => {
1108
- var b, k;
1109
- o.preventDefault();
1110
- const r = o.currentTarget.getBoundingClientRect(), d = o.clientX - r.left, h = o.clientY - r.top, n = F.current, f = Oe(d, h, R.current, n.intervalTree, n.layoutEngine, n.groups);
1111
- if (f)
1112
- (b = n.onItemContextMenu) == null || b.call(n, f.id, o.nativeEvent);
1290
+ }, []), ri = ie((a) => {
1291
+ var y, k;
1292
+ a.preventDefault();
1293
+ const o = a.currentTarget.getBoundingClientRect(), h = a.clientX - o.left, f = a.clientY - o.top, s = O.current, m = Le(h, f, D.current, s.intervalTree, s.layoutEngine, s.groups);
1294
+ if (m)
1295
+ (y = s.onItemContextMenu) == null || y.call(s, m.id, a.nativeEvent);
1113
1296
  else {
1114
- const C = ot(h, R.current, n.groups), X = R.current.xToTime(d);
1115
- C && ((k = n.onCanvasContextMenu) == null || k.call(n, C.id, X, o.nativeEvent));
1297
+ const H = at(f, D.current, s.groups), F = D.current.xToTime(h);
1298
+ H && ((k = s.onCanvasContextMenu) == null || k.call(s, H.id, F, a.nativeEvent));
1116
1299
  }
1117
- }, []), ri = ee(() => {
1118
- var o, r;
1119
- Ze.current = null, Re.current && (Re.current.style.cursor = "default"), De.current !== void 0 && (De.current = void 0, M.markDirty("items"), (r = (o = F.current).onItemHover) == null || r.call(o, null, new PointerEvent("pointerleave"))), F.current.showCursorLine && M.markDirty("overlay");
1120
- }, [M]), ni = ce(() => {
1121
- const o = [];
1122
- return he.Children.forEach(be, (r) => {
1123
- var h;
1124
- if (!he.isValidElement(r))
1300
+ }, []), oi = ie(() => {
1301
+ var a, o;
1302
+ Ke.current = null, _e.current && (_e.current.style.cursor = "default"), Fe.current !== void 0 && (Fe.current = void 0, E.markDirty("items"), (o = (a = O.current).onItemHover) == null || o.call(a, null, new PointerEvent("pointerleave"))), O.current.showCursorLine && E.markDirty("overlay");
1303
+ }, [E]), si = oe(() => {
1304
+ const a = [];
1305
+ return ge.Children.forEach(Te, (o) => {
1306
+ var f;
1307
+ if (!ge.isValidElement(o))
1125
1308
  return;
1126
- if (((h = r.type) == null ? void 0 : h.displayName) === "TimelineHeaders") {
1127
- const n = r.props;
1128
- o.push(he.cloneElement(r, {
1129
- visibleTimeStart: n.visibleTimeStart ?? yt,
1130
- visibleTimeEnd: n.visibleTimeEnd ?? Tt,
1131
- canvasWidth: n.canvasWidth ?? pe,
1132
- sidebarWidth: n.sidebarWidth ?? m,
1133
- theme: n.theme ?? Ee,
1134
- onZoomToInterval: n.onZoomToInterval ?? ((f, b) => {
1135
- var k, C, X, q;
1136
- R.current.update({ visibleTimeStart: f, visibleTimeEnd: b }), M.markAllDirty(), we(), (C = (k = F.current).onTimeChange) == null || C.call(k, f, b), (q = (X = F.current).onZoom) == null || q.call(X, f, b);
1309
+ if (((f = o.type) == null ? void 0 : f.displayName) === "TimelineHeaders") {
1310
+ const s = o.props;
1311
+ a.push(ge.cloneElement(o, {
1312
+ visibleTimeStart: s.visibleTimeStart ?? Tt,
1313
+ visibleTimeEnd: s.visibleTimeEnd ?? St,
1314
+ canvasWidth: s.canvasWidth ?? Se,
1315
+ sidebarWidth: s.sidebarWidth ?? u,
1316
+ theme: s.theme ?? ye,
1317
+ onZoomToInterval: s.onZoomToInterval ?? ((m, y) => {
1318
+ var k, H, F, V;
1319
+ D.current.update({ visibleTimeStart: m, visibleTimeEnd: y }), E.markAllDirty(), Re(), (H = (k = O.current).onTimeChange) == null || H.call(k, m, y), (V = (F = O.current).onZoom) == null || V.call(F, m, y);
1137
1320
  })
1138
1321
  }));
1139
1322
  }
1140
- }), o;
1141
- }, [be, yt, Tt, pe, m, Ee, M, we]), It = z(!1);
1142
- ue(() => {
1143
- It.current || (It.current = !0, M.markAllDirty());
1144
- }, [M]), li(t, () => ({
1145
- captureToCanvas({ timeStart: o, timeEnd: r, scale: d, sidebarWidth: h }) {
1146
- const n = F.current, f = 28, b = f * 3, k = n.groups.length * n.lineHeight, C = R.current, X = n.canvasWidth / (C.visibleTimeEnd - C.visibleTimeStart), q = r - o, U = Math.max(n.canvasWidth, Math.round(q * X)), P = (h + U) * d, te = (b + k) * d, G = document.createElement("canvas");
1147
- G.width = P, G.height = te;
1148
- const E = G.getContext("2d");
1149
- E.scale(d, d);
1150
- for (let _ = 0; _ < n.groups.length; _++) {
1151
- const ae = n.groups[_], de = b + _ * n.lineHeight;
1152
- if (n.rowStyle) {
1153
- const x = n.rowStyle(ae);
1154
- x != null && x.backgroundColor && (E.fillStyle = x.backgroundColor, E.fillRect(0, de, h, n.lineHeight));
1323
+ }), a;
1324
+ }, [Te, Tt, St, Se, u, ye, E, Re]), Pt = z(!1);
1325
+ he(() => {
1326
+ Pt.current || (Pt.current = !0, E.markAllDirty());
1327
+ }, [E]), ui(t, () => ({
1328
+ captureToCanvas({ timeStart: a, timeEnd: o, scale: h, sidebarWidth: f }) {
1329
+ const s = O.current, m = 28, y = m * 3, k = s.groups.length * s.lineHeight, H = D.current, F = s.canvasWidth / (H.visibleTimeEnd - H.visibleTimeStart), V = o - a, J = Math.max(s.canvasWidth, Math.round(V * F)), R = (f + J) * h, re = (y + k) * h, G = document.createElement("canvas");
1330
+ G.width = R, G.height = re;
1331
+ const w = G.getContext("2d");
1332
+ w.scale(h, h);
1333
+ for (let A = 0; A < s.groups.length; A++) {
1334
+ const ae = s.groups[A], fe = y + A * s.lineHeight;
1335
+ if (s.rowStyle) {
1336
+ const N = s.rowStyle(ae);
1337
+ N != null && N.backgroundColor && (w.fillStyle = N.backgroundColor, w.fillRect(0, fe, f, s.lineHeight));
1155
1338
  }
1156
- const O = ae.type;
1157
- let K = "400", Q = 8;
1158
- O === "project" ? K = "700" : O === "CAG" ? K = "600" : O === "CA" && (K = "400", Q = 24), E.fillStyle = "#111", E.font = `${K} 12px sans-serif`, E.textBaseline = "middle", E.fillText(ae.title, Q, de + n.lineHeight / 2, h - Q - 4);
1339
+ const X = ae.type;
1340
+ let q = "400", ee = 8;
1341
+ X === "project" ? q = "700" : X === "CAG" ? q = "600" : X === "CA" && (q = "400", ee = 24), w.fillStyle = "#111", w.font = `${q} 12px sans-serif`, w.textBaseline = "middle", w.fillText(ae.title, ee, fe + s.lineHeight / 2, f - ee - 4);
1159
1342
  }
1160
- const g = (_, ae, de) => {
1161
- var Q, x;
1162
- E.fillStyle = ((Q = n.theme.header) == null ? void 0 : Q.bg) ?? "#f5f5f5", E.fillRect(h, _, U, f), E.strokeStyle = ((x = n.theme.grid) == null ? void 0 : x.line) ?? "#e0e0e0", E.lineWidth = 1, E.strokeRect(h, _, U, f);
1163
- let O = me(o).startOf(de);
1164
- O.valueOf() < o && (O = O.add(1, de));
1165
- const K = U / (r - o);
1166
- for (; O.valueOf() < r; ) {
1167
- const oe = O.add(1, de), ie = h + (O.valueOf() - o) * K, se = h + (Math.min(oe.valueOf(), r) - o) * K - ie;
1168
- E.beginPath(), E.moveTo(ie, _), E.lineTo(ie, _ + f), E.stroke(), E.fillStyle = "#333", E.font = "600 11px sans-serif", E.textBaseline = "middle", E.textAlign = "center", E.fillText(ae(O), ie + se / 2, _ + f / 2, se - 4), O = oe;
1343
+ const p = (A, ae, fe) => {
1344
+ var ee, N;
1345
+ w.fillStyle = ((ee = s.theme.header) == null ? void 0 : ee.bg) ?? "#f5f5f5", w.fillRect(f, A, J, m), w.strokeStyle = ((N = s.theme.grid) == null ? void 0 : N.line) ?? "#e0e0e0", w.lineWidth = 1, w.strokeRect(f, A, J, m);
1346
+ let X = pe(a).startOf(fe);
1347
+ X.valueOf() < a && (X = X.add(1, fe));
1348
+ const q = J / (o - a);
1349
+ for (; X.valueOf() < o; ) {
1350
+ const le = X.add(1, fe), U = f + (X.valueOf() - a) * q, de = f + (Math.min(le.valueOf(), o) - a) * q - U;
1351
+ w.beginPath(), w.moveTo(U, A), w.lineTo(U, A + m), w.stroke(), w.fillStyle = "#333", w.font = "600 11px sans-serif", w.textBaseline = "middle", w.textAlign = "center", w.fillText(ae(X), U + de / 2, A + m / 2, de - 4), X = le;
1169
1352
  }
1170
- E.textAlign = "start";
1353
+ w.textAlign = "start";
1171
1354
  };
1172
- g(0, (_) => _.format("YYYY"), "year"), g(f, (_) => _.format("MM"), "month"), g(f * 2, (_) => String(_.isoWeek()), "week");
1173
- const A = new nt({
1174
- visibleTimeStart: o,
1175
- visibleTimeEnd: r,
1176
- canvasWidth: U,
1355
+ p(0, (A) => A.format("YYYY"), "year"), p(m, (A) => A.format("MM"), "month"), p(m * 2, (A) => String(A.isoWeek()), "week");
1356
+ const j = new lt({
1357
+ visibleTimeStart: a,
1358
+ visibleTimeEnd: o,
1359
+ canvasWidth: J,
1177
1360
  canvasHeight: k,
1178
1361
  sidebarWidth: 0,
1179
- lineHeight: n.lineHeight,
1180
- groupCount: n.groups.length,
1362
+ lineHeight: s.lineHeight,
1363
+ groupCount: s.groups.length,
1181
1364
  buffer: 1,
1182
1365
  scrollTop: 0
1183
1366
  });
1184
- return E.save(), E.translate(h, b), E.beginPath(), E.rect(0, 0, U, k), E.clip(), He.draw(E, A, n.groups, n.theme, n.dayStyle, n.rowStyle, n.highlights), Ce.draw(E, A, n.groups, n.items, n.intervalTree, n.layoutEngine, n.itemRenderer, n.groupRenderer, n.theme, n.selected, void 0, n.dependencies), Ie.draw(E, A, n.theme, {
1367
+ return w.save(), w.translate(f, y), w.beginPath(), w.rect(0, 0, J, k), w.clip(), Pe.draw(w, j, s.groups, s.theme, s.dayStyle, s.rowStyle, s.highlights), De.draw(w, j, s.groups, s.items, s.intervalTree, s.layoutEngine, s.itemRenderer, s.groupRenderer, s.theme, s.selected, void 0, s.dependencies, s.summaryRenderer, s.hierarchyEngine), Oe.draw(w, j, s.theme, {
1185
1368
  cursorX: null,
1186
1369
  snapX: null,
1187
1370
  markers: Xe.current,
1188
1371
  interaction: null
1189
- }), E.restore(), G;
1372
+ }), w.restore(), G;
1190
1373
  }
1191
- }), [He, Ce, Ie]), ue(() => {
1192
- const o = {
1193
- captureToCanvas({ timeStart: r, timeEnd: d, scale: h, sidebarWidth: n }) {
1194
- var de;
1195
- const f = F.current, b = 28, k = b * 3, C = f.groups.length * f.lineHeight, X = R.current, q = f.canvasWidth / (X.visibleTimeEnd - X.visibleTimeStart), U = d - r, P = Math.max(f.canvasWidth, Math.round(U * q)), te = n + P, G = k + C, E = document.createElement("canvas");
1196
- E.width = te * h, E.height = G * h;
1197
- const g = E.getContext("2d");
1198
- g.scale(h, h), g.fillStyle = "#FFFFFF", g.fillRect(0, 0, te, G), g.save(), g.beginPath(), g.rect(0, 0, n, G), g.clip(), g.fillStyle = "#F9FAFB", g.fillRect(0, 0, n, k), g.strokeStyle = "#E5E7EB", g.lineWidth = 1, g.strokeRect(0, 0, n, k);
1199
- for (let O = 0; O < f.groups.length; O++) {
1200
- const K = f.groups[O], Q = k + O * f.lineHeight, x = (de = f.rowStyle) == null ? void 0 : de.call(f, K);
1201
- g.fillStyle = (x == null ? void 0 : x.backgroundColor) ?? (O % 2 === 0 ? "#FFFFFF" : "#F7F7F7"), g.fillRect(0, Q, n, f.lineHeight), g.strokeStyle = "#E5E5E5", g.lineWidth = 0.5, g.beginPath(), g.moveTo(0, Q + f.lineHeight), g.lineTo(n, Q + f.lineHeight), g.stroke();
1202
- const oe = K.type ?? "";
1203
- let ie = 8, ge = "400", se = 11;
1204
- oe === "project" ? (ge = "700", se = 12) : oe === "control_area_group" ? ge = "600" : oe === "control_area" && (ie = 24), g.fillStyle = "#374151", g.font = `${ge} ${se}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`, g.textBaseline = "middle";
1205
- const ke = typeof K.title == "string" ? K.title : String(K.title);
1206
- g.fillText(ke, ie, Q + f.lineHeight / 2, n - ie - 8);
1374
+ }), [Pe, De, Oe]), he(() => {
1375
+ const a = {
1376
+ captureToCanvas({ timeStart: o, timeEnd: h, scale: f, sidebarWidth: s }) {
1377
+ var fe;
1378
+ const m = O.current, y = 28, k = y * 3, H = m.groups.length * m.lineHeight, F = D.current, V = m.canvasWidth / (F.visibleTimeEnd - F.visibleTimeStart), J = h - o, R = Math.max(m.canvasWidth, Math.round(J * V)), re = s + R, G = k + H, w = document.createElement("canvas");
1379
+ w.width = re * f, w.height = G * f;
1380
+ const p = w.getContext("2d");
1381
+ p.scale(f, f), p.fillStyle = "#FFFFFF", p.fillRect(0, 0, re, G), p.save(), p.beginPath(), p.rect(0, 0, s, G), p.clip(), p.fillStyle = "#F9FAFB", p.fillRect(0, 0, s, k), p.strokeStyle = "#E5E7EB", p.lineWidth = 1, p.strokeRect(0, 0, s, k);
1382
+ for (let X = 0; X < m.groups.length; X++) {
1383
+ const q = m.groups[X], ee = k + X * m.lineHeight, N = (fe = m.rowStyle) == null ? void 0 : fe.call(m, q);
1384
+ p.fillStyle = (N == null ? void 0 : N.backgroundColor) ?? (X % 2 === 0 ? "#FFFFFF" : "#F7F7F7"), p.fillRect(0, ee, s, m.lineHeight), p.strokeStyle = "#E5E5E5", p.lineWidth = 0.5, p.beginPath(), p.moveTo(0, ee + m.lineHeight), p.lineTo(s, ee + m.lineHeight), p.stroke();
1385
+ const le = q.type ?? "";
1386
+ let U = 8, ce = "400", de = 11;
1387
+ le === "project" ? (ce = "700", de = 12) : le === "control_area_group" ? ce = "600" : le === "control_area" && (U = 24), p.fillStyle = "#374151", p.font = `${ce} ${de}px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif`, p.textBaseline = "middle";
1388
+ const me = typeof q.title == "string" ? q.title : String(q.title);
1389
+ p.fillText(me, U, ee + m.lineHeight / 2, s - U - 8);
1207
1390
  }
1208
- g.strokeStyle = "#E5E7EB", g.lineWidth = 1, g.beginPath(), g.moveTo(n, 0), g.lineTo(n, G), g.stroke(), g.restore(), g.save(), g.beginPath(), g.rect(n, 0, P, k), g.clip();
1209
- const A = d - r, _ = [
1391
+ p.strokeStyle = "#E5E7EB", p.lineWidth = 1, p.beginPath(), p.moveTo(s, 0), p.lineTo(s, G), p.stroke(), p.restore(), p.save(), p.beginPath(), p.rect(s, 0, R, k), p.clip();
1392
+ const j = h - o, A = [
1210
1393
  { unit: "year", row: 0 },
1211
1394
  { unit: "month", row: 1 },
1212
1395
  { unit: "week", row: 2 }
1213
1396
  ];
1214
- for (const { unit: O, row: K } of _) {
1215
- const Q = K * b;
1216
- g.fillStyle = "#F9FAFB", g.fillRect(n, Q, P, b);
1217
- let x = me(r).startOf(O);
1218
- const oe = me(d).add(1, O);
1219
- for (; x.isBefore(oe); ) {
1220
- const ie = x.add(1, O), ge = n + (x.valueOf() - r) / A * P, se = (ie.valueOf() - x.valueOf()) / A * P;
1221
- g.strokeStyle = "#E5E7EB", g.lineWidth = 0.5, g.strokeRect(ge, Q, se, b);
1222
- let ke;
1223
- O === "year" ? ke = x.format("YYYY") : O === "month" ? ke = x.format("MM") : ke = `${x.week()}`, g.fillStyle = "#6c737f", g.font = O === "year" ? '600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' : '400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', g.textBaseline = "middle", g.textAlign = "center", se > 20 && g.fillText(ke, ge + se / 2, Q + b / 2), x = ie;
1397
+ for (const { unit: X, row: q } of A) {
1398
+ const ee = q * y;
1399
+ p.fillStyle = "#F9FAFB", p.fillRect(s, ee, R, y);
1400
+ let N = pe(o).startOf(X);
1401
+ const le = pe(h).add(1, X);
1402
+ for (; N.isBefore(le); ) {
1403
+ const U = N.add(1, X), ce = s + (N.valueOf() - o) / j * R, de = (U.valueOf() - N.valueOf()) / j * R;
1404
+ p.strokeStyle = "#E5E7EB", p.lineWidth = 0.5, p.strokeRect(ce, ee, de, y);
1405
+ let me;
1406
+ X === "year" ? me = N.format("YYYY") : X === "month" ? me = N.format("MM") : me = `${N.week()}`, p.fillStyle = "#6c737f", p.font = X === "year" ? '600 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif' : '400 11px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif', p.textBaseline = "middle", p.textAlign = "center", de > 20 && p.fillText(me, ce + de / 2, ee + y / 2), N = U;
1224
1407
  }
1225
1408
  }
1226
- g.textAlign = "start", g.restore(), g.save(), g.beginPath(), g.rect(n, k, P, C), g.clip(), g.translate(n, k);
1227
- const ae = new nt({
1228
- visibleTimeStart: r,
1229
- visibleTimeEnd: d,
1230
- canvasWidth: P,
1231
- canvasHeight: C,
1409
+ p.textAlign = "start", p.restore(), p.save(), p.beginPath(), p.rect(s, k, R, H), p.clip(), p.translate(s, k);
1410
+ const ae = new lt({
1411
+ visibleTimeStart: o,
1412
+ visibleTimeEnd: h,
1413
+ canvasWidth: R,
1414
+ canvasHeight: H,
1232
1415
  sidebarWidth: 0,
1233
- lineHeight: f.lineHeight,
1234
- groupCount: f.groups.length,
1416
+ lineHeight: m.lineHeight,
1417
+ groupCount: m.groups.length,
1235
1418
  buffer: 1,
1236
1419
  scrollTop: 0
1237
1420
  });
1238
- return He.draw(g, ae, f.groups, f.theme, f.dayStyle, f.rowStyle, f.highlights), Ce.draw(g, ae, f.groups, f.items, f.intervalTree, f.layoutEngine, f.itemRenderer, f.groupRenderer, f.theme, f.selected, void 0, f.dependencies), Ie.draw(g, ae, f.theme, { cursorX: null, markers: Xe.current }), g.restore(), E;
1421
+ return Pe.draw(p, ae, m.groups, m.theme, m.dayStyle, m.rowStyle, m.highlights), De.draw(p, ae, m.groups, m.items, m.intervalTree, m.layoutEngine, m.itemRenderer, m.groupRenderer, m.theme, m.selected, void 0, m.dependencies, m.summaryRenderer, m.hierarchyEngine), Oe.draw(p, ae, m.theme, { cursorX: null, markers: Xe.current }), p.restore(), w;
1239
1422
  }
1240
1423
  };
1241
- Be == null || Be(o);
1242
- }, [Be, He, Ce, Ie]);
1243
- const oi = {
1424
+ Ye == null || Ye(a);
1425
+ }, [Ye, Pe, De, Oe]);
1426
+ const li = {
1244
1427
  position: "relative",
1245
- width: pe,
1246
- height: ye,
1428
+ width: Se,
1429
+ height: ke,
1247
1430
  overflow: "hidden",
1248
1431
  cursor: "default"
1249
- }, rt = { position: "absolute", top: 0, left: 0 };
1250
- return Ne("div", { ref: pt, style: { display: "flex", flexDirection: "column", width: "100%" }, children: [ni, Ne("div", { ref: Nt, style: { display: "flex", overflow: "hidden" }, children: [re(Ft, { groups: s, width: m, lineHeight: u, scrollTop: kt, canvasHeight: ye, theme: Ee, groupRenderer: Y, onScroll: (o) => {
1251
- R.current.update({ scrollTop: o }), M.markDirty("grid"), M.markDirty("items"), M.markDirty("overlay"), _e(o);
1252
- } }), Ne("div", { ref: Re, style: oi, onPointerMove: Jt, onPointerDown: Qt, onPointerUp: ei, onDoubleClick: ti, onContextMenu: ii, onPointerLeave: ri, children: [re("canvas", { ref: gt, style: { ...rt, zIndex: 0 } }), re("canvas", { ref: vt, style: { ...rt, zIndex: 1 } }), re("canvas", { ref: bt, style: { ...rt, zIndex: 2 } })] }), ze && ft ? re(Ft, { groups: s, width: ze, lineHeight: u, scrollTop: kt, canvasHeight: ye, theme: Ee, groupRenderer: ft, onScroll: (o) => {
1253
- R.current.update({ scrollTop: o }), M.markDirty("grid"), M.markDirty("items"), M.markDirty("overlay"), _e(o);
1432
+ }, st = { position: "absolute", top: 0, left: 0 };
1433
+ return Ze("div", { ref: yt, style: { display: "flex", flexDirection: "column", width: "100%" }, children: [si, Ze("div", { ref: xt, style: { display: "flex", overflow: "hidden" }, children: [se(Wt, { groups: n, width: u, lineHeight: c, scrollTop: kt, canvasHeight: ke, theme: ye, groupRenderer: ne, onScroll: (a) => {
1434
+ D.current.update({ scrollTop: a }), E.markDirty("grid"), E.markDirty("items"), E.markDirty("overlay"), je(a);
1435
+ } }), Ze("div", { ref: _e, style: li, onPointerMove: ei, onPointerDown: ti, onPointerUp: ii, onDoubleClick: ni, onContextMenu: ri, onPointerLeave: oi, children: [se("canvas", { ref: pt, style: { ...st, zIndex: 0 } }), se("canvas", { ref: vt, style: { ...st, zIndex: 1 } }), se("canvas", { ref: bt, style: { ...st, zIndex: 2 } })] }), qe && mt ? se(Wt, { groups: n, width: qe, lineHeight: c, scrollTop: kt, canvasHeight: ke, theme: ye, groupRenderer: mt, onScroll: (a) => {
1436
+ D.current.update({ scrollTop: a }), E.markDirty("grid"), E.markDirty("items"), E.markDirty("overlay"), je(a);
1254
1437
  } }) : null] })] });
1255
1438
  }));
1256
- function wi({ children: i, theme: e, className: t, classNames: s, style: l, visibleTimeStart: c, visibleTimeEnd: a, canvasWidth: m, sidebarWidth: u = 0, onZoomToInterval: v }) {
1257
- const T = he.Children.map(i, (p) => {
1258
- var S;
1259
- if (!he.isValidElement(p))
1260
- return p;
1261
- if (((S = p.type) == null ? void 0 : S.displayName) === "DateHeader") {
1262
- const I = p.props, W = he.cloneElement(p, {
1263
- visibleTimeStart: I.visibleTimeStart ?? c,
1264
- visibleTimeEnd: I.visibleTimeEnd ?? a,
1265
- canvasWidth: I.canvasWidth ?? m,
1266
- theme: I.theme ?? e,
1267
- onZoomToInterval: I.onIntervalClick ?? I.onZoomToInterval ?? v
1439
+ function Pi({ children: i, theme: e, className: t, classNames: n, style: r, visibleTimeStart: d, visibleTimeEnd: l, canvasWidth: u, sidebarWidth: c = 0, onZoomToInterval: v }) {
1440
+ const M = ge.Children.map(i, (g) => {
1441
+ var T;
1442
+ if (!ge.isValidElement(g))
1443
+ return g;
1444
+ if (((T = g.type) == null ? void 0 : T.displayName) === "DateHeader") {
1445
+ const C = g.props, I = ge.cloneElement(g, {
1446
+ visibleTimeStart: C.visibleTimeStart ?? d,
1447
+ visibleTimeEnd: C.visibleTimeEnd ?? l,
1448
+ canvasWidth: C.canvasWidth ?? u,
1449
+ theme: C.theme ?? e,
1450
+ onZoomToInterval: C.onIntervalClick ?? C.onZoomToInterval ?? v
1268
1451
  });
1269
- return Ne("div", { style: { display: "flex" }, children: [re("div", { style: { width: u, flexShrink: 0 } }), re("div", { style: { flex: 1, overflow: "hidden" }, children: W })] });
1452
+ return Ze("div", { style: { display: "flex" }, children: [se("div", { style: { width: c, flexShrink: 0 } }), se("div", { style: { flex: 1, overflow: "hidden" }, children: I })] });
1270
1453
  }
1271
- return p;
1454
+ return g;
1272
1455
  });
1273
- return re("div", { className: t, style: {
1456
+ return se("div", { className: t, style: {
1274
1457
  position: "sticky",
1275
1458
  top: 0,
1276
1459
  zIndex: 20,
@@ -1279,90 +1462,90 @@ function wi({ children: i, theme: e, className: t, classNames: s, style: l, visi
1279
1462
  backgroundColor: (e == null ? void 0 : e.header.bg) ?? "#F9FAFB",
1280
1463
  borderTop: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
1281
1464
  borderBottom: `1px solid ${(e == null ? void 0 : e.header.border) ?? "#E5E7EB"}`,
1282
- ...l
1283
- }, children: T });
1465
+ ...r
1466
+ }, children: M });
1284
1467
  }
1285
- wi.displayName = "TimelineHeaders";
1286
- var xt = { exports: {} };
1468
+ Pi.displayName = "TimelineHeaders";
1469
+ var Gt = { exports: {} };
1287
1470
  (function(i, e) {
1288
- (function(t, s) {
1289
- i.exports = s();
1290
- })(At, function() {
1291
- var t = "week", s = "year";
1292
- return function(l, c, a) {
1293
- var m = c.prototype;
1294
- m.week = function(u) {
1295
- if (u === void 0 && (u = null), u !== null) return this.add(7 * (u - this.week()), "day");
1471
+ (function(t, n) {
1472
+ i.exports = n();
1473
+ })(jt, function() {
1474
+ var t = "week", n = "year";
1475
+ return function(r, d, l) {
1476
+ var u = d.prototype;
1477
+ u.week = function(c) {
1478
+ if (c === void 0 && (c = null), c !== null) return this.add(7 * (c - this.week()), "day");
1296
1479
  var v = this.$locale().yearStart || 1;
1297
1480
  if (this.month() === 11 && this.date() > 25) {
1298
- var T = a(this).startOf(s).add(1, s).date(v), p = a(this).endOf(t);
1299
- if (T.isBefore(p)) return 1;
1481
+ var M = l(this).startOf(n).add(1, n).date(v), g = l(this).endOf(t);
1482
+ if (M.isBefore(g)) return 1;
1300
1483
  }
1301
- var H = a(this).startOf(s).date(v).startOf(t).subtract(1, "millisecond"), S = this.diff(H, t, !0);
1302
- return S < 0 ? a(this).startOf("week").week() : Math.ceil(S);
1303
- }, m.weeks = function(u) {
1304
- return u === void 0 && (u = null), this.week(u);
1484
+ var b = l(this).startOf(n).date(v).startOf(t).subtract(1, "millisecond"), T = this.diff(b, t, !0);
1485
+ return T < 0 ? l(this).startOf("week").week() : Math.ceil(T);
1486
+ }, u.weeks = function(c) {
1487
+ return c === void 0 && (c = null), this.week(c);
1305
1488
  };
1306
1489
  };
1307
1490
  });
1308
- })(xt);
1309
- var Hi = xt.exports;
1310
- const Ci = /* @__PURE__ */ Yt(Hi);
1311
- me.extend(Ci);
1312
- const Ii = {
1491
+ })(Gt);
1492
+ var Di = Gt.exports;
1493
+ const Oi = /* @__PURE__ */ Nt(Di);
1494
+ pe.extend(Oi);
1495
+ const _i = {
1313
1496
  year: 30,
1314
1497
  month: 30,
1315
1498
  week: 20,
1316
1499
  day: 15,
1317
1500
  hour: 30
1318
1501
  };
1319
- function Ri({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWidth: s = 0, theme: l, height: c = 28, className: a, labelFormat: m, onIntervalClick: u, minCellWidth: v, onZoomToInterval: T }) {
1320
- const p = ce(() => {
1321
- if (!e || !t || !s)
1502
+ function Fi({ unit: i, visibleTimeStart: e = 0, visibleTimeEnd: t = 0, canvasWidth: n = 0, theme: r, height: d = 28, className: l, labelFormat: u, onIntervalClick: c, minCellWidth: v, onZoomToInterval: M }) {
1503
+ const g = oe(() => {
1504
+ if (!e || !t || !n)
1322
1505
  return [];
1323
- const S = t - e, I = v ?? Ii[i];
1324
- if (I > 0) {
1325
- const y = me(e).startOf(i);
1326
- if ((y.add(1, i).valueOf() - y.valueOf()) / S * s < I)
1506
+ const T = t - e, C = v ?? _i[i];
1507
+ if (C > 0) {
1508
+ const S = pe(e).startOf(i);
1509
+ if ((S.add(1, i).valueOf() - S.valueOf()) / T * n < C)
1327
1510
  return [];
1328
1511
  }
1329
- const W = [];
1330
- let L = me(e).startOf(i).subtract(1, i);
1331
- const j = me(t).add(2, i).valueOf();
1332
- for (; L.valueOf() < j; ) {
1333
- const y = L.add(1, i), D = L.valueOf(), B = y.valueOf(), $ = (D - e) / S * s, w = (B - D) / S * s, Y = Di(L, y, i, m);
1334
- W.push({ start: D, end: B, label: Y, left: $, width: w }), L = y;
1512
+ const I = [];
1513
+ let W = pe(e).startOf(i).subtract(1, i);
1514
+ const $ = pe(t).add(2, i).valueOf();
1515
+ for (; W.valueOf() < $; ) {
1516
+ const S = W.add(1, i), _ = W.valueOf(), B = S.valueOf(), Y = (_ - e) / T * n, x = (B - _) / T * n, ne = Wi(W, S, i, u);
1517
+ I.push({ start: _, end: B, label: ne, left: Y, width: x }), W = S;
1335
1518
  }
1336
- return W;
1337
- }, [e, t, s, i, m, v]), H = ee((S, I) => {
1338
- u ? u(S, I) : T && T(S, I);
1339
- }, [u, T]);
1340
- return p.length === 0 ? null : re("div", { style: { display: "flex", position: "relative", height: c, overflow: "hidden" }, children: p.map((S) => re("div", { className: a, onClick: () => H(S.start, S.end), style: {
1519
+ return I;
1520
+ }, [e, t, n, i, u, v]), b = ie((T, C) => {
1521
+ c ? c(T, C) : M && M(T, C);
1522
+ }, [c, M]);
1523
+ return g.length === 0 ? null : se("div", { style: { display: "flex", position: "relative", height: d, overflow: "hidden" }, children: g.map((T) => se("div", { className: l, onClick: () => b(T.start, T.end), style: {
1341
1524
  position: "absolute",
1342
- left: S.left,
1343
- width: S.width,
1525
+ left: T.left,
1526
+ width: T.width,
1344
1527
  height: "100%",
1345
1528
  display: "flex",
1346
1529
  alignItems: "center",
1347
1530
  justifyContent: "center",
1348
- borderRight: `1px solid ${(l == null ? void 0 : l.header.border) ?? "#E5E7EB"}`,
1349
- borderBottom: `1px solid ${(l == null ? void 0 : l.header.border) ?? "#E5E7EB"}`,
1531
+ borderRight: `1px solid ${(r == null ? void 0 : r.header.border) ?? "#E5E7EB"}`,
1532
+ borderBottom: `1px solid ${(r == null ? void 0 : r.header.border) ?? "#E5E7EB"}`,
1350
1533
  fontSize: 12,
1351
- color: (l == null ? void 0 : l.header.text) ?? "#6c737f",
1352
- backgroundColor: (l == null ? void 0 : l.header.bg) ?? "#F9FAFB",
1534
+ color: (r == null ? void 0 : r.header.text) ?? "#6c737f",
1535
+ backgroundColor: (r == null ? void 0 : r.header.bg) ?? "#F9FAFB",
1353
1536
  overflow: "hidden",
1354
1537
  whiteSpace: "nowrap",
1355
1538
  cursor: "pointer",
1356
1539
  userSelect: "none",
1357
1540
  padding: "0 4px",
1358
1541
  boxSizing: "border-box"
1359
- }, children: re("span", { children: S.label }) }, S.start)) });
1542
+ }, children: se("span", { children: T.label }) }, T.start)) });
1360
1543
  }
1361
- Ri.displayName = "DateHeader";
1362
- function Di(i, e, t, s, l) {
1363
- return typeof s == "function" ? s(i.toDate(), e.toDate(), t) : typeof s == "string" ? i.format(s) : Pi(i, t);
1544
+ Fi.displayName = "DateHeader";
1545
+ function Wi(i, e, t, n, r) {
1546
+ return typeof n == "function" ? n(i.toDate(), e.toDate(), t) : typeof n == "string" ? i.format(n) : Xi(i, t);
1364
1547
  }
1365
- function Pi(i, e) {
1548
+ function Xi(i, e) {
1366
1549
  switch (e) {
1367
1550
  case "year":
1368
1551
  return i.format("YYYY");
@@ -1376,23 +1559,24 @@ function Pi(i, e) {
1376
1559
  return i.format("HH:mm");
1377
1560
  }
1378
1561
  }
1379
- function Xi({ width: i, children: e, style: t }) {
1380
- const s = () => ({ style: { width: i, ...t } });
1381
- return e ? re(_t, { children: e({ getRootProps: s }) }) : re("div", { style: { width: i } });
1562
+ function Bi({ width: i, children: e, style: t }) {
1563
+ const n = () => ({ style: { width: i, ...t } });
1564
+ return e ? se(At, { children: e({ getRootProps: n }) }) : se("div", { style: { width: i } });
1382
1565
  }
1383
- Xi.displayName = "SidebarHeader";
1384
- function Fi({ children: i }) {
1385
- return re(_t, { children: i });
1566
+ Bi.displayName = "SidebarHeader";
1567
+ function Li({ children: i }) {
1568
+ return se(At, { children: i });
1386
1569
  }
1387
- Fi.displayName = "CustomHeader";
1570
+ Li.displayName = "CustomHeader";
1388
1571
  export {
1389
- Li as CanvasTimeline,
1390
- Fi as CustomHeader,
1391
- Ei as CustomMarker,
1392
- Se as DEFAULT_THEME,
1393
- Ri as DateHeader,
1394
- Xi as SidebarHeader,
1395
- wi as TimelineHeaders,
1396
- ki as TodayMarker
1572
+ $i as CanvasTimeline,
1573
+ Li as CustomHeader,
1574
+ Ii as CustomMarker,
1575
+ we as DEFAULT_THEME,
1576
+ Fi as DateHeader,
1577
+ mi as HierarchyEngine,
1578
+ Bi as SidebarHeader,
1579
+ Pi as TimelineHeaders,
1580
+ Ci as TodayMarker
1397
1581
  };
1398
1582
  //# sourceMappingURL=canvas-timeline.es.js.map