cross-country 1.2.21 → 1.2.22

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 (259) hide show
  1. package/dist/Color-F6OSRLHC-BbLcUd-T.js +575 -0
  2. package/dist/{bolt-Bw4E_fgS.js → bolt-BLbYxvOV.js} +6 -5
  3. package/dist/bundle.css +36 -31
  4. package/dist/colour-util-Bzfca_cM.js +775 -0
  5. package/dist/components/atoms/circle/__tests__/circle.test.js +2 -2
  6. package/dist/components/atoms/column/__tests__/column.test.js +2 -2
  7. package/dist/components/atoms/index.js +1 -1
  8. package/dist/components/atoms/list/index.js +4 -0
  9. package/dist/components/atoms/list/list-item/index.js +4 -0
  10. package/dist/components/atoms/list/list-item/list-item.js +20 -0
  11. package/dist/components/atoms/list/list.js +33 -0
  12. package/dist/components/atoms/radio/index.js +2 -2
  13. package/dist/components/atoms/radio/radio.js +42 -3
  14. package/dist/components/atoms/text/animate-number/animate-number.js +1 -1
  15. package/dist/components/atoms/text/index.js +1 -1
  16. package/dist/components/atoms/text/input/__stories__/state-machine-fetch-dragons.js +3 -3
  17. package/dist/components/atoms/text/input/input-text-machine.js +3 -3
  18. package/dist/components/atoms/text/input/state-machine-text-input.js +1 -1
  19. package/dist/components/atoms/text/span/__stories__/span-story.js +6 -5
  20. package/dist/components/index.js +116 -116
  21. package/dist/components/molecules/autocomplete/autocomplete-machine.js +3 -3
  22. package/dist/components/molecules/autocomplete/autocomplete.js +1 -1
  23. package/dist/components/molecules/card/amazon/amazon-card.js +7 -6
  24. package/dist/components/molecules/card/builder/card-builder-machine/card-builder-machine.js +1 -1
  25. package/dist/components/molecules/card/builder/card-builder-machine/card-service-events.js +2 -2
  26. package/dist/components/molecules/card/builder/card-builder-machine/platform-states-amazon.js +1 -1
  27. package/dist/components/molecules/card/builder/card-builder-machine/platform-states-common.js +1 -1
  28. package/dist/components/molecules/card/builder/card-builder.js +1 -1
  29. package/dist/components/molecules/card/builder/card-editor.js +7 -6
  30. package/dist/components/molecules/card/card.js +6 -5
  31. package/dist/components/molecules/carousel/carousel.js +6 -5
  32. package/dist/components/molecules/day-number/day-number.js +6 -5
  33. package/dist/components/molecules/field/field.js +6 -5
  34. package/dist/components/molecules/gold-leaf/gold-leaf-view/__tests__/gold-leaf-view.test.js +3 -3
  35. package/dist/components/molecules/gold-leaf/gold-leaf-view/controls/gold-leaf-view-controls.js +8 -7
  36. package/dist/components/molecules/gold-leaf/gold-leaf-view/email/gold-leaf-email-view.js +7 -6
  37. package/dist/components/molecules/gold-leaf/gold-leaf-view/gold-leaf-view.js +7 -6
  38. package/dist/components/molecules/gold-leaf/gold-leaf-view/index.js +1 -1
  39. package/dist/components/molecules/gold-leaf/gold-leaf-view/title-image/gold-leaf-image.js +7 -6
  40. package/dist/components/molecules/gold-leaf/gold-leaf-view/title-image/gold-title-card.js +40 -0
  41. package/dist/components/molecules/gold-leaf/gold-leaf-view/title-image/gold-title-image-card.js +8 -7
  42. package/dist/components/molecules/gold-leaf/gold-leaf.js +1 -1
  43. package/dist/components/molecules/header/Header.js +10 -9
  44. package/dist/components/molecules/hero/hero.js +7 -6
  45. package/dist/components/molecules/icons/index.js +4 -3
  46. package/dist/components/molecules/icons/x/x.js +6 -5
  47. package/dist/components/molecules/index.js +8 -7
  48. package/dist/components/molecules/key-value-pairs/__tests__/key-value-pairs.js +1 -1
  49. package/dist/components/molecules/key-value-pairs/key-value-pairs.js +10 -9
  50. package/dist/components/molecules/keywords/keywords.js +6 -5
  51. package/dist/components/molecules/loading/__tests__/loading.test.js +1 -1
  52. package/dist/components/molecules/log-error-boundary/__stories__/log-error-boundary-story.js +1 -1
  53. package/dist/components/molecules/log-error-boundary/__tests__/log-error-boundary.test.js +2 -2
  54. package/dist/components/molecules/log-error-boundary/log-error-boundary.js +6 -5
  55. package/dist/components/molecules/modal/modal.js +6 -5
  56. package/dist/components/molecules/policies/index.js +4 -3
  57. package/dist/components/molecules/policies/privacy-policy.js +8 -7
  58. package/dist/components/molecules/policies/terms-of-use.js +8 -7
  59. package/dist/components/molecules/quote/quote.js +6 -5
  60. package/dist/components/molecules/radiogroup/__stories__/radio-group-form-story.js +12 -11
  61. package/dist/components/molecules/radiogroup/__stories__/radio-group-react-hook-form-story.js +15 -14
  62. package/dist/components/molecules/radiogroup/radiogroup.js +9 -9
  63. package/dist/components/molecules/related-articles/related-articles.js +15 -14
  64. package/dist/components/molecules/search/search.js +6 -5
  65. package/dist/components/molecules/stagger/stagger.js +6 -5
  66. package/dist/components/molecules/tile/corners.js +1 -1
  67. package/dist/components/molecules/tile/index.js +1 -1
  68. package/dist/components/molecules/tile/tile-interactive.js +5 -4
  69. package/dist/components/molecules/tile/tile.js +1 -1
  70. package/dist/components/molecules/time-progress/__tests__/progress.test.js +1 -1
  71. package/dist/components/molecules/time-progress/pilot/index.js +2 -3
  72. package/dist/components/molecules/time-progress/progress-over-year.js +6 -5
  73. package/dist/components/molecules/time-progress/progress.js +6 -5
  74. package/dist/components/molecules/user/anon-user.js +6 -5
  75. package/dist/components/molecules/user/user.js +7 -6
  76. package/dist/components/molecules/venn-diagram/__tests__/venn-diagram.tests.js +2 -2
  77. package/dist/components/molecules/venn-diagram/venn-diagram-circle.js +6 -5
  78. package/dist/components/molecules/venn-diagram/venn-diagram.js +6 -5
  79. package/dist/components/molecules/wallpaper/__tests__/wallpaper.tests.js +2 -2
  80. package/dist/components/molecules/wallpaper/wallpaper.js +1 -1
  81. package/dist/components/molecules/wrapper/__stories__/wrapper-children-story.js +6 -5
  82. package/dist/components/organisms/actors/actor/actor-builder-machine.js +2 -2
  83. package/dist/components/organisms/actors/actor/actor-builder.js +6 -5
  84. package/dist/components/organisms/actors/actor/actor.js +5 -4
  85. package/dist/components/organisms/actors/actor/index.js +1 -1
  86. package/dist/components/organisms/actors/animal/animal.js +1 -1
  87. package/dist/components/organisms/actors/monsters/troll/troll-machine.js +2 -2
  88. package/dist/components/organisms/actors/monsters/troll/troll.js +6 -5
  89. package/dist/components/organisms/actors/party/cleric/cleric.js +1 -1
  90. package/dist/components/organisms/actors/party/hunter/hunter.js +1 -1
  91. package/dist/components/organisms/actors/party/warrior/warrior.js +1 -1
  92. package/dist/components/organisms/actors/party/wizard/wizard.js +1 -1
  93. package/dist/components/organisms/actors/wisp/wisp.js +1 -1
  94. package/dist/components/organisms/ads/ad-card.js +6 -5
  95. package/dist/components/organisms/animation/animate-actor/animate-actor.js +6 -5
  96. package/dist/components/organisms/animation/one-day/one-day.js +15 -14
  97. package/dist/components/organisms/animation/reverse-text-animation/reverse-text-animation.js +6 -5
  98. package/dist/components/organisms/bento/layouts/five-by-four/bento-five-by-four.js +9 -8
  99. package/dist/components/organisms/bento/layouts/four-by-four/bento-four-by-four.js +6 -5
  100. package/dist/components/organisms/bento/layouts/three-by-three/bento-three-by-three.js +6 -5
  101. package/dist/components/organisms/bento/layouts/two-by-two/bento-two-by-two.js +6 -5
  102. package/dist/components/organisms/blog/__stories__/blog-story.js +9 -8
  103. package/dist/components/organisms/blog/blog-post/__stories__/blog-post-story.js +6 -5
  104. package/dist/components/organisms/blog/blog-post/blog-post-machine/build-listicle-machine.js +1 -1
  105. package/dist/components/organisms/blog/blog-post/blog-post-machine/delete-listicle-item.js +2 -2
  106. package/dist/components/organisms/blog/blog-post/blog-post-machine/load-listicle.js +2 -2
  107. package/dist/components/organisms/blog/blog-post/blog-post-machine/manage-listicle-items.js +1 -1
  108. package/dist/components/organisms/blog/blog-post/blog-post-machine/save-listicle-item.js +2 -2
  109. package/dist/components/organisms/blog/blog-post/blog-post-machine/save-listicle.js +2 -2
  110. package/dist/components/organisms/blog/blog-post/blog-post-machine/update-listice-item.js +2 -2
  111. package/dist/components/organisms/blog/blog-post/blog-post.js +6 -5
  112. package/dist/components/organisms/blog/blog-post-list.js +12 -11
  113. package/dist/components/organisms/blog/blog.js +6 -5
  114. package/dist/components/organisms/branch/branch.js +6 -5
  115. package/dist/components/organisms/branches/__tests__/branch-list.test.js +6 -4
  116. package/dist/components/organisms/branches/branch-list.js +61 -39
  117. package/dist/components/organisms/branches/branches.js +7 -6
  118. package/dist/components/organisms/calendar/calendar.js +6 -5
  119. package/dist/components/organisms/charts/chart/__stories__/data-set.js +1 -1
  120. package/dist/components/organisms/charts/chart/chart-gold-leaf/chart-gold-leaf.js +4 -3
  121. package/dist/components/organisms/clusters/cluster.js +6 -5
  122. package/dist/components/organisms/json-map-tile-grid/index.js +1 -1
  123. package/dist/components/organisms/json-map-tile-grid/json-map-tile-grid.js +6 -4
  124. package/dist/components/organisms/listicle/__stories__/andor-right-click-story.js +6 -5
  125. package/dist/components/organisms/listicle/__stories__/listicle-fb-v-canada-story.js +6 -5
  126. package/dist/components/organisms/listicle/__stories__/listicle-story.js +6 -5
  127. package/dist/components/organisms/listicle/build-listicle-machine/build-listicle-machine.js +1 -1
  128. package/dist/components/organisms/listicle/build-listicle-machine/delete-listicle-item.js +2 -2
  129. package/dist/components/organisms/listicle/build-listicle-machine/load-listicle.js +2 -2
  130. package/dist/components/organisms/listicle/build-listicle-machine/manage-listicle-items.js +1 -1
  131. package/dist/components/organisms/listicle/build-listicle-machine/save-listicle-item.js +2 -2
  132. package/dist/components/organisms/listicle/build-listicle-machine/save-listicle.js +2 -2
  133. package/dist/components/organisms/listicle/build-listicle-machine/update-listice-item.js +2 -2
  134. package/dist/components/organisms/listicle/edit-listicle/edit-listicle.js +13 -12
  135. package/dist/components/organisms/listicle/edit-listicle-item-list/edit-listicle-item-list.js +6 -5
  136. package/dist/components/organisms/listicle/edit-listicle-item-list/listicle-item-input.js +12 -11
  137. package/dist/components/organisms/listicle/edit-listicle-item-list/listicle-item.js +6 -5
  138. package/dist/components/organisms/listicle/listicle-builder.js +14 -13
  139. package/dist/components/organisms/listicle/listicle-item-list.js +12 -11
  140. package/dist/components/organisms/listicle/listicle.js +6 -5
  141. package/dist/components/organisms/listicle/post-link.js +7 -6
  142. package/dist/components/organisms/login/__stories__/login-story.js +6 -5
  143. package/dist/components/organisms/login/login-fetching-transition.js +6 -5
  144. package/dist/components/organisms/login/login-fields-transition.js +21 -20
  145. package/dist/components/organisms/login/login-response-transition.js +66 -11
  146. package/dist/components/organisms/login/login-submit-transition.js +6 -5
  147. package/dist/components/organisms/login/login-view.js +7 -6
  148. package/dist/components/organisms/metrics/metrics.js +6 -5
  149. package/dist/components/organisms/palettes/palettes.js +14 -12
  150. package/dist/components/organisms/player/player.js +6 -5
  151. package/dist/components/organisms/registration/password-strength-helper.js +11 -10
  152. package/dist/components/organisms/registration/post-registration.js +2 -2
  153. package/dist/components/organisms/registration/registration-form.js +6 -5
  154. package/dist/components/organisms/registration/registration-machine.js +2 -2
  155. package/dist/components/organisms/registration/registration-response.js +6 -5
  156. package/dist/components/organisms/registration/registration.js +7 -6
  157. package/dist/components/organisms/stage/stage.js +9 -8
  158. package/dist/components/organisms/survey/__stories__/build-form-story.js +6 -5
  159. package/dist/components/organisms/survey/build-form-machine.js +2 -2
  160. package/dist/components/organisms/survey/build-form.js +8 -7
  161. package/dist/components/organisms/survey/final-form.js +8 -7
  162. package/dist/components/organisms/survey/question/edit/__stories__/edit-question-story.js +6 -5
  163. package/dist/components/organisms/survey/question/edit/add-media.js +6 -5
  164. package/dist/components/organisms/survey/question/edit/add-question/__stories__/add-question-story.js +6 -5
  165. package/dist/components/organisms/survey/question/edit/add-question/add-question.js +30 -29
  166. package/dist/components/organisms/survey/question/edit/answer/answer-input.js +6 -5
  167. package/dist/components/organisms/survey/question/edit/answer-input.js +6 -5
  168. package/dist/components/organisms/survey/question/edit/edit-multiple-choice.js +6 -5
  169. package/dist/components/organisms/survey/question/edit/edit-option-list/edit-option-list-machine.js +2 -2
  170. package/dist/components/organisms/survey/question/edit/edit-option-list/edit-option-list.js +7 -6
  171. package/dist/components/organisms/survey/question/edit/edit-option-list/option-input.js +6 -5
  172. package/dist/components/organisms/survey/question/edit/edit-option-list/option.js +7 -6
  173. package/dist/components/organisms/survey/question/edit/question-answer-input.js +6 -5
  174. package/dist/components/organisms/survey/question/take/__stories__/multiple-choice-story.js +6 -5
  175. package/dist/components/organisms/survey/question/take/__stories__/take-answer-date-time-input-story.js +6 -5
  176. package/dist/components/organisms/survey/question/take/__stories__/take-answer-input-story.js +6 -5
  177. package/dist/components/organisms/survey/question/take/inputs/input-manager.js +6 -5
  178. package/dist/components/organisms/survey/question/take/multiple-choice.js +6 -5
  179. package/dist/components/organisms/survey/question/take/take-answer-input.js +12 -11
  180. package/dist/components/organisms/tile-grid/__tests__/tile-grid.tests.js +3 -3
  181. package/dist/components/organisms/tile-grid/grid-row.js +6 -5
  182. package/dist/components/organisms/tile-grid/index.js +1 -1
  183. package/dist/components/organisms/tile-grid/island-tile-grid.js +12 -11
  184. package/dist/components/organisms/tile-grid/tile-grid.js +6 -4
  185. package/dist/components/organisms/worlds/area-of-effect/__stories__/area-of-affect-story.js +6 -5
  186. package/dist/components/organisms/worlds/area-of-effect/area-of-affect.js +31 -29
  187. package/dist/components/organisms/worlds/island/__stories__/island-story.js +18 -16
  188. package/dist/components/organisms/worlds/island/__stories__/island-util.js +25 -23
  189. package/dist/components/pages/home/headwinds/header/headwinds-header.js +6 -5
  190. package/dist/components/pages/home/headwinds/headwinds-footer.js +6 -5
  191. package/dist/components/pages/home/headwinds/headwinds-hero.js +6 -5
  192. package/dist/components/pages/home/headwinds/headwinds-sidequest.js +35 -34
  193. package/dist/components/pages/home/headwinds/home.js +9 -8
  194. package/dist/components/pages/index.js +6 -5
  195. package/dist/components/pages/profile/headwinds/headwinds-profile.js +21 -20
  196. package/dist/components/pages/profile/index.js +4 -3
  197. package/dist/components/templates/articles/article/article.js +6 -5
  198. package/dist/components/templates/home/headwinds/headwinds-home-hero.js +6 -5
  199. package/dist/components/templates/home/headwinds/headwinds-home.js +6 -5
  200. package/dist/components/templates/home/home.js +10 -9
  201. package/dist/fp-util-DZLSTUg5.js +8 -0
  202. package/dist/gold-leaf-view-CgRraK2i.js +183 -0
  203. package/dist/gold-leaf-view.module-p3mWnO60.js +17 -0
  204. package/dist/headline-DzDFQZ3e.js +11 -0
  205. package/dist/image-find-util-DMX6BcO-.js +1036 -0
  206. package/dist/index-BTF1caLu.js +2529 -0
  207. package/dist/{index-COQaJqs5.js → index-OdyFkztm.js} +3670 -2660
  208. package/dist/{index-DsigmIMS.js → index-_cvPLH70.js} +1 -1
  209. package/dist/index.esm-DGm91C_6.js +944 -0
  210. package/dist/index.js +143 -140
  211. package/dist/lib/components/atoms/list/index.d.ts +2 -0
  212. package/dist/lib/components/atoms/list/list-item/index.d.ts +2 -0
  213. package/dist/lib/components/atoms/list/list-item/list-item.d.ts +10 -0
  214. package/dist/lib/components/atoms/list/list.d.ts +12 -0
  215. package/dist/lib/components/molecules/gold-leaf/gold-leaf-view/title-image/gold-title-card.d.ts +4 -0
  216. package/dist/lib/components/organisms/branch/branch.d.ts +3 -1
  217. package/dist/lib/components/organisms/branches/__stories__/branches.stories.d.ts +7 -0
  218. package/dist/lib/components/organisms/branches/branch-list.d.ts +4 -1
  219. package/dist/lib/models/TreeModel.d.ts +12 -0
  220. package/dist/lib/models/index.d.ts +1 -0
  221. package/dist/lib/utils/golds/feed-util.d.ts +17 -0
  222. package/dist/lib/utils/index.d.ts +5 -0
  223. package/dist/list.module-pjS_KHqp.js +10 -0
  224. package/dist/{log-2a4cc478.esm-HFv7vQ7j.js → log-2a4cc478.esm-BdzQp5f-.js} +15 -15
  225. package/dist/{log-error-boundary-story-BF8rmHhr.js → log-error-boundary-story-CcyM__Yt.js} +6541 -7185
  226. package/dist/{magic-string.es-VsGWiGpd.js → magic-string.es-QkQE39Zh.js} +11 -6
  227. package/dist/{radio-BTUtRmLM.js → mobile-detect-CWVWWCSg.js} +12 -51
  228. package/dist/models/TreeModel.js +12 -0
  229. package/dist/models/index.js +3 -2
  230. package/dist/{react-spring_web.modern-nSq5Xzxb.js → react-spring_web.modern-ClBJWBW2.js} +281 -273
  231. package/dist/{react.esm-BEaxtOYu.js → react.esm-BpVcViTQ.js} +2197 -2181
  232. package/dist/string-util-D7tmqJRS.js +35 -0
  233. package/dist/table-data-BnRZ5F7y.js +16 -0
  234. package/dist/utils/golds/feed-util.js +240 -0
  235. package/dist/utils/index.js +12 -0
  236. package/dist/{vi.YFlodzP_-CjWVzrI3.js → vi.YFlodzP_-C3qjkUdf.js} +2 -2
  237. package/dist/{xstate-actors.esm-Ba6reXm_.js → xstate-actors.esm-CcLF5JHw.js} +1 -1
  238. package/dist/{xstate-react.esm-Ct8KIFgA.js → xstate-react.esm-DWdE0_Ay.js} +1 -1
  239. package/dist/{xstate.esm-Bo02HSs2.js → xstate.esm-COAqQ2fq.js} +11 -11
  240. package/package.json +4 -2
  241. package/dist/Color-ERTF36HU-DRLqcX19.js +0 -358
  242. package/dist/_getTag-CqbPZ7Cl.js +0 -449
  243. package/dist/components/organisms/branches/__stories__/branches-story.js +0 -6
  244. package/dist/components/organisms/branches/branch-list.types.js +0 -1
  245. package/dist/feed-util-CZfVh6cR.js +0 -244
  246. package/dist/fp-util-4N0NK_eU.js +0 -8
  247. package/dist/gold-leaf-view-BAGw5McJ.js +0 -117
  248. package/dist/gold-leaf-view.module-BTNjKEeW.js +0 -17
  249. package/dist/headline-DuHL8hAt.js +0 -11
  250. package/dist/image-find-util-Cl2ZJHfC.js +0 -41
  251. package/dist/index-BsYJgl86.js +0 -3853
  252. package/dist/index-Cdg9lY68.js +0 -542
  253. package/dist/index.esm-BrPDxyfz.js +0 -933
  254. package/dist/lib/components/organisms/branches/__stories__/branches-story.d.ts +0 -2
  255. package/dist/lib/components/organisms/branches/branch-list.types.d.ts +0 -5
  256. package/dist/list-BkQjCFcb.js +0 -14
  257. package/dist/list-item-DyDjznkQ.js +0 -8
  258. package/dist/login-response-transition-Dws0eBbH.js +0 -123
  259. package/dist/table-data-PGM-_ef9.js +0 -16
