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