zegantt 0.1.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.
@@ -0,0 +1,1753 @@
1
+ import { jsx as t, jsxs as s, Fragment as ie } from "react/jsx-runtime";
2
+ import { createContext as Ze, useContext as Qe, useRef as ue, useCallback as V, useEffect as le, useState as Y, useMemo as re } from "react";
3
+ import { Flag as we, Clock as ke, MessageCircle as et, Plus as tt, ChevronDown as Ce, ChevronRight as ze, Paperclip as je, AlertTriangle as ot, Eye as rt, Edit2 as nt, Trash2 as it, Loader2 as st } from "lucide-react";
4
+ const Xe = Ze(void 0);
5
+ function at({ children: o, value: g }) {
6
+ return /* @__PURE__ */ t(Xe.Provider, { value: g, children: o });
7
+ }
8
+ function Se() {
9
+ const o = Qe(Xe);
10
+ if (!o)
11
+ throw new Error("useGanttContext must be used within a GanttProvider");
12
+ return o;
13
+ }
14
+ const G = {
15
+ white: "#FFFFFF",
16
+ dark_gray: "#4F4F4F",
17
+ gray: "#7B7B7B",
18
+ light_gray: "#D9D9D9",
19
+ dark_green: "#1A3C30",
20
+ water_green: "#7ab7a3",
21
+ light_green: "#A0D8A8",
22
+ orange: "#CD6200",
23
+ yellow: "#FFBB1C",
24
+ red: "#FF0000"
25
+ }, e = {
26
+ pageBg: "#F8FAFB",
27
+ surface: G.white,
28
+ // #FFFFFF
29
+ surfaceAlt: "#F7FAF8",
30
+ // subtle alternating row
31
+ headerBg: "#F2F5F3",
32
+ // soft green-tinted header
33
+ textTitle: G.dark_green,
34
+ // #1A3C30
35
+ textPrimary: G.dark_gray,
36
+ // #4F4F4F
37
+ textSecondary: G.gray,
38
+ // #7B7B7B
39
+ textMuted: G.light_gray,
40
+ // #D9D9D9
41
+ group: G.dark_green,
42
+ // #1A3C30
43
+ groupLight: G.water_green,
44
+ // #A0D8A8 (bar border)
45
+ milestone: G.dark_green,
46
+ // #1A3C30
47
+ milestoneRing: G.light_green,
48
+ // #A0D8A8
49
+ event: G.orange,
50
+ // yellow translucent
51
+ note: G.yellow,
52
+ // #FFBB1C
53
+ border: G.light_gray,
54
+ // #D9D9D9
55
+ borderLight: "#ECECEC",
56
+ weekendBg: "#F4F6F5",
57
+ today: G.red,
58
+ // #FF0000
59
+ todayBg: "#FF000008",
60
+ // today column tint
61
+ arrow: G.gray,
62
+ // #7B7B7B
63
+ arrowHover: G.dark_green
64
+ // #1A3C30
65
+ }, X = 50, ve = 32, dt = ve * 2, lt = 460, Q = 26, Ne = 28, Oe = 120, ct = 40, pt = 3.5, te = [
66
+ { bar: "#D1D8A0", barBorder: "#A0D8A8", progress: "#1A3C30" },
67
+ // sistema (light_yellow)
68
+ { bar: "#A0D8C8", barBorder: "#6BBFA8", progress: "#14534A" },
69
+ // teal
70
+ { bar: "#B8C9E8", barBorder: "#8AAAD6", progress: "#2C4A70" },
71
+ // blue
72
+ { bar: "#E8C9A0", barBorder: "#D6AA7A", progress: "#6B4510" },
73
+ // amber
74
+ { bar: "#D8A0C8", barBorder: "#C47AAE", progress: "#6B2058" },
75
+ // pink
76
+ { bar: "#A0C8D8", barBorder: "#74ACBF", progress: "#1A4F60" },
77
+ // sky
78
+ { bar: "#C8D8A0", barBorder: "#A8BF74", progress: "#3F5014" },
79
+ // lime
80
+ { bar: "#D8B0A0", barBorder: "#C4907A", progress: "#6B3020" },
81
+ // coral
82
+ { bar: "#B0A0D8", barBorder: "#937ACE", progress: "#3A2070" },
83
+ // violet
84
+ { bar: "#A0D8B0", barBorder: "#70C888", progress: "#1A5030" }
85
+ // mint
86
+ ], Fe = {
87
+ step: "Etapas",
88
+ milestone: "Marcos",
89
+ event: "Eventos",
90
+ note: "Notas"
91
+ };
92
+ function ut() {
93
+ const {
94
+ props: o,
95
+ t: g,
96
+ viewMode: d,
97
+ setViewMode: N,
98
+ visibleTypes: f,
99
+ setVisibleTypes: b,
100
+ newActionOpen: I,
101
+ setNewActionOpen: T,
102
+ newActionRef: S
103
+ } = Se(), { projectName: D, onAddNewStage: E, onAddMilestone: k, onAddEvent: w, onAddNote: p } = o, x = (c) => {
104
+ b((a) => {
105
+ const l = new Set(a);
106
+ return l.has(c) ? l.delete(c) : l.add(c), l;
107
+ });
108
+ };
109
+ return /* @__PURE__ */ s(
110
+ "div",
111
+ {
112
+ className: "flex items-center justify-between px-6 py-5",
113
+ style: { borderBottom: `1px solid ${e.border}`, background: `linear-gradient(180deg, ${e.headerBg} 0%, ${e.surface} 100%)` },
114
+ children: [
115
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-4", children: [
116
+ /* @__PURE__ */ s("div", { children: [
117
+ /* @__PURE__ */ t("h3", { className: "text-sm font-bold uppercase tracking-widest", style: { color: e.textTitle }, children: g("planning.gantt", "PLANEJAMENTO DA OBRA") }),
118
+ /* @__PURE__ */ t("div", { className: "h-[2.5px] w-16 mt-1.5 rounded-full", style: { background: `linear-gradient(90deg, ${e.group}, ${e.milestoneRing})` } })
119
+ ] }),
120
+ D && /* @__PURE__ */ t(
121
+ "span",
122
+ {
123
+ className: "text-xs font-medium px-3 py-1 rounded-full",
124
+ style: { color: e.textSecondary, background: e.surface, border: `1px solid ${e.border}` },
125
+ children: D
126
+ }
127
+ )
128
+ ] }),
129
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-3", children: [
130
+ /* @__PURE__ */ t("div", { className: "flex p-1 rounded-lg", style: { background: "rgba(122,122,122,0.07)", border: `1px solid ${e.borderLight}` }, children: ["month", "year"].map((c) => /* @__PURE__ */ t(
131
+ "button",
132
+ {
133
+ onClick: () => N(c),
134
+ className: "px-5 py-1.5 text-xs font-semibold rounded-md transition-all duration-200",
135
+ style: d === c ? { background: e.surface, color: e.group, boxShadow: "0 1px 3px rgb(0 0 0 / 0.08)" } : { color: e.textSecondary },
136
+ children: c === "month" ? g("charts.gantt.month", "Mês") : g("charts.gantt.year", "Ano")
137
+ },
138
+ c
139
+ )) }),
140
+ /* @__PURE__ */ t("div", { className: "flex p-1 rounded-lg gap-0.5", style: { background: "rgba(122,122,122,0.07)", border: `1px solid ${e.borderLight}` }, children: [
141
+ { type: "step", label: "Etapas", icon: /* @__PURE__ */ t("div", { className: "w-2.5 h-2.5 rounded-sm", style: { background: te[0].bar, border: `1px solid ${te[0].barBorder}` } }) },
142
+ { type: "milestone", label: "Marcos", icon: /* @__PURE__ */ t(we, { size: 11, style: { color: e.milestone } }) },
143
+ { type: "event", label: "Eventos", icon: /* @__PURE__ */ t(ke, { size: 11, style: { color: e.event } }) },
144
+ { type: "note", label: "Notas", icon: /* @__PURE__ */ t(et, { size: 11, style: { color: e.note } }) }
145
+ ].map((c) => {
146
+ const a = f.has(c.type);
147
+ return /* @__PURE__ */ s(
148
+ "button",
149
+ {
150
+ onClick: () => x(c.type),
151
+ className: "flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-semibold rounded-md transition-all duration-200",
152
+ style: a ? { background: e.surface, color: e.group, boxShadow: "0 1px 3px rgb(0 0 0 / 0.08)" } : { color: e.textMuted, opacity: 0.5 },
153
+ children: [
154
+ c.icon,
155
+ /* @__PURE__ */ t("span", { children: c.label })
156
+ ]
157
+ },
158
+ c.type
159
+ );
160
+ }) }),
161
+ E && /* @__PURE__ */ s("div", { ref: S, style: { position: "relative" }, children: [
162
+ /* @__PURE__ */ s(
163
+ "button",
164
+ {
165
+ onClick: () => T((c) => !c),
166
+ className: "flex items-center gap-2 px-5 py-2.5 rounded-lg text-sm font-semibold text-white transition-all duration-200 hover:shadow-lg hover:scale-[1.02] active:scale-[0.98]",
167
+ style: { background: `linear-gradient(135deg, ${e.group}, ${e.group}dd)` },
168
+ children: [
169
+ /* @__PURE__ */ t(tt, { size: 16 }),
170
+ /* @__PURE__ */ t("span", { children: g("charts.gantt.newAction", "Nova Ação") }),
171
+ /* @__PURE__ */ t(Ce, { size: 14, style: { opacity: 0.7, transform: I ? "rotate(180deg)" : "none", transition: "transform 0.18s" } })
172
+ ]
173
+ }
174
+ ),
175
+ I && /* @__PURE__ */ t(
176
+ "div",
177
+ {
178
+ style: {
179
+ position: "absolute",
180
+ top: "calc(100% + 6px)",
181
+ right: 0,
182
+ zIndex: 99999,
183
+ background: "#fff",
184
+ borderRadius: 10,
185
+ boxShadow: "0 12px 40px rgba(0,0,0,0.15), 0 3px 10px rgba(0,0,0,0.08)",
186
+ border: `1.5px solid ${e.borderLight}`,
187
+ width: 200,
188
+ overflow: "hidden",
189
+ padding: "5px 5px"
190
+ },
191
+ onClick: (c) => c.stopPropagation(),
192
+ children: [
193
+ {
194
+ label: "Etapa",
195
+ icon: /* @__PURE__ */ t("div", { style: { width: 14, height: 14, borderRadius: 3, background: te[0].bar, border: `1.5px solid ${te[0].barBorder}`, flexShrink: 0 } }),
196
+ action: () => {
197
+ E(), T(!1);
198
+ }
199
+ },
200
+ {
201
+ label: "Marco",
202
+ icon: /* @__PURE__ */ t("div", { style: { width: 22, height: 22, borderRadius: "50%", background: `${e.milestoneRing}30`, border: `1.5px solid ${e.milestoneRing}`, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, children: /* @__PURE__ */ t(we, { size: 11, style: { color: e.milestone } }) }),
203
+ action: () => {
204
+ k?.(), T(!1);
205
+ }
206
+ },
207
+ {
208
+ label: "Evento",
209
+ icon: /* @__PURE__ */ t("div", { style: { width: 22, height: 22, borderRadius: "50%", background: `${e.event}18`, border: `1.5px solid ${e.event}55`, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, children: /* @__PURE__ */ t(ke, { size: 11, style: { color: e.event } }) }),
210
+ action: () => {
211
+ w?.(), T(!1);
212
+ }
213
+ },
214
+ {
215
+ label: "Nota",
216
+ icon: /* @__PURE__ */ t("div", { style: { width: 16, height: 20, background: e.note, borderRadius: 2, boxShadow: "1px 1px 3px rgba(0,0,0,0.14)", position: "relative", overflow: "visible", flexShrink: 0 }, children: /* @__PURE__ */ t("div", { style: { position: "absolute", top: -2, left: "50%", transform: "translateX(-50%)", width: 10, height: 4, background: "rgba(255,255,255,0.55)", borderRadius: 1 } }) }),
217
+ action: () => {
218
+ p?.(), T(!1);
219
+ }
220
+ }
221
+ ].map((c) => /* @__PURE__ */ s(
222
+ "button",
223
+ {
224
+ onClick: c.action,
225
+ style: {
226
+ display: "flex",
227
+ alignItems: "center",
228
+ gap: 10,
229
+ width: "100%",
230
+ padding: "8px 10px",
231
+ borderRadius: 7,
232
+ border: "none",
233
+ background: "transparent",
234
+ cursor: "pointer",
235
+ fontSize: 13,
236
+ fontWeight: 500,
237
+ color: e.textPrimary,
238
+ textAlign: "left",
239
+ transition: "background 0.12s"
240
+ },
241
+ onMouseEnter: (a) => {
242
+ a.currentTarget.style.background = e.headerBg;
243
+ },
244
+ onMouseLeave: (a) => {
245
+ a.currentTarget.style.background = "transparent";
246
+ },
247
+ children: [
248
+ c.icon,
249
+ c.label
250
+ ]
251
+ },
252
+ c.label
253
+ ))
254
+ }
255
+ )
256
+ ] })
257
+ ] })
258
+ ]
259
+ }
260
+ );
261
+ }
262
+ const _e = 864e5, q = (o, g) => new Date(o.getTime() + g * _e), he = (o, g) => Math.round((g.getTime() - o.getTime()) / _e), Pe = (o) => new Date(o.getFullYear(), o.getMonth(), 1), Be = (o) => new Date(o.getFullYear(), o.getMonth() + 1, 0), ee = (o) => `${String(o.getDate()).padStart(2, "0")}/${String(o.getMonth() + 1).padStart(2, "0")}/${o.getFullYear()}`, Ye = {
263
+ 0: "JANEIRO",
264
+ 1: "FEVEREIRO",
265
+ 2: "MARÇO",
266
+ 3: "ABRIL",
267
+ 4: "MAIO",
268
+ 5: "JUNHO",
269
+ 6: "JULHO",
270
+ 7: "AGOSTO",
271
+ 8: "SETEMBRO",
272
+ 9: "OUTUBRO",
273
+ 10: "NOVEMBRO",
274
+ 11: "DEZEMBRO"
275
+ };
276
+ function ht() {
277
+ const {
278
+ props: o,
279
+ t: g,
280
+ displayRows: d,
281
+ leftBodyRef: N,
282
+ handleLeftScroll: f,
283
+ toggleProject: b,
284
+ toggleGroup: I,
285
+ hoveredTaskId: T,
286
+ setHoveredTaskId: S,
287
+ selectedTaskId: D,
288
+ setSelectedTaskId: E,
289
+ delayedIds: k,
290
+ criticalIds: w,
291
+ relatedIds: p
292
+ } = Se(), x = 540, c = (a) => ({
293
+ id: a.id,
294
+ name: a.name,
295
+ start: a.start,
296
+ end: a.end,
297
+ type: a.originalType === "step" ? "task" : "milestone",
298
+ progress: a.progress
299
+ });
300
+ return /* @__PURE__ */ s("div", { style: { width: lt, flexShrink: 0, borderRight: `1px solid ${e.border}` }, children: [
301
+ /* @__PURE__ */ s(
302
+ "div",
303
+ {
304
+ className: "flex items-center px-4",
305
+ style: { height: dt, background: e.headerBg, borderBottom: `1px solid ${e.border}` },
306
+ children: [
307
+ /* @__PURE__ */ t("div", { className: "flex-1 text-[11px] font-bold uppercase tracking-wider", style: { color: e.textSecondary }, children: g("charts.gantt.stepName", "NOME DA ETAPA") }),
308
+ /* @__PURE__ */ t("div", { className: "w-[80px] text-[11px] font-bold uppercase tracking-wider text-center", style: { color: e.textSecondary }, children: g("charts.gantt.start", "INÍCIO") }),
309
+ /* @__PURE__ */ t("div", { className: "w-[80px] text-[11px] font-bold uppercase tracking-wider text-center", style: { color: e.textSecondary }, children: g("charts.gantt.end", "FIM") })
310
+ ]
311
+ }
312
+ ),
313
+ /* @__PURE__ */ t(
314
+ "div",
315
+ {
316
+ ref: N,
317
+ onScroll: f,
318
+ className: "overflow-y-auto overflow-x-hidden",
319
+ style: { maxHeight: x, scrollbarWidth: "none" },
320
+ children: d.map((a) => {
321
+ if (a.kind === "projectHeader")
322
+ return /* @__PURE__ */ t(
323
+ "div",
324
+ {
325
+ className: "flex items-center px-4 cursor-pointer select-none",
326
+ style: { height: X, borderBottom: `1.5px solid ${e.group}44`, background: `${e.group}0E` },
327
+ onClick: () => b(a.projectId),
328
+ children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
329
+ a.collapsed ? /* @__PURE__ */ t(ze, { size: 15, style: { color: e.group, flexShrink: 0 } }) : /* @__PURE__ */ t(Ce, { size: 15, style: { color: e.group, flexShrink: 0 } }),
330
+ /* @__PURE__ */ t("span", { className: "text-[12px] font-bold uppercase tracking-widest truncate", style: { color: e.group }, children: a.projectTitle })
331
+ ] })
332
+ },
333
+ `ph-${a.projectId}`
334
+ );
335
+ if (a.kind === "group") {
336
+ const z = a.projectId ? `${a.projectId}-${a.groupType}` : a.groupType;
337
+ return /* @__PURE__ */ t(
338
+ "div",
339
+ {
340
+ className: "flex items-center px-4 cursor-pointer select-none",
341
+ style: { height: X, borderBottom: `1px solid ${e.border}`, background: e.headerBg },
342
+ onClick: () => I(z),
343
+ children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
344
+ a.collapsed ? /* @__PURE__ */ t(ze, { size: 14, style: { color: e.textSecondary, flexShrink: 0 } }) : /* @__PURE__ */ t(Ce, { size: 14, style: { color: e.textSecondary, flexShrink: 0 } }),
345
+ /* @__PURE__ */ t("span", { className: "text-[11px] font-bold uppercase tracking-wider", style: { color: e.textTitle }, children: a.label }),
346
+ /* @__PURE__ */ t("span", { className: "text-[10px] font-semibold px-1.5 py-0.5 rounded-full", style: { background: "rgba(0,0,0,0.06)", color: e.textSecondary }, children: a.count })
347
+ ] })
348
+ },
349
+ `g-${z}`
350
+ );
351
+ }
352
+ const l = a.task, u = D === l.id, h = T === l.id, $ = l.originalType !== "step", r = k.has(l.id), v = w.has(l.id), B = D !== null && l.id !== D && !p.has(l.id), A = D !== null && p.has(l.id), W = r ? "#FFF5F5" : u ? e.groupLight : A ? `${e.groupLight}99` : h ? e.pageBg : e.surface;
353
+ return /* @__PURE__ */ s(
354
+ "div",
355
+ {
356
+ className: "flex items-center px-4 cursor-pointer transition-colors duration-150",
357
+ style: {
358
+ height: X,
359
+ borderBottom: `1px solid ${e.borderLight}`,
360
+ background: W,
361
+ borderLeft: u ? `3px solid ${e.group}` : A ? `3px solid ${e.group}66` : v ? `3px solid ${e.today}` : void 0,
362
+ opacity: B ? 0.3 : 1,
363
+ transition: "opacity 0.18s, background 0.15s"
364
+ },
365
+ onClick: () => E((z) => z === l.id ? null : l.id),
366
+ onDoubleClick: () => o.onTaskClick?.(c(l)),
367
+ onMouseEnter: () => S(l.id),
368
+ onMouseLeave: () => S(null),
369
+ children: [
370
+ /* @__PURE__ */ s("div", { className: "flex-1 flex items-center gap-2 min-w-0 pr-2", children: [
371
+ l.originalType === "step" && /* @__PURE__ */ t("div", { className: "flex-shrink-0 rounded", style: { width: 14, height: 14, background: te[l.colorIdx ?? 0].bar, border: `1.5px solid ${te[l.colorIdx ?? 0].barBorder}` } }),
372
+ l.originalType === "milestone" && /* @__PURE__ */ t("div", { className: "flex-shrink-0 flex items-center justify-center rounded-full", style: { width: 22, height: 22, background: `${e.milestoneRing}30`, border: `1.5px solid ${e.milestoneRing}` }, children: /* @__PURE__ */ t(we, { size: 11, style: { color: e.milestone } }) }),
373
+ l.originalType === "event" && /* @__PURE__ */ t("div", { className: "flex-shrink-0 flex items-center justify-center rounded-full", style: { width: 22, height: 22, background: `${e.event}18`, border: `1.5px solid ${e.event}55` }, children: /* @__PURE__ */ t(ke, { size: 11, style: { color: e.event } }) }),
374
+ l.originalType === "note" && /* @__PURE__ */ t("div", { className: "flex-shrink-0", style: { width: 16, height: 20, background: l.noteColor || e.note, borderRadius: 2, boxShadow: "1px 1px 3px rgba(0,0,0,0.14)", position: "relative", overflow: "visible" }, children: /* @__PURE__ */ t("div", { style: { position: "absolute", top: -2, left: "50%", transform: "translateX(-50%)", width: 10, height: 4, background: "rgba(255,255,255,0.55)", borderRadius: 1 } }) }),
375
+ /* @__PURE__ */ s("div", { className: "flex-1 flex flex-col min-w-0", children: [
376
+ /* @__PURE__ */ t(
377
+ "span",
378
+ {
379
+ className: "text-[13px] truncate font-medium leading-tight",
380
+ style: { color: u ? e.group : r ? e.today : e.textPrimary },
381
+ children: l.name
382
+ }
383
+ ),
384
+ l.originalType === "note" && l.noteProjectTitle && /* @__PURE__ */ t("span", { className: "text-[10px] truncate", style: { color: e.textSecondary, marginTop: 1 }, children: l.noteProjectTitle })
385
+ ] }),
386
+ l.originalType === "note" && (l.filesCount || 0) > 0 && /* @__PURE__ */ s("span", { className: "flex-shrink-0 flex items-center gap-0.5 text-[10px] px-1.5 py-0.5 rounded-full", style: { color: e.textSecondary, background: e.headerBg, border: `1px solid ${e.borderLight}` }, children: [
387
+ /* @__PURE__ */ t(je, { size: 9 }),
388
+ l.filesCount
389
+ ] }),
390
+ r && /* @__PURE__ */ t(ot, { size: 12, className: "flex-shrink-0", style: { color: e.today } })
391
+ ] }),
392
+ /* @__PURE__ */ t("div", { className: "w-[80px] text-[11px] font-medium text-center tabular-nums", style: { color: r ? e.today : e.textMuted }, children: ee(l.start) }),
393
+ /* @__PURE__ */ t("div", { className: "w-[80px] text-[11px] font-medium text-center tabular-nums", style: { color: r ? e.today : e.textMuted }, children: $ ? "—" : ee(l.end) })
394
+ ]
395
+ },
396
+ l.id
397
+ );
398
+ })
399
+ }
400
+ )
401
+ ] });
402
+ }
403
+ function gt(o, g) {
404
+ const d = g === "day" ? ct : pt, N = (x, c) => {
405
+ const a = [], l = (/* @__PURE__ */ new Date()).toDateString();
406
+ let u = -1;
407
+ for (let h = 0; h < c; h++) {
408
+ const $ = q(x, h), r = $.toDateString() === l;
409
+ r && (u = h), a.push({
410
+ date: $,
411
+ isToday: r,
412
+ isWeekend: $.getDay() === 0 || $.getDay() === 6
413
+ });
414
+ }
415
+ return { daysArr: a, todayIndex: u };
416
+ };
417
+ if (o.length === 0) {
418
+ const x = /* @__PURE__ */ new Date(), c = Pe(x), a = Be(x), l = he(c, a) + 1, { daysArr: u, todayIndex: h } = N(c, l);
419
+ return {
420
+ start: c,
421
+ end: a,
422
+ totalDays: l,
423
+ dayWidth: d,
424
+ totalWidth: l * d,
425
+ months: [{ date: c, label: `${Ye[c.getMonth()]} DE ${c.getFullYear()}`, startDay: 0, days: l, width: l * d }],
426
+ years: [{ label: c.getFullYear().toString(), width: l * d }],
427
+ days: u,
428
+ todayIndex: h
429
+ };
430
+ }
431
+ let f = new Date(o[0].start), b = new Date(o[0].end);
432
+ o.forEach((x) => {
433
+ x.start < f && (f = new Date(x.start)), x.end > b && (b = new Date(x.end));
434
+ });
435
+ const I = Pe(q(f, -14)), T = Be(q(b, 14)), S = he(I, T) + 1, D = [];
436
+ let E = new Date(I);
437
+ for (; E <= T; ) {
438
+ const x = Be(E), c = x > T ? T : x, a = he(I, E), l = he(E, c) + 1;
439
+ D.push({
440
+ date: new Date(E),
441
+ label: `${Ye[E.getMonth()]} DE ${E.getFullYear()}`,
442
+ startDay: a,
443
+ days: l,
444
+ width: l * d
445
+ }), E = new Date(E.getFullYear(), E.getMonth() + 1, 1);
446
+ }
447
+ const { daysArr: k, todayIndex: w } = N(I, S), p = [];
448
+ if (g === "month") {
449
+ let x = "", c = 0;
450
+ for (const a of D) {
451
+ const l = a.date.getFullYear().toString();
452
+ l !== x ? (x && p.push({ label: x, width: c * d }), x = l, c = a.days) : c += a.days;
453
+ }
454
+ x && p.push({ label: x, width: c * d });
455
+ }
456
+ return { start: I, end: T, totalDays: S, dayWidth: d, totalWidth: S * d, months: D, years: p, days: k, todayIndex: w };
457
+ }
458
+ function ne(o, g) {
459
+ return he(g.start, o) * g.dayWidth;
460
+ }
461
+ function ft({
462
+ task: o,
463
+ x: g,
464
+ y: d,
465
+ w: N,
466
+ progW: f,
467
+ isHov: b,
468
+ isDrag: I,
469
+ isResize: T,
470
+ isCritical: S,
471
+ isDelayed: D,
472
+ isConnectTarget: E,
473
+ showDots: k,
474
+ isBarDimmed: w,
475
+ isBarHighlighted: p,
476
+ commonEvents: x,
477
+ handleResizeMouseDown: c,
478
+ handleConnectDotMouseDown: a
479
+ }) {
480
+ const { timeline: l, viewMode: u } = Se();
481
+ if (o.originalType === "step") {
482
+ const h = te[o.colorIdx ?? 0], $ = d + (X - Q) / 2, r = !!(o.previsionStart && o.previsionEnd), v = r ? ne(o.previsionStart, l) : 0, B = r ? Math.max(ne(o.previsionEnd, l) - v, u === "month" ? l.dayWidth : 6) : 0, A = $ + Q + 3;
483
+ return /* @__PURE__ */ s(ie, { children: [
484
+ r && /* @__PURE__ */ t(
485
+ "div",
486
+ {
487
+ title: `Previsto: ${ee(o.previsionStart)} → ${ee(o.previsionEnd)}`,
488
+ style: {
489
+ position: "absolute",
490
+ left: v,
491
+ top: A,
492
+ width: B,
493
+ height: 5,
494
+ borderRadius: 3,
495
+ background: `${h.progress}33`,
496
+ border: `1.5px solid ${h.progress}66`,
497
+ boxShadow: `inset 0 0 0 1px ${h.progress}22`,
498
+ pointerEvents: "none",
499
+ zIndex: 5
500
+ }
501
+ }
502
+ ),
503
+ /* @__PURE__ */ s(
504
+ "div",
505
+ {
506
+ "data-task-id": o.id,
507
+ ...x,
508
+ style: {
509
+ position: "absolute",
510
+ left: g,
511
+ top: $,
512
+ width: N,
513
+ height: Q,
514
+ borderRadius: Q / 2,
515
+ background: D ? "linear-gradient(135deg, #fdd, #fee)" : h.bar,
516
+ border: S ? `2px solid ${e.today}` : D ? `1.5px solid ${e.today}88` : `1.5px solid ${h.barBorder}`,
517
+ cursor: I || T ? "grabbing" : "grab",
518
+ zIndex: b || E ? 20 : 10,
519
+ boxShadow: E ? `0 0 0 2px ${e.group}, 0 4px 16px ${e.group}33` : S ? `0 0 0 1px ${e.today}44, 0 3px 12px ${e.today}22` : p && !b ? `0 0 0 2px ${e.group}99, 0 3px 14px ${e.group}33` : b ? `0 3px 12px ${h.progress}22` : "none",
520
+ transform: b ? "scaleY(1.06)" : "scaleY(1)",
521
+ opacity: w ? 0.15 : 1,
522
+ transition: I || T ? "none" : "box-shadow 0.2s, transform 0.15s, opacity 0.18s",
523
+ overflow: "visible"
524
+ },
525
+ children: [
526
+ /* @__PURE__ */ s("div", { style: { position: "absolute", left: 0, top: 0, width: N, height: "100%", borderRadius: Q / 2, overflow: "hidden", pointerEvents: "none" }, children: [
527
+ /* @__PURE__ */ t("div", { style: {
528
+ position: "absolute",
529
+ left: 0,
530
+ top: 0,
531
+ width: f,
532
+ height: "100%",
533
+ background: D ? `linear-gradient(90deg, ${e.today}cc, ${e.today}88)` : `linear-gradient(90deg, ${h.progress}, ${h.progress}cc)`,
534
+ borderRadius: `${Q / 2}px 0 0 ${Q / 2}px`,
535
+ transition: I || T ? "none" : "width 0.3s"
536
+ } }),
537
+ N > 50 && /* @__PURE__ */ s("span", { style: {
538
+ position: "absolute",
539
+ inset: 0,
540
+ display: "flex",
541
+ alignItems: "center",
542
+ justifyContent: "center",
543
+ fontSize: 10,
544
+ fontWeight: 700,
545
+ letterSpacing: "0.05em",
546
+ color: o.progress > 50 ? "#fff" : D ? e.today : h.progress,
547
+ zIndex: 1,
548
+ pointerEvents: "none"
549
+ }, children: [
550
+ Math.round(o.progress),
551
+ "%"
552
+ ] })
553
+ ] }),
554
+ /* @__PURE__ */ t("div", { onMouseDown: (W) => c(W, o, "left"), style: { position: "absolute", left: 0, top: 0, width: 8, height: "100%", cursor: "col-resize", zIndex: 2, borderRadius: `${Q / 2}px 0 0 ${Q / 2}px` } }),
555
+ /* @__PURE__ */ t("div", { onMouseDown: (W) => c(W, o, "right"), style: { position: "absolute", right: 0, top: 0, width: 8, height: "100%", cursor: "col-resize", zIndex: 2, borderRadius: `0 ${Q / 2}px ${Q / 2}px 0` } }),
556
+ k && /* @__PURE__ */ s(ie, { children: [
557
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: (W) => a(W, o, "left"), style: { position: "absolute", left: -7, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } }),
558
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: (W) => a(W, o, "right"), style: { position: "absolute", right: -7, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } })
559
+ ] })
560
+ ]
561
+ }
562
+ )
563
+ ] });
564
+ }
565
+ if (o.originalType === "milestone") {
566
+ const h = d + (X - Ne) / 2;
567
+ return /* @__PURE__ */ s(
568
+ "div",
569
+ {
570
+ "data-task-id": o.id,
571
+ ...x,
572
+ style: {
573
+ position: "absolute",
574
+ left: g - 6,
575
+ top: h,
576
+ height: Ne,
577
+ minWidth: Oe,
578
+ borderRadius: Ne / 2,
579
+ background: S ? "linear-gradient(135deg, #fee, #fff5f5)" : "linear-gradient(135deg, #e8f5ee, #f0f8f4)",
580
+ border: E ? `2px solid ${e.group}` : S ? `2px solid ${e.today}` : `1.5px solid ${e.milestoneRing}`,
581
+ display: "flex",
582
+ alignItems: "center",
583
+ gap: 6,
584
+ paddingLeft: 4,
585
+ paddingRight: 12,
586
+ cursor: I ? "grabbing" : "grab",
587
+ zIndex: b || E ? 20 : 10,
588
+ boxShadow: E ? `0 0 0 2px ${e.group}, 0 4px 16px ${e.group}33` : S ? `0 0 0 1px ${e.today}44, 0 3px 12px ${e.today}22` : p && !b ? `0 0 0 2px ${e.group}99, 0 3px 14px ${e.group}33` : b ? `0 3px 12px ${e.milestone}22` : "0 1px 3px rgba(0,0,0,0.06)",
589
+ opacity: w ? 0.15 : 1,
590
+ transition: "box-shadow 0.2s, transform 0.15s, opacity 0.18s",
591
+ transform: b ? "translateY(-1px)" : "none",
592
+ whiteSpace: "nowrap",
593
+ overflow: "visible"
594
+ },
595
+ children: [
596
+ /* @__PURE__ */ t("div", { style: { width: 20, height: 20, borderRadius: "50%", background: S ? e.today : e.milestone, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, children: /* @__PURE__ */ t(we, { size: 11, color: "#fff", strokeWidth: 2.5 }) }),
597
+ /* @__PURE__ */ t("span", { style: { fontSize: 11, fontWeight: 600, color: S ? e.today : e.milestone, overflow: "hidden", textOverflow: "ellipsis", maxWidth: 130 }, children: o.name }),
598
+ o.progress >= 100 && /* @__PURE__ */ t("span", { style: { fontSize: 9, fontWeight: 700, color: "#fff", background: e.milestoneRing, borderRadius: 6, padding: "1px 5px" }, children: "✓" }),
599
+ k && /* @__PURE__ */ s(ie, { children: [
600
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: ($) => a($, o, "left"), style: { position: "absolute", left: -7, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } }),
601
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: ($) => a($, o, "right"), style: { position: "absolute", right: -7, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } })
602
+ ] })
603
+ ]
604
+ }
605
+ );
606
+ }
607
+ if (o.originalType === "event") {
608
+ const $ = d + (X - 22) / 2;
609
+ return /* @__PURE__ */ s(
610
+ "div",
611
+ {
612
+ "data-task-id": o.id,
613
+ ...x,
614
+ style: {
615
+ position: "absolute",
616
+ left: g - 22 / 2,
617
+ top: $,
618
+ width: 22,
619
+ height: 22,
620
+ borderRadius: "50%",
621
+ background: S ? "linear-gradient(135deg, #fee, #fff5f5)" : "linear-gradient(135deg, #fff7ed, #ffedd5)",
622
+ border: E ? `2px solid ${e.group}` : S ? `2px solid ${e.today}` : `1.5px solid ${e.event}`,
623
+ display: "flex",
624
+ alignItems: "center",
625
+ justifyContent: "center",
626
+ cursor: I ? "grabbing" : "grab",
627
+ zIndex: b || E ? 20 : 10,
628
+ boxShadow: E ? `0 0 0 2px ${e.group}, 0 4px 16px ${e.group}33` : S ? `0 0 0 1px ${e.today}44, 0 3px 12px ${e.today}22` : p && !b ? `0 0 0 2px ${e.group}99, 0 3px 14px ${e.group}33` : b ? `0 3px 12px ${e.event}33` : "0 1px 3px rgba(0,0,0,0.06)",
629
+ opacity: w ? 0.15 : 1,
630
+ transition: "box-shadow 0.2s, transform 0.15s, opacity 0.18s",
631
+ transform: b ? "scale(1.15)" : "none",
632
+ overflow: "visible"
633
+ },
634
+ children: [
635
+ /* @__PURE__ */ t("div", { style: { width: 14, height: 14, borderRadius: "50%", background: S ? e.today : e.event, display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ t(ke, { size: 8, color: "#fff", strokeWidth: 3 }) }),
636
+ o.progress >= 100 && /* @__PURE__ */ t("div", { style: { position: "absolute", top: -5, right: -12, background: e.event, color: "#fff", fontSize: 8, fontWeight: 700, padding: "1px 4px", borderRadius: 4 }, children: "✓" }),
637
+ /* @__PURE__ */ t("div", { style: {
638
+ position: "absolute",
639
+ top: "100%",
640
+ left: "50%",
641
+ transform: "translateX(-50%)",
642
+ marginTop: 4,
643
+ background: "rgba(255,255,255,0.9)",
644
+ padding: "2px 6px",
645
+ borderRadius: 4,
646
+ border: `1px solid ${e.borderLight}`,
647
+ fontSize: 9,
648
+ fontWeight: 600,
649
+ color: S ? e.today : e.event,
650
+ whiteSpace: "nowrap",
651
+ pointerEvents: "none",
652
+ opacity: b ? 1 : 0,
653
+ transition: "opacity 0.15s"
654
+ }, children: o.name }),
655
+ k && /* @__PURE__ */ s(ie, { children: [
656
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: (r) => a(r, o, "left"), style: { position: "absolute", left: -7, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } }),
657
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: (r) => a(r, o, "right"), style: { position: "absolute", right: -7, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } })
658
+ ] })
659
+ ]
660
+ }
661
+ );
662
+ }
663
+ if (o.originalType === "note") {
664
+ const r = d + (X - 44) / 2, v = o.noteColor || e.note;
665
+ return /* @__PURE__ */ s(
666
+ "div",
667
+ {
668
+ "data-task-id": o.id,
669
+ ...x,
670
+ style: {
671
+ position: "absolute",
672
+ left: g - 36 / 2,
673
+ top: r,
674
+ width: 36,
675
+ height: 44,
676
+ background: v,
677
+ borderRadius: 2,
678
+ cursor: I ? "grabbing" : "grab",
679
+ zIndex: b || E ? 20 : 10,
680
+ boxShadow: E ? `0 0 0 2px ${e.group}, 0 4px 16px ${e.group}33` : p && !b ? `0 0 0 2px ${e.group}99, 0 3px 14px ${e.group}33` : b ? "3px 4px 12px rgba(0,0,0,0.2)" : "1px 2px 5px rgba(0,0,0,0.15)",
681
+ opacity: w ? 0.2 : 1,
682
+ transition: "box-shadow 0.2s, transform 0.15s, opacity 0.18s",
683
+ transform: b ? "rotate(-2deg) scale(1.05)" : "none",
684
+ overflow: "visible",
685
+ display: "flex",
686
+ flexDirection: "column",
687
+ border: "1px solid rgba(0,0,0,0.04)"
688
+ },
689
+ children: [
690
+ /* @__PURE__ */ t("div", { style: { position: "absolute", top: -5, left: "50%", transform: "translateX(-50%)", width: 18, height: 6, background: "rgba(255,255,255,0.6)", borderRadius: 1, boxShadow: "0 1px 2px rgba(0,0,0,0.05)" } }),
691
+ /* @__PURE__ */ s("div", { style: { padding: "6px 4px 2px", flex: 1, overflow: "hidden" }, children: [
692
+ /* @__PURE__ */ t("div", { style: { width: "80%", height: 2, background: "rgba(0,0,0,0.1)", borderRadius: 1, marginBottom: 3 } }),
693
+ /* @__PURE__ */ t("div", { style: { width: "60%", height: 2, background: "rgba(0,0,0,0.1)", borderRadius: 1, marginBottom: 3 } }),
694
+ /* @__PURE__ */ t("div", { style: { width: "90%", height: 2, background: "rgba(0,0,0,0.1)", borderRadius: 1 } })
695
+ ] }),
696
+ (o.filesCount || 0) > 0 && /* @__PURE__ */ t("div", { style: { position: "absolute", bottom: -5, right: -5, background: e.headerBg, color: e.textSecondary, borderRadius: "50%", border: `1px solid ${e.borderLight}`, width: 16, height: 16, display: "flex", alignItems: "center", justifyContent: "center", boxShadow: "0 1px 3px rgba(0,0,0,0.1)", zIndex: 2 }, children: /* @__PURE__ */ t(je, { size: 8 }) }),
697
+ /* @__PURE__ */ t("div", { style: {
698
+ position: "absolute",
699
+ top: "100%",
700
+ left: "50%",
701
+ transform: "translateX(-50%)",
702
+ marginTop: 6,
703
+ background: "rgba(255,255,255,0.95)",
704
+ padding: "3px 8px",
705
+ borderRadius: 4,
706
+ border: `1px solid ${e.borderLight}`,
707
+ fontSize: 10,
708
+ fontWeight: 500,
709
+ color: e.textPrimary,
710
+ whiteSpace: "nowrap",
711
+ pointerEvents: "none",
712
+ opacity: b ? 1 : 0,
713
+ transition: "opacity 0.15s",
714
+ boxShadow: "0 2px 8px rgba(0,0,0,0.08)"
715
+ }, children: o.name }),
716
+ k && /* @__PURE__ */ s(ie, { children: [
717
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: (B) => a(B, o, "left"), style: { position: "absolute", left: -10, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } }),
718
+ /* @__PURE__ */ t("div", { "data-task-id": o.id, onMouseDown: (B) => a(B, o, "right"), style: { position: "absolute", right: -10, top: "50%", transform: "translateY(-50%)", width: 14, height: 14, borderRadius: "50%", background: e.group, border: "2.5px solid #fff", boxShadow: "0 1px 4px rgba(0,0,0,0.25)", cursor: "crosshair", zIndex: 30 } })
719
+ ] })
720
+ ]
721
+ }
722
+ );
723
+ }
724
+ return null;
725
+ }
726
+ function xt() {
727
+ const {
728
+ arrows: o,
729
+ hoveredTaskId: g,
730
+ selectedTaskId: d,
731
+ relatedIds: N
732
+ } = Se();
733
+ return /* @__PURE__ */ t(ie, { children: o.map((f, b) => {
734
+ const I = g === f.predId || g === f.succId, T = !d || f.predId === d || f.succId === d || N.has(f.predId) || N.has(f.succId), S = d !== null && T, D = I ? e.arrowHover : S ? e.group : e.arrow;
735
+ return /* @__PURE__ */ s("g", { style: { opacity: T ? S ? 1 : void 0 : 0.08, transition: "opacity 0.18s" }, children: [
736
+ /* @__PURE__ */ t(
737
+ "path",
738
+ {
739
+ d: f.path,
740
+ fill: "none",
741
+ stroke: D,
742
+ strokeWidth: S ? 2.5 : I ? 2 : 1.5,
743
+ style: { transition: "stroke 0.2s, stroke-width 0.2s" }
744
+ }
745
+ ),
746
+ /* @__PURE__ */ t(
747
+ "polygon",
748
+ {
749
+ points: `${f.headX},${f.headY} ${f.headX - 6},${f.headY - 4} ${f.headX - 6},${f.headY + 4}`,
750
+ fill: D,
751
+ style: { transition: "fill 0.2s" }
752
+ }
753
+ )
754
+ ] }, b);
755
+ }) });
756
+ }
757
+ const Ae = (o) => ({
758
+ id: o.id,
759
+ name: o.name,
760
+ start: o.start,
761
+ end: o.end,
762
+ type: o.originalType === "step" ? "task" : o.originalType,
763
+ progress: o.progress
764
+ }), be = (o, g) => {
765
+ switch (o) {
766
+ case "step":
767
+ return /* @__PURE__ */ t("div", { style: { width: 12, height: 12, borderRadius: 2, background: te[g ?? 0].bar, border: `1.5px solid ${te[g ?? 0].barBorder}`, flexShrink: 0 } });
768
+ case "milestone":
769
+ return /* @__PURE__ */ t("div", { style: { width: 16, height: 16, borderRadius: "50%", background: e.milestone, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, children: /* @__PURE__ */ t(we, { size: 8, color: "#fff" }) });
770
+ case "event":
771
+ return /* @__PURE__ */ t("div", { style: { width: 16, height: 16, borderRadius: "50%", background: e.event, display: "flex", alignItems: "center", justifyContent: "center", flexShrink: 0 }, children: /* @__PURE__ */ t(ke, { size: 8, color: "#fff" }) });
772
+ case "note":
773
+ return /* @__PURE__ */ t("div", { style: { width: 12, height: 14, background: e.note, borderRadius: 2, boxShadow: "1px 1px 2px rgba(0,0,0,0.1)", flexShrink: 0 } });
774
+ default:
775
+ return null;
776
+ }
777
+ };
778
+ function yt() {
779
+ const {
780
+ props: o,
781
+ viewMode: g,
782
+ timeline: d,
783
+ displayRows: N,
784
+ dragState: f,
785
+ resizeState: b,
786
+ connectState: I,
787
+ pendingConnection: T,
788
+ setPendingConnection: S,
789
+ depModalType: D,
790
+ setDepModalType: E,
791
+ depModalLag: k,
792
+ setDepModalLag: w,
793
+ depCreating: p,
794
+ deletingDepId: x,
795
+ setDeletingDepId: c,
796
+ chartMenu: a,
797
+ setChartMenu: l,
798
+ rightBodyRef: u,
799
+ timeHeaderRef: h,
800
+ handleChartMouseDown: $,
801
+ handleChartWheel: r,
802
+ openChartMenu: v,
803
+ hoveredTaskId: B,
804
+ setHoveredTaskId: A,
805
+ selectedTaskId: W,
806
+ setSelectedTaskId: z,
807
+ tooltip: R,
808
+ setTooltip: H,
809
+ popupState: _,
810
+ setPopupState: O,
811
+ criticalIds: se,
812
+ delayedIds: ge,
813
+ relatedIds: fe,
814
+ handleBarMouseDown: xe,
815
+ handleResizeMouseDown: Ie,
816
+ handleConnectDotMouseDown: ye,
817
+ handleCreateDependency: Te
818
+ } = Se(), {
819
+ translations: ae,
820
+ onViewStage: me,
821
+ onEditStage: De,
822
+ onDeleteStage: j,
823
+ onDeleteDependency: P,
824
+ onAddNewStage: $e,
825
+ onAddMilestone: Re,
826
+ onAddEvent: Me,
827
+ onAddNote: Ee
828
+ } = o, J = (y, n) => ae ? typeof ae == "function" ? ae(y, n) : ae[y] || n : n, ce = (y, n) => Math.round((n.getTime() - y.getTime()) / 864e5) + 1, oe = Math.max(N.length * X, 400), pe = () => O({ isOpen: !1, position: { x: 0, y: 0 }, task: null });
829
+ return /* @__PURE__ */ s(
830
+ "div",
831
+ {
832
+ className: "flex-1 w-full bg-[#FAFAFA] flex flex-col relative overflow-hidden",
833
+ style: { borderLeft: `1px solid ${e.borderLight}` },
834
+ children: [
835
+ /* @__PURE__ */ t(
836
+ "div",
837
+ {
838
+ ref: h,
839
+ style: {
840
+ height: ve * 2,
841
+ background: e.headerBg,
842
+ borderBottom: `1px solid ${e.borderLight}`,
843
+ overflow: "hidden",
844
+ position: "relative",
845
+ flexShrink: 0,
846
+ boxShadow: "0 1px 3px rgba(0,0,0,0.02)"
847
+ },
848
+ onWheel: r,
849
+ children: /* @__PURE__ */ s("div", { style: { width: d.totalWidth, height: "100%", position: "relative" }, children: [
850
+ /* @__PURE__ */ s("div", { style: { position: "absolute", top: 0, left: 0, right: 0, height: ve, display: "flex" }, children: [
851
+ g === "day" && d.months.map((y, n) => /* @__PURE__ */ t("div", { style: { width: y.width, position: "relative", height: "100%", borderRight: `1px solid ${e.borderLight}`, paddingLeft: 12, display: "flex", alignItems: "flex-end", paddingBottom: 6 }, children: /* @__PURE__ */ t("span", { style: { fontSize: 13, fontWeight: 700, color: e.textTitle, letterSpacing: "0.02em" }, children: y.label }) }, n)),
852
+ g === "month" && d.years?.map((y, n) => /* @__PURE__ */ t("div", { style: { width: y.width, position: "relative", height: "100%", borderRight: `1px solid ${e.borderLight}`, paddingLeft: 12, display: "flex", alignItems: "flex-end", paddingBottom: 6 }, children: /* @__PURE__ */ t("span", { style: { fontSize: 13, fontWeight: 700, color: e.textTitle, letterSpacing: "0.02em" }, children: y.label }) }, n))
853
+ ] }),
854
+ /* @__PURE__ */ s("div", { style: { position: "absolute", top: ve, left: 0, right: 0, height: ve, display: "flex" }, children: [
855
+ g === "day" && d.days.map((y, n) => {
856
+ const i = y.isToday;
857
+ return /* @__PURE__ */ t("div", { style: { width: d.dayWidth, position: "relative", height: "100%", borderRight: `1px solid ${e.borderLight}`, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ t("span", { style: { fontSize: 11, fontWeight: i ? 800 : 500, color: i ? e.today : e.textSecondary, letterSpacing: "-0.03em" }, children: y.date.getDate().toString().padStart(2, "0") }) }, n);
858
+ }),
859
+ g === "month" && d.months.map((y, n) => /* @__PURE__ */ t("div", { style: { width: y.width, position: "relative", height: "100%", borderRight: `1px solid ${e.borderLight}`, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ t("span", { style: { fontSize: 11, fontWeight: 600, color: e.textPrimary, textTransform: "uppercase", letterSpacing: "0.05em" }, children: y.label.substring(0, 3) }) }, n))
860
+ ] })
861
+ ] })
862
+ }
863
+ ),
864
+ /* @__PURE__ */ t(
865
+ "div",
866
+ {
867
+ ref: u,
868
+ className: "flex-1 overflow-auto bg-white gantt-scroll",
869
+ onMouseDown: $,
870
+ onWheel: r,
871
+ onContextMenu: v,
872
+ style: { position: "relative" },
873
+ children: /* @__PURE__ */ s("div", { style: { width: d.totalWidth, height: oe, position: "relative" }, children: [
874
+ /* @__PURE__ */ s("svg", { width: d.totalWidth, height: oe, style: { position: "absolute", top: 0, left: 0, pointerEvents: "none" }, children: [
875
+ /* @__PURE__ */ s("defs", { children: [
876
+ /* @__PURE__ */ t("pattern", { id: "gantt-y-lines", x: "0", y: "0", width: d.dayWidth, height: X, patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ t("line", { x1: d.dayWidth, y1: "0", x2: d.dayWidth, y2: X, stroke: e.border, strokeWidth: "1", strokeDasharray: "4 4", opacity: "0.4" }) }),
877
+ /* @__PURE__ */ t("pattern", { id: "gantt-x-lines", x: "0", y: "0", width: d.dayWidth, height: X, patternUnits: "userSpaceOnUse", children: /* @__PURE__ */ t("line", { x1: "0", y1: X, x2: d.dayWidth, y2: X, stroke: e.borderLight, strokeWidth: "1" }) })
878
+ ] }),
879
+ /* @__PURE__ */ t("rect", { width: "100%", height: "100%", fill: "url(#gantt-x-lines)" }),
880
+ /* @__PURE__ */ t("rect", { width: "100%", height: "100%", fill: "url(#gantt-y-lines)" }),
881
+ g === "day" && d.days.map((y, n) => y.isWeekend ? /* @__PURE__ */ t("rect", { x: n * d.dayWidth, y: 0, width: d.dayWidth, height: oe, fill: e.weekendBg, opacity: 0.6 }, `we-${n}`) : null),
882
+ g === "month" && d.days.map((y, n) => y.isWeekend ? /* @__PURE__ */ t("rect", { x: n * d.dayWidth, y: 0, width: d.dayWidth, height: oe, fill: e.weekendBg, opacity: 0.3 }, `wem-${n}`) : null),
883
+ d.todayIndex >= 0 && /* @__PURE__ */ s("g", { children: [
884
+ /* @__PURE__ */ t("rect", { x: d.todayIndex * d.dayWidth, y: 0, width: d.dayWidth, height: oe, fill: e.todayBg }),
885
+ /* @__PURE__ */ t("line", { x1: (d.todayIndex + 0.5) * d.dayWidth, y1: 0, x2: (d.todayIndex + 0.5) * d.dayWidth, y2: oe, stroke: e.today, strokeWidth: 2, strokeDasharray: "4 4", opacity: 0.3 })
886
+ ] })
887
+ ] }),
888
+ N.map((y, n) => y.kind === "group" || y.kind === "projectHeader" ? /* @__PURE__ */ t("div", { style: {
889
+ position: "absolute",
890
+ left: 0,
891
+ top: n * X,
892
+ width: "100%",
893
+ height: X,
894
+ background: y.kind === "projectHeader" ? e.headerBg : `${e.groupLight}15`,
895
+ borderBottom: `1px solid ${e.borderLight}`,
896
+ pointerEvents: "none"
897
+ } }, `bg-${n}`) : null),
898
+ /* @__PURE__ */ s("div", { style: { position: "absolute", inset: 0 }, children: [
899
+ N.map((y, n) => {
900
+ if (y.kind !== "task") return null;
901
+ const i = y.task, m = f?.task.id === i.id, L = b?.task.id === i.id, C = m || L && b.edge === "left" ? q(i.start, m ? f.offsetDays : b.offsetDays) : i.start, M = m || L && b.edge === "right" ? q(i.end, m ? f.offsetDays : b.offsetDays) : i.end, F = i.originalType !== "step";
902
+ let de = ne(C, d), U = 0, Z = 0;
903
+ F || (U = Math.max(ne(M, d) - de, d.dayWidth), Z = U * (i.progress / 100));
904
+ const We = B === i.id, Le = W === i.id, Ge = ge.has(i.id), He = se.has(i.id), Ue = !!W && !Le && !fe.has(i.id), Ve = Le || !!W && fe.has(i.id), Je = I?.hoverTargetId === i.id, Ke = We || Le, qe = n * X;
905
+ return /* @__PURE__ */ t(
906
+ ft,
907
+ {
908
+ task: i,
909
+ x: de,
910
+ y: qe,
911
+ w: U,
912
+ progW: Z,
913
+ isHov: We,
914
+ isDrag: m,
915
+ isResize: L,
916
+ isCritical: He,
917
+ isDelayed: Ge,
918
+ isConnectTarget: Je,
919
+ showDots: Ke,
920
+ isBarDimmed: Ue,
921
+ isBarHighlighted: Ve,
922
+ commonEvents: {
923
+ onMouseEnter: (K) => {
924
+ A(i.id), !f && !b && H({ task: i, x: K.clientX, y: K.clientY });
925
+ },
926
+ onMouseMove: (K) => {
927
+ B === i.id && !f && !b && H({ task: i, x: K.clientX, y: K.clientY });
928
+ },
929
+ onMouseLeave: () => {
930
+ A(null), H(null);
931
+ },
932
+ onClick: (K) => {
933
+ K.stopPropagation(), z(i.id), K.detail === 2 && me?.(Ae(i)), O(!_.isOpen || _.task?.id !== i.id ? {
934
+ isOpen: !0,
935
+ position: { x: K.clientX, y: K.clientY },
936
+ task: i
937
+ } : { isOpen: !1, position: { x: 0, y: 0 }, task: null });
938
+ },
939
+ onMouseDown: (K) => xe(K, i)
940
+ },
941
+ handleResizeMouseDown: Ie,
942
+ handleConnectDotMouseDown: ye
943
+ },
944
+ i.id
945
+ );
946
+ }),
947
+ /* @__PURE__ */ t("svg", { width: d.totalWidth, height: oe, style: { position: "absolute", inset: 0, pointerEvents: "none" }, children: /* @__PURE__ */ t(xt, {}) }),
948
+ R && !f && /* @__PURE__ */ t("div", { style: { position: "fixed", left: R.x + 16, top: R.y - 10, zIndex: 9999, pointerEvents: "none" }, children: /* @__PURE__ */ s(
949
+ "div",
950
+ {
951
+ className: "rounded-xl px-4 py-3 min-w-[220px] max-w-[340px] backdrop-blur-sm",
952
+ style: { background: `${e.surface}f5`, border: `1px solid ${e.borderLight}`, boxShadow: "0 8px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06)" },
953
+ children: [
954
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2 mb-1.5", children: [
955
+ be(R.task.originalType, R.task.colorIdx),
956
+ /* @__PURE__ */ t("span", { className: "text-xs font-bold truncate", style: { color: e.textTitle }, children: R.task.name })
957
+ ] }),
958
+ /* @__PURE__ */ t("div", { className: "flex flex-col gap-1 text-[11px]", style: { color: e.textSecondary }, children: R.task.originalType === "step" ? /* @__PURE__ */ s(ie, { children: [
959
+ R.task.previsionStart && R.task.previsionEnd && /* @__PURE__ */ s("div", { style: { background: `${e.headerBg}`, borderRadius: 6, padding: "4px 6px", marginBottom: 2 }, children: [
960
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1 mb-1", children: [
961
+ /* @__PURE__ */ t("div", { style: { width: 20, height: 4, borderRadius: 2, background: `${e.textSecondary}44`, border: `1.5px solid ${e.textSecondary}66` } }),
962
+ /* @__PURE__ */ t("span", { style: { fontSize: 9, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: e.textSecondary }, children: "Previsto" })
963
+ ] }),
964
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
965
+ /* @__PURE__ */ t("span", { children: "Início:" }),
966
+ /* @__PURE__ */ t("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: ee(R.task.previsionStart) })
967
+ ] }),
968
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
969
+ /* @__PURE__ */ t("span", { children: "Fim:" }),
970
+ /* @__PURE__ */ t("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: ee(R.task.previsionEnd) })
971
+ ] }),
972
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
973
+ /* @__PURE__ */ t("span", { children: "Duração:" }),
974
+ /* @__PURE__ */ s("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: [
975
+ ce(R.task.previsionStart, R.task.previsionEnd),
976
+ "d"
977
+ ] })
978
+ ] })
979
+ ] }),
980
+ /* @__PURE__ */ s("div", { style: { background: R.task.hasActualDates ? `${e.groupLight}22` : "transparent", borderRadius: 6, padding: "4px 6px" }, children: [
981
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-1 mb-1", children: [
982
+ /* @__PURE__ */ t("div", { style: { width: 20, height: 4, borderRadius: 2, background: te[R.task.colorIdx ?? 0].progress } }),
983
+ /* @__PURE__ */ t("span", { style: { fontSize: 9, fontWeight: 700, textTransform: "uppercase", letterSpacing: "0.06em", color: R.task.hasActualDates ? e.group : e.textSecondary }, children: R.task.hasActualDates ? "Real" : "Previsto (em uso)" })
984
+ ] }),
985
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
986
+ /* @__PURE__ */ t("span", { children: "Início:" }),
987
+ /* @__PURE__ */ t("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: ee(R.task.start) })
988
+ ] }),
989
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
990
+ /* @__PURE__ */ t("span", { children: "Fim:" }),
991
+ /* @__PURE__ */ t("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: ee(R.task.end) })
992
+ ] }),
993
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
994
+ /* @__PURE__ */ t("span", { children: "Duração:" }),
995
+ /* @__PURE__ */ s("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: [
996
+ ce(R.task.start, R.task.end),
997
+ "d"
998
+ ] })
999
+ ] })
1000
+ ] }),
1001
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4 pt-1 mt-1", style: { borderTop: `1px solid ${e.borderLight}` }, children: [
1002
+ /* @__PURE__ */ s("span", { children: [
1003
+ J("charts.gantt.progress", "Progresso"),
1004
+ ":"
1005
+ ] }),
1006
+ /* @__PURE__ */ s("span", { className: "font-bold", style: { color: e.group }, children: [
1007
+ Math.round(R.task.progress),
1008
+ "%"
1009
+ ] })
1010
+ ] })
1011
+ ] }) : R.task.originalType === "note" ? /* @__PURE__ */ s(ie, { children: [
1012
+ R.task.noteProjectTitle && /* @__PURE__ */ s("div", { className: "flex items-center gap-1.5 mb-1", children: [
1013
+ /* @__PURE__ */ t("div", { style: { width: 8, height: 8, borderRadius: 2, background: R.task.noteColor || e.note, flexShrink: 0 } }),
1014
+ /* @__PURE__ */ t("span", { className: "text-[11px] font-semibold truncate", style: { color: e.textPrimary }, children: R.task.noteProjectTitle })
1015
+ ] }),
1016
+ /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
1017
+ /* @__PURE__ */ t("span", { children: "Data:" }),
1018
+ /* @__PURE__ */ t("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: ee(R.task.start) })
1019
+ ] }),
1020
+ (R.task.filesCount || 0) > 0 && /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
1021
+ /* @__PURE__ */ t("span", { children: "Anexos:" }),
1022
+ /* @__PURE__ */ s("span", { className: "font-semibold flex items-center gap-1", style: { color: e.textPrimary }, children: [
1023
+ /* @__PURE__ */ t(je, { size: 10 }),
1024
+ R.task.filesCount
1025
+ ] })
1026
+ ] })
1027
+ ] }) : /* @__PURE__ */ s("div", { className: "flex justify-between gap-4", children: [
1028
+ /* @__PURE__ */ s("span", { children: [
1029
+ J("charts.gantt.start", "Início"),
1030
+ ":"
1031
+ ] }),
1032
+ /* @__PURE__ */ t("span", { className: "font-semibold tabular-nums", style: { color: e.textPrimary }, children: ee(R.task.start) })
1033
+ ] }) })
1034
+ ]
1035
+ }
1036
+ ) })
1037
+ ] })
1038
+ ] })
1039
+ }
1040
+ ),
1041
+ _.task && _.isOpen && (() => {
1042
+ const y = _.task, n = (o.dependencies || []).filter((M) => M.predecessorId === y.id || M.successorId === y.id), i = { FS: "Início após Fim", SS: "Inícios simultâneos", FF: "Fins simultâneos", SF: "Fim após Início" }, m = n.length > 0 ? 300 : 220, L = Math.min(_.position.x, window.innerWidth - m - 16), C = _.position.y + 8;
1043
+ return /* @__PURE__ */ s(
1044
+ "div",
1045
+ {
1046
+ "data-popup": "gantt-action",
1047
+ style: { position: "fixed", left: L, top: C, zIndex: 9999, background: "#fff", borderRadius: 4, boxShadow: "0 12px 40px rgba(0,0,0,0.14), 0 3px 10px rgba(0,0,0,0.07)", border: `1.5px solid ${e.borderLight}`, width: m, overflow: "hidden" },
1048
+ onMouseDown: (M) => M.stopPropagation(),
1049
+ children: [
1050
+ /* @__PURE__ */ t("div", { style: { padding: "12px 14px 10px", borderBottom: `1px solid ${e.borderLight}` }, children: /* @__PURE__ */ t("p", { style: { fontSize: 13, fontWeight: 700, color: e.group, margin: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: y.name, children: y.name }) }),
1051
+ /* @__PURE__ */ s("div", { style: { display: "flex", flexDirection: "column", gap: 2, padding: "8px 6px" }, children: [
1052
+ /* @__PURE__ */ s("button", { onClick: () => {
1053
+ me?.(Ae(y)), pe();
1054
+ }, className: "gantt-popup-btn", children: [
1055
+ /* @__PURE__ */ t(rt, { size: 15 }),
1056
+ " ",
1057
+ /* @__PURE__ */ t("span", { children: J("projects.stepAction.viewDetails", "Ver detalhes") })
1058
+ ] }),
1059
+ /* @__PURE__ */ s("button", { onClick: () => {
1060
+ De?.(Ae(y)), pe();
1061
+ }, className: "gantt-popup-btn", children: [
1062
+ /* @__PURE__ */ t(nt, { size: 15 }),
1063
+ " ",
1064
+ /* @__PURE__ */ t("span", { children: J("projects.stepAction.edit", "Editar") })
1065
+ ] }),
1066
+ /* @__PURE__ */ s("button", { onClick: () => {
1067
+ j?.(y.id), pe();
1068
+ }, className: "gantt-popup-btn text-red-500 hover:bg-red-50", children: [
1069
+ /* @__PURE__ */ t(it, { size: 15 }),
1070
+ " ",
1071
+ /* @__PURE__ */ t("span", { children: J("projects.stepAction.delete", "Excluir") })
1072
+ ] })
1073
+ ] }),
1074
+ n.length > 0 && /* @__PURE__ */ s("div", { style: { borderTop: `1px solid ${e.borderLight}`, padding: "10px 14px 12px" }, children: [
1075
+ /* @__PURE__ */ s("div", { style: { fontSize: 10, fontWeight: 700, color: e.textSecondary, textTransform: "uppercase", letterSpacing: "0.08em", marginBottom: 8 }, children: [
1076
+ "Relações (",
1077
+ n.length,
1078
+ ")"
1079
+ ] }),
1080
+ /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", gap: 5 }, children: n.map((M) => {
1081
+ const F = M.predecessorId === y.id, de = F ? M.successorName : M.predecessorName, U = x === M.id;
1082
+ return /* @__PURE__ */ s("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "6px 8px", borderRadius: 8, background: "#f8fafb", border: `1px solid ${e.borderLight}` }, children: [
1083
+ /* @__PURE__ */ s("div", { style: { flex: 1, minWidth: 0 }, children: [
1084
+ /* @__PURE__ */ s("div", { style: { fontSize: 10, fontWeight: 700, color: e.group, marginBottom: 2 }, children: [
1085
+ /* @__PURE__ */ t("span", { style: { background: `${e.group}15`, borderRadius: 4, padding: "1px 5px" }, children: M.type }),
1086
+ " ",
1087
+ /* @__PURE__ */ t("span", { style: { color: e.textSecondary, fontWeight: 500 }, children: F ? "→ " : "← " }),
1088
+ /* @__PURE__ */ t("span", { style: { color: e.textMuted, fontWeight: 400, fontSize: 9 }, children: i[M.type] ?? M.type })
1089
+ ] }),
1090
+ /* @__PURE__ */ t("div", { style: { fontSize: 11, color: e.textPrimary, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, title: de, children: de })
1091
+ ] }),
1092
+ P && /* @__PURE__ */ t(
1093
+ "button",
1094
+ {
1095
+ disabled: !!U,
1096
+ onClick: async () => {
1097
+ c(M.id);
1098
+ try {
1099
+ await P(M.id);
1100
+ } finally {
1101
+ c(null);
1102
+ }
1103
+ },
1104
+ style: { flexShrink: 0, padding: "4px 6px", borderRadius: 6, border: "none", background: U ? "#fee2e2" : "transparent", cursor: U ? "wait" : "pointer", color: "#ef4444", fontSize: 14, opacity: U ? 0.5 : 1, transition: "background 0.12s" },
1105
+ children: U ? "⟳" : "🗑"
1106
+ }
1107
+ )
1108
+ ] }, M.id);
1109
+ }) })
1110
+ ] })
1111
+ ]
1112
+ }
1113
+ );
1114
+ })(),
1115
+ a && /* @__PURE__ */ s(
1116
+ "div",
1117
+ {
1118
+ "data-menu": "chart-create",
1119
+ style: {
1120
+ position: "fixed",
1121
+ left: Math.min(a.x, window.innerWidth - 220),
1122
+ top: Math.min(a.y, window.innerHeight - 220),
1123
+ zIndex: 99999,
1124
+ background: "#fff",
1125
+ borderRadius: 10,
1126
+ boxShadow: "0 12px 40px rgba(0,0,0,0.15), 0 3px 10px rgba(0,0,0,0.08)",
1127
+ border: `1.5px solid ${e.borderLight}`,
1128
+ width: 200,
1129
+ overflow: "hidden"
1130
+ },
1131
+ onClick: (y) => y.stopPropagation(),
1132
+ children: [
1133
+ /* @__PURE__ */ t("div", { style: { padding: "9px 13px 8px", borderBottom: `1px solid ${e.borderLight}`, background: e.headerBg }, children: /* @__PURE__ */ s("p", { style: { margin: 0, fontSize: 10, fontWeight: 700, color: e.textSecondary, textTransform: "uppercase", letterSpacing: "0.08em" }, children: [
1134
+ "Adicionar em ",
1135
+ ee(a.date)
1136
+ ] }) }),
1137
+ /* @__PURE__ */ t("div", { style: { padding: "5px 5px" }, children: [
1138
+ { label: "Etapa", icon: be("step", 0), action: () => {
1139
+ $e?.(a.date, a.projectId), l(null);
1140
+ } },
1141
+ { label: "Marco", icon: be("milestone"), action: () => {
1142
+ Re?.(a.date, a.projectId), l(null);
1143
+ } },
1144
+ { label: "Evento", icon: be("event"), action: () => {
1145
+ Me?.(a.date, a.projectId), l(null);
1146
+ } },
1147
+ { label: "Nota", icon: be("note"), action: () => {
1148
+ Ee?.(a.date, a.projectId), l(null);
1149
+ } }
1150
+ ].map((y) => /* @__PURE__ */ s(
1151
+ "button",
1152
+ {
1153
+ onClick: y.action,
1154
+ className: "gantt-popup-btn",
1155
+ style: { display: "flex", alignItems: "center", gap: 10, width: "100%", padding: "8px 10px", borderRadius: 7, border: "none", background: "transparent", cursor: "pointer", fontSize: 13, fontWeight: 500, color: e.textPrimary, textAlign: "left", transition: "background 0.12s" },
1156
+ children: [
1157
+ y.icon,
1158
+ " ",
1159
+ y.label
1160
+ ]
1161
+ },
1162
+ y.label
1163
+ )) })
1164
+ ]
1165
+ }
1166
+ ),
1167
+ I && /* @__PURE__ */ s("svg", { style: { position: "fixed", inset: 0, width: "100vw", height: "100vh", pointerEvents: "none", zIndex: 99999 }, children: [
1168
+ /* @__PURE__ */ t("defs", { children: /* @__PURE__ */ t("marker", { id: "connect-arrow", markerWidth: "8", markerHeight: "8", refX: "6", refY: "3", orient: "auto", children: /* @__PURE__ */ t("path", { d: "M0,0 L0,6 L6,3 z", fill: e.group }) }) }),
1169
+ /* @__PURE__ */ t("line", { x1: I.fromScreenX, y1: I.fromScreenY, x2: I.currentScreenX, y2: I.currentScreenY, stroke: e.group, strokeWidth: 2.5, strokeDasharray: "8 5", markerEnd: "url(#connect-arrow)", opacity: 0.85, style: { animation: "gantt-dash 0.5s linear infinite" } }),
1170
+ /* @__PURE__ */ t("style", { children: "@keyframes gantt-dash { to { stroke-dashoffset: -13; } }" })
1171
+ ] }),
1172
+ T && /* @__PURE__ */ t("div", { style: { position: "fixed", inset: 0, background: "rgba(0,0,0,0.35)", backdropFilter: "blur(4px)", display: "flex", alignItems: "center", justifyContent: "center", zIndex: 99998 }, onClick: () => S(null), children: /* @__PURE__ */ s("div", { style: { background: "#fff", borderRadius: 20, padding: "32px 36px", width: 420, boxShadow: "0 24px 80px rgba(0,0,0,0.18), 0 6px 24px rgba(0,0,0,0.08)" }, onClick: (y) => y.stopPropagation(), children: [
1173
+ /* @__PURE__ */ s("div", { style: { marginBottom: 20 }, children: [
1174
+ /* @__PURE__ */ t("h3", { style: { fontSize: 18, fontWeight: 700, color: e.textTitle, marginBottom: 4 }, children: "Tipo de Relação" }),
1175
+ /* @__PURE__ */ t("p", { style: { fontSize: 13, color: e.textSecondary }, children: "Escolha como as duas tarefas se relacionam" })
1176
+ ] }),
1177
+ /* @__PURE__ */ t("div", { style: { display: "grid", gridTemplateColumns: "1fr 1fr", gap: 10, marginBottom: 20 }, children: [
1178
+ { type: "FS", label: "Início após Fim", desc: "B começa quando A termina" },
1179
+ { type: "SS", label: "Inícios simultâneos", desc: "A e B começam juntos" },
1180
+ { type: "FF", label: "Fins simultâneos", desc: "A e B terminam juntos" },
1181
+ { type: "SF", label: "Fim após Início", desc: "B termina quando A começa" }
1182
+ ].map((y) => /* @__PURE__ */ s("button", { onClick: () => E(y.type), style: { border: D === y.type ? `2px solid ${e.group}` : `1.5px solid ${e.borderLight}`, borderRadius: 12, padding: "12px 14px", textAlign: "left", cursor: "pointer", background: D === y.type ? `${e.group}0d` : "#fafafa" }, children: [
1183
+ /* @__PURE__ */ t("div", { style: { fontSize: 11, fontFamily: "monospace", fontWeight: 700, color: e.group, marginBottom: 4, background: D === y.type ? `${e.group}20` : `${e.group}0d`, borderRadius: 6, padding: "2px 6px", display: "inline-block" }, children: y.type }),
1184
+ /* @__PURE__ */ t("div", { style: { fontSize: 13, fontWeight: 600, color: e.textTitle, marginBottom: 2 }, children: y.label }),
1185
+ /* @__PURE__ */ t("div", { style: { fontSize: 11, color: e.textSecondary }, children: y.desc })
1186
+ ] }, y.type)) }),
1187
+ /* @__PURE__ */ s("div", { style: { marginBottom: 24 }, children: [
1188
+ /* @__PURE__ */ t("label", { style: { display: "block", fontSize: 13, fontWeight: 600, color: e.textTitle, marginBottom: 6 }, children: "Atraso (Lag) em dias" }),
1189
+ /* @__PURE__ */ t("input", { type: "number", value: k, onChange: (y) => w(parseInt(y.target.value) || 0), style: { width: "100%", padding: "10px 12px", border: `1.5px solid ${e.borderLight}`, borderRadius: 8, fontSize: 14 } })
1190
+ ] }),
1191
+ /* @__PURE__ */ s("div", { style: { display: "flex", justifyContent: "flex-end", gap: 12 }, children: [
1192
+ /* @__PURE__ */ t("button", { onClick: () => S(null), style: { padding: "10px 16px", borderRadius: 8, border: `1px solid ${e.borderLight}`, background: "#fff", cursor: "pointer", fontWeight: 600 }, children: "Cancelar" }),
1193
+ /* @__PURE__ */ t("button", { onClick: Te, disabled: p, style: { padding: "10px 16px", borderRadius: 8, border: "none", background: e.group, color: "#fff", cursor: p ? "wait" : "pointer", fontWeight: 600 }, children: p ? "Salvando..." : "Criar Dependência" })
1194
+ ] })
1195
+ ] }) })
1196
+ ]
1197
+ }
1198
+ );
1199
+ }
1200
+ function mt(o) {
1201
+ const g = ue(null), d = ue(null), N = ue(null), f = ue(!1), b = V(() => {
1202
+ if (f.current) return;
1203
+ f.current = !0;
1204
+ const w = d.current;
1205
+ w && g.current && (g.current.scrollTop = w.scrollTop), w && N.current && (N.current.scrollLeft = w.scrollLeft), f.current = !1;
1206
+ }, []), I = V(() => {
1207
+ f.current || (f.current = !0, g.current && d.current && (d.current.scrollTop = g.current.scrollTop), f.current = !1);
1208
+ }, []), T = ue(!1);
1209
+ le(() => {
1210
+ if (T.current || !o.totalWidth) return;
1211
+ const w = d.current;
1212
+ if (!w) return;
1213
+ const p = ne(/* @__PURE__ */ new Date(), o);
1214
+ if (p >= 0 && p <= o.totalWidth) {
1215
+ const x = p - w.clientWidth / 2;
1216
+ w.scrollLeft = Math.max(0, x), N.current && (N.current.scrollLeft = w.scrollLeft), T.current = !0;
1217
+ }
1218
+ }, [o]);
1219
+ const [S, D] = Y(null), E = V((w, p) => {
1220
+ if (p || w.button === 2) return;
1221
+ const x = d.current;
1222
+ x && (w.preventDefault(), D({ startX: w.clientX, startY: w.clientY, scrollLeft: x.scrollLeft, scrollTop: x.scrollTop }));
1223
+ }, []);
1224
+ le(() => {
1225
+ if (!S) return;
1226
+ const w = (x) => {
1227
+ const c = d.current;
1228
+ if (!c) return;
1229
+ const a = x.clientX - S.startX, l = x.clientY - S.startY;
1230
+ c.scrollLeft = S.scrollLeft - a, c.scrollTop = S.scrollTop - l, g.current && (g.current.scrollTop = c.scrollTop), N.current && (N.current.scrollLeft = c.scrollLeft);
1231
+ }, p = () => D(null);
1232
+ return document.addEventListener("mousemove", w), document.addEventListener("mouseup", p), () => {
1233
+ document.removeEventListener("mousemove", w), document.removeEventListener("mouseup", p);
1234
+ };
1235
+ }, [S]);
1236
+ const k = V((w) => {
1237
+ const p = d.current;
1238
+ if (p)
1239
+ if (w.preventDefault(), w.shiftKey || Math.abs(w.deltaX) > Math.abs(w.deltaY)) {
1240
+ const x = w.shiftKey ? w.deltaY : w.deltaX;
1241
+ p.scrollLeft += x, N.current && (N.current.scrollLeft = p.scrollLeft);
1242
+ } else
1243
+ p.scrollTop += w.deltaY, g.current && (g.current.scrollTop = p.scrollTop);
1244
+ }, []);
1245
+ return {
1246
+ leftBodyRef: g,
1247
+ rightBodyRef: d,
1248
+ timeHeaderRef: N,
1249
+ handleRightScroll: b,
1250
+ handleLeftScroll: I,
1251
+ handleChartMouseDown: E,
1252
+ handleChartWheel: k,
1253
+ panState: S,
1254
+ setPanState: D
1255
+ };
1256
+ }
1257
+ function bt(o, g, d, N) {
1258
+ const f = /* @__PURE__ */ new Map();
1259
+ return o.forEach((b) => f.set(b.id, b)), g.map((b) => {
1260
+ const I = f.get(b.predecessorId), T = f.get(b.successorId);
1261
+ if (!I || !T) return null;
1262
+ const S = N.get(I.id), D = N.get(T.id);
1263
+ if (S == null || D == null) return null;
1264
+ const E = I.originalType !== "step", k = T.originalType !== "step", w = E ? ne(I.start, d) + Oe : ne(I.end, d), p = S * X + X / 2, x = k ? ne(T.start, d) - 10 : ne(T.start, d), c = D * X + X / 2, a = 14, l = Math.max(w + a, x - a), u = p === c ? `M${w},${p} L${x - 6},${c}` : `M${w},${p} L${l},${p} L${l},${c} L${x - 6},${c}`;
1265
+ return { predId: I.id, succId: T.id, path: u, headX: x - 6, headY: c };
1266
+ }).filter(Boolean);
1267
+ }
1268
+ function vt(o, g) {
1269
+ if (o.length === 0 || g.length === 0) return /* @__PURE__ */ new Set();
1270
+ const d = /* @__PURE__ */ new Map();
1271
+ o.forEach((u) => d.set(u.id, u));
1272
+ const N = new Set(o.map((u) => u.id)), f = g.filter((u) => N.has(u.predecessorId) && N.has(u.successorId));
1273
+ if (f.length === 0) return /* @__PURE__ */ new Set();
1274
+ const b = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
1275
+ f.forEach((u) => {
1276
+ b.has(u.predecessorId) || b.set(u.predecessorId, []), b.get(u.predecessorId).push(u.successorId), I.has(u.successorId) || I.set(u.successorId, []), I.get(u.successorId).push(u.predecessorId);
1277
+ });
1278
+ const T = (u) => Math.max(1, he(u.start, u.end)), S = /* @__PURE__ */ new Set(), D = [];
1279
+ function E(u) {
1280
+ S.has(u) || (S.add(u), (b.get(u) || []).forEach(E), D.unshift(u));
1281
+ }
1282
+ o.forEach((u) => E(u.id));
1283
+ const k = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map();
1284
+ for (const u of D) {
1285
+ const h = d.get(u), $ = I.get(u) || [];
1286
+ let r = 0;
1287
+ for (const B of $) r = Math.max(r, w.get(B) || 0);
1288
+ const v = $.length > 0 ? r : 0;
1289
+ k.set(u, v), w.set(u, v + T(h));
1290
+ }
1291
+ let p = 0;
1292
+ w.forEach((u) => {
1293
+ u > p && (p = u);
1294
+ });
1295
+ const x = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
1296
+ for (let u = D.length - 1; u >= 0; u--) {
1297
+ const h = D[u], $ = d.get(h), r = b.get(h) || [];
1298
+ let v = p;
1299
+ for (const B of r) v = Math.min(v, x.get(B) ?? p);
1300
+ c.set(h, r.length > 0 ? v : p), x.set(h, (c.get(h) || 0) - T($));
1301
+ }
1302
+ const a = /* @__PURE__ */ new Set();
1303
+ f.forEach((u) => {
1304
+ a.add(u.predecessorId), a.add(u.successorId);
1305
+ });
1306
+ const l = /* @__PURE__ */ new Set();
1307
+ for (const u of D) {
1308
+ if (!a.has(u)) continue;
1309
+ const h = (x.get(u) || 0) - (k.get(u) || 0);
1310
+ Math.abs(h) < 0.5 && l.add(u);
1311
+ }
1312
+ return l;
1313
+ }
1314
+ function wt({
1315
+ steps: o,
1316
+ milestones: g,
1317
+ events: d,
1318
+ notes: N,
1319
+ dependencies: f,
1320
+ viewMode: b,
1321
+ groupByProject: I,
1322
+ visibleTypes: T,
1323
+ collapsedGroups: S,
1324
+ collapsedProjects: D,
1325
+ selectedTaskId: E
1326
+ }) {
1327
+ const k = re(() => {
1328
+ const h = [];
1329
+ let $ = 0;
1330
+ return o.forEach((r) => {
1331
+ const v = !!(r.startDate && r.finishDate), B = r.startDate || r.previsionStartDate, A = r.finishDate || r.previsionFinishDate;
1332
+ if (!B || !A) return;
1333
+ const W = new Date(B), z = new Date(A);
1334
+ if (isNaN(W.getTime()) || isNaN(z.getTime())) return;
1335
+ z <= W && z.setDate(z.getDate() + 1);
1336
+ let R, H;
1337
+ if (r.previsionStartDate && r.previsionFinishDate) {
1338
+ const O = new Date(r.previsionStartDate), se = new Date(r.previsionFinishDate);
1339
+ !isNaN(O.getTime()) && !isNaN(se.getTime()) && (R = O, H = se <= O ? q(O, 1) : se);
1340
+ }
1341
+ const _ = f?.filter((O) => O.successorId === r.id).map((O) => O.predecessorId) || [];
1342
+ h.push({
1343
+ id: r.id,
1344
+ name: r.name,
1345
+ start: W,
1346
+ end: z,
1347
+ progress: r.conclusionPercent ? Number(r.conclusionPercent) * 100 : 0,
1348
+ originalType: "step",
1349
+ deps: _,
1350
+ colorIdx: $ % te.length,
1351
+ previsionStart: R,
1352
+ previsionEnd: H,
1353
+ hasActualDates: v,
1354
+ projectId: r.projectId || void 0,
1355
+ projectTitle: r.projectTitle || void 0
1356
+ }), $++;
1357
+ }), g?.forEach((r) => {
1358
+ if (!r.date) return;
1359
+ const v = new Date(r.date);
1360
+ if (isNaN(v.getTime())) return;
1361
+ const B = f?.filter((A) => A.successorId === r.id).map((A) => A.predecessorId) || [];
1362
+ h.push({
1363
+ id: r.id,
1364
+ name: r.name,
1365
+ start: v,
1366
+ end: v,
1367
+ progress: r.finished ? 100 : 0,
1368
+ originalType: "milestone",
1369
+ deps: B,
1370
+ projectId: r.projectId || void 0,
1371
+ projectTitle: r.projectTitle || void 0
1372
+ });
1373
+ }), d?.forEach((r) => {
1374
+ if (!r.date) return;
1375
+ const v = new Date(r.date);
1376
+ if (isNaN(v.getTime())) return;
1377
+ const B = f?.filter((A) => A.successorId === r.id).map((A) => A.predecessorId) || [];
1378
+ h.push({
1379
+ id: r.id,
1380
+ name: r.title,
1381
+ start: v,
1382
+ end: v,
1383
+ progress: r.finished ? 100 : 0,
1384
+ originalType: "event",
1385
+ deps: B,
1386
+ projectId: r.projectId || void 0,
1387
+ projectTitle: r.projectTitle || void 0
1388
+ });
1389
+ }), N?.forEach((r) => {
1390
+ if (!r.date) return;
1391
+ const v = new Date(r.date);
1392
+ isNaN(v.getTime()) || h.push({
1393
+ id: r.id,
1394
+ name: r.title || "Nota",
1395
+ start: v,
1396
+ end: v,
1397
+ progress: 0,
1398
+ originalType: "note",
1399
+ deps: [],
1400
+ noteCount: 1,
1401
+ noteColor: r.color || e.note,
1402
+ filesCount: r.filesCount || 0,
1403
+ noteProjectTitle: r.projectTitle || void 0,
1404
+ projectId: r.projectId || void 0,
1405
+ projectTitle: r.projectTitle || void 0
1406
+ });
1407
+ }), h;
1408
+ }, [o, g, d, N, f]), w = re(() => gt(k, b), [k, b]), p = re(() => {
1409
+ const h = [], $ = ["step", "milestone", "event", "note"];
1410
+ if (I) {
1411
+ const r = /* @__PURE__ */ new Map();
1412
+ k.forEach((v) => {
1413
+ v.projectId && !r.has(v.projectId) && r.set(v.projectId, v.projectTitle || v.projectId);
1414
+ });
1415
+ for (const [v, B] of Array.from(r.entries())) {
1416
+ const A = D.has(v);
1417
+ if (h.push({ kind: "projectHeader", projectId: v, projectTitle: B, collapsed: A }), !A) {
1418
+ const W = k.filter((z) => z.projectId === v);
1419
+ for (const z of $) {
1420
+ if (!T.has(z)) continue;
1421
+ const R = W.filter((O) => O.originalType === z);
1422
+ if (R.length === 0) continue;
1423
+ const H = `${v}-${z}`, _ = S.has(H);
1424
+ h.push({ kind: "group", groupType: z, label: Fe[z], count: R.length, collapsed: _, projectId: v }), _ || R.forEach((O) => h.push({ kind: "task", task: O }));
1425
+ }
1426
+ }
1427
+ }
1428
+ } else
1429
+ for (const r of $) {
1430
+ if (!T.has(r)) continue;
1431
+ const v = k.filter((A) => A.originalType === r);
1432
+ if (v.length === 0) continue;
1433
+ const B = S.has(r);
1434
+ h.push({ kind: "group", groupType: r, label: Fe[r], count: v.length, collapsed: B }), B || v.forEach((A) => h.push({ kind: "task", task: A }));
1435
+ }
1436
+ return h;
1437
+ }, [k, T, S, D, I]), x = re(() => {
1438
+ const h = /* @__PURE__ */ new Map();
1439
+ return p.forEach(($, r) => {
1440
+ $.kind === "task" && h.set($.task.id, r);
1441
+ }), h;
1442
+ }, [p]), c = re(
1443
+ () => bt(k, f || [], w, x),
1444
+ [k, f, w, x]
1445
+ ), a = re(() => vt(k, f || []), [k, f]), l = re(() => {
1446
+ const h = /* @__PURE__ */ new Set(), $ = /* @__PURE__ */ new Date();
1447
+ return k.forEach((r) => {
1448
+ r.originalType === "step" && r.end < $ && r.progress < 100 && h.add(r.id);
1449
+ }), h;
1450
+ }, [k]), u = re(() => {
1451
+ if (!E || !f?.length) return /* @__PURE__ */ new Set();
1452
+ const h = /* @__PURE__ */ new Set(), $ = [E];
1453
+ for (; $.length; ) {
1454
+ const r = $.shift();
1455
+ for (const v of f)
1456
+ v.predecessorId === r && !h.has(v.successorId) && (h.add(v.successorId), $.push(v.successorId)), v.successorId === r && !h.has(v.predecessorId) && (h.add(v.predecessorId), $.push(v.predecessorId));
1457
+ }
1458
+ return h;
1459
+ }, [E, f]);
1460
+ return {
1461
+ tasks: k,
1462
+ timeline: w,
1463
+ displayRows: p,
1464
+ taskRowIndex: x,
1465
+ arrows: c,
1466
+ criticalIds: a,
1467
+ delayedIds: l,
1468
+ relatedIds: u
1469
+ };
1470
+ }
1471
+ function Dt(o) {
1472
+ const [g, d] = Y("day"), [N, f] = Y(null), [b, I] = Y(null), [T, S] = Y(null), [D, E] = Y({
1473
+ isOpen: !1,
1474
+ position: { x: 0, y: 0 },
1475
+ task: null
1476
+ }), [k, w] = Y(null), [p, x] = Y(null), [c, a] = Y(null), [l, u] = Y(null), [h, $] = Y("FS"), [r, v] = Y(0), [B, A] = Y(!1), [W, z] = Y(null), [R, H] = Y(null), [_, O] = Y(!1), se = ue(null), [ge, fe] = Y(/* @__PURE__ */ new Set(["step", "milestone", "event", "note"])), [xe, Ie] = Y(/* @__PURE__ */ new Set()), [ye, Te] = Y(/* @__PURE__ */ new Set()), ae = V((n) => {
1477
+ fe((i) => {
1478
+ const m = new Set(i);
1479
+ return m.has(n) ? m.delete(n) : m.add(n), m;
1480
+ });
1481
+ }, []), me = V((n) => {
1482
+ Ie((i) => {
1483
+ const m = new Set(i);
1484
+ return m.has(n) ? m.delete(n) : m.add(n), m;
1485
+ });
1486
+ }, []), De = V((n) => {
1487
+ Te((i) => {
1488
+ const m = new Set(i);
1489
+ return m.has(n) ? m.delete(n) : m.add(n), m;
1490
+ });
1491
+ }, []), j = wt({
1492
+ steps: o.steps,
1493
+ milestones: o.milestones,
1494
+ events: o.events,
1495
+ notes: o.notes,
1496
+ dependencies: o.dependencies,
1497
+ viewMode: g,
1498
+ visibleTypes: ge,
1499
+ collapsedGroups: xe,
1500
+ collapsedProjects: ye,
1501
+ groupByProject: o.groupByProject,
1502
+ selectedTaskId: b || null
1503
+ }), P = mt(j.timeline), $e = V((n, i) => {
1504
+ n.preventDefault(), n.stopPropagation(), w({ task: i, startMouseX: n.clientX, originalStart: new Date(i.start), originalEnd: new Date(i.end), offsetDays: 0 });
1505
+ }, []), Re = V((n, i, m) => {
1506
+ n.preventDefault(), n.stopPropagation(), x({ task: i, edge: m, startMouseX: n.clientX, originalStart: new Date(i.start), originalEnd: new Date(i.end), offsetDays: 0 });
1507
+ }, []), Me = V((n, i, m) => {
1508
+ n.preventDefault(), n.stopPropagation(), a({ fromTaskId: i.id, fromEdge: m, fromScreenX: n.clientX, fromScreenY: n.clientY, currentScreenX: n.clientX, currentScreenY: n.clientY, hoverTargetId: null });
1509
+ }, []), Ee = V(async () => {
1510
+ if (!l || !o.onCreateDependency) return;
1511
+ const n = new Map(j.tasks.map((F) => [F.id, F])), i = n.get(l.fromTaskId), m = n.get(l.toTaskId);
1512
+ if (!i || !m) return;
1513
+ const L = (F) => F.originalType === "step" ? "STEP" : "MILESTONE", C = l.fromEdge === "right" ? i : m, M = l.fromEdge === "right" ? m : i;
1514
+ A(!0);
1515
+ try {
1516
+ await o.onCreateDependency({ predecessorId: C.id, predecessorType: L(C), successorId: M.id, successorType: L(M), type: h, lag: r }), u(null);
1517
+ } finally {
1518
+ A(!1);
1519
+ }
1520
+ }, [l, j.tasks, o.onCreateDependency, h, r]);
1521
+ le(() => {
1522
+ if (!k) return;
1523
+ const n = (m) => {
1524
+ const L = m.clientX - k.startMouseX, C = Math.round(L / j.timeline.dayWidth);
1525
+ C !== k.offsetDays && w((M) => M ? { ...M, offsetDays: C } : null);
1526
+ }, i = () => {
1527
+ k.offsetDays !== 0 && o.onTaskChange && o.onTaskChange({
1528
+ id: k.task.id,
1529
+ name: k.task.name,
1530
+ start: q(k.originalStart, k.offsetDays),
1531
+ end: q(k.originalEnd, k.offsetDays),
1532
+ type: k.task.originalType === "step" ? "task" : "milestone",
1533
+ progress: k.task.progress
1534
+ }), w(null);
1535
+ };
1536
+ return document.addEventListener("mousemove", n), document.addEventListener("mouseup", i), () => {
1537
+ document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", i);
1538
+ };
1539
+ }, [k, j.timeline.dayWidth, o.onTaskChange]), le(() => {
1540
+ if (!p) return;
1541
+ const n = (m) => {
1542
+ const L = m.clientX - p.startMouseX, C = Math.round(L / j.timeline.dayWidth);
1543
+ C !== p.offsetDays && x((M) => M ? { ...M, offsetDays: C } : null);
1544
+ }, i = () => {
1545
+ if (p.offsetDays !== 0 && o.onTaskChange) {
1546
+ const m = p.edge === "left" ? q(p.originalStart, p.offsetDays) : p.originalStart, L = p.edge === "right" ? q(p.originalEnd, p.offsetDays) : p.originalEnd;
1547
+ L > m && o.onTaskChange({ id: p.task.id, name: p.task.name, start: m, end: L, type: "task", progress: p.task.progress });
1548
+ }
1549
+ x(null);
1550
+ };
1551
+ return document.addEventListener("mousemove", n), document.addEventListener("mouseup", i), () => {
1552
+ document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", i);
1553
+ };
1554
+ }, [p, j.timeline.dayWidth, o.onTaskChange]), le(() => {
1555
+ if (!c) return;
1556
+ const n = (m) => {
1557
+ let L = null;
1558
+ for (const C of document.elementsFromPoint(m.clientX, m.clientY)) {
1559
+ const M = C.dataset?.taskId;
1560
+ if (M && M !== c.fromTaskId) {
1561
+ L = M;
1562
+ break;
1563
+ }
1564
+ }
1565
+ a((C) => C ? { ...C, currentScreenX: m.clientX, currentScreenY: m.clientY, hoverTargetId: L } : null);
1566
+ }, i = (m) => {
1567
+ let L = null;
1568
+ for (const C of document.elementsFromPoint(m.clientX, m.clientY)) {
1569
+ const M = C.dataset?.taskId;
1570
+ if (M && M !== c.fromTaskId) {
1571
+ L = M;
1572
+ break;
1573
+ }
1574
+ }
1575
+ L && o.onCreateDependency && (u({ fromTaskId: c.fromTaskId, fromEdge: c.fromEdge, toTaskId: L }), $("FS"), v(0)), a(null);
1576
+ };
1577
+ return document.addEventListener("mousemove", n), document.addEventListener("mouseup", i), () => {
1578
+ document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", i);
1579
+ };
1580
+ }, [c?.fromTaskId, c?.fromEdge, o.onCreateDependency]);
1581
+ const [J, ce] = Y(null), oe = V((n) => {
1582
+ if (p || k || n.button === 2) return;
1583
+ const i = P.rightBodyRef.current;
1584
+ i && (n.preventDefault(), ce({ startX: n.clientX, startY: n.clientY, scrollLeft: i.scrollLeft, scrollTop: i.scrollTop }));
1585
+ }, [p, k, P.rightBodyRef]);
1586
+ le(() => {
1587
+ if (!J) return;
1588
+ const n = (m) => {
1589
+ const L = P.rightBodyRef.current;
1590
+ L && (L.scrollLeft = J.scrollLeft - (m.clientX - J.startX), L.scrollTop = J.scrollTop - (m.clientY - J.startY), P.leftBodyRef.current && (P.leftBodyRef.current.scrollTop = L.scrollTop), P.timeHeaderRef.current && (P.timeHeaderRef.current.scrollLeft = L.scrollLeft));
1591
+ }, i = () => ce(null);
1592
+ return document.addEventListener("mousemove", n), document.addEventListener("mouseup", i), () => {
1593
+ document.removeEventListener("mousemove", n), document.removeEventListener("mouseup", i);
1594
+ };
1595
+ }, [J, P.rightBodyRef, P.leftBodyRef, P.timeHeaderRef]);
1596
+ const pe = V((n) => {
1597
+ n.preventDefault(), n.stopPropagation();
1598
+ const i = (L) => {
1599
+ const C = P.rightBodyRef.current;
1600
+ if (!C) return /* @__PURE__ */ new Date();
1601
+ const M = C.getBoundingClientRect(), F = L - M.left + C.scrollLeft;
1602
+ return q(j.timeline.start, Math.max(0, Math.floor(F / j.timeline.dayWidth)));
1603
+ }, m = (L) => {
1604
+ if (!o.groupByProject) return;
1605
+ const C = P.leftBodyRef.current;
1606
+ if (!C) return;
1607
+ const M = C.getBoundingClientRect(), F = L - M.top + C.scrollTop, de = Math.max(0, Math.floor(F / 50));
1608
+ for (let U = Math.min(de, j.displayRows.length - 1); U >= 0; U--) {
1609
+ const Z = j.displayRows[U];
1610
+ if (Z.kind === "projectHeader") return Z.projectId;
1611
+ if (Z.kind === "task" && Z.task.projectId) return Z.task.projectId;
1612
+ if (Z.kind === "group" && Z.projectId) return Z.projectId;
1613
+ }
1614
+ };
1615
+ H({ x: n.clientX, y: n.clientY, date: i(n.clientX), projectId: m(n.clientY) }), ce(null);
1616
+ }, [j.timeline, j.displayRows, o.groupByProject, P.rightBodyRef, P.leftBodyRef]);
1617
+ le(() => {
1618
+ if (!R) return;
1619
+ const n = (L) => {
1620
+ L.key === "Escape" && H(null);
1621
+ }, i = (L) => {
1622
+ L.target.closest('[data-menu="chart-create"]') || H(null);
1623
+ }, m = () => H(null);
1624
+ return document.addEventListener("keydown", n), document.addEventListener("click", i), window.addEventListener("scroll", m, !0), () => {
1625
+ document.removeEventListener("keydown", n), document.removeEventListener("click", i), window.removeEventListener("scroll", m, !0);
1626
+ };
1627
+ }, [R]);
1628
+ const y = re(() => ({
1629
+ props: o,
1630
+ t: (n, i) => o.translations ? typeof o.translations == "function" ? o.translations(n, i) : o.translations[n] || i || "" : i || "",
1631
+ viewMode: g,
1632
+ setViewMode: d,
1633
+ hoveredTaskId: N,
1634
+ setHoveredTaskId: f,
1635
+ selectedTaskId: b,
1636
+ setSelectedTaskId: I,
1637
+ tooltip: T,
1638
+ setTooltip: S,
1639
+ popupState: D,
1640
+ setPopupState: E,
1641
+ dragState: k,
1642
+ setDragState: w,
1643
+ resizeState: p,
1644
+ setResizeState: x,
1645
+ connectState: c,
1646
+ setConnectState: a,
1647
+ visibleTypes: ge,
1648
+ setVisibleTypes: fe,
1649
+ toggleVisibility: ae,
1650
+ collapsedGroups: xe,
1651
+ setCollapsedGroups: Ie,
1652
+ toggleGroup: me,
1653
+ collapsedProjects: ye,
1654
+ setCollapsedProjects: Te,
1655
+ toggleProject: De,
1656
+ pendingConnection: l,
1657
+ setPendingConnection: u,
1658
+ depModalType: h,
1659
+ setDepModalType: $,
1660
+ depModalLag: r,
1661
+ setDepModalLag: v,
1662
+ depCreating: B,
1663
+ setDepCreating: A,
1664
+ deletingDepId: W,
1665
+ setDeletingDepId: z,
1666
+ chartMenu: R,
1667
+ setChartMenu: H,
1668
+ newActionOpen: _,
1669
+ setNewActionOpen: O,
1670
+ tasks: j.tasks,
1671
+ timeline: j.timeline,
1672
+ displayRows: j.displayRows,
1673
+ taskRowIndex: j.taskRowIndex || /* @__PURE__ */ new Map(),
1674
+ arrows: j.arrows,
1675
+ criticalIds: j.criticalIds,
1676
+ delayedIds: j.delayedIds,
1677
+ relatedIds: j.relatedIds,
1678
+ ...P,
1679
+ newActionRef: se,
1680
+ screenXToDate: (n) => {
1681
+ const i = P.rightBodyRef.current;
1682
+ if (!i) return /* @__PURE__ */ new Date();
1683
+ const m = i.getBoundingClientRect(), L = n - m.left + i.scrollLeft;
1684
+ return q(j.timeline.start, Math.max(0, Math.floor(L / j.timeline.dayWidth)));
1685
+ },
1686
+ screenYToProjectId: (n) => {
1687
+ if (!o.groupByProject) return;
1688
+ const i = P.leftBodyRef.current;
1689
+ if (!i) return;
1690
+ const m = i.getBoundingClientRect(), L = n - m.top + i.scrollTop, C = Math.max(0, Math.floor(L / 50));
1691
+ for (let M = Math.min(C, j.displayRows.length - 1); M >= 0; M--) {
1692
+ const F = j.displayRows[M];
1693
+ if (F.kind === "projectHeader") return F.projectId;
1694
+ if (F.kind === "task" && F.task.projectId) return F.task.projectId;
1695
+ if (F.kind === "group" && F.projectId) return F.projectId;
1696
+ }
1697
+ },
1698
+ handleChartMouseDown: oe,
1699
+ openChartMenu: pe,
1700
+ handleBarMouseDown: $e,
1701
+ handleResizeMouseDown: Re,
1702
+ handleConnectDotMouseDown: Me,
1703
+ handleCreateDependency: Ee
1704
+ }), [
1705
+ o,
1706
+ g,
1707
+ N,
1708
+ b,
1709
+ T,
1710
+ D,
1711
+ k,
1712
+ p,
1713
+ c,
1714
+ ge,
1715
+ xe,
1716
+ ye,
1717
+ l,
1718
+ h,
1719
+ r,
1720
+ B,
1721
+ W,
1722
+ R,
1723
+ _,
1724
+ j,
1725
+ P,
1726
+ ae,
1727
+ me,
1728
+ De,
1729
+ oe,
1730
+ pe,
1731
+ $e,
1732
+ Re,
1733
+ Me,
1734
+ Ee
1735
+ ]);
1736
+ return o.loading ? /* @__PURE__ */ t("div", { style: { padding: 48, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", color: e.textSecondary }, children: /* @__PURE__ */ t(st, { size: 32, style: { animation: "spin 1.5s linear infinite", color: e.group } }) }) : /* @__PURE__ */ t(at, { value: y, children: /* @__PURE__ */ s(
1737
+ "div",
1738
+ {
1739
+ className: "w-full flex flex-col mx-auto bg-white rounded-xl shadow-[0_8px_30px_rgb(0,0,0,0.06)] overflow-hidden",
1740
+ style: { height: "calc(100vh - 48px)", minHeight: 600, border: `1px solid ${e.borderLight}` },
1741
+ children: [
1742
+ /* @__PURE__ */ t(ut, {}),
1743
+ /* @__PURE__ */ s("div", { className: "flex flex-1 overflow-hidden relative", style: { background: e.surfaceAlt }, children: [
1744
+ /* @__PURE__ */ t(ht, {}),
1745
+ /* @__PURE__ */ t(yt, {})
1746
+ ] })
1747
+ ]
1748
+ }
1749
+ ) });
1750
+ }
1751
+ export {
1752
+ Dt as ProjectGantt
1753
+ };