@nice2dev/ui 1.1.6 → 1.1.7

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 (162) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +50 -29
  3. package/css/legacy-bg-text-aliases.css +65 -61
  4. package/dist/NiceCodeEditor-Bc81wiaN.js +1134 -0
  5. package/dist/NiceCodeEditor-D6f8KdHN.js +1134 -0
  6. package/dist/NiceCodeEditor-DE3saxyt.cjs +260 -0
  7. package/dist/NiceCodeEditor-DZM16My5.cjs +260 -0
  8. package/dist/NiceCodeEditor-HqmcJjmZ.js +1179 -0
  9. package/dist/NiceColorPicker-6EqXaDj0.cjs +1 -0
  10. package/dist/NiceColorPicker-BiEWqWnd.js +596 -0
  11. package/dist/NiceColorPicker-Cuc6YXqz.cjs +1 -0
  12. package/dist/NiceColorPicker-DMATcNWG.js +596 -0
  13. package/dist/NiceColorPicker-R3O1nemp.js +596 -0
  14. package/dist/NiceConfirmDialog-B0e10fRL.cjs +1 -0
  15. package/dist/NiceConfirmDialog-BBDgEMHv.js +81 -0
  16. package/dist/NiceConfirmDialog-C7kdr8jJ.js +81 -0
  17. package/dist/NiceConfirmDialog-DMHqPfFM.js +81 -0
  18. package/dist/NiceConfirmDialog-ZJpQLQQS.cjs +1 -0
  19. package/dist/NiceDataGrid-BzUw4dSu.cjs +10 -0
  20. package/dist/NiceDataGrid-CPKcVOVz.js +1743 -0
  21. package/dist/NiceDataGrid-DJr33WMy.cjs +10 -0
  22. package/dist/NiceDataGrid-D_4gZ1Hu.js +1736 -0
  23. package/dist/NiceDataGrid-DlUAaXhD.js +1736 -0
  24. package/dist/NiceDocumentViewer-8ghRVtfO.js +672 -0
  25. package/dist/NiceDocumentViewer-ChWtA_Ry.cjs +180 -0
  26. package/dist/NiceDocumentViewer-DwLUV7Tc.js +672 -0
  27. package/dist/NiceDocumentViewer-goMzF1w3.cjs +180 -0
  28. package/dist/NiceDocumentViewer-gt1mxzP8.js +672 -0
  29. package/dist/NiceForm-CHEAHxDw.js +4805 -0
  30. package/dist/NiceForm-CJUp1CL0.cjs +1 -0
  31. package/dist/NiceForm-Cp_RH3Yj.js +4805 -0
  32. package/dist/NiceForm-a6tGr6ss.js +4819 -0
  33. package/dist/NiceForm-jU89oe2S.cjs +1 -0
  34. package/dist/NiceGantt-BnQwyTfG.cjs +1 -0
  35. package/dist/NiceGantt-D8coFAvK.js +328 -0
  36. package/dist/NiceGantt-DOZfT6r5.js +328 -0
  37. package/dist/NiceGantt-DQzH1V-R.js +328 -0
  38. package/dist/NiceGantt-jQ8ZpXko.cjs +1 -0
  39. package/dist/NiceHtmlEditor-B1nlXJNW.cjs +10 -0
  40. package/dist/NiceHtmlEditor-Bv3VqJPG.js +862 -0
  41. package/dist/NiceHtmlEditor-CKsGj-Ei.cjs +10 -0
  42. package/dist/NiceHtmlEditor-CloMgyzg.js +841 -0
  43. package/dist/NiceHtmlEditor-DUAHmkWI.js +841 -0
  44. package/dist/NiceLoginForm-Ce_QLnLf.js +736 -0
  45. package/dist/NiceLoginForm-DLpNTQlR.cjs +1 -0
  46. package/dist/NiceLoginForm-Dg0286Cc.js +736 -0
  47. package/dist/NiceLoginForm-X05Vadeg.js +708 -0
  48. package/dist/NiceLoginForm-f_dBCnUi.cjs +1 -0
  49. package/dist/NiceMention-BByI4nFG.js +11120 -0
  50. package/dist/NiceMention-C2TPiMph.cjs +430 -0
  51. package/dist/NiceMention-C67vT6m0.js +11145 -0
  52. package/dist/NiceMention-D1cdy63w.cjs +430 -0
  53. package/dist/NiceMention-QIuggb9Y.js +11122 -0
  54. package/dist/NiceMention.css +1 -1
  55. package/dist/NiceModal-CHaan9al.js +95 -0
  56. package/dist/NiceModal-Czq6OEAT.js +95 -0
  57. package/dist/NiceModal-D-HFwawr.js +95 -0
  58. package/dist/NiceModal-DOy2XTzc.cjs +1 -0
  59. package/dist/NiceModal-DkawKzEE.cjs +1 -0
  60. package/dist/NiceModuleLifecyclePanel-1CsP8Zst.js +6997 -0
  61. package/dist/NiceModuleLifecyclePanel-Bkx4Yg-3.cjs +1 -0
  62. package/dist/NiceModuleLifecyclePanel-C5oYtczk.js +6999 -0
  63. package/dist/NiceModuleLifecyclePanel-DCcy2yYi.cjs +1 -0
  64. package/dist/NiceModuleLifecyclePanel-DqdgW-0s.js +7004 -0
  65. package/dist/NiceModuleLifecyclePanel.css +1 -1
  66. package/dist/NicePagination-7od5KUa3.cjs +1 -0
  67. package/dist/NicePagination-DMrkR8hH.cjs +1 -0
  68. package/dist/NicePagination-DQmZpsSQ.js +179 -0
  69. package/dist/NicePagination-DipQRjPq.js +172 -0
  70. package/dist/NicePagination-KhlVXYaT.js +172 -0
  71. package/dist/NicePivotGrid-B-KthuqL.cjs +152 -0
  72. package/dist/NicePivotGrid-CLCTHkKO.cjs +152 -0
  73. package/dist/NicePivotGrid-DV54FCsH.js +1174 -0
  74. package/dist/NicePivotGrid-DoWLUPUs.js +1167 -0
  75. package/dist/NicePivotGrid-etwpfccz.js +1167 -0
  76. package/dist/NiceSavedQueryPanel-BABkTNc5.js +5129 -0
  77. package/dist/NiceSavedQueryPanel-Cfeig83P.cjs +586 -0
  78. package/dist/NiceSavedQueryPanel-DTWRLseb.cjs +586 -0
  79. package/dist/NiceSavedQueryPanel-Dy154sxE.js +5129 -0
  80. package/dist/NiceSavedQueryPanel-v7AffOOe.js +5129 -0
  81. package/dist/NiceSavedQueryPanel.css +1 -1
  82. package/dist/NiceScheduler-BEgB7ZgF.cjs +5 -0
  83. package/dist/NiceScheduler-C9JprsEI.cjs +5 -0
  84. package/dist/NiceScheduler-DSP-PPh0.js +1645 -0
  85. package/dist/NiceScheduler-DuPnaA3t.js +1652 -0
  86. package/dist/NiceScheduler-Oa89YZx9.js +1645 -0
  87. package/dist/NiceSelect-A336yeLZ.js +433 -0
  88. package/dist/NiceSelect-B5hTbqi2.js +433 -0
  89. package/dist/NiceSelect-BYSgDYzq.cjs +1 -0
  90. package/dist/NiceSelect-Dudf2T5T.js +433 -0
  91. package/dist/NiceSelect-DwBAIrX7.cjs +1 -0
  92. package/dist/NiceWindow-B6zjBTl9.cjs +1 -0
  93. package/dist/NiceWindow-BKQEx7Vf.js +1623 -0
  94. package/dist/NiceWindow-BnTH7Gy0.js +1623 -0
  95. package/dist/NiceWindow-CZN9NVZw.cjs +1 -0
  96. package/dist/NiceWindow-lxtPR7yZ.js +1623 -0
  97. package/dist/NiceWindow.css +1 -1
  98. package/dist/charts-B8_V3_nq.cjs +882 -0
  99. package/dist/charts-BZgyyybE.js +31933 -0
  100. package/dist/charts-FuDk5-r6.js +31958 -0
  101. package/dist/charts-INj3yFo5.js +31946 -0
  102. package/dist/charts-NolNXKUL.cjs +882 -0
  103. package/dist/charts.cjs +1 -1
  104. package/dist/charts.css +1 -1
  105. package/dist/charts.mjs +1 -1
  106. package/dist/core-A_A6c7an.js +795 -0
  107. package/dist/core-B2iH2J_X.js +795 -0
  108. package/dist/core-BmspZEfD.js +795 -0
  109. package/dist/core-DAfLOet6.cjs +1 -0
  110. package/dist/core-ZG3bgnBR.cjs +1 -0
  111. package/dist/data-branching-B3TOqXAO.cjs +1 -0
  112. package/dist/data-branching-BUGiICDZ.js +6275 -0
  113. package/dist/data-branching-DMXmcocj.js +6275 -0
  114. package/dist/data-branching-YE8P9M5P.js +6275 -0
  115. package/dist/data-branching-t6uhAwIm.cjs +1 -0
  116. package/dist/data-branching.cjs +1 -1
  117. package/dist/data-branching.mjs +1 -1
  118. package/dist/data.cjs +1 -1
  119. package/dist/data.d.ts +7 -2
  120. package/dist/data.mjs +3 -3
  121. package/dist/devops-BhV3OmF7.js +8285 -0
  122. package/dist/devops-BqUxnbRi.cjs +17 -0
  123. package/dist/devops-Bx-Qwj9w.cjs +17 -0
  124. package/dist/devops-DYZatW45.js +8251 -0
  125. package/dist/devops-R98k2zpd.js +8251 -0
  126. package/dist/devops.cjs +1 -1
  127. package/dist/devops.d.ts +29 -16
  128. package/dist/devops.mjs +1 -1
  129. package/dist/editors.cjs +1 -1
  130. package/dist/editors.d.ts +35 -20
  131. package/dist/editors.mjs +7 -7
  132. package/dist/feedback.cjs +1 -1
  133. package/dist/feedback.mjs +3 -3
  134. package/dist/index.cjs +445 -445
  135. package/dist/index.css +1 -1
  136. package/dist/index.d.ts +190 -111
  137. package/dist/index.mjs +16635 -16351
  138. package/dist/lazy.cjs +1 -1
  139. package/dist/lazy.d.ts +31 -18
  140. package/dist/lazy.mjs +24 -24
  141. package/dist/navigation.cjs +1 -1
  142. package/dist/navigation.d.ts +17 -14
  143. package/dist/navigation.mjs +130 -130
  144. package/dist/no-code-BPaAS4wW.cjs +332 -0
  145. package/dist/no-code-CBwUVL1i.js +7447 -0
  146. package/dist/no-code-CjktkQ50.js +7447 -0
  147. package/dist/no-code-DW2NrRba.js +7447 -0
  148. package/dist/no-code-DmFxrZ5T.cjs +332 -0
  149. package/dist/no-code.cjs +1 -1
  150. package/dist/no-code.d.ts +2 -2
  151. package/dist/no-code.mjs +1 -1
  152. package/dist/overlays.cjs +1 -1
  153. package/dist/overlays.d.ts +4 -4
  154. package/dist/overlays.mjs +2 -2
  155. package/dist/pickerCommons-C4XWRUvH.cjs +1 -0
  156. package/dist/pickerCommons-C_BpYs_m.cjs +1 -0
  157. package/dist/pickerCommons-DAOXH_u5.js +1122 -0
  158. package/dist/pickerCommons-Dn4wnDco.js +1122 -0
  159. package/dist/pickerCommons-DskswPS5.js +1122 -0
  160. package/dist/pickerCommons.css +1 -1
  161. package/dist/style.css +7 -7
  162. package/package.json +3 -3
