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