md-components-mdigial-azamat 0.0.112 → 0.0.114

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 (147) hide show
  1. package/dist/ActionCardList/ActionCardList.js +28 -5
  2. package/dist/ActionCardList/index.js +1 -1
  3. package/dist/ActionCardList/info.js +1 -1
  4. package/dist/ActionCardSecondaryList/ActionCardSecondaryList.js +32 -0
  5. package/dist/ActionCardSecondaryList/index.js +6 -0
  6. package/dist/ActionCardSecondaryList/info.js +11 -0
  7. package/dist/ActionCardSecondaryList/schema.js +51 -0
  8. package/dist/ActionCardSecondaryList/types.js +4 -0
  9. package/dist/ActionIconList/ActionIconList.js +25 -2
  10. package/dist/AllComponents.js +28 -5
  11. package/dist/AllComponentsInfo.js +111 -95
  12. package/dist/AnimatedSwiper/index.js +40 -38
  13. package/dist/CardImageList/CardImageList.js +122 -81
  14. package/dist/CardImageList/schema.js +17 -12
  15. package/dist/Cards/ActionSecondaryCard/ActionSecondaryCard.js +77 -0
  16. package/dist/Cards/ActionSecondaryCard/index.js +6 -0
  17. package/dist/Cards/ActionSecondaryCard/info.js +11 -0
  18. package/dist/Cards/ActionSecondaryCard/types.js +4 -0
  19. package/dist/Cards/CardImage/CardImage.js +48 -50
  20. package/dist/Cards/InfoCard/InfoCard.js +114 -0
  21. package/dist/Cards/InfoCard/index.js +9 -0
  22. package/dist/Cards/InfoCard/info.js +11 -0
  23. package/dist/Cards/InfoCard/schema.js +60 -0
  24. package/dist/Cards/InfoCard/types.js +4 -0
  25. package/dist/Cards/PostCard/PostCard.js +60 -0
  26. package/dist/Cards/PostCard/index.js +6 -0
  27. package/dist/Cards/PostCard/info.js +11 -0
  28. package/dist/Cards/PostCard/types.js +4 -0
  29. package/dist/Cards/WarningCard/WarningCard.js +27 -4
  30. package/dist/Cards/WarningCard/index.js +1 -1
  31. package/dist/Cards/WarningCard/info.js +1 -1
  32. package/dist/Cards/WarningCard/model.js +1 -1
  33. package/dist/CurrencyRates/CurrencyRates.js +78 -0
  34. package/dist/CurrencyRates/components/Calculator.js +101 -0
  35. package/dist/CurrencyRates/components/RateCell.js +15 -0
  36. package/dist/CurrencyRates/components/RatesTable.js +134 -0
  37. package/dist/CurrencyRates/components/index.js +6 -0
  38. package/dist/CurrencyRates/index.js +8 -0
  39. package/dist/CurrencyRates/info.js +11 -0
  40. package/dist/CurrencyRates/schema.js +63 -0
  41. package/dist/CurrencyRates/types.js +4 -0
  42. package/dist/DownloadFile/components/DownloadFileBanner/DownloadFileBanner.js +1 -1
  43. package/dist/DownloadFile/components/DownloadFileFull/DownloadFileFull.js +1 -1
  44. package/dist/DownloadFile/components/DownloadFileHalf/DownloadFileHalf.js +1 -1
  45. package/dist/DownloadFile/components/DownloadFileMini/DownloadFileMini.js +1 -1
  46. package/dist/DownloadFile/components/FileBannerSecondary/FileBannerSecondary.js +1 -1
  47. package/dist/Faq/Faq.js +1 -1
  48. package/dist/Faq/components/FeedbackForm/FeedbackForm.js +55 -6
  49. package/dist/Faq/components/FeedbackForm/index.js +1 -1
  50. package/dist/FieldInput-ef2a18d4.js +2743 -0
  51. package/dist/Forms/FormDefault/FormDefault.js +12 -0
  52. package/dist/Forms/FormDefault/components/FieldCustom.js +11 -0
  53. package/dist/Forms/FormDefault/components/FieldInput.js +11 -0
  54. package/dist/Forms/FormDefault/components/FieldSection.js +10 -0
  55. package/dist/Forms/FormDefault/components/FormContent.js +10 -0
  56. package/dist/Forms/FormDefault/components/FormFields.js +7 -0
  57. package/dist/Forms/FormDefault/components/FormSuccessMessage.js +49 -0
  58. package/dist/Forms/FormDefault/components/index.js +6 -0
  59. package/dist/Forms/FormDefault/hooks/index.js +10 -0
  60. package/dist/Forms/FormDefault/hooks/useFieldOptions.js +32 -0
  61. package/dist/Forms/FormDefault/hooks/useFieldValidation.js +33 -0
  62. package/dist/Forms/FormDefault/hooks/useFieldVisibility.js +24 -0
  63. package/dist/Forms/FormDefault/hooks/useFormSubmission.js +64 -0
  64. package/dist/Forms/FormDefault/index.js +6 -12
  65. package/dist/Forms/FormDefault/info.js +3 -115
  66. package/dist/Forms/FormDefault/model/componentRegistry.js +134 -0
  67. package/dist/Forms/FormDefault/model/fieldTypes.js +18 -0
  68. package/dist/Forms/FormDefault/model/formElementTypes.js +18 -0
  69. package/dist/Forms/FormDefault/model/index.js +13 -0
  70. package/dist/Forms/FormDefault/model/requestForm.js +4 -0
  71. package/dist/Forms/{model/components.js → FormDefault/schema.js} +32 -5
  72. package/dist/Forms/FormDefault/utils.js +20 -0
  73. package/dist/Grid-331af266.js +80 -0
  74. package/dist/Header/Header.js +54 -42
  75. package/dist/Header/components/HeaderMainMobile/HeaderMainMobile.js +21 -19
  76. package/dist/Header/components/HeaderMobile/HeaderMobile.js +67 -52
  77. package/dist/Header/components/HeaderTab/HeaderTab.js +17 -15
  78. package/dist/Header/components/HeaderTabsMobile/HeaderTabsMobile.js +8 -7
  79. package/dist/Header/components/HeaderWeb/HeaderWeb.js +134 -114
  80. package/dist/Header/components/TabsOutlined/TabsOutlined.js +8 -7
  81. package/dist/HeroIconsBanner/HeroIconsBanner.js +25 -25
  82. package/dist/IconList/IconList.js +60 -54
  83. package/dist/InfoCardList/InfoCardList.js +100 -0
  84. package/dist/InfoCardList/index.js +6 -0
  85. package/dist/InfoCardList/info.js +11 -0
  86. package/dist/InfoCardList/schema.js +39 -0
  87. package/dist/InfoCardList/types.js +1 -0
  88. package/dist/PageViewer/renderComponents.js +1 -1
  89. package/dist/PostsList/PostsList.js +78 -0
  90. package/dist/PostsList/index.js +4 -0
  91. package/dist/PostsList/info.js +11 -0
  92. package/dist/PostsList/schema.js +49 -0
  93. package/dist/PostsList/types.js +1 -0
  94. package/dist/PostsSlider/PostsSlider.js +78 -0
  95. package/dist/PostsSlider/index.js +4 -0
  96. package/dist/PostsSlider/info.js +11 -0
  97. package/dist/PostsSlider/schema.js +49 -0
  98. package/dist/PostsSlider/types.js +1 -0
  99. package/dist/RenderAllComponents/RenderAllComponents.js +1 -1
  100. package/dist/RenderAllComponents/const.js +1 -1
  101. package/dist/SearchBlock/SearchBlock.js +36 -37
  102. package/dist/SegmentedContent/SegmentedContent.js +160 -0
  103. package/dist/SegmentedContent/components/ContentCard.js +50 -0
  104. package/dist/SegmentedContent/components/index.js +4 -0
  105. package/dist/SegmentedContent/index.js +8 -0
  106. package/dist/SegmentedContent/info.js +12 -0
  107. package/dist/SegmentedContent/schema.js +108 -0
  108. package/dist/SegmentedContent/types.js +1 -0
  109. package/dist/Segments/Segments.js +36 -28
  110. package/dist/Segments/index.js +8 -2
  111. package/dist/Segments/info.js +1 -1
  112. package/dist/Segments/schema.js +21 -0
  113. package/dist/Segments/types.js +4 -1
  114. package/dist/SegmentsIcons/SegmentsIcons.js +92 -0
  115. package/dist/SegmentsIcons/index.js +8 -0
  116. package/dist/SegmentsIcons/info.js +11 -0
  117. package/dist/SegmentsIcons/schema.js +14 -0
  118. package/dist/SegmentsIcons/types.js +1 -0
  119. package/dist/SwiperList/SwiperList.js +13 -11
  120. package/dist/assets/index.css +1 -1
  121. package/dist/{componentsMap-cac6c316.js → componentsMap-6fc8d724.js} +5 -3
  122. package/dist/{data.mock-ebc679ec.js → data.mock-a00d8eec.js} +546 -148
  123. package/dist/index-0791c17f.js +56 -0
  124. package/dist/index-2ec92a04.js +32 -0
  125. package/dist/index.esm-0558519f.js +1171 -0
  126. package/dist/info-ce6598a7.js +794 -0
  127. package/dist/main.js +151 -119
  128. package/dist/{mousewheel-865ae601.js → mousewheel-afbc6d42.js} +1 -1
  129. package/dist/navigation-266856e7.js +136 -0
  130. package/dist/navigation-cd786a0d.js +133 -0
  131. package/dist/{palette-c2fe86ec.js → palette-256cf77a.js} +3 -1
  132. package/dist/{swiper-react-90953710.js → swiper-react-3c2710e8.js} +695 -825
  133. package/dist/types-c3843cc0.js +4 -0
  134. package/dist/useDraggableScroll-440da9b7.js +29 -0
  135. package/dist/useTranslation-d7a3ca6f.js +298 -0
  136. package/package.json +1 -1
  137. package/dist/FileLoader/fileLoader.js +0 -22
  138. package/dist/FileLoader/index.js +0 -8
  139. package/dist/Forms/FormDefault/componentTypes.js +0 -31
  140. package/dist/Forms/FormDefault/fieldTypesList.js +0 -45
  141. package/dist/Forms/helpers/renderFormFields.js +0 -7
  142. package/dist/Forms/model/requestForm.js +0 -4
  143. package/dist/index-6686852d.js +0 -1794
  144. package/dist/index-a0ed2e4a.js +0 -1221
  145. package/dist/info-d05a1f02.js +0 -1547
  146. package/dist/navigation-b894d0cd.js +0 -183
  147. /package/dist/Forms/{types/formItems.js → FormDefault/model/types.js} +0 -0