@@ -1,933 +0,0 @@
1
- import B from "react";
2
- var oe = (e) => e.type === "checkbox", se = (e) => e instanceof Date, L = (e) => e == null;
3
- const Ze = (e) => typeof e == "object";
4
- var D = (e) => !L(e) && !Array.isArray(e) && Ze(e) && !se(e), gr = (e) => D(e) && e.target ? oe(e.target) ? e.target.checked : e.target.value : e, vr = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, hr = (e, s) => e.has(vr(s)), _r = (e) => {
5
- const s = e.constructor && e.constructor.prototype;
6
- return D(s) && s.hasOwnProperty("isPrototypeOf");
7
- }, Te = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
8
- function M(e) {
9
- let s;
10
- const t = Array.isArray(e);
11
- if (e instanceof Date)
12
- s = new Date(e);
13
- else if (e instanceof Set)
14
- s = new Set(e);
15
- else if (!(Te && (e instanceof Blob || e instanceof FileList)) && (t || D(e)))
16
- if (s = t ? [] : {}, !t && !_r(e))
17
- s = e;
18
- else
19
- for (const a in e)
20
- e.hasOwnProperty(a) && (s[a] = M(e[a]));
21
- else
22
- return e;
23
- return s;
24
- }
25
- var Ve = (e) => Array.isArray(e) ? e.filter(Boolean) : [], w = (e) => e === void 0, d = (e, s, t) => {
26
- if (!s || !D(e))
27
- return t;
28
- const a = Ve(s.split(/[,[\].]+?/)).reduce((n, l) => L(n) ? n : n[l], e);
29
- return w(a) || a === e ? w(e[s]) ? t : e[s] : a;
30
- }, W = (e) => typeof e == "boolean", Oe = (e) => /^\w*$/.test(e), er = (e) => Ve(e.replace(/["|']|\]/g, "").split(/\.|\[/)), A = (e, s, t) => {
31
- let a = -1;
32
- const n = Oe(s) ? [s] : er(s), l = n.length, g = l - 1;
33
- for (; ++a < l; ) {
34
- const v = n[a];
35
- let P = t;
36
- if (a !== g) {
37
- const q = e[v];
38
- P = D(q) || Array.isArray(q) ? q : isNaN(+n[a + 1]) ? {} : [];
39
- }
40
- if (v === "__proto__")
41
- return;
42
- e[v] = P, e = e[v];
43
- }
44
- return e;
45
- };
46
- const He = {
47
- BLUR: "blur",
48
- FOCUS_OUT: "focusout",
49
- CHANGE: "change"
50
- }, p = {
51
- onBlur: "onBlur",
52
- onChange: "onChange",
53
- onSubmit: "onSubmit",
54
- onTouched: "onTouched",
55
- all: "all"
56
- }, Y = {
57
- max: "max",
58
- min: "min",
59
- maxLength: "maxLength",
60
- minLength: "minLength",
61
- pattern: "pattern",
62
- required: "required",
63
- validate: "validate"
64
- };
65
- B.createContext(null);
66
- var br = (e, s, t, a = !0) => {
67
- const n = {
68
- defaultValues: s._defaultValues
69
- };
70
- for (const l in e)
71
- Object.defineProperty(n, l, {
72
- get: () => {
73
- const g = l;
74
- return s._proxyFormState[g] !== p.all && (s._proxyFormState[g] = !a || p.all), e[g];
75
- }
76
- });
77
- return n;
78
- }, C = (e) => D(e) && !Object.keys(e).length, Fr = (e, s, t, a) => {
79
- t(e);
80
- const { name: n, ...l } = e;
81
- return C(l) || Object.keys(l).length >= Object.keys(s).length || Object.keys(l).find((g) => s[g] === p.all);
82
- }, ge = (e) => Array.isArray(e) ? e : [e];
83
- function Vr(e) {
84
- const s = B.useRef(e);
85
- s.current = e, B.useEffect(() => {
86
- const t = !e.disabled && s.current.subject && s.current.subject.subscribe({
87
- next: s.current.next
88
- });
89
- return () => {
90
- t && t.unsubscribe();
91
- };
92
- }, [e.disabled]);
93
- }
94
- var H = (e) => typeof e == "string", Ar = (e, s, t, a, n) => H(e) ? (a && s.watch.add(e), d(t, e, n)) : Array.isArray(e) ? e.map((l) => (a && s.watch.add(l), d(t, l))) : (a && (s.watchAll = !0), t), xr = (e, s, t, a, n) => s ? {
95
- ...t[e],
96
- types: {
97
- ...t[e] && t[e].types ? t[e].types : {},
98
- [a]: n || !0
99
- }
100
- } : {}, $e = (e) => ({
101
- isOnSubmit: !e || e === p.onSubmit,
102
- isOnBlur: e === p.onBlur,
103
- isOnChange: e === p.onChange,
104
- isOnAll: e === p.all,
105
- isOnTouch: e === p.onTouched
106
- }), je = (e, s, t) => !t && (s.watchAll || s.watch.has(e) || [...s.watch].some((a) => e.startsWith(a) && /^\.\w+/.test(e.slice(a.length))));
107
- const ne = (e, s, t, a) => {
108
- for (const n of t || Object.keys(e)) {
109
- const l = d(e, n);
110
- if (l) {
111
- const { _f: g, ...v } = l;
112
- if (g) {
113
- if (g.refs && g.refs[0] && s(g.refs[0], n) && !a)
114
- return !0;
115
- if (g.ref && s(g.ref, g.name) && !a)
116
- return !0;
117
- if (ne(v, s))
118
- break;
119
- } else if (D(v) && ne(v, s))
120
- break;
121
- }
122
- }
123
- };
124
- var wr = (e, s, t) => {
125
- const a = ge(d(e, t));
126
- return A(a, "root", s[t]), A(e, t, a), e;
127
- }, Le = (e) => e.type === "file", z = (e) => typeof e == "function", he = (e) => {
128
- if (!Te)
129
- return !1;
130
- const s = e ? e.ownerDocument : 0;
131
- return e instanceof (s && s.defaultView ? s.defaultView.HTMLElement : HTMLElement);
132
- }, ve = (e) => H(e), Ce = (e) => e.type === "radio", _e = (e) => e instanceof RegExp;
133
- const Ke = {
134
- value: !1,
135
- isValid: !1
136
- }, Ye = { value: !0, isValid: !0 };
137
- var rr = (e) => {
138
- if (Array.isArray(e)) {
139
- if (e.length > 1) {
140
- const s = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
141
- return { value: s, isValid: !!s.length };
142
- }
143
- return e[0].checked && !e[0].disabled ? (
144
- // @ts-expect-error expected to work in the browser
145
- e[0].attributes && !w(e[0].attributes.value) ? w(e[0].value) || e[0].value === "" ? Ye : { value: e[0].value, isValid: !0 } : Ye
146
- ) : Ke;
147
- }
148
- return Ke;
149
- };
150
- const ze = {
151
- isValid: !1,
152
- value: null
153
- };
154
- var tr = (e) => Array.isArray(e) ? e.reduce((s, t) => t && t.checked && !t.disabled ? {
155
- isValid: !0,
156
- value: t.value
157
- } : s, ze) : ze;
158
- function Ge(e, s, t = "validate") {
159
- if (ve(e) || Array.isArray(e) && e.every(ve) || W(e) && !e)
160
- return {
161
- type: t,
162
- message: ve(e) ? e : "",
163
- ref: s
164
- };
165
- }
166
- var te = (e) => D(e) && !_e(e) ? e : {
167
- value: e,
168
- message: ""
169
- }, Je = async (e, s, t, a, n) => {
170
- const { ref: l, refs: g, required: v, maxLength: P, minLength: q, min: x, max: _, pattern: fe, validate: G, name: U, valueAsNumber: Ae, mount: $, disabled: J } = e._f, b = d(s, U);
171
- if (!$ || J)
172
- return {};
173
- const j = g ? g[0] : l, K = (h) => {
174
- a && j.reportValidity && (j.setCustomValidity(W(h) ? "" : h || ""), j.reportValidity());
175
- }, m = {}, ee = Ce(l), ce = oe(l), X = ee || ce, re = (Ae || Le(l)) && w(l.value) && w(b) || he(l) && l.value === "" || b === "" || Array.isArray(b) && !b.length, N = xr.bind(null, U, t, m), de = (h, F, E, O = Y.maxLength, I = Y.minLength) => {
176
- const R = h ? F : E;
177
- m[U] = {
178
- type: h ? O : I,
179
- message: R,
180
- ref: l,
181
- ...N(h ? O : I, R)
182
- };
183
- };
184
- if (n ? !Array.isArray(b) || !b.length : v && (!X && (re || L(b)) || W(b) && !b || ce && !rr(g).isValid || ee && !tr(g).isValid)) {
185
- const { value: h, message: F } = ve(v) ? { value: !!v, message: v } : te(v);
186
- if (h && (m[U] = {
187
- type: Y.required,
188
- message: F,
189
- ref: j,
190
- ...N(Y.required, F)
191
- }, !t))
192
- return K(F), m;
193
- }
194
- if (!re && (!L(x) || !L(_))) {
195
- let h, F;
196
- const E = te(_), O = te(x);
197
- if (!L(b) && !isNaN(b)) {
198
- const I = l.valueAsNumber || b && +b;
199
- L(E.value) || (h = I > E.value), L(O.value) || (F = I < O.value);
200
- } else {
201
- const I = l.valueAsDate || new Date(b), R = (le) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + le), ie = l.type == "time", ue = l.type == "week";
202
- H(E.value) && b && (h = ie ? R(b) > R(E.value) : ue ? b > E.value : I > new Date(E.value)), H(O.value) && b && (F = ie ? R(b) < R(O.value) : ue ? b < O.value : I < new Date(O.value));
203
- }
204
- if ((h || F) && (de(!!h, E.message, O.message, Y.max, Y.min), !t))
205
- return K(m[U].message), m;
206
- }
207
- if ((P || q) && !re && (H(b) || n && Array.isArray(b))) {
208
- const h = te(P), F = te(q), E = !L(h.value) && b.length > +h.value, O = !L(F.value) && b.length < +F.value;
209
- if ((E || O) && (de(E, h.message, F.message), !t))
210
- return K(m[U].message), m;
211
- }
212
- if (fe && !re && H(b)) {
213
- const { value: h, message: F } = te(fe);
214
- if (_e(h) && !b.match(h) && (m[U] = {
215
- type: Y.pattern,
216
- message: F,
217
- ref: l,
218
- ...N(Y.pattern, F)
219
- }, !t))
220
- return K(F), m;
221
- }
222
- if (G) {
223
- if (z(G)) {
224
- const h = await G(b, s), F = Ge(h, j);
225
- if (F && (m[U] = {
226
- ...F,
227
- ...N(Y.validate, F.message)
228
- }, !t))
229
- return K(F.message), m;
230
- } else if (D(G)) {
231
- let h = {};
232
- for (const F in G) {
233
- if (!C(h) && !t)
234
- break;
235
- const E = Ge(await G[F](b, s), j, F);
236
- E && (h = {
237
- ...E,
238
- ...N(F, E.message)
239
- }, K(E.message), t && (m[U] = h));
240
- }
241
- if (!C(h) && (m[U] = {
242
- ref: j,
243
- ...h
244
- }, !t))
245
- return m;
246
- }
247
- }
248
- return K(!0), m;
249
- };
250
- function Dr(e, s) {
251
- const t = s.slice(0, -1).length;
252
- let a = 0;
253
- for (; a < t; )
254
- e = w(e) ? a++ : e[s[a++]];
255
- return e;
256
- }
257
- function mr(e) {
258
- for (const s in e)
259
- if (e.hasOwnProperty(s) && !w(e[s]))
260
- return !1;
261
- return !0;
262
- }
263
- function k(e, s) {
264
- const t = Array.isArray(s) ? s : Oe(s) ? [s] : er(s), a = t.length === 1 ? e : Dr(e, t), n = t.length - 1, l = t[n];
265
- return a && delete a[l], n !== 0 && (D(a) && C(a) || Array.isArray(a) && mr(a)) && k(e, t.slice(0, -1)), e;
266
- }
267
- var Ee = () => {
268
- let e = [];
269
- return {
270
- get observers() {
271
- return e;
272
- },
273
- next: (n) => {
274
- for (const l of e)
275
- l.next && l.next(n);
276
- },
277
- subscribe: (n) => (e.push(n), {
278
- unsubscribe: () => {
279
- e = e.filter((l) => l !== n);
280
- }
281
- }),
282
- unsubscribe: () => {
283
- e = [];
284
- }
285
- };
286
- }, be = (e) => L(e) || !Ze(e);
287
- function Q(e, s) {
288
- if (be(e) || be(s))
289
- return e === s;
290
- if (se(e) && se(s))
291
- return e.getTime() === s.getTime();
292
- const t = Object.keys(e), a = Object.keys(s);
293
- if (t.length !== a.length)
294
- return !1;
295
- for (const n of t) {
296
- const l = e[n];
297
- if (!a.includes(n))
298
- return !1;
299
- if (n !== "ref") {
300
- const g = s[n];
301
- if (se(l) && se(g) || D(l) && D(g) || Array.isArray(l) && Array.isArray(g) ? !Q(l, g) : l !== g)
302
- return !1;
303
- }
304
- }
305
- return !0;
306
- }
307
- var sr = (e) => e.type === "select-multiple", Er = (e) => Ce(e) || oe(e), ke = (e) => he(e) && e.isConnected, ir = (e) => {
308
- for (const s in e)
309
- if (z(e[s]))
310
- return !0;
311
- return !1;
312
- };
313
- function Fe(e, s = {}) {
314
- const t = Array.isArray(e);
315
- if (D(e) || t)
316
- for (const a in e)
317
- Array.isArray(e[a]) || D(e[a]) && !ir(e[a]) ? (s[a] = Array.isArray(e[a]) ? [] : {}, Fe(e[a], s[a])) : L(e[a]) || (s[a] = !0);
318
- return s;
319
- }
320
- function ur(e, s, t) {
321
- const a = Array.isArray(e);
322
- if (D(e) || a)
323
- for (const n in e)
324
- Array.isArray(e[n]) || D(e[n]) && !ir(e[n]) ? w(s) || be(t[n]) ? t[n] = Array.isArray(e[n]) ? Fe(e[n], []) : { ...Fe(e[n]) } : ur(e[n], L(s) ? {} : s[n], t[n]) : t[n] = !Q(e[n], s[n]);
325
- return t;
326
- }
327
- var ye = (e, s) => ur(e, s, Fe(s)), lr = (e, { valueAsNumber: s, valueAsDate: t, setValueAs: a }) => w(e) ? e : s ? e === "" ? NaN : e && +e : t && H(e) ? new Date(e) : a ? a(e) : e;
328
- function Se(e) {
329
- const s = e.ref;
330
- if (!(e.refs ? e.refs.every((t) => t.disabled) : s.disabled))
331
- return Le(s) ? s.files : Ce(s) ? tr(e.refs).value : sr(s) ? [...s.selectedOptions].map(({ value: t }) => t) : oe(s) ? rr(e.refs).value : lr(w(s.value) ? e.ref.value : s.value, e);
332
- }
333
- var kr = (e, s, t, a) => {
334
- const n = {};
335
- for (const l of e) {
336
- const g = d(s, l);
337
- g && A(n, l, g._f);
338
- }
339
- return {
340
- criteriaMode: t,
341
- names: [...e],
342
- fields: n,
343
- shouldUseNativeValidation: a
344
- };
345
- }, ae = (e) => w(e) ? e : _e(e) ? e.source : D(e) ? _e(e.value) ? e.value.source : e.value : e;
346
- const Qe = "AsyncFunction";
347
- var Sr = (e) => (!e || !e.validate) && !!(z(e.validate) && e.validate.constructor.name === Qe || D(e.validate) && Object.values(e.validate).find((s) => s.constructor.name === Qe)), Tr = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate);
348
- function Xe(e, s, t) {
349
- const a = d(e, t);
350
- if (a || Oe(t))
351
- return {
352
- error: a,
353
- name: t
354
- };
355
- const n = t.split(".");
356
- for (; n.length; ) {
357
- const l = n.join("."), g = d(s, l), v = d(e, l);
358
- if (g && !Array.isArray(g) && t !== l)
359
- return { name: t };
360
- if (v && v.type)
361
- return {
362
- name: l,
363
- error: v
364
- };
365
- n.pop();
366
- }
367
- return {
368
- name: t
369
- };
370
- }
371
- var Or = (e, s, t, a, n) => n.isOnAll ? !1 : !t && n.isOnTouch ? !(s || e) : (t ? a.isOnBlur : n.isOnBlur) ? !e : (t ? a.isOnChange : n.isOnChange) ? e : !0, Lr = (e, s) => !Ve(d(e, s)).length && k(e, s);
372
- const Cr = {
373
- mode: p.onSubmit,
374
- reValidateMode: p.onChange,
375
- shouldFocusError: !0
376
- };
377
- function Ur(e = {}) {
378
- let s = {
379
- ...Cr,
380
- ...e
381
- }, t = {
382
- submitCount: 0,
383
- isDirty: !1,
384
- isLoading: z(s.defaultValues),
385
- isValidating: !1,
386
- isSubmitted: !1,
387
- isSubmitting: !1,
388
- isSubmitSuccessful: !1,
389
- isValid: !1,
390
- touchedFields: {},
391
- dirtyFields: {},
392
- validatingFields: {},
393
- errors: s.errors || {},
394
- disabled: s.disabled || !1
395
- }, a = {}, n = D(s.defaultValues) || D(s.values) ? M(s.defaultValues || s.values) || {} : {}, l = s.shouldUnregister ? {} : M(n), g = {
396
- action: !1,
397
- mount: !1,
398
- watch: !1
399
- }, v = {
400
- mount: /* @__PURE__ */ new Set(),
401
- unMount: /* @__PURE__ */ new Set(),
402
- array: /* @__PURE__ */ new Set(),
403
- watch: /* @__PURE__ */ new Set()
404
- }, P, q = 0;
405
- const x = {
406
- isDirty: !1,
407
- dirtyFields: !1,
408
- validatingFields: !1,
409
- touchedFields: !1,
410
- isValidating: !1,
411
- isValid: !1,
412
- errors: !1
413
- }, _ = {
414
- values: Ee(),
415
- array: Ee(),
416
- state: Ee()
417
- }, fe = $e(s.mode), G = $e(s.reValidateMode), U = s.criteriaMode === p.all, Ae = (r) => (i) => {
418
- clearTimeout(q), q = setTimeout(r, i);
419
- }, $ = async (r) => {
420
- if (x.isValid || r) {
421
- const i = s.resolver ? C((await X()).errors) : await N(a, !0);
422
- i !== t.isValid && _.state.next({
423
- isValid: i
424
- });
425
- }
426
- }, J = (r, i) => {
427
- (x.isValidating || x.validatingFields) && ((r || Array.from(v.mount)).forEach((u) => {
428
- u && (i ? A(t.validatingFields, u, i) : k(t.validatingFields, u));
429
- }), _.state.next({
430
- validatingFields: t.validatingFields,
431
- isValidating: !C(t.validatingFields)
432
- }));
433
- }, b = (r, i = [], u, c, f = !0, o = !0) => {
434
- if (c && u) {
435
- if (g.action = !0, o && Array.isArray(d(a, r))) {
436
- const y = u(d(a, r), c.argA, c.argB);
437
- f && A(a, r, y);
438
- }
439
- if (o && Array.isArray(d(t.errors, r))) {
440
- const y = u(d(t.errors, r), c.argA, c.argB);
441
- f && A(t.errors, r, y), Lr(t.errors, r);
442
- }
443
- if (x.touchedFields && o && Array.isArray(d(t.touchedFields, r))) {
444
- const y = u(d(t.touchedFields, r), c.argA, c.argB);
445
- f && A(t.touchedFields, r, y);
446
- }
447
- x.dirtyFields && (t.dirtyFields = ye(n, l)), _.state.next({
448
- name: r,
449
- isDirty: h(r, i),
450
- dirtyFields: t.dirtyFields,
451
- errors: t.errors,
452
- isValid: t.isValid
453
- });
454
- } else
455
- A(l, r, i);
456
- }, j = (r, i) => {
457
- A(t.errors, r, i), _.state.next({
458
- errors: t.errors
459
- });
460
- }, K = (r) => {
461
- t.errors = r, _.state.next({
462
- errors: t.errors,
463
- isValid: !1
464
- });
465
- }, m = (r, i, u, c) => {
466
- const f = d(a, r);
467
- if (f) {
468
- const o = d(l, r, w(u) ? d(n, r) : u);
469
- w(o) || c && c.defaultChecked || i ? A(l, r, i ? o : Se(f._f)) : O(r, o), g.mount && $();
470
- }
471
- }, ee = (r, i, u, c, f) => {
472
- let o = !1, y = !1;
473
- const V = {
474
- name: r
475
- }, S = !!(d(a, r) && d(a, r)._f && d(a, r)._f.disabled);
476
- if (!u || c) {
477
- x.isDirty && (y = t.isDirty, t.isDirty = V.isDirty = h(), o = y !== V.isDirty);
478
- const T = S || Q(d(n, r), i);
479
- y = !!(!S && d(t.dirtyFields, r)), T || S ? k(t.dirtyFields, r) : A(t.dirtyFields, r, !0), V.dirtyFields = t.dirtyFields, o = o || x.dirtyFields && y !== !T;
480
- }
481
- if (u) {
482
- const T = d(t.touchedFields, r);
483
- T || (A(t.touchedFields, r, u), V.touchedFields = t.touchedFields, o = o || x.touchedFields && T !== u);
484
- }
485
- return o && f && _.state.next(V), o ? V : {};
486
- }, ce = (r, i, u, c) => {
487
- const f = d(t.errors, r), o = x.isValid && W(i) && t.isValid !== i;
488
- if (e.delayError && u ? (P = Ae(() => j(r, u)), P(e.delayError)) : (clearTimeout(q), P = null, u ? A(t.errors, r, u) : k(t.errors, r)), (u ? !Q(f, u) : f) || !C(c) || o) {
489
- const y = {
490
- ...c,
491
- ...o && W(i) ? { isValid: i } : {},
492
- errors: t.errors,
493
- name: r
494
- };
495
- t = {
496
- ...t,
497
- ...y
498
- }, _.state.next(y);
499
- }
500
- }, X = async (r) => {
501
- J(r, !0);
502
- const i = await s.resolver(l, s.context, kr(r || v.mount, a, s.criteriaMode, s.shouldUseNativeValidation));
503
- return J(r), i;
504
- }, re = async (r) => {
505
- const { errors: i } = await X(r);
506
- if (r)
507
- for (const u of r) {
508
- const c = d(i, u);
509
- c ? A(t.errors, u, c) : k(t.errors, u);
510
- }
511
- else
512
- t.errors = i;
513
- return i;
514
- }, N = async (r, i, u = {
515
- valid: !0
516
- }) => {
517
- for (const c in r) {
518
- const f = r[c];
519
- if (f) {
520
- const { _f: o, ...y } = f;
521
- if (o) {
522
- const V = v.array.has(o.name), S = f._f && Sr(f._f);
523
- S && x.validatingFields && J([c], !0);
524
- const T = await Je(f, l, U, s.shouldUseNativeValidation && !i, V);
525
- if (S && x.validatingFields && J([c]), T[o.name] && (u.valid = !1, i))
526
- break;
527
- !i && (d(T, o.name) ? V ? wr(t.errors, T, o.name) : A(t.errors, o.name, T[o.name]) : k(t.errors, o.name));
528
- }
529
- !C(y) && await N(y, i, u);
530
- }
531
- }
532
- return u.valid;
533
- }, de = () => {
534
- for (const r of v.unMount) {
535
- const i = d(a, r);
536
- i && (i._f.refs ? i._f.refs.every((u) => !ke(u)) : !ke(i._f.ref)) && xe(r);
537
- }
538
- v.unMount = /* @__PURE__ */ new Set();
539
- }, h = (r, i) => (r && i && A(l, r, i), !Q(Ue(), n)), F = (r, i, u) => Ar(r, v, {
540
- ...g.mount ? l : w(i) ? n : H(r) ? { [r]: i } : i
541
- }, u, i), E = (r) => Ve(d(g.mount ? l : n, r, e.shouldUnregister ? d(n, r, []) : [])), O = (r, i, u = {}) => {
542
- const c = d(a, r);
543
- let f = i;
544
- if (c) {
545
- const o = c._f;
546
- o && (!o.disabled && A(l, r, lr(i, o)), f = he(o.ref) && L(i) ? "" : i, sr(o.ref) ? [...o.ref.options].forEach((y) => y.selected = f.includes(y.value)) : o.refs ? oe(o.ref) ? o.refs.length > 1 ? o.refs.forEach((y) => (!y.defaultChecked || !y.disabled) && (y.checked = Array.isArray(f) ? !!f.find((V) => V === y.value) : f === y.value)) : o.refs[0] && (o.refs[0].checked = !!f) : o.refs.forEach((y) => y.checked = y.value === f) : Le(o.ref) ? o.ref.value = "" : (o.ref.value = f, o.ref.type || _.values.next({
547
- name: r,
548
- values: { ...l }
549
- })));
550
- }
551
- (u.shouldDirty || u.shouldTouch) && ee(r, f, u.shouldTouch, u.shouldDirty, !0), u.shouldValidate && le(r);
552
- }, I = (r, i, u) => {
553
- for (const c in i) {
554
- const f = i[c], o = `${r}.${c}`, y = d(a, o);
555
- (v.array.has(r) || !be(f) || y && !y._f) && !se(f) ? I(o, f, u) : O(o, f, u);
556
- }
557
- }, R = (r, i, u = {}) => {
558
- const c = d(a, r), f = v.array.has(r), o = M(i);
559
- A(l, r, o), f ? (_.array.next({
560
- name: r,
561
- values: { ...l }
562
- }), (x.isDirty || x.dirtyFields) && u.shouldDirty && _.state.next({
563
- name: r,
564
- dirtyFields: ye(n, l),
565
- isDirty: h(r, o)
566
- })) : c && !c._f && !L(o) ? I(r, o, u) : O(r, o, u), je(r, v) && _.state.next({ ...t }), _.values.next({
567
- name: g.mount ? r : void 0,
568
- values: { ...l }
569
- });
570
- }, ie = async (r) => {
571
- g.mount = !0;
572
- const i = r.target;
573
- let u = i.name, c = !0;
574
- const f = d(a, u), o = () => i.type ? Se(f._f) : gr(r), y = (V) => {
575
- c = Number.isNaN(V) || Q(V, d(l, u, V));
576
- };
577
- if (f) {
578
- let V, S;
579
- const T = o(), Z = r.type === He.BLUR || r.type === He.FOCUS_OUT, cr = !Tr(f._f) && !s.resolver && !d(t.errors, u) && !f._f.deps || Or(Z, d(t.touchedFields, u), t.isSubmitted, G, fe), De = je(u, v, Z);
580
- A(l, u, T), Z ? (f._f.onBlur && f._f.onBlur(r), P && P(0)) : f._f.onChange && f._f.onChange(r);
581
- const me = ee(u, T, Z, !1), dr = !C(me) || De;
582
- if (!Z && _.values.next({
583
- name: u,
584
- type: r.type,
585
- values: { ...l }
586
- }), cr)
587
- return x.isValid && (e.mode === "onBlur" ? Z && $() : $()), dr && _.state.next({ name: u, ...De ? {} : me });
588
- if (!Z && De && _.state.next({ ...t }), s.resolver) {
589
- const { errors: qe } = await X([u]);
590
- if (y(T), c) {
591
- const yr = Xe(t.errors, a, u), We = Xe(qe, a, yr.name || u);
592
- V = We.error, u = We.name, S = C(qe);
593
- }
594
- } else
595
- J([u], !0), V = (await Je(f, l, U, s.shouldUseNativeValidation))[u], J([u]), y(T), c && (V ? S = !1 : x.isValid && (S = await N(a, !0)));
596
- c && (f._f.deps && le(f._f.deps), ce(u, S, V, me));
597
- }
598
- }, ue = (r, i) => {
599
- if (d(t.errors, i) && r.focus)
600
- return r.focus(), 1;
601
- }, le = async (r, i = {}) => {
602
- let u, c;
603
- const f = ge(r);
604
- if (s.resolver) {
605
- const o = await re(w(r) ? r : f);
606
- u = C(o), c = r ? !f.some((y) => d(o, y)) : u;
607
- } else r ? (c = (await Promise.all(f.map(async (o) => {
608
- const y = d(a, o);
609
- return await N(y && y._f ? { [o]: y } : y);
610
- }))).every(Boolean), !(!c && !t.isValid) && $()) : c = u = await N(a);
611
- return _.state.next({
612
- ...!H(r) || x.isValid && u !== t.isValid ? {} : { name: r },
613
- ...s.resolver || !r ? { isValid: u } : {},
614
- errors: t.errors
615
- }), i.shouldFocus && !c && ne(a, ue, r ? f : v.mount), c;
616
- }, Ue = (r) => {
617
- const i = {
618
- ...g.mount ? l : n
619
- };
620
- return w(r) ? i : H(r) ? d(i, r) : r.map((u) => d(i, u));
621
- }, Ne = (r, i) => ({
622
- invalid: !!d((i || t).errors, r),
623
- isDirty: !!d((i || t).dirtyFields, r),
624
- error: d((i || t).errors, r),
625
- isValidating: !!d(t.validatingFields, r),
626
- isTouched: !!d((i || t).touchedFields, r)
627
- }), ar = (r) => {
628
- r && ge(r).forEach((i) => k(t.errors, i)), _.state.next({
629
- errors: r ? t.errors : {}
630
- });
631
- }, Re = (r, i, u) => {
632
- const c = (d(a, r, { _f: {} })._f || {}).ref, f = d(t.errors, r) || {}, { ref: o, message: y, type: V, ...S } = f;
633
- A(t.errors, r, {
634
- ...S,
635
- ...i,
636
- ref: c
637
- }), _.state.next({
638
- name: r,
639
- errors: t.errors,
640
- isValid: !1
641
- }), u && u.shouldFocus && c && c.focus && c.focus();
642
- }, nr = (r, i) => z(r) ? _.values.subscribe({
643
- next: (u) => r(F(void 0, i), u)
644
- }) : F(r, i, !0), xe = (r, i = {}) => {
645
- for (const u of r ? ge(r) : v.mount)
646
- v.mount.delete(u), v.array.delete(u), i.keepValue || (k(a, u), k(l, u)), !i.keepError && k(t.errors, u), !i.keepDirty && k(t.dirtyFields, u), !i.keepTouched && k(t.touchedFields, u), !i.keepIsValidating && k(t.validatingFields, u), !s.shouldUnregister && !i.keepDefaultValue && k(n, u);
647
- _.values.next({
648
- values: { ...l }
649
- }), _.state.next({
650
- ...t,
651
- ...i.keepDirty ? { isDirty: h() } : {}
652
- }), !i.keepIsValid && $();
653
- }, Me = ({ disabled: r, name: i, field: u, fields: c, value: f }) => {
654
- if (W(r) && g.mount || r) {
655
- const o = r ? void 0 : w(f) ? Se(u ? u._f : d(c, i)._f) : f;
656
- A(l, i, o), ee(i, o, !1, !1, !0);
657
- }
658
- }, we = (r, i = {}) => {
659
- let u = d(a, r);
660
- const c = W(i.disabled) || W(e.disabled);
661
- return A(a, r, {
662
- ...u || {},
663
- _f: {
664
- ...u && u._f ? u._f : { ref: { name: r } },
665
- name: r,
666
- mount: !0,
667
- ...i
668
- }
669
- }), v.mount.add(r), u ? Me({
670
- field: u,
671
- disabled: W(i.disabled) ? i.disabled : e.disabled,
672
- name: r,
673
- value: i.value
674
- }) : m(r, !0, i.value), {
675
- ...c ? { disabled: i.disabled || e.disabled } : {},
676
- ...s.progressive ? {
677
- required: !!i.required,
678
- min: ae(i.min),
679
- max: ae(i.max),
680
- minLength: ae(i.minLength),
681
- maxLength: ae(i.maxLength),
682
- pattern: ae(i.pattern)
683
- } : {},
684
- name: r,
685
- onChange: ie,
686
- onBlur: ie,
687
- ref: (f) => {
688
- if (f) {
689
- we(r, i), u = d(a, r);
690
- const o = w(f.value) && f.querySelectorAll && f.querySelectorAll("input,select,textarea")[0] || f, y = Er(o), V = u._f.refs || [];
691
- if (y ? V.find((S) => S === o) : o === u._f.ref)
692
- return;
693
- A(a, r, {
694
- _f: {
695
- ...u._f,
696
- ...y ? {
697
- refs: [
698
- ...V.filter(ke),
699
- o,
700
- ...Array.isArray(d(n, r)) ? [{}] : []
701
- ],
702
- ref: { type: o.type, name: r }
703
- } : { ref: o }
704
- }
705
- }), m(r, !1, void 0, o);
706
- } else
707
- u = d(a, r, {}), u._f && (u._f.mount = !1), (s.shouldUnregister || i.shouldUnregister) && !(hr(v.array, r) && g.action) && v.unMount.add(r);
708
- }
709
- };
710
- }, Be = () => s.shouldFocusError && ne(a, ue, v.mount), or = (r) => {
711
- W(r) && (_.state.next({ disabled: r }), ne(a, (i, u) => {
712
- const c = d(a, u);
713
- c && (i.disabled = c._f.disabled || r, Array.isArray(c._f.refs) && c._f.refs.forEach((f) => {
714
- f.disabled = c._f.disabled || r;
715
- }));
716
- }, 0, !1));
717
- }, Pe = (r, i) => async (u) => {
718
- let c;
719
- u && (u.preventDefault && u.preventDefault(), u.persist && u.persist());
720
- let f = M(l);
721
- if (_.state.next({
722
- isSubmitting: !0
723
- }), s.resolver) {
724
- const { errors: o, values: y } = await X();
725
- t.errors = o, f = y;
726
- } else
727
- await N(a);
728
- if (k(t.errors, "root"), C(t.errors)) {
729
- _.state.next({
730
- errors: {}
731
- });
732
- try {
733
- await r(f, u);
734
- } catch (o) {
735
- c = o;
736
- }
737
- } else
738
- i && await i({ ...t.errors }, u), Be(), setTimeout(Be);
739
- if (_.state.next({
740
- isSubmitted: !0,
741
- isSubmitting: !1,
742
- isSubmitSuccessful: C(t.errors) && !c,
743
- submitCount: t.submitCount + 1,
744
- errors: t.errors
745
- }), c)
746
- throw c;
747
- }, fr = (r, i = {}) => {
748
- d(a, r) && (w(i.defaultValue) ? R(r, M(d(n, r))) : (R(r, i.defaultValue), A(n, r, M(i.defaultValue))), i.keepTouched || k(t.touchedFields, r), i.keepDirty || (k(t.dirtyFields, r), t.isDirty = i.defaultValue ? h(r, M(d(n, r))) : h()), i.keepError || (k(t.errors, r), x.isValid && $()), _.state.next({ ...t }));
749
- }, Ie = (r, i = {}) => {
750
- const u = r ? M(r) : n, c = M(u), f = C(r), o = f ? n : c;
751
- if (i.keepDefaultValues || (n = u), !i.keepValues) {
752
- if (i.keepDirtyValues)
753
- for (const y of v.mount)
754
- d(t.dirtyFields, y) ? A(o, y, d(l, y)) : R(y, d(o, y));
755
- else {
756
- if (Te && w(r))
757
- for (const y of v.mount) {
758
- const V = d(a, y);
759
- if (V && V._f) {
760
- const S = Array.isArray(V._f.refs) ? V._f.refs[0] : V._f.ref;
761
- if (he(S)) {
762
- const T = S.closest("form");
763
- if (T) {
764
- T.reset();
765
- break;
766
- }
767
- }
768
- }
769
- }
770
- a = {};
771
- }
772
- l = e.shouldUnregister ? i.keepDefaultValues ? M(n) : {} : M(o), _.array.next({
773
- values: { ...o }
774
- }), _.values.next({
775
- values: { ...o }
776
- });
777
- }
778
- v = {
779
- mount: i.keepDirtyValues ? v.mount : /* @__PURE__ */ new Set(),
780
- unMount: /* @__PURE__ */ new Set(),
781
- array: /* @__PURE__ */ new Set(),
782
- watch: /* @__PURE__ */ new Set(),
783
- watchAll: !1,
784
- focus: ""
785
- }, g.mount = !x.isValid || !!i.keepIsValid || !!i.keepDirtyValues, g.watch = !!e.shouldUnregister, _.state.next({
786
- submitCount: i.keepSubmitCount ? t.submitCount : 0,
787
- isDirty: f ? !1 : i.keepDirty ? t.isDirty : !!(i.keepDefaultValues && !Q(r, n)),
788
- isSubmitted: i.keepIsSubmitted ? t.isSubmitted : !1,
789
- dirtyFields: f ? {} : i.keepDirtyValues ? i.keepDefaultValues && l ? ye(n, l) : t.dirtyFields : i.keepDefaultValues && r ? ye(n, r) : i.keepDirty ? t.dirtyFields : {},
790
- touchedFields: i.keepTouched ? t.touchedFields : {},
791
- errors: i.keepErrors ? t.errors : {},
792
- isSubmitSuccessful: i.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
793
- isSubmitting: !1
794
- });
795
- }, pe = (r, i) => Ie(z(r) ? r(l) : r, i);
796
- return {
797
- control: {
798
- register: we,
799
- unregister: xe,
800
- getFieldState: Ne,
801
- handleSubmit: Pe,
802
- setError: Re,
803
- _executeSchema: X,
804
- _getWatch: F,
805
- _getDirty: h,
806
- _updateValid: $,
807
- _removeUnmounted: de,
808
- _updateFieldArray: b,
809
- _updateDisabledField: Me,
810
- _getFieldArray: E,
811
- _reset: Ie,
812
- _resetDefaultValues: () => z(s.defaultValues) && s.defaultValues().then((r) => {
813
- pe(r, s.resetOptions), _.state.next({
814
- isLoading: !1
815
- });
816
- }),
817
- _updateFormState: (r) => {
818
- t = {
819
- ...t,
820
- ...r
821
- };
822
- },
823
- _disableForm: or,
824
- _subjects: _,
825
- _proxyFormState: x,
826
- _setErrors: K,
827
- get _fields() {
828
- return a;
829
- },
830
- get _formValues() {
831
- return l;
832
- },
833
- get _state() {
834
- return g;
835
- },
836
- set _state(r) {
837
- g = r;
838
- },
839
- get _defaultValues() {
840
- return n;
841
- },
842
- get _names() {
843
- return v;
844
- },
845
- set _names(r) {
846
- v = r;
847
- },
848
- get _formState() {
849
- return t;
850
- },
851
- set _formState(r) {
852
- t = r;
853
- },
854
- get _options() {
855
- return s;
856
- },
857
- set _options(r) {
858
- s = {
859
- ...s,
860
- ...r
861
- };
862
- }
863
- },
864
- trigger: le,
865
- register: we,
866
- handleSubmit: Pe,
867
- watch: nr,
868
- setValue: R,
869
- getValues: Ue,
870
- reset: pe,
871
- resetField: fr,
872
- clearErrors: ar,
873
- unregister: xe,
874
- setError: Re,
875
- setFocus: (r, i = {}) => {
876
- const u = d(a, r), c = u && u._f;
877
- if (c) {
878
- const f = c.refs ? c.refs[0] : c.ref;
879
- f.focus && (f.focus(), i.shouldSelect && f.select());
880
- }
881
- },
882
- getFieldState: Ne
883
- };
884
- }
885
- function Pr(e = {}) {
886
- const s = B.useRef(), t = B.useRef(), [a, n] = B.useState({
887
- isDirty: !1,
888
- isValidating: !1,
889
- isLoading: z(e.defaultValues),
890
- isSubmitted: !1,
891
- isSubmitting: !1,
892
- isSubmitSuccessful: !1,
893
- isValid: !1,
894
- submitCount: 0,
895
- dirtyFields: {},
896
- touchedFields: {},
897
- validatingFields: {},
898
- errors: e.errors || {},
899
- disabled: e.disabled || !1,
900
- defaultValues: z(e.defaultValues) ? void 0 : e.defaultValues
901
- });
902
- s.current || (s.current = {
903
- ...Ur(e),
904
- formState: a
905
- });
906
- const l = s.current.control;
907
- return l._options = e, Vr({
908
- subject: l._subjects.state,
909
- next: (g) => {
910
- Fr(g, l._proxyFormState, l._updateFormState) && n({ ...l._formState });
911
- }
912
- }), B.useEffect(() => l._disableForm(e.disabled), [l, e.disabled]), B.useEffect(() => {
913
- if (l._proxyFormState.isDirty) {
914
- const g = l._getDirty();
915
- g !== a.isDirty && l._subjects.state.next({
916
- isDirty: g
917
- });
918
- }
919
- }, [l, a.isDirty]), B.useEffect(() => {
920
- e.values && !Q(e.values, t.current) ? (l._reset(e.values, l._options.resetOptions), t.current = e.values, n((g) => ({ ...g }))) : l._resetDefaultValues();
921
- }, [e.values, l]), B.useEffect(() => {
922
- e.errors && l._setErrors(e.errors);
923
- }, [e.errors, l]), B.useEffect(() => {
924
- l._state.mount || (l._updateValid(), l._state.mount = !0), l._state.watch && (l._state.watch = !1, l._subjects.state.next({ ...l._formState })), l._removeUnmounted();
925
- }), B.useEffect(() => {
926
- e.shouldUnregister && l._subjects.values.next({
927
- values: l._getWatch()
928
- });
929
- }, [e.shouldUnregister, l]), s.current.formState = br(a, l), s.current;
930
- }
931
- export {
932
- Pr as u
933
- };