@nice2dev/ui 1.1.10 → 1.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.
Files changed (114) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +12 -20
  3. package/dist/NiceButton-5tWvfXKl.cjs +1 -0
  4. package/dist/NiceButton-DHSgQT1_.js +112 -0
  5. package/dist/NiceCodeEditor-B8At55f5.js +1179 -0
  6. package/dist/NiceCodeEditor-BJSEzhcY.cjs +260 -0
  7. package/dist/NiceColorPicker-DCgmE-3H.cjs +1 -0
  8. package/dist/NiceColorPicker-DK30kJgy.js +486 -0
  9. package/dist/NiceColorPicker-DtPFxDKM.cjs +1 -0
  10. package/dist/NiceColorPicker-bNJBAU_c.js +598 -0
  11. package/dist/NiceDataGrid-BOCJr6XF.js +2217 -0
  12. package/dist/NiceDataGrid-BV5Oh-gy.cjs +10 -0
  13. package/dist/NiceDataGrid-Dd7SI-M6.cjs +10 -0
  14. package/dist/NiceDataGrid-DjZchXYG.js +2217 -0
  15. package/dist/NiceForm-BCEXovJR.cjs +1 -0
  16. package/dist/NiceForm-D7oyWHXg.js +4820 -0
  17. package/dist/NiceForm-DUhxXArr.js +4817 -0
  18. package/dist/NiceForm-uCeVmTrD.cjs +1 -0
  19. package/dist/NiceHtmlEditor-BYk1roA4.cjs +10 -0
  20. package/dist/NiceHtmlEditor-C5kLeF9H.cjs +10 -0
  21. package/dist/NiceHtmlEditor-CFVMIC5L.js +848 -0
  22. package/dist/NiceHtmlEditor-mWebBmy1.js +849 -0
  23. package/dist/NiceLoginForm-BHyDY7br.cjs +1 -0
  24. package/dist/NiceLoginForm-BuxFY2Rk.js +750 -0
  25. package/dist/NiceLoginForm.css +1 -0
  26. package/dist/NiceMention-CA7CL5BI.js +11263 -0
  27. package/dist/NiceMention-CHcKRl-L.cjs +430 -0
  28. package/dist/NiceMention-DJD0BLcp.js +11269 -0
  29. package/dist/NiceMention-DcaUEMSg.cjs +430 -0
  30. package/dist/NiceMention.css +1 -1
  31. package/dist/NiceModal-C4p8a82e.cjs +1 -0
  32. package/dist/NiceModal-TNlkaL_i.js +85 -0
  33. package/dist/NiceModuleLifecyclePanel-BWbKdVC_.js +7054 -0
  34. package/dist/NiceModuleLifecyclePanel-CZHIzvkE.cjs +1 -0
  35. package/dist/NiceModuleLifecyclePanel-OC9YK2kG.js +7052 -0
  36. package/dist/NiceModuleLifecyclePanel-_OcfDmtC.cjs +1 -0
  37. package/dist/NicePagination-8XsBbMNx.js +165 -0
  38. package/dist/NicePagination-CkOoXf0f.js +165 -0
  39. package/dist/NicePagination-D7lek1G7.cjs +1 -0
  40. package/dist/NicePagination-OjTEfZJE.cjs +1 -0
  41. package/dist/NicePivotGrid-BJRSciWl.js +1183 -0
  42. package/dist/NicePivotGrid-CS1dPmNI.cjs +152 -0
  43. package/dist/NicePivotGrid-D2AxqDzJ.js +1183 -0
  44. package/dist/NicePivotGrid-DxQ6Py9D.cjs +152 -0
  45. package/dist/NiceSavedQueryPanel-B5HhqlAI.cjs +586 -0
  46. package/dist/NiceSavedQueryPanel-CMStDOKe.js +5125 -0
  47. package/dist/NiceSavedQueryPanel-D2i34e_b.cjs +586 -0
  48. package/dist/NiceSavedQueryPanel-mPO2THs7.js +5142 -0
  49. package/dist/NiceSavedQueryPanel.css +1 -1
  50. package/dist/NiceScheduler-7gP7vcLy.cjs +5 -0
  51. package/dist/NiceScheduler-Cy7F9tgH.js +1693 -0
  52. package/dist/NiceScheduler-DquRUZxD.cjs +5 -0
  53. package/dist/NiceScheduler-l8N4yCWd.js +1716 -0
  54. package/dist/NiceSelect-DZB1Rs9x.js +435 -0
  55. package/dist/NiceSelect-tMz9QQUs.cjs +1 -0
  56. package/dist/NiceStreamDashboard.doc-74KUXya1.cjs +8 -0
  57. package/dist/NiceStreamDashboard.doc-k8PQfCM0.js +32 -0
  58. package/dist/NiceWindow-BEov3s9F.js +2094 -0
  59. package/dist/NiceWindow-CDt6PCEg.cjs +1 -0
  60. package/dist/NiceWindow.css +1 -1
  61. package/dist/charts-C047IMVn.cjs +768 -0
  62. package/dist/charts-CCXSb3xk.js +4752 -0
  63. package/dist/charts-CqETcUhH.js +4752 -0
  64. package/dist/charts-DouiiHOT.cjs +768 -0
  65. package/dist/charts.cjs +1 -1
  66. package/dist/charts.mjs +1 -1
  67. package/dist/core-BL-KmGYC.js +795 -0
  68. package/dist/core-Chg-oYCr.cjs +1 -0
  69. package/dist/core-CxBnKAhs.cjs +1 -0
  70. package/dist/core-D_LRh59n.js +795 -0
  71. package/dist/data-branching-Km4lc8P_.cjs +1 -0
  72. package/dist/data-branching-YQtJJEtn.js +6273 -0
  73. package/dist/data-branching.cjs +1 -1
  74. package/dist/data-branching.mjs +1 -1
  75. package/dist/data.cjs +1 -1
  76. package/dist/data.d.ts +0 -51
  77. package/dist/data.mjs +3 -3
  78. package/dist/devops-D5yIDM3e.js +8312 -0
  79. package/dist/devops-rVpB0ZAX.cjs +17 -0
  80. package/dist/devops.cjs +1 -1
  81. package/dist/devops.mjs +1 -1
  82. package/dist/editors.cjs +1 -1
  83. package/dist/editors.d.ts +6 -25
  84. package/dist/editors.mjs +55 -54
  85. package/dist/feedback.cjs +1 -1
  86. package/dist/feedback.d.ts +5 -0
  87. package/dist/feedback.mjs +2 -2
  88. package/dist/index.cjs +284 -284
  89. package/dist/index.css +1 -1
  90. package/dist/index.d.ts +194 -208
  91. package/dist/index.mjs +20312 -19511
  92. package/dist/lazy.cjs +1 -1
  93. package/dist/lazy.mjs +29 -29
  94. package/dist/navigation.cjs +1 -1
  95. package/dist/navigation.mjs +3 -3
  96. package/dist/no-code-6WyYb3hL.cjs +331 -0
  97. package/dist/no-code-BH5oVFC6.js +8186 -0
  98. package/dist/no-code-CnHG5_Vn.js +8186 -0
  99. package/dist/no-code-DMKlg1Zl.cjs +331 -0
  100. package/dist/no-code.cjs +1 -1
  101. package/dist/no-code.css +1 -1
  102. package/dist/no-code.d.ts +25 -18
  103. package/dist/no-code.mjs +3 -3
  104. package/dist/overlays.cjs +1 -1
  105. package/dist/overlays.d.ts +24 -24
  106. package/dist/overlays.mjs +24 -490
  107. package/dist/pickerCommons-0vyK1Knv.js +547 -0
  108. package/dist/pickerCommons-BFbItm8o.cjs +1 -0
  109. package/dist/pickerCommons-BHirHJyn.js +548 -0
  110. package/dist/pickerCommons-Bt8JIaTN.cjs +1 -0
  111. package/dist/pickerCommons.css +1 -1
  112. package/dist/style.css +10 -7
  113. package/package.json +4 -6
  114. package/css/legacy-bg-text-aliases.css +0 -87