@@ -0,0 +1,4819 @@
1
+ import { jsxs as p, jsx as e, Fragment as vn } from "react/jsx-runtime";
2
+ import { r as qn, g as Un, D as dn, c as un, G as en, V as mt, q as Ve, j as _n, o as Le, S as Et, n as Ft, A as Lt, t as zt, E as Bt, B as Pt, Z as Ht, F as Gt } from "./charts-FuDk5-r6.js";
3
+ import An, { useMemo as be, useState as we, useRef as Ce, useEffect as Fe, useCallback as F, forwardRef as bn, useImperativeHandle as Yt, useContext as Vt, useLayoutEffect as ht } from "react";
4
+ import { N as jt, a as Vn } from "./NiceColorPicker-BiEWqWnd.js";
5
+ import { b as on, u as Kt, F as lt, c as Ot, N as qt, a as ct, d as Zt } from "./pickerCommons-Dn4wnDco.js";
6
+ import { createPortal as gt } from "react-dom";
7
+ import { u as Jt, N as yt, s as Qt } from "./NiceSelect-A336yeLZ.js";
8
+ import { u as Xt } from "./core-B2iH2J_X.js";
9
+ function Wt({ text: n, query: i }) {
10
+ if (!i)
11
+ return /* @__PURE__ */ e(vn, { children: n });
12
+ const t = n.toLowerCase().indexOf(i.toLowerCase());
13
+ return t < 0 ? /* @__PURE__ */ e(vn, { children: n }) : /* @__PURE__ */ p("span", { children: [
14
+ n.slice(0, t),
15
+ /* @__PURE__ */ e("strong", { children: n.slice(t, t + i.length) }),
16
+ n.slice(t + i.length)
17
+ ] });
18
+ }
19
+ const ei = ({
20
+ options: n,
21
+ value: i,
22
+ defaultValue: t,
23
+ onChange: r,
24
+ minSearchLength: a = 1,
25
+ maxResults: o = 10,
26
+ onSearch: s,
27
+ clearable: C,
28
+ loading: w,
29
+ multiple: S,
30
+ renderOption: re,
31
+ highlightMatch: D = !0,
32
+ showAll: T = !0,
33
+ menuGap: Z,
34
+ label: ae,
35
+ error: G,
36
+ helperText: U,
37
+ required: k,
38
+ disabled: ne,
39
+ readOnly: X,
40
+ size: Y = "md",
41
+ id: ue,
42
+ className: oe,
43
+ style: M,
44
+ accessMode: L,
45
+ showKeyboardHints: z,
46
+ displayStyle: R,
47
+ labelPlacement: J,
48
+ errorPlacement: x,
49
+ labelWidth: te,
50
+ controlWidth: I
51
+ }) => {
52
+ qn("input", R), Un("input", R);
53
+ const B = dn(L, ue), pe = B === "hidden";
54
+ (B === "disabled" || B === "readOnly") && (ne = !0);
55
+ const g = un(ue), { t: f } = en(), [m, W] = mt({
56
+ value: i,
57
+ defaultValue: t,
58
+ fallbackValue: S ? [] : "",
59
+ onChange: r,
60
+ componentName: "NiceAutocomplete"
61
+ }), O = be(
62
+ () => S ? Array.isArray(m) ? m : m ? [m] : [] : [],
63
+ [m, S]
64
+ ), [v, b] = we(
65
+ () => S || Array.isArray(m) ? "" : n.find((y) => String(y.value) === m)?.label ?? m ?? ""
66
+ ), [q, P] = we(!1), ce = Ce(null), [Q, le] = we(-1), de = Ce(null), fe = Ce(null), { popupRef: ie, coords: E, ready: Ne, themeClass: j, portalTarget: _e } = Jt(
67
+ q,
68
+ ce,
69
+ () => P(!1)
70
+ ), V = be(() => {
71
+ const y = [
72
+ Ve.moveDown,
73
+ Ve.moveUp,
74
+ Ve.submit,
75
+ Ve.cancel
76
+ ];
77
+ return S && y.push({ key: "Backspace", description: f("shortcuts.removeLastTag", "Remove last tag") }), y;
78
+ }, [S, f]);
79
+ Fe(() => {
80
+ S || b(
81
+ Array.isArray(m) ? "" : n.find((y) => String(y.value) === m)?.label ?? m ?? ""
82
+ );
83
+ }, [m, S, n]);
84
+ const Te = be(() => {
85
+ if (v.length < a)
86
+ return T ? (s ? n : [...n].sort((ke, je) => ke.label.localeCompare(je.label))).slice(0, o) : [];
87
+ if (s)
88
+ return n.slice(0, o);
89
+ const y = v.toLowerCase();
90
+ return n.filter((d) => d.label.toLowerCase().includes(y)).slice(0, o);
91
+ }, [n, v, a, o, s, T]), h = be(() => {
92
+ const y = /* @__PURE__ */ new Map();
93
+ for (const d of Te) {
94
+ const ke = d.group || "";
95
+ y.has(ke) || y.set(ke, []), y.get(ke).push(d);
96
+ }
97
+ return y;
98
+ }, [Te]), $ = F(
99
+ (y) => {
100
+ X || (b(y), P(y.length >= a), le(0), s?.(y));
101
+ },
102
+ [a, s, X]
103
+ ), H = F(
104
+ (y) => {
105
+ if (!X)
106
+ if (S) {
107
+ const d = String(y.value), ke = O.includes(d) ? O.filter((je) => je !== d) : [...O, d];
108
+ W(ke), b("");
109
+ } else
110
+ b(y.label), W(String(y.value)), P(!1);
111
+ },
112
+ [W, S, O, X]
113
+ ), Ie = (y) => {
114
+ if (!X) {
115
+ if (S && y.key === "Backspace" && !v && O.length > 0) {
116
+ W(O.slice(0, -1));
117
+ return;
118
+ }
119
+ if (!q && (y.key === "ArrowDown" || y.key === "ArrowUp")) {
120
+ y.preventDefault(), P(!0), le(0);
121
+ return;
122
+ }
123
+ q && (y.key === "ArrowDown" ? (y.preventDefault(), le((d) => d < 0 ? 0 : Math.min(d + 1, Te.length - 1))) : y.key === "ArrowUp" ? (y.preventDefault(), le((d) => d <= 0 ? Te.length - 1 : d - 1)) : (y.key === "Enter" || y.key === "Tab") && Q >= 0 && Q < Te.length ? (y.preventDefault(), H(Te[Q])) : y.key === "Escape" && P(!1));
124
+ }
125
+ }, me = F(
126
+ (y) => {
127
+ X || W(O.filter((d) => d !== y));
128
+ },
129
+ [O, W, X]
130
+ );
131
+ return pe ? null : /* @__PURE__ */ p(
132
+ "div",
133
+ {
134
+ className: `nice-field nice-field--${Y} ${J === "left" ? "nice-field--label-left" : ""} ${w ? "nice-field--loading" : ""} ${oe || ""}`,
135
+ style: {
136
+ width: "fit-content",
137
+ ...M,
138
+ ...te != null && {
139
+ "--nice-field-label-width": typeof te == "number" ? `${te}px` : te
140
+ },
141
+ ...I != null && {
142
+ "--nice-field-control-width": typeof I == "number" ? `${I}px` : I
143
+ },
144
+ ...Z != null && { "--nice-dropdown-gap": `${Z}px` }
145
+ },
146
+ ref: de,
147
+ "aria-busy": w || void 0,
148
+ children: [
149
+ ae && /* @__PURE__ */ p(
150
+ "label",
151
+ {
152
+ className: `nice-field__label ${k ? "nice-field__label--required" : ""}`,
153
+ htmlFor: g,
154
+ children: [
155
+ ae,
156
+ z && /* @__PURE__ */ e(_n, { shortcuts: V, size: "sm" })
157
+ ]
158
+ }
159
+ ),
160
+ /* @__PURE__ */ p("div", { className: "nice-field__control", style: { position: "relative" }, children: [
161
+ /* @__PURE__ */ e(
162
+ "div",
163
+ {
164
+ ref: ce,
165
+ className: `nice-input nice-input--${Y} ${G ? "nice-input--error" : ""} ${ne ? "nice-input--disabled" : ""}`,
166
+ style: { width: "220px" },
167
+ children: /* @__PURE__ */ p(
168
+ "div",
169
+ {
170
+ className: "nice-field__input-wrap",
171
+ style: {
172
+ display: "flex",
173
+ flexWrap: S ? "wrap" : "nowrap",
174
+ gap: 4,
175
+ alignItems: "center",
176
+ flex: 1,
177
+ minWidth: 0
178
+ },
179
+ children: [
180
+ S && O.map((y) => {
181
+ const d = n.find((ke) => String(ke.value) === y);
182
+ return /* @__PURE__ */ p("span", { className: "nice-autocomplete__tag", children: [
183
+ d?.label || y,
184
+ !X && /* @__PURE__ */ e(
185
+ "button",
186
+ {
187
+ type: "button",
188
+ className: "nice-autocomplete__tag-remove",
189
+ onClick: () => me(y),
190
+ "aria-label": f("controls.remove", "Remove"),
191
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
192
+ }
193
+ )
194
+ ] }, y);
195
+ }),
196
+ /* @__PURE__ */ e(
197
+ "input",
198
+ {
199
+ ref: fe,
200
+ id: g,
201
+ type: "text",
202
+ className: "nice-input__native",
203
+ value: v,
204
+ onChange: (y) => $(y.target.value),
205
+ onFocus: () => !X && (T || v.length >= a) && P(!0),
206
+ onKeyDown: Ie,
207
+ disabled: ne,
208
+ readOnly: X,
209
+ required: k,
210
+ role: "combobox",
211
+ "aria-expanded": q,
212
+ "aria-autocomplete": "list",
213
+ autoComplete: "off",
214
+ style: {
215
+ flex: 1,
216
+ minWidth: 60,
217
+ border: "none",
218
+ outline: "none",
219
+ background: "transparent",
220
+ color: "inherit",
221
+ padding: 0,
222
+ font: "inherit"
223
+ }
224
+ }
225
+ ),
226
+ C && !S && v && !ne && !X && /* @__PURE__ */ e(
227
+ "button",
228
+ {
229
+ type: "button",
230
+ className: "nice-input__clear",
231
+ onClick: () => {
232
+ b(""), W("");
233
+ },
234
+ "aria-label": f("controls.clear", "Clear"),
235
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
236
+ }
237
+ )
238
+ ]
239
+ }
240
+ )
241
+ }
242
+ ),
243
+ q && Te.length > 0 && E && _e && gt(
244
+ /* @__PURE__ */ e(
245
+ "ul",
246
+ {
247
+ ref: ie,
248
+ className: `nice-dropdown__list${j ? ` ${j}` : ""}`,
249
+ "data-theme": j === "nice-dark" ? "dark" : j === "nice-light" ? "light" : void 0,
250
+ role: "listbox",
251
+ style: {
252
+ position: "fixed",
253
+ left: E.left,
254
+ top: E.top,
255
+ width: E.width,
256
+ minWidth: E.width,
257
+ zIndex: 1e3,
258
+ // Stay transparent until the hook measures the real height (first open
259
+ // positions with an estimate that can flip above the trigger). opacity
260
+ // (not visibility) keeps the search input focusable while hidden.
261
+ opacity: Ne ? 1 : 0,
262
+ pointerEvents: Ne ? void 0 : "none"
263
+ },
264
+ children: Array.from(h.entries()).map(([y, d]) => /* @__PURE__ */ p(An.Fragment, { children: [
265
+ y && /* @__PURE__ */ e("li", { className: "nice-dropdown__group-label", children: y }),
266
+ d.map((ke) => {
267
+ const Ze = Te.indexOf(ke) === Q, He = S && O.includes(String(ke.value));
268
+ return /* @__PURE__ */ e(
269
+ "li",
270
+ {
271
+ role: "option",
272
+ className: `nice-dropdown__option ${Ze ? "nice-dropdown__option--active" : ""} ${He ? "nice-dropdown__option--selected" : ""}`,
273
+ onMouseDown: (ee) => {
274
+ ee.preventDefault(), H(ke);
275
+ },
276
+ "aria-selected": Ze,
277
+ children: re ? re(ke, v) : D ? /* @__PURE__ */ e(Wt, { text: ke.label, query: v }) : ke.label
278
+ },
279
+ String(ke.value)
280
+ );
281
+ })
282
+ ] }, y))
283
+ }
284
+ ),
285
+ _e
286
+ ),
287
+ w && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
288
+ x === "right" && G && /* @__PURE__ */ e("div", { id: `${g}-error`, className: "nice-field__error", role: "alert", children: G }),
289
+ x === "right" && !G && U && /* @__PURE__ */ e("div", { id: `${g}-helper`, className: "nice-field__helper", children: U })
290
+ ] }),
291
+ x !== "right" && G && /* @__PURE__ */ e("div", { id: `${g}-error`, className: "nice-field__error", role: "alert", children: G }),
292
+ x !== "right" && !G && U && /* @__PURE__ */ e("div", { id: `${g}-helper`, className: "nice-field__helper", children: U })
293
+ ]
294
+ }
295
+ );
296
+ }, ni = {
297
+ phone: "(999) 999-9999",
298
+ "credit-card": "9999 9999 9999 9999",
299
+ date: "99/99/9999",
300
+ ssn: "999-99-9999",
301
+ zip: "99-999",
302
+ time: "99:99",
303
+ iban: "aa99 9999 9999 9999 9999 9999"
304
+ };
305
+ function ti(n) {
306
+ return [...n].map((i) => i === "9" ? { type: "digit" } : i === "a" ? { type: "letter" } : i === "*" ? { type: "alphanum" } : { type: "literal", literal: i });
307
+ }
308
+ function ii(n, i) {
309
+ return i.type === "digit" ? /\d/.test(n) : i.type === "letter" ? /[a-zA-Z]/.test(n) : i.type === "alphanum" ? /[a-zA-Z0-9]/.test(n) : !1;
310
+ }
311
+ function rt(n, i, t) {
312
+ let r = 0, a = "";
313
+ for (const o of i)
314
+ o.type === "literal" ? a += o.literal : r < n.length ? (a += n[r], r++) : a += t;
315
+ return a;
316
+ }
317
+ function ai(n, i) {
318
+ return n.map((t) => t.type === "literal" ? t.literal : i).join("");
319
+ }
320
+ const _t = bn(
321
+ ({
322
+ label: n,
323
+ helperText: i,
324
+ error: t,
325
+ required: r,
326
+ disabled: a,
327
+ readOnly: o,
328
+ size: s = "md",
329
+ name: C,
330
+ id: w,
331
+ className: S,
332
+ style: re,
333
+ value: D = "",
334
+ onChange: T,
335
+ onBlur: Z,
336
+ onKeyDown: ae,
337
+ mask: G,
338
+ maskPreset: U,
339
+ maskChar: k = "_",
340
+ placeholder: ne,
341
+ showMaskAsPlaceholder: X = !0,
342
+ clearable: Y = !1,
343
+ autoFocus: ue,
344
+ labelPlacement: oe,
345
+ errorPlacement: M,
346
+ loading: L,
347
+ labelWidth: z,
348
+ controlWidth: R,
349
+ ...J
350
+ }, x) => {
351
+ const { t: te } = en(), I = un(w), B = Ce(null), [pe, g] = we(!1), f = G || (U ? ni[U] : "") || "999", m = An.useMemo(() => ti(f), [f]), W = An.useMemo(
352
+ () => rt(D, m, k),
353
+ [D, m, k]
354
+ ), O = pe || D ? W : "", v = ne ?? (X ? ai(m, k) : void 0), b = F(
355
+ (fe) => {
356
+ B.current = fe, typeof x == "function" ? x(fe) : x && (x.current = fe);
357
+ },
358
+ [x]
359
+ ), q = F(
360
+ (fe) => {
361
+ const ie = rt(fe, m, k);
362
+ T?.(fe, ie);
363
+ },
364
+ [T, m, k]
365
+ ), P = F(
366
+ (fe) => {
367
+ const ie = fe.currentTarget, E = ie.value, Ne = ie.selectionStart ?? E.length;
368
+ let j = "", _e = 0;
369
+ for (let V = 0; V < E.length && _e < m.length; V++) {
370
+ const Te = E[V];
371
+ for (; _e < m.length && m[_e].type === "literal"; )
372
+ _e++;
373
+ if (_e >= m.length)
374
+ break;
375
+ ii(Te, m[_e]) && (j += Te, _e++);
376
+ }
377
+ q(j), requestAnimationFrame(() => {
378
+ let V = 0, Te = 0;
379
+ for (let h = 0; h < m.length; h++) {
380
+ if (m[h].type === "literal")
381
+ V = h + 1;
382
+ else if (Te < j.length)
383
+ Te++, V = h + 1;
384
+ else {
385
+ V = h;
386
+ break;
387
+ }
388
+ if (V >= Ne && Te >= j.length)
389
+ break;
390
+ }
391
+ Te >= j.length && j.length > 0 && (V = Math.min(V, m.length)), ie.setSelectionRange(V, V);
392
+ });
393
+ },
394
+ [m, q]
395
+ ), ce = F(
396
+ (fe) => {
397
+ if (fe.key === "Backspace" && D.length > 0) {
398
+ fe.preventDefault();
399
+ const ie = D.slice(0, -1);
400
+ q(ie);
401
+ }
402
+ ae?.(fe);
403
+ },
404
+ [D, q, ae]
405
+ ), Q = F(() => g(!0), []), le = F(
406
+ (fe) => {
407
+ g(!1), Z?.(fe);
408
+ },
409
+ [Z]
410
+ ), de = F(() => {
411
+ q(""), B.current?.focus();
412
+ }, [q]);
413
+ return /* @__PURE__ */ p(
414
+ "div",
415
+ {
416
+ className: `nice-field nice-field--masked nice-field--${s} ${oe === "left" ? "nice-field--label-left" : ""} ${L ? "nice-field--loading" : ""} ${S || ""}`,
417
+ style: {
418
+ ...re,
419
+ ...z != null && {
420
+ "--nice-field-label-width": typeof z == "number" ? `${z}px` : z
421
+ },
422
+ ...R != null && {
423
+ "--nice-field-control-width": typeof R == "number" ? `${R}px` : R
424
+ }
425
+ },
426
+ "aria-busy": L || void 0,
427
+ children: [
428
+ n && /* @__PURE__ */ e(
429
+ "label",
430
+ {
431
+ htmlFor: I,
432
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
433
+ children: n
434
+ }
435
+ ),
436
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
437
+ /* @__PURE__ */ p(
438
+ "div",
439
+ {
440
+ className: `nice-input nice-input--${s} ${t ? "nice-input--error" : ""} ${a ? "nice-input--disabled" : ""} ${o ? "nice-input--readonly" : ""}`,
441
+ style: { width: "fit-content", minWidth: 0 },
442
+ children: [
443
+ /* @__PURE__ */ e(
444
+ "input",
445
+ {
446
+ ref: b,
447
+ id: I,
448
+ className: "nice-input__native nice-masked-input",
449
+ type: "text",
450
+ name: C,
451
+ value: O,
452
+ placeholder: v,
453
+ disabled: a || L,
454
+ readOnly: o,
455
+ autoFocus: ue,
456
+ style: {
457
+ width: `${f.length}ch`,
458
+ minWidth: 0,
459
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
460
+ fontVariantNumeric: "tabular-nums"
461
+ },
462
+ "aria-invalid": !!t,
463
+ "aria-describedby": t ? `${I}-error` : i ? `${I}-helper` : void 0,
464
+ onInput: P,
465
+ onChange: () => {
466
+ },
467
+ onKeyDown: ce,
468
+ onFocus: Q,
469
+ onBlur: le,
470
+ ...J
471
+ }
472
+ ),
473
+ Y && D && /* @__PURE__ */ e(
474
+ "button",
475
+ {
476
+ type: "button",
477
+ className: "nice-input__clear",
478
+ disabled: a || o,
479
+ onClick: de,
480
+ "aria-label": te("controls.clear", "Clear"),
481
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
482
+ }
483
+ )
484
+ ]
485
+ }
486
+ ),
487
+ L && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
488
+ M === "right" && t && /* @__PURE__ */ e("div", { id: `${I}-error`, className: "nice-field__error", role: "alert", children: t }),
489
+ M === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${I}-helper`, className: "nice-field__helper", children: i })
490
+ ] }),
491
+ M !== "right" && t && /* @__PURE__ */ e("div", { id: `${I}-error`, className: "nice-field__error", role: "alert", children: t }),
492
+ M !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${I}-helper`, className: "nice-field__helper", children: i })
493
+ ]
494
+ }
495
+ );
496
+ }
497
+ );
498
+ _t.displayName = "NiceMaskedInput";
499
+ const li = [
500
+ { id: "length", label: "At least 8 characters", test: (n) => n.length >= 8 },
501
+ { id: "uppercase", label: "At least one uppercase letter", test: (n) => /[A-Z]/.test(n) },
502
+ { id: "lowercase", label: "At least one lowercase letter", test: (n) => /[a-z]/.test(n) },
503
+ { id: "digit", label: "At least one digit", test: (n) => /\d/.test(n) },
504
+ { id: "special", label: "At least one special character", test: (n) => /[^a-zA-Z0-9]/.test(n) }
505
+ ];
506
+ function ci(n, i) {
507
+ if (!n)
508
+ return { level: "none", passed: [], ratio: 0 };
509
+ const t = i.filter((o) => o.test(n)).map((o) => o.id), r = t.length / i.length;
510
+ let a = "weak";
511
+ return r >= 1 ? a = "strong" : r >= 0.75 ? a = "good" : r >= 0.5 && (a = "fair"), { level: a, passed: t, ratio: r };
512
+ }
513
+ const vt = bn(
514
+ ({
515
+ label: n,
516
+ helperText: i,
517
+ error: t,
518
+ required: r,
519
+ disabled: a,
520
+ readOnly: o,
521
+ size: s = "md",
522
+ name: C,
523
+ id: w,
524
+ className: S,
525
+ style: re,
526
+ value: D = "",
527
+ onChange: T,
528
+ onBlur: Z,
529
+ onKeyDown: ae,
530
+ placeholder: G,
531
+ maxLength: U,
532
+ showToggle: k = !0,
533
+ showStrength: ne = !1,
534
+ strengthRules: X,
535
+ validationPlacement: Y = "bottom",
536
+ autoFocus: ue,
537
+ autoComplete: oe,
538
+ labelPlacement: M,
539
+ errorPlacement: L,
540
+ loading: z,
541
+ labelWidth: R,
542
+ controlWidth: J,
543
+ ...x
544
+ }, te) => {
545
+ const { t: I } = en(), B = un(w), [pe, g] = we(!1), f = X ?? li, m = be(
546
+ () => ne ? ci(D, f) : null,
547
+ [ne, D, f]
548
+ ), W = F(() => g((v) => !v), []), O = ne && m && D ? /* @__PURE__ */ p(
549
+ "div",
550
+ {
551
+ className: `nice-password__strength ${Y === "right" ? "nice-password__strength--right" : ""}`,
552
+ children: [
553
+ /* @__PURE__ */ e("div", { className: "nice-password__meter", children: /* @__PURE__ */ e(
554
+ "div",
555
+ {
556
+ className: `nice-password__meter-fill nice-password__meter-fill--${m.level}`,
557
+ style: { width: `${m.ratio * 100}%` }
558
+ }
559
+ ) }),
560
+ /* @__PURE__ */ e(
561
+ "span",
562
+ {
563
+ className: `nice-password__strength-label nice-password__strength-label--${m.level}`,
564
+ children: I(
565
+ `password.strength.${m.level}`,
566
+ m.level.charAt(0).toUpperCase() + m.level.slice(1)
567
+ )
568
+ }
569
+ ),
570
+ /* @__PURE__ */ e("ul", { className: "nice-password__rules", children: f.map((v) => {
571
+ const b = m.passed.includes(v.id);
572
+ return /* @__PURE__ */ p(
573
+ "li",
574
+ {
575
+ className: `nice-password__rule ${b ? "nice-password__rule--passed" : ""}`,
576
+ children: [
577
+ /* @__PURE__ */ e("span", { className: "nice-password__rule-icon", children: /* @__PURE__ */ e(Le, { name: b ? "check" : "close", size: 14 }) }),
578
+ v.label
579
+ ]
580
+ },
581
+ v.id
582
+ );
583
+ }) })
584
+ ]
585
+ }
586
+ ) : null;
587
+ return /* @__PURE__ */ p(
588
+ "div",
589
+ {
590
+ className: `nice-field nice-field--${s} ${M === "left" ? "nice-field--label-left" : ""} ${z ? "nice-field--loading" : ""} ${S || ""}`,
591
+ style: {
592
+ ...re,
593
+ ...R != null && {
594
+ "--nice-field-label-width": typeof R == "number" ? `${R}px` : R
595
+ },
596
+ ...J != null && {
597
+ "--nice-field-control-width": typeof J == "number" ? `${J}px` : J
598
+ }
599
+ },
600
+ "aria-busy": z || void 0,
601
+ children: [
602
+ n && /* @__PURE__ */ e(
603
+ "label",
604
+ {
605
+ htmlFor: B,
606
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
607
+ style: Y === "right" && M === "left" ? (
608
+ /* When validation block sits to the right of the input it makes
609
+ `.nice-field__control` taller than a single input row. Without
610
+ this override the grid row centres the label against the whole
611
+ control (input + strength meter), pushing it visually too low.
612
+ `align-self: flex-start` + matching padding keeps the label
613
+ aligned with the input row only. */
614
+ { alignSelf: "flex-start", paddingTop: 6 }
615
+ ) : void 0,
616
+ children: n
617
+ }
618
+ ),
619
+ /* @__PURE__ */ p(
620
+ "div",
621
+ {
622
+ className: "nice-field__control",
623
+ style: Y === "right" ? { alignItems: "flex-start" } : void 0,
624
+ children: [
625
+ /* @__PURE__ */ p(
626
+ "div",
627
+ {
628
+ style: Y === "right" ? { display: "flex", flexDirection: "column", flex: "1 1 auto", minWidth: 0 } : { display: "contents" },
629
+ children: [
630
+ /* @__PURE__ */ p(
631
+ "div",
632
+ {
633
+ className: `nice-input nice-input--${s} ${t ? "nice-input--error" : ""} ${a ? "nice-input--disabled" : ""} ${o ? "nice-input--readonly" : ""}`,
634
+ children: [
635
+ /* @__PURE__ */ e(
636
+ "input",
637
+ {
638
+ ref: te,
639
+ id: B,
640
+ className: "nice-input__native",
641
+ type: pe ? "text" : "password",
642
+ name: C,
643
+ value: D,
644
+ placeholder: G,
645
+ disabled: a || z,
646
+ readOnly: o,
647
+ maxLength: U,
648
+ autoFocus: ue,
649
+ autoComplete: oe,
650
+ "aria-invalid": !!t,
651
+ "aria-describedby": t ? `${B}-error` : i ? `${B}-helper` : void 0,
652
+ onChange: (v) => T?.(v.target.value),
653
+ onBlur: Z,
654
+ onKeyDown: ae,
655
+ ...x
656
+ }
657
+ ),
658
+ k && /* @__PURE__ */ e(
659
+ "button",
660
+ {
661
+ type: "button",
662
+ className: "nice-password__toggle",
663
+ onClick: W,
664
+ disabled: a,
665
+ tabIndex: -1,
666
+ "aria-label": pe ? I("password.hide", "Hide password") : I("password.show", "Show password"),
667
+ children: /* @__PURE__ */ e(Le, { name: pe ? "eye-off" : "eye", size: 18 })
668
+ }
669
+ )
670
+ ]
671
+ }
672
+ ),
673
+ Y === "right" && L !== "right" && t && /* @__PURE__ */ e("div", { id: `${B}-error`, className: "nice-field__error", role: "alert", children: t }),
674
+ Y === "right" && L !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${B}-helper`, className: "nice-field__helper", children: i })
675
+ ]
676
+ }
677
+ ),
678
+ z && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
679
+ Y === "right" && O,
680
+ L === "right" && t && /* @__PURE__ */ e("div", { id: `${B}-error`, className: "nice-field__error", role: "alert", children: t }),
681
+ L === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${B}-helper`, className: "nice-field__helper", children: i })
682
+ ]
683
+ }
684
+ ),
685
+ Y !== "right" && O,
686
+ Y !== "right" && L !== "right" && t && /* @__PURE__ */ e("div", { id: `${B}-error`, className: "nice-field__error", role: "alert", children: t }),
687
+ Y !== "right" && L !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${B}-helper`, className: "nice-field__helper", children: i })
688
+ ]
689
+ }
690
+ );
691
+ }
692
+ );
693
+ vt.displayName = "NicePasswordInput";
694
+ const bt = ({
695
+ label: n,
696
+ helperText: i,
697
+ error: t,
698
+ required: r,
699
+ disabled: a,
700
+ size: o = "md",
701
+ name: s,
702
+ id: C,
703
+ className: w,
704
+ style: S,
705
+ accessMode: re,
706
+ options: D,
707
+ value: T,
708
+ onChange: Z,
709
+ direction: ae = "horizontal",
710
+ showKeyboardHints: G,
711
+ displayStyle: U,
712
+ labelPlacement: k,
713
+ errorPlacement: ne,
714
+ labelWidth: X,
715
+ controlWidth: Y,
716
+ loading: ue,
717
+ readOnly: oe
718
+ }) => {
719
+ Un("toggle", U);
720
+ const M = dn(re, C), L = M === "hidden";
721
+ (M === "disabled" || M === "readOnly") && (a = !0);
722
+ const { t: z } = en(), R = un(C), J = s || R, x = be(
723
+ () => [
724
+ { key: "ArrowUp", description: z("shortcuts.previousOption", "Previous option") },
725
+ { key: "ArrowDown", description: z("shortcuts.nextOption", "Next option") },
726
+ { key: "Space", description: z("shortcuts.select", "Select") }
727
+ ],
728
+ [z]
729
+ );
730
+ return L ? null : /* @__PURE__ */ p(
731
+ "div",
732
+ {
733
+ className: `nice-field nice-field--inline nice-field--inline-block nice-field--${o} ${k === "left" ? "nice-field--label-left" : ""} ${ne === "right" ? "nice-field--error-right" : ""} ${ue ? "nice-field--loading" : ""} ${w || ""}`,
734
+ style: {
735
+ ...S,
736
+ ...X != null && {
737
+ "--nice-field-label-width": typeof X == "number" ? `${X}px` : X
738
+ },
739
+ ...Y != null && {
740
+ "--nice-field-control-width": typeof Y == "number" ? `${Y}px` : Y
741
+ }
742
+ },
743
+ role: "radiogroup",
744
+ "aria-labelledby": `${R}-label`,
745
+ "aria-busy": ue || void 0,
746
+ children: [
747
+ n && /* @__PURE__ */ p(
748
+ "span",
749
+ {
750
+ id: `${R}-label`,
751
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
752
+ children: [
753
+ n,
754
+ G && /* @__PURE__ */ e(_n, { shortcuts: x, size: "sm" })
755
+ ]
756
+ }
757
+ ),
758
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
759
+ /* @__PURE__ */ e(
760
+ "div",
761
+ {
762
+ className: `nice-radio-group ${ae === "vertical" ? "nice-radio-group--vertical" : ""}`,
763
+ children: D.map((te) => /* @__PURE__ */ p(
764
+ "label",
765
+ {
766
+ className: `nice-radio ${a || te.disabled || ue ? "nice-radio--disabled" : ""} ${oe ? "nice-radio--readonly" : ""}`,
767
+ children: [
768
+ /* @__PURE__ */ e(
769
+ "input",
770
+ {
771
+ type: "radio",
772
+ className: "nice-radio__input",
773
+ name: J,
774
+ value: te.value,
775
+ checked: T === te.value,
776
+ disabled: a || te.disabled || ue,
777
+ "aria-readonly": oe || void 0,
778
+ onChange: () => {
779
+ oe || Z?.(te.value);
780
+ }
781
+ }
782
+ ),
783
+ /* @__PURE__ */ e("span", { className: "nice-radio__circle", children: /* @__PURE__ */ e("span", { className: "nice-radio__dot" }) }),
784
+ /* @__PURE__ */ e("span", { children: te.label })
785
+ ]
786
+ },
787
+ te.value
788
+ ))
789
+ }
790
+ ),
791
+ ue && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
792
+ ne === "right" && t && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: t }),
793
+ ne === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: i })
794
+ ] }),
795
+ ne !== "right" && t && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: t }),
796
+ ne !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: i })
797
+ ]
798
+ }
799
+ );
800
+ }, Ki = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
801
+ __proto__: null,
802
+ NiceRadioGroup: bt
803
+ }, Symbol.toStringTag, { value: "Module" })), ri = ({
804
+ filled: n,
805
+ size: i
806
+ }) => /* @__PURE__ */ p(
807
+ "svg",
808
+ {
809
+ width: i,
810
+ height: i,
811
+ viewBox: "0 0 24 24",
812
+ fill: "none",
813
+ xmlns: "http://www.w3.org/2000/svg",
814
+ children: [
815
+ n === "half" && /* @__PURE__ */ e("defs", { children: /* @__PURE__ */ p("linearGradient", { id: "halfGrad", children: [
816
+ /* @__PURE__ */ e("stop", { offset: "50%", stopColor: "currentColor" }),
817
+ /* @__PURE__ */ e("stop", { offset: "50%", stopColor: "transparent" })
818
+ ] }) }),
819
+ /* @__PURE__ */ e(
820
+ "path",
821
+ {
822
+ d: "M12 2l3.09 6.26L22 9.27l-5 4.87L18.18 22 12 18.27 5.82 22 7 14.14l-5-4.87 6.91-1.01L12 2z",
823
+ fill: n === "full" ? "currentColor" : n === "half" ? "url(#halfGrad)" : "none",
824
+ stroke: "currentColor",
825
+ strokeWidth: "1.5",
826
+ strokeLinejoin: "round"
827
+ }
828
+ )
829
+ ]
830
+ }
831
+ ), oi = {
832
+ xxs: 10,
833
+ xs: 14,
834
+ sm: 18,
835
+ md: 22,
836
+ lg: 28,
837
+ xl: 34,
838
+ xxl: 42,
839
+ small: 18,
840
+ medium: 22,
841
+ large: 28
842
+ }, Zn = bn(
843
+ ({
844
+ value: n = 0,
845
+ onChange: i,
846
+ count: t = 5,
847
+ half: r = !1,
848
+ readOnly: a = !1,
849
+ disabled: o = !1,
850
+ size: s = "md",
851
+ label: C,
852
+ icon: w,
853
+ name: S,
854
+ error: re,
855
+ helperText: D,
856
+ required: T,
857
+ id: Z,
858
+ className: ae,
859
+ style: G,
860
+ labelPlacement: U,
861
+ errorPlacement: k,
862
+ labelWidth: ne,
863
+ controlWidth: X,
864
+ valuePlacement: Y = "none",
865
+ valueTemplate: ue,
866
+ loading: oe,
867
+ ...M
868
+ }, L) => {
869
+ const { t: z } = en(), R = un(Z), [J, x] = we(null), te = oi[s], I = !a && !o && !oe, B = J ?? n, pe = (v) => B >= v + 1 ? "full" : r && B >= v + 0.5 ? "half" : "empty", g = F(
870
+ (v, b) => {
871
+ if (!I)
872
+ return;
873
+ const q = b && r ? v + 0.5 : v + 1;
874
+ i?.(q === n ? 0 : q);
875
+ },
876
+ [I, r, i, n]
877
+ ), f = F(
878
+ (v, b) => {
879
+ if (I)
880
+ if (r) {
881
+ const q = b.currentTarget.getBoundingClientRect(), P = b.clientX - q.left < q.width / 2;
882
+ x(P ? v + 0.5 : v + 1);
883
+ } else
884
+ x(v + 1);
885
+ },
886
+ [I, r]
887
+ ), m = F(() => {
888
+ I && x(null);
889
+ }, [I]), W = F(
890
+ (v) => {
891
+ if (!I)
892
+ return;
893
+ const b = r ? 0.5 : 1;
894
+ if (v.key === "ArrowRight" || v.key === "ArrowUp") {
895
+ v.preventDefault();
896
+ const q = Math.min(t, n + b);
897
+ i?.(q);
898
+ } else if (v.key === "ArrowLeft" || v.key === "ArrowDown") {
899
+ v.preventDefault();
900
+ const q = Math.max(0, n - b);
901
+ i?.(q);
902
+ }
903
+ },
904
+ [I, r, t, n, i]
905
+ ), O = ue ? ue.replace("{value}", String(n)) : String(n);
906
+ return /* @__PURE__ */ p(
907
+ "div",
908
+ {
909
+ className: `nice-field nice-field--${s} ${U === "left" ? "nice-field--label-left" : ""} ${oe ? "nice-field--loading" : ""} ${ae || ""}`,
910
+ style: {
911
+ ...G,
912
+ ...ne != null && {
913
+ "--nice-field-label-width": typeof ne == "number" ? `${ne}px` : ne
914
+ },
915
+ ...X != null && {
916
+ "--nice-field-control-width": typeof X == "number" ? `${X}px` : X
917
+ }
918
+ },
919
+ "aria-busy": oe || void 0,
920
+ ...M,
921
+ children: [
922
+ C && /* @__PURE__ */ e(
923
+ "label",
924
+ {
925
+ htmlFor: R,
926
+ className: `nice-field__label ${T ? "nice-field__label--required" : ""}`,
927
+ children: C
928
+ }
929
+ ),
930
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
931
+ /* @__PURE__ */ p(
932
+ "div",
933
+ {
934
+ ref: L,
935
+ id: R,
936
+ className: `nice-rating nice-rating--${s} ${o ? "nice-rating--disabled" : ""} ${a ? "nice-rating--readonly" : ""}`,
937
+ role: "slider",
938
+ "aria-valuenow": n,
939
+ "aria-valuemin": 0,
940
+ "aria-valuemax": t,
941
+ "aria-label": C || z("controls.rating", "Rating"),
942
+ "aria-invalid": !!re,
943
+ tabIndex: I ? 0 : -1,
944
+ onMouseLeave: m,
945
+ onKeyDown: W,
946
+ children: [
947
+ S && /* @__PURE__ */ e("input", { type: "hidden", name: S, value: n }),
948
+ Array.from({ length: t }, (v, b) => {
949
+ const q = pe(b);
950
+ return /* @__PURE__ */ e(
951
+ "span",
952
+ {
953
+ className: `nice-rating__star nice-rating__star--${q}`,
954
+ onClick: (P) => {
955
+ if (!I)
956
+ return;
957
+ const ce = P.currentTarget.getBoundingClientRect(), Q = r && P.clientX - ce.left < ce.width / 2;
958
+ g(b, Q);
959
+ },
960
+ onMouseMove: (P) => f(b, P),
961
+ "aria-label": `${b + 1} ${z("controls.star", "star")}`,
962
+ children: w ? w(q) : /* @__PURE__ */ e(ri, { filled: q, size: te })
963
+ },
964
+ b
965
+ );
966
+ }),
967
+ oe && /* @__PURE__ */ e("span", { className: "nice-rating__loading", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) })
968
+ ]
969
+ }
970
+ ),
971
+ Y === "right" && !oe && /* @__PURE__ */ e("span", { className: "nice-rating__value", children: O }),
972
+ Y === "bottom" && !oe && /* @__PURE__ */ e("div", { className: "nice-rating__value nice-rating__value--bottom", children: O }),
973
+ k === "right" && re && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: re }),
974
+ k === "right" && !re && D && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: D })
975
+ ] }),
976
+ k !== "right" && re && /* @__PURE__ */ e("div", { id: `${R}-error`, className: "nice-field__error", role: "alert", children: re }),
977
+ k !== "right" && !re && D && /* @__PURE__ */ e("div", { id: `${R}-helper`, className: "nice-field__helper", children: D })
978
+ ]
979
+ }
980
+ );
981
+ }
982
+ );
983
+ Zn.displayName = "NiceRating";
984
+ const Oi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
985
+ __proto__: null,
986
+ NiceRating: Zn
987
+ }, Symbol.toStringTag, { value: "Module" })), Jn = bn(
988
+ ({
989
+ label: n,
990
+ helperText: i,
991
+ error: t,
992
+ required: r,
993
+ disabled: a,
994
+ id: o,
995
+ className: s,
996
+ style: C,
997
+ accessMode: w,
998
+ value: S = 0,
999
+ onChange: re,
1000
+ min: D = 0,
1001
+ max: T = 100,
1002
+ step: Z = 1,
1003
+ showValue: ae = !0,
1004
+ showMinMax: G = !1,
1005
+ formatValue: U,
1006
+ showKeyboardHints: k,
1007
+ displayStyle: ne,
1008
+ size: X = "md",
1009
+ labelPlacement: Y,
1010
+ errorPlacement: ue,
1011
+ labelWidth: oe,
1012
+ controlWidth: M,
1013
+ loading: L,
1014
+ showTicks: z = !1,
1015
+ tickInterval: R,
1016
+ maxTicks: J = 21,
1017
+ showTickLabels: x = !1
1018
+ }, te) => {
1019
+ Un("input", ne);
1020
+ const I = dn(w, o), B = I === "hidden";
1021
+ (I === "disabled" || I === "readOnly") && (a = !0);
1022
+ const { t: pe } = en(), g = un(o), f = be(() => (S - D) / (T - D) * 100, [S, D, T]), m = U ? U(S) : S.toString(), W = be(() => {
1023
+ if (!z)
1024
+ return [];
1025
+ const b = T - D;
1026
+ if (b <= 0)
1027
+ return [D, T];
1028
+ let q = R ?? Z, P = Math.floor(b / q) + 1;
1029
+ return P > J && (q = b / (J - 1), P = J), Array.from({ length: P }, (ce, Q) => {
1030
+ const le = D + Q * q;
1031
+ return Q === P - 1 ? T : le;
1032
+ });
1033
+ }, [z, D, T, Z, R, J]), O = be(
1034
+ () => [
1035
+ Ve.increment,
1036
+ Ve.decrement,
1037
+ Ve.first,
1038
+ Ve.last,
1039
+ Ve.incrementBig,
1040
+ Ve.decrementBig
1041
+ ],
1042
+ []
1043
+ ), v = Y === "left";
1044
+ return B ? null : /* @__PURE__ */ p(
1045
+ "div",
1046
+ {
1047
+ className: `nice-field nice-field--${X} ${v ? "nice-field--label-left" : ""} ${L ? "nice-field--loading" : ""} ${s || ""}`,
1048
+ style: {
1049
+ ...C,
1050
+ ...oe != null && {
1051
+ "--nice-field-label-width": typeof oe == "number" ? `${oe}px` : oe
1052
+ },
1053
+ ...M != null && {
1054
+ "--nice-field-control-width": typeof M == "number" ? `${M}px` : M
1055
+ }
1056
+ },
1057
+ "aria-busy": L || void 0,
1058
+ children: [
1059
+ v ? n && /* @__PURE__ */ p(
1060
+ "label",
1061
+ {
1062
+ htmlFor: g,
1063
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
1064
+ children: [
1065
+ n,
1066
+ k && /* @__PURE__ */ e(_n, { shortcuts: O, size: "sm" })
1067
+ ]
1068
+ }
1069
+ ) : (n || ae || k) && /* @__PURE__ */ p("div", { className: "nice-slider__header", children: [
1070
+ n ? /* @__PURE__ */ p(
1071
+ "label",
1072
+ {
1073
+ htmlFor: g,
1074
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
1075
+ children: [
1076
+ n,
1077
+ k && /* @__PURE__ */ e(_n, { shortcuts: O, size: "sm" })
1078
+ ]
1079
+ }
1080
+ ) : /* @__PURE__ */ e("span", {}),
1081
+ ae && /* @__PURE__ */ e("span", { className: "nice-slider__value nice-slider__value--header", children: m })
1082
+ ] }),
1083
+ /* @__PURE__ */ p("div", { className: "nice-field__control nice-field__control--slider", children: [
1084
+ /* @__PURE__ */ p(
1085
+ "div",
1086
+ {
1087
+ className: `nice-slider ${a || L ? "nice-slider--disabled" : ""} ${z ? "nice-slider--with-ticks" : ""}`,
1088
+ children: [
1089
+ /* @__PURE__ */ p("div", { className: "nice-slider__track-wrapper", children: [
1090
+ /* @__PURE__ */ e("div", { className: "nice-slider__track", children: /* @__PURE__ */ e("div", { className: "nice-slider__fill", style: { width: `${f}%` } }) }),
1091
+ z && W.length > 0 && /* @__PURE__ */ e("div", { className: "nice-slider__ticks", "aria-hidden": "true", children: W.map((b, q) => {
1092
+ const P = (b - D) / (T - D) * 100, ce = b <= S;
1093
+ return /* @__PURE__ */ e(
1094
+ "span",
1095
+ {
1096
+ className: `nice-slider__tick ${ce ? "nice-slider__tick--active" : ""}`,
1097
+ style: { left: `${P}%` },
1098
+ children: x && /* @__PURE__ */ e("span", { className: "nice-slider__tick-label", children: U ? U(b) : b })
1099
+ },
1100
+ q
1101
+ );
1102
+ }) }),
1103
+ /* @__PURE__ */ e(
1104
+ "input",
1105
+ {
1106
+ ref: te,
1107
+ id: g,
1108
+ type: "range",
1109
+ className: "nice-slider__native",
1110
+ min: D,
1111
+ max: T,
1112
+ step: Z,
1113
+ value: S,
1114
+ disabled: a || L,
1115
+ "aria-valuenow": S,
1116
+ "aria-valuemin": D,
1117
+ "aria-valuemax": T,
1118
+ onChange: (b) => re?.(parseFloat(b.target.value))
1119
+ }
1120
+ ),
1121
+ /* @__PURE__ */ e("div", { className: "nice-slider__thumb-visual", style: { left: `${f}%` } })
1122
+ ] }),
1123
+ G && /* @__PURE__ */ p("div", { className: "nice-slider__labels", children: [
1124
+ /* @__PURE__ */ e("span", { children: U ? U(D) : D }),
1125
+ /* @__PURE__ */ e("span", { children: U ? U(T) : T })
1126
+ ] })
1127
+ ]
1128
+ }
1129
+ ),
1130
+ v && ae && /* @__PURE__ */ e("span", { className: "nice-slider__value nice-slider__value--inline", children: m }),
1131
+ L && /* @__PURE__ */ e("span", { className: "nice-field__spinner nice-field__spinner--slider", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
1132
+ ue === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error nice-field__error--slider", role: "alert", children: t }),
1133
+ ue === "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper nice-field__helper--slider", children: i })
1134
+ ] }),
1135
+ ue !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
1136
+ ue !== "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
1137
+ ]
1138
+ }
1139
+ );
1140
+ }
1141
+ );
1142
+ Jn.displayName = "NiceSlider";
1143
+ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1144
+ __proto__: null,
1145
+ NiceSlider: Jn
1146
+ }, Symbol.toStringTag, { value: "Module" })), si = ({
1147
+ options: n,
1148
+ suggestions: i,
1149
+ value: t,
1150
+ defaultValue: r,
1151
+ onChange: a,
1152
+ searchable: o = !0,
1153
+ clearable: s,
1154
+ maxTags: C,
1155
+ allowCustom: w,
1156
+ placeholder: S,
1157
+ label: re,
1158
+ error: D,
1159
+ helperText: T,
1160
+ required: Z,
1161
+ disabled: ae,
1162
+ size: G = "md",
1163
+ loading: U,
1164
+ id: k,
1165
+ className: ne,
1166
+ style: X,
1167
+ accessMode: Y,
1168
+ showKeyboardHints: ue,
1169
+ labelPlacement: oe,
1170
+ errorPlacement: M,
1171
+ labelWidth: L,
1172
+ controlWidth: z,
1173
+ readOnly: R,
1174
+ autoExpand: J = !1
1175
+ }) => {
1176
+ const x = dn(Y, k), te = x === "hidden";
1177
+ (x === "disabled" || x === "readOnly") && (ae = !0);
1178
+ const I = un(k), { t: B } = en(), [pe, g] = we(!1), [f, m] = we(""), W = Ce(null), O = Ce(null);
1179
+ Et(W, () => g(!1));
1180
+ const v = be(
1181
+ () => [
1182
+ Ve.submit,
1183
+ Ve.cancel,
1184
+ { key: "Backspace", description: B("shortcuts.removeLastTag", "Remove last tag") }
1185
+ ],
1186
+ [B]
1187
+ ), b = be(() => Array.isArray(n) && n.length > 0 ? n : Array.isArray(i) ? i.map((E) => ({ label: E, value: E })) : [], [n, i]), [q, P] = mt({
1188
+ value: t,
1189
+ defaultValue: r,
1190
+ fallbackValue: [],
1191
+ onChange: a,
1192
+ componentName: "NiceTagBox"
1193
+ }), ce = be(() => Array.isArray(q) ? q : [], [q]), Q = be(() => {
1194
+ let E = b.filter((Ne) => !ce.includes(String(Ne.value)));
1195
+ if (f) {
1196
+ const Ne = f.toLowerCase();
1197
+ E = E.filter((j) => j.label.toLowerCase().includes(Ne));
1198
+ }
1199
+ return E;
1200
+ }, [b, ce, f]), le = F(
1201
+ (E) => {
1202
+ C && ce.length >= C || (ce.includes(E) || P([...ce, E]), m(""));
1203
+ },
1204
+ [ce, P, C]
1205
+ ), de = F(
1206
+ (E) => {
1207
+ P(ce.filter((Ne) => Ne !== E));
1208
+ },
1209
+ [ce, P]
1210
+ ), fe = (E) => {
1211
+ R || (E.key === "Backspace" && !f && ce.length > 0 ? de(ce[ce.length - 1]) : E.key === "Enter" && f ? (E.preventDefault(), Q.length > 0 ? le(String(Q[0].value)) : w && le(f)) : E.key === "Escape" && g(!1));
1212
+ }, ie = (E) => b.find((Ne) => String(Ne.value) === E)?.label ?? E;
1213
+ return te ? null : /* @__PURE__ */ p(
1214
+ "div",
1215
+ {
1216
+ className: `nice-field nice-field--${G} ${oe === "left" ? "nice-field--label-left" : ""} ${U ? "nice-field--loading" : ""} ${ne || ""}`,
1217
+ style: {
1218
+ ...X,
1219
+ ...L != null && {
1220
+ "--nice-field-label-width": typeof L == "number" ? `${L}px` : L
1221
+ },
1222
+ ...z != null && {
1223
+ "--nice-field-control-width": typeof z == "number" ? `${z}px` : z
1224
+ }
1225
+ },
1226
+ ref: W,
1227
+ "aria-busy": U || void 0,
1228
+ children: [
1229
+ re && /* @__PURE__ */ p(
1230
+ "label",
1231
+ {
1232
+ className: `nice-field__label ${Z ? "nice-field__label--required" : ""}`,
1233
+ htmlFor: I,
1234
+ children: [
1235
+ re,
1236
+ ue && /* @__PURE__ */ e(_n, { shortcuts: v, size: "sm" })
1237
+ ]
1238
+ }
1239
+ ),
1240
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
1241
+ /* @__PURE__ */ p(
1242
+ "div",
1243
+ {
1244
+ className: `nice-tagbox nice-tagbox--${G} ${J ? "nice-tagbox--expand" : "nice-tagbox--fixed"} ${D ? "nice-tagbox--error" : ""} ${ae ? "nice-tagbox--disabled" : ""} ${R ? "nice-tagbox--readonly" : ""}`,
1245
+ onClick: () => {
1246
+ !ae && !U && !R && (g(!0), O.current?.focus());
1247
+ },
1248
+ style: {
1249
+ position: "relative",
1250
+ cursor: ae || U ? "not-allowed" : R ? "default" : "text"
1251
+ },
1252
+ children: [
1253
+ /* @__PURE__ */ p("div", { className: "nice-tagbox__tags", children: [
1254
+ ce.map((E) => /* @__PURE__ */ p("span", { className: "nice-tag nice-tagbox__tag", children: [
1255
+ ie(E),
1256
+ !ae && !R && /* @__PURE__ */ e(
1257
+ "button",
1258
+ {
1259
+ type: "button",
1260
+ className: "nice-tag__remove",
1261
+ onClick: (Ne) => {
1262
+ Ne.stopPropagation(), de(E);
1263
+ },
1264
+ "aria-label": B("controls.remove", "Remove"),
1265
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
1266
+ }
1267
+ )
1268
+ ] }, E)),
1269
+ o && /* @__PURE__ */ e(
1270
+ "input",
1271
+ {
1272
+ ref: O,
1273
+ id: I,
1274
+ type: "text",
1275
+ className: "nice-tagbox__input nice-input__native",
1276
+ value: f,
1277
+ onChange: (E) => {
1278
+ m(E.target.value), g(!0);
1279
+ },
1280
+ onFocus: () => g(!0),
1281
+ onKeyDown: fe,
1282
+ placeholder: ce.length === 0 ? S || B("controls.select", "Select...") : "",
1283
+ disabled: ae || U,
1284
+ readOnly: R,
1285
+ autoComplete: "off",
1286
+ style: {
1287
+ border: "none",
1288
+ outline: "none",
1289
+ background: "transparent",
1290
+ color: "inherit",
1291
+ flex: 1,
1292
+ minWidth: 80,
1293
+ padding: 0,
1294
+ font: "inherit",
1295
+ caretColor: "var(--nice-color-primary)"
1296
+ }
1297
+ }
1298
+ )
1299
+ ] }),
1300
+ s && ce.length > 0 && !ae && !R && /* @__PURE__ */ e(
1301
+ "button",
1302
+ {
1303
+ type: "button",
1304
+ className: "nice-input__clear",
1305
+ onClick: (E) => {
1306
+ E.stopPropagation(), P([]);
1307
+ },
1308
+ "aria-label": B("controls.clear", "Clear"),
1309
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
1310
+ }
1311
+ ),
1312
+ pe && (Q.length > 0 || w && f) && /* @__PURE__ */ p("ul", { className: "nice-dropdown__list nice-tagbox__dropdown", role: "listbox", children: [
1313
+ Q.map((E) => /* @__PURE__ */ e(
1314
+ "li",
1315
+ {
1316
+ role: "option",
1317
+ className: "nice-dropdown__option",
1318
+ onMouseDown: (Ne) => {
1319
+ Ne.preventDefault(), le(String(E.value));
1320
+ },
1321
+ children: E.label
1322
+ },
1323
+ String(E.value)
1324
+ )),
1325
+ w && f && !Q.some((E) => String(E.value).toLowerCase() === f.toLowerCase()) && /* @__PURE__ */ p(
1326
+ "li",
1327
+ {
1328
+ role: "option",
1329
+ className: "nice-dropdown__option nice-dropdown__option--add",
1330
+ onMouseDown: (E) => {
1331
+ E.preventDefault(), le(f);
1332
+ },
1333
+ children: [
1334
+ "+ ",
1335
+ B("controls.add", "Add"),
1336
+ " “",
1337
+ f,
1338
+ "”"
1339
+ ]
1340
+ }
1341
+ )
1342
+ ] })
1343
+ ]
1344
+ }
1345
+ ),
1346
+ U && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
1347
+ M === "right" && D && /* @__PURE__ */ e("div", { id: `${I}-error`, className: "nice-field__error", role: "alert", children: D }),
1348
+ M === "right" && !D && T && /* @__PURE__ */ e("div", { id: `${I}-helper`, className: "nice-field__helper", children: T })
1349
+ ] }),
1350
+ M !== "right" && D && /* @__PURE__ */ e("div", { id: `${I}-error`, className: "nice-field__error", role: "alert", children: D }),
1351
+ M !== "right" && !D && T && /* @__PURE__ */ e("div", { id: `${I}-helper`, className: "nice-field__helper", children: T })
1352
+ ]
1353
+ }
1354
+ );
1355
+ }, Qn = bn(
1356
+ ({
1357
+ label: n,
1358
+ helperText: i,
1359
+ error: t,
1360
+ required: r,
1361
+ disabled: a,
1362
+ readOnly: o,
1363
+ size: s = "md",
1364
+ name: C,
1365
+ id: w,
1366
+ className: S,
1367
+ style: re,
1368
+ accessMode: D,
1369
+ displayStyle: T,
1370
+ value: Z,
1371
+ defaultValue: ae,
1372
+ onChange: G,
1373
+ onBlur: U,
1374
+ onKeyDown: k,
1375
+ placeholder: ne,
1376
+ rows: X = 3,
1377
+ maxLength: Y,
1378
+ resize: ue = "vertical",
1379
+ autoFocus: oe,
1380
+ showCount: M,
1381
+ counterPlacement: L = "bottom",
1382
+ submitOnEnter: z,
1383
+ onSubmit: R,
1384
+ showKeyboardHints: J,
1385
+ labelPlacement: x,
1386
+ errorPlacement: te,
1387
+ loading: I,
1388
+ labelWidth: B,
1389
+ controlWidth: pe,
1390
+ displayMode: g
1391
+ }, f) => {
1392
+ const m = dn(D, w), W = m === "hidden";
1393
+ m === "disabled" && (a = !0), m === "readOnly" && (o = !0);
1394
+ const { t: O } = en(), v = un(w), b = qn("input", T), q = Un("input", T), P = Z?.length ?? 0, ce = Y ? P > Y : !1, Q = Ft({ enabled: g, readOnly: o, disabled: a }), le = {
1395
+ key: "Enter",
1396
+ ctrl: !0,
1397
+ description: O("shortcuts.submit", "Submit")
1398
+ }, de = F(
1399
+ (ie) => {
1400
+ z && Lt(ie, le) && (ie.preventDefault(), R?.()), k?.(ie);
1401
+ },
1402
+ [z, R, k, le]
1403
+ ), fe = be(() => {
1404
+ const ie = [];
1405
+ return z && ie.push(le), ie.push({ key: "Tab", description: O("shortcuts.indent", "Indent (when supported)") }), ie;
1406
+ }, [z, O, le]);
1407
+ return W ? null : /* @__PURE__ */ p(
1408
+ "div",
1409
+ {
1410
+ className: `nice-field nice-field--${s} ${x === "left" ? "nice-field--label-left" : ""} ${I ? "nice-field--loading" : ""} ${S || ""}`,
1411
+ style: {
1412
+ ...re,
1413
+ ...B != null && {
1414
+ "--nice-field-label-width": typeof B == "number" ? `${B}px` : B
1415
+ },
1416
+ ...pe != null && {
1417
+ "--nice-field-control-width": typeof pe == "number" ? `${pe}px` : pe
1418
+ }
1419
+ },
1420
+ "aria-busy": I || void 0,
1421
+ children: [
1422
+ n && /* @__PURE__ */ p(
1423
+ "label",
1424
+ {
1425
+ htmlFor: v,
1426
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
1427
+ children: [
1428
+ n,
1429
+ J && fe.length > 0 && /* @__PURE__ */ e(_n, { shortcuts: fe, size: "sm" })
1430
+ ]
1431
+ }
1432
+ ),
1433
+ /* @__PURE__ */ p("div", { className: "nice-field__control nice-field__control--textarea", children: [
1434
+ Q.isDisplay ? /* @__PURE__ */ e(
1435
+ zt,
1436
+ {
1437
+ value: Z ?? ae ?? "",
1438
+ placeholder: ne,
1439
+ disabled: a,
1440
+ readOnly: o,
1441
+ onActivate: Q.enterEdit,
1442
+ ariaLabel: n,
1443
+ className: "nice-display-value--textarea"
1444
+ }
1445
+ ) : /* @__PURE__ */ p(vn, { children: [
1446
+ /* @__PURE__ */ p(
1447
+ "div",
1448
+ {
1449
+ style: { display: "flex", flexDirection: "column", flex: "1 1 auto", minWidth: 0 },
1450
+ children: [
1451
+ /* @__PURE__ */ e(
1452
+ "textarea",
1453
+ {
1454
+ ref: (ie) => {
1455
+ typeof f == "function" ? f(ie) : f && (f.current = ie), Q.autoFocusRef(ie);
1456
+ },
1457
+ id: v,
1458
+ className: `nice-textarea nice-input--${s} nice-textarea--ds-${q} ${t ? "nice-textarea--error" : ""} ${a ? "nice-textarea--disabled" : ""}`,
1459
+ style: { ...b, resize: ue },
1460
+ name: C,
1461
+ value: Z,
1462
+ defaultValue: ae,
1463
+ placeholder: ne,
1464
+ rows: X,
1465
+ maxLength: Y,
1466
+ disabled: a || I,
1467
+ readOnly: o,
1468
+ autoFocus: oe,
1469
+ "aria-invalid": !!t,
1470
+ "aria-describedby": t ? `${v}-error` : i ? `${v}-helper` : void 0,
1471
+ onChange: (ie) => G?.(ie.target.value),
1472
+ onBlur: (ie) => {
1473
+ g && Q.exitEdit(), U?.(ie);
1474
+ },
1475
+ onKeyDown: de
1476
+ }
1477
+ ),
1478
+ L !== "right" && (M || Y) && /* @__PURE__ */ p(
1479
+ "div",
1480
+ {
1481
+ className: `nice-textarea__counter ${ce ? "nice-textarea__counter--over" : ""}`,
1482
+ children: [
1483
+ P,
1484
+ Y ? ` / ${Y}` : ""
1485
+ ]
1486
+ }
1487
+ )
1488
+ ]
1489
+ }
1490
+ ),
1491
+ L === "right" && (M || Y) && /* @__PURE__ */ p(
1492
+ "div",
1493
+ {
1494
+ className: `nice-textarea__counter nice-textarea__counter--right ${ce ? "nice-textarea__counter--over" : ""}`,
1495
+ children: [
1496
+ P,
1497
+ Y ? ` / ${Y}` : ""
1498
+ ]
1499
+ }
1500
+ )
1501
+ ] }),
1502
+ I && /* @__PURE__ */ e("span", { className: "nice-field__spinner nice-field__spinner--textarea", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
1503
+ te === "right" && t && /* @__PURE__ */ e("div", { id: `${v}-error`, className: "nice-field__error", role: "alert", children: t }),
1504
+ te === "right" && !t && i && /* @__PURE__ */ e("div", { id: `${v}-helper`, className: "nice-field__helper", children: i })
1505
+ ] }),
1506
+ te !== "right" && t && /* @__PURE__ */ e("div", { id: `${v}-error`, className: "nice-field__error", role: "alert", children: t }),
1507
+ te !== "right" && !t && i && /* @__PURE__ */ e("div", { id: `${v}-helper`, className: "nice-field__helper", children: i })
1508
+ ]
1509
+ }
1510
+ );
1511
+ }
1512
+ );
1513
+ Qn.displayName = "NiceTextArea";
1514
+ const Zi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1515
+ __proto__: null,
1516
+ NiceTextArea: Qn
1517
+ }, Symbol.toStringTag, { value: "Module" })), di = () => `file-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`, jn = (n) => {
1518
+ if (n === 0)
1519
+ return "0 B";
1520
+ const i = 1024, t = ["B", "KB", "MB", "GB", "TB"], r = Math.floor(Math.log(n) / Math.log(i));
1521
+ return `${parseFloat((n / Math.pow(i, r)).toFixed(2))} ${t[r]}`;
1522
+ }, Xn = (n) => n.startsWith("image/"), Wn = (n) => n.startsWith("video/"), Ct = (n) => n.startsWith("audio/"), ui = (n) => Xn(n) ? "image" : Wn(n) ? "video" : Ct(n) ? "music" : /pdf|word|document|text|json|xml/.test(n) ? "file" : /excel|spreadsheet/.test(n) ? "table" : /powerpoint|presentation/.test(n) ? "monitor" : /zip|rar|7z/.test(n) ? "box" : "folder", pi = (n) => {
1523
+ if (Xn(n.type) || Wn(n.type) || Ct(n.type))
1524
+ return URL.createObjectURL(n);
1525
+ }, fi = {
1526
+ xxs: 24,
1527
+ xs: 32,
1528
+ sm: 48,
1529
+ md: 80,
1530
+ lg: 120,
1531
+ xl: 160,
1532
+ xxl: 200
1533
+ }, mi = (n, i) => (t) => {
1534
+ const r = new FormData();
1535
+ t.chunk ? (r.append("chunk", t.chunk), r.append("chunkIndex", String(t.chunkIndex)), r.append("totalChunks", String(t.totalChunks)), r.append("fileName", t.file.name), r.append("fileId", t.fileId || "")) : r.append("file", t.file);
1536
+ const a = new XMLHttpRequest();
1537
+ return new Promise((o) => {
1538
+ a.upload.addEventListener("progress", (s) => {
1539
+ s.lengthComputable && t.onProgress && t.onProgress(s.loaded / s.total * 100);
1540
+ }), a.addEventListener("load", () => {
1541
+ if (a.status >= 200 && a.status < 300)
1542
+ try {
1543
+ const s = JSON.parse(a.responseText);
1544
+ o({
1545
+ success: !0,
1546
+ url: s.url,
1547
+ fileId: s.fileId || s.id,
1548
+ metadata: s
1549
+ });
1550
+ } catch {
1551
+ o({ success: !0, url: a.responseText });
1552
+ }
1553
+ else
1554
+ o({ success: !1, error: `Upload failed: ${a.status} ${a.statusText}` });
1555
+ }), a.addEventListener("error", () => o({ success: !1, error: "Network error" })), a.addEventListener("abort", () => o({ success: !1, error: "Upload cancelled" })), t.signal && t.signal.addEventListener("abort", () => a.abort()), a.open("POST", n), i && Object.entries(i).forEach(([s, C]) => a.setRequestHeader(s, C)), a.send(r);
1556
+ });
1557
+ }, Nt = bn((n, i) => {
1558
+ const {
1559
+ accept: t,
1560
+ multiple: r = !0,
1561
+ maxFileSize: a,
1562
+ maxFiles: o,
1563
+ minFileSize: s,
1564
+ onFilesSelected: C,
1565
+ uploadMode: w = "instant",
1566
+ labelText: S,
1567
+ text: re,
1568
+ dropzoneText: D,
1569
+ browseText: T,
1570
+ dragActiveText: Z,
1571
+ labelPlacement: ae = "right",
1572
+ icon: G = "upload",
1573
+ showFileList: U = !0,
1574
+ imagePreview: k,
1575
+ showPreview: ne = !0,
1576
+ listMode: X = "list",
1577
+ previewSize: Y = "md",
1578
+ fileProgress: ue,
1579
+ renderPreview: oe,
1580
+ renderFileItem: M,
1581
+ variant: L = "dropzone",
1582
+ trigger: z,
1583
+ dropChildren: R,
1584
+ autoUpload: J = !1,
1585
+ uploadHandler: x,
1586
+ uploadUrl: te,
1587
+ uploadHeaders: I,
1588
+ concurrentUploads: B = 3,
1589
+ maxRetries: pe = 3,
1590
+ chunkSize: g = 5 * 1024 * 1024,
1591
+ chunkThreshold: f = 10 * 1024 * 1024,
1592
+ validateFile: m,
1593
+ keepFilesAfterUpload: W = !0,
1594
+ initialFiles: O,
1595
+ disabled: v,
1596
+ readOnly: b,
1597
+ onFilesAdded: q,
1598
+ onUploadComplete: P,
1599
+ onUploadError: ce,
1600
+ onProgress: Q,
1601
+ onFileRemoved: le,
1602
+ onChange: de,
1603
+ apiRef: fe,
1604
+ pasteFromClipboard: ie,
1605
+ className: E,
1606
+ style: Ne
1607
+ } = n, { t: j } = en(), [_e, V] = we(() => O ?? []), [Te, h] = we(!1), $ = Ce(_e), H = Ce(null), Ie = Ce(/* @__PURE__ */ new Map()), me = Ce([]), y = Ce(/* @__PURE__ */ new Set()), d = Ce(0), ke = Ce(() => {
1608
+ }), je = Ce(de), Ze = !!(x || te);
1609
+ Fe(() => {
1610
+ $.current = _e;
1611
+ }, [_e]), Fe(() => {
1612
+ je.current = de;
1613
+ }), Fe(() => {
1614
+ je.current?.(_e);
1615
+ }, [_e]), Fe(
1616
+ () => () => {
1617
+ $.current.forEach((l) => l.previewUrl && URL.revokeObjectURL(l.previewUrl));
1618
+ },
1619
+ []
1620
+ );
1621
+ const He = F(
1622
+ (l) => C(l.map((K) => K.file)),
1623
+ [C]
1624
+ ), ee = F(
1625
+ (l) => {
1626
+ if (m) {
1627
+ const K = m(l);
1628
+ if (K)
1629
+ return K;
1630
+ }
1631
+ if (a && l.size > a)
1632
+ return j("fileUpload.error.tooLarge", "File is too large. Maximum size: {size}").replace(
1633
+ "{size}",
1634
+ jn(a)
1635
+ );
1636
+ if (s && l.size < s)
1637
+ return j("fileUpload.error.tooSmall", "File is too small. Minimum size: {size}").replace(
1638
+ "{size}",
1639
+ jn(s)
1640
+ );
1641
+ if (t) {
1642
+ const K = t.split(",").map((he) => he.trim().toLowerCase()), se = l.type.toLowerCase(), $e = "." + (l.name.split(".").pop()?.toLowerCase() ?? "");
1643
+ if (!K.some((he) => he.startsWith(".") ? $e === he : he.endsWith("/*") ? se.startsWith(he.replace("/*", "/")) : se === he))
1644
+ return j(
1645
+ "fileUpload.error.badType",
1646
+ "File type not allowed. Accepted types: {accept}"
1647
+ ).replace("{accept}", t);
1648
+ }
1649
+ return null;
1650
+ },
1651
+ [m, a, s, t, j]
1652
+ ), Ae = F(() => x || (te ? mi(te, I) : null), [x, te, I]), We = F(
1653
+ async (l, K, se) => {
1654
+ const $e = l.file, xe = Math.ceil($e.size / g);
1655
+ let he = 0, Be = { success: !1 };
1656
+ for (let Ee = 0; Ee < xe; Ee++) {
1657
+ if (se.aborted)
1658
+ throw new Error("Upload cancelled");
1659
+ const Xe = Ee * g, Fn = Math.min(Xe + g, $e.size), mn = $e.slice(Xe, Fn);
1660
+ let hn = 0, an = !1;
1661
+ for (; !an && hn < pe; )
1662
+ try {
1663
+ Be = await K({
1664
+ file: $e,
1665
+ chunk: mn,
1666
+ chunkIndex: Ee,
1667
+ totalChunks: xe,
1668
+ fileId: l.id,
1669
+ onProgress: (gn) => {
1670
+ const Mn = (he + mn.size * gn / 100) / $e.size * 100;
1671
+ V(
1672
+ (Gn) => Gn.map((kn) => kn.id === l.id ? { ...kn, progress: Mn } : kn)
1673
+ );
1674
+ },
1675
+ signal: se
1676
+ }), Be.success ? (an = !0, he += mn.size) : hn++;
1677
+ } catch (gn) {
1678
+ if (hn++, hn >= pe)
1679
+ throw gn;
1680
+ }
1681
+ if (!an)
1682
+ throw new Error(`Failed to upload chunk ${Ee + 1}/${xe}`);
1683
+ }
1684
+ return Be;
1685
+ },
1686
+ [g, pe]
1687
+ ), nn = F(
1688
+ async (l, K) => {
1689
+ const se = $.current.find((xe) => xe.id === l);
1690
+ if (!se || se.status === "uploading" || se.status === "success")
1691
+ return;
1692
+ const $e = new AbortController();
1693
+ Ie.current.set(l, $e), y.current.add(l), V(
1694
+ (xe) => xe.map(
1695
+ (he) => he.id === l ? { ...he, status: "uploading", progress: 0, error: void 0 } : he
1696
+ )
1697
+ );
1698
+ try {
1699
+ const xe = se.file;
1700
+ let he;
1701
+ if (xe.size > f ? he = await We(se, K, $e.signal) : he = await K({
1702
+ file: xe,
1703
+ onProgress: (Be) => {
1704
+ V((Ee) => Ee.map((Xe) => Xe.id === l ? { ...Xe, progress: Be } : Xe)), Q?.(se, Be);
1705
+ },
1706
+ signal: $e.signal
1707
+ }), he.success) {
1708
+ if (V(
1709
+ (Be) => Be.map(
1710
+ (Ee) => Ee.id === l ? {
1711
+ ...Ee,
1712
+ status: "success",
1713
+ progress: 100,
1714
+ uploadedUrl: he.url,
1715
+ uploadedAt: /* @__PURE__ */ new Date()
1716
+ } : Ee
1717
+ )
1718
+ ), P?.({ ...se, status: "success", uploadedUrl: he.url }), !W) {
1719
+ const Be = $.current.find((Ee) => Ee.id === l);
1720
+ Be?.previewUrl && URL.revokeObjectURL(Be.previewUrl), V((Ee) => Ee.filter((Xe) => Xe.id !== l));
1721
+ }
1722
+ } else
1723
+ throw new Error(he.error || "Upload failed");
1724
+ } catch (xe) {
1725
+ const he = xe;
1726
+ if (he.name === "AbortError" || he.message === "Upload cancelled")
1727
+ V(
1728
+ (Be) => Be.map(
1729
+ (Ee) => Ee.id === l ? {
1730
+ ...Ee,
1731
+ status: "cancelled",
1732
+ error: j("fileUpload.status.cancelled", "Cancelled")
1733
+ } : Ee
1734
+ )
1735
+ );
1736
+ else {
1737
+ const Be = he.message || j("fileUpload.error.generic", "Upload error");
1738
+ V(
1739
+ (Ee) => Ee.map((Xe) => Xe.id === l ? { ...Xe, status: "error", error: Be } : Xe)
1740
+ ), ce?.(se, Be);
1741
+ }
1742
+ } finally {
1743
+ Ie.current.delete(l), y.current.delete(l), ke.current();
1744
+ }
1745
+ },
1746
+ [
1747
+ f,
1748
+ We,
1749
+ Q,
1750
+ P,
1751
+ ce,
1752
+ W,
1753
+ j
1754
+ ]
1755
+ ), pn = Ce(nn);
1756
+ Fe(() => {
1757
+ pn.current = nn;
1758
+ });
1759
+ const Je = F(() => {
1760
+ const l = Ae();
1761
+ if (l)
1762
+ for (; me.current.length > 0 && y.current.size < B; ) {
1763
+ const K = me.current.shift();
1764
+ K && pn.current(K, l);
1765
+ }
1766
+ }, [Ae, B]);
1767
+ Fe(() => {
1768
+ ke.current = Je;
1769
+ });
1770
+ const De = F(
1771
+ (l) => {
1772
+ const K = Ae();
1773
+ if (!K) {
1774
+ console.error("No upload handler configured");
1775
+ return;
1776
+ }
1777
+ pn.current(l, K);
1778
+ },
1779
+ [Ae]
1780
+ ), fn = F(
1781
+ (l) => {
1782
+ Ie.current.get(l)?.abort(), V(
1783
+ (K) => K.map(
1784
+ (se) => se.id === l && se.status === "uploading" ? { ...se, status: "cancelled", error: j("fileUpload.status.cancelled", "Cancelled") } : se
1785
+ )
1786
+ );
1787
+ },
1788
+ [j]
1789
+ ), N = F(
1790
+ (l) => {
1791
+ V(
1792
+ (K) => K.map(
1793
+ (se) => se.id === l ? { ...se, status: "pending", progress: 0, error: void 0 } : se
1794
+ )
1795
+ ), De(l);
1796
+ },
1797
+ [De]
1798
+ ), u = F(
1799
+ (l) => {
1800
+ const K = $.current.find(($e) => $e.id === l);
1801
+ if (!K)
1802
+ return;
1803
+ Ie.current.get(l)?.abort(), K.previewUrl && URL.revokeObjectURL(K.previewUrl);
1804
+ const se = $.current.filter(($e) => $e.id !== l);
1805
+ $.current = se, V(($e) => $e.filter((xe) => xe.id !== l)), le?.(K), w === "instant" && He(se);
1806
+ },
1807
+ [le, w, He]
1808
+ ), ge = F(() => {
1809
+ $.current.filter((l) => l.status === "pending").forEach((l) => me.current.push(l.id)), Je();
1810
+ }, [Je]), Ke = F(() => {
1811
+ Ie.current.forEach((l) => l.abort()), V(
1812
+ (l) => l.map(
1813
+ (K) => K.status === "uploading" ? { ...K, status: "cancelled", error: j("fileUpload.status.cancelled", "Cancelled") } : K
1814
+ )
1815
+ );
1816
+ }, [j]), ze = F(() => {
1817
+ Ke(), $.current.forEach((l) => l.previewUrl && URL.revokeObjectURL(l.previewUrl)), V([]), w === "instant" && He([]);
1818
+ }, [Ke, w, He]), qe = F(() => {
1819
+ $.current.filter((l) => l.status === "error").forEach((l) => N(l.id));
1820
+ }, [N]), Oe = F(
1821
+ (l) => {
1822
+ if (v || b)
1823
+ return;
1824
+ const K = $.current;
1825
+ let se = r ? l : l.slice(0, 1);
1826
+ o && (se = se.slice(0, Math.max(0, o - K.length)));
1827
+ const $e = se.map((he) => {
1828
+ const Be = ee(he);
1829
+ return {
1830
+ id: di(),
1831
+ file: he,
1832
+ name: he.name,
1833
+ size: he.size,
1834
+ type: he.type,
1835
+ status: Be ? "error" : "pending",
1836
+ progress: 0,
1837
+ error: Be || void 0,
1838
+ previewUrl: pi(he)
1839
+ };
1840
+ }), xe = r ? [...K, ...$e] : $e;
1841
+ V(xe), $.current = xe, q?.($e), w === "instant" && He(xe), J && ($e.filter((he) => he.status === "pending").forEach((he) => me.current.push(he.id)), Je());
1842
+ },
1843
+ [
1844
+ v,
1845
+ b,
1846
+ r,
1847
+ o,
1848
+ ee,
1849
+ q,
1850
+ w,
1851
+ He,
1852
+ J,
1853
+ Je
1854
+ ]
1855
+ ), tn = F(() => H.current?.click(), []);
1856
+ Yt(
1857
+ fe,
1858
+ () => ({
1859
+ addFiles: Oe,
1860
+ uploadAll: ge,
1861
+ cancelAll: Ke,
1862
+ clearAll: ze,
1863
+ getFiles: () => $.current,
1864
+ getFile: (l) => $.current.find((K) => K.id === l),
1865
+ retryFailed: qe,
1866
+ openFileBrowser: tn
1867
+ }),
1868
+ [Oe, ge, Ke, ze, qe, tn]
1869
+ ), Fe(() => {
1870
+ if (!ie || v || b)
1871
+ return;
1872
+ const l = (K) => {
1873
+ const se = K.clipboardData?.items;
1874
+ if (!se)
1875
+ return;
1876
+ const $e = [];
1877
+ for (let xe = 0; xe < se.length; xe++)
1878
+ if (se[xe].kind === "file") {
1879
+ const he = se[xe].getAsFile();
1880
+ he && $e.push(he);
1881
+ }
1882
+ $e.length > 0 && (K.preventDefault(), Oe($e));
1883
+ };
1884
+ return document.addEventListener("paste", l), () => document.removeEventListener("paste", l);
1885
+ }, [ie, v, b, Oe]);
1886
+ const Rn = (l) => {
1887
+ l.preventDefault(), !(v || b) && (d.current++, h(!0));
1888
+ }, Dn = (l) => {
1889
+ l.preventDefault(), d.current--, d.current <= 0 && (d.current = 0, h(!1));
1890
+ }, zn = (l) => {
1891
+ l.preventDefault(), d.current = 0, h(!1), !(v || b) && Oe(Array.from(l.dataTransfer.files));
1892
+ }, In = (l) => {
1893
+ l.target.files && Oe(Array.from(l.target.files)), l.target.value = "";
1894
+ }, Pe = be(() => {
1895
+ const l = { total: _e.length, pending: 0, uploading: 0, success: 0, error: 0 };
1896
+ for (const K of _e)
1897
+ K.status === "pending" ? l.pending++ : K.status === "uploading" ? l.uploading++ : K.status === "success" ? l.success++ : K.status === "error" && l.error++;
1898
+ return l;
1899
+ }, [_e]), cn = S ?? re ?? D ?? j("dropOrClick", "Drop files here or click to browse"), rn = Z ?? j("fileUpload.dropzone.dragActive", "Drop files here"), Cn = (l) => j(
1900
+ `fileUpload.status.${l}`,
1901
+ {
1902
+ pending: "Pending",
1903
+ uploading: "Uploading…",
1904
+ success: "Uploaded",
1905
+ error: "Error",
1906
+ cancelled: "Cancelled"
1907
+ }[l]
1908
+ ), Bn = (l) => Ze || l.status !== "pending", Pn = (l) => {
1909
+ if (oe)
1910
+ return oe(l);
1911
+ const K = fi[Y] ?? 80, se = k ?? ne;
1912
+ return se && l.previewUrl && Xn(l.type) ? /* @__PURE__ */ e(
1913
+ "img",
1914
+ {
1915
+ src: l.previewUrl,
1916
+ alt: l.name,
1917
+ className: "nice-fileuploader__thumb nice-upload__thumb nice-upload__preview",
1918
+ style: { width: K, height: K, objectFit: "cover" }
1919
+ }
1920
+ ) : se && l.previewUrl && Wn(l.type) ? /* @__PURE__ */ p(
1921
+ "span",
1922
+ {
1923
+ className: "nice-upload__preview",
1924
+ style: { position: "relative", display: "inline-flex" },
1925
+ children: [
1926
+ /* @__PURE__ */ e("video", { src: l.previewUrl, muted: !0, style: { width: K, height: K, objectFit: "cover" } }),
1927
+ /* @__PURE__ */ e("span", { className: "nice-upload__preview-overlay", "aria-hidden": "true", children: /* @__PURE__ */ e(Le, { name: "play", size: 20 }) })
1928
+ ]
1929
+ }
1930
+ ) : /* @__PURE__ */ e("span", { className: "nice-upload__preview nice-upload__preview--icon", "aria-hidden": "true", children: /* @__PURE__ */ e(Le, { name: ui(l.type), size: Math.round(K * 0.5) }) });
1931
+ }, Hn = (l) => {
1932
+ const K = {
1933
+ upload: () => De(l.id),
1934
+ cancel: () => fn(l.id),
1935
+ retry: () => N(l.id),
1936
+ remove: () => u(l.id)
1937
+ };
1938
+ if (M)
1939
+ return /* @__PURE__ */ e(An.Fragment, { children: M(l, K) }, l.id);
1940
+ const se = ue?.[l.name] ?? l.progress, $e = Bn(l);
1941
+ return /* @__PURE__ */ p(
1942
+ "div",
1943
+ {
1944
+ className: `nice-fileuploader__file nice-upload__file nice-upload__item nice-upload__item--${l.status}`,
1945
+ children: [
1946
+ (k ?? ne) && Pn(l),
1947
+ /* @__PURE__ */ e("span", { className: "nice-fileuploader__filename nice-upload__filename", title: l.name, children: l.name }),
1948
+ /* @__PURE__ */ e("span", { className: "nice-fileuploader__filesize nice-upload__filesize", children: jn(l.size) }),
1949
+ $e && /* @__PURE__ */ e("span", { className: `nice-upload__badge nice-upload__badge--${l.status}`, children: Cn(l.status) }),
1950
+ (l.status === "uploading" || se != null && se > 0 && se < 100) && /* @__PURE__ */ e("div", { className: "nice-fileuploader__progress nice-upload__progress", children: /* @__PURE__ */ e(
1951
+ "div",
1952
+ {
1953
+ className: "nice-fileuploader__progress-bar nice-upload__progress-bar",
1954
+ style: { width: `${Math.min(100, Math.max(0, se))}%` }
1955
+ }
1956
+ ) }),
1957
+ l.error && l.status === "error" && /* @__PURE__ */ e("span", { className: "nice-upload__item-error", children: l.error }),
1958
+ l.uploadedUrl && /* @__PURE__ */ e(
1959
+ "a",
1960
+ {
1961
+ className: "nice-upload__link",
1962
+ href: l.uploadedUrl,
1963
+ target: "_blank",
1964
+ rel: "noopener noreferrer",
1965
+ children: j("fileUpload.openFile", "Open file")
1966
+ }
1967
+ ),
1968
+ !b && !v && /* @__PURE__ */ p("span", { className: "nice-upload__item-actions", children: [
1969
+ Ze && l.status === "pending" && /* @__PURE__ */ e(
1970
+ "button",
1971
+ {
1972
+ type: "button",
1973
+ className: "nice-upload__btn nice-upload__btn--upload",
1974
+ onClick: K.upload,
1975
+ title: j("fileUpload.action.upload", "Upload"),
1976
+ "aria-label": j("fileUpload.action.upload", "Upload"),
1977
+ children: /* @__PURE__ */ e(Le, { name: "upload", size: 14 })
1978
+ }
1979
+ ),
1980
+ l.status === "uploading" && /* @__PURE__ */ e(
1981
+ "button",
1982
+ {
1983
+ type: "button",
1984
+ className: "nice-upload__btn nice-upload__btn--cancel",
1985
+ onClick: K.cancel,
1986
+ title: j("fileUpload.action.cancel", "Cancel"),
1987
+ "aria-label": j("fileUpload.action.cancel", "Cancel"),
1988
+ children: /* @__PURE__ */ e(Le, { name: "stop", size: 14 })
1989
+ }
1990
+ ),
1991
+ Ze && l.status === "error" && /* @__PURE__ */ e(
1992
+ "button",
1993
+ {
1994
+ type: "button",
1995
+ className: "nice-upload__btn nice-upload__btn--retry",
1996
+ onClick: K.retry,
1997
+ title: j("fileUpload.action.retry", "Retry"),
1998
+ "aria-label": j("fileUpload.action.retry", "Retry"),
1999
+ children: /* @__PURE__ */ e(Le, { name: "refresh", size: 14 })
2000
+ }
2001
+ ),
2002
+ l.status !== "uploading" && /* @__PURE__ */ e(
2003
+ "button",
2004
+ {
2005
+ type: "button",
2006
+ className: "nice-fileuploader__remove nice-upload__remove nice-upload__btn nice-upload__btn--remove",
2007
+ onClick: K.remove,
2008
+ title: j("remove", "Remove"),
2009
+ "aria-label": j("remove", "Remove"),
2010
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
2011
+ }
2012
+ )
2013
+ ] })
2014
+ ]
2015
+ },
2016
+ l.id
2017
+ );
2018
+ }, Nn = (l) => {
2019
+ (l.key === "Enter" || l.key === " ") && (l.preventDefault(), tn());
2020
+ }, En = /* @__PURE__ */ e(
2021
+ "input",
2022
+ {
2023
+ ref: H,
2024
+ type: "file",
2025
+ accept: t,
2026
+ multiple: r,
2027
+ hidden: !0,
2028
+ disabled: v,
2029
+ onChange: In
2030
+ }
2031
+ );
2032
+ return /* @__PURE__ */ p(
2033
+ "div",
2034
+ {
2035
+ ref: i,
2036
+ className: `nice-fileuploader nice-upload ${v ? "nice-fileuploader--disabled nice-upload--disabled" : ""} ${b ? "nice-upload--readonly" : ""} ${E || ""}`,
2037
+ style: Ne,
2038
+ children: [
2039
+ L === "button" ? /* @__PURE__ */ p(vn, { children: [
2040
+ /* @__PURE__ */ e(
2041
+ "button",
2042
+ {
2043
+ type: "button",
2044
+ className: "nice-upload__trigger nice-btn nice-btn--primary",
2045
+ onClick: tn,
2046
+ disabled: v || b,
2047
+ children: z ?? j("filePicker.label", "Choose files")
2048
+ }
2049
+ ),
2050
+ En
2051
+ ] }) : !b && /* @__PURE__ */ p(
2052
+ "div",
2053
+ {
2054
+ className: `nice-fileuploader__dropzone nice-upload__dropzone nice-upload__dropzone--label-${ae} ${!R && !cn ? "nice-upload__dropzone--icon-only" : ""} ${Te ? "nice-fileuploader__dropzone--active nice-upload__dropzone--active" : ""}`,
2055
+ role: "button",
2056
+ tabIndex: v ? -1 : 0,
2057
+ "aria-disabled": v || void 0,
2058
+ onDragEnter: Rn,
2059
+ onDragOver: (l) => l.preventDefault(),
2060
+ onDragLeave: Dn,
2061
+ onDrop: zn,
2062
+ onClick: () => !v && tn(),
2063
+ onKeyDown: Nn,
2064
+ children: [
2065
+ En,
2066
+ R ?? /* @__PURE__ */ p(vn, { children: [
2067
+ G && /* @__PURE__ */ e("div", { className: "nice-upload__icon", "aria-hidden": "true", children: /* @__PURE__ */ e(Le, { name: G, size: "lg" }) }),
2068
+ (Te ? rn : cn) && /* @__PURE__ */ p("div", { className: "nice-fileuploader__label nice-upload__label", children: [
2069
+ Te ? rn : cn,
2070
+ T && /* @__PURE__ */ p("span", { className: "nice-upload__browse", children: [
2071
+ " ",
2072
+ T
2073
+ ] })
2074
+ ] })
2075
+ ] })
2076
+ ]
2077
+ }
2078
+ ),
2079
+ U && _e.length > 0 && /* @__PURE__ */ e("div", { className: `nice-fileuploader__list nice-upload__list nice-upload__list--${X}`, children: _e.map(Hn) }),
2080
+ Ze && _e.length > 0 && !b && /* @__PURE__ */ p("div", { className: "nice-upload__bulk", children: [
2081
+ Pe.pending > 0 && /* @__PURE__ */ e(
2082
+ "button",
2083
+ {
2084
+ type: "button",
2085
+ className: "nice-btn nice-btn--primary nice-btn--sm",
2086
+ onClick: ge,
2087
+ children: j("fileUpload.bulk.uploadAll", "Upload all ({n})").replace(
2088
+ "{n}",
2089
+ String(Pe.pending)
2090
+ )
2091
+ }
2092
+ ),
2093
+ Pe.error > 0 && /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: qe, children: j("fileUpload.bulk.retryFailed", "Retry failed ({n})").replace(
2094
+ "{n}",
2095
+ String(Pe.error)
2096
+ ) }),
2097
+ /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: ze, children: j("fileUpload.bulk.clear", "Clear") })
2098
+ ] }),
2099
+ !Ze && w === "useButtons" && _e.length > 0 && !b && /* @__PURE__ */ p("div", { className: "nice-fileuploader__actions nice-upload__actions", children: [
2100
+ /* @__PURE__ */ e(
2101
+ "button",
2102
+ {
2103
+ type: "button",
2104
+ className: "nice-btn nice-btn--primary nice-btn--sm",
2105
+ onClick: () => He($.current),
2106
+ children: j("upload", "Upload")
2107
+ }
2108
+ ),
2109
+ /* @__PURE__ */ e("button", { type: "button", className: "nice-btn nice-btn--sm", onClick: ze, children: j("clearAll", "Clear All") })
2110
+ ] })
2111
+ ]
2112
+ }
2113
+ );
2114
+ });
2115
+ Nt.displayName = "NiceUpload";
2116
+ const hi = [
2117
+ { label: "Polska", value: "PL" },
2118
+ { label: "Deutschland", value: "DE" },
2119
+ { label: "Česko", value: "CZ" },
2120
+ { label: "Slovensko", value: "SK" },
2121
+ { label: "United Kingdom", value: "GB" },
2122
+ { label: "United States", value: "US" },
2123
+ { label: "France", value: "FR" },
2124
+ { label: "Italia", value: "IT" },
2125
+ { label: "España", value: "ES" },
2126
+ { label: "Nederland", value: "NL" }
2127
+ ], Mt = ({
2128
+ label: n,
2129
+ helperText: i,
2130
+ error: t,
2131
+ errorPlacement: r = "bottom",
2132
+ required: a,
2133
+ disabled: o,
2134
+ readOnly: s,
2135
+ loading: C,
2136
+ size: w = "md",
2137
+ className: S,
2138
+ style: re,
2139
+ accessMode: D,
2140
+ id: T,
2141
+ value: Z,
2142
+ defaultValue: ae,
2143
+ onChange: G,
2144
+ columns: U = 2,
2145
+ showState: k = !1,
2146
+ showBuilding: ne = !0,
2147
+ showApartment: X = !0,
2148
+ showCountry: Y = !0,
2149
+ countryOptions: ue = hi,
2150
+ defaultCountry: oe = "PL",
2151
+ fieldLabels: M,
2152
+ fieldPlaceholders: L,
2153
+ showLabel: z = !0,
2154
+ labelPlacement: R,
2155
+ labelWidth: J,
2156
+ controlWidth: x
2157
+ }) => {
2158
+ const te = dn(D, T), I = te === "hidden";
2159
+ te === "disabled" && (o = !0), te === "readOnly" && (s = !0);
2160
+ const { t: B } = en(), pe = Z !== void 0, [g, f] = An.useState(ae ?? {}), m = pe ? Z : g, W = (de) => {
2161
+ const fe = { ...m, ...de };
2162
+ pe || f(fe), G?.(fe);
2163
+ }, O = {
2164
+ street: M?.street ?? B("address.street", "Street"),
2165
+ building: M?.building ?? B("address.building", "Building"),
2166
+ apartment: M?.apartment ?? B("address.apartment", "Apt."),
2167
+ postalCode: M?.postalCode ?? B("address.postalCode", "Postal code"),
2168
+ city: M?.city ?? B("address.city", "City"),
2169
+ state: M?.state ?? B("address.state", "State / Region"),
2170
+ country: M?.country ?? B("address.country", "Country")
2171
+ }, v = L ?? {}, b = m.country ?? oe, q = R === "left" ? "left" : "top", P = {
2172
+ ...re,
2173
+ ...J != null && {
2174
+ "--nice-field-label-width": typeof J == "number" ? `${J}px` : J
2175
+ },
2176
+ ...x != null && {
2177
+ "--nice-field-control-width": typeof x == "number" ? `${x}px` : x
2178
+ }
2179
+ }, ce = {
2180
+ display: "grid",
2181
+ gridTemplateColumns: `repeat(${U}, minmax(0, 1fr))`,
2182
+ gap: "8px 12px"
2183
+ }, Q = U === 2 ? { gridColumn: "span 2" } : {}, le = {
2184
+ size: w,
2185
+ disabled: o || C,
2186
+ readOnly: s,
2187
+ labelPlacement: q
2188
+ };
2189
+ return I ? null : /* @__PURE__ */ p(
2190
+ "div",
2191
+ {
2192
+ className: `nice-field nice-field--${w} nice-address nice-address--cols-${U} ${C ? "nice-field--loading" : ""} ${S || ""}`,
2193
+ style: P,
2194
+ "aria-busy": C || void 0,
2195
+ children: [
2196
+ z && n && /* @__PURE__ */ e("label", { className: `nice-field__label ${a ? "nice-field__label--required" : ""}`, children: n }),
2197
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
2198
+ /* @__PURE__ */ p("div", { className: "nice-address__grid", style: ce, children: [
2199
+ /* @__PURE__ */ e("div", { style: Q, children: /* @__PURE__ */ e(
2200
+ on,
2201
+ {
2202
+ ...le,
2203
+ label: O.street,
2204
+ value: m.street ?? "",
2205
+ onChange: (de) => W({ street: de }),
2206
+ placeholder: v.street,
2207
+ required: a
2208
+ }
2209
+ ) }),
2210
+ ne && /* @__PURE__ */ e(
2211
+ on,
2212
+ {
2213
+ ...le,
2214
+ label: O.building,
2215
+ value: m.building ?? "",
2216
+ onChange: (de) => W({ building: de }),
2217
+ placeholder: v.building
2218
+ }
2219
+ ),
2220
+ X && /* @__PURE__ */ e(
2221
+ on,
2222
+ {
2223
+ ...le,
2224
+ label: O.apartment,
2225
+ value: m.apartment ?? "",
2226
+ onChange: (de) => W({ apartment: de }),
2227
+ placeholder: v.apartment
2228
+ }
2229
+ ),
2230
+ /* @__PURE__ */ e(
2231
+ on,
2232
+ {
2233
+ ...le,
2234
+ label: O.postalCode,
2235
+ value: m.postalCode ?? "",
2236
+ onChange: (de) => W({ postalCode: de }),
2237
+ placeholder: v.postalCode ?? "00-000",
2238
+ required: a
2239
+ }
2240
+ ),
2241
+ /* @__PURE__ */ e(
2242
+ on,
2243
+ {
2244
+ ...le,
2245
+ label: O.city,
2246
+ value: m.city ?? "",
2247
+ onChange: (de) => W({ city: de }),
2248
+ placeholder: v.city,
2249
+ required: a
2250
+ }
2251
+ ),
2252
+ k && /* @__PURE__ */ e(
2253
+ on,
2254
+ {
2255
+ ...le,
2256
+ label: O.state,
2257
+ value: m.state ?? "",
2258
+ onChange: (de) => W({ state: de }),
2259
+ placeholder: v.state
2260
+ }
2261
+ ),
2262
+ Y && /* @__PURE__ */ e(
2263
+ yt,
2264
+ {
2265
+ ...le,
2266
+ label: O.country,
2267
+ value: b,
2268
+ onChange: (de) => W({ country: typeof de == "string" ? de : String(de ?? "") }),
2269
+ options: ue,
2270
+ required: a
2271
+ }
2272
+ )
2273
+ ] }),
2274
+ C && /* @__PURE__ */ e("span", { className: "nice-field__spinner nice-field__spinner--address", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
2275
+ r === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
2276
+ r === "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
2277
+ ] }),
2278
+ r !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
2279
+ r !== "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
2280
+ ]
2281
+ }
2282
+ );
2283
+ };
2284
+ Mt.displayName = "NiceAddress";
2285
+ const gi = [
2286
+ { code: "US", name: "United States", dialCode: "+1", flag: "🇺🇸" },
2287
+ { code: "GB", name: "United Kingdom", dialCode: "+44", flag: "🇬🇧" },
2288
+ { code: "DE", name: "Germany", dialCode: "+49", flag: "🇩🇪" },
2289
+ { code: "FR", name: "France", dialCode: "+33", flag: "🇫🇷" },
2290
+ { code: "PL", name: "Poland", dialCode: "+48", flag: "🇵🇱" },
2291
+ { code: "ES", name: "Spain", dialCode: "+34", flag: "🇪🇸" },
2292
+ { code: "IT", name: "Italy", dialCode: "+39", flag: "🇮🇹" },
2293
+ { code: "NL", name: "Netherlands", dialCode: "+31", flag: "🇳🇱" },
2294
+ { code: "BE", name: "Belgium", dialCode: "+32", flag: "🇧🇪" },
2295
+ { code: "AT", name: "Austria", dialCode: "+43", flag: "🇦🇹" },
2296
+ { code: "CH", name: "Switzerland", dialCode: "+41", flag: "🇨🇭" },
2297
+ { code: "SE", name: "Sweden", dialCode: "+46", flag: "🇸🇪" },
2298
+ { code: "NO", name: "Norway", dialCode: "+47", flag: "🇳🇴" },
2299
+ { code: "DK", name: "Denmark", dialCode: "+45", flag: "🇩🇰" },
2300
+ { code: "FI", name: "Finland", dialCode: "+358", flag: "🇫🇮" },
2301
+ { code: "PT", name: "Portugal", dialCode: "+351", flag: "🇵🇹" },
2302
+ { code: "IE", name: "Ireland", dialCode: "+353", flag: "🇮🇪" },
2303
+ { code: "CZ", name: "Czech Republic", dialCode: "+420", flag: "🇨🇿" },
2304
+ { code: "SK", name: "Slovakia", dialCode: "+421", flag: "🇸🇰" },
2305
+ { code: "HU", name: "Hungary", dialCode: "+36", flag: "🇭🇺" },
2306
+ { code: "RO", name: "Romania", dialCode: "+40", flag: "🇷🇴" },
2307
+ { code: "BG", name: "Bulgaria", dialCode: "+359", flag: "🇧🇬" },
2308
+ { code: "GR", name: "Greece", dialCode: "+30", flag: "🇬🇷" },
2309
+ { code: "UA", name: "Ukraine", dialCode: "+380", flag: "🇺🇦" },
2310
+ { code: "RU", name: "Russia", dialCode: "+7", flag: "🇷🇺" },
2311
+ { code: "CA", name: "Canada", dialCode: "+1", flag: "🇨🇦" },
2312
+ { code: "AU", name: "Australia", dialCode: "+61", flag: "🇦🇺" },
2313
+ { code: "NZ", name: "New Zealand", dialCode: "+64", flag: "🇳🇿" },
2314
+ { code: "JP", name: "Japan", dialCode: "+81", flag: "🇯🇵" },
2315
+ { code: "KR", name: "South Korea", dialCode: "+82", flag: "🇰🇷" },
2316
+ { code: "CN", name: "China", dialCode: "+86", flag: "🇨🇳" },
2317
+ { code: "IN", name: "India", dialCode: "+91", flag: "🇮🇳" },
2318
+ { code: "SG", name: "Singapore", dialCode: "+65", flag: "🇸🇬" },
2319
+ { code: "MY", name: "Malaysia", dialCode: "+60", flag: "🇲🇾" },
2320
+ { code: "TH", name: "Thailand", dialCode: "+66", flag: "🇹🇭" },
2321
+ { code: "VN", name: "Vietnam", dialCode: "+84", flag: "🇻🇳" },
2322
+ { code: "ID", name: "Indonesia", dialCode: "+62", flag: "🇮🇩" },
2323
+ { code: "PH", name: "Philippines", dialCode: "+63", flag: "🇵🇭" },
2324
+ { code: "BR", name: "Brazil", dialCode: "+55", flag: "🇧🇷" },
2325
+ { code: "MX", name: "Mexico", dialCode: "+52", flag: "🇲🇽" },
2326
+ { code: "AR", name: "Argentina", dialCode: "+54", flag: "🇦🇷" },
2327
+ { code: "CL", name: "Chile", dialCode: "+56", flag: "🇨🇱" },
2328
+ { code: "CO", name: "Colombia", dialCode: "+57", flag: "🇨🇴" },
2329
+ { code: "PE", name: "Peru", dialCode: "+51", flag: "🇵🇪" },
2330
+ { code: "ZA", name: "South Africa", dialCode: "+27", flag: "🇿🇦" },
2331
+ { code: "EG", name: "Egypt", dialCode: "+20", flag: "🇪🇬" },
2332
+ { code: "NG", name: "Nigeria", dialCode: "+234", flag: "🇳🇬" },
2333
+ { code: "KE", name: "Kenya", dialCode: "+254", flag: "🇰🇪" },
2334
+ { code: "AE", name: "United Arab Emirates", dialCode: "+971", flag: "🇦🇪" },
2335
+ { code: "SA", name: "Saudi Arabia", dialCode: "+966", flag: "🇸🇦" },
2336
+ { code: "IL", name: "Israel", dialCode: "+972", flag: "🇮🇱" },
2337
+ { code: "TR", name: "Turkey", dialCode: "+90", flag: "🇹🇷" },
2338
+ // Additional countries
2339
+ { code: "AF", name: "Afghanistan", dialCode: "+93", flag: "🇦🇫" },
2340
+ { code: "AL", name: "Albania", dialCode: "+355", flag: "🇦🇱" },
2341
+ { code: "DZ", name: "Algeria", dialCode: "+213", flag: "🇩🇿" },
2342
+ { code: "AD", name: "Andorra", dialCode: "+376", flag: "🇦🇩" },
2343
+ { code: "AO", name: "Angola", dialCode: "+244", flag: "🇦🇴" },
2344
+ { code: "AG", name: "Antigua and Barbuda", dialCode: "+1268", flag: "🇦🇬" },
2345
+ { code: "AM", name: "Armenia", dialCode: "+374", flag: "🇦🇲" },
2346
+ { code: "AZ", name: "Azerbaijan", dialCode: "+994", flag: "🇦🇿" },
2347
+ { code: "BS", name: "Bahamas", dialCode: "+1242", flag: "🇧🇸" },
2348
+ { code: "BH", name: "Bahrain", dialCode: "+973", flag: "🇧🇭" },
2349
+ { code: "BD", name: "Bangladesh", dialCode: "+880", flag: "🇧🇩" },
2350
+ { code: "BB", name: "Barbados", dialCode: "+1246", flag: "🇧🇧" },
2351
+ { code: "BY", name: "Belarus", dialCode: "+375", flag: "🇧🇾" },
2352
+ { code: "BZ", name: "Belize", dialCode: "+501", flag: "🇧🇿" },
2353
+ { code: "BJ", name: "Benin", dialCode: "+229", flag: "🇧🇯" },
2354
+ { code: "BT", name: "Bhutan", dialCode: "+975", flag: "🇧🇹" },
2355
+ { code: "BO", name: "Bolivia", dialCode: "+591", flag: "🇧🇴" },
2356
+ { code: "BA", name: "Bosnia and Herzegovina", dialCode: "+387", flag: "🇧🇦" },
2357
+ { code: "BW", name: "Botswana", dialCode: "+267", flag: "🇧🇼" },
2358
+ { code: "BN", name: "Brunei", dialCode: "+673", flag: "🇧🇳" },
2359
+ { code: "BF", name: "Burkina Faso", dialCode: "+226", flag: "🇧🇫" },
2360
+ { code: "BI", name: "Burundi", dialCode: "+257", flag: "🇧🇮" },
2361
+ { code: "CV", name: "Cape Verde", dialCode: "+238", flag: "🇨🇻" },
2362
+ { code: "KH", name: "Cambodia", dialCode: "+855", flag: "🇰🇭" },
2363
+ { code: "CM", name: "Cameroon", dialCode: "+237", flag: "🇨🇲" },
2364
+ { code: "CF", name: "Central African Republic", dialCode: "+236", flag: "🇨🇫" },
2365
+ { code: "TD", name: "Chad", dialCode: "+235", flag: "🇹🇩" },
2366
+ { code: "KM", name: "Comoros", dialCode: "+269", flag: "🇰🇲" },
2367
+ { code: "CG", name: "Congo", dialCode: "+242", flag: "🇨🇬" },
2368
+ { code: "CD", name: "DR Congo", dialCode: "+243", flag: "🇨🇩" },
2369
+ { code: "CR", name: "Costa Rica", dialCode: "+506", flag: "🇨🇷" },
2370
+ { code: "CI", name: "Côte d'Ivoire", dialCode: "+225", flag: "🇨🇮" },
2371
+ { code: "HR", name: "Croatia", dialCode: "+385", flag: "🇭🇷" },
2372
+ { code: "CU", name: "Cuba", dialCode: "+53", flag: "🇨🇺" },
2373
+ { code: "CY", name: "Cyprus", dialCode: "+357", flag: "🇨🇾" },
2374
+ { code: "DJ", name: "Djibouti", dialCode: "+253", flag: "🇩🇯" },
2375
+ { code: "DM", name: "Dominica", dialCode: "+1767", flag: "🇩🇲" },
2376
+ { code: "DO", name: "Dominican Republic", dialCode: "+1809", flag: "🇩🇴" },
2377
+ { code: "EC", name: "Ecuador", dialCode: "+593", flag: "🇪🇨" },
2378
+ { code: "SV", name: "El Salvador", dialCode: "+503", flag: "🇸🇻" },
2379
+ { code: "GQ", name: "Equatorial Guinea", dialCode: "+240", flag: "🇬🇶" },
2380
+ { code: "ER", name: "Eritrea", dialCode: "+291", flag: "🇪🇷" },
2381
+ { code: "EE", name: "Estonia", dialCode: "+372", flag: "🇪🇪" },
2382
+ { code: "SZ", name: "Eswatini", dialCode: "+268", flag: "🇸🇿" },
2383
+ { code: "ET", name: "Ethiopia", dialCode: "+251", flag: "🇪🇹" },
2384
+ { code: "FJ", name: "Fiji", dialCode: "+679", flag: "🇫🇯" },
2385
+ { code: "GA", name: "Gabon", dialCode: "+241", flag: "🇬🇦" },
2386
+ { code: "GM", name: "Gambia", dialCode: "+220", flag: "🇬🇲" },
2387
+ { code: "GE", name: "Georgia", dialCode: "+995", flag: "🇬🇪" },
2388
+ { code: "GH", name: "Ghana", dialCode: "+233", flag: "🇬🇭" },
2389
+ { code: "GD", name: "Grenada", dialCode: "+1473", flag: "🇬🇩" },
2390
+ { code: "GT", name: "Guatemala", dialCode: "+502", flag: "🇬🇹" },
2391
+ { code: "GN", name: "Guinea", dialCode: "+224", flag: "🇬🇳" },
2392
+ { code: "GW", name: "Guinea-Bissau", dialCode: "+245", flag: "🇬🇼" },
2393
+ { code: "GY", name: "Guyana", dialCode: "+592", flag: "🇬🇾" },
2394
+ { code: "HT", name: "Haiti", dialCode: "+509", flag: "🇭🇹" },
2395
+ { code: "HN", name: "Honduras", dialCode: "+504", flag: "🇭🇳" },
2396
+ { code: "HK", name: "Hong Kong", dialCode: "+852", flag: "🇭🇰" },
2397
+ { code: "IS", name: "Iceland", dialCode: "+354", flag: "🇮🇸" },
2398
+ { code: "IQ", name: "Iraq", dialCode: "+964", flag: "🇮🇶" },
2399
+ { code: "IR", name: "Iran", dialCode: "+98", flag: "🇮🇷" },
2400
+ { code: "JM", name: "Jamaica", dialCode: "+1876", flag: "🇯🇲" },
2401
+ { code: "JO", name: "Jordan", dialCode: "+962", flag: "🇯🇴" },
2402
+ { code: "KZ", name: "Kazakhstan", dialCode: "+7", flag: "🇰🇿" },
2403
+ { code: "KW", name: "Kuwait", dialCode: "+965", flag: "🇰🇼" },
2404
+ { code: "KG", name: "Kyrgyzstan", dialCode: "+996", flag: "🇰🇬" },
2405
+ { code: "LA", name: "Laos", dialCode: "+856", flag: "🇱🇦" },
2406
+ { code: "LV", name: "Latvia", dialCode: "+371", flag: "🇱🇻" },
2407
+ { code: "LB", name: "Lebanon", dialCode: "+961", flag: "🇱🇧" },
2408
+ { code: "LS", name: "Lesotho", dialCode: "+266", flag: "🇱🇸" },
2409
+ { code: "LR", name: "Liberia", dialCode: "+231", flag: "🇱🇷" },
2410
+ { code: "LY", name: "Libya", dialCode: "+218", flag: "🇱🇾" },
2411
+ { code: "LI", name: "Liechtenstein", dialCode: "+423", flag: "🇱🇮" },
2412
+ { code: "LT", name: "Lithuania", dialCode: "+370", flag: "🇱🇹" },
2413
+ { code: "LU", name: "Luxembourg", dialCode: "+352", flag: "🇱🇺" },
2414
+ { code: "MO", name: "Macau", dialCode: "+853", flag: "🇲🇴" },
2415
+ { code: "MK", name: "North Macedonia", dialCode: "+389", flag: "🇲🇰" },
2416
+ { code: "MG", name: "Madagascar", dialCode: "+261", flag: "🇲🇬" },
2417
+ { code: "MW", name: "Malawi", dialCode: "+265", flag: "🇲🇼" },
2418
+ { code: "MV", name: "Maldives", dialCode: "+960", flag: "🇲🇻" },
2419
+ { code: "ML", name: "Mali", dialCode: "+223", flag: "🇲🇱" },
2420
+ { code: "MT", name: "Malta", dialCode: "+356", flag: "🇲🇹" },
2421
+ { code: "MR", name: "Mauritania", dialCode: "+222", flag: "🇲🇷" },
2422
+ { code: "MU", name: "Mauritius", dialCode: "+230", flag: "🇲🇺" },
2423
+ { code: "MD", name: "Moldova", dialCode: "+373", flag: "🇲🇩" },
2424
+ { code: "MC", name: "Monaco", dialCode: "+377", flag: "🇲🇨" },
2425
+ { code: "MN", name: "Mongolia", dialCode: "+976", flag: "🇲🇳" },
2426
+ { code: "ME", name: "Montenegro", dialCode: "+382", flag: "🇲🇪" },
2427
+ { code: "MA", name: "Morocco", dialCode: "+212", flag: "🇲🇦" },
2428
+ { code: "MZ", name: "Mozambique", dialCode: "+258", flag: "🇲🇿" },
2429
+ { code: "MM", name: "Myanmar", dialCode: "+95", flag: "🇲🇲" },
2430
+ { code: "NA", name: "Namibia", dialCode: "+264", flag: "🇳🇦" },
2431
+ { code: "NP", name: "Nepal", dialCode: "+977", flag: "🇳🇵" },
2432
+ { code: "NI", name: "Nicaragua", dialCode: "+505", flag: "🇳🇮" },
2433
+ { code: "NE", name: "Niger", dialCode: "+227", flag: "🇳🇪" },
2434
+ { code: "KP", name: "North Korea", dialCode: "+850", flag: "🇰🇵" },
2435
+ { code: "OM", name: "Oman", dialCode: "+968", flag: "🇴🇲" },
2436
+ { code: "PK", name: "Pakistan", dialCode: "+92", flag: "🇵🇰" },
2437
+ { code: "PS", name: "Palestine", dialCode: "+970", flag: "🇵🇸" },
2438
+ { code: "PA", name: "Panama", dialCode: "+507", flag: "🇵🇦" },
2439
+ { code: "PG", name: "Papua New Guinea", dialCode: "+675", flag: "🇵🇬" },
2440
+ { code: "PY", name: "Paraguay", dialCode: "+595", flag: "🇵🇾" },
2441
+ { code: "QA", name: "Qatar", dialCode: "+974", flag: "🇶🇦" },
2442
+ { code: "RW", name: "Rwanda", dialCode: "+250", flag: "🇷🇼" },
2443
+ { code: "WS", name: "Samoa", dialCode: "+685", flag: "🇼🇸" },
2444
+ { code: "SM", name: "San Marino", dialCode: "+378", flag: "🇸🇲" },
2445
+ { code: "ST", name: "São Tomé and Príncipe", dialCode: "+239", flag: "🇸🇹" },
2446
+ { code: "SN", name: "Senegal", dialCode: "+221", flag: "🇸🇳" },
2447
+ { code: "RS", name: "Serbia", dialCode: "+381", flag: "🇷🇸" },
2448
+ { code: "SC", name: "Seychelles", dialCode: "+248", flag: "🇸🇨" },
2449
+ { code: "SL", name: "Sierra Leone", dialCode: "+232", flag: "🇸🇱" },
2450
+ { code: "SI", name: "Slovenia", dialCode: "+386", flag: "🇸🇮" },
2451
+ { code: "SB", name: "Solomon Islands", dialCode: "+677", flag: "🇸🇧" },
2452
+ { code: "SO", name: "Somalia", dialCode: "+252", flag: "🇸🇴" },
2453
+ { code: "SS", name: "South Sudan", dialCode: "+211", flag: "🇸🇸" },
2454
+ { code: "LK", name: "Sri Lanka", dialCode: "+94", flag: "🇱🇰" },
2455
+ { code: "SD", name: "Sudan", dialCode: "+249", flag: "🇸🇩" },
2456
+ { code: "SR", name: "Suriname", dialCode: "+597", flag: "🇸🇷" },
2457
+ { code: "SY", name: "Syria", dialCode: "+963", flag: "🇸🇾" },
2458
+ { code: "TW", name: "Taiwan", dialCode: "+886", flag: "🇹🇼" },
2459
+ { code: "TJ", name: "Tajikistan", dialCode: "+992", flag: "🇹🇯" },
2460
+ { code: "TZ", name: "Tanzania", dialCode: "+255", flag: "🇹🇿" },
2461
+ { code: "TL", name: "Timor-Leste", dialCode: "+670", flag: "🇹🇱" },
2462
+ { code: "TG", name: "Togo", dialCode: "+228", flag: "🇹🇬" },
2463
+ { code: "TO", name: "Tonga", dialCode: "+676", flag: "🇹🇴" },
2464
+ { code: "TT", name: "Trinidad and Tobago", dialCode: "+1868", flag: "🇹🇹" },
2465
+ { code: "TN", name: "Tunisia", dialCode: "+216", flag: "🇹🇳" },
2466
+ { code: "TM", name: "Turkmenistan", dialCode: "+993", flag: "🇹🇲" },
2467
+ { code: "UG", name: "Uganda", dialCode: "+256", flag: "🇺🇬" },
2468
+ { code: "UY", name: "Uruguay", dialCode: "+598", flag: "🇺🇾" },
2469
+ { code: "UZ", name: "Uzbekistan", dialCode: "+998", flag: "🇺🇿" },
2470
+ { code: "VU", name: "Vanuatu", dialCode: "+678", flag: "🇻🇺" },
2471
+ { code: "VA", name: "Vatican City", dialCode: "+379", flag: "🇻🇦" },
2472
+ { code: "VE", name: "Venezuela", dialCode: "+58", flag: "🇻🇪" },
2473
+ { code: "YE", name: "Yemen", dialCode: "+967", flag: "🇾🇪" },
2474
+ { code: "ZM", name: "Zambia", dialCode: "+260", flag: "🇿🇲" },
2475
+ { code: "ZW", name: "Zimbabwe", dialCode: "+263", flag: "🇿🇼" }
2476
+ ], kt = ({
2477
+ value: n,
2478
+ defaultValue: i,
2479
+ onChange: t,
2480
+ placeholder: r,
2481
+ showSearch: a = !0,
2482
+ searchPlaceholder: o,
2483
+ showDialCode: s,
2484
+ showFlag: C,
2485
+ showFlagInValue: w,
2486
+ showFlagInMenu: S,
2487
+ showTextInValue: re,
2488
+ showTextInMenu: D,
2489
+ showDialCodeInValue: T,
2490
+ showDialCodeInMenu: Z,
2491
+ showCodeInValue: ae = !1,
2492
+ showCodeInMenu: G = !1,
2493
+ compact: U = !1,
2494
+ variant: k = "default",
2495
+ dropdownAlign: ne,
2496
+ disabled: X = !1,
2497
+ countries: Y,
2498
+ priorityCountries: ue = ["US", "GB", "DE", "FR", "PL"],
2499
+ allowClear: oe = !1,
2500
+ size: M = "md",
2501
+ className: L = "",
2502
+ style: z,
2503
+ // NiceFormFieldProps extras (label/error/state placement etc.)
2504
+ label: R,
2505
+ helperText: J,
2506
+ error: x,
2507
+ required: te,
2508
+ readOnly: I,
2509
+ loading: B,
2510
+ labelPlacement: pe,
2511
+ errorPlacement: g,
2512
+ labelWidth: f,
2513
+ controlWidth: m,
2514
+ id: W,
2515
+ "data-testid": O = "nice-country-picker"
2516
+ }) => {
2517
+ const { t: v } = en(), b = Ce(null), q = Ce(null), P = Ce(null), [ce, Q] = we(i), [le, de] = we(!1), [fe, ie] = we(""), [E, Ne] = we(0), j = w ?? C ?? !0, _e = S ?? C ?? !0, V = re ?? !U, Te = D ?? !0, h = T ?? s ?? !U, $ = Z ?? s ?? !0, H = Kt(
2518
+ le,
2519
+ q,
2520
+ ne ?? (U ? "auto" : "left")
2521
+ ), Ie = n !== void 0 ? n : ce, me = be(() => {
2522
+ let ee = gi;
2523
+ if (Y) {
2524
+ const Ae = new Set(Y.map((We) => We.toUpperCase()));
2525
+ ee = ee.filter((We) => Ae.has(We.code));
2526
+ }
2527
+ return ee;
2528
+ }, [Y]), y = be(() => {
2529
+ if (!ue?.length)
2530
+ return me;
2531
+ const ee = new Set(ue.map((nn) => nn.toUpperCase())), Ae = me.filter((nn) => ee.has(nn.code)), We = me.filter((nn) => !ee.has(nn.code));
2532
+ return [...Ae, ...We];
2533
+ }, [me, ue]), d = be(() => {
2534
+ if (!fe)
2535
+ return y;
2536
+ const ee = fe.toLowerCase();
2537
+ return y.filter(
2538
+ (Ae) => Ae.name.toLowerCase().includes(ee) || Ae.code.toLowerCase().includes(ee) || Ae.dialCode.includes(ee)
2539
+ );
2540
+ }, [y, fe]), ke = be(() => Ie ? me.find((ee) => ee.code === Ie) ?? null : null, [Ie, me]);
2541
+ Fe(() => {
2542
+ if (!le)
2543
+ return;
2544
+ const ee = (Ae) => {
2545
+ b.current && !b.current.contains(Ae.target) && (de(!1), ie(""));
2546
+ };
2547
+ return document.addEventListener("mousedown", ee), () => document.removeEventListener("mousedown", ee);
2548
+ }, [le]), Fe(() => {
2549
+ le && a && P.current && P.current.focus();
2550
+ }, [le, a]), Fe(() => {
2551
+ Ne(0);
2552
+ }, [fe]);
2553
+ const je = F(
2554
+ (ee) => {
2555
+ n === void 0 && Q(ee.code), t?.(ee), de(!1), ie("");
2556
+ },
2557
+ [n, t]
2558
+ ), Ze = F(
2559
+ (ee) => {
2560
+ ee.stopPropagation(), n === void 0 && Q(void 0), t?.(null);
2561
+ },
2562
+ [n, t]
2563
+ ), He = F(
2564
+ (ee) => {
2565
+ if (!le) {
2566
+ (ee.key === "Enter" || ee.key === " " || ee.key === "ArrowDown") && (ee.preventDefault(), de(!0));
2567
+ return;
2568
+ }
2569
+ switch (ee.key) {
2570
+ case "ArrowDown":
2571
+ ee.preventDefault(), Ne((Ae) => Math.min(Ae + 1, d.length - 1));
2572
+ break;
2573
+ case "ArrowUp":
2574
+ ee.preventDefault(), Ne((Ae) => Math.max(Ae - 1, 0));
2575
+ break;
2576
+ case "Enter":
2577
+ ee.preventDefault(), d[E] && je(d[E]);
2578
+ break;
2579
+ case "Escape":
2580
+ ee.preventDefault(), de(!1), ie("");
2581
+ break;
2582
+ }
2583
+ },
2584
+ [le, d, E, je]
2585
+ );
2586
+ return /* @__PURE__ */ p(
2587
+ "div",
2588
+ {
2589
+ ref: b,
2590
+ className: `nice-field nice-field--${M} nice-field--country-picker ${pe === "left" ? "nice-field--label-left" : ""} ${g === "right" ? "nice-field--error-right" : ""} ${x ? "nice-field--error" : ""} ${B ? "nice-field--loading" : ""} nice-country-picker nice-country-picker--${M} ${U ? "nice-country-picker--compact" : ""} ${k === "ghost" ? "nice-country-picker--ghost" : ""} ${le ? "nice-country-picker--open" : ""} ${X ? "nice-country-picker--disabled" : ""} ${L}`,
2591
+ style: {
2592
+ ...z,
2593
+ ...f != null && {
2594
+ "--nice-field-label-width": typeof f == "number" ? `${f}px` : f
2595
+ },
2596
+ ...m != null && {
2597
+ "--nice-field-control-width": typeof m == "number" ? `${m}px` : m
2598
+ }
2599
+ },
2600
+ "data-testid": O,
2601
+ "aria-busy": B || void 0,
2602
+ children: [
2603
+ R && /* @__PURE__ */ p("label", { className: "nice-field__label", htmlFor: W, children: [
2604
+ R,
2605
+ te && /* @__PURE__ */ e("span", { className: "nice-field__required", children: "*" })
2606
+ ] }),
2607
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
2608
+ /* @__PURE__ */ p(
2609
+ "button",
2610
+ {
2611
+ ref: q,
2612
+ type: "button",
2613
+ className: "nice-country-picker__trigger",
2614
+ onClick: () => !X && !I && de(!le),
2615
+ onKeyDown: He,
2616
+ disabled: X,
2617
+ id: W,
2618
+ "aria-haspopup": "listbox",
2619
+ "aria-expanded": le,
2620
+ "aria-invalid": x ? !0 : void 0,
2621
+ "data-testid": `${O}-trigger`,
2622
+ children: [
2623
+ ke ? /* @__PURE__ */ p("span", { className: "nice-country-picker__value", children: [
2624
+ j && /* @__PURE__ */ e("span", { className: "nice-country-picker__flag", "aria-hidden": "true", children: /* @__PURE__ */ e(lt, { code: ke.code }) }),
2625
+ V && /* @__PURE__ */ e("span", { className: "nice-country-picker__name", children: ke.name }),
2626
+ ae && /* @__PURE__ */ e("span", { className: "nice-country-picker__code", children: ke.code }),
2627
+ h && /* @__PURE__ */ p("span", { className: "nice-country-picker__dial-code", children: [
2628
+ "(",
2629
+ ke.dialCode,
2630
+ ")"
2631
+ ] })
2632
+ ] }) : /* @__PURE__ */ e("span", { className: "nice-country-picker__placeholder", children: U ? "" : r ?? v("controls.select", "Select country") }),
2633
+ /* @__PURE__ */ p("span", { className: "nice-country-picker__icons", children: [
2634
+ oe && ke && !X && !I && /* @__PURE__ */ e(
2635
+ "span",
2636
+ {
2637
+ className: "nice-country-picker__clear",
2638
+ onClick: Ze,
2639
+ "aria-label": v("clear", "Clear"),
2640
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
2641
+ }
2642
+ ),
2643
+ k !== "ghost" && /* @__PURE__ */ e("span", { className: "nice-country-picker__arrow", children: /* @__PURE__ */ e(Le, { name: le ? "chevron-up" : "chevron-down", size: 16 }) })
2644
+ ] })
2645
+ ]
2646
+ }
2647
+ ),
2648
+ le && /* @__PURE__ */ p(
2649
+ "div",
2650
+ {
2651
+ className: `nice-country-picker__dropdown nice-country-picker__dropdown--align-${H}`,
2652
+ role: "listbox",
2653
+ "data-testid": `${O}-dropdown`,
2654
+ children: [
2655
+ a && /* @__PURE__ */ e("div", { className: "nice-country-picker__search", children: /* @__PURE__ */ e(
2656
+ "input",
2657
+ {
2658
+ ref: P,
2659
+ type: "text",
2660
+ value: fe,
2661
+ onChange: (ee) => ie(ee.target.value),
2662
+ onKeyDown: He,
2663
+ placeholder: o ?? v("search", "Search"),
2664
+ className: "nice-country-picker__search-input",
2665
+ "data-testid": `${O}-search`
2666
+ }
2667
+ ) }),
2668
+ /* @__PURE__ */ e("div", { className: "nice-country-picker__list", children: d.length === 0 ? /* @__PURE__ */ e("div", { className: "nice-country-picker__empty", children: v("noData", "No countries found") }) : d.map((ee, Ae) => /* @__PURE__ */ p(
2669
+ "div",
2670
+ {
2671
+ className: `nice-country-picker__option ${ee.code === Ie ? "nice-country-picker__option--selected" : ""} ${Ae === E ? "nice-country-picker__option--highlighted" : ""}`,
2672
+ onClick: () => je(ee),
2673
+ onMouseEnter: () => Ne(Ae),
2674
+ role: "option",
2675
+ "aria-selected": ee.code === Ie,
2676
+ "data-testid": `${O}-option-${ee.code}`,
2677
+ children: [
2678
+ _e && /* @__PURE__ */ e("span", { className: "nice-country-picker__flag", "aria-hidden": "true", children: /* @__PURE__ */ e(lt, { code: ee.code }) }),
2679
+ Te && /* @__PURE__ */ e("span", { className: "nice-country-picker__name", children: ee.name }),
2680
+ G && /* @__PURE__ */ e("span", { className: "nice-country-picker__code", children: ee.code }),
2681
+ $ && /* @__PURE__ */ e("span", { className: "nice-country-picker__dial-code", children: ee.dialCode })
2682
+ ]
2683
+ },
2684
+ ee.code
2685
+ )) })
2686
+ ]
2687
+ }
2688
+ ),
2689
+ B && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
2690
+ g === "right" && x && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: x }),
2691
+ g === "right" && !x && J && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: J })
2692
+ ] }),
2693
+ g !== "right" && x && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: x }),
2694
+ g !== "right" && !x && J && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: J })
2695
+ ]
2696
+ }
2697
+ );
2698
+ };
2699
+ kt.displayName = "NiceCountryPicker";
2700
+ const yi = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"];
2701
+ function _i(n, i) {
2702
+ return new Date(n, i + 1, 0).getDate();
2703
+ }
2704
+ function vi(n, i) {
2705
+ return new Date(n, i, 1).getDay();
2706
+ }
2707
+ function ot(n, i, t) {
2708
+ return `${n}-${String(i + 1).padStart(2, "0")}-${String(t).padStart(2, "0")}`;
2709
+ }
2710
+ function bi(n) {
2711
+ const i = new Date(Date.UTC(n.getFullYear(), n.getMonth(), n.getDate()));
2712
+ i.setUTCDate(i.getUTCDate() + 4 - (i.getUTCDay() || 7));
2713
+ const t = new Date(Date.UTC(i.getUTCFullYear(), 0, 1));
2714
+ return Math.ceil(((i.getTime() - t.getTime()) / 864e5 + 1) / 7);
2715
+ }
2716
+ const st = [
2717
+ "January",
2718
+ "February",
2719
+ "March",
2720
+ "April",
2721
+ "May",
2722
+ "June",
2723
+ "July",
2724
+ "August",
2725
+ "September",
2726
+ "October",
2727
+ "November",
2728
+ "December"
2729
+ ], $t = ({
2730
+ value: n,
2731
+ onChange: i,
2732
+ min: t,
2733
+ max: r,
2734
+ disabledDates: a = [],
2735
+ firstDayOfWeek: o = 1,
2736
+ size: s = "md",
2737
+ showWeekNumbers: C,
2738
+ onMonthChange: w,
2739
+ className: S,
2740
+ style: re,
2741
+ accessMode: D,
2742
+ id: T,
2743
+ multiple: Z,
2744
+ selectedDates: ae,
2745
+ onSelectedDatesChange: G,
2746
+ selectionMode: U = "single",
2747
+ rangeStart: k,
2748
+ rangeEnd: ne,
2749
+ onRangeChange: X,
2750
+ renderDay: Y,
2751
+ showKeyboardHints: ue,
2752
+ persistPreferences: oe = !1,
2753
+ fullWidth: M = !1,
2754
+ // Traceless storage props
2755
+ cookies: L = !1,
2756
+ localStorage: z = !0,
2757
+ sessionStorage: R = !1,
2758
+ storageMode: J,
2759
+ storageKey: x
2760
+ }) => {
2761
+ const te = dn(D, T), I = te === "hidden", B = te === "disabled" || te === "readOnly", { t: pe } = en(), g = /* @__PURE__ */ new Date(), f = (U === "range" ? k : n) || n, m = f ? new Date(f) : g, W = Xt(x ?? "nice-calendar"), O = be(() => oe ? W.get("prefs") ?? {} : {}, [oe, W]), v = O.firstDayOfWeek ?? o, [b, q] = we(O.lastViewYear ?? m.getFullYear()), [P, ce] = we(O.lastViewMonth ?? m.getMonth()), [Q, le] = we(O.preferredView ?? "days"), [de, fe] = we([]), ie = ae ?? de, [E, Ne] = we(null), j = F(
2762
+ (N) => {
2763
+ if (!oe)
2764
+ return;
2765
+ const u = W.get("prefs") ?? {};
2766
+ W.set("prefs", { ...u, ...N });
2767
+ },
2768
+ [oe, W]
2769
+ ), _e = F(
2770
+ (N) => {
2771
+ le(N), j({ preferredView: N });
2772
+ },
2773
+ [j]
2774
+ ), V = F(
2775
+ (N, u) => {
2776
+ j({ lastViewYear: N, lastViewMonth: u });
2777
+ },
2778
+ [j]
2779
+ ), Te = be(
2780
+ () => [
2781
+ Ve.moveUp,
2782
+ Ve.moveDown,
2783
+ Ve.moveLeft,
2784
+ Ve.moveRight,
2785
+ { key: "Enter", description: pe("shortcuts.selectDate", "Select date") },
2786
+ Ve.pageUp,
2787
+ Ve.pageDown
2788
+ ],
2789
+ [pe]
2790
+ ), h = be(() => _i(b, P), [b, P]), $ = be(() => (vi(b, P) - v + 7) % 7, [b, P, v]), H = be(() => {
2791
+ const N = [...yi];
2792
+ for (let u = 0; u < v; u++)
2793
+ N.push(N.shift());
2794
+ return N;
2795
+ }, [v]), Ie = F(
2796
+ (N) => {
2797
+ const u = (ge) => /^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])/.test(ge);
2798
+ return t && u(t) && N < t || r && u(r) && N > r ? !0 : a.includes(N);
2799
+ },
2800
+ [t, r, a]
2801
+ ), me = F(
2802
+ (N) => {
2803
+ if (Q === "years") {
2804
+ q((Ke) => Ke + N * 10);
2805
+ return;
2806
+ }
2807
+ if (Q === "months") {
2808
+ q((Ke) => Ke + N);
2809
+ return;
2810
+ }
2811
+ let u = P + N, ge = b;
2812
+ u < 0 && (u = 11, ge--), u > 11 && (u = 0, ge++), ce(u), q(ge), V(ge, u), w?.(ge, u);
2813
+ },
2814
+ [P, b, w, Q, V]
2815
+ ), y = ot(g.getFullYear(), g.getMonth(), g.getDate()), d = U === "range", ke = F(
2816
+ (N) => d ? N === k || N === ne : Z ? ie.includes(N) : N === n,
2817
+ [d, k, ne, Z, ie, n]
2818
+ ), [je, Ze] = be(() => {
2819
+ if (!d || !k)
2820
+ return ["", ""];
2821
+ const N = ne || E;
2822
+ return N ? N < k ? [N, k] : [k, N] : [k, k];
2823
+ }, [d, k, ne, E]), He = F(
2824
+ (N) => {
2825
+ if (!B) {
2826
+ if (d) {
2827
+ const u = !k || ne ? { start: N, end: "" } : N < k ? { start: N, end: k } : { start: k, end: N };
2828
+ Ne(null), X?.(u), i?.(N);
2829
+ return;
2830
+ }
2831
+ if (Z) {
2832
+ const u = ie.includes(N) ? ie.filter((ge) => ge !== N) : [...ie, N];
2833
+ ae === void 0 && fe(u), G?.(u);
2834
+ }
2835
+ i?.(N);
2836
+ }
2837
+ },
2838
+ [
2839
+ B,
2840
+ d,
2841
+ k,
2842
+ ne,
2843
+ X,
2844
+ Z,
2845
+ ie,
2846
+ ae,
2847
+ i,
2848
+ G
2849
+ ]
2850
+ ), ee = F(() => {
2851
+ Q === "days" ? _e("months") : Q === "months" && _e("years");
2852
+ }, [Q, _e]), Ae = F(
2853
+ (N) => {
2854
+ ce(N), _e("days"), V(b, N), w?.(b, N);
2855
+ },
2856
+ [b, w, _e, V]
2857
+ ), We = F(
2858
+ (N) => {
2859
+ q(N), _e("months");
2860
+ },
2861
+ [_e]
2862
+ ), nn = Q === "years" ? `${b - b % 10} – ${b - b % 10 + 9}` : Q === "months" ? `${b}` : `${st[P]} ${b}`, pn = Q === "years" ? "decade" : Q === "months" ? "year" : "month", Je = [];
2863
+ for (let N = 0; N < $; N++)
2864
+ Je.push(null);
2865
+ for (let N = 1; N <= h; N++)
2866
+ Je.push(N);
2867
+ for (; Je.length % 7 !== 0; )
2868
+ Je.push(null);
2869
+ const De = [];
2870
+ for (let N = 0; N < Je.length; N += 7)
2871
+ De.push(Je.slice(N, N + 7));
2872
+ const fn = b - b % 10;
2873
+ return I ? null : /* @__PURE__ */ p(
2874
+ "div",
2875
+ {
2876
+ className: `nice-calendar nice-calendar--${s}${M ? " nice-calendar--full-width" : ""} ${S || ""}`,
2877
+ style: re,
2878
+ children: [
2879
+ /* @__PURE__ */ p("div", { className: "nice-calendar__header", children: [
2880
+ /* @__PURE__ */ e(
2881
+ "button",
2882
+ {
2883
+ type: "button",
2884
+ className: "nice-calendar__nav",
2885
+ onClick: () => me(-1),
2886
+ "aria-label": `Previous ${pn}`,
2887
+ children: /* @__PURE__ */ e(Le, { name: "chevron-left", size: 16 })
2888
+ }
2889
+ ),
2890
+ /* @__PURE__ */ e(
2891
+ "button",
2892
+ {
2893
+ type: "button",
2894
+ className: "nice-calendar__title",
2895
+ onClick: ee,
2896
+ "aria-label": Q === "days" ? "Show month picker" : Q === "months" ? "Show year picker" : void 0,
2897
+ disabled: Q === "years",
2898
+ children: nn
2899
+ }
2900
+ ),
2901
+ /* @__PURE__ */ e(
2902
+ "button",
2903
+ {
2904
+ type: "button",
2905
+ className: "nice-calendar__nav",
2906
+ onClick: () => me(1),
2907
+ "aria-label": `Next ${pn}`,
2908
+ children: /* @__PURE__ */ e(Le, { name: "chevron-right", size: 16 })
2909
+ }
2910
+ ),
2911
+ ue && /* @__PURE__ */ e(_n, { shortcuts: Te, size: "sm" })
2912
+ ] }),
2913
+ Q === "days" && /* @__PURE__ */ p(
2914
+ "table",
2915
+ {
2916
+ className: "nice-calendar__grid",
2917
+ role: "grid",
2918
+ onMouseLeave: d ? () => Ne(null) : void 0,
2919
+ children: [
2920
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ p("tr", { children: [
2921
+ C && /* @__PURE__ */ e("th", { className: "nice-calendar__wk", children: "W" }),
2922
+ H.map((N) => /* @__PURE__ */ e("th", { children: N }, N))
2923
+ ] }) }),
2924
+ /* @__PURE__ */ e("tbody", { children: De.map((N, u) => /* @__PURE__ */ p("tr", { children: [
2925
+ C && /* @__PURE__ */ e("td", { className: "nice-calendar__wk", children: N.find((ge) => ge != null) ? bi(
2926
+ new Date(
2927
+ b,
2928
+ P,
2929
+ N.find((ge) => ge != null)
2930
+ )
2931
+ ) : "" }),
2932
+ N.map((ge, Ke) => {
2933
+ if (ge == null)
2934
+ return /* @__PURE__ */ e("td", { className: "nice-calendar__empty-cell" }, Ke);
2935
+ const ze = ot(b, P, ge), qe = Ie(ze), Oe = ke(ze), tn = ze === y, Dn = je !== "" && ze >= je && ze <= Ze ? ` nice-calendar__day--in-range${ze === je ? " nice-calendar__day--range-start" : ""}${ze === Ze ? " nice-calendar__day--range-end" : ""}` : "";
2936
+ return /* @__PURE__ */ e(
2937
+ "td",
2938
+ {
2939
+ className: `nice-calendar__day${Oe ? " nice-calendar__day--selected" : ""}${Dn}${tn ? " nice-calendar__day--today" : ""}${qe ? " nice-calendar__day--disabled" : ""}`,
2940
+ onClick: () => !qe && He(ze),
2941
+ onMouseEnter: d && !qe ? () => Ne(ze) : void 0,
2942
+ role: "gridcell",
2943
+ "aria-selected": Oe,
2944
+ "aria-disabled": qe,
2945
+ children: Y ? Y(ze, ge) : ge
2946
+ },
2947
+ Ke
2948
+ );
2949
+ })
2950
+ ] }, u)) })
2951
+ ]
2952
+ }
2953
+ ),
2954
+ Q === "months" && /* @__PURE__ */ e("div", { className: "nice-calendar__picker-grid", children: st.map((N, u) => /* @__PURE__ */ e(
2955
+ "button",
2956
+ {
2957
+ type: "button",
2958
+ className: `nice-calendar__picker-cell${u === P && b === m.getFullYear() ? " nice-calendar__picker-cell--selected" : ""}`,
2959
+ onClick: () => Ae(u),
2960
+ children: N.slice(0, 3)
2961
+ },
2962
+ u
2963
+ )) }),
2964
+ Q === "years" && /* @__PURE__ */ e("div", { className: "nice-calendar__picker-grid", children: Array.from({ length: 12 }, (N, u) => fn - 1 + u).map((N) => /* @__PURE__ */ e(
2965
+ "button",
2966
+ {
2967
+ type: "button",
2968
+ className: `nice-calendar__picker-cell${N === b ? " nice-calendar__picker-cell--selected" : ""}${N < fn || N > fn + 9 ? " nice-calendar__picker-cell--other" : ""}`,
2969
+ onClick: () => We(N),
2970
+ children: N
2971
+ },
2972
+ N
2973
+ )) })
2974
+ ]
2975
+ }
2976
+ );
2977
+ };
2978
+ $t.displayName = "NiceCalendar";
2979
+ const Ci = {
2980
+ "date-local": { inputType: "date", localized: !0 },
2981
+ "date-utc": { inputType: "date", localized: !1 },
2982
+ "datetime-local": { inputType: "datetime-local", localized: !0 },
2983
+ "datetime-utc": { inputType: "datetime-local", localized: !1 },
2984
+ "month-local": { inputType: "month", localized: !0 },
2985
+ "month-utc": { inputType: "month", localized: !1 },
2986
+ week: { inputType: "week", localized: !1 },
2987
+ time: { inputType: "time", localized: !1 }
2988
+ }, dt = {
2989
+ date: "yyyy-MM-dd",
2990
+ "datetime-local": "yyyy-MM-ddTHH:mm",
2991
+ month: "yyyy-MM",
2992
+ week: "yyyy-Www",
2993
+ time: "HH:mm"
2994
+ }, Ni = {
2995
+ "yyyy-MM-dd": "YYYY-MM-DD",
2996
+ "yyyy-MM-ddTHH:mm": "YYYY-MM-DDTHH:MM",
2997
+ "yyyy-MM": "YYYY-MM",
2998
+ "yyyy-Www": "YYYY-Www",
2999
+ "HH:mm": "HH:MM"
3000
+ };
3001
+ function On(n) {
3002
+ const i = (n || "").toLowerCase().replace("_", "-"), t = i.split("-")[0], r = {
3003
+ // dd.MM.yyyy (dot)
3004
+ pl: "dd.MM.yyyy",
3005
+ "pl-pl": "dd.MM.yyyy",
3006
+ de: "dd.MM.yyyy",
3007
+ "de-de": "dd.MM.yyyy",
3008
+ "de-at": "dd.MM.yyyy",
3009
+ "de-ch": "dd.MM.yyyy",
3010
+ cs: "dd.MM.yyyy",
3011
+ "cs-cz": "dd.MM.yyyy",
3012
+ sk: "dd.MM.yyyy",
3013
+ "sk-sk": "dd.MM.yyyy",
3014
+ ru: "dd.MM.yyyy",
3015
+ "ru-ru": "dd.MM.yyyy",
3016
+ fi: "dd.MM.yyyy",
3017
+ "fi-fi": "dd.MM.yyyy",
3018
+ no: "dd.MM.yyyy",
3019
+ nb: "dd.MM.yyyy",
3020
+ nn: "dd.MM.yyyy",
3021
+ da: "dd.MM.yyyy",
3022
+ "da-dk": "dd.MM.yyyy",
3023
+ tr: "dd.MM.yyyy",
3024
+ "tr-tr": "dd.MM.yyyy",
3025
+ sl: "dd.MM.yyyy",
3026
+ hr: "dd.MM.yyyy",
3027
+ sr: "dd.MM.yyyy",
3028
+ ro: "dd.MM.yyyy",
3029
+ bg: "dd.MM.yyyy",
3030
+ uk: "dd.MM.yyyy",
3031
+ is: "dd.MM.yyyy",
3032
+ et: "dd.MM.yyyy",
3033
+ lv: "dd.MM.yyyy",
3034
+ lt: "dd.MM.yyyy",
3035
+ // dd/MM/yyyy (slash)
3036
+ "en-gb": "dd/MM/yyyy",
3037
+ "en-au": "dd/MM/yyyy",
3038
+ "en-ie": "dd/MM/yyyy",
3039
+ "en-nz": "dd/MM/yyyy",
3040
+ "en-in": "dd/MM/yyyy",
3041
+ fr: "dd/MM/yyyy",
3042
+ "fr-fr": "dd/MM/yyyy",
3043
+ "fr-be": "dd/MM/yyyy",
3044
+ es: "dd/MM/yyyy",
3045
+ "es-es": "dd/MM/yyyy",
3046
+ pt: "dd/MM/yyyy",
3047
+ "pt-pt": "dd/MM/yyyy",
3048
+ "pt-br": "dd/MM/yyyy",
3049
+ it: "dd/MM/yyyy",
3050
+ "it-it": "dd/MM/yyyy",
3051
+ nl: "dd-MM-yyyy",
3052
+ "nl-nl": "dd-MM-yyyy",
3053
+ "nl-be": "dd/MM/yyyy",
3054
+ el: "dd/MM/yyyy",
3055
+ hu: "yyyy.MM.dd",
3056
+ // MM/dd/yyyy
3057
+ en: "MM/dd/yyyy",
3058
+ "en-us": "MM/dd/yyyy",
3059
+ "en-ca": "MM/dd/yyyy",
3060
+ // yyyy-MM-dd / yyyy/MM/dd
3061
+ ja: "yyyy/MM/dd",
3062
+ "ja-jp": "yyyy/MM/dd",
3063
+ ko: "yyyy.MM.dd",
3064
+ "ko-kr": "yyyy.MM.dd",
3065
+ zh: "yyyy/MM/dd",
3066
+ "zh-cn": "yyyy/MM/dd",
3067
+ "zh-tw": "yyyy/MM/dd",
3068
+ sv: "yyyy-MM-dd",
3069
+ "sv-se": "yyyy-MM-dd"
3070
+ };
3071
+ if (r[i])
3072
+ return r[i];
3073
+ if (r[t])
3074
+ return r[t];
3075
+ try {
3076
+ const o = new Intl.DateTimeFormat(n, {
3077
+ year: "numeric",
3078
+ month: "2-digit",
3079
+ day: "2-digit"
3080
+ }).formatToParts(new Date(2024, 0, 15));
3081
+ let s = "";
3082
+ for (const C of o)
3083
+ if (C.type === "day")
3084
+ s += "dd";
3085
+ else if (C.type === "month")
3086
+ s += "MM";
3087
+ else if (C.type === "year")
3088
+ s += "yyyy";
3089
+ else if (C.type === "literal") {
3090
+ const w = C.value.replace(/[\u00A0\u202F\u2009]/g, " ").trim();
3091
+ s += w || ".";
3092
+ }
3093
+ return !/y/.test(s) || !/M/.test(s) || !/d/.test(s) ? "yyyy-MM-dd" : s;
3094
+ } catch {
3095
+ return "yyyy-MM-dd";
3096
+ }
3097
+ }
3098
+ function Mi(n) {
3099
+ const t = On(n).replace(/dd[^\w]*/g, "").replace(/[^\w]*dd/g, "");
3100
+ return !/y/.test(t) || !/M/.test(t) ? "yyyy-MM" : t;
3101
+ }
3102
+ function wt() {
3103
+ if (typeof document < "u") {
3104
+ const n = document.documentElement?.lang;
3105
+ if (n && /^[a-zA-Z]{2,}/.test(n))
3106
+ return n;
3107
+ }
3108
+ return typeof navigator < "u" && navigator.language ? navigator.language : "en-US";
3109
+ }
3110
+ function ki(n, i, t, r = !1) {
3111
+ dt[n] || (n = "date");
3112
+ let a = dt[n];
3113
+ r && (n === "datetime-local" || n === "time") && (a = a.replace("HH:mm", "HH:mm:ss"));
3114
+ let o = a;
3115
+ i && (n === "date" || n === "datetime-local" || n === "month") && (n === "date" ? o = On(t) : n === "datetime-local" ? o = `${On(t)} HH:mm${r ? ":ss" : ""}` : o = Mi(t)), n === "datetime-local" && (o = o.replace("T", " · "));
3116
+ const s = Ni[o] ?? o.replace(/y/g, "Y").replace(/M/g, "M").replace(/d/g, "D").replace(/H/g, "H").replace(/m/g, "M").replace(/s/g, "S");
3117
+ return { displayTpl: o, isoTpl: a, placeholder: s };
3118
+ }
3119
+ const $i = /* @__PURE__ */ new Set(["y", "M", "d", "H", "m", "s", "w"]);
3120
+ function sn(n) {
3121
+ return $i.has(n);
3122
+ }
3123
+ function et(n) {
3124
+ let i = 0;
3125
+ for (const t of n)
3126
+ sn(t) && i++;
3127
+ return i;
3128
+ }
3129
+ function nt(n, i) {
3130
+ let t = "", r = 0;
3131
+ for (const a of n)
3132
+ if (sn(a)) {
3133
+ if (r >= i.length)
3134
+ break;
3135
+ t += i[r++];
3136
+ } else {
3137
+ if (r === 0)
3138
+ break;
3139
+ r >= i.length, t += a;
3140
+ }
3141
+ return t;
3142
+ }
3143
+ function wi(n, i, t) {
3144
+ if (t.length === 0)
3145
+ return "";
3146
+ const r = {};
3147
+ let a = 0;
3148
+ for (const C of n)
3149
+ sn(C) && (a >= t.length ? (r[C] ?? (r[C] = [])).push("") : (r[C] ?? (r[C] = [])).push(t[a]), a++);
3150
+ const o = {};
3151
+ let s = "";
3152
+ for (const C of i)
3153
+ if (sn(C)) {
3154
+ const w = r[C] ?? [], S = o[C] ?? 0;
3155
+ s += w[S] ?? "", o[C] = S + 1;
3156
+ }
3157
+ return s;
3158
+ }
3159
+ function yn(n, i, t) {
3160
+ if (t.length === 0)
3161
+ return "";
3162
+ const r = {};
3163
+ let a = 0;
3164
+ for (const C of i)
3165
+ sn(C) && ((r[C] ?? (r[C] = [])).push(t[a] ?? ""), a++);
3166
+ const o = {};
3167
+ let s = "";
3168
+ for (const C of n)
3169
+ if (sn(C)) {
3170
+ const w = r[C] ?? [], S = o[C] ?? 0;
3171
+ s += w[S] ?? "", o[C] = S + 1;
3172
+ }
3173
+ return s.replace(/\s+$/, "");
3174
+ }
3175
+ function ut(n, i, t) {
3176
+ const r = et(i);
3177
+ if (t.length < r)
3178
+ return "";
3179
+ const a = wi(n, i, t);
3180
+ if (a.length < r)
3181
+ return "";
3182
+ let o = "", s = 0;
3183
+ for (const C of i)
3184
+ sn(C) ? o += a[s++] : o += C;
3185
+ return o;
3186
+ }
3187
+ function pt(n, i, t) {
3188
+ return n && (i && n < i ? i : t && n > t ? t : n);
3189
+ }
3190
+ function Se(n) {
3191
+ return n.toString().padStart(2, "0");
3192
+ }
3193
+ function xn(n) {
3194
+ const i = /(\d{2}):(\d{2})(?::(\d{2}))?$/.exec(n);
3195
+ return i ? { hours: Number(i[1]), minutes: Number(i[2]), seconds: Number(i[3] ?? 0) } : null;
3196
+ }
3197
+ function ft(n, i, t, r, a) {
3198
+ const o = a ? `${Se(i)}:${Se(t)}:${Se(r)}` : `${Se(i)}:${Se(t)}`;
3199
+ return n.replace(/\d{2}:\d{2}(?::\d{2})?$/, o);
3200
+ }
3201
+ function Tt(n, i) {
3202
+ if (n <= 0)
3203
+ return i;
3204
+ const t = Math.floor(n / 864e5), r = `${Se(Math.floor(n % 864e5 / 36e5))}:${Se(Math.floor(n % 36e5 / 6e4))}:${Se(Math.floor(n % 6e4 / 1e3))}`;
3205
+ return t > 0 ? `${t}d ${r}` : r;
3206
+ }
3207
+ function Ti(n, i) {
3208
+ if (n <= 0)
3209
+ return i;
3210
+ const t = Math.floor(n / 864e5), r = Math.floor(n % 864e5 / 36e5), a = Math.floor(n % 36e5 / 6e4), o = Math.floor(n % 6e4 / 1e3), s = [];
3211
+ return t && s.push(`${t}d`), (t || r) && s.push(`${r}h`), (t || r || a) && s.push(`${a}m`), s.push(`${o}s`), s.join(" ");
3212
+ }
3213
+ function Di(n, i) {
3214
+ if (n <= 0)
3215
+ return i;
3216
+ const t = Math.floor(n / 1e3), r = Math.floor(t / 3600), a = Math.floor(t % 3600 / 60), o = t % 60;
3217
+ return r > 0 ? `${Se(r)}:${Se(a)}:${Se(o)}` : `${Se(a)}:${Se(o)}`;
3218
+ }
3219
+ function xi(n, i) {
3220
+ if (n <= 0)
3221
+ return i;
3222
+ const t = Math.floor(n / 1e3), r = Math.floor(t / 86400);
3223
+ if (r)
3224
+ return `${r}d`;
3225
+ const a = Math.floor(t / 3600);
3226
+ if (a)
3227
+ return `${a}h`;
3228
+ const o = Math.floor(t / 60);
3229
+ return o ? `${o}m` : `${t}s`;
3230
+ }
3231
+ function Si(n, i) {
3232
+ if (n <= 0)
3233
+ return i;
3234
+ const t = Math.floor(n / 1e3), r = Math.floor(t / 86400), a = Math.floor(t % 86400 / 3600), o = Math.floor(t % 3600 / 60), s = [];
3235
+ return r && s.push(`${r} ${r === 1 ? "day" : "days"}`), a && s.push(`${a} ${a === 1 ? "hour" : "hours"}`), o && s.push(`${o} ${o === 1 ? "minute" : "minutes"}`), s.length ? s.join(", ") : "less than a minute";
3236
+ }
3237
+ const Ai = {
3238
+ verbose: Tt,
3239
+ compact: Ti,
3240
+ short: Di,
3241
+ minimal: xi,
3242
+ words: Si
3243
+ };
3244
+ function Ui(n, i, t) {
3245
+ const r = n ? xn(n) : null, { hours: a, minutes: o, seconds: s } = r ?? { hours: 0, minutes: 0, seconds: 0 }, C = new Date(t);
3246
+ if (i != null) {
3247
+ const S = typeof i == "string" ? new Date(i) : new Date(i.getTime());
3248
+ if (!Number.isNaN(S.getTime()))
3249
+ return S.setHours(a, o, s, 0), S;
3250
+ }
3251
+ if (n && /^\d{4}-\d{2}-\d{2}T/.test(n)) {
3252
+ const S = new Date(n);
3253
+ if (!Number.isNaN(S.getTime()))
3254
+ return S;
3255
+ }
3256
+ const w = new Date(C);
3257
+ return w.setHours(a, o, s, 0), w.getTime() <= C.getTime() && w.setDate(w.getDate() + 1), w;
3258
+ }
3259
+ function Tn(n, i) {
3260
+ if (!n)
3261
+ return "";
3262
+ const t = n.replace(/[^0-9]/g, ""), r = et(i);
3263
+ return t.slice(0, r);
3264
+ }
3265
+ function ln(n, i, t) {
3266
+ const r = nt(n, t);
3267
+ let a = 0;
3268
+ const o = Math.min(i, r.length);
3269
+ for (let s = 0; s < o; s++)
3270
+ sn(n[s]) && a++;
3271
+ return Math.min(a, t.length);
3272
+ }
3273
+ function Ri(n, i, t) {
3274
+ if (t <= 0)
3275
+ return 0;
3276
+ const r = nt(n, i);
3277
+ let a = 0;
3278
+ for (let o = 0; o < r.length; o++)
3279
+ if (sn(n[o]) && (a++, a === t)) {
3280
+ let s = o + 1;
3281
+ for (; s < r.length && !sn(n[s]); )
3282
+ s++;
3283
+ return s;
3284
+ }
3285
+ return r.length;
3286
+ }
3287
+ const Kn = 40;
3288
+ function Ii() {
3289
+ return typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
3290
+ }
3291
+ const Ei = ({
3292
+ part: n,
3293
+ label: i,
3294
+ value: t,
3295
+ max: r,
3296
+ step: a,
3297
+ onPick: o,
3298
+ onStep: s,
3299
+ startHold: C,
3300
+ stopHold: w
3301
+ }) => {
3302
+ const S = Ce(null), re = Ce(!1), D = Ce(null), T = Ce(null), Z = be(() => {
3303
+ const M = [], L = a > 0 ? a : 1;
3304
+ for (let z = 0; z <= r; z += L)
3305
+ M.push(z);
3306
+ return M;
3307
+ }, [r, a]), ae = Math.max(
3308
+ 0,
3309
+ Math.min(Z.length - 1, Math.round(t / (a > 0 ? a : 1)))
3310
+ ), G = Z.length, U = be(() => [...Z, ...Z, ...Z], [Z]), k = G + ae, ne = Ce(!1);
3311
+ ht(() => {
3312
+ const M = S.current;
3313
+ if (!M)
3314
+ return;
3315
+ const L = k * Kn;
3316
+ if (Math.abs(M.scrollTop - L) < 1)
3317
+ return;
3318
+ const z = Math.abs(M.scrollTop / Kn - k);
3319
+ re.current = !0, D.current && (clearTimeout(D.current), D.current = null);
3320
+ const R = ne.current && z <= 3 && !Ii();
3321
+ M.scrollTo({ top: L, behavior: R ? "smooth" : "instant" }), ne.current = !0, T.current && clearTimeout(T.current), T.current = setTimeout(() => {
3322
+ re.current = !1;
3323
+ }, 380);
3324
+ }, [k]), Fe(
3325
+ () => () => {
3326
+ D.current && clearTimeout(D.current), T.current && clearTimeout(T.current);
3327
+ },
3328
+ []
3329
+ );
3330
+ const X = () => {
3331
+ re.current || (D.current && clearTimeout(D.current), D.current = setTimeout(() => {
3332
+ const M = S.current;
3333
+ if (!M)
3334
+ return;
3335
+ const L = Math.round(M.scrollTop / Kn), z = Z[(L % G + G) % G];
3336
+ z !== t && o(z);
3337
+ }, 110));
3338
+ }, Y = (M) => {
3339
+ M.key === "ArrowUp" ? (M.preventDefault(), s(-1)) : M.key === "ArrowDown" && (M.preventDefault(), s(1));
3340
+ }, ue = (M) => {
3341
+ const L = M.replace(/\D/g, "");
3342
+ if (!L)
3343
+ return;
3344
+ const z = Number(L.slice(-2));
3345
+ o(Math.max(0, Math.min(r, z)));
3346
+ }, oe = (M) => {
3347
+ S.current && S.current.scrollBy({ top: M.deltaY });
3348
+ };
3349
+ return /* @__PURE__ */ p("div", { className: "nice-datetime-popup__spinner", role: "group", "aria-label": i, children: [
3350
+ /* @__PURE__ */ e(
3351
+ "div",
3352
+ {
3353
+ ref: S,
3354
+ className: "nice-datetime-popup__spin-column",
3355
+ role: "listbox",
3356
+ tabIndex: -1,
3357
+ "aria-label": i,
3358
+ "aria-activedescendant": `${n}-opt-${k}`,
3359
+ onScroll: X,
3360
+ children: U.map((M, L) => /* @__PURE__ */ e(
3361
+ "button",
3362
+ {
3363
+ type: "button",
3364
+ id: `${n}-opt-${L}`,
3365
+ role: "option",
3366
+ "aria-selected": L === k,
3367
+ className: `nice-datetime-popup__spin-item${L === k ? " is-selected" : ""}`,
3368
+ onClick: () => o(M),
3369
+ tabIndex: -1,
3370
+ children: Se(M)
3371
+ },
3372
+ L
3373
+ ))
3374
+ }
3375
+ ),
3376
+ /* @__PURE__ */ p("div", { className: "nice-datetime-popup__spin-center", onWheel: oe, children: [
3377
+ /* @__PURE__ */ e(
3378
+ "button",
3379
+ {
3380
+ type: "button",
3381
+ className: "nice-datetime-popup__spin-btn",
3382
+ onClick: () => s(-1),
3383
+ onPointerDown: () => C(() => s(-1)),
3384
+ onPointerUp: w,
3385
+ onPointerLeave: w,
3386
+ "aria-label": `${i} -`,
3387
+ tabIndex: -1,
3388
+ children: /* @__PURE__ */ e(Le, { name: "chevron-up", size: 14 })
3389
+ }
3390
+ ),
3391
+ /* @__PURE__ */ e(
3392
+ "input",
3393
+ {
3394
+ className: "nice-datetime-popup__spin-value",
3395
+ inputMode: "numeric",
3396
+ "aria-label": i,
3397
+ value: Se(t),
3398
+ onFocus: (M) => M.currentTarget.select(),
3399
+ onChange: (M) => ue(M.target.value),
3400
+ onKeyDown: Y
3401
+ }
3402
+ ),
3403
+ /* @__PURE__ */ e(
3404
+ "button",
3405
+ {
3406
+ type: "button",
3407
+ className: "nice-datetime-popup__spin-btn",
3408
+ onClick: () => s(1),
3409
+ onPointerDown: () => C(() => s(1)),
3410
+ onPointerUp: w,
3411
+ onPointerLeave: w,
3412
+ "aria-label": `${i} +`,
3413
+ tabIndex: -1,
3414
+ children: /* @__PURE__ */ e(Le, { name: "chevron-down", size: 14 })
3415
+ }
3416
+ )
3417
+ ] })
3418
+ ] });
3419
+ }, Fi = ({ hours: n, minutes: i, minuteStep: t, onChange: r, t: a }) => {
3420
+ const [o, s] = we("hours"), C = Ce(null), w = 100, S = 78, re = 52, D = 62, T = 65, Z = 18, ae = n >= 12 ? "PM" : "AM", G = n % 12 === 0 ? 12 : n % 12, U = (g, f) => {
3421
+ const m = (g - 90) * Math.PI / 180;
3422
+ return { x: w + f * Math.cos(m), y: w + f * Math.sin(m) };
3423
+ }, k = (g) => {
3424
+ const f = ae === "PM" ? g % 12 + 12 : g % 12;
3425
+ r(f, i);
3426
+ }, ne = (g) => {
3427
+ const f = t && t > 1 ? t : 1, m = Math.round(g / f) * f % 60;
3428
+ r(n, m);
3429
+ }, X = (g) => {
3430
+ if (g === ae)
3431
+ return;
3432
+ const f = g === "PM" ? n + 12 : n - 12;
3433
+ r((f % 24 + 24) % 24, i);
3434
+ }, Y = (g) => {
3435
+ const f = g.currentTarget.getBoundingClientRect(), m = (g.clientX - f.left) / f.width * 200 - w, W = (g.clientY - f.top) / f.height * 200 - w;
3436
+ let O = Math.atan2(W, m) * 180 / Math.PI + 90;
3437
+ return O < 0 && (O += 360), { ang: O, radius: Math.hypot(m, W) };
3438
+ }, ue = (g, f) => {
3439
+ if (g === "hours") {
3440
+ const m = Math.round(f / 30) % 12;
3441
+ k(m === 0 ? 12 : m);
3442
+ } else
3443
+ ne(Math.round(f / 6) % 60);
3444
+ }, oe = (g) => {
3445
+ const { ang: f, radius: m } = Y(g);
3446
+ if (m < Z)
3447
+ return;
3448
+ const W = m > T ? "hours" : "minutes";
3449
+ C.current = W, s(W), g.currentTarget.setPointerCapture?.(g.pointerId), ue(W, f);
3450
+ }, M = (g) => {
3451
+ const f = C.current;
3452
+ f && ue(f, Y(g).ang);
3453
+ }, L = (g) => {
3454
+ C.current && (C.current = null, g.currentTarget.releasePointerCapture?.(g.pointerId));
3455
+ }, z = Array.from({ length: 12 }, (g, f) => f + 1), R = t && t > 1 ? t : 5, J = [];
3456
+ for (let g = 0; g < 60; g += R)
3457
+ J.push(g);
3458
+ const x = t && t > 1 ? t : 1, te = Math.round(i / x) * x % 60, I = o === "hours", B = U(G % 12 * 30, S), pe = U(te * 6, re);
3459
+ return /* @__PURE__ */ p("div", { className: "nice-datetime-popup__clock", children: [
3460
+ /* @__PURE__ */ p("div", { className: "nice-datetime-popup__clock-readout", children: [
3461
+ /* @__PURE__ */ e(
3462
+ "button",
3463
+ {
3464
+ type: "button",
3465
+ className: `nice-datetime-popup__clock-seg${o === "hours" ? " nice-datetime-popup__clock-seg--active" : ""}`,
3466
+ onClick: () => s("hours"),
3467
+ "aria-label": a("datetime.hours", "Hours"),
3468
+ children: Se(G)
3469
+ }
3470
+ ),
3471
+ /* @__PURE__ */ e("span", { className: "nice-datetime-popup__clock-colon", children: ":" }),
3472
+ /* @__PURE__ */ e(
3473
+ "button",
3474
+ {
3475
+ type: "button",
3476
+ className: `nice-datetime-popup__clock-seg${o === "minutes" ? " nice-datetime-popup__clock-seg--active" : ""}`,
3477
+ onClick: () => s("minutes"),
3478
+ "aria-label": a("datetime.minutes", "Minutes"),
3479
+ children: Se(i)
3480
+ }
3481
+ ),
3482
+ /* @__PURE__ */ p("div", { className: "nice-datetime-popup__clock-ampm", role: "group", children: [
3483
+ /* @__PURE__ */ e(
3484
+ "button",
3485
+ {
3486
+ type: "button",
3487
+ className: `nice-datetime-popup__clock-period${ae === "AM" ? " nice-datetime-popup__clock-period--active" : ""}`,
3488
+ onClick: () => X("AM"),
3489
+ "aria-pressed": ae === "AM",
3490
+ children: "AM"
3491
+ }
3492
+ ),
3493
+ /* @__PURE__ */ e(
3494
+ "button",
3495
+ {
3496
+ type: "button",
3497
+ className: `nice-datetime-popup__clock-period${ae === "PM" ? " nice-datetime-popup__clock-period--active" : ""}`,
3498
+ onClick: () => X("PM"),
3499
+ "aria-pressed": ae === "PM",
3500
+ children: "PM"
3501
+ }
3502
+ )
3503
+ ] })
3504
+ ] }),
3505
+ /* @__PURE__ */ p(
3506
+ "svg",
3507
+ {
3508
+ viewBox: "0 0 200 200",
3509
+ className: "nice-datetime-popup__clock-face",
3510
+ onPointerDown: oe,
3511
+ onPointerMove: M,
3512
+ onPointerUp: L,
3513
+ onPointerCancel: L,
3514
+ role: "img",
3515
+ "aria-label": a("datetime.clockMode", "Analog clock"),
3516
+ children: [
3517
+ /* @__PURE__ */ e("circle", { cx: w, cy: w, r: 96, className: "nice-datetime-popup__clock-bg" }),
3518
+ J.map((g) => {
3519
+ const f = U(g * 6, D);
3520
+ return /* @__PURE__ */ e(
3521
+ "circle",
3522
+ {
3523
+ cx: f.x,
3524
+ cy: f.y,
3525
+ r: g === te ? 2.6 : 1.5,
3526
+ className: `nice-datetime-popup__clock-tick${g === te ? " nice-datetime-popup__clock-tick--active" : ""}`
3527
+ },
3528
+ `tick-${g}`
3529
+ );
3530
+ }),
3531
+ /* @__PURE__ */ e(
3532
+ "line",
3533
+ {
3534
+ x1: w,
3535
+ y1: w,
3536
+ x2: B.x,
3537
+ y2: B.y,
3538
+ className: `nice-datetime-popup__clock-hand nice-datetime-popup__clock-hand--hour${I ? " nice-datetime-popup__clock-hand--active" : ""}`
3539
+ }
3540
+ ),
3541
+ /* @__PURE__ */ e(
3542
+ "line",
3543
+ {
3544
+ x1: w,
3545
+ y1: w,
3546
+ x2: pe.x,
3547
+ y2: pe.y,
3548
+ className: `nice-datetime-popup__clock-hand nice-datetime-popup__clock-hand--minute${I ? "" : " nice-datetime-popup__clock-hand--active"}`
3549
+ }
3550
+ ),
3551
+ /* @__PURE__ */ e("circle", { cx: B.x, cy: B.y, r: 15, className: "nice-datetime-popup__clock-knob" }),
3552
+ /* @__PURE__ */ e(
3553
+ "circle",
3554
+ {
3555
+ cx: pe.x,
3556
+ cy: pe.y,
3557
+ r: 12,
3558
+ className: "nice-datetime-popup__clock-knob nice-datetime-popup__clock-knob--minute"
3559
+ }
3560
+ ),
3561
+ /* @__PURE__ */ e("circle", { cx: w, cy: w, r: 4, className: "nice-datetime-popup__clock-center" }),
3562
+ z.map((g) => {
3563
+ const f = U(g * 30, S);
3564
+ return /* @__PURE__ */ e(
3565
+ "text",
3566
+ {
3567
+ x: f.x,
3568
+ y: f.y,
3569
+ className: `nice-datetime-popup__clock-num${g === G ? " nice-datetime-popup__clock-num--active" : ""}`,
3570
+ textAnchor: "middle",
3571
+ dominantBaseline: "central",
3572
+ children: g
3573
+ },
3574
+ `h-${g}`
3575
+ );
3576
+ }),
3577
+ J.map((g) => {
3578
+ const f = U(g * 6, re);
3579
+ return /* @__PURE__ */ e(
3580
+ "text",
3581
+ {
3582
+ x: f.x,
3583
+ y: f.y,
3584
+ className: `nice-datetime-popup__clock-num nice-datetime-popup__clock-num--minute${g === te ? " nice-datetime-popup__clock-num--active" : ""}`,
3585
+ textAnchor: "middle",
3586
+ dominantBaseline: "central",
3587
+ children: Se(g)
3588
+ },
3589
+ `m-${g}`
3590
+ );
3591
+ })
3592
+ ]
3593
+ }
3594
+ )
3595
+ ] });
3596
+ }, Sn = bn(
3597
+ ({
3598
+ label: n,
3599
+ helperText: i,
3600
+ error: t,
3601
+ required: r,
3602
+ disabled: a,
3603
+ readOnly: o,
3604
+ size: s = "md",
3605
+ name: C,
3606
+ id: w,
3607
+ className: S,
3608
+ style: re,
3609
+ accessMode: D,
3610
+ value: T,
3611
+ onChange: Z,
3612
+ onBlur: ae,
3613
+ onKeyDown: G,
3614
+ min: U,
3615
+ max: k,
3616
+ type: ne,
3617
+ dateFormatPreset: X,
3618
+ submitOnEnter: Y,
3619
+ onSubmit: ue,
3620
+ showKeyboardHints: oe,
3621
+ displayStyle: M,
3622
+ labelPlacement: L,
3623
+ errorPlacement: z,
3624
+ loading: R,
3625
+ labelWidth: J,
3626
+ controlWidth: x,
3627
+ placeholder: te,
3628
+ clearable: I = !1,
3629
+ showPickerButton: B = !0,
3630
+ displayLocale: pe,
3631
+ keyboardShortcuts: g = !0,
3632
+ showSeconds: f = !1,
3633
+ minuteStep: m = 1,
3634
+ showNow: W = !1,
3635
+ hourFormat: O = "24",
3636
+ timeSelectorType: v = "spinners",
3637
+ targetDate: b,
3638
+ onTargetChange: q,
3639
+ countdown: P = !1,
3640
+ countdownFormat: ce = "verbose",
3641
+ formatCountdown: Q,
3642
+ countdownLabel: le,
3643
+ countdownInterval: de = 1e3,
3644
+ countdownDoneText: fe
3645
+ }, ie) => {
3646
+ const E = qn("input", M), Ne = Un("input", M), j = dn(D, w), _e = j === "hidden";
3647
+ j === "disabled" && (a = !0), j === "readOnly" && (o = !0);
3648
+ const { t: V } = en(), Te = un(w), h = Ce(null), $ = Ce(null), H = Ce(null), Ie = Ce(null), [me, y] = we(!1), [d, ke] = we(null), [je, Ze] = we(""), [He, ee] = we(v);
3649
+ Fe(() => {
3650
+ ee(v);
3651
+ }, [v]);
3652
+ const We = Vt(Bt)?.portalTarget ?? (typeof document < "u" ? document.body : null), { start: nn, stop: pn } = Pt(), Je = X ? Ci[X] : null, De = Je?.inputType ?? ne ?? "date", fn = Je?.localized ?? !1, N = pe ?? wt(), u = be(
3653
+ () => ki(De, fn, N, f),
3654
+ [De, fn, N, f]
3655
+ ), ge = be(() => et(u.isoTpl), [u.isoTpl]), [Ke, ze] = we(() => {
3656
+ const c = Tn(T, u.isoTpl);
3657
+ return yn(u.displayTpl, u.isoTpl, c);
3658
+ }), qe = Ce(Ke);
3659
+ Fe(() => {
3660
+ qe.current = Ke;
3661
+ }, [Ke]);
3662
+ const Oe = Ce(T ?? ""), tn = Ce(null);
3663
+ Fe(() => {
3664
+ const c = T ?? "";
3665
+ if (c === Oe.current)
3666
+ return;
3667
+ const _ = Tn(c, u.isoTpl), A = yn(u.displayTpl, u.isoTpl, _);
3668
+ ze(A), Oe.current = c;
3669
+ }, [T, u.displayTpl, u.isoTpl]), Fe(() => {
3670
+ const c = Tn(T, u.isoTpl);
3671
+ ze(yn(u.displayTpl, u.isoTpl, c));
3672
+ }, [u.displayTpl, u.isoTpl]), Fe(() => {
3673
+ if (tn.current == null)
3674
+ return;
3675
+ const c = tn.current;
3676
+ tn.current = null;
3677
+ const _ = h.current;
3678
+ if (_ && document.activeElement === _)
3679
+ try {
3680
+ _.setSelectionRange(c, c);
3681
+ } catch {
3682
+ }
3683
+ });
3684
+ const Rn = be(
3685
+ () => nt(u.displayTpl, Ke),
3686
+ [u.displayTpl, Ke]
3687
+ ), Dn = te ?? u.placeholder, zn = Math.max(u.displayTpl.length + 1, 9), In = Ht({
3688
+ enabled: Y,
3689
+ onSubmit: ue
3690
+ }), Pe = F(
3691
+ (c, _) => {
3692
+ const A = c.slice(0, ge);
3693
+ qe.current = A, ze(A), tn.current = Ri(
3694
+ u.displayTpl,
3695
+ A,
3696
+ Math.max(0, Math.min(A.length, _))
3697
+ );
3698
+ const ye = pt(ut(u.displayTpl, u.isoTpl, A), U, k);
3699
+ ye !== Oe.current && (Oe.current = ye, Z?.(ye));
3700
+ },
3701
+ [Z, u.displayTpl, u.isoTpl, ge, U, k]
3702
+ ), cn = F(
3703
+ (c) => {
3704
+ const _ = pt(c, U, k), A = Tn(_, u.isoTpl);
3705
+ Oe.current = _, ze(yn(u.displayTpl, u.isoTpl, A)), Z?.(_);
3706
+ },
3707
+ [Z, u.displayTpl, u.isoTpl, U, k]
3708
+ ), rn = De === "time" || De === "datetime-local", Cn = F(
3709
+ () => ut(u.displayTpl, u.isoTpl, qe.current),
3710
+ [u.displayTpl, u.isoTpl]
3711
+ ), Bn = F(() => {
3712
+ if (a || o)
3713
+ return;
3714
+ const c = Cn(), _ = c ? xn(c) : null;
3715
+ if (!_)
3716
+ return;
3717
+ const A = _.hours >= 12 ? _.hours - 12 : _.hours + 12;
3718
+ cn(ft(c, A, _.minutes, _.seconds, f));
3719
+ }, [a, o, Cn, cn, f]), Pn = (() => {
3720
+ const c = xn(T ?? "");
3721
+ return c && c.hours >= 12 ? "PM" : "AM";
3722
+ })(), Hn = F(
3723
+ (c) => {
3724
+ if (In(c), o || a) {
3725
+ G?.(c);
3726
+ return;
3727
+ }
3728
+ const _ = c.key;
3729
+ if (c.ctrlKey || c.metaKey || c.altKey) {
3730
+ G?.(c);
3731
+ return;
3732
+ }
3733
+ if (rn && (_ === "ArrowUp" || _ === "ArrowDown")) {
3734
+ const ve = Cn(), Re = ve ? xn(ve) : null;
3735
+ if (Re) {
3736
+ c.preventDefault();
3737
+ const Me = _ === "ArrowUp" ? 1 : -1;
3738
+ let { minutes: Ye, seconds: Qe } = Re;
3739
+ f ? Qe = ((Qe + Me) % 60 + 60) % 60 : Ye = ((Ye + Me * m) % 60 + 60) % 60, cn(ft(ve, Re.hours, Ye, Qe, f)), G?.(c);
3740
+ return;
3741
+ }
3742
+ }
3743
+ const A = qe.current;
3744
+ if (_ === "Escape" && A.length > 0) {
3745
+ c.preventDefault(), Pe("", 0), G?.(c);
3746
+ return;
3747
+ }
3748
+ if (g && (u.isoTpl === "yyyy-MM-dd" || u.isoTpl === "yyyy-MM-ddTHH:mm" || u.isoTpl === "yyyy-MM")) {
3749
+ const ve = (Me) => {
3750
+ const Ye = String(Me.getFullYear()).padStart(4, "0"), Qe = String(Me.getMonth() + 1).padStart(2, "0"), $n = String(Me.getDate()).padStart(2, "0");
3751
+ let wn = "";
3752
+ if (u.isoTpl === "yyyy-MM")
3753
+ wn = `${Ye}-${Qe}`;
3754
+ else if (u.isoTpl === "yyyy-MM-dd")
3755
+ wn = `${Ye}-${Qe}-${$n}`;
3756
+ else {
3757
+ const Rt = String(Me.getHours()).padStart(2, "0"), It = String(Me.getMinutes()).padStart(2, "0");
3758
+ wn = `${Ye}-${Qe}-${$n}T${Rt}:${It}`;
3759
+ }
3760
+ cn(wn);
3761
+ }, Re = () => {
3762
+ if (T && /^\d{4}-\d{2}/.test(T)) {
3763
+ const Me = new Date(T);
3764
+ if (!Number.isNaN(Me.getTime()))
3765
+ return Me;
3766
+ }
3767
+ return /* @__PURE__ */ new Date();
3768
+ };
3769
+ if (_ === "t" || _ === "T") {
3770
+ c.preventDefault(), ve(/* @__PURE__ */ new Date()), G?.(c);
3771
+ return;
3772
+ }
3773
+ if (_ === "+" || _ === "=" || _ === "-") {
3774
+ c.preventDefault();
3775
+ const Me = _ === "-" ? -1 : 1, Ye = Re();
3776
+ Ye.setDate(Ye.getDate() + Me), ve(Ye), G?.(c);
3777
+ return;
3778
+ }
3779
+ if (_ === "m" || _ === "M") {
3780
+ c.preventDefault();
3781
+ const Me = Re();
3782
+ Me.setMonth(Me.getMonth() + (_ === "M" ? -1 : 1)), ve(Me), G?.(c);
3783
+ return;
3784
+ }
3785
+ if (_ === "y" || _ === "Y") {
3786
+ c.preventDefault();
3787
+ const Me = Re();
3788
+ Me.setFullYear(Me.getFullYear() + (_ === "Y" ? -1 : 1)), ve(Me), G?.(c);
3789
+ return;
3790
+ }
3791
+ }
3792
+ const ye = c.currentTarget, Ue = ye.selectionStart ?? 0, Ge = ye.selectionEnd ?? 0;
3793
+ if (/^[0-9]$/.test(_)) {
3794
+ c.preventDefault();
3795
+ const ve = ln(u.displayTpl, Ue, A), Re = ln(u.displayTpl, Ge, A), Me = A.slice(0, ve), Ye = A.slice(Re);
3796
+ let Qe = (Me + _ + Ye).slice(0, ge);
3797
+ ve === Re && Me.length + 1 + Ye.length > ge && (Qe = (Me + _ + Ye.slice(1)).slice(0, ge)), Pe(Qe, ve + 1), G?.(c);
3798
+ return;
3799
+ }
3800
+ if (_ === "Backspace") {
3801
+ if (c.preventDefault(), Ue !== Ge) {
3802
+ const ve = ln(u.displayTpl, Ue, A), Re = ln(u.displayTpl, Ge, A), Me = A.slice(0, ve) + A.slice(Re);
3803
+ Pe(Me, ve);
3804
+ } else {
3805
+ const ve = ln(u.displayTpl, Ue, A);
3806
+ if (ve === 0) {
3807
+ G?.(c);
3808
+ return;
3809
+ }
3810
+ const Re = A.slice(0, ve - 1) + A.slice(ve);
3811
+ Pe(Re, ve - 1);
3812
+ }
3813
+ G?.(c);
3814
+ return;
3815
+ }
3816
+ if (_ === "Delete") {
3817
+ if (c.preventDefault(), Ue !== Ge) {
3818
+ const ve = ln(u.displayTpl, Ue, A), Re = ln(u.displayTpl, Ge, A), Me = A.slice(0, ve) + A.slice(Re);
3819
+ Pe(Me, ve);
3820
+ } else {
3821
+ const ve = ln(u.displayTpl, Ue, A);
3822
+ if (ve >= A.length) {
3823
+ G?.(c);
3824
+ return;
3825
+ }
3826
+ const Re = A.slice(0, ve) + A.slice(ve + 1);
3827
+ Pe(Re, ve);
3828
+ }
3829
+ G?.(c);
3830
+ return;
3831
+ }
3832
+ G?.(c);
3833
+ },
3834
+ [
3835
+ Pe,
3836
+ a,
3837
+ In,
3838
+ G,
3839
+ o,
3840
+ u.displayTpl,
3841
+ u.isoTpl,
3842
+ ge,
3843
+ g,
3844
+ T,
3845
+ rn,
3846
+ Cn,
3847
+ cn,
3848
+ f,
3849
+ m
3850
+ ]
3851
+ ), [Nn, En] = we(() => Date.now());
3852
+ Fe(() => {
3853
+ if (!P)
3854
+ return;
3855
+ const c = window.setInterval(
3856
+ () => En(Date.now()),
3857
+ Math.max(100, de)
3858
+ );
3859
+ return () => window.clearInterval(c);
3860
+ }, [P, de]);
3861
+ const l = be(
3862
+ () => Ui(T, b, Nn),
3863
+ [T, b, Nn]
3864
+ ), K = Ce(0);
3865
+ Fe(() => {
3866
+ if (!q)
3867
+ return;
3868
+ const c = l.getTime();
3869
+ c !== K.current && (K.current = c, q(l));
3870
+ }, [l, q]);
3871
+ const se = be(() => {
3872
+ if (!P)
3873
+ return null;
3874
+ const c = l.getTime() - Nn;
3875
+ return Q ? Q(c, l) : (Ai[ce] ?? Tt)(c, fe ?? V("datetime.countdownDone", "Done"));
3876
+ }, [P, l, Nn, Q, ce, fe, V]), $e = F(
3877
+ (c) => {
3878
+ if (o || a)
3879
+ return;
3880
+ const _ = c.clipboardData.getData("text");
3881
+ if (!_)
3882
+ return;
3883
+ c.preventDefault();
3884
+ const A = qe.current, ye = _.replace(/[^0-9]/g, "");
3885
+ let Ue;
3886
+ ye.length === ge && (_.includes("-") || _.includes("T")) ? Ue = yn(u.displayTpl, u.isoTpl, ye) : Ue = ye.slice(0, ge);
3887
+ const Ge = c.currentTarget, ve = Ge.selectionStart ?? 0, Re = Ge.selectionEnd ?? 0, Me = ln(u.displayTpl, ve, A), Ye = ln(u.displayTpl, Re, A), Qe = A.slice(0, Me), $n = A.slice(Ye), wn = (Qe + Ue + $n).slice(0, ge);
3888
+ Pe(wn, Math.min(ge, Qe.length + Ue.length));
3889
+ },
3890
+ [Pe, a, o, u.displayTpl, u.isoTpl, ge]
3891
+ ), xe = F(
3892
+ (c) => {
3893
+ const _ = c;
3894
+ if (_.inputType === "insertText" || _.inputType === "insertCompositionText" || _.inputType === "insertFromComposition") {
3895
+ const A = _.data ?? "";
3896
+ if (!/^[0-9]+$/.test(A)) {
3897
+ c.preventDefault();
3898
+ return;
3899
+ }
3900
+ if (A.length > 1) {
3901
+ c.preventDefault();
3902
+ const ye = c.currentTarget, Ue = ye.selectionStart ?? 0, Ge = ye.selectionEnd ?? 0, ve = qe.current, Re = ln(u.displayTpl, Ue, ve), Me = ln(u.displayTpl, Ge, ve), Ye = ve.slice(0, Re), Qe = ve.slice(Me), $n = (Ye + A + Qe).slice(0, ge);
3903
+ Pe($n, Math.min(ge, Ye.length + A.length));
3904
+ }
3905
+ }
3906
+ },
3907
+ [Pe, u.displayTpl, ge]
3908
+ ), he = F(
3909
+ (c) => {
3910
+ if (o || a)
3911
+ return;
3912
+ const _ = c.target.value, A = _.replace(/[^0-9]/g, "").slice(0, ge);
3913
+ if (A !== qe.current)
3914
+ if (A.length === ge && (_.includes("-") || _.includes("T") || _.includes(":"))) {
3915
+ const ye = yn(u.displayTpl, u.isoTpl, A);
3916
+ Pe(ye, ye.length);
3917
+ } else
3918
+ Pe(A, A.length);
3919
+ },
3920
+ [Pe, a, o, u.displayTpl, u.isoTpl, ge]
3921
+ ), Be = F(() => {
3922
+ Pe("", 0), requestAnimationFrame(() => h.current?.focus());
3923
+ }, [Pe]), Ee = F(() => {
3924
+ if (a || o)
3925
+ return;
3926
+ if (De === "date" || De === "datetime-local" || De === "time") {
3927
+ y((A) => !A);
3928
+ return;
3929
+ }
3930
+ const c = $.current;
3931
+ if (!c)
3932
+ return;
3933
+ const _ = c;
3934
+ try {
3935
+ if (typeof _.showPicker == "function") {
3936
+ _.showPicker();
3937
+ return;
3938
+ }
3939
+ } catch {
3940
+ }
3941
+ c.focus(), c.click();
3942
+ }, [a, o, De]), Xe = F(
3943
+ (c) => {
3944
+ const _ = c.target.value, A = Tn(_, u.isoTpl), ye = yn(u.displayTpl, u.isoTpl, A);
3945
+ Oe.current = _, ze(ye), Z?.(_), requestAnimationFrame(() => h.current?.focus());
3946
+ },
3947
+ [Z, u.displayTpl, u.isoTpl]
3948
+ ), Fn = F(() => {
3949
+ if (a || o)
3950
+ return;
3951
+ const c = /* @__PURE__ */ new Date(), _ = (Re) => String(Re).padStart(2, "0"), A = `${c.getFullYear()}-${_(c.getMonth() + 1)}-${_(c.getDate())}`, ye = `${_(c.getHours())}:${_(c.getMinutes())}`, Ue = f ? `${ye}:${_(c.getSeconds())}` : ye;
3952
+ let Ge;
3953
+ De === "time" ? Ge = Ue : De === "datetime-local" ? Ge = `${A}T${Ue}` : De === "month" ? Ge = `${c.getFullYear()}-${_(c.getMonth() + 1)}` : Ge = A;
3954
+ const ve = Tn(Ge, u.isoTpl);
3955
+ Oe.current = Ge, ze(yn(u.displayTpl, u.isoTpl, ve)), Z?.(Ge);
3956
+ }, [a, o, De, f, Z, u.displayTpl, u.isoTpl]), mn = De === "date" || De === "datetime-local", hn = (() => {
3957
+ const c = /^(\d{4}-\d{2}-\d{2})/.exec(T ?? "");
3958
+ return c ? c[1] : "";
3959
+ })(), an = xn(T ?? "") ?? { hours: 0, minutes: 0, seconds: 0 }, gn = () => {
3960
+ const c = /* @__PURE__ */ new Date();
3961
+ return `${c.getFullYear()}-${Se(c.getMonth() + 1)}-${Se(c.getDate())}`;
3962
+ }, Mn = (c, _) => {
3963
+ const A = f ? `${Se(_.hours)}:${Se(_.minutes)}:${Se(_.seconds)}` : `${Se(_.hours)}:${Se(_.minutes)}`;
3964
+ let ye;
3965
+ De === "time" ? ye = A : De === "datetime-local" ? ye = `${c}T${A}` : ye = c, cn(ye);
3966
+ }, Gn = (c) => {
3967
+ c && Mn(c, rn ? an : { hours: 0, minutes: 0, seconds: 0 });
3968
+ }, kn = (c, _) => {
3969
+ Mn(mn ? hn || gn() : "", { ...an, [c]: _ });
3970
+ }, tt = (c) => c === "hours" ? 23 : 59, it = (c) => c === "minutes" && m && m > 0 ? m : 1, Dt = (c, _) => {
3971
+ const A = tt(c), ye = it(c), Ue = A + 1, Ge = ((an[c] + _ * ye) % Ue + Ue) % Ue;
3972
+ kn(c, Ge);
3973
+ }, Yn = (c, _, A) => /* @__PURE__ */ e(
3974
+ Ei,
3975
+ {
3976
+ part: c,
3977
+ label: V(_, A),
3978
+ value: an[c],
3979
+ max: tt(c),
3980
+ step: it(c),
3981
+ onPick: (ye) => kn(c, ye),
3982
+ onStep: (ye) => Dt(c, ye),
3983
+ startHold: nn,
3984
+ stopHold: pn
3985
+ }
3986
+ ), xt = () => {
3987
+ Mn(gn(), rn ? an : { hours: 0, minutes: 0, seconds: 0 });
3988
+ }, Ln = (() => {
3989
+ const c = gn(), _ = U && U.length >= 10 ? U.slice(0, 10) : U, A = k && k.length >= 10 ? k.slice(0, 10) : k;
3990
+ return !!(_ && c < _ || A && c > A);
3991
+ })(), St = () => {
3992
+ y(!1), requestAnimationFrame(() => h.current?.focus());
3993
+ };
3994
+ ht(() => {
3995
+ if (!me)
3996
+ return;
3997
+ const c = H.current?.getBoundingClientRect();
3998
+ c && (ke({ left: c.left, top: c.bottom + 6 }), Ze(Qt(H.current)));
3999
+ }, [me]), Fe(() => {
4000
+ if (!me)
4001
+ return;
4002
+ const c = (ye) => {
4003
+ const Ue = ye.target;
4004
+ H.current?.contains(Ue) || Ie.current?.contains(Ue) || y(!1);
4005
+ }, _ = (ye) => {
4006
+ ye.key === "Escape" && y(!1);
4007
+ }, A = () => {
4008
+ const ye = H.current?.getBoundingClientRect();
4009
+ ye && ke({ left: ye.left, top: ye.bottom + 6 });
4010
+ };
4011
+ return document.addEventListener("mousedown", c), document.addEventListener("keydown", _), window.addEventListener("scroll", A, !0), window.addEventListener("resize", A), () => {
4012
+ document.removeEventListener("mousedown", c), document.removeEventListener("keydown", _), window.removeEventListener("scroll", A, !0), window.removeEventListener("resize", A);
4013
+ };
4014
+ }, [me]);
4015
+ const At = F(
4016
+ (c) => {
4017
+ h.current = c, typeof ie == "function" ? ie(c) : ie && (ie.current = c);
4018
+ },
4019
+ [ie]
4020
+ ), at = be(() => {
4021
+ const c = [];
4022
+ return Y && c.push(Ve.submit), c.push({ key: "Esc", description: V("shortcuts.clearDate", "Clear value") }), c;
4023
+ }, [Y, V]), Ut = De === "time";
4024
+ return _e ? null : /* @__PURE__ */ p(
4025
+ "div",
4026
+ {
4027
+ className: `nice-field nice-field--${s}${L ? ` nice-field--label-${L}` : ""}${z === "right" ? " nice-field--error-right" : ""} ${R ? "nice-field--loading" : ""} ${S || ""}`,
4028
+ style: {
4029
+ ...re,
4030
+ ...J != null && {
4031
+ "--nice-field-label-width": typeof J == "number" ? `${J}px` : J
4032
+ },
4033
+ ...x != null && {
4034
+ "--nice-field-control-width": typeof x == "number" ? `${x}px` : x
4035
+ }
4036
+ },
4037
+ "aria-busy": R || void 0,
4038
+ children: [
4039
+ n && /* @__PURE__ */ p(
4040
+ "label",
4041
+ {
4042
+ htmlFor: Te,
4043
+ className: `nice-field__label ${r ? "nice-field__label--required" : ""}`,
4044
+ children: [
4045
+ n,
4046
+ oe && at.length > 0 && /* @__PURE__ */ e(_n, { shortcuts: at, size: "sm" })
4047
+ ]
4048
+ }
4049
+ ),
4050
+ /* @__PURE__ */ p("div", { className: "nice-field__control", children: [
4051
+ /* @__PURE__ */ p(
4052
+ "div",
4053
+ {
4054
+ ref: H,
4055
+ className: `nice-input nice-input--date nice-input--${s} nice-input--ds-${Ne} ${t ? "nice-input--error" : ""} ${a ? "nice-input--disabled" : ""} ${o ? "nice-input--readonly" : ""}`,
4056
+ style: { ...E, width: "fit-content", position: "relative" },
4057
+ children: [
4058
+ /* @__PURE__ */ e(
4059
+ "input",
4060
+ {
4061
+ ref: At,
4062
+ id: Te,
4063
+ className: "nice-input__native nice-masked-input",
4064
+ type: "text",
4065
+ name: C,
4066
+ value: Rn,
4067
+ placeholder: Dn,
4068
+ disabled: a || R,
4069
+ readOnly: o,
4070
+ autoComplete: "off",
4071
+ spellCheck: !1,
4072
+ inputMode: "numeric",
4073
+ "aria-invalid": !!t,
4074
+ "aria-label": n ? void 0 : V("controls.date", "Date"),
4075
+ "data-display-tpl": u.displayTpl,
4076
+ "data-iso-tpl": u.isoTpl,
4077
+ style: {
4078
+ width: `${zn}ch`,
4079
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",
4080
+ fontVariantNumeric: "tabular-nums"
4081
+ },
4082
+ onBeforeInput: xe,
4083
+ onChange: he,
4084
+ onBlur: ae,
4085
+ onKeyDown: Hn,
4086
+ onPaste: $e
4087
+ }
4088
+ ),
4089
+ I && /* @__PURE__ */ e(
4090
+ "button",
4091
+ {
4092
+ type: "button",
4093
+ className: "nice-input__clear",
4094
+ onClick: Be,
4095
+ disabled: !T || a || o,
4096
+ "aria-label": V("controls.clear", "Clear"),
4097
+ tabIndex: T && !a && !o ? 0 : -1,
4098
+ children: /* @__PURE__ */ e(Le, { name: "close", size: 14 })
4099
+ }
4100
+ ),
4101
+ B && /* @__PURE__ */ p(vn, { children: [
4102
+ /* @__PURE__ */ e(
4103
+ "button",
4104
+ {
4105
+ type: "button",
4106
+ className: "nice-input__picker-trigger",
4107
+ onClick: Ee,
4108
+ "aria-label": V("controls.openPicker", "Open picker"),
4109
+ tabIndex: -1,
4110
+ disabled: a || o,
4111
+ children: Ut ? (
4112
+ /* Clock icon */
4113
+ /* @__PURE__ */ p(
4114
+ "svg",
4115
+ {
4116
+ width: "16",
4117
+ height: "16",
4118
+ viewBox: "0 0 24 24",
4119
+ fill: "none",
4120
+ "aria-hidden": "true",
4121
+ focusable: "false",
4122
+ children: [
4123
+ /* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "9", stroke: "currentColor", strokeWidth: "1.8" }),
4124
+ /* @__PURE__ */ e(
4125
+ "path",
4126
+ {
4127
+ d: "M12 7v5l3.5 2",
4128
+ stroke: "currentColor",
4129
+ strokeWidth: "1.8",
4130
+ strokeLinecap: "round",
4131
+ strokeLinejoin: "round"
4132
+ }
4133
+ )
4134
+ ]
4135
+ }
4136
+ )
4137
+ ) : (
4138
+ /* Calendar icon — outline style, matches NtdCalendar.outline */
4139
+ /* @__PURE__ */ p(
4140
+ "svg",
4141
+ {
4142
+ width: "16",
4143
+ height: "16",
4144
+ viewBox: "0 0 24 24",
4145
+ fill: "none",
4146
+ "aria-hidden": "true",
4147
+ focusable: "false",
4148
+ children: [
4149
+ /* @__PURE__ */ e(
4150
+ "rect",
4151
+ {
4152
+ x: "3.25",
4153
+ y: "4.5",
4154
+ width: "17.5",
4155
+ height: "16.5",
4156
+ rx: "2",
4157
+ stroke: "currentColor",
4158
+ strokeWidth: "1.7"
4159
+ }
4160
+ ),
4161
+ /* @__PURE__ */ e(
4162
+ "line",
4163
+ {
4164
+ x1: "16",
4165
+ y1: "2.5",
4166
+ x2: "16",
4167
+ y2: "6.5",
4168
+ stroke: "currentColor",
4169
+ strokeWidth: "1.7",
4170
+ strokeLinecap: "round"
4171
+ }
4172
+ ),
4173
+ /* @__PURE__ */ e(
4174
+ "line",
4175
+ {
4176
+ x1: "8",
4177
+ y1: "2.5",
4178
+ x2: "8",
4179
+ y2: "6.5",
4180
+ stroke: "currentColor",
4181
+ strokeWidth: "1.7",
4182
+ strokeLinecap: "round"
4183
+ }
4184
+ ),
4185
+ /* @__PURE__ */ e(
4186
+ "line",
4187
+ {
4188
+ x1: "3.25",
4189
+ y1: "9.75",
4190
+ x2: "20.75",
4191
+ y2: "9.75",
4192
+ stroke: "currentColor",
4193
+ strokeWidth: "1.5"
4194
+ }
4195
+ )
4196
+ ]
4197
+ }
4198
+ )
4199
+ )
4200
+ }
4201
+ ),
4202
+ /* @__PURE__ */ e(
4203
+ "input",
4204
+ {
4205
+ ref: $,
4206
+ type: De,
4207
+ className: "nice-input__picker-companion",
4208
+ value: T ?? "",
4209
+ min: U,
4210
+ max: k,
4211
+ step: De === "time" || De === "datetime-local" ? f ? 1 : m ? m * 60 : void 0 : void 0,
4212
+ onChange: Xe,
4213
+ tabIndex: -1,
4214
+ "aria-hidden": "true",
4215
+ style: {
4216
+ position: "absolute",
4217
+ width: 0,
4218
+ height: 0,
4219
+ opacity: 0,
4220
+ pointerEvents: "none",
4221
+ border: 0,
4222
+ padding: 0,
4223
+ left: 0,
4224
+ bottom: 0
4225
+ }
4226
+ }
4227
+ )
4228
+ ] }),
4229
+ rn && O === "12" && !a && !o && /* @__PURE__ */ e(
4230
+ "button",
4231
+ {
4232
+ type: "button",
4233
+ className: "nice-input__ampm",
4234
+ onClick: Bn,
4235
+ disabled: !T,
4236
+ "aria-label": V("datetime.toggleAmPm", "Toggle AM/PM"),
4237
+ tabIndex: -1,
4238
+ children: Pn
4239
+ }
4240
+ ),
4241
+ W && !a && !o && /* @__PURE__ */ e("button", { type: "button", className: "nice-input__now", onClick: Fn, tabIndex: -1, children: V("controls.now", "Now") })
4242
+ ]
4243
+ }
4244
+ ),
4245
+ me && d && We && gt(
4246
+ /* @__PURE__ */ p(
4247
+ "div",
4248
+ {
4249
+ ref: Ie,
4250
+ className: `nice-datetime-popup${je ? ` ${je}` : ""}`,
4251
+ style: {
4252
+ position: "fixed",
4253
+ left: d.left,
4254
+ top: d.top,
4255
+ zIndex: 1e3
4256
+ },
4257
+ role: "dialog",
4258
+ "aria-label": V("controls.openPicker", "Open picker"),
4259
+ children: [
4260
+ /* @__PURE__ */ p("div", { className: "nice-datetime-popup__body", children: [
4261
+ mn && /* @__PURE__ */ e("div", { className: "nice-datetime-popup__col nice-datetime-popup__col--date", children: /* @__PURE__ */ e(
4262
+ $t,
4263
+ {
4264
+ value: hn,
4265
+ onChange: Gn,
4266
+ min: U && U.length >= 10 ? U.slice(0, 10) : void 0,
4267
+ max: k && k.length >= 10 ? k.slice(0, 10) : void 0
4268
+ }
4269
+ ) }),
4270
+ rn && /* @__PURE__ */ p("div", { className: "nice-datetime-popup__col nice-datetime-popup__col--time", children: [
4271
+ /* @__PURE__ */ p(
4272
+ "div",
4273
+ {
4274
+ className: "nice-datetime-popup__time-modes",
4275
+ role: "group",
4276
+ "aria-label": V("datetime.timeSelector", "Time selector"),
4277
+ children: [
4278
+ /* @__PURE__ */ e(
4279
+ "button",
4280
+ {
4281
+ type: "button",
4282
+ className: `nice-datetime-popup__mode-btn${He === "spinners" ? " nice-datetime-popup__mode-btn--active" : ""}`,
4283
+ onClick: () => ee("spinners"),
4284
+ "aria-pressed": He === "spinners",
4285
+ "aria-label": V("datetime.spinnersMode", "Spinner wheels"),
4286
+ title: V("datetime.spinnersMode", "Spinner wheels"),
4287
+ tabIndex: -1,
4288
+ children: /* @__PURE__ */ e(Le, { name: "list", size: 16 })
4289
+ }
4290
+ ),
4291
+ /* @__PURE__ */ e(
4292
+ "button",
4293
+ {
4294
+ type: "button",
4295
+ className: `nice-datetime-popup__mode-btn${He === "clock" ? " nice-datetime-popup__mode-btn--active" : ""}`,
4296
+ onClick: () => ee("clock"),
4297
+ "aria-pressed": He === "clock",
4298
+ "aria-label": V("datetime.clockMode", "Analog clock"),
4299
+ title: V("datetime.clockMode", "Analog clock"),
4300
+ tabIndex: -1,
4301
+ children: /* @__PURE__ */ e(Le, { name: "clock", size: 16 })
4302
+ }
4303
+ )
4304
+ ]
4305
+ }
4306
+ ),
4307
+ He === "clock" ? /* @__PURE__ */ e(
4308
+ Fi,
4309
+ {
4310
+ hours: an.hours,
4311
+ minutes: an.minutes,
4312
+ minuteStep: m,
4313
+ onChange: (c, _) => Mn(mn ? hn || gn() : "", {
4314
+ ...an,
4315
+ hours: c,
4316
+ minutes: _
4317
+ }),
4318
+ t: V
4319
+ }
4320
+ ) : /* @__PURE__ */ p("div", { className: "nice-datetime-popup__time", role: "group", children: [
4321
+ Yn("hours", "datetime.hours", "Hours"),
4322
+ /* @__PURE__ */ e("span", { className: "nice-datetime-popup__time-sep", children: ":" }),
4323
+ Yn("minutes", "datetime.minutes", "Minutes"),
4324
+ f && /* @__PURE__ */ p(vn, { children: [
4325
+ /* @__PURE__ */ e("span", { className: "nice-datetime-popup__time-sep", children: ":" }),
4326
+ Yn("seconds", "datetime.seconds", "Seconds")
4327
+ ] })
4328
+ ] })
4329
+ ] })
4330
+ ] }),
4331
+ /* @__PURE__ */ p("div", { className: "nice-datetime-popup__footer", children: [
4332
+ I && /* @__PURE__ */ e(
4333
+ "button",
4334
+ {
4335
+ type: "button",
4336
+ className: "nice-datetime-popup__btn",
4337
+ onClick: Be,
4338
+ children: V("controls.clear", "Clear")
4339
+ }
4340
+ ),
4341
+ mn && /* @__PURE__ */ e(
4342
+ "button",
4343
+ {
4344
+ type: "button",
4345
+ className: "nice-datetime-popup__btn",
4346
+ onClick: xt,
4347
+ disabled: Ln,
4348
+ "aria-disabled": Ln || void 0,
4349
+ children: V("controls.today", "Today")
4350
+ }
4351
+ ),
4352
+ rn && /* @__PURE__ */ e(
4353
+ "button",
4354
+ {
4355
+ type: "button",
4356
+ className: "nice-datetime-popup__btn",
4357
+ onClick: Fn,
4358
+ disabled: Ln,
4359
+ "aria-disabled": Ln || void 0,
4360
+ children: V("controls.now", "Now")
4361
+ }
4362
+ ),
4363
+ /* @__PURE__ */ e(
4364
+ "button",
4365
+ {
4366
+ type: "button",
4367
+ className: "nice-datetime-popup__btn nice-datetime-popup__btn--primary",
4368
+ onClick: St,
4369
+ children: V("controls.confirm", "Confirm")
4370
+ }
4371
+ )
4372
+ ] })
4373
+ ]
4374
+ }
4375
+ ),
4376
+ We
4377
+ ),
4378
+ P && se != null && /* @__PURE__ */ p("span", { className: "nice-datetime__countdown", "aria-live": "polite", children: [
4379
+ le && /* @__PURE__ */ p("span", { className: "nice-datetime__countdown-label", children: [
4380
+ le,
4381
+ " "
4382
+ ] }),
4383
+ /* @__PURE__ */ e("span", { className: "nice-datetime__countdown-value", children: se })
4384
+ ] }),
4385
+ R && /* @__PURE__ */ e("span", { className: "nice-field__spinner", children: /* @__PURE__ */ e("span", { className: "nice-spinner nice-spinner--sm" }) }),
4386
+ z === "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
4387
+ z === "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
4388
+ ] }),
4389
+ z !== "right" && t && /* @__PURE__ */ e("div", { className: "nice-field__error", role: "alert", children: t }),
4390
+ z !== "right" && !t && i && /* @__PURE__ */ e("div", { className: "nice-field__helper", children: i })
4391
+ ]
4392
+ }
4393
+ );
4394
+ }
4395
+ );
4396
+ Sn.displayName = "NiceDateTimePicker";
4397
+ const Ji = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4398
+ __proto__: null,
4399
+ NiceDateTimePicker: Sn,
4400
+ getDefaultLocale: wt
4401
+ }, Symbol.toStringTag, { value: "Module" })), Li = ({
4402
+ items: n,
4403
+ data: i,
4404
+ onFieldChange: t,
4405
+ onSubmit: r,
4406
+ dataSource: a,
4407
+ recordKey: o,
4408
+ columns: s = 1,
4409
+ responsiveColumns: C,
4410
+ gap: w = 16,
4411
+ labelPosition: S = "top",
4412
+ size: re = "md",
4413
+ readOnly: D,
4414
+ disabled: T,
4415
+ className: Z,
4416
+ style: ae,
4417
+ accessMode: G,
4418
+ id: U,
4419
+ autoSaveDelay: k,
4420
+ onDirtyChange: ne,
4421
+ showActions: X,
4422
+ submitLabel: Y = "Submit",
4423
+ resetLabel: ue = "Reset",
4424
+ onCancel: oe,
4425
+ cancelLabel: M = "Cancel"
4426
+ }) => {
4427
+ const L = dn(G, U), z = L === "hidden";
4428
+ L === "disabled" && (T = !0), L === "readOnly" && (D = !0);
4429
+ const R = Gt(a ?? null, o), J = !!a && o != null, x = J ? R.editData : i ?? {}, [te] = we(() => ({ ...x })), [I, B] = we([]), pe = be(() => Object.keys(x).some((h) => x[h] !== te[h]), [x, te]), g = Ce(!1);
4430
+ Fe(() => {
4431
+ pe !== g.current && (g.current = pe, ne?.(pe));
4432
+ }, [pe, ne]);
4433
+ const f = Ce(null), m = F(() => {
4434
+ k && (f.current && clearTimeout(f.current), f.current = setTimeout(() => {
4435
+ J ? R.save() : r?.(x);
4436
+ }, k));
4437
+ }, [k, J, R, r, x]), W = F(
4438
+ (h, $) => {
4439
+ D || T || (B((H) => [...H, { field: h, prev: x[h] }]), J ? R.set(h, $) : t?.(h, $), m());
4440
+ },
4441
+ [J, R, t, D, T, x, m]
4442
+ ), O = F(() => {
4443
+ if (I.length === 0)
4444
+ return;
4445
+ const h = I[I.length - 1];
4446
+ B(($) => $.slice(0, -1)), J ? R.set(h.field, h.prev) : t?.(h.field, h.prev);
4447
+ }, [I, J, R, t]), v = F(
4448
+ (h) => {
4449
+ h.preventDefault(), f.current && clearTimeout(f.current), J ? R.save() : r?.(x);
4450
+ },
4451
+ [x, r, J, R]
4452
+ ), b = Ce(null), [q, P] = we(s);
4453
+ Fe(() => {
4454
+ if (!C || !b.current) {
4455
+ P(s);
4456
+ return;
4457
+ }
4458
+ const h = b.current, $ = new ResizeObserver((H) => {
4459
+ const Ie = H[0]?.contentRect.width ?? 0, me = Object.keys(C).map(Number).sort((y, d) => d - y);
4460
+ for (const y of me)
4461
+ if (Ie >= y) {
4462
+ P(C[y]);
4463
+ return;
4464
+ }
4465
+ P(s);
4466
+ });
4467
+ return $.observe(h), () => $.disconnect();
4468
+ }, [C, s]);
4469
+ const ce = be(
4470
+ () => n.filter((h) => !(h.visible === !1 || h.visibleWhen && !h.visibleWhen(x))),
4471
+ [n, x]
4472
+ ), Q = be(() => {
4473
+ const h = [];
4474
+ let $ = null;
4475
+ for (const H of ce)
4476
+ !$ || $.name !== H.group ? ($ = { name: H.group, items: [H] }, h.push($)) : $.items.push(H);
4477
+ return h;
4478
+ }, [ce]), le = F(
4479
+ (h) => {
4480
+ const $ = x[h.field] !== void 0 ? x[h.field] : h.defaultValue, H = (d) => W(h.field, d);
4481
+ if (h.render)
4482
+ return h.render($, H);
4483
+ const Ie = h.type || "text", me = h.options?.map(
4484
+ (d) => typeof d == "string" ? { label: d, value: d } : { label: d.label, value: String(d.value) }
4485
+ ), y = { size: re, disabled: T, readOnly: D };
4486
+ switch (Ie) {
4487
+ case "number":
4488
+ return /* @__PURE__ */ e(
4489
+ ct,
4490
+ {
4491
+ ...y,
4492
+ value: $ ?? null,
4493
+ onChange: (d) => H(d),
4494
+ required: h.required
4495
+ }
4496
+ );
4497
+ case "currency":
4498
+ return /* @__PURE__ */ e(
4499
+ ct,
4500
+ {
4501
+ ...y,
4502
+ value: $ ?? null,
4503
+ onChange: (d) => H(d),
4504
+ required: h.required,
4505
+ precision: h.precision ?? 2,
4506
+ step: h.step ?? 100,
4507
+ suffix: h.unit ?? "PLN",
4508
+ formatPreset: "money"
4509
+ }
4510
+ );
4511
+ case "textarea":
4512
+ return /* @__PURE__ */ e(Qn, { ...y, value: $ ?? "", onChange: (d) => H(d), rows: 3 });
4513
+ case "address":
4514
+ return /* @__PURE__ */ e(
4515
+ Mt,
4516
+ {
4517
+ ...y,
4518
+ value: $ ?? {},
4519
+ onChange: (d) => H(d),
4520
+ required: h.required,
4521
+ columns: h.columns ?? 2
4522
+ }
4523
+ );
4524
+ case "select":
4525
+ return /* @__PURE__ */ e(
4526
+ yt,
4527
+ {
4528
+ ...y,
4529
+ value: $ ?? "",
4530
+ onChange: (d) => H(d),
4531
+ options: me ?? []
4532
+ }
4533
+ );
4534
+ case "autocomplete":
4535
+ return /* @__PURE__ */ e(
4536
+ ei,
4537
+ {
4538
+ ...y,
4539
+ value: $ ?? "",
4540
+ onChange: (d) => H(d),
4541
+ options: me ?? [],
4542
+ suggestions: (me ?? []).map((d) => d.label)
4543
+ }
4544
+ );
4545
+ case "radio":
4546
+ return /* @__PURE__ */ e(
4547
+ bt,
4548
+ {
4549
+ ...y,
4550
+ value: $ ?? "",
4551
+ onChange: (d) => H(d),
4552
+ options: me ?? []
4553
+ }
4554
+ );
4555
+ case "checkbox":
4556
+ return /* @__PURE__ */ e(
4557
+ qt,
4558
+ {
4559
+ ...y,
4560
+ checked: !!$,
4561
+ onChange: (d) => H(d),
4562
+ label: h.label
4563
+ }
4564
+ );
4565
+ case "toggle":
4566
+ return /* @__PURE__ */ e(Ot, { ...y, checked: !!$, onChange: (d) => H(d) });
4567
+ case "date":
4568
+ return /* @__PURE__ */ e(Sn, { ...y, value: $ ?? "", onChange: (d) => H(d) });
4569
+ case "time":
4570
+ return /* @__PURE__ */ e(
4571
+ Sn,
4572
+ {
4573
+ ...y,
4574
+ dateFormatPreset: "time",
4575
+ value: $ ?? "",
4576
+ onChange: (d) => H(d)
4577
+ }
4578
+ );
4579
+ case "datetime":
4580
+ return /* @__PURE__ */ e(
4581
+ Sn,
4582
+ {
4583
+ ...y,
4584
+ dateFormatPreset: "datetime-local",
4585
+ value: $ ?? "",
4586
+ onChange: (d) => H(d)
4587
+ }
4588
+ );
4589
+ case "color":
4590
+ return /* @__PURE__ */ e(
4591
+ jt,
4592
+ {
4593
+ ...y,
4594
+ value: $ ?? "var(--nice-text-primary, #000000)",
4595
+ onChange: (d) => H(d)
4596
+ }
4597
+ );
4598
+ case "slider":
4599
+ return /* @__PURE__ */ e(
4600
+ Jn,
4601
+ {
4602
+ ...y,
4603
+ value: typeof $ == "number" ? $ : 0,
4604
+ onChange: (d) => H(d)
4605
+ }
4606
+ );
4607
+ case "rating":
4608
+ return /* @__PURE__ */ e(
4609
+ Zn,
4610
+ {
4611
+ ...y,
4612
+ value: typeof $ == "number" ? $ : 0,
4613
+ onChange: (d) => H(d)
4614
+ }
4615
+ );
4616
+ case "password":
4617
+ return /* @__PURE__ */ e(
4618
+ vt,
4619
+ {
4620
+ ...y,
4621
+ value: $ ?? "",
4622
+ onChange: (d) => H(d),
4623
+ required: h.required
4624
+ }
4625
+ );
4626
+ case "phone":
4627
+ case "tel":
4628
+ return /* @__PURE__ */ e(
4629
+ on,
4630
+ {
4631
+ ...y,
4632
+ type: "tel",
4633
+ value: $ ?? "",
4634
+ onChange: (d) => H(d),
4635
+ required: h.required
4636
+ }
4637
+ );
4638
+ case "country":
4639
+ return /* @__PURE__ */ e(kt, { ...y, value: $ ?? "", onChange: (d) => H(d) });
4640
+ case "tags":
4641
+ return /* @__PURE__ */ e(
4642
+ si,
4643
+ {
4644
+ ...y,
4645
+ value: Array.isArray($) ? $ : [],
4646
+ onChange: (d) => H(d),
4647
+ options: me ?? []
4648
+ }
4649
+ );
4650
+ case "masked":
4651
+ return /* @__PURE__ */ e(
4652
+ _t,
4653
+ {
4654
+ ...y,
4655
+ value: $ ?? "",
4656
+ mask: h.mask ?? "999-999-9999",
4657
+ onChange: (d) => H(d)
4658
+ }
4659
+ );
4660
+ case "file":
4661
+ return /* @__PURE__ */ e(Nt, { ...y, onFilesSelected: (d) => H(d) });
4662
+ case "email":
4663
+ return /* @__PURE__ */ e(
4664
+ on,
4665
+ {
4666
+ ...y,
4667
+ type: "email",
4668
+ value: $ ?? "",
4669
+ onChange: (d) => H(d),
4670
+ required: h.required
4671
+ }
4672
+ );
4673
+ case "url":
4674
+ return /* @__PURE__ */ e(
4675
+ on,
4676
+ {
4677
+ ...y,
4678
+ type: "url",
4679
+ value: $ ?? "",
4680
+ onChange: (d) => H(d),
4681
+ required: h.required
4682
+ }
4683
+ );
4684
+ default:
4685
+ return /* @__PURE__ */ e(
4686
+ on,
4687
+ {
4688
+ ...y,
4689
+ value: $ ?? "",
4690
+ onChange: (d) => H(d),
4691
+ required: h.required
4692
+ }
4693
+ );
4694
+ }
4695
+ },
4696
+ [x, W, T, D, re]
4697
+ ), de = (h) => /* @__PURE__ */ p(
4698
+ "div",
4699
+ {
4700
+ className: "nice-form__item",
4701
+ style: { gridColumn: h.colSpan ? `span ${h.colSpan}` : void 0 },
4702
+ children: [
4703
+ h.label && /* @__PURE__ */ p("label", { className: "nice-form__label", children: [
4704
+ h.label,
4705
+ h.required && /* @__PURE__ */ e("span", { className: "nice-field__required", children: "*" })
4706
+ ] }),
4707
+ /* @__PURE__ */ e("div", { className: "nice-form__control", children: le(h) }),
4708
+ h.hint && /* @__PURE__ */ e("div", { className: "nice-form__hint", children: h.hint })
4709
+ ]
4710
+ },
4711
+ h.field
4712
+ ), fe = {
4713
+ display: "grid",
4714
+ gridTemplateColumns: `repeat(${q}, 1fr)`,
4715
+ gap: w
4716
+ }, ie = Q.some((h) => h.name != null), E = be(() => {
4717
+ const h = /* @__PURE__ */ new Set(), $ = [];
4718
+ for (const H of ce)
4719
+ H.tab && !h.has(H.tab) && (h.add(H.tab), $.push(H.tab));
4720
+ return $;
4721
+ }, [ce]), Ne = E.length > 0, [j, _e] = we("");
4722
+ Fe(() => {
4723
+ Ne && !E.includes(j) && _e(E[0]);
4724
+ }, [Ne, E, j]);
4725
+ const V = (h) => {
4726
+ const $ = [];
4727
+ let H = null;
4728
+ for (const me of h)
4729
+ !H || H.name !== me.group ? (H = { name: me.group, items: [me] }, $.push(H)) : H.items.push(me);
4730
+ return $.some((me) => me.name != null) ? $.map((me, y) => /* @__PURE__ */ p(
4731
+ "fieldset",
4732
+ {
4733
+ className: me.name ? "nice-form__group" : "nice-form__group nice-form__group--no-title",
4734
+ children: [
4735
+ me.name && /* @__PURE__ */ e("legend", { className: "nice-form__group-title", children: me.name }),
4736
+ /* @__PURE__ */ e("div", { style: fe, children: me.items.map(de) })
4737
+ ]
4738
+ },
4739
+ y
4740
+ )) : /* @__PURE__ */ e("div", { style: fe, children: h.map(de) });
4741
+ }, Te = X ? /* @__PURE__ */ p("div", { className: "nice-form__actions", children: [
4742
+ /* @__PURE__ */ p("div", { className: "nice-form__actions-left", children: [
4743
+ oe && /* @__PURE__ */ e(Vn, { type: "button", variant: "secondary", size: re, onClick: oe, children: M }),
4744
+ /* @__PURE__ */ e(
4745
+ Vn,
4746
+ {
4747
+ type: "button",
4748
+ variant: "ghost",
4749
+ size: re,
4750
+ onClick: O,
4751
+ disabled: I.length === 0,
4752
+ children: ue
4753
+ }
4754
+ )
4755
+ ] }),
4756
+ /* @__PURE__ */ e("div", { className: "nice-form__actions-right", children: /* @__PURE__ */ e(Vn, { type: "submit", variant: "primary", size: re, children: Y }) })
4757
+ ] }) : null;
4758
+ return z ? null : /* @__PURE__ */ p(
4759
+ "form",
4760
+ {
4761
+ ref: b,
4762
+ className: `nice-form nice-form--label-${S}${pe ? " nice-form--dirty" : ""} ${Z || ""}`,
4763
+ style: ie || Ne ? { ...ae } : { ...fe, ...ae },
4764
+ onSubmit: v,
4765
+ noValidate: !0,
4766
+ children: [
4767
+ Ne ? /* @__PURE__ */ e(
4768
+ Zt,
4769
+ {
4770
+ className: "nice-form__tabs",
4771
+ activeTab: j || E[0],
4772
+ onChange: _e,
4773
+ tabs: E.map((h) => ({
4774
+ id: h,
4775
+ label: h,
4776
+ content: /* @__PURE__ */ e("div", { className: "nice-form__tab-panel", children: V(ce.filter(($) => ($.tab ?? E[0]) === h)) })
4777
+ }))
4778
+ }
4779
+ ) : ie ? Q.map((h, $) => /* @__PURE__ */ p(
4780
+ "fieldset",
4781
+ {
4782
+ className: h.name ? "nice-form__group" : "nice-form__group nice-form__group--no-title",
4783
+ children: [
4784
+ h.name && /* @__PURE__ */ e("legend", { className: "nice-form__group-title", children: h.name }),
4785
+ /* @__PURE__ */ e("div", { style: fe, children: h.items.map(de) })
4786
+ ]
4787
+ },
4788
+ $
4789
+ )) : ce.map(de),
4790
+ Te
4791
+ ]
4792
+ }
4793
+ );
4794
+ };
4795
+ Li.displayName = "NiceForm";
4796
+ export {
4797
+ gi as C,
4798
+ ni as M,
4799
+ ei as N,
4800
+ $t as a,
4801
+ kt as b,
4802
+ Sn as c,
4803
+ Li as d,
4804
+ _t as e,
4805
+ vt as f,
4806
+ bt as g,
4807
+ Zn as h,
4808
+ Jn as i,
4809
+ si as j,
4810
+ Qn as k,
4811
+ Nt as l,
4812
+ wt as m,
4813
+ Mt as n,
4814
+ Ki as o,
4815
+ Oi as p,
4816
+ qi as q,
4817
+ Zi as r,
4818
+ Ji as s
4819
+ };