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