@@ -0,0 +1,1716 @@
1
+ import { jsxs as g, jsx as t, Fragment as Be } from "react/jsx-runtime";
2
+ import { NiceIcon as $e, useAccessibleClick as ut, useNiceTranslation as mt, useControllableState as ht } from "@nice2dev/ui-core";
3
+ import z, { useState as B, useRef as gt, useCallback as ne, useMemo as we } from "react";
4
+ import { N as re } from "./NiceButton-DHSgQT1_.js";
5
+ import { u as Te } from "./devops-D5yIDM3e.js";
6
+ import { d as pt, c as ze } from "./NiceForm-DUhxXArr.js";
7
+ import { NiceColorPicker as yt } from "./NiceColorPicker-DK30kJgy.js";
8
+ import { N as ft } from "./NiceModal-TNlkaL_i.js";
9
+ const Ve = ({
10
+ children: e,
11
+ className: n,
12
+ style: a,
13
+ direction: l = "horizontal",
14
+ size: i,
15
+ disabled: u,
16
+ readOnly: D,
17
+ loading: w,
18
+ error: C,
19
+ errorPlacement: I = "bottom"
20
+ }) => {
21
+ const k = /* @__PURE__ */ g(
22
+ "div",
23
+ {
24
+ className: `nice-btn-group ${l === "vertical" ? "nice-btn-group--vertical" : ""} ${w ? "nice-btn-group--loading" : ""} ${D ? "nice-btn-group--readonly" : ""} ${n || ""}`,
25
+ style: a,
26
+ role: "group",
27
+ "aria-busy": w || void 0,
28
+ children: [
29
+ z.Children.map(e, (M) => {
30
+ if (!z.isValidElement(M))
31
+ return M;
32
+ const r = {};
33
+ return u && (r.disabled = !0), D && (r.disabled = !0), w && (r.disabled = !0), i && (r.size = i), z.cloneElement(M, r);
34
+ }),
35
+ w && /* @__PURE__ */ t("span", { className: "nice-btn-group__spinner", children: /* @__PURE__ */ t("span", { className: "nice-spinner nice-spinner--sm" }) })
36
+ ]
37
+ }
38
+ );
39
+ if (!C)
40
+ return k;
41
+ const h = /* @__PURE__ */ t("div", { className: "nice-field__error", role: "alert", children: C });
42
+ return I === "right" ? /* @__PURE__ */ g(
43
+ "span",
44
+ {
45
+ className: `nice-btn-field nice-btn-field--right ${i ? `nice-field--${i}` : ""}`,
46
+ style: {
47
+ display: "inline-flex",
48
+ flexDirection: "row",
49
+ alignItems: "center",
50
+ gap: "8px",
51
+ width: "fit-content"
52
+ },
53
+ children: [
54
+ k,
55
+ h
56
+ ]
57
+ }
58
+ ) : /* @__PURE__ */ g(
59
+ "span",
60
+ {
61
+ className: `nice-btn-field nice-btn-field--bottom ${i ? `nice-field--${i}` : ""}`,
62
+ style: {
63
+ display: "inline-flex",
64
+ flexDirection: "column",
65
+ alignItems: "flex-start",
66
+ gap: "4px",
67
+ width: "fit-content"
68
+ },
69
+ children: [
70
+ k,
71
+ h
72
+ ]
73
+ }
74
+ );
75
+ }, P = (e, n) => {
76
+ const a = new Date(e);
77
+ return a.setDate(a.getDate() + n), a;
78
+ }, j = (e, n) => e.getFullYear() === n.getFullYear() && e.getMonth() === n.getMonth() && e.getDate() === n.getDate(), vt = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], _t = [
79
+ "January",
80
+ "February",
81
+ "March",
82
+ "April",
83
+ "May",
84
+ "June",
85
+ "July",
86
+ "August",
87
+ "September",
88
+ "October",
89
+ "November",
90
+ "December"
91
+ ], Dt = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"], wt = [
92
+ "january",
93
+ "february",
94
+ "march",
95
+ "april",
96
+ "may",
97
+ "june",
98
+ "july",
99
+ "august",
100
+ "september",
101
+ "october",
102
+ "november",
103
+ "december"
104
+ ];
105
+ function he(e) {
106
+ return Dt.map((n, a) => e(n, vt[a]));
107
+ }
108
+ function Nt(e) {
109
+ return wt.map((n, a) => e(n, _t[a]));
110
+ }
111
+ function Ue(e) {
112
+ const n = [
113
+ "Jan",
114
+ "Feb",
115
+ "Mar",
116
+ "Apr",
117
+ "May",
118
+ "Jun",
119
+ "Jul",
120
+ "Aug",
121
+ "Sep",
122
+ "Oct",
123
+ "Nov",
124
+ "Dec"
125
+ ];
126
+ return [
127
+ "janShort",
128
+ "febShort",
129
+ "marShort",
130
+ "aprShort",
131
+ "mayShort",
132
+ "junShort",
133
+ "julShort",
134
+ "augShort",
135
+ "sepShort",
136
+ "octShort",
137
+ "novShort",
138
+ "decShort"
139
+ ].map((l, i) => e(l, n[i]));
140
+ }
141
+ const bt = [
142
+ "Sunday",
143
+ "Monday",
144
+ "Tuesday",
145
+ "Wednesday",
146
+ "Thursday",
147
+ "Friday",
148
+ "Saturday"
149
+ ], St = [
150
+ "sunday",
151
+ "monday",
152
+ "tuesday",
153
+ "wednesday",
154
+ "thursday",
155
+ "friday",
156
+ "saturday"
157
+ ];
158
+ function xe(e) {
159
+ return St.map((n, a) => e(n, bt[a]));
160
+ }
161
+ function Ct(e, n, a, l = 1 / 0) {
162
+ const i = [], u = Math.max(1, Math.floor(e.interval ?? 1)), D = e.until ? new Date(e.until) : void 0, w = D && D < a ? D : a, C = Math.min(e.count && e.count > 0 ? e.count : 1 / 0, l), I = e.freq === "weekly" && e.byDay?.length ? [...new Set(e.byDay.filter((h) => Number.isInteger(h) && h >= 0 && h <= 6))].sort(
163
+ (h, M) => h - M
164
+ ) : [];
165
+ if (I.length > 0) {
166
+ const h = new Date(n);
167
+ h.setDate(n.getDate() - n.getDay());
168
+ for (let M = 0; i.length < C; M += u) {
169
+ const r = new Date(h);
170
+ if (r.setDate(h.getDate() + M * 7), r > w)
171
+ break;
172
+ for (const N of I) {
173
+ const b = new Date(r);
174
+ if (b.setDate(r.getDate() + N), !(b < n)) {
175
+ if (b > w || i.length >= C)
176
+ break;
177
+ i.push(b);
178
+ }
179
+ }
180
+ }
181
+ return i;
182
+ }
183
+ let k = new Date(n);
184
+ for (; k <= w && i.length < C; ) {
185
+ i.push(new Date(k));
186
+ const h = new Date(k);
187
+ e.freq === "daily" ? h.setDate(h.getDate() + u) : e.freq === "weekly" ? h.setDate(h.getDate() + 7 * u) : e.freq === "monthly" ? h.setMonth(h.getMonth() + u) : h.setFullYear(h.getFullYear() + u), k = h;
188
+ }
189
+ return i;
190
+ }
191
+ function kt(e, n, a) {
192
+ const l = [];
193
+ for (const i of e) {
194
+ if (!i.recurrence) {
195
+ l.push(i);
196
+ continue;
197
+ }
198
+ const u = new Date(i.end).getTime() - new Date(i.start).getTime();
199
+ Ct(i.recurrence, new Date(i.start), a).forEach((D, w) => {
200
+ const C = new Date(D.getTime() + u);
201
+ C >= n && l.push({ ...i, id: `${i.id}_${w}`, start: D, end: C });
202
+ });
203
+ }
204
+ return l;
205
+ }
206
+ function Je(e, n) {
207
+ return e.filter((a) => {
208
+ const l = new Date(a.start), i = new Date(a.end);
209
+ return n >= new Date(l.getFullYear(), l.getMonth(), l.getDate()) && n <= new Date(i.getFullYear(), i.getMonth(), i.getDate());
210
+ });
211
+ }
212
+ function Mt(e = "r") {
213
+ return `${e}_${Math.random().toString(36).slice(2, 9)}`;
214
+ }
215
+ function Tt(e = {}) {
216
+ return {
217
+ id: e.id ?? Mt(),
218
+ title: e.title ?? "",
219
+ description: e.description ?? "",
220
+ servings: e.servings ?? 2,
221
+ prepMinutes: e.prepMinutes,
222
+ cookMinutes: e.cookMinutes,
223
+ difficulty: e.difficulty,
224
+ cuisine: e.cuisine,
225
+ tags: e.tags ?? [],
226
+ ingredients: e.ingredients ?? [],
227
+ steps: e.steps ?? [],
228
+ photos: e.photos ?? [],
229
+ nutrition: e.nutrition,
230
+ sourceUrl: e.sourceUrl,
231
+ createdAt: e.createdAt ?? /* @__PURE__ */ new Date(),
232
+ updatedAt: e.updatedAt ?? /* @__PURE__ */ new Date()
233
+ };
234
+ }
235
+ function $t(e) {
236
+ const n = (e.prepMinutes ?? 0) + (e.cookMinutes ?? 0);
237
+ return n > 0 ? n : void 0;
238
+ }
239
+ const ge = ({ ev: e, renderEvent: n, onClick: a, draggable: l, dragRef: i, onHover: u, categoryColor: D }) => {
240
+ const w = D || e.color || "var(--nice-color-primary, #3b82f6)", I = {
241
+ solid: { backgroundColor: w, color: "var(--nice-color-white, #fff)" },
242
+ striped: {
243
+ background: `repeating-linear-gradient(45deg, ${w}, ${w} 4px, transparent 4px, transparent 8px)`,
244
+ border: `1px solid ${w}`,
245
+ color: "var(--nice-text-primary, #333)"
246
+ },
247
+ outlined: { backgroundColor: "transparent", border: `2px solid ${w}`, color: w },
248
+ dashed: { backgroundColor: "transparent", border: `2px dashed ${w}`, color: w }
249
+ }[e.eventStyle || "solid"];
250
+ return /* @__PURE__ */ t(
251
+ "div",
252
+ {
253
+ className: `nice-scheduler__event nice-scheduler__event--${e.eventStyle || "solid"}`,
254
+ style: I,
255
+ draggable: l,
256
+ onDragStart: () => {
257
+ i.current = { event: e };
258
+ },
259
+ onDragEnd: () => {
260
+ i.current = null;
261
+ },
262
+ onClick: (k) => {
263
+ k.stopPropagation(), a?.(e);
264
+ },
265
+ onMouseEnter: (k) => u(e, k.currentTarget.getBoundingClientRect()),
266
+ onMouseLeave: () => u(null),
267
+ children: n ? n(e) : e.title
268
+ }
269
+ );
270
+ };
271
+ function ie(e, n) {
272
+ if (!(!e.category || !n))
273
+ return n.find((a) => a.key === e.category)?.color;
274
+ }
275
+ const xt = ({
276
+ events: e,
277
+ curDate: n,
278
+ firstDayOfWeek: a,
279
+ onSlotClick: l,
280
+ onEventClick: i,
281
+ draggable: u,
282
+ dragRef: D,
283
+ categories: w,
284
+ renderEvent: C,
285
+ onHoverEvent: I,
286
+ readOnly: k,
287
+ t: h
288
+ }) => {
289
+ const M = he(h), r = n.getFullYear(), N = n.getMonth(), b = new Date(r, N, 1), o = new Date(r, N + 1, 0), d = (b.getDay() - a + 7) % 7, E = o.getDate(), y = [];
290
+ for (let m = d - 1; m >= 0; m--)
291
+ y.push({ date: P(b, -m - 1), isCurrentMonth: !1 });
292
+ for (let m = 0; m < E; m++)
293
+ y.push({ date: new Date(r, N, m + 1), isCurrentMonth: !0 });
294
+ let F = 1;
295
+ for (; y.length < 42; )
296
+ y.push({ date: new Date(r, N + 1, F++), isCurrentMonth: !1 });
297
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__month", children: [
298
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__month-header", children: Array.from({ length: 7 }, (m, f) => /* @__PURE__ */ t("div", { className: "nice-scheduler__month-dayname", children: M[(a + f) % 7] }, f)) }),
299
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__month-grid", children: y.map((m, f) => {
300
+ const L = Je(e, m.date), p = j(m.date, /* @__PURE__ */ new Date()), S = m.date.getDay(), A = S === 0 || S === 6;
301
+ return /* @__PURE__ */ g(
302
+ "div",
303
+ {
304
+ className: `nice-scheduler__month-cell ${m.isCurrentMonth ? "" : "nice-scheduler__month-cell--other"} ${p ? "nice-scheduler__month-cell--today" : ""} ${A ? "nice-scheduler__month-cell--weekend" : ""}`,
305
+ onClick: () => !k && l?.(m.date, P(m.date, 1)),
306
+ children: [
307
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__month-date", children: m.date.getDate() }),
308
+ L.slice(0, 3).map((Y) => /* @__PURE__ */ t(
309
+ ge,
310
+ {
311
+ ev: Y,
312
+ renderEvent: C,
313
+ onClick: i,
314
+ draggable: u && !k,
315
+ dragRef: D,
316
+ onHover: I,
317
+ categoryColor: ie(Y, w)
318
+ },
319
+ Y.id
320
+ )),
321
+ L.length > 3 && /* @__PURE__ */ g("div", { className: "nice-scheduler__month-more", children: [
322
+ "+",
323
+ L.length - 3
324
+ ] })
325
+ ]
326
+ },
327
+ f
328
+ );
329
+ }) })
330
+ ] });
331
+ }, Et = ({
332
+ events: e,
333
+ days: n,
334
+ startHour: a,
335
+ endHour: l,
336
+ draggable: i,
337
+ dragRef: u,
338
+ onEventClick: D,
339
+ onSlotClick: w,
340
+ onEventDrop: C,
341
+ categories: I,
342
+ workHours: k,
343
+ showCurrentTime: h,
344
+ renderEvent: M,
345
+ onHoverEvent: r,
346
+ readOnly: N,
347
+ t: b
348
+ }) => {
349
+ const o = [];
350
+ for (let p = a; p < l; p++)
351
+ o.push(p);
352
+ he(b);
353
+ const d = xe(b), E = z.useRef(null), y = /* @__PURE__ */ new Date(), F = y.getHours() * 60 + y.getMinutes(), m = (l - a) * 60, f = (F - a * 60) / m * 100, L = h && F >= a * 60 && F < l * 60;
354
+ return z.useEffect(() => {
355
+ const p = E.current;
356
+ if (!p)
357
+ return;
358
+ const S = /* @__PURE__ */ new Date(), A = e.filter((x) => n.some((q) => j(q, new Date(x.start)))), Y = A.filter((x) => j(new Date(x.start), S));
359
+ let H;
360
+ Y.length > 0 ? H = Math.min(...Y.map((x) => new Date(x.start).getHours())) : A.length > 0 ? H = Math.min(...A.map((x) => new Date(x.start).getHours())) : H = 8, H = Math.max(a, Math.min(H, l - 1));
361
+ const s = H - a, v = p.children[s];
362
+ if (v) {
363
+ const x = p.closest(".nice-scheduler__content") ?? p.closest(".nice-scheduler__timegrid");
364
+ x && (x.scrollTop = v.offsetTop - 4);
365
+ }
366
+ }, []), /* @__PURE__ */ g("div", { className: "nice-scheduler__timegrid", children: [
367
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__timegrid-header", children: [
368
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__time-gutter" }),
369
+ n.map((p, S) => {
370
+ const A = p.getDay() === 0 || p.getDay() === 6;
371
+ return /* @__PURE__ */ g(
372
+ "div",
373
+ {
374
+ className: `nice-scheduler__timegrid-day-header ${j(p, y) ? "nice-scheduler__timegrid-day-header--today" : ""} ${A ? "nice-scheduler__timegrid-day-header--weekend" : ""}`,
375
+ children: [
376
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timegrid-day-name", children: d[p.getDay()] }),
377
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timegrid-day-num", children: p.getDate() })
378
+ ]
379
+ },
380
+ S
381
+ );
382
+ })
383
+ ] }),
384
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__timegrid-body", ref: E, style: { position: "relative" }, children: [
385
+ o.map((p) => {
386
+ const S = k ? p >= k[0] && p < k[1] : !1;
387
+ return /* @__PURE__ */ g(
388
+ "div",
389
+ {
390
+ className: `nice-scheduler__timegrid-row ${S ? "nice-scheduler__timegrid-row--work" : ""}`,
391
+ children: [
392
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__time-gutter", children: `${p.toString().padStart(2, "0")}:00` }),
393
+ n.map((A, Y) => {
394
+ const H = e.filter((s) => {
395
+ const v = new Date(s.start);
396
+ return j(v, A) && v.getHours() === p;
397
+ });
398
+ return /* @__PURE__ */ t(
399
+ "div",
400
+ {
401
+ className: "nice-scheduler__timegrid-cell",
402
+ onDragOver: i && !N ? (s) => s.preventDefault() : void 0,
403
+ onDrop: i && !N ? () => {
404
+ if (!u.current || !C)
405
+ return;
406
+ const s = u.current.event, v = new Date(s.end).getTime() - new Date(s.start).getTime(), x = new Date(A);
407
+ x.setHours(p, 0, 0, 0);
408
+ const q = new Date(x.getTime() + v);
409
+ C(s, x, q), u.current = null;
410
+ } : void 0,
411
+ onClick: () => !N && (() => {
412
+ const s = new Date(A);
413
+ s.setHours(p);
414
+ const v = new Date(s);
415
+ v.setHours(p + 1), w?.(s, v);
416
+ })(),
417
+ children: H.map((s) => /* @__PURE__ */ t(
418
+ ge,
419
+ {
420
+ ev: s,
421
+ renderEvent: M,
422
+ onClick: D,
423
+ draggable: i && !N,
424
+ dragRef: u,
425
+ onHover: r,
426
+ categoryColor: ie(s, I)
427
+ },
428
+ s.id
429
+ ))
430
+ },
431
+ Y
432
+ );
433
+ })
434
+ ]
435
+ },
436
+ p
437
+ );
438
+ }),
439
+ L && n.some((p) => j(p, y)) && /* @__PURE__ */ t("div", { className: "nice-scheduler__now-line", style: { top: `${f}%` }, children: /* @__PURE__ */ t("div", { className: "nice-scheduler__now-dot" }) })
440
+ ] })
441
+ ] });
442
+ }, Lt = ({
443
+ events: e,
444
+ curDate: n,
445
+ onEventClick: a,
446
+ categories: l,
447
+ t: i
448
+ }) => {
449
+ const u = [...e].filter(
450
+ (D) => new Date(D.start) >= new Date(n.getFullYear(), n.getMonth(), n.getDate())
451
+ ).sort((D, w) => new Date(D.start).getTime() - new Date(w.start).getTime()).slice(0, 50);
452
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__agenda", children: [
453
+ u.map((D) => /* @__PURE__ */ t(Rt, { ev: D, categories: l, onEventClick: a }, D.id)),
454
+ u.length === 0 && /* @__PURE__ */ t("div", { className: "nice-scheduler__agenda-empty", children: i("noEvents", "No upcoming events") })
455
+ ] });
456
+ }, je = ({ parts: e }) => /* @__PURE__ */ t("div", { className: "nice-scheduler__agenda-meta", children: e.map(([n, a], l) => /* @__PURE__ */ g(z.Fragment, { children: [
457
+ l > 0 && " · ",
458
+ /* @__PURE__ */ t($e, { name: n, size: 12, style: { verticalAlign: "-2px" } }),
459
+ " ",
460
+ a
461
+ ] }, n)) }), Ge = ({ ev: e }) => {
462
+ if (e.eventType === "recipe" && e.recipe) {
463
+ const n = $t(e.recipe), a = [];
464
+ return n !== void 0 && a.push(["clock", `${n} min`]), e.recipe.ingredients?.length && a.push(["list", `${e.recipe.ingredients.length} ingredients`]), e.recipe.servings && a.push(["utensils", `${e.recipe.servings} servings`]), a.length === 0 ? null : /* @__PURE__ */ t(je, { parts: a });
465
+ }
466
+ if (e.eventType === "service" && e.service) {
467
+ const n = e.service, a = [];
468
+ return n.serviceName && a.push(["bell", n.serviceName]), n.providerName && a.push(["user", n.providerName]), n.customerName && a.push(["arrow-right", n.customerName]), typeof n.price == "number" && a.push(["dollar", `${n.price}${n.currency ? " " + n.currency : ""}`]), a.length === 0 ? null : /* @__PURE__ */ t(je, { parts: a });
469
+ }
470
+ return null;
471
+ }, Rt = ({ ev: e, categories: n, onEventClick: a }) => {
472
+ const l = ut({ onClick: () => a?.(e) });
473
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__agenda-item", "aria-label": `Event ${e.title}`, ...l, children: [
474
+ /* @__PURE__ */ t(
475
+ "div",
476
+ {
477
+ className: "nice-scheduler__agenda-dot",
478
+ style: {
479
+ backgroundColor: ie(e, n) || e.color || "var(--nice-color-primary, #3b82f6)"
480
+ }
481
+ }
482
+ ),
483
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__agenda-info", children: [
484
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__agenda-title", children: e.title }),
485
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__agenda-time", children: [
486
+ new Date(e.start).toLocaleString(),
487
+ " – ",
488
+ new Date(e.end).toLocaleString()
489
+ ] }),
490
+ e.description && /* @__PURE__ */ t("div", { className: "nice-scheduler__agenda-desc", children: e.description }),
491
+ /* @__PURE__ */ t(Ge, { ev: e })
492
+ ] }),
493
+ e.category && n && /* @__PURE__ */ t(
494
+ "span",
495
+ {
496
+ className: "nice-scheduler__agenda-badge",
497
+ style: { backgroundColor: ie(e, n) || e.color },
498
+ children: n.find((i) => i.key === e.category)?.label
499
+ }
500
+ )
501
+ ] });
502
+ }, It = ({
503
+ events: e,
504
+ curDate: n,
505
+ timelineDays: a,
506
+ resources: l,
507
+ draggable: i,
508
+ dragRef: u,
509
+ onEventClick: D,
510
+ onSlotClick: w,
511
+ onEventDrop: C,
512
+ categories: I,
513
+ renderEvent: k,
514
+ onHoverEvent: h,
515
+ readOnly: M,
516
+ t: r
517
+ }) => {
518
+ const N = Array.from({ length: a }, (d, E) => P(n, E)), b = l ?? [{ id: "__default", name: "" }], o = he(r);
519
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__timeline", children: [
520
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__timeline-header", children: [
521
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timeline-res-label" }),
522
+ N.map((d, E) => /* @__PURE__ */ g(
523
+ "div",
524
+ {
525
+ className: `nice-scheduler__timeline-day ${j(d, /* @__PURE__ */ new Date()) ? "nice-scheduler__timeline-day--today" : ""}`,
526
+ children: [
527
+ o[d.getDay()],
528
+ " ",
529
+ d.getDate()
530
+ ]
531
+ },
532
+ E
533
+ ))
534
+ ] }),
535
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timeline-body", children: b.map((d) => {
536
+ const E = e.filter((y) => !l || y.resourceId === d.id);
537
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__timeline-row", children: [
538
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timeline-res-label", children: d.name }),
539
+ N.map((y, F) => {
540
+ const m = E.filter((f) => j(new Date(f.start), y));
541
+ return /* @__PURE__ */ t(
542
+ "div",
543
+ {
544
+ className: "nice-scheduler__timeline-cell",
545
+ onDragOver: i && !M ? (f) => f.preventDefault() : void 0,
546
+ onDrop: i && !M ? () => {
547
+ if (!u.current || !C)
548
+ return;
549
+ const f = u.current.event, L = new Date(f.end).getTime() - new Date(f.start).getTime(), p = new Date(y);
550
+ p.setHours(
551
+ new Date(f.start).getHours(),
552
+ new Date(f.start).getMinutes()
553
+ ), C(f, p, new Date(p.getTime() + L), d.id), u.current = null;
554
+ } : void 0,
555
+ onClick: () => !M && w?.(y, P(y, 1), d.id),
556
+ children: m.map((f) => /* @__PURE__ */ t(
557
+ ge,
558
+ {
559
+ ev: f,
560
+ renderEvent: k,
561
+ onClick: D,
562
+ draggable: i && !M,
563
+ dragRef: u,
564
+ onHover: h,
565
+ categoryColor: ie(f, I)
566
+ },
567
+ f.id
568
+ ))
569
+ },
570
+ F
571
+ );
572
+ })
573
+ ] }, d.id);
574
+ }) })
575
+ ] });
576
+ }, Ke = ({ categories: e, events: n, filteredCategories: a, onToggleCategory: l, t: i }) => /* @__PURE__ */ g("div", { className: "nice-scheduler__legend", children: [
577
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__legend-title", children: i("legend", "Legend") }),
578
+ e.map((u) => {
579
+ const D = n.filter((C) => C.category === u.key).length, w = !a.has(u.key);
580
+ return /* @__PURE__ */ g(
581
+ "button",
582
+ {
583
+ className: `nice-scheduler__legend-item ${w ? "" : "nice-scheduler__legend-item--hidden"}`,
584
+ onClick: () => l(u.key),
585
+ children: [
586
+ /* @__PURE__ */ t(
587
+ "span",
588
+ {
589
+ className: "nice-scheduler__legend-dot",
590
+ style: { backgroundColor: w ? u.color : "var(--nice-border-color, #ccc)" }
591
+ }
592
+ ),
593
+ /* @__PURE__ */ t("span", { className: "nice-scheduler__legend-label", children: u.label }),
594
+ /* @__PURE__ */ t("span", { className: "nice-scheduler__legend-count", children: D })
595
+ ]
596
+ },
597
+ u.key
598
+ );
599
+ })
600
+ ] }), Ft = ({ curDate: e, onDateSelect: n, firstDayOfWeek: a, t: l }) => {
601
+ const [i, u] = z.useState(e.getMonth()), [D, w] = z.useState(e.getFullYear()), C = new Date(D, i, 1), I = new Date(D, i + 1, 0), k = (C.getDay() - a + 7) % 7, h = [];
602
+ for (let d = k - 1; d >= 0; d--)
603
+ h.push(P(C, -d - 1));
604
+ for (let d = 0; d < I.getDate(); d++)
605
+ h.push(new Date(D, i, d + 1));
606
+ const M = 7 - h.length % 7;
607
+ if (M < 7)
608
+ for (let d = 1; d <= M; d++)
609
+ h.push(new Date(D, i + 1, d));
610
+ const r = () => {
611
+ i === 0 ? (u(11), w((d) => d - 1)) : u((d) => d - 1);
612
+ }, N = () => {
613
+ i === 11 ? (u(0), w((d) => d + 1)) : u((d) => d + 1);
614
+ }, b = Ue(l), o = he(l);
615
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__mini-cal", children: [
616
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__mini-cal-header", children: [
617
+ /* @__PURE__ */ t(
618
+ "button",
619
+ {
620
+ type: "button",
621
+ className: "nice-btn nice-btn--xs",
622
+ onClick: r,
623
+ "aria-label": l("scheduler.prevMonth", "Previous month"),
624
+ children: /* @__PURE__ */ t($e, { name: "chevron-left", size: "sm" })
625
+ }
626
+ ),
627
+ /* @__PURE__ */ g("span", { children: [
628
+ b[i],
629
+ " ",
630
+ D
631
+ ] }),
632
+ /* @__PURE__ */ t(
633
+ "button",
634
+ {
635
+ type: "button",
636
+ className: "nice-btn nice-btn--xs",
637
+ onClick: N,
638
+ "aria-label": l("scheduler.nextMonth", "Next month"),
639
+ children: /* @__PURE__ */ t($e, { name: "chevron-right", size: "sm" })
640
+ }
641
+ )
642
+ ] }),
643
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__mini-cal-grid", children: [
644
+ o.map((d, E) => /* @__PURE__ */ t("div", { className: "nice-scheduler__mini-cal-dayname", children: o[(a + E) % 7].charAt(0) }, E)),
645
+ h.map((d, E) => {
646
+ const y = j(d, /* @__PURE__ */ new Date()), F = j(d, e), m = d.getMonth() !== i;
647
+ return /* @__PURE__ */ t(
648
+ "button",
649
+ {
650
+ className: `nice-scheduler__mini-cal-day ${y ? "nice-scheduler__mini-cal-day--today" : ""} ${F ? "nice-scheduler__mini-cal-day--selected" : ""} ${m ? "nice-scheduler__mini-cal-day--other" : ""}`,
651
+ onClick: () => n(d),
652
+ children: d.getDate()
653
+ },
654
+ E
655
+ );
656
+ })
657
+ ] })
658
+ ] });
659
+ }, At = ({
660
+ events: e,
661
+ rangeStart: n,
662
+ rangeEnd: a,
663
+ startHour: l,
664
+ endHour: i,
665
+ draggable: u,
666
+ dragRef: D,
667
+ onEventClick: w,
668
+ onSlotClick: C,
669
+ onEventDrop: I,
670
+ categories: k,
671
+ workHours: h,
672
+ showCurrentTime: M,
673
+ renderEvent: r,
674
+ onHoverEvent: N,
675
+ readOnly: b,
676
+ t: o
677
+ }) => {
678
+ const d = [];
679
+ let E = new Date(n);
680
+ for (; E <= a; )
681
+ d.push(new Date(E)), E = P(E, 1);
682
+ const y = [];
683
+ for (let v = l; v < i; v++)
684
+ y.push(v);
685
+ const F = xe(o), m = z.useRef(null), f = z.useRef(null), L = z.useRef(null), p = /* @__PURE__ */ new Date(), S = p.getHours() * 60 + p.getMinutes(), A = (i - l) * 60, Y = (S - l * 60) / A * 100, H = M && S >= l * 60 && S < i * 60;
686
+ z.useEffect(() => {
687
+ const v = m.current;
688
+ if (!v)
689
+ return;
690
+ const x = /* @__PURE__ */ new Date(), q = e.filter(
691
+ (R) => d.some((T) => j(T, x) && j(new Date(R.start), x))
692
+ );
693
+ let K = q.length > 0 ? Math.min(...q.map((R) => new Date(R.start).getHours())) : x.getHours();
694
+ K = Math.max(l, Math.min(K, i - 1));
695
+ const G = v.children[K - l];
696
+ if (G) {
697
+ const R = L.current ?? v.closest(".nice-scheduler__content") ?? v.closest(".nice-scheduler__timegrid");
698
+ R && (R.scrollTop = G.offsetTop - 4);
699
+ }
700
+ }, []);
701
+ const s = (v) => {
702
+ f.current && (f.current.scrollLeft = v.currentTarget.scrollLeft);
703
+ };
704
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__timegrid nice-scheduler__timegrid--range", children: [
705
+ /* @__PURE__ */ t(
706
+ "div",
707
+ {
708
+ className: "nice-scheduler__timegrid-header-scroll",
709
+ ref: f,
710
+ "aria-hidden": "true",
711
+ children: /* @__PURE__ */ g("div", { className: "nice-scheduler__timegrid-header", children: [
712
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__time-gutter" }),
713
+ d.map((v, x) => {
714
+ const q = v.getDay() === 0 || v.getDay() === 6;
715
+ return /* @__PURE__ */ g(
716
+ "div",
717
+ {
718
+ className: `nice-scheduler__timegrid-day-header ${j(v, p) ? "nice-scheduler__timegrid-day-header--today" : ""} ${q ? "nice-scheduler__timegrid-day-header--weekend" : ""}`,
719
+ children: [
720
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timegrid-day-name", children: F[v.getDay()] }),
721
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__timegrid-day-num", children: v.getDate() })
722
+ ]
723
+ },
724
+ x
725
+ );
726
+ })
727
+ ] })
728
+ }
729
+ ),
730
+ /* @__PURE__ */ t(
731
+ "div",
732
+ {
733
+ className: "nice-scheduler__timegrid-body-scroll",
734
+ ref: L,
735
+ onScroll: s,
736
+ children: /* @__PURE__ */ g(
737
+ "div",
738
+ {
739
+ className: "nice-scheduler__timegrid-body",
740
+ ref: m,
741
+ style: { position: "relative" },
742
+ children: [
743
+ y.map((v) => {
744
+ const x = h ? v >= h[0] && v < h[1] : !1;
745
+ return /* @__PURE__ */ g(
746
+ "div",
747
+ {
748
+ className: `nice-scheduler__timegrid-row ${x ? "nice-scheduler__timegrid-row--work" : ""}`,
749
+ children: [
750
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__time-gutter", children: `${v.toString().padStart(2, "0")}:00` }),
751
+ d.map((q, K) => {
752
+ const G = e.filter((R) => {
753
+ const T = new Date(R.start);
754
+ return j(T, q) && T.getHours() === v;
755
+ });
756
+ return /* @__PURE__ */ t(
757
+ "div",
758
+ {
759
+ className: "nice-scheduler__timegrid-cell",
760
+ onDragOver: u && !b ? (R) => R.preventDefault() : void 0,
761
+ onDrop: u && !b ? () => {
762
+ if (!D.current || !I)
763
+ return;
764
+ const R = D.current.event, T = new Date(R.end).getTime() - new Date(R.start).getTime(), Q = new Date(q);
765
+ Q.setHours(v, 0, 0, 0), I(R, Q, new Date(Q.getTime() + T)), D.current = null;
766
+ } : void 0,
767
+ onClick: () => !b && (() => {
768
+ const R = new Date(q);
769
+ R.setHours(v);
770
+ const T = new Date(R);
771
+ T.setHours(v + 1), C?.(R, T);
772
+ })(),
773
+ children: G.map((R) => /* @__PURE__ */ t(
774
+ ge,
775
+ {
776
+ ev: R,
777
+ renderEvent: r,
778
+ onClick: w,
779
+ draggable: u && !b,
780
+ dragRef: D,
781
+ onHover: N,
782
+ categoryColor: ie(R, k)
783
+ },
784
+ R.id
785
+ ))
786
+ },
787
+ K
788
+ );
789
+ })
790
+ ]
791
+ },
792
+ v
793
+ );
794
+ }),
795
+ H && d.some((v) => j(v, p)) && /* @__PURE__ */ t("div", { className: "nice-scheduler__now-line", style: { top: `${Y}%` }, children: /* @__PURE__ */ t("div", { className: "nice-scheduler__now-dot" }) })
796
+ ]
797
+ }
798
+ )
799
+ }
800
+ )
801
+ ] });
802
+ }, Pt = ({
803
+ events: e,
804
+ rangeStart: n,
805
+ rangeEnd: a,
806
+ firstDayOfWeek: l,
807
+ onSlotClick: i,
808
+ onEventClick: u,
809
+ draggable: D,
810
+ dragRef: w,
811
+ categories: C,
812
+ renderEvent: I,
813
+ onHoverEvent: k,
814
+ readOnly: h,
815
+ t: M
816
+ }) => {
817
+ const r = he(M);
818
+ xe(M);
819
+ const N = [];
820
+ let b = new Date(n);
821
+ for (; b <= a; )
822
+ N.push(new Date(b)), b = P(b, 1);
823
+ const o = (N[0].getDay() - l + 7) % 7, d = [];
824
+ for (let y = o - 1; y >= 0; y--)
825
+ d.push({ date: P(N[0], -y - 1), inRange: !1 });
826
+ N.forEach((y) => d.push({ date: y, inRange: !0 }));
827
+ const E = 7 - d.length % 7;
828
+ if (E < 7) {
829
+ const y = N[N.length - 1];
830
+ for (let F = 1; F <= E; F++)
831
+ d.push({ date: P(y, F), inRange: !1 });
832
+ }
833
+ return /* @__PURE__ */ g("div", { className: "nice-scheduler__month nice-scheduler__month--range", children: [
834
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__month-header", children: Array.from({ length: 7 }, (y, F) => /* @__PURE__ */ t("div", { className: "nice-scheduler__month-dayname", children: r[(l + F) % 7] }, F)) }),
835
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__month-grid", children: d.map((y, F) => {
836
+ const m = Je(e, y.date), f = j(y.date, /* @__PURE__ */ new Date()), L = y.date.getDay() === 0 || y.date.getDay() === 6;
837
+ return /* @__PURE__ */ g(
838
+ "div",
839
+ {
840
+ className: `nice-scheduler__month-cell ${y.inRange ? "" : "nice-scheduler__month-cell--other"} ${f ? "nice-scheduler__month-cell--today" : ""} ${L ? "nice-scheduler__month-cell--weekend" : ""}`,
841
+ onClick: () => !h && i?.(y.date, P(y.date, 1)),
842
+ children: [
843
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__month-date", children: y.date.getDate() === 1 || F === 0 ? /* @__PURE__ */ g(Be, { children: [
844
+ /* @__PURE__ */ t("span", { className: "nice-scheduler__month-monthname", children: Ue(M)[y.date.getMonth()] }),
845
+ " ",
846
+ y.date.getDate()
847
+ ] }) : y.date.getDate() }),
848
+ m.slice(0, 3).map((p) => /* @__PURE__ */ t(
849
+ ge,
850
+ {
851
+ ev: p,
852
+ renderEvent: I,
853
+ onClick: u,
854
+ draggable: D && !h,
855
+ dragRef: w,
856
+ onHover: k,
857
+ categoryColor: ie(p, C)
858
+ },
859
+ p.id
860
+ )),
861
+ m.length > 3 && /* @__PURE__ */ g("div", { className: "nice-scheduler__month-more", children: [
862
+ "+",
863
+ m.length - 3
864
+ ] })
865
+ ]
866
+ },
867
+ F
868
+ );
869
+ }) })
870
+ ] });
871
+ }, Yt = ({ event: e, rect: n, categories: a, renderTooltip: l }) => {
872
+ if (l)
873
+ return /* @__PURE__ */ t(
874
+ "div",
875
+ {
876
+ className: "nice-scheduler__tooltip",
877
+ style: { position: "fixed", left: n.right + 8, top: n.top, zIndex: 1e4 },
878
+ children: l(e)
879
+ }
880
+ );
881
+ const i = a?.find((u) => u.key === e.category);
882
+ return /* @__PURE__ */ g(
883
+ "div",
884
+ {
885
+ className: "nice-scheduler__tooltip",
886
+ style: { position: "fixed", left: n.right + 8, top: n.top, zIndex: 1e4 },
887
+ children: [
888
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__tooltip-title", children: e.title }),
889
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__tooltip-time", children: [
890
+ new Date(e.start).toLocaleString(),
891
+ " – ",
892
+ new Date(e.end).toLocaleString()
893
+ ] }),
894
+ i && /* @__PURE__ */ g("div", { className: "nice-scheduler__tooltip-cat", children: [
895
+ /* @__PURE__ */ t("span", { className: "nice-scheduler__tooltip-dot", style: { backgroundColor: i.color } }),
896
+ i.label
897
+ ] }),
898
+ e.description && /* @__PURE__ */ t("div", { className: "nice-scheduler__tooltip-desc", children: e.description }),
899
+ /* @__PURE__ */ t(Ge, { ev: e })
900
+ ]
901
+ }
902
+ );
903
+ }, Wt = ({
904
+ event: e,
905
+ slotStart: n,
906
+ slotEnd: a,
907
+ categories: l,
908
+ resources: i,
909
+ formFields: u,
910
+ formFieldsByType: D,
911
+ eventTypes: w,
912
+ renderEditor: C,
913
+ saving: I,
914
+ onSave: k,
915
+ onDelete: h,
916
+ onClose: M,
917
+ t: r
918
+ }) => {
919
+ const N = !!e, b = z.useMemo(
920
+ () => ({
921
+ title: e?.title ?? "",
922
+ description: e?.description ?? "",
923
+ color: e?.color ?? "var(--nice-primary, #3b82f6)",
924
+ category: e?.category ?? "",
925
+ eventStyle: e?.eventStyle ?? "solid",
926
+ start: e?.start ?? n ?? /* @__PURE__ */ new Date(),
927
+ end: e?.end ?? a ?? /* @__PURE__ */ new Date(),
928
+ allDay: e?.allDay ?? !1,
929
+ resourceId: e?.resourceId ?? "",
930
+ eventType: e?.eventType ?? "task",
931
+ recurring: !!e?.recurrence,
932
+ recurrenceFreq: e?.recurrence?.freq ?? "weekly",
933
+ recurrenceInterval: e?.recurrence?.interval ?? 1,
934
+ recurrenceCount: e?.recurrence?.count,
935
+ // Recipe-specific
936
+ recipeTitle: e?.recipe?.title ?? "",
937
+ recipeServings: e?.recipe?.servings ?? 2,
938
+ recipePrep: e?.recipe?.prepMinutes,
939
+ recipeCook: e?.recipe?.cookMinutes,
940
+ recipeIngredients: (e?.recipe?.ingredients ?? []).map(
941
+ (m) => [m.quantity, m.unit, m.name].filter((f) => f !== void 0 && f !== "").join(" ")
942
+ ).join(`
943
+ `),
944
+ recipeSteps: (e?.recipe?.steps ?? []).map((m) => m.instruction).join(`
945
+ `),
946
+ // Service-specific
947
+ serviceName: e?.service?.serviceName ?? "",
948
+ serviceProvider: e?.service?.providerName ?? "",
949
+ serviceCustomer: e?.service?.customerName ?? "",
950
+ serviceContact: e?.service?.customerContact ?? "",
951
+ serviceLocation: e?.service?.location ?? "",
952
+ servicePrice: e?.service?.price,
953
+ serviceCurrency: e?.service?.currency ?? "PLN",
954
+ serviceNotes: e?.service?.notes ?? ""
955
+ }),
956
+ [e, n, a]
957
+ ), [o, d] = z.useState(b);
958
+ z.useEffect(() => {
959
+ d(b);
960
+ }, [b]);
961
+ const E = z.useCallback((m, f) => {
962
+ d((L) => ({ ...L, [m]: f }));
963
+ }, []), y = z.useMemo(() => {
964
+ if (u && u.length > 0)
965
+ return u;
966
+ const m = (s) => s.toString().padStart(2, "0"), f = (s) => `${s.getFullYear()}-${m(s.getMonth() + 1)}-${m(s.getDate())}`, L = (s) => `${m(s.getHours())}:${m(s.getMinutes())}`, p = (s, v) => {
967
+ const x = s instanceof Date ? s : new Date(s), q = isNaN(x.getTime()) ? /* @__PURE__ */ new Date() : x, K = f(q), G = L(q), R = (T, Q) => {
968
+ const [X, U, pe] = T.split("-").map((ce) => parseInt(ce, 10)), [ye, fe] = Q.split(":").map((ce) => parseInt(ce, 10)), le = new Date(q);
969
+ !isNaN(X) && !isNaN(U) && !isNaN(pe) && le.setFullYear(X, U - 1, pe), !isNaN(ye) && !isNaN(fe) && le.setHours(ye, fe, 0, 0), v(le);
970
+ };
971
+ return /* @__PURE__ */ g("div", { style: { display: "flex", gap: 12, flexWrap: "wrap", alignItems: "flex-end" }, children: [
972
+ /* @__PURE__ */ g("div", { style: { display: "flex", flexDirection: "column", gap: 2 }, children: [
973
+ /* @__PURE__ */ t("span", { style: { fontSize: "0.7rem", color: "var(--nice-text-muted, #888)" }, children: r("date", "Date") }),
974
+ /* @__PURE__ */ t(ze, { value: K, onChange: (T) => R(T, G), size: "sm" })
975
+ ] }),
976
+ /* @__PURE__ */ g("div", { style: { display: "flex", flexDirection: "column", gap: 2 }, children: [
977
+ /* @__PURE__ */ t("span", { style: { fontSize: "0.7rem", color: "var(--nice-text-muted, #888)" }, children: r("time", "Time") }),
978
+ /* @__PURE__ */ t(
979
+ ze,
980
+ {
981
+ dateFormatPreset: "time",
982
+ value: G,
983
+ onChange: (T) => R(K, T),
984
+ size: "sm"
985
+ }
986
+ )
987
+ ] })
988
+ ] });
989
+ }, S = [];
990
+ w && w.length > 1 && S.push({
991
+ field: "eventType",
992
+ label: r("eventType", "Type"),
993
+ type: "select",
994
+ group: r("common", "Common"),
995
+ options: w.map((s) => ({
996
+ label: s.icon ? `${s.icon} ${s.label}` : s.label,
997
+ value: s.type
998
+ }))
999
+ }), S.push(
1000
+ {
1001
+ field: "title",
1002
+ label: r("title", "Title"),
1003
+ type: "text",
1004
+ required: !0,
1005
+ group: r("common", "Common")
1006
+ },
1007
+ {
1008
+ field: "start",
1009
+ label: r("start", "Start"),
1010
+ render: p,
1011
+ group: r("common", "Common")
1012
+ },
1013
+ {
1014
+ field: "end",
1015
+ label: r("end", "End"),
1016
+ render: p,
1017
+ group: r("common", "Common")
1018
+ },
1019
+ {
1020
+ field: "description",
1021
+ label: r("description", "Description"),
1022
+ type: "textarea",
1023
+ group: r("common", "Common")
1024
+ },
1025
+ {
1026
+ field: "color",
1027
+ label: r("color", "Color"),
1028
+ group: r("common", "Common"),
1029
+ render: (s, v) => /* @__PURE__ */ t(
1030
+ yt,
1031
+ {
1032
+ value: typeof s == "string" ? s : "var(--nice-primary, #3b82f6)",
1033
+ onChange: v,
1034
+ showInput: !1,
1035
+ showRandom: !1
1036
+ }
1037
+ )
1038
+ }
1039
+ ), l && l.length > 0 && S.push({
1040
+ field: "category",
1041
+ label: r("category", "Category"),
1042
+ type: "select",
1043
+ group: r("common", "Common"),
1044
+ options: [
1045
+ { label: r("none", "(none)"), value: "" },
1046
+ ...l.map((s) => ({ label: s.label, value: s.key }))
1047
+ ]
1048
+ }), i && i.length > 0 && S.push({
1049
+ field: "resourceId",
1050
+ label: r("resource", "Resource"),
1051
+ type: "select",
1052
+ group: r("common", "Common"),
1053
+ options: [
1054
+ { label: r("none", "(none)"), value: "" },
1055
+ ...i.map((s) => ({ label: s.name, value: String(s.id) }))
1056
+ ]
1057
+ });
1058
+ const A = r("recurring", "Recurring");
1059
+ S.push({
1060
+ field: "recurring",
1061
+ label: r("repeat", "Repeat"),
1062
+ type: "checkbox",
1063
+ group: A
1064
+ }), S.push({
1065
+ field: "recurrenceFreq",
1066
+ label: r("frequency", "Frequency"),
1067
+ type: "select",
1068
+ group: A,
1069
+ visibleWhen: (s) => !!s.recurring,
1070
+ options: [
1071
+ { label: r("daily", "Daily"), value: "daily" },
1072
+ { label: r("weekly", "Weekly"), value: "weekly" },
1073
+ { label: r("monthly", "Monthly"), value: "monthly" },
1074
+ { label: r("yearly", "Yearly"), value: "yearly" }
1075
+ ]
1076
+ }), S.push({
1077
+ field: "recurrenceInterval",
1078
+ label: r("interval", "Interval"),
1079
+ type: "number",
1080
+ group: A,
1081
+ visibleWhen: (s) => !!s.recurring
1082
+ }), S.push({
1083
+ field: "recurrenceCount",
1084
+ label: r("occurrences", "Occurrences (optional)"),
1085
+ type: "number",
1086
+ group: A,
1087
+ visibleWhen: (s) => !!s.recurring
1088
+ });
1089
+ const Y = o.eventType ?? "task", H = D?.[Y];
1090
+ if (H && H.length > 0)
1091
+ S.push(...H);
1092
+ else if (Y === "recipe") {
1093
+ const s = r("recipe.section", "Recipe");
1094
+ S.push(
1095
+ { field: "recipeTitle", label: r("recipe.title", "Recipe title"), type: "text", group: s },
1096
+ {
1097
+ field: "recipeServings",
1098
+ label: r("recipe.servings", "Servings"),
1099
+ type: "number",
1100
+ group: s
1101
+ },
1102
+ {
1103
+ field: "recipePrep",
1104
+ label: r("recipe.prepMinutes", "Prep (min)"),
1105
+ type: "number",
1106
+ group: s
1107
+ },
1108
+ {
1109
+ field: "recipeCook",
1110
+ label: r("recipe.cookMinutes", "Cook (min)"),
1111
+ type: "number",
1112
+ group: s
1113
+ },
1114
+ {
1115
+ field: "recipeIngredients",
1116
+ label: r("recipe.ingredients", "Ingredients (one per line)"),
1117
+ type: "textarea",
1118
+ group: s,
1119
+ hint: r("recipe.ingredients.hint", 'Format: "200 g flour"')
1120
+ },
1121
+ {
1122
+ field: "recipeSteps",
1123
+ label: r("recipe.steps", "Steps (one per line)"),
1124
+ type: "textarea",
1125
+ group: s
1126
+ }
1127
+ );
1128
+ } else if (Y === "service") {
1129
+ const s = r("service.section", "Service");
1130
+ S.push(
1131
+ {
1132
+ field: "serviceName",
1133
+ label: r("service.name", "Service name"),
1134
+ type: "text",
1135
+ group: s,
1136
+ required: !0
1137
+ },
1138
+ {
1139
+ field: "serviceProvider",
1140
+ label: r("service.provider", "Provider"),
1141
+ type: "text",
1142
+ group: s
1143
+ },
1144
+ {
1145
+ field: "serviceCustomer",
1146
+ label: r("service.customer", "Customer"),
1147
+ type: "text",
1148
+ group: s
1149
+ },
1150
+ { field: "serviceContact", label: r("service.contact", "Contact"), type: "text", group: s },
1151
+ {
1152
+ field: "serviceLocation",
1153
+ label: r("service.location", "Location"),
1154
+ type: "text",
1155
+ group: s
1156
+ },
1157
+ {
1158
+ field: "servicePrice",
1159
+ label: r("service.price", "Price"),
1160
+ type: "number",
1161
+ group: s
1162
+ },
1163
+ {
1164
+ field: "serviceCurrency",
1165
+ label: r("service.currency", "Currency"),
1166
+ type: "text",
1167
+ group: s
1168
+ },
1169
+ { field: "serviceNotes", label: r("service.notes", "Notes"), type: "textarea", group: s }
1170
+ );
1171
+ }
1172
+ return S;
1173
+ }, [u, D, w, l, i, o.eventType, r]), F = () => {
1174
+ const m = o.eventType ?? "task", f = {
1175
+ title: o.title,
1176
+ description: o.description || void 0,
1177
+ color: o.color,
1178
+ category: o.category || void 0,
1179
+ eventStyle: o.eventStyle,
1180
+ allDay: o.allDay,
1181
+ start: o.start instanceof Date ? o.start : new Date(o.start),
1182
+ end: o.end instanceof Date ? o.end : new Date(o.end),
1183
+ resourceId: o.resourceId || void 0,
1184
+ eventType: m
1185
+ };
1186
+ if (o.recurring) {
1187
+ const L = {
1188
+ freq: o.recurrenceFreq || "weekly",
1189
+ interval: typeof o.recurrenceInterval == "number" && o.recurrenceInterval > 0 ? o.recurrenceInterval : 1
1190
+ };
1191
+ typeof o.recurrenceCount == "number" && o.recurrenceCount > 0 && (L.count = o.recurrenceCount), f.recurrence = L;
1192
+ } else
1193
+ f.recurrence = void 0;
1194
+ if (m === "recipe") {
1195
+ const L = String(o.recipeIngredients || "").split(`
1196
+ `).map((Y) => Y.trim()).filter(Boolean).map((Y, H) => {
1197
+ const s = Y.match(/^([\d.,/]+)\s*(\S+)?\s+(.+)$/);
1198
+ if (s) {
1199
+ const v = parseFloat(s[1].replace(",", "."));
1200
+ return {
1201
+ id: `ing-${H}`,
1202
+ name: s[3],
1203
+ quantity: isNaN(v) ? void 0 : v,
1204
+ unit: s[2]
1205
+ };
1206
+ }
1207
+ return { id: `ing-${H}`, name: Y };
1208
+ }), p = String(o.recipeSteps || "").split(`
1209
+ `).map((Y) => Y.trim()).filter(Boolean).map((Y, H) => ({
1210
+ id: `step-${H}`,
1211
+ order: H + 1,
1212
+ instruction: Y
1213
+ })), S = e?.recipe ?? Tt(), A = {
1214
+ ...S,
1215
+ title: o.recipeTitle || o.title || S.title,
1216
+ servings: typeof o.recipeServings == "number" ? o.recipeServings : S.servings,
1217
+ prepMinutes: typeof o.recipePrep == "number" ? o.recipePrep : S.prepMinutes,
1218
+ cookMinutes: typeof o.recipeCook == "number" ? o.recipeCook : S.cookMinutes,
1219
+ ingredients: L,
1220
+ steps: p
1221
+ };
1222
+ f.recipe = A, f.service = void 0;
1223
+ } else if (m === "service") {
1224
+ const L = {
1225
+ serviceName: String(o.serviceName || ""),
1226
+ providerName: o.serviceProvider || void 0,
1227
+ customerName: o.serviceCustomer || void 0,
1228
+ customerContact: o.serviceContact || void 0,
1229
+ location: o.serviceLocation || void 0,
1230
+ price: typeof o.servicePrice == "number" ? o.servicePrice : void 0,
1231
+ currency: o.serviceCurrency || void 0,
1232
+ notes: o.serviceNotes || void 0
1233
+ };
1234
+ f.service = L, f.recipe = void 0;
1235
+ } else
1236
+ f.recipe = void 0, f.service = void 0;
1237
+ return N && (f.id = e.id), f;
1238
+ };
1239
+ return /* @__PURE__ */ t(
1240
+ ft,
1241
+ {
1242
+ open: !0,
1243
+ onClose: M,
1244
+ title: N ? r("editEvent", "Edit Event") : r("newEvent", "New Event"),
1245
+ size: "md",
1246
+ footer: C ? null : /* @__PURE__ */ g(Be, { children: [
1247
+ N && h && /* @__PURE__ */ t(
1248
+ re,
1249
+ {
1250
+ type: "button",
1251
+ variant: "error",
1252
+ size: "sm",
1253
+ onClick: () => {
1254
+ h(e), M();
1255
+ },
1256
+ disabled: I,
1257
+ children: r("delete", "Delete")
1258
+ }
1259
+ ),
1260
+ /* @__PURE__ */ t("div", { style: { flex: 1 } }),
1261
+ /* @__PURE__ */ t(
1262
+ re,
1263
+ {
1264
+ type: "button",
1265
+ variant: "secondary",
1266
+ size: "sm",
1267
+ onClick: M,
1268
+ disabled: I,
1269
+ children: r("cancel", "Cancel")
1270
+ }
1271
+ ),
1272
+ /* @__PURE__ */ t(
1273
+ re,
1274
+ {
1275
+ type: "button",
1276
+ variant: "primary",
1277
+ size: "sm",
1278
+ onClick: () => {
1279
+ o.title && k(F());
1280
+ },
1281
+ disabled: I || !o.title,
1282
+ children: I ? r("saving", "Saving…") : r("save", "Save")
1283
+ }
1284
+ )
1285
+ ] }),
1286
+ children: /* @__PURE__ */ t(
1287
+ "div",
1288
+ {
1289
+ className: "nice-scheduler__form-body",
1290
+ onKeyDown: (m) => {
1291
+ m.key === "Enter" && m.target.tagName !== "TEXTAREA" && (m.preventDefault(), o.title && k(F()));
1292
+ },
1293
+ children: C ? C({
1294
+ event: e,
1295
+ slotStart: n,
1296
+ slotEnd: a,
1297
+ save: k,
1298
+ cancel: M,
1299
+ remove: h
1300
+ }) : /* @__PURE__ */ t(
1301
+ pt,
1302
+ {
1303
+ items: y,
1304
+ data: o,
1305
+ onFieldChange: E,
1306
+ columns: 1,
1307
+ gap: 12,
1308
+ size: "sm"
1309
+ }
1310
+ )
1311
+ }
1312
+ )
1313
+ }
1314
+ );
1315
+ }, Ht = [
1316
+ "day",
1317
+ "workWeek",
1318
+ "week",
1319
+ "dayRange",
1320
+ "month",
1321
+ "monthRange",
1322
+ "timeline",
1323
+ "agenda"
1324
+ ], Oe = ({
1325
+ events: e,
1326
+ defaultEvents: n,
1327
+ resources: a,
1328
+ currentDate: l,
1329
+ view: i,
1330
+ onDateChange: u,
1331
+ onViewChange: D,
1332
+ onEventClick: w,
1333
+ onSlotClick: C,
1334
+ onEventDrop: I,
1335
+ draggable: k = !1,
1336
+ timelineDays: h = 7,
1337
+ startHour: M = 0,
1338
+ endHour: r = 24,
1339
+ firstDayOfWeek: N = 1,
1340
+ categories: b,
1341
+ showLegend: o,
1342
+ showTooltip: d,
1343
+ renderEvent: E,
1344
+ renderTooltip: y,
1345
+ workHours: F,
1346
+ showCurrentTime: m = !0,
1347
+ showMiniCalendar: f,
1348
+ onEventCreate: L,
1349
+ onEventEdit: p,
1350
+ onEventDelete: S,
1351
+ editable: A = !0,
1352
+ formFields: Y,
1353
+ formFieldsByType: H,
1354
+ eventTypes: s,
1355
+ renderEventEditor: v,
1356
+ loadEvents: x,
1357
+ onEventsChange: q,
1358
+ accessMode: K = "full",
1359
+ className: G,
1360
+ style: R
1361
+ }) => {
1362
+ const { t: T } = mt(), Q = K === "hidden", X = K === "readOnly" || K === "disabled", U = K === "disabled", [pe, ye] = B(l ?? /* @__PURE__ */ new Date()), [fe, le] = B(i ?? "week"), ce = l !== void 0 && u !== void 0, Ee = i !== void 0 && D !== void 0, W = ce ? l : pe, $ = Ee ? i : fe;
1363
+ Te(
1364
+ "NiceScheduler",
1365
+ "currentDate",
1366
+ "onDateChange",
1367
+ l,
1368
+ ce
1369
+ ), Te("NiceScheduler", "view", "onViewChange", i, Ee);
1370
+ const Xe = gt(null), [J, Ne] = B(() => {
1371
+ const c = /* @__PURE__ */ new Date();
1372
+ return c.setHours(0, 0, 0, 0), c;
1373
+ }), [O, be] = B(() => P(/* @__PURE__ */ new Date(), 13)), [Se, Le] = B(
1374
+ null
1375
+ ), Qe = ne(
1376
+ (c, _) => {
1377
+ d && Le(c && _ ? { event: c, rect: _ } : null);
1378
+ },
1379
+ [d]
1380
+ ), [se, de] = B(null), [Ze, ve] = B(!1), Ce = e !== void 0 && q !== void 0, [et, Re] = ht({
1381
+ value: Ce ? e : void 0,
1382
+ defaultValue: n,
1383
+ fallbackValue: [],
1384
+ onChange: q,
1385
+ componentName: "NiceScheduler"
1386
+ }), [Ie, tt] = B(!1), [Fe, nt] = B(null), [qt, Ae] = B(!1), Z = Fe ?? (Ce || Ie || e === void 0 ? et : e);
1387
+ Te(
1388
+ "NiceScheduler",
1389
+ "events",
1390
+ "onEventsChange",
1391
+ e,
1392
+ Ce || !(Ie || Fe !== null),
1393
+ "the built-in editor has taken over the list"
1394
+ );
1395
+ const [ue, rt] = B(/* @__PURE__ */ new Set()), Pe = ne((c) => {
1396
+ rt((_) => {
1397
+ const V = new Set(_);
1398
+ return V.has(c) ? V.delete(c) : V.add(c), V;
1399
+ });
1400
+ }, []), ee = we(() => {
1401
+ if ($ === "month")
1402
+ return {
1403
+ start: new Date(W.getFullYear(), W.getMonth(), 1),
1404
+ end: new Date(W.getFullYear(), W.getMonth() + 2, 0)
1405
+ };
1406
+ if ($ === "timeline")
1407
+ return { start: new Date(W), end: P(W, h) };
1408
+ if ($ === "dayRange" || $ === "monthRange")
1409
+ return { start: new Date(J), end: P(O, 1) };
1410
+ const c = (() => {
1411
+ const _ = new Date(W), V = (_.getDay() - N + 7) % 7;
1412
+ return P(_, -V);
1413
+ })();
1414
+ return { start: P(c, -1), end: P(c, 8) };
1415
+ }, [W, $, N, h, J, O]), ke = we(() => {
1416
+ let c = kt(Z, ee.start, ee.end);
1417
+ return ue.size > 0 && (c = c.filter((_) => !_.category || !ue.has(_.category))), c;
1418
+ }, [Z, ee, ue]), ae = (c) => {
1419
+ ye(c), u?.(c);
1420
+ }, it = (c) => {
1421
+ le(c), D?.(c);
1422
+ }, Ye = (c) => {
1423
+ if ($ === "day")
1424
+ ae(P(W, c));
1425
+ else if ($ === "week" || $ === "workWeek")
1426
+ ae(P(W, c * 7));
1427
+ else if ($ === "timeline")
1428
+ ae(P(W, c * h));
1429
+ else if ($ === "dayRange" || $ === "monthRange") {
1430
+ const _ = Math.round((O.getTime() - J.getTime()) / 864e5) + 1;
1431
+ Ne(P(J, c * _)), be(P(O, c * _));
1432
+ } else {
1433
+ const _ = new Date(W);
1434
+ _.setMonth(_.getMonth() + c), ae(_);
1435
+ }
1436
+ }, Me = we(() => {
1437
+ const c = new Date(W), _ = (c.getDay() - N + 7) % 7;
1438
+ return P(c, -_);
1439
+ }, [W, N]), _e = we(() => {
1440
+ if ($ === "day")
1441
+ return [W];
1442
+ if ($ === "workWeek") {
1443
+ const c = [];
1444
+ for (let _ = 0; _ < 7; _++) {
1445
+ const V = P(Me, _), te = V.getDay();
1446
+ te !== 0 && te !== 6 && c.push(V);
1447
+ }
1448
+ return c;
1449
+ }
1450
+ return Array.from({ length: 7 }, (c, _) => P(Me, _));
1451
+ }, [$, W, Me]), ct = $ === "day" ? W.toLocaleDateString() : $ === "week" || $ === "workWeek" ? `${_e[0].toLocaleDateString()} – ${_e[_e.length - 1].toLocaleDateString()}` : $ === "timeline" ? `${W.toLocaleDateString()} – ${P(W, h - 1).toLocaleDateString()}` : $ === "dayRange" || $ === "monthRange" ? `${J.toLocaleDateString()} – ${O.toLocaleDateString()}` : `${Nt(T)[W.getMonth()]} ${W.getFullYear()}`, st = ne(
1452
+ (c, _, V) => {
1453
+ X || (A && de({ mode: "create", slotStart: c, slotEnd: _ }), C?.(c, _, V));
1454
+ },
1455
+ [A, C, X]
1456
+ ), at = ne(
1457
+ (c) => {
1458
+ A && !X && de({ mode: "edit", event: c }), w?.(c);
1459
+ },
1460
+ [A, w, X]
1461
+ ), me = ne(
1462
+ (c) => {
1463
+ tt(!0), Re(c);
1464
+ },
1465
+ [Re]
1466
+ ), ot = ne(
1467
+ async (c) => {
1468
+ const _ = se?.mode === "create";
1469
+ try {
1470
+ if (ve(!0), _) {
1471
+ const te = (L ? await L(c) : void 0) ?? {
1472
+ ...c,
1473
+ id: typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : `evt_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`
1474
+ }, De = Z.slice();
1475
+ De.push(te), me(De);
1476
+ } else {
1477
+ const te = (p ? await p(c) : void 0) ?? c, De = Z.map((qe) => qe.id === te.id ? te : qe);
1478
+ me(De);
1479
+ }
1480
+ de(null);
1481
+ } finally {
1482
+ ve(!1);
1483
+ }
1484
+ },
1485
+ [se, L, p, Z, me]
1486
+ ), lt = ne(
1487
+ async (c) => {
1488
+ try {
1489
+ ve(!0), S && await S(c);
1490
+ const _ = Z.filter((V) => V.id !== c.id);
1491
+ me(_), de(null);
1492
+ } finally {
1493
+ ve(!1);
1494
+ }
1495
+ },
1496
+ [S, Z, me]
1497
+ );
1498
+ z.useEffect(() => {
1499
+ if (!x)
1500
+ return;
1501
+ let c = !1;
1502
+ return Ae(!0), x({ start: ee.start, end: ee.end }).then((_) => {
1503
+ c || nt(_);
1504
+ }).finally(() => {
1505
+ c || Ae(!1);
1506
+ }), () => {
1507
+ c = !0;
1508
+ };
1509
+ }, [x, ee.start.getTime(), ee.end.getTime()]);
1510
+ const dt = (c) => ({
1511
+ day: T("day", "Day"),
1512
+ week: T("week", "Week"),
1513
+ workWeek: T("workWeek", "Work Week"),
1514
+ month: T("month", "Month"),
1515
+ timeline: T("timeline", "Timeline"),
1516
+ agenda: T("agenda", "Agenda"),
1517
+ dayRange: T("dayRange", "Day Range"),
1518
+ monthRange: T("monthRange", "Month Range")
1519
+ })[c], oe = {
1520
+ events: ke,
1521
+ curDate: W,
1522
+ firstDayOfWeek: N,
1523
+ startHour: M,
1524
+ endHour: r,
1525
+ draggable: k,
1526
+ dragRef: Xe,
1527
+ onEventClick: at,
1528
+ onSlotClick: st,
1529
+ onEventDrop: I,
1530
+ resources: a,
1531
+ timelineDays: h,
1532
+ categories: b,
1533
+ workHours: F,
1534
+ showCurrentTime: m,
1535
+ renderEvent: E,
1536
+ showTooltip: d,
1537
+ renderTooltip: y,
1538
+ onHoverEvent: Qe,
1539
+ readOnly: X,
1540
+ t: T
1541
+ }, We = $ === "dayRange" || $ === "monthRange", He = (c) => {
1542
+ const _ = (V) => V.toString().padStart(2, "0");
1543
+ return `${c.getFullYear()}-${_(c.getMonth() + 1)}-${_(c.getDate())}`;
1544
+ };
1545
+ return Q ? null : /* @__PURE__ */ g(
1546
+ "div",
1547
+ {
1548
+ className: `nice-scheduler ${U ? "nice-scheduler--disabled" : ""} ${G || ""}`,
1549
+ style: R,
1550
+ children: [
1551
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__toolbar", children: [
1552
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__nav", children: [
1553
+ /* @__PURE__ */ g(Ve, { size: "sm", children: [
1554
+ /* @__PURE__ */ t(
1555
+ re,
1556
+ {
1557
+ onClick: () => Ye(-1),
1558
+ disabled: U,
1559
+ "aria-label": T("previous", "Previous"),
1560
+ children: "‹"
1561
+ }
1562
+ ),
1563
+ /* @__PURE__ */ t(
1564
+ re,
1565
+ {
1566
+ onClick: () => {
1567
+ if (We) {
1568
+ const c = /* @__PURE__ */ new Date();
1569
+ c.setHours(0, 0, 0, 0);
1570
+ const _ = Math.round((O.getTime() - J.getTime()) / 864e5);
1571
+ Ne(c), be(P(c, _));
1572
+ } else
1573
+ ae(/* @__PURE__ */ new Date());
1574
+ },
1575
+ disabled: U,
1576
+ children: T("today", "Today")
1577
+ }
1578
+ ),
1579
+ /* @__PURE__ */ t(
1580
+ re,
1581
+ {
1582
+ onClick: () => Ye(1),
1583
+ disabled: U,
1584
+ "aria-label": T("next", "Next"),
1585
+ children: "›"
1586
+ }
1587
+ )
1588
+ ] }),
1589
+ We ? /* @__PURE__ */ g("span", { className: "nice-scheduler__range-picker", children: [
1590
+ /* @__PURE__ */ t(
1591
+ "input",
1592
+ {
1593
+ type: "date",
1594
+ className: "nice-textinput nice-textinput--sm",
1595
+ value: He(J),
1596
+ disabled: U,
1597
+ onChange: (c) => {
1598
+ const _ = /* @__PURE__ */ new Date(c.target.value + "T00:00:00");
1599
+ isNaN(_.getTime()) || Ne(_);
1600
+ }
1601
+ }
1602
+ ),
1603
+ /* @__PURE__ */ t("span", { style: { margin: "0 4px" }, children: "–" }),
1604
+ /* @__PURE__ */ t(
1605
+ "input",
1606
+ {
1607
+ type: "date",
1608
+ className: "nice-textinput nice-textinput--sm",
1609
+ value: He(O),
1610
+ disabled: U,
1611
+ onChange: (c) => {
1612
+ const _ = /* @__PURE__ */ new Date(c.target.value + "T00:00:00");
1613
+ !isNaN(_.getTime()) && _ >= J && be(_);
1614
+ }
1615
+ }
1616
+ )
1617
+ ] }) : /* @__PURE__ */ t("span", { className: "nice-scheduler__title", children: ct })
1618
+ ] }),
1619
+ /* @__PURE__ */ t("div", { className: "nice-scheduler__views", children: /* @__PURE__ */ t(Ve, { size: "sm", children: Ht.map((c) => /* @__PURE__ */ t(
1620
+ re,
1621
+ {
1622
+ variant: c === $ ? "primary" : "secondary",
1623
+ onClick: () => it(c),
1624
+ disabled: U,
1625
+ children: dt(c)
1626
+ },
1627
+ c
1628
+ )) }) })
1629
+ ] }),
1630
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__body", children: [
1631
+ f && /* @__PURE__ */ g("div", { className: "nice-scheduler__sidebar", children: [
1632
+ /* @__PURE__ */ t(
1633
+ Ft,
1634
+ {
1635
+ curDate: W,
1636
+ onDateSelect: (c) => ae(c),
1637
+ firstDayOfWeek: N,
1638
+ t: T
1639
+ }
1640
+ ),
1641
+ o && b && /* @__PURE__ */ t(
1642
+ Ke,
1643
+ {
1644
+ categories: b,
1645
+ events: ke,
1646
+ filteredCategories: ue,
1647
+ onToggleCategory: Pe,
1648
+ t: T
1649
+ }
1650
+ )
1651
+ ] }),
1652
+ /* @__PURE__ */ g("div", { className: "nice-scheduler__content", children: [
1653
+ $ === "month" && /* @__PURE__ */ t(xt, { ...oe }),
1654
+ ($ === "week" || $ === "day" || $ === "workWeek") && /* @__PURE__ */ t(Et, { ...oe, days: _e }),
1655
+ $ === "dayRange" && /* @__PURE__ */ t(At, { ...oe, rangeStart: J, rangeEnd: O }),
1656
+ $ === "monthRange" && /* @__PURE__ */ t(Pt, { ...oe, rangeStart: J, rangeEnd: O }),
1657
+ $ === "timeline" && /* @__PURE__ */ t(It, { ...oe }),
1658
+ $ === "agenda" && /* @__PURE__ */ t(Lt, { ...oe })
1659
+ ] }),
1660
+ !f && o && b && /* @__PURE__ */ t("div", { className: "nice-scheduler__sidebar nice-scheduler__sidebar--right", children: /* @__PURE__ */ t(
1661
+ Ke,
1662
+ {
1663
+ categories: b,
1664
+ events: ke,
1665
+ filteredCategories: ue,
1666
+ onToggleCategory: Pe,
1667
+ t: T
1668
+ }
1669
+ ) })
1670
+ ] }),
1671
+ Se && /* @__PURE__ */ t(
1672
+ Yt,
1673
+ {
1674
+ event: Se.event,
1675
+ rect: Se.rect,
1676
+ categories: b,
1677
+ renderTooltip: y
1678
+ }
1679
+ ),
1680
+ se && A && /* @__PURE__ */ t(
1681
+ Wt,
1682
+ {
1683
+ event: se.event,
1684
+ slotStart: se.slotStart,
1685
+ slotEnd: se.slotEnd,
1686
+ categories: b,
1687
+ resources: a,
1688
+ formFields: Y,
1689
+ formFieldsByType: H,
1690
+ eventTypes: s,
1691
+ renderEditor: v,
1692
+ saving: Ze,
1693
+ onSave: ot,
1694
+ onDelete: lt,
1695
+ onClose: () => de(null),
1696
+ t: T
1697
+ }
1698
+ )
1699
+ ]
1700
+ }
1701
+ );
1702
+ };
1703
+ Oe.displayName = "NiceScheduler";
1704
+ const Ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1705
+ __proto__: null,
1706
+ NiceScheduler: Oe
1707
+ }, Symbol.toStringTag, { value: "Module" }));
1708
+ export {
1709
+ Ve as N,
1710
+ $t as a,
1711
+ Oe as b,
1712
+ Tt as c,
1713
+ Ot as d,
1714
+ Mt as n,
1715
+ Ct as r
1716
+ };