@@ -1,1221 +0,0 @@
1
- import { jsx as le, jsxs as Se } from "react/jsx-runtime";
2
- import m, { useState as Rt } from "react";
3
- import { B as Je } from "./index-875e92ce.js";
4
- import { a as Qe, b as Xe } from "./const-53dff524.js";
5
- var he = (e) => e.type === "checkbox", ae = (e) => e instanceof Date, H = (e) => e == null;
6
- const ct = (e) => typeof e == "object";
7
- var M = (e) => !H(e) && !Array.isArray(e) && ct(e) && !ae(e), dt = (e) => M(e) && e.target ? he(e.target) ? e.target.checked : e.target.value : e, Ot = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, ft = (e, s) => e.has(Ot(s)), Lt = (e) => {
8
- const s = e.constructor && e.constructor.prototype;
9
- return M(s) && s.hasOwnProperty("isPrototypeOf");
10
- }, Le = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
11
- function N(e) {
12
- let s;
13
- const t = Array.isArray(e), i = typeof FileList < "u" ? e instanceof FileList : !1;
14
- if (e instanceof Date)
15
- s = new Date(e);
16
- else if (!(Le && (e instanceof Blob || i)) && (t || M(e)))
17
- if (s = t ? [] : Object.create(Object.getPrototypeOf(e)), !t && !Lt(e))
18
- s = e;
19
- else
20
- for (const u in e)
21
- e.hasOwnProperty(u) && (s[u] = N(e[u]));
22
- else
23
- return e;
24
- return s;
25
- }
26
- var Fe = (e) => /^\w*$/.test(e), O = (e) => e === void 0, Te = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Me = (e) => Te(e.replace(/["|']|\]/g, "").split(/\.|\[/)), y = (e, s, t) => {
27
- if (!s || !M(e))
28
- return t;
29
- const i = (Fe(s) ? [s] : Me(s)).reduce((u, n) => H(u) ? u : u[n], e);
30
- return O(i) || i === e ? O(e[s]) ? t : e[s] : i;
31
- }, j = (e) => typeof e == "boolean", E = (e, s, t) => {
32
- let i = -1;
33
- const u = Fe(s) ? [s] : Me(s), n = u.length, c = n - 1;
34
- for (; ++i < n; ) {
35
- const d = u[i];
36
- let k = t;
37
- if (i !== c) {
38
- const C = e[d];
39
- k = M(C) || Array.isArray(C) ? C : isNaN(+u[i + 1]) ? {} : [];
40
- }
41
- if (d === "__proto__" || d === "constructor" || d === "prototype")
42
- return;
43
- e[d] = k, e = e[d];
44
- }
45
- };
46
- const be = {
47
- BLUR: "blur",
48
- FOCUS_OUT: "focusout",
49
- CHANGE: "change"
50
- }, Y = {
51
- onBlur: "onBlur",
52
- onChange: "onChange",
53
- onSubmit: "onSubmit",
54
- onTouched: "onTouched",
55
- all: "all"
56
- }, re = {
57
- max: "max",
58
- min: "min",
59
- maxLength: "maxLength",
60
- minLength: "minLength",
61
- pattern: "pattern",
62
- required: "required",
63
- validate: "validate"
64
- }, Ne = m.createContext(null);
65
- Ne.displayName = "HookFormContext";
66
- const Ue = () => m.useContext(Ne), Tt = (e) => {
67
- const { children: s, ...t } = e;
68
- return m.createElement(Ne.Provider, { value: t }, s);
69
- };
70
- var yt = (e, s, t, i = !0) => {
71
- const u = {
72
- defaultValues: s._defaultValues
73
- };
74
- for (const n in e)
75
- Object.defineProperty(u, n, {
76
- get: () => {
77
- const c = n;
78
- return s._proxyFormState[c] !== Y.all && (s._proxyFormState[c] = !i || Y.all), t && (t[c] = !0), e[c];
79
- }
80
- });
81
- return u;
82
- };
83
- const pe = typeof window < "u" ? m.useLayoutEffect : m.useEffect;
84
- function Mt(e) {
85
- const s = Ue(), { control: t = s.control, disabled: i, name: u, exact: n } = e || {}, [c, d] = m.useState(t._formState), k = m.useRef({
86
- isDirty: !1,
87
- isLoading: !1,
88
- dirtyFields: !1,
89
- touchedFields: !1,
90
- validatingFields: !1,
91
- isValidating: !1,
92
- isValid: !1,
93
- errors: !1
94
- });
95
- return pe(() => t._subscribe({
96
- name: u,
97
- formState: k.current,
98
- exact: n,
99
- callback: (C) => {
100
- !i && d({
101
- ...t._formState,
102
- ...C
103
- });
104
- }
105
- }), [u, i, n]), m.useEffect(() => {
106
- k.current.isValid && t._setValid(!0);
107
- }, [t]), m.useMemo(() => yt(c, t, k.current, !1), [c, t]);
108
- }
109
- var G = (e) => typeof e == "string", Ce = (e, s, t, i, u) => G(e) ? (i && s.watch.add(e), y(t, e, u)) : Array.isArray(e) ? e.map((n) => (i && s.watch.add(n), y(t, n))) : (i && (s.watchAll = !0), t), Re = (e) => H(e) || !ct(e);
110
- function J(e, s, t = /* @__PURE__ */ new WeakSet()) {
111
- if (Re(e) || Re(s))
112
- return Object.is(e, s);
113
- if (ae(e) && ae(s))
114
- return e.getTime() === s.getTime();
115
- const i = Object.keys(e), u = Object.keys(s);
116
- if (i.length !== u.length)
117
- return !1;
118
- if (t.has(e) || t.has(s))
119
- return !0;
120
- t.add(e), t.add(s);
121
- for (const n of i) {
122
- const c = e[n];
123
- if (!u.includes(n))
124
- return !1;
125
- if (n !== "ref") {
126
- const d = s[n];
127
- if (ae(c) && ae(d) || M(c) && M(d) || Array.isArray(c) && Array.isArray(d) ? !J(c, d, t) : !Object.is(c, d))
128
- return !1;
129
- }
130
- }
131
- return !0;
132
- }
133
- function Nt(e) {
134
- const s = Ue(), { control: t = s.control, name: i, defaultValue: u, disabled: n, exact: c, compute: d } = e || {}, k = m.useRef(u), C = m.useRef(d), F = m.useRef(void 0), b = m.useRef(t), v = m.useRef(i);
135
- C.current = d;
136
- const [X, q] = m.useState(() => {
137
- const V = t._getWatch(i, k.current);
138
- return C.current ? C.current(V) : V;
139
- }), R = m.useCallback((V) => {
140
- const x = Ce(i, t._names, V || t._formValues, !1, k.current);
141
- return C.current ? C.current(x) : x;
142
- }, [t._formValues, t._names, i]), U = m.useCallback((V) => {
143
- if (!n) {
144
- const x = Ce(i, t._names, V || t._formValues, !1, k.current);
145
- if (C.current) {
146
- const z = C.current(x);
147
- J(z, F.current) || (q(z), F.current = z);
148
- } else
149
- q(x);
150
- }
151
- }, [t._formValues, t._names, n, i]);
152
- pe(() => ((b.current !== t || !J(v.current, i)) && (b.current = t, v.current = i, U()), t._subscribe({
153
- name: i,
154
- formState: {
155
- values: !0
156
- },
157
- exact: c,
158
- callback: (V) => {
159
- U(V.values);
160
- }
161
- })), [t, c, i, U]), m.useEffect(() => t._removeUnmounted());
162
- const Z = b.current !== t, _ = v.current, p = m.useMemo(() => {
163
- if (n)
164
- return null;
165
- const V = !Z && !J(_, i);
166
- return Z || V ? R() : null;
167
- }, [n, Z, i, _, R]);
168
- return p !== null ? p : X;
169
- }
170
- function Ut(e) {
171
- const s = Ue(), { name: t, disabled: i, control: u = s.control, shouldUnregister: n, defaultValue: c, exact: d = !0 } = e, k = ft(u._names.array, t), C = m.useMemo(() => y(u._formValues, t, y(u._defaultValues, t, c)), [u, t, c]), F = Nt({
172
- control: u,
173
- name: t,
174
- defaultValue: C,
175
- exact: d
176
- }), b = Mt({
177
- control: u,
178
- name: t,
179
- exact: d
180
- }), v = m.useRef(e), X = m.useRef(void 0), q = m.useRef(u.register(t, {
181
- ...e.rules,
182
- value: F,
183
- ...j(e.disabled) ? { disabled: e.disabled } : {}
184
- }));
185
- v.current = e;
186
- const R = m.useMemo(() => Object.defineProperties({}, {
187
- invalid: {
188
- enumerable: !0,
189
- get: () => !!y(b.errors, t)
190
- },
191
- isDirty: {
192
- enumerable: !0,
193
- get: () => !!y(b.dirtyFields, t)
194
- },
195
- isTouched: {
196
- enumerable: !0,
197
- get: () => !!y(b.touchedFields, t)
198
- },
199
- isValidating: {
200
- enumerable: !0,
201
- get: () => !!y(b.validatingFields, t)
202
- },
203
- error: {
204
- enumerable: !0,
205
- get: () => y(b.errors, t)
206
- }
207
- }), [b, t]), U = m.useCallback((V) => q.current.onChange({
208
- target: {
209
- value: dt(V),
210
- name: t
211
- },
212
- type: be.CHANGE
213
- }), [t]), Z = m.useCallback(() => q.current.onBlur({
214
- target: {
215
- value: y(u._formValues, t),
216
- name: t
217
- },
218
- type: be.BLUR
219
- }), [t, u._formValues]), _ = m.useCallback((V) => {
220
- const x = y(u._fields, t);
221
- x && V && (x._f.ref = {
222
- focus: () => V.focus && V.focus(),
223
- select: () => V.select && V.select(),
224
- setCustomValidity: (z) => V.setCustomValidity(z),
225
- reportValidity: () => V.reportValidity()
226
- });
227
- }, [u._fields, t]), p = m.useMemo(() => ({
228
- name: t,
229
- value: F,
230
- ...j(i) || b.disabled ? { disabled: b.disabled || i } : {},
231
- onChange: U,
232
- onBlur: Z,
233
- ref: _
234
- }), [t, i, b.disabled, U, Z, _, F]);
235
- return m.useEffect(() => {
236
- const V = u._options.shouldUnregister || n, x = X.current;
237
- x && x !== t && !k && u.unregister(x), u.register(t, {
238
- ...v.current.rules,
239
- ...j(v.current.disabled) ? { disabled: v.current.disabled } : {}
240
- });
241
- const z = ($, ce) => {
242
- const B = y(u._fields, $);
243
- B && B._f && (B._f.mount = ce);
244
- };
245
- if (z(t, !0), V) {
246
- const $ = N(y(u._options.defaultValues, t, v.current.defaultValue));
247
- E(u._defaultValues, t, $), O(y(u._formValues, t)) && E(u._formValues, t, $);
248
- }
249
- return !k && u.register(t), X.current = t, () => {
250
- (k ? V && !u._state.action : V) ? u.unregister(t) : z(t, !1);
251
- };
252
- }, [t, u, k, n]), m.useEffect(() => {
253
- u._setDisabledField({
254
- disabled: i,
255
- name: t
256
- });
257
- }, [i, t, u]), m.useMemo(() => ({
258
- field: p,
259
- formState: b,
260
- fieldState: R
261
- }), [p, b, R]);
262
- }
263
- const ir = (e) => e.render(Ut(e));
264
- var pt = (e, s, t, i, u) => s ? {
265
- ...t[e],
266
- types: {
267
- ...t[e] && t[e].types ? t[e].types : {},
268
- [i]: u || !0
269
- }
270
- } : {}, ye = (e) => Array.isArray(e) ? e : [e], Ze = () => {
271
- let e = [];
272
- return {
273
- get observers() {
274
- return e;
275
- },
276
- next: (u) => {
277
- for (const n of e)
278
- n.next && n.next(u);
279
- },
280
- subscribe: (u) => (e.push(u), {
281
- unsubscribe: () => {
282
- e = e.filter((n) => n !== u);
283
- }
284
- }),
285
- unsubscribe: () => {
286
- e = [];
287
- }
288
- };
289
- };
290
- function gt(e, s) {
291
- const t = {};
292
- for (const i in e)
293
- if (e.hasOwnProperty(i)) {
294
- const u = e[i], n = s[i];
295
- if (u && M(u) && n) {
296
- const c = gt(u, n);
297
- M(c) && (t[i] = c);
298
- } else
299
- e[i] && (t[i] = n);
300
- }
301
- return t;
302
- }
303
- var P = (e) => M(e) && !Object.keys(e).length, Be = (e) => e.type === "file", Q = (e) => typeof e == "function", _e = (e) => {
304
- if (!Le)
305
- return !1;
306
- const s = e ? e.ownerDocument : 0;
307
- return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
308
- }, ht = (e) => e.type === "select-multiple", Ie = (e) => e.type === "radio", Bt = (e) => Ie(e) || he(e), Ee = (e) => _e(e) && e.isConnected;
309
- function It(e, s) {
310
- const t = s.slice(0, -1).length;
311
- let i = 0;
312
- for (; i < t; )
313
- e = O(e) ? i++ : e[s[i++]];
314
- return e;
315
- }
316
- function Pt(e) {
317
- for (const s in e)
318
- if (e.hasOwnProperty(s) && !O(e[s]))
319
- return !1;
320
- return !0;
321
- }
322
- function T(e, s) {
323
- const t = Array.isArray(s) ? s : Fe(s) ? [s] : Me(s), i = t.length === 1 ? e : It(e, t), u = t.length - 1, n = t[u];
324
- return i && delete i[n], u !== 0 && (M(i) && P(i) || Array.isArray(i) && Pt(i)) && T(e, t.slice(0, -1)), e;
325
- }
326
- var qt = (e) => {
327
- for (const s in e)
328
- if (Q(e[s]))
329
- return !0;
330
- return !1;
331
- };
332
- function vt(e) {
333
- return Array.isArray(e) || M(e) && !qt(e);
334
- }
335
- function Oe(e, s = {}) {
336
- for (const t in e) {
337
- const i = e[t];
338
- vt(i) ? (s[t] = Array.isArray(i) ? [] : {}, Oe(i, s[t])) : O(i) || (s[t] = !0);
339
- }
340
- return s;
341
- }
342
- function oe(e, s, t) {
343
- t || (t = Oe(s));
344
- for (const i in e) {
345
- const u = e[i];
346
- if (vt(u))
347
- O(s) || Re(t[i]) ? t[i] = Oe(u, Array.isArray(u) ? [] : {}) : oe(u, H(s) ? {} : s[i], t[i]);
348
- else {
349
- const n = s[i];
350
- t[i] = !J(u, n);
351
- }
352
- }
353
- return t;
354
- }
355
- const et = {
356
- value: !1,
357
- isValid: !1
358
- }, tt = { value: !0, isValid: !0 };
359
- var mt = (e) => {
360
- if (Array.isArray(e)) {
361
- if (e.length > 1) {
362
- const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
363
- return { value: s, isValid: !!s.length };
364
- }
365
- return e[0].checked && !e[0].disabled ? (
366
- // @ts-expect-error expected to work in the browser
367
- e[0].attributes && !O(e[0].attributes.value) ? O(e[0].value) || e[0].value === "" ? tt : { value: e[0].value, isValid: !0 } : tt
368
- ) : et;
369
- }
370
- return et;
371
- }, bt = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: i }) => O(e) ? e : s ? e === "" ? NaN : e && +e : t && G(e) ? new Date(e) : i ? i(e) : e;
372
- const rt = {
373
- isValid: !1,
374
- value: null
375
- };
376
- var _t = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
377
- isValid: !0,
378
- value: t.value
379
- } : s, rt) : rt;
380
- function st(e) {
381
- const s = e.ref;
382
- return Be(s) ? s.files : Ie(s) ? _t(e.refs).value : ht(s) ? [...s.selectedOptions].map(({ value: t }) => t) : he(s) ? mt(e.refs).value : bt(O(s.value) ? e.ref.value : s.value, e);
383
- }
384
- var Wt = (e, s, t, i) => {
385
- const u = {};
386
- for (const n of e) {
387
- const c = y(s, n);
388
- c && E(u, n, c._f);
389
- }
390
- return {
391
- criteriaMode: t,
392
- names: [...e],
393
- fields: u,
394
- shouldUseNativeValidation: i
395
- };
396
- }, Ve = (e) => e instanceof RegExp, fe = (e) => O(e) ? e : Ve(e) ? e.source : M(e) ? Ve(e.value) ? e.value.source : e.value : e, it = (e) => ({
397
- isOnSubmit: !e || e === Y.onSubmit,
398
- isOnBlur: e === Y.onBlur,
399
- isOnChange: e === Y.onChange,
400
- isOnAll: e === Y.all,
401
- isOnTouch: e === Y.onTouched
402
- });
403
- const at = "AsyncFunction";
404
- var Ht = (e) => !!e && !!e.validate && !!(Q(e.validate) && e.validate.constructor.name === at || M(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === at)), zt = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), nt = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((i) => e.startsWith(i) && /^\.\w+/.test(e.slice(i.length))));
405
- const ge = (e, s, t, i) => {
406
- for (const u of t || Object.keys(e)) {
407
- const n = y(e, u);
408
- if (n) {
409
- const { _f: c, ...d } = n;
410
- if (c) {
411
- if (c.refs && c.refs[0] && s(c.refs[0], u) && !i)
412
- return !0;
413
- if (c.ref && s(c.ref, c.name) && !i)
414
- return !0;
415
- if (ge(d, s))
416
- break;
417
- } else if (M(d) && ge(d, s))
418
- break;
419
- }
420
- }
421
- };
422
- function lt(e, s, t) {
423
- const i = y(e, t);
424
- if (i || Fe(t))
425
- return {
426
- error: i,
427
- name: t
428
- };
429
- const u = t.split(".");
430
- for (; u.length; ) {
431
- const n = u.join("."), c = y(s, n), d = y(e, n);
432
- if (c && !Array.isArray(c) && t !== n)
433
- return { name: t };
434
- if (d && d.type)
435
- return {
436
- name: n,
437
- error: d
438
- };
439
- if (d && d.root && d.root.type)
440
- return {
441
- name: `${n}.root`,
442
- error: d.root
443
- };
444
- u.pop();
445
- }
446
- return {
447
- name: t
448
- };
449
- }
450
- var $t = (e, s, t, i) => {
451
- t(e);
452
- const { name: u, ...n } = e;
453
- return P(n) || Object.keys(n).length >= Object.keys(s).length || Object.keys(n).find((c) => s[c] === (!i || Y.all));
454
- }, jt = (e, s, t) => !e || !s || e === s || ye(e).some((i) => i && (t ? i === s : i.startsWith(s) || s.startsWith(i))), Gt = (e, s, t, i, u) => u.isOnAll ? !1 : !t && u.isOnTouch ? !(s || e) : (t ? i.isOnBlur : u.isOnBlur) ? !e : (t ? i.isOnChange : u.isOnChange) ? e : !0, Kt = (e, s) => !Te(y(e, s)).length && T(e, s), Yt = (e, s, t) => {
455
- const i = ye(y(e, t));
456
- return E(i, "root", s[t]), E(e, t, i), e;
457
- };
458
- function ut(e, s, t = "validate") {
459
- if (G(e) || Array.isArray(e) && e.every(G) || j(e) && !e)
460
- return {
461
- type: t,
462
- message: G(e) ? e : "",
463
- ref: s
464
- };
465
- }
466
- var ue = (e) => M(e) && !Ve(e) ? e : {
467
- value: e,
468
- message: ""
469
- }, ot = async (e, s, t, i, u, n) => {
470
- const { ref: c, refs: d, required: k, maxLength: C, minLength: F, min: b, max: v, pattern: X, validate: q, name: R, valueAsNumber: U, mount: Z } = e._f, _ = y(t, R);
471
- if (!Z || s.has(R))
472
- return {};
473
- const p = d ? d[0] : c, V = (A) => {
474
- u && p.reportValidity && (p.setCustomValidity(j(A) ? "" : A || ""), p.reportValidity());
475
- }, x = {}, z = Ie(c), $ = he(c), ce = z || $, B = (U || Be(c)) && O(c.value) && O(_) || _e(c) && c.value === "" || _ === "" || Array.isArray(_) && !_.length, ie = pt.bind(null, R, i, x), ee = (A, D, L, I = re.maxLength, W = re.minLength) => {
476
- const te = A ? D : L;
477
- x[R] = {
478
- type: A ? I : W,
479
- message: te,
480
- ref: c,
481
- ...ie(A ? I : W, te)
482
- };
483
- };
484
- if (n ? !Array.isArray(_) || !_.length : k && (!ce && (B || H(_)) || j(_) && !_ || $ && !mt(d).isValid || z && !_t(d).isValid)) {
485
- const { value: A, message: D } = G(k) ? { value: !!k, message: k } : ue(k);
486
- if (A && (x[R] = {
487
- type: re.required,
488
- message: D,
489
- ref: p,
490
- ...ie(re.required, D)
491
- }, !i))
492
- return V(D), x;
493
- }
494
- if (!B && (!H(b) || !H(v))) {
495
- let A, D;
496
- const L = ue(v), I = ue(b);
497
- if (!H(_) && !isNaN(_)) {
498
- const W = c.valueAsNumber || _ && +_;
499
- H(L.value) || (A = W > L.value), H(I.value) || (D = W < I.value);
500
- } else {
501
- const W = c.valueAsDate || new Date(_), te = (ve) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ve), de = c.type == "time", ne = c.type == "week";
502
- G(L.value) && _ && (A = de ? te(_) > te(L.value) : ne ? _ > L.value : W > new Date(L.value)), G(I.value) && _ && (D = de ? te(_) < te(I.value) : ne ? _ < I.value : W < new Date(I.value));
503
- }
504
- if ((A || D) && (ee(!!A, L.message, I.message, re.max, re.min), !i))
505
- return V(x[R].message), x;
506
- }
507
- if ((C || F) && !B && (G(_) || n && Array.isArray(_))) {
508
- const A = ue(C), D = ue(F), L = !H(A.value) && _.length > +A.value, I = !H(D.value) && _.length < +D.value;
509
- if ((L || I) && (ee(L, A.message, D.message), !i))
510
- return V(x[R].message), x;
511
- }
512
- if (X && !B && G(_)) {
513
- const { value: A, message: D } = ue(X);
514
- if (Ve(A) && !_.match(A) && (x[R] = {
515
- type: re.pattern,
516
- message: D,
517
- ref: c,
518
- ...ie(re.pattern, D)
519
- }, !i))
520
- return V(D), x;
521
- }
522
- if (q) {
523
- if (Q(q)) {
524
- const A = await q(_, t), D = ut(A, p);
525
- if (D && (x[R] = {
526
- ...D,
527
- ...ie(re.validate, D.message)
528
- }, !i))
529
- return V(D.message), x;
530
- } else if (M(q)) {
531
- let A = {};
532
- for (const D in q) {
533
- if (!P(A) && !i)
534
- break;
535
- const L = ut(await q[D](_, t), p, D);
536
- L && (A = {
537
- ...L,
538
- ...ie(D, L.message)
539
- }, V(L.message), i && (x[R] = A));
540
- }
541
- if (!P(A) && (x[R] = {
542
- ref: p,
543
- ...A
544
- }, !i))
545
- return x;
546
- }
547
- }
548
- return V(!0), x;
549
- };
550
- const Jt = {
551
- mode: Y.onSubmit,
552
- reValidateMode: Y.onChange,
553
- shouldFocusError: !0
554
- };
555
- function Qt(e = {}) {
556
- let s = {
557
- ...Jt,
558
- ...e
559
- }, t = {
560
- submitCount: 0,
561
- isDirty: !1,
562
- isReady: !1,
563
- isLoading: Q(s.defaultValues),
564
- isValidating: !1,
565
- isSubmitted: !1,
566
- isSubmitting: !1,
567
- isSubmitSuccessful: !1,
568
- isValid: !1,
569
- touchedFields: {},
570
- dirtyFields: {},
571
- validatingFields: {},
572
- errors: s.errors || {},
573
- disabled: s.disabled || !1
574
- }, i = {}, u = M(s.defaultValues) || M(s.values) ? N(s.defaultValues || s.values) || {} : {}, n = s.shouldUnregister ? {} : N(u), c = {
575
- action: !1,
576
- mount: !1,
577
- watch: !1
578
- }, d = {
579
- mount: /* @__PURE__ */ new Set(),
580
- disabled: /* @__PURE__ */ new Set(),
581
- unMount: /* @__PURE__ */ new Set(),
582
- array: /* @__PURE__ */ new Set(),
583
- watch: /* @__PURE__ */ new Set()
584
- }, k, C = 0;
585
- const F = {
586
- isDirty: !1,
587
- dirtyFields: !1,
588
- validatingFields: !1,
589
- touchedFields: !1,
590
- isValidating: !1,
591
- isValid: !1,
592
- errors: !1
593
- };
594
- let b = {
595
- ...F
596
- };
597
- const v = {
598
- array: Ze(),
599
- state: Ze()
600
- }, X = s.criteriaMode === Y.all, q = (r) => (a) => {
601
- clearTimeout(C), C = setTimeout(r, a);
602
- }, R = async (r) => {
603
- if (!s.disabled && (F.isValid || b.isValid || r)) {
604
- const a = s.resolver ? P((await $()).errors) : await B(i, !0);
605
- a !== t.isValid && v.state.next({
606
- isValid: a
607
- });
608
- }
609
- }, U = (r, a) => {
610
- !s.disabled && (F.isValidating || F.validatingFields || b.isValidating || b.validatingFields) && ((r || Array.from(d.mount)).forEach((l) => {
611
- l && (a ? E(t.validatingFields, l, a) : T(t.validatingFields, l));
612
- }), v.state.next({
613
- validatingFields: t.validatingFields,
614
- isValidating: !P(t.validatingFields)
615
- }));
616
- }, Z = (r, a = [], l, g, f = !0, o = !0) => {
617
- if (g && l && !s.disabled) {
618
- if (c.action = !0, o && Array.isArray(y(i, r))) {
619
- const h = l(y(i, r), g.argA, g.argB);
620
- f && E(i, r, h);
621
- }
622
- if (o && Array.isArray(y(t.errors, r))) {
623
- const h = l(y(t.errors, r), g.argA, g.argB);
624
- f && E(t.errors, r, h), Kt(t.errors, r);
625
- }
626
- if ((F.touchedFields || b.touchedFields) && o && Array.isArray(y(t.touchedFields, r))) {
627
- const h = l(y(t.touchedFields, r), g.argA, g.argB);
628
- f && E(t.touchedFields, r, h);
629
- }
630
- (F.dirtyFields || b.dirtyFields) && (t.dirtyFields = oe(u, n)), v.state.next({
631
- name: r,
632
- isDirty: ee(r, a),
633
- dirtyFields: t.dirtyFields,
634
- errors: t.errors,
635
- isValid: t.isValid
636
- });
637
- } else
638
- E(n, r, a);
639
- }, _ = (r, a) => {
640
- E(t.errors, r, a), v.state.next({
641
- errors: t.errors
642
- });
643
- }, p = (r) => {
644
- t.errors = r, v.state.next({
645
- errors: t.errors,
646
- isValid: !1
647
- });
648
- }, V = (r, a, l, g) => {
649
- const f = y(i, r);
650
- if (f) {
651
- const o = y(n, r, O(l) ? y(u, r) : l);
652
- O(o) || g && g.defaultChecked || a ? E(n, r, a ? o : st(f._f)) : L(r, o), c.mount && !c.action && R();
653
- }
654
- }, x = (r, a, l, g, f) => {
655
- let o = !1, h = !1;
656
- const w = {
657
- name: r
658
- };
659
- if (!s.disabled) {
660
- if (!l || g) {
661
- (F.isDirty || b.isDirty) && (h = t.isDirty, t.isDirty = w.isDirty = ee(), o = h !== w.isDirty);
662
- const S = J(y(u, r), a);
663
- h = !!y(t.dirtyFields, r), S ? T(t.dirtyFields, r) : E(t.dirtyFields, r, !0), w.dirtyFields = t.dirtyFields, o = o || (F.dirtyFields || b.dirtyFields) && h !== !S;
664
- }
665
- if (l) {
666
- const S = y(t.touchedFields, r);
667
- S || (E(t.touchedFields, r, l), w.touchedFields = t.touchedFields, o = o || (F.touchedFields || b.touchedFields) && S !== l);
668
- }
669
- o && f && v.state.next(w);
670
- }
671
- return o ? w : {};
672
- }, z = (r, a, l, g) => {
673
- const f = y(t.errors, r), o = (F.isValid || b.isValid) && j(a) && t.isValid !== a;
674
- if (s.delayError && l ? (k = q(() => _(r, l)), k(s.delayError)) : (clearTimeout(C), k = null, l ? E(t.errors, r, l) : T(t.errors, r)), (l ? !J(f, l) : f) || !P(g) || o) {
675
- const h = {
676
- ...g,
677
- ...o && j(a) ? { isValid: a } : {},
678
- errors: t.errors,
679
- name: r
680
- };
681
- t = {
682
- ...t,
683
- ...h
684
- }, v.state.next(h);
685
- }
686
- }, $ = async (r) => {
687
- U(r, !0);
688
- const a = await s.resolver(n, s.context, Wt(r || d.mount, i, s.criteriaMode, s.shouldUseNativeValidation));
689
- return U(r), a;
690
- }, ce = async (r) => {
691
- const { errors: a } = await $(r);
692
- if (r)
693
- for (const l of r) {
694
- const g = y(a, l);
695
- g ? E(t.errors, l, g) : T(t.errors, l);
696
- }
697
- else
698
- t.errors = a;
699
- return a;
700
- }, B = async (r, a, l = {
701
- valid: !0
702
- }) => {
703
- for (const g in r) {
704
- const f = r[g];
705
- if (f) {
706
- const { _f: o, ...h } = f;
707
- if (o) {
708
- const w = d.array.has(o.name), S = f._f && Ht(f._f);
709
- S && F.validatingFields && U([o.name], !0);
710
- const K = await ot(f, d.disabled, n, X, s.shouldUseNativeValidation && !a, w);
711
- if (S && F.validatingFields && U([o.name]), K[o.name] && (l.valid = !1, a))
712
- break;
713
- !a && (y(K, o.name) ? w ? Yt(t.errors, K, o.name) : E(t.errors, o.name, K[o.name]) : T(t.errors, o.name));
714
- }
715
- !P(h) && await B(h, a, l);
716
- }
717
- }
718
- return l.valid;
719
- }, ie = () => {
720
- for (const r of d.unMount) {
721
- const a = y(i, r);
722
- a && (a._f.refs ? a._f.refs.every((l) => !Ee(l)) : !Ee(a._f.ref)) && xe(r);
723
- }
724
- d.unMount = /* @__PURE__ */ new Set();
725
- }, ee = (r, a) => !s.disabled && (r && a && E(n, r, a), !J(ve(), u)), A = (r, a, l) => Ce(r, d, {
726
- ...c.mount ? n : O(a) ? u : G(r) ? { [r]: a } : a
727
- }, l, a), D = (r) => Te(y(c.mount ? n : u, r, s.shouldUnregister ? y(u, r, []) : [])), L = (r, a, l = {}) => {
728
- const g = y(i, r);
729
- let f = a;
730
- if (g) {
731
- const o = g._f;
732
- o && (!o.disabled && E(n, r, bt(a, o)), f = _e(o.ref) && H(a) ? "" : a, ht(o.ref) ? [...o.ref.options].forEach((h) => h.selected = f.includes(h.value)) : o.refs ? he(o.ref) ? o.refs.forEach((h) => {
733
- (!h.defaultChecked || !h.disabled) && (Array.isArray(f) ? h.checked = !!f.find((w) => w === h.value) : h.checked = f === h.value || !!f);
734
- }) : o.refs.forEach((h) => h.checked = h.value === f) : Be(o.ref) ? o.ref.value = "" : (o.ref.value = f, o.ref.type || v.state.next({
735
- name: r,
736
- values: N(n)
737
- })));
738
- }
739
- (l.shouldDirty || l.shouldTouch) && x(r, f, l.shouldTouch, l.shouldDirty, !0), l.shouldValidate && ne(r);
740
- }, I = (r, a, l) => {
741
- for (const g in a) {
742
- if (!a.hasOwnProperty(g))
743
- return;
744
- const f = a[g], o = r + "." + g, h = y(i, o);
745
- (d.array.has(r) || M(f) || h && !h._f) && !ae(f) ? I(o, f, l) : L(o, f, l);
746
- }
747
- }, W = (r, a, l = {}) => {
748
- const g = y(i, r), f = d.array.has(r), o = N(a);
749
- E(n, r, o), f ? (v.array.next({
750
- name: r,
751
- values: N(n)
752
- }), (F.isDirty || F.dirtyFields || b.isDirty || b.dirtyFields) && l.shouldDirty && v.state.next({
753
- name: r,
754
- dirtyFields: oe(u, n),
755
- isDirty: ee(r, o)
756
- })) : g && !g._f && !H(o) ? I(r, o, l) : L(r, o, l), nt(r, d) && v.state.next({ ...t, name: r }), v.state.next({
757
- name: c.mount ? r : void 0,
758
- values: N(n)
759
- });
760
- }, te = async (r) => {
761
- c.mount = !0;
762
- const a = r.target;
763
- let l = a.name, g = !0;
764
- const f = y(i, l), o = (S) => {
765
- g = Number.isNaN(S) || ae(S) && isNaN(S.getTime()) || J(S, y(n, l, S));
766
- }, h = it(s.mode), w = it(s.reValidateMode);
767
- if (f) {
768
- let S, K;
769
- const me = a.type ? st(f._f) : dt(r), se = r.type === be.BLUR || r.type === be.FOCUS_OUT, St = !zt(f._f) && !s.resolver && !y(t.errors, l) && !f._f.deps || Gt(se, y(t.touchedFields, l), t.isSubmitted, w, h), we = nt(l, d, se);
770
- E(n, l, me), se ? (!a || !a.readOnly) && (f._f.onBlur && f._f.onBlur(r), k && k(0)) : f._f.onChange && f._f.onChange(r);
771
- const De = x(l, me, se), Et = !P(De) || we;
772
- if (!se && v.state.next({
773
- name: l,
774
- type: r.type,
775
- values: N(n)
776
- }), St)
777
- return (F.isValid || b.isValid) && (s.mode === "onBlur" ? se && R() : se || R()), Et && v.state.next({ name: l, ...we ? {} : De });
778
- if (!se && we && v.state.next({ ...t }), s.resolver) {
779
- const { errors: Ke } = await $([l]);
780
- if (o(me), g) {
781
- const Ct = lt(t.errors, i, l), Ye = lt(Ke, i, Ct.name || l);
782
- S = Ye.error, l = Ye.name, K = P(Ke);
783
- }
784
- } else
785
- U([l], !0), S = (await ot(f, d.disabled, n, X, s.shouldUseNativeValidation))[l], U([l]), o(me), g && (S ? K = !1 : (F.isValid || b.isValid) && (K = await B(i, !0)));
786
- g && (f._f.deps && (!Array.isArray(f._f.deps) || f._f.deps.length > 0) && ne(f._f.deps), z(l, K, S, De));
787
- }
788
- }, de = (r, a) => {
789
- if (y(t.errors, a) && r.focus)
790
- return r.focus(), 1;
791
- }, ne = async (r, a = {}) => {
792
- let l, g;
793
- const f = ye(r);
794
- if (s.resolver) {
795
- const o = await ce(O(r) ? r : f);
796
- l = P(o), g = r ? !f.some((h) => y(o, h)) : l;
797
- } else
798
- r ? (g = (await Promise.all(f.map(async (o) => {
799
- const h = y(i, o);
800
- return await B(h && h._f ? { [o]: h } : h);
801
- }))).every(Boolean), !(!g && !t.isValid) && R()) : g = l = await B(i);
802
- return v.state.next({
803
- ...!G(r) || (F.isValid || b.isValid) && l !== t.isValid ? {} : { name: r },
804
- ...s.resolver || !r ? { isValid: l } : {},
805
- errors: t.errors
806
- }), a.shouldFocus && !g && ge(i, de, r ? f : d.mount), g;
807
- }, ve = (r, a) => {
808
- let l = {
809
- ...c.mount ? n : u
810
- };
811
- return a && (l = gt(a.dirtyFields ? t.dirtyFields : t.touchedFields, l)), O(r) ? l : G(r) ? y(l, r) : r.map((g) => y(l, g));
812
- }, Pe = (r, a) => ({
813
- invalid: !!y((a || t).errors, r),
814
- isDirty: !!y((a || t).dirtyFields, r),
815
- error: y((a || t).errors, r),
816
- isValidating: !!y(t.validatingFields, r),
817
- isTouched: !!y((a || t).touchedFields, r)
818
- }), Vt = (r) => {
819
- r && ye(r).forEach((a) => T(t.errors, a)), v.state.next({
820
- errors: r ? t.errors : {}
821
- });
822
- }, qe = (r, a, l) => {
823
- const g = (y(i, r, { _f: {} })._f || {}).ref, f = y(t.errors, r) || {}, { ref: o, message: h, type: w, ...S } = f;
824
- E(t.errors, r, {
825
- ...S,
826
- ...a,
827
- ref: g
828
- }), v.state.next({
829
- name: r,
830
- errors: t.errors,
831
- isValid: !1
832
- }), l && l.shouldFocus && g && g.focus && g.focus();
833
- }, Ft = (r, a) => Q(r) ? v.state.subscribe({
834
- next: (l) => "values" in l && r(A(void 0, a), l)
835
- }) : A(r, a, !0), We = (r) => v.state.subscribe({
836
- next: (a) => {
837
- jt(r.name, a.name, r.exact) && $t(a, r.formState || F, Dt, r.reRenderRoot) && r.callback({
838
- values: { ...n },
839
- ...t,
840
- ...a,
841
- defaultValues: u
842
- });
843
- }
844
- }).unsubscribe, xt = (r) => (c.mount = !0, b = {
845
- ...b,
846
- ...r.formState
847
- }, We({
848
- ...r,
849
- formState: b
850
- })), xe = (r, a = {}) => {
851
- for (const l of r ? ye(r) : d.mount)
852
- d.mount.delete(l), d.array.delete(l), a.keepValue || (T(i, l), T(n, l)), !a.keepError && T(t.errors, l), !a.keepDirty && T(t.dirtyFields, l), !a.keepTouched && T(t.touchedFields, l), !a.keepIsValidating && T(t.validatingFields, l), !s.shouldUnregister && !a.keepDefaultValue && T(u, l);
853
- v.state.next({
854
- values: N(n)
855
- }), v.state.next({
856
- ...t,
857
- ...a.keepDirty ? { isDirty: ee() } : {}
858
- }), !a.keepIsValid && R();
859
- }, He = ({ disabled: r, name: a }) => {
860
- (j(r) && c.mount || r || d.disabled.has(a)) && (r ? d.disabled.add(a) : d.disabled.delete(a));
861
- }, Ae = (r, a = {}) => {
862
- let l = y(i, r);
863
- const g = j(a.disabled) || j(s.disabled);
864
- return E(i, r, {
865
- ...l || {},
866
- _f: {
867
- ...l && l._f ? l._f : { ref: { name: r } },
868
- name: r,
869
- mount: !0,
870
- ...a
871
- }
872
- }), d.mount.add(r), l ? He({
873
- disabled: j(a.disabled) ? a.disabled : s.disabled,
874
- name: r
875
- }) : V(r, !0, a.value), {
876
- ...g ? { disabled: a.disabled || s.disabled } : {},
877
- ...s.progressive ? {
878
- required: !!a.required,
879
- min: fe(a.min),
880
- max: fe(a.max),
881
- minLength: fe(a.minLength),
882
- maxLength: fe(a.maxLength),
883
- pattern: fe(a.pattern)
884
- } : {},
885
- name: r,
886
- onChange: te,
887
- onBlur: te,
888
- ref: (f) => {
889
- if (f) {
890
- Ae(r, a), l = y(i, r);
891
- const o = O(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, h = Bt(o), w = l._f.refs || [];
892
- if (h ? w.find((S) => S === o) : o === l._f.ref)
893
- return;
894
- E(i, r, {
895
- _f: {
896
- ...l._f,
897
- ...h ? {
898
- refs: [
899
- ...w.filter(Ee),
900
- o,
901
- ...Array.isArray(y(u, r)) ? [{}] : []
902
- ],
903
- ref: { type: o.type, name: r }
904
- } : { ref: o }
905
- }
906
- }), V(r, !1, void 0, o);
907
- } else
908
- l = y(i, r, {}), l._f && (l._f.mount = !1), (s.shouldUnregister || a.shouldUnregister) && !(ft(d.array, r) && c.action) && d.unMount.add(r);
909
- }
910
- };
911
- }, ke = () => s.shouldFocusError && ge(i, de, d.mount), At = (r) => {
912
- j(r) && (v.state.next({ disabled: r }), ge(i, (a, l) => {
913
- const g = y(i, l);
914
- g && (a.disabled = g._f.disabled || r, Array.isArray(g._f.refs) && g._f.refs.forEach((f) => {
915
- f.disabled = g._f.disabled || r;
916
- }));
917
- }, 0, !1));
918
- }, ze = (r, a) => async (l) => {
919
- let g;
920
- l && (l.preventDefault && l.preventDefault(), l.persist && l.persist());
921
- let f = N(n);
922
- if (v.state.next({
923
- isSubmitting: !0
924
- }), s.resolver) {
925
- const { errors: o, values: h } = await $();
926
- t.errors = o, f = N(h);
927
- } else
928
- await B(i);
929
- if (d.disabled.size)
930
- for (const o of d.disabled)
931
- T(f, o);
932
- if (T(t.errors, "root"), P(t.errors)) {
933
- v.state.next({
934
- errors: {}
935
- });
936
- try {
937
- await r(f, l);
938
- } catch (o) {
939
- g = o;
940
- }
941
- } else
942
- a && await a({ ...t.errors }, l), ke(), setTimeout(ke);
943
- if (v.state.next({
944
- isSubmitted: !0,
945
- isSubmitting: !1,
946
- isSubmitSuccessful: P(t.errors) && !g,
947
- submitCount: t.submitCount + 1,
948
- errors: t.errors
949
- }), g)
950
- throw g;
951
- }, kt = (r, a = {}) => {
952
- y(i, r) && (O(a.defaultValue) ? W(r, N(y(u, r))) : (W(r, a.defaultValue), E(u, r, N(a.defaultValue))), a.keepTouched || T(t.touchedFields, r), a.keepDirty || (T(t.dirtyFields, r), t.isDirty = a.defaultValue ? ee(r, N(y(u, r))) : ee()), a.keepError || (T(t.errors, r), F.isValid && R()), v.state.next({ ...t }));
953
- }, $e = (r, a = {}) => {
954
- const l = r ? N(r) : u, g = N(l), f = P(r), o = f ? u : g;
955
- if (a.keepDefaultValues || (u = l), !a.keepValues) {
956
- if (a.keepDirtyValues) {
957
- const h = /* @__PURE__ */ new Set([
958
- ...d.mount,
959
- ...Object.keys(oe(u, n))
960
- ]);
961
- for (const w of Array.from(h))
962
- y(t.dirtyFields, w) ? E(o, w, y(n, w)) : W(w, y(o, w));
963
- } else {
964
- if (Le && O(r))
965
- for (const h of d.mount) {
966
- const w = y(i, h);
967
- if (w && w._f) {
968
- const S = Array.isArray(w._f.refs) ? w._f.refs[0] : w._f.ref;
969
- if (_e(S)) {
970
- const K = S.closest("form");
971
- if (K) {
972
- K.reset();
973
- break;
974
- }
975
- }
976
- }
977
- }
978
- if (a.keepFieldsRef)
979
- for (const h of d.mount)
980
- W(h, y(o, h));
981
- else
982
- i = {};
983
- }
984
- n = s.shouldUnregister ? a.keepDefaultValues ? N(u) : {} : N(o), v.array.next({
985
- values: { ...o }
986
- }), v.state.next({
987
- values: { ...o }
988
- });
989
- }
990
- d = {
991
- mount: a.keepDirtyValues ? d.mount : /* @__PURE__ */ new Set(),
992
- unMount: /* @__PURE__ */ new Set(),
993
- array: /* @__PURE__ */ new Set(),
994
- disabled: /* @__PURE__ */ new Set(),
995
- watch: /* @__PURE__ */ new Set(),
996
- watchAll: !1,
997
- focus: ""
998
- }, c.mount = !F.isValid || !!a.keepIsValid || !!a.keepDirtyValues || !s.shouldUnregister && !P(o), c.watch = !!s.shouldUnregister, c.action = !1, a.keepErrors || (t.errors = {}), v.state.next({
999
- submitCount: a.keepSubmitCount ? t.submitCount : 0,
1000
- isDirty: f ? !1 : a.keepDirty ? t.isDirty : !!(a.keepDefaultValues && !J(r, u)),
1001
- isSubmitted: a.keepIsSubmitted ? t.isSubmitted : !1,
1002
- dirtyFields: f ? {} : a.keepDirtyValues ? a.keepDefaultValues && n ? oe(u, n) : t.dirtyFields : a.keepDefaultValues && r ? oe(u, r) : a.keepDirty ? t.dirtyFields : {},
1003
- touchedFields: a.keepTouched ? t.touchedFields : {},
1004
- errors: a.keepErrors ? t.errors : {},
1005
- isSubmitSuccessful: a.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
1006
- isSubmitting: !1,
1007
- defaultValues: u
1008
- });
1009
- }, je = (r, a) => $e(Q(r) ? r(n) : r, a), wt = (r, a = {}) => {
1010
- const l = y(i, r), g = l && l._f;
1011
- if (g) {
1012
- const f = g.refs ? g.refs[0] : g.ref;
1013
- f.focus && (f.focus(), a.shouldSelect && Q(f.select) && f.select());
1014
- }
1015
- }, Dt = (r) => {
1016
- t = {
1017
- ...t,
1018
- ...r
1019
- };
1020
- }, Ge = {
1021
- control: {
1022
- register: Ae,
1023
- unregister: xe,
1024
- getFieldState: Pe,
1025
- handleSubmit: ze,
1026
- setError: qe,
1027
- _subscribe: We,
1028
- _runSchema: $,
1029
- _focusError: ke,
1030
- _getWatch: A,
1031
- _getDirty: ee,
1032
- _setValid: R,
1033
- _setFieldArray: Z,
1034
- _setDisabledField: He,
1035
- _setErrors: p,
1036
- _getFieldArray: D,
1037
- _reset: $e,
1038
- _resetDefaultValues: () => Q(s.defaultValues) && s.defaultValues().then((r) => {
1039
- je(r, s.resetOptions), v.state.next({
1040
- isLoading: !1
1041
- });
1042
- }),
1043
- _removeUnmounted: ie,
1044
- _disableForm: At,
1045
- _subjects: v,
1046
- _proxyFormState: F,
1047
- get _fields() {
1048
- return i;
1049
- },
1050
- get _formValues() {
1051
- return n;
1052
- },
1053
- get _state() {
1054
- return c;
1055
- },
1056
- set _state(r) {
1057
- c = r;
1058
- },
1059
- get _defaultValues() {
1060
- return u;
1061
- },
1062
- get _names() {
1063
- return d;
1064
- },
1065
- set _names(r) {
1066
- d = r;
1067
- },
1068
- get _formState() {
1069
- return t;
1070
- },
1071
- get _options() {
1072
- return s;
1073
- },
1074
- set _options(r) {
1075
- s = {
1076
- ...s,
1077
- ...r
1078
- };
1079
- }
1080
- },
1081
- subscribe: xt,
1082
- trigger: ne,
1083
- register: Ae,
1084
- handleSubmit: ze,
1085
- watch: Ft,
1086
- setValue: W,
1087
- getValues: ve,
1088
- reset: je,
1089
- resetField: kt,
1090
- clearErrors: Vt,
1091
- unregister: xe,
1092
- setError: qe,
1093
- setFocus: wt,
1094
- getFieldState: Pe
1095
- };
1096
- return {
1097
- ...Ge,
1098
- formControl: Ge
1099
- };
1100
- }
1101
- function Xt(e = {}) {
1102
- const s = m.useRef(void 0), t = m.useRef(void 0), [i, u] = m.useState({
1103
- isDirty: !1,
1104
- isValidating: !1,
1105
- isLoading: Q(e.defaultValues),
1106
- isSubmitted: !1,
1107
- isSubmitting: !1,
1108
- isSubmitSuccessful: !1,
1109
- isValid: !1,
1110
- submitCount: 0,
1111
- dirtyFields: {},
1112
- touchedFields: {},
1113
- validatingFields: {},
1114
- errors: e.errors || {},
1115
- disabled: e.disabled || !1,
1116
- isReady: !1,
1117
- defaultValues: Q(e.defaultValues) ? void 0 : e.defaultValues
1118
- });
1119
- if (!s.current)
1120
- if (e.formControl)
1121
- s.current = {
1122
- ...e.formControl,
1123
- formState: i
1124
- }, e.defaultValues && !Q(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
1125
- else {
1126
- const { formControl: c, ...d } = Qt(e);
1127
- s.current = {
1128
- ...d,
1129
- formState: i
1130
- };
1131
- }
1132
- const n = s.current.control;
1133
- return n._options = e, pe(() => {
1134
- const c = n._subscribe({
1135
- formState: n._proxyFormState,
1136
- callback: () => u({ ...n._formState }),
1137
- reRenderRoot: !0
1138
- });
1139
- return u((d) => ({
1140
- ...d,
1141
- isReady: !0
1142
- })), n._formState.isReady = !0, c;
1143
- }, [n]), m.useEffect(() => n._disableForm(e.disabled), [n, e.disabled]), m.useEffect(() => {
1144
- e.mode && (n._options.mode = e.mode), e.reValidateMode && (n._options.reValidateMode = e.reValidateMode);
1145
- }, [n, e.mode, e.reValidateMode]), m.useEffect(() => {
1146
- e.errors && (n._setErrors(e.errors), n._focusError());
1147
- }, [n, e.errors]), m.useEffect(() => {
1148
- e.shouldUnregister && n._subjects.state.next({
1149
- values: n._getWatch()
1150
- });
1151
- }, [n, e.shouldUnregister]), m.useEffect(() => {
1152
- if (n._proxyFormState.isDirty) {
1153
- const c = n._getDirty();
1154
- c !== i.isDirty && n._subjects.state.next({
1155
- isDirty: c
1156
- });
1157
- }
1158
- }, [n, i.isDirty]), m.useEffect(() => {
1159
- var c;
1160
- e.values && !J(e.values, t.current) ? (n._reset(e.values, {
1161
- keepFieldsRef: !0,
1162
- ...n._options.resetOptions
1163
- }), !((c = n._options.resetOptions) === null || c === void 0) && c.keepIsValid || n._setValid(), t.current = e.values, u((d) => ({ ...d }))) : n._resetDefaultValues();
1164
- }, [n, e.values]), m.useEffect(() => {
1165
- n._state.mount || (n._setValid(), n._state.mount = !0), n._state.watch && (n._state.watch = !1, n._subjects.state.next({ ...n._formState })), n._removeUnmounted();
1166
- }), s.current.formState = yt(i, n), s.current;
1167
- }
1168
- const ar = ({ faqId: e, percent: s }) => {
1169
- const [t, i] = Rt(!1), u = Xt({
1170
- defaultValues: {
1171
- faq: e
1172
- }
1173
- }), { handleSubmit: n, setValue: c, getValues: d } = u, k = (b) => {
1174
- try {
1175
- i(!0), console.log("Submitted:", b);
1176
- } catch (v) {
1177
- console.error("Error submitting feedback:", v);
1178
- } finally {
1179
- i(!1);
1180
- }
1181
- }, C = (b) => {
1182
- c("rate", b), n(k)();
1183
- }, F = d("rate");
1184
- return /* @__PURE__ */ le(Tt, { ...u, children: /* @__PURE__ */ le("form", { children: /* @__PURE__ */ Se("div", { className: "mt-6 flex items-center gap-6 max-tablet:flex-col max-tablet:items-start", children: [
1185
- /* @__PURE__ */ Se("div", { className: "border-l-2 border-green pl-6 mr-14 shrink-0", children: [
1186
- /* @__PURE__ */ le("span", { className: "text-gray2 block text-[14px] leading-5", children: `${s}% считают ответ полезным` }),
1187
- /* @__PURE__ */ le("p", { className: "text-blackBG text-[15px] leading-[22px]", children: "Ответ был полезным?" })
1188
- ] }),
1189
- /* @__PURE__ */ Se("div", { className: "flex items-center gap-4 w-full max-tablet::pt-4", children: [
1190
- /* @__PURE__ */ le(
1191
- Je,
1192
- {
1193
- size: Qe.M,
1194
- variant: Xe.Secondary,
1195
- className: "w-[125px]",
1196
- disabled: t,
1197
- onClick: () => C("yes"),
1198
- loading: F === "yes" && t,
1199
- children: "Да"
1200
- }
1201
- ),
1202
- /* @__PURE__ */ le(
1203
- Je,
1204
- {
1205
- size: Qe.M,
1206
- variant: Xe.Secondary,
1207
- className: "w-[125px]",
1208
- disabled: t,
1209
- onClick: () => C("no"),
1210
- loading: F === "no" && t,
1211
- children: "Нет"
1212
- }
1213
- )
1214
- ] })
1215
- ] }) }) });
1216
- };
1217
- export {
1218
- ir as C,
1219
- ar as F,
1220
- Xt as u
1221
